Golang RADIUS implementation
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
Wijnand Modderman-Lenstra d357964116 Added an Authenticator client 3 år sedan
.travis.yml save 4 år sedan
AttributeType.go save 4 år sedan
LICENSE save 4 år sedan
PacketCode.go save 4 år sedan
README.md support specifying secret per client 4 år sedan
auth.go Added an Authenticator client 3 år sedan
avp.go Added an Authenticator client 3 år sedan
avp_test.go save 4 år sedan
client.go support specifying secret per client 4 år sedan
client_test.go support specifying secret per client 4 år sedan
eap.go save 4 år sedan
msChapv2.go save 4 år sedan
packet.go Added an Authenticator client 3 år sedan
packet_test.go save 4 år sedan
server.go support specifying secret per client 4 år sedan

README.md

a golang radius library

Build Status GoDoc docs examples Total views GitHub issues GitHub stars GitHub forks MIT License

This project forks from https://github.com/jessta/radius

document

example

package main

import (
	"fmt"
	"github.com/bronze1man/radius"
)

type radiusService struct{}

func (p radiusService) RadiusHandle(request *radius.Packet) *radius.Packet {
    // a pretty print of the request.
	fmt.Printf("[Authenticate] %s\n", request.String())
	npac := request.Reply()
	switch request.Code {
	case radius.AccessRequest:
	    // check username and password
		if request.GetUsername() == "a" && request.GetPassword() == "a" {
			npac.Code = radius.AccessAccept
			return npac
		} else {
			npac.Code = radius.AccessReject
			npac.AVPs = append(npac.AVPs, radius.AVP{Type: radius.ReplyMessage, Value: []byte("you dick!")})
			return npac
		}
	case radius.AccountingRequest:
	    // accounting start or end
		npac.Code = radius.AccountingResponse
		return npac
	default:
		npac.Code = radius.AccessAccept
		return npac
	}
}

func main() {
	s := radius.NewServer(":1812", "secret", radiusService{})

	// or you can convert it to a server that accept request 
	// from some host with different secret
	// cls := radius.NewClientList([]radius.Client{
	// 		radius.NewClient("127.0.0.1", "secret1"),
	// 		radius.NewClient("10.10.10.10", "secret2"),
	// })
	// s.WithClientList(cls)

	signalChan := make(chan os.Signal, 1)
	signal.Notify(signalChan, syscall.SIGINT, syscall.SIGTERM)
	errChan := make(chan error)
	go func() {
		fmt.Println("waiting for packets...")
		err := s.ListenAndServe()
		if err != nil {
			errChan <- err
		}
	}()
	select {
	case <-signalChan:
		log.Println("stopping server...")
		s.Stop()
	case err := <-errChan:
		log.Println("[ERR] %v", err.Error())
	}
}

implemented

  • a radius server can handle AccessRequest request from strongswan with ikev1-xauth-psk
  • a radius server can handle AccountingRequest request from strongswan with ikev1-xauth-psk

notice

  • A radius client has not been implement.
  • It works , but it is not stable.

reference

TODO

  • avpEapMessaget.Value error handle.
  • implement eap-MSCHAPV2 server side.
  • implement radius client side.