radius: github.com/bronze1man/radius Index | Files

package radius

import "github.com/bronze1man/radius"

Index

Package Files

AttributeType.go PacketCode.go avp.go avp_vendor.go client.go eap.go msChapv2.go packet.go server.go

Constants

const ACCOUNTING_PORT = 1813
const AUTH_PORT = 1812

Variables

var ErrMessageAuthenticatorCheckFail = fmt.Errorf("RADIUS Response-Authenticator verification failed")

type AVP Uses

type AVP struct {
    Type  AttributeType
    Value []byte
}

func (AVP) Copy Uses

func (a AVP) Copy() AVP

func (AVP) Decode Uses

func (a AVP) Decode(p *Packet) interface{}

func (AVP) Encode Uses

func (a AVP) Encode(b []byte) (n int, err error)

func (AVP) String Uses

func (a AVP) String() string

func (AVP) StringWithPacket Uses

func (a AVP) StringWithPacket(p *Packet) string

type AcctStatusTypeEnum Uses

type AcctStatusTypeEnum uint32
const (
    AcctStatusTypeEnumStart         AcctStatusTypeEnum = 1
    AcctStatusTypeEnumStop          AcctStatusTypeEnum = 2
    AcctStatusTypeEnumInterimUpdate AcctStatusTypeEnum = 3
    AcctStatusTypeEnumAccountingOn  AcctStatusTypeEnum = 7
    AcctStatusTypeEnumAccountingOff AcctStatusTypeEnum = 8
)

func (AcctStatusTypeEnum) String Uses

func (e AcctStatusTypeEnum) String() string

type AcctTerminateCauseEnum Uses

type AcctTerminateCauseEnum uint32
const (
    AcctTerminateCauseEnumUserRequest        AcctTerminateCauseEnum = 1
    AcctTerminateCauseEnumLostCarrier        AcctTerminateCauseEnum = 2
    AcctTerminateCauseEnumLostService        AcctTerminateCauseEnum = 3
    AcctTerminateCauseEnumIdleTimeout        AcctTerminateCauseEnum = 4
    AcctTerminateCauseEnumSessionTimout      AcctTerminateCauseEnum = 5
    AcctTerminateCauseEnumAdminReset         AcctTerminateCauseEnum = 6
    AcctTerminateCauseEnumAdminReboot        AcctTerminateCauseEnum = 7
    AcctTerminateCauseEnumPortError          AcctTerminateCauseEnum = 8
    AcctTerminateCauseEnumNASError           AcctTerminateCauseEnum = 9
    AcctTerminateCauseEnumNASRequest         AcctTerminateCauseEnum = 10
    AcctTerminateCauseEnumNASReboot          AcctTerminateCauseEnum = 11
    AcctTerminateCauseEnumPortUnneeded       AcctTerminateCauseEnum = 12
    AcctTerminateCauseEnumPortPreempted      AcctTerminateCauseEnum = 13
    AcctTerminateCauseEnumPortSuspended      AcctTerminateCauseEnum = 14
    AcctTerminateCauseEnumServiceUnavailable AcctTerminateCauseEnum = 15
    AcctTerminateCauseEnumCallbkack          AcctTerminateCauseEnum = 16
    AcctTerminateCauseEnumUserError          AcctTerminateCauseEnum = 17
    AcctTerminateCauseEnumHostRequest        AcctTerminateCauseEnum = 18
)

func (AcctTerminateCauseEnum) String Uses

func (e AcctTerminateCauseEnum) String() string

type AttributeType Uses

type AttributeType uint8
const (
    UserName          AttributeType = iota //1
    UserPassword      AttributeType = iota //2
    CHAPPassword      AttributeType = iota //3
    NASIPAddress      AttributeType = iota //4
    NASPort           AttributeType = iota //5
    ServiceType       AttributeType = iota //6
    FramedProtocol    AttributeType = iota //7
    FramedIPAddress   AttributeType = iota //8
    FramedIPNetmask   AttributeType = iota //9
    FramedRouting     AttributeType = iota //10
    FilterId          AttributeType = iota //11
    FramedMTU         AttributeType = iota //12
    FramedCompression AttributeType = iota //13
    LoginIPHost       AttributeType = iota //14
    LoginService      AttributeType = iota //15
    LoginTCPPort      AttributeType = iota //16

    ReplyMessage   AttributeType = iota //18
    CallbackNumber AttributeType = iota //19
    CallbackId     AttributeType = iota //20

    FramedRoute            AttributeType = iota //22
    FramedIPXNetwork       AttributeType = iota //23
    State                  AttributeType = iota //24
    Class                  AttributeType = iota //25
    VendorSpecific         AttributeType = iota
    SessionTimeout         AttributeType = iota
    IdleTimeout            AttributeType = iota
    TerminationAction      AttributeType = iota
    CalledStationId        AttributeType = iota
    CallingStationId       AttributeType = iota
    NASIdentifier          AttributeType = iota
    ProxyState             AttributeType = iota
    LoginLATService        AttributeType = iota
    LoginLATNode           AttributeType = iota
    LoginLATGroup          AttributeType = iota
    FramedAppleTalkLink    AttributeType = iota
    FramedAppleTalkNetwork AttributeType = iota
    FramedAppleTalkZone    AttributeType = iota
    AcctStatusType         AttributeType = iota
    AcctDelayTime          AttributeType = iota
    AcctInputOctets        AttributeType = iota
    AcctOutputOctets       AttributeType = iota
    AcctSessionId          AttributeType = iota
    AcctAuthentic          AttributeType = iota
    AcctSessionTime        AttributeType = iota
    AcctInputPackets       AttributeType = iota
    AcctOutputPackets      AttributeType = iota
    AcctTerminateCause     AttributeType = iota
    AcctMultiSessionId     AttributeType = iota
    AcctLinkCount          AttributeType = iota
    AcctInputGigawords     AttributeType = iota //52
    AcctOutputGigawords    AttributeType = iota
    Unassigned1            AttributeType = iota
    EventTimestamp         AttributeType = iota
    EgressVLANID           AttributeType = iota
    IngressFilters         AttributeType = iota
    EgressVLANName         AttributeType = iota
    UserPriorityTable      AttributeType = iota //59
    CHAPChallenge          AttributeType = 60
    NASPortType            AttributeType = 61
    PortLimit              AttributeType = 62
    LoginLATPort           AttributeType = 63
    //end rfc2865 rfc 2866
    TunnelType                   AttributeType = iota
    TunnelMediumType             AttributeType = iota
    TunnelClientEndpoint         AttributeType = iota
    TunnelServerEndpoint         AttributeType = iota
    AcctTunnelConnection         AttributeType = iota
    TunnelPassword               AttributeType = iota
    ARAPPassword                 AttributeType = iota
    ARAPFeatures                 AttributeType = iota
    ARAPZoneAccess               AttributeType = iota
    ARAPSecurity                 AttributeType = iota
    ARAPSecurityData             AttributeType = iota
    PasswordRetry                AttributeType = iota
    Prompt                       AttributeType = iota
    ConnectInfo                  AttributeType = iota
    ConfigurationToken           AttributeType = iota
    EAPMessage                   AttributeType = iota
    MessageAuthenticator         AttributeType = iota
    TunnelPrivateGroupID         AttributeType = iota
    TunnelAssignmentID           AttributeType = iota
    TunnelPreference             AttributeType = iota
    ARAPChallengeResponse        AttributeType = iota
    AcctInterimInterval          AttributeType = iota
    AcctTunnelPacketsLost        AttributeType = iota
    NASPortId                    AttributeType = iota
    FramedPool                   AttributeType = iota
    CUI                          AttributeType = iota
    TunnelClientAuthID           AttributeType = iota
    TunnelServerAuthID           AttributeType = iota
    NASFilterRule                AttributeType = iota
    Unassigned                   AttributeType = iota
    OriginatingLineInfo          AttributeType = iota
    NASIPv6Address               AttributeType = iota
    FramedInterfaceId            AttributeType = iota
    FramedIPv6Prefix             AttributeType = iota
    LoginIPv6Host                AttributeType = iota
    FramedIPv6Route              AttributeType = iota
    FramedIPv6Pool               AttributeType = iota
    ErrorCause                   AttributeType = iota
    EAPKeyName                   AttributeType = iota
    DigestResponse               AttributeType = iota
    DigestRealm                  AttributeType = iota
    DigestNonce                  AttributeType = iota
    DigestResponseAuth           AttributeType = iota
    DigestNextnonce              AttributeType = iota
    DigestMethod                 AttributeType = iota
    DigestURI                    AttributeType = iota
    DigestQop                    AttributeType = iota
    DigestAlgorithm              AttributeType = iota
    DigestEntityBodyHash         AttributeType = iota
    DigestCNonce                 AttributeType = iota
    DigestNonceCount             AttributeType = iota
    DigestUsername               AttributeType = iota
    DigestOpaque                 AttributeType = iota
    DigestAuthParam              AttributeType = iota
    DigestAKAAuts                AttributeType = iota
    DigestDomain                 AttributeType = iota
    DigestStale                  AttributeType = iota
    DigestHA1                    AttributeType = iota
    SIPAOR                       AttributeType = iota
    DelegatedIPv6Prefix          AttributeType = iota
    MIP6FeatureVector            AttributeType = iota
    MIP6HomeLinkPrefix           AttributeType = iota
    OperatorName                 AttributeType = iota
    LocationInformation          AttributeType = iota
    LocationData                 AttributeType = iota
    BasicLocationPolicyRules     AttributeType = iota
    ExtendedLocationPolicyRules  AttributeType = iota
    LocationCapable              AttributeType = iota
    RequestedLocationInfo        AttributeType = iota
    FramedManagementProtocol     AttributeType = iota
    ManagementTransportProtectio AttributeType = iota
    ManagementPolicyId           AttributeType = iota
    ManagementPrivilegeLevel     AttributeType = iota
    PKMSSCert                    AttributeType = iota
    PKMCACert                    AttributeType = iota
    PKMConfigSettings            AttributeType = iota
    PKMCryptosuiteList           AttributeType = iota
    PKMSAID                      AttributeType = iota
    PKMSADescriptor              AttributeType = iota
    PKMAuthKey                   AttributeType = iota
    DSLiteTunnelName             AttributeType = iota
    MobileNodeIdentifier         AttributeType = iota
    ServiceSelection             AttributeType = iota
    PMIP6HomeLMAIPv6Address      AttributeType = iota
    PMIP6VisitedLMAIPv6Address   AttributeType = iota
    PMIP6HomeLMAIPv4Address      AttributeType = iota
    PMIP6VisitedLMAIPv4Address   AttributeType = iota
    PMIP6HomeHNPrefix            AttributeType = iota
    PMIP6VisitedHNPrefix         AttributeType = iota
    PMIP6HomeInterfaceID         AttributeType = iota
    PMIP6VisitedInterfaceID      AttributeType = iota
    PMIP6HomeIPv4HoA             AttributeType = iota
    PMIP6VisitedIPv4HoA          AttributeType = iota
    PMIP6HomeDHCP4ServerAddress  AttributeType = iota
    PMIP6VisitedDHCP4ServerAddre AttributeType = iota
    PMIP6HomeDHCP6ServerAddress  AttributeType = iota
    PMIP6VisitedDHCP6ServerAddre AttributeType = iota
    UnassignedStart              AttributeType = 161
    UnassignedEnd                AttributeType = 191

    ExperimentalStart           AttributeType = 192
    ExperimentalEnd             AttributeType = 223
    ImplementationSpecificStart AttributeType = 224
    ImplementationSpecificEnd   AttributeType = 240
    ReservedStart               AttributeType = 241
    ReservedEnd                 AttributeType = 254
)

func (AttributeType) String Uses

func (a AttributeType) String() string

type Client Uses

type Client interface {
    // GetHost get the client host
    GetHost() string
    // GetSecret get shared secret
    GetSecret() string
}

Client represent a client to connect to radius server

func NewClient Uses

func NewClient(host, secret string) Client

NewClient return new client

type ClientList Uses

type ClientList struct {
    sync.RWMutex
    // contains filtered or unexported fields
}

ClientList are list of client allowed to communicate with server

func NewClientList Uses

func NewClientList(cs []Client) *ClientList

func (*ClientList) AddOrUpdate Uses

func (cls *ClientList) AddOrUpdate(cl Client)

Add new client or reset existing client based on host

func (*ClientList) Get Uses

func (cls *ClientList) Get(host string) Client

Get client from list of clients based on host

func (*ClientList) GetHerd Uses

func (cls *ClientList) GetHerd() []Client

func (*ClientList) Remove Uses

func (cls *ClientList) Remove(host string)

Remove client based on host

func (*ClientList) SetHerd Uses

func (cls *ClientList) SetHerd(herd []Client)

SetHerd reset/initialize the herd of clients

type DefaultClient Uses

type DefaultClient struct {
    Host   string
    Secret string
}

DefaultClient is default client implementation

func (*DefaultClient) GetHost Uses

func (cl *DefaultClient) GetHost() string

GetHost get the client host

func (*DefaultClient) GetSecret Uses

func (cl *DefaultClient) GetSecret() string

GetSecret get shared secret

type EapCode Uses

type EapCode uint8
const (
    EapCodeRequest  EapCode = 1
    EapCodeResponse EapCode = 2
    EapCodeSuccess  EapCode = 3
    EapCodeFailure  EapCode = 4
)

func (EapCode) String Uses

func (c EapCode) String() string

type EapPacket Uses

type EapPacket struct {
    Code       EapCode
    Identifier uint8
    Type       EapType
    Data       []byte
}

func EapDecode Uses

func EapDecode(b []byte) (eap *EapPacket, err error)

func (*EapPacket) Copy Uses

func (a *EapPacket) Copy() *EapPacket

func (*EapPacket) Encode Uses

func (a *EapPacket) Encode() (b []byte)

func (*EapPacket) String Uses

func (a *EapPacket) String() string

func (*EapPacket) ToEAPMessage Uses

func (a *EapPacket) ToEAPMessage() *AVP

type EapType Uses

type EapType uint8
const (
    EapTypeIdentity         EapType = 1
    EapTypeNotification     EapType = 2
    EapTypeNak              EapType = 3 //Response only
    EapTypeMd5Challenge     EapType = 4
    EapTypeOneTimePassword  EapType = 5 //otp
    EapTypeGenericTokenCard EapType = 6 //gtc
    EapTypeMSCHAPV2         EapType = 26
    EapTypeExpandedTypes    EapType = 254
    EapTypeExperimentalUse  EapType = 255
)

func (EapType) String Uses

func (c EapType) String() string

type MsChapV2OpCode Uses

type MsChapV2OpCode uint8
const (
    MsChapV2OpCodeChallenge      MsChapV2OpCode = 1
    MsChapV2OpCodeResponse       MsChapV2OpCode = 2
    MsChapV2OpCodeSuccess        MsChapV2OpCode = 3
    MsChapV2OpCodeFailure        MsChapV2OpCode = 4
    MsChapV2OpCodeChangePassword MsChapV2OpCode = 7
)

func (MsChapV2OpCode) String Uses

func (c MsChapV2OpCode) String() string

type MsChapV2Packet Uses

type MsChapV2Packet struct {
    Eap    *EapPacket //解密的时候的eap信息,不使用里面的data
    OpCode MsChapV2OpCode
    Data   []byte
}

func MsChapV2PacketFromEap Uses

func MsChapV2PacketFromEap(eap *EapPacket) (p *MsChapV2Packet, err error)

func (*MsChapV2Packet) String Uses

func (p *MsChapV2Packet) String() string

不包括eap的信息

func (*MsChapV2Packet) ToEap Uses

func (p *MsChapV2Packet) ToEap() *EapPacket

type NASPortTypeEnum Uses

type NASPortTypeEnum uint32
const (
    NASPortTypeEnumAsync            NASPortTypeEnum = 0
    NASPortTypeEnumSync             NASPortTypeEnum = 1
    NASPortTypeEnumISDNSync         NASPortTypeEnum = 2
    NASPortTypeEnumISDNSyncV120     NASPortTypeEnum = 3
    NASPortTypeEnumISDNSyncV110     NASPortTypeEnum = 4
    NASPortTypeEnumVirtual          NASPortTypeEnum = 5
    NASPortTypeEnumPIAFS            NASPortTypeEnum = 6
    NASPortTypeEnumHDLCClearChannel NASPortTypeEnum = 7
    NASPortTypeEnumEthernet         NASPortTypeEnum = 15
    NASPortTypeEnumCable            NASPortTypeEnum = 17
)

TODO finish it

func (NASPortTypeEnum) String Uses

func (e NASPortTypeEnum) String() string

type Packet Uses

type Packet struct {
    Secret        string
    Code          PacketCode
    Identifier    uint8
    Authenticator [16]byte
    AVPs          []AVP
    ClientAddr    string
}

func DecodePacket Uses

func DecodePacket(Secret string, buf []byte) (p *Packet, err error)

func (*Packet) AddAVP Uses

func (p *Packet) AddAVP(avp AVP)

func (*Packet) AddVSA Uses

func (p *Packet) AddVSA(vsa VSA)

func (*Packet) Copy Uses

func (p *Packet) Copy() *Packet

func (*Packet) DeleteAVP Uses

func (p *Packet) DeleteAVP(avp *AVP)

删除一个AVP Delete a AVP

func (*Packet) DeleteOneType Uses

func (p *Packet) DeleteOneType(attrType AttributeType)

delete all avps with this type

func (*Packet) Encode Uses

func (p *Packet) Encode() (b []byte, err error)

此方法保证不修改包的内容 This method does not modify the contents of the package to ensure

func (*Packet) GetAVP Uses

func (p *Packet) GetAVP(attrType AttributeType) *AVP

get one avp

func (*Packet) GetAcctSessionId Uses

func (p *Packet) GetAcctSessionId() string

func (*Packet) GetAcctStatusType Uses

func (p *Packet) GetAcctStatusType() AcctStatusTypeEnum

func (*Packet) GetAcctTotalInputOctets Uses

func (p *Packet) GetAcctTotalInputOctets() uint64

func (*Packet) GetAcctTotalOutputOctets Uses

func (p *Packet) GetAcctTotalOutputOctets() uint64

func (*Packet) GetCalledStationId Uses

func (p *Packet) GetCalledStationId() string

func (*Packet) GetCallingStationId Uses

func (p *Packet) GetCallingStationId() string

func (*Packet) GetEAPMessage Uses

func (p *Packet) GetEAPMessage() *EapPacket

func (*Packet) GetFramedIPAddress Uses

func (p *Packet) GetFramedIPAddress() (ip net.IP)

func (*Packet) GetNASIdentifier Uses

func (p *Packet) GetNASIdentifier() string

func (*Packet) GetNASPort Uses

func (p *Packet) GetNASPort() uint32

it is ike_id in strongswan client

func (*Packet) GetNASPortId Uses

func (p *Packet) GetNASPortId() string

func (*Packet) GetNasIpAddress Uses

func (p *Packet) GetNasIpAddress() (ip net.IP)

func (*Packet) GetPassword Uses

func (p *Packet) GetPassword() (password string)

func (*Packet) GetTerminateCause Uses

func (p *Packet) GetTerminateCause() string

func (*Packet) GetUsername Uses

func (p *Packet) GetUsername() (username string)

func (*Packet) GetVSA Uses

func (p *Packet) GetVSA(vendor uint32, attr uint8) *VSA

get one vsa

func (*Packet) HasAVP Uses

func (p *Packet) HasAVP(attrType AttributeType) bool

func (*Packet) Reply Uses

func (p *Packet) Reply() *Packet

func (*Packet) Send Uses

func (p *Packet) Send(c net.PacketConn, addr net.Addr) error

func (*Packet) SetAVP Uses

func (p *Packet) SetAVP(avp AVP)

set one avp,remove all other same type

func (*Packet) String Uses

func (p *Packet) String() string

type PacketCode Uses

type PacketCode uint8
const (
    AccessRequest      PacketCode = 1
    AccessAccept       PacketCode = 2
    AccessReject       PacketCode = 3
    AccountingRequest  PacketCode = 4
    AccountingResponse PacketCode = 5
    AccessChallenge    PacketCode = 11
    StatusServer       PacketCode = 12 //(experimental)
    StatusClient       PacketCode = 13 //(experimental)
    DisconnectRequest  PacketCode = 40
    DisconnectAccept   PacketCode = 41
    DisconnectReject   PacketCode = 42
    CoARequest         PacketCode = 43
    CoAAccept          PacketCode = 44
    CoaReject          PacketCode = 45
    Reserved           PacketCode = 255
)

func (PacketCode) String Uses

func (p PacketCode) String() string

type PasswordService Uses

type PasswordService struct{}

func (*PasswordService) Authenticate Uses

func (p *PasswordService) Authenticate(request *Packet) (*Packet, error)

type Server Uses

type Server struct {
    // contains filtered or unexported fields
}

func NewServer Uses

func NewServer(addr string, secret string, service Service) *Server

NewServer return a new Server given a addr, secret, and service

func (*Server) ListenAndServe Uses

func (s *Server) ListenAndServe() error

ListenAndServe listen on the UDP network address

func (*Server) Stop Uses

func (s *Server) Stop()

Stop will stop the server

func (*Server) WithClientList Uses

func (s *Server) WithClientList(cl *ClientList)

WithClientList set a list of clients that have it's own secret

type Service Uses

type Service interface {
    RadiusHandle(request *Packet) *Packet
}

type ServiceTypeEnum Uses

type ServiceTypeEnum uint32
const (
    ServiceTypeEnumLogin          ServiceTypeEnum = 1
    ServiceTypeEnumFramed         ServiceTypeEnum = 2
    ServiceTypeEnumCallbackLogin  ServiceTypeEnum = 3
    ServiceTypeEnumCallbackFramed ServiceTypeEnum = 4
    ServiceTypeEnumOutbound       ServiceTypeEnum = 5
)

TODO finish it

func (ServiceTypeEnum) String Uses

func (e ServiceTypeEnum) String() string

type VSA Uses

type VSA struct {
    Vendor uint32
    Type   uint8
    Value  []byte
}

Vendor

func (VSA) ToAVP Uses

func (vsa VSA) ToAVP() AVP

encode VSA attribute under Vendor-Specific AVP

Package radius imports 13 packages (graph) and is imported by 1 packages. Updated 2019-05-16. Refresh now. Tools for package owners.