radius

package module
v0.0.0-...-c900615 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 1, 2018 License: MPL-2.0 Imports: 13 Imported by: 0

README

radius

a Go (golang) RADIUS client and server implementation

The datatypes currently supported are:

type description
string ASCII string
ipaddr IPv4 address
date 32 bits UNIX
octets arbitrary binary data
ipv6addr 16 octets in network byte order
integer 32 bits unsigned number
signed 32 bits signed number
short 16 bits unsigned number
byte 8 bits unsigned number

Example

Parse packet

p, err := radius.Parse(request, secret)
if err != nil {
	t.Fatal(err)
}
// Get a attribute by name
if p.GetByName("User-Name").(string) != "nemo" {
	t.Fatal("expecting User-Name = nemo")
}
// Get a attribute by type
if p.Get(radius.AttrUserName).(string) != "nemo" {
	t.Fatal("expecting User-Name = nemo")
}

Build attributes with tags

attr := make(Attributes)
attr.Set(AttrTunnelPrivateGroupId.WithTag(1), []byte("test1"))
attr.Set(AttrTunnelPrivateGroupId.WithTag(2), []byte("test2"))
if attr.Get(AttrTunnelPrivateGroupId.WithTag(1)).(string) != "test1" {
	t.Fail()
}
if attr.Get(AttrTunnelPrivateGroupId.WithTag(2)).(string) != "test2" {
	t.Fail()
}

Builtin Dictionaries

  • dictionary.rfc2865
  • dictionary.rfc2866
  • dictionary.rfc2867
  • dictionary.rfc2868
  • dictionary.rfc2869
  • dictionary.rfc3162
  • dictionary.rfc3576
  • dictionary.rfc3580
  • dictionary.rfc4072
  • dictionary.rfc4372
  • dictionary.rfc4603
  • dictionary.rfc4675
  • dictionary.rfc4679 (partial)
  • dictionary.rfc4818
  • dictionary.rfc4849
  • dictionary.rfc5090
  • dictionary.rfc5176
  • dictionary.rfc5447
  • dictionary.rfc5580
  • dictionary.rfc5607
  • dictionary.rfc5904
  • dictionary.rfc6519
  • dictionary.rfc6572 (partial)
  • dictionary.rfc6677
  • dictionary.rfc6911
  • dictionary.rfc6930 (partial)
  • dictionary.rfc7055
  • dictionary.rfc7155
  • dictionary.rfc7268
  • dictionary.rfc7930

Documentation

Index

Constants

View Source
const (
	VENDOR_MASK uint64 = 0xFFFFFFFF << 32
	TAG_MASK    uint64 = 0xFF << 8
	TYPE_MASK   uint64 = 0xFF
)
View Source
const (
	TAG_NONE    = 0
	TAG_INTERGE = 1
	TAG_STRING  = 2
)
View Source
const (
	AttrUserName                                                     AttributeKey = 1
	AttrUserPassword                                                 AttributeKey = 2
	AttrCHAPPassword                                                 AttributeKey = 3
	AttrNASIPAddress                                                 AttributeKey = 4
	AttrNASPort                                                      AttributeKey = 5
	AttrServiceType                                                  AttributeKey = 6
	AttrFramedProtocol                                               AttributeKey = 7
	AttrFramedIPAddress                                              AttributeKey = 8
	AttrFramedIPNetmask                                              AttributeKey = 9
	AttrFramedRouting                                                AttributeKey = 10
	AttrFilterId                                                     AttributeKey = 11
	AttrFramedMTU                                                    AttributeKey = 12
	AttrFramedCompression                                            AttributeKey = 13
	AttrLoginIPHost                                                  AttributeKey = 14
	AttrLoginService                                                 AttributeKey = 15
	AttrLoginTCPPort                                                 AttributeKey = 16
	AttrReplyMessage                                                 AttributeKey = 18
	AttrCallbackNumber                                               AttributeKey = 19
	AttrCallbackId                                                   AttributeKey = 20
	AttrFramedRoute                                                  AttributeKey = 22
	AttrFramedIPXNetwork                                             AttributeKey = 23
	AttrState                                                        AttributeKey = 24
	AttrClass                                                        AttributeKey = 25
	AttrSessionTimeout                                               AttributeKey = 27
	AttrIdleTimeout                                                  AttributeKey = 28
	AttrTerminationAction                                            AttributeKey = 29
	AttrCalledStationId                                              AttributeKey = 30
	AttrCallingStationId                                             AttributeKey = 31
	AttrNASIdentifier                                                AttributeKey = 32
	AttrProxyState                                                   AttributeKey = 33
	AttrLoginLATService                                              AttributeKey = 34
	AttrLoginLATNode                                                 AttributeKey = 35
	AttrLoginLATGroup                                                AttributeKey = 36
	AttrFramedAppleTalkLink                                          AttributeKey = 37
	AttrFramedAppleTalkNetwork                                       AttributeKey = 38
	AttrFramedAppleTalkZone                                          AttributeKey = 39
	AttrAcctStatusType                                               AttributeKey = 40
	AttrAcctDelayTime                                                AttributeKey = 41
	AttrAcctInputOctets                                              AttributeKey = 42
	AttrAcctOutputOctets                                             AttributeKey = 43
	AttrAcctSessionId                                                AttributeKey = 44
	AttrAcctAuthentic                                                AttributeKey = 45
	AttrAcctSessionTime                                              AttributeKey = 46
	AttrAcctInputPackets                                             AttributeKey = 47
	AttrAcctOutputPackets                                            AttributeKey = 48
	AttrAcctTerminateCause                                           AttributeKey = 49
	AttrAcctMultiSessionId                                           AttributeKey = 50
	AttrAcctLinkCount                                                AttributeKey = 51
	AttrAcctInputGigawords                                           AttributeKey = 52
	AttrAcctOutputGigawords                                          AttributeKey = 53
	AttrEventTimestamp                                               AttributeKey = 55
	AttrEgressVLANID                                                 AttributeKey = 56
	AttrIngressFilters                                               AttributeKey = 57
	AttrEgressVLANName                                               AttributeKey = 58
	AttrUserPriorityTable                                            AttributeKey = 59
	AttrCHAPChallenge                                                AttributeKey = 60
	AttrNASPortType                                                  AttributeKey = 61
	AttrPortLimit                                                    AttributeKey = 62
	AttrLoginLATPort                                                 AttributeKey = 63
	AttrTunnelType                                                   AttributeKey = 64
	AttrTunnelMediumType                                             AttributeKey = 65
	AttrTunnelClientEndpoint                                         AttributeKey = 66
	AttrTunnelServerEndpoint                                         AttributeKey = 67
	AttrAcctTunnelConnection                                         AttributeKey = 68
	AttrTunnelPassword                                               AttributeKey = 69
	AttrARAPPassword                                                 AttributeKey = 70
	AttrARAPFeatures                                                 AttributeKey = 71
	AttrARAPZoneAccess                                               AttributeKey = 72
	AttrARAPSecurity                                                 AttributeKey = 73
	AttrARAPSecurityData                                             AttributeKey = 74
	AttrPasswordRetry                                                AttributeKey = 75
	AttrPrompt                                                       AttributeKey = 76
	AttrConnectInfo                                                  AttributeKey = 77
	AttrConfigurationToken                                           AttributeKey = 78
	AttrMessageAuthenticator                                         AttributeKey = 80
	AttrTunnelPrivateGroupId                                         AttributeKey = 81
	AttrTunnelAssignmentId                                           AttributeKey = 82
	AttrTunnelPreference                                             AttributeKey = 83
	AttrARAPChallengeResponse                                        AttributeKey = 84
	AttrAcctInterimInterval                                          AttributeKey = 85
	AttrAcctTunnelPacketsLost                                        AttributeKey = 86
	AttrNASPortId                                                    AttributeKey = 87
	AttrFramedPool                                                   AttributeKey = 88
	AttrChargeableUserIdentity                                       AttributeKey = 89
	AttrTunnelClientAuthId                                           AttributeKey = 90
	AttrTunnelServerAuthId                                           AttributeKey = 91
	AttrNASFilterRule                                                AttributeKey = 92
	AttrOriginatingLineInfo                                          AttributeKey = 94
	AttrNASIPv6Address                                               AttributeKey = 95
	AttrFramedInterfaceId                                            AttributeKey = 96
	AttrFramedIPv6Prefix                                             AttributeKey = 97
	AttrLoginIPv6Host                                                AttributeKey = 98
	AttrFramedIPv6Route                                              AttributeKey = 99
	AttrFramedIPv6Pool                                               AttributeKey = 100
	AttrErrorCause                                                   AttributeKey = 101
	AttrEAPKeyName                                                   AttributeKey = 102
	AttrDigestResponse                                               AttributeKey = 103
	AttrDigestRealm                                                  AttributeKey = 104
	AttrDigestNonce                                                  AttributeKey = 105
	AttrDigestResponseAuth                                           AttributeKey = 106
	AttrDigestNextnonce                                              AttributeKey = 107
	AttrDigestMethod                                                 AttributeKey = 108
	AttrDigestURI                                                    AttributeKey = 109
	AttrDigestQop                                                    AttributeKey = 110
	AttrDigestAlgorithm                                              AttributeKey = 111
	AttrDigestEntityBodyHash                                         AttributeKey = 112
	AttrDigestCNonce                                                 AttributeKey = 113
	AttrDigestNonceCount                                             AttributeKey = 114
	AttrDigestUsername                                               AttributeKey = 115
	AttrDigestOpaque                                                 AttributeKey = 116
	AttrDigestAuthParam                                              AttributeKey = 117
	AttrDigestAKAAuts                                                AttributeKey = 118
	AttrDigestDomain                                                 AttributeKey = 119
	AttrDigestStale                                                  AttributeKey = 120
	AttrDigestHA1                                                    AttributeKey = 121
	AttrSIPAOR                                                       AttributeKey = 122
	AttrDelegatedIPv6Prefix                                          AttributeKey = 123
	AttrMIP6FeatureVector                                            AttributeKey = 124
	AttrMIP6HomeLinkPrefix                                           AttributeKey = 125
	AttrOperatorName                                                 AttributeKey = 126
	AttrLocationInformation                                          AttributeKey = 127
	AttrLocationData                                                 AttributeKey = 128
	AttrBasicLocationPolicyRules                                     AttributeKey = 129
	AttrExtendedLocationPolicyRules                                  AttributeKey = 130
	AttrLocationCapable                                              AttributeKey = 131
	AttrRequestedLocationInfo                                        AttributeKey = 132
	AttrFramedManagement                                             AttributeKey = 133
	AttrManagementTransportProtection                                AttributeKey = 134
	AttrManagementPolicyId                                           AttributeKey = 135
	AttrManagementPrivilegeLevel                                     AttributeKey = 136
	AttrPKMConfigSettings                                            AttributeKey = 139
	AttrPKMCryptosuiteList                                           AttributeKey = 140
	AttrPKMSAID                                                      AttributeKey = 141
	AttrPKMSADescriptor                                              AttributeKey = 142
	AttrPKMAuthKey                                                   AttributeKey = 143
	AttrDSLiteTunnelName                                             AttributeKey = 144
	AttrMobileNodeIdentifier                                         AttributeKey = 145
	AttrServiceSelection                                             AttributeKey = 146
	AttrPMIP6HomeLMAIPv6Address                                      AttributeKey = 147
	AttrPMIP6VisitedLMAIPv6Address                                   AttributeKey = 148
	AttrPMIP6HomeLMAIPv4Address                                      AttributeKey = 149
	AttrPMIP6VisitedLMAIPv4Address                                   AttributeKey = 150
	AttrPMIP6HomeHNPrefix                                            AttributeKey = 151
	AttrPMIP6VisitedHNPrefix                                         AttributeKey = 152
	AttrPMIP6HomeInterfaceID                                         AttributeKey = 153
	AttrPMIP6VisitedInterfaceID                                      AttributeKey = 154
	AttrPMIP6HomeDHCP4ServerAddress                                  AttributeKey = 157
	AttrPMIP6VisitedDHCP4ServerAddress                               AttributeKey = 158
	AttrPMIP6HomeDHCP6ServerAddress                                  AttributeKey = 159
	AttrPMIP6VisitedDHCP6ServerAddress                               AttributeKey = 160
	AttrPMIP6HomeIPv4Gateway                                         AttributeKey = 161
	AttrPMIP6VisitedIPv4Gateway                                      AttributeKey = 162
	AttrEAPLowerLayer                                                AttributeKey = 163
	AttrGSSAcceptorServiceName                                       AttributeKey = 164
	AttrGSSAcceptorHostName                                          AttributeKey = 165
	AttrGSSAcceptorServiceSpecifics                                  AttributeKey = 166
	AttrGSSAcceptorRealmName                                         AttributeKey = 167
	AttrFramedIPv6Address                                            AttributeKey = 168
	AttrDNSServerIPv6Address                                         AttributeKey = 169
	AttrRouteIPv6Information                                         AttributeKey = 170
	AttrDelegatedIPv6PrefixPool                                      AttributeKey = 171
	AttrStatefulIPv6AddressPool                                      AttributeKey = 172
	AttrAllowedCalledStationId                                       AttributeKey = 174
	AttrEAPPeerId                                                    AttributeKey = 175
	AttrEAPServerId                                                  AttributeKey = 176
	AttrMobilityDomainId                                             AttributeKey = 177
	AttrPreauthTimeout                                               AttributeKey = 178
	AttrNetworkIdName                                                AttributeKey = 179
	AttrWLANHESSID                                                   AttributeKey = 181
	AttrWLANVenueInfo                                                AttributeKey = 182
	AttrWLANVenueLanguage                                            AttributeKey = 183
	AttrWLANVenueName                                                AttributeKey = 184
	AttrWLANReasonCode                                               AttributeKey = 185
	AttrWLANPairwiseCipher                                           AttributeKey = 186
	AttrWLANGroupCipher                                              AttributeKey = 187
	AttrWLANAKMSuite                                                 AttributeKey = 188
	AttrWLANGroupMgmtCipher                                          AttributeKey = 189
	AttrWLANRFBand                                                   AttributeKey = 190
	AttrADSLAgentCircuitId                                           AttributeKey = 15294378541057
	AttrADSLAgentRemoteId                                            AttributeKey = 15294378541058
	AttrActualDataRateUpstream                                       AttributeKey = 15294378541185
	AttrActualDataRateDownstream                                     AttributeKey = 15294378541186
	AttrMinimumDataRateUpstream                                      AttributeKey = 15294378541187
	AttrMinimumDataRateDownstream                                    AttributeKey = 15294378541188
	AttrAttainableDataRateUpstream                                   AttributeKey = 15294378541189
	AttrAttainableDataRateDownstream                                 AttributeKey = 15294378541190
	AttrMaximumDataRateUpstream                                      AttributeKey = 15294378541191
	AttrMaximumDataRateDownstream                                    AttributeKey = 15294378541192
	AttrMinimumDataRateUpstreamLowPower                              AttributeKey = 15294378541193
	AttrMinimumDataRateDownstreamLowPower                            AttributeKey = 15294378541194
	AttrMaximumInterleavingDelayUpstream                             AttributeKey = 15294378541195
	AttrActualInterleavingDelayUpstream                              AttributeKey = 15294378541196
	AttrMaximumInterleavingDelayDownstream                           AttributeKey = 15294378541197
	AttrActualInterleavingDelayDownstream                            AttributeKey = 15294378541198
	AttrAccessLoopEncapsulation                                      AttributeKey = 15294378541200
	AttrIWFSession                                                   AttributeKey = 15294378541310
	VendorADSLForum                                                  uint32       = 3561
	ServiceType_LoginUser                                            uint32       = 1
	ServiceType_FramedUser                                           uint32       = 2
	ServiceType_CallbackLoginUser                                    uint32       = 3
	ServiceType_CallbackFramedUser                                   uint32       = 4
	ServiceType_OutboundUser                                         uint32       = 5
	ServiceType_AdministrativeUser                                   uint32       = 6
	ServiceType_NASPromptUser                                        uint32       = 7
	ServiceType_AuthenticateOnly                                     uint32       = 8
	ServiceType_CallbackNASPrompt                                    uint32       = 9
	ServiceType_CallCheck                                            uint32       = 10
	ServiceType_CallbackAdministrative                               uint32       = 11
	ServiceType_AuthorizeOnly                                        uint32       = 17
	ServiceType_FramedManagement                                     uint32       = 18
	FramedProtocol_PPP                                               uint32       = 1
	FramedProtocol_SLIP                                              uint32       = 2
	FramedProtocol_ARAP                                              uint32       = 3
	FramedProtocol_GandalfSLML                                       uint32       = 4
	FramedProtocol_XylogicsIPXSLIP                                   uint32       = 5
	FramedProtocol_X75Synchronous                                    uint32       = 6
	FramedRouting_None                                               uint32       = 0
	FramedRouting_Broadcast                                          uint32       = 1
	FramedRouting_Listen                                             uint32       = 2
	FramedRouting_BroadcastListen                                    uint32       = 3
	FramedCompression_None                                           uint32       = 0
	FramedCompression_VanJacobsonTCPIP                               uint32       = 1
	FramedCompression_IPXHeaderCompression                           uint32       = 2
	FramedCompression_StacLZS                                        uint32       = 3
	LoginService_Telnet                                              uint32       = 0
	LoginService_Rlogin                                              uint32       = 1
	LoginService_TCPClear                                            uint32       = 2
	LoginService_PortMaster                                          uint32       = 3
	LoginService_LAT                                                 uint32       = 4
	LoginService_X25PAD                                              uint32       = 5
	LoginService_X25T3POS                                            uint32       = 6
	LoginService_TCPClearQuiet                                       uint32       = 8
	LoginTCPPort_Telnet                                              uint32       = 23
	LoginTCPPort_Rlogin                                              uint32       = 513
	LoginTCPPort_Rsh                                                 uint32       = 514
	TerminationAction_Default                                        uint32       = 0
	TerminationAction_RADIUSRequest                                  uint32       = 1
	AcctStatusType_Start                                             uint32       = 1
	AcctStatusType_Stop                                              uint32       = 2
	AcctStatusType_InterimUpdate                                     uint32       = 3
	AcctStatusType_Alive                                             uint32       = 3
	AcctStatusType_AccountingOn                                      uint32       = 7
	AcctStatusType_AccountingOff                                     uint32       = 8
	AcctStatusType_TunnelStart                                       uint32       = 9
	AcctStatusType_TunnelStop                                        uint32       = 10
	AcctStatusType_TunnelReject                                      uint32       = 11
	AcctStatusType_TunnelLinkStart                                   uint32       = 12
	AcctStatusType_TunnelLinkStop                                    uint32       = 13
	AcctStatusType_TunnelLinkReject                                  uint32       = 14
	AcctStatusType_Failed                                            uint32       = 15
	AcctAuthentic_RADIUS                                             uint32       = 1
	AcctAuthentic_Local                                              uint32       = 2
	AcctAuthentic_Remote                                             uint32       = 3
	AcctAuthentic_Diameter                                           uint32       = 4
	AcctTerminateCause_UserRequest                                   uint32       = 1
	AcctTerminateCause_LostCarrier                                   uint32       = 2
	AcctTerminateCause_LostService                                   uint32       = 3
	AcctTerminateCause_IdleTimeout                                   uint32       = 4
	AcctTerminateCause_SessionTimeout                                uint32       = 5
	AcctTerminateCause_AdminReset                                    uint32       = 6
	AcctTerminateCause_AdminReboot                                   uint32       = 7
	AcctTerminateCause_PortError                                     uint32       = 8
	AcctTerminateCause_NASError                                      uint32       = 9
	AcctTerminateCause_NASRequest                                    uint32       = 10
	AcctTerminateCause_NASReboot                                     uint32       = 11
	AcctTerminateCause_PortUnneeded                                  uint32       = 12
	AcctTerminateCause_PortPreempted                                 uint32       = 13
	AcctTerminateCause_PortSuspended                                 uint32       = 14
	AcctTerminateCause_ServiceUnavailable                            uint32       = 15
	AcctTerminateCause_Callback                                      uint32       = 16
	AcctTerminateCause_UserError                                     uint32       = 17
	AcctTerminateCause_HostRequest                                   uint32       = 18
	AcctTerminateCause_SupplicantRestart                             uint32       = 19
	AcctTerminateCause_ReauthenticationFailure                       uint32       = 20
	AcctTerminateCause_PortReinit                                    uint32       = 21
	AcctTerminateCause_PortDisabled                                  uint32       = 22
	IngressFilters_Enabled                                           uint32       = 1
	IngressFilters_Disabled                                          uint32       = 2
	NASPortType_Async                                                uint32       = 0
	NASPortType_Sync                                                 uint32       = 1
	NASPortType_ISDN                                                 uint32       = 2
	NASPortType_ISDNV120                                             uint32       = 3
	NASPortType_ISDNV110                                             uint32       = 4
	NASPortType_Virtual                                              uint32       = 5
	NASPortType_PIAFS                                                uint32       = 6
	NASPortType_HDLCClearChannel                                     uint32       = 7
	NASPortType_X25                                                  uint32       = 8
	NASPortType_X75                                                  uint32       = 9
	NASPortType_G3Fax                                                uint32       = 10
	NASPortType_SDSL                                                 uint32       = 11
	NASPortType_ADSLCAP                                              uint32       = 12
	NASPortType_ADSLDMT                                              uint32       = 13
	NASPortType_IDSL                                                 uint32       = 14
	NASPortType_Ethernet                                             uint32       = 15
	NASPortType_xDSL                                                 uint32       = 16
	NASPortType_Cable                                                uint32       = 17
	NASPortType_WirelessOther                                        uint32       = 18
	NASPortType_Wireless80211                                        uint32       = 19
	NASPortType_TokenRing                                            uint32       = 20
	NASPortType_FDDI                                                 uint32       = 21
	NASPortType_PPPoA                                                uint32       = 30
	NASPortType_PPPoEoA                                              uint32       = 31
	NASPortType_PPPoEoE                                              uint32       = 32
	NASPortType_PPPoEoVLAN                                           uint32       = 33
	NASPortType_PPPoEoQinQ                                           uint32       = 34
	TunnelType_PPTP                                                  uint32       = 1
	TunnelType_L2F                                                   uint32       = 2
	TunnelType_L2TP                                                  uint32       = 3
	TunnelType_ATMP                                                  uint32       = 4
	TunnelType_VTP                                                   uint32       = 5
	TunnelType_AH                                                    uint32       = 6
	TunnelType_IP                                                    uint32       = 7
	TunnelType_MINIP                                                 uint32       = 8
	TunnelType_ESP                                                   uint32       = 9
	TunnelType_GRE                                                   uint32       = 10
	TunnelType_DVS                                                   uint32       = 11
	TunnelType_IPinIP                                                uint32       = 12
	TunnelType_VLAN                                                  uint32       = 13
	TunnelMediumType_IP                                              uint32       = 1
	TunnelMediumType_IPv4                                            uint32       = 1
	TunnelMediumType_IPv6                                            uint32       = 2
	TunnelMediumType_NSAP                                            uint32       = 3
	TunnelMediumType_HDLC                                            uint32       = 4
	TunnelMediumType_BBN1822                                         uint32       = 5
	TunnelMediumType_IEEE802                                         uint32       = 6
	TunnelMediumType_E163                                            uint32       = 7
	TunnelMediumType_E164                                            uint32       = 8
	TunnelMediumType_F69                                             uint32       = 9
	TunnelMediumType_X121                                            uint32       = 10
	TunnelMediumType_IPX                                             uint32       = 11
	TunnelMediumType_Appletalk                                       uint32       = 12
	TunnelMediumType_DecNetIV                                        uint32       = 13
	TunnelMediumType_BanyanVines                                     uint32       = 14
	TunnelMediumType_E164NSAP                                        uint32       = 15
	ARAPZoneAccess_DefaultZone                                       uint32       = 1
	ARAPZoneAccess_ZoneFilterInclusive                               uint32       = 2
	ARAPZoneAccess_ZoneFilterExclusive                               uint32       = 4
	Prompt_NoEcho                                                    uint32       = 0
	Prompt_Echo                                                      uint32       = 1
	ErrorCause_ResidualContextRemoved                                uint32       = 201
	ErrorCause_InvalidEAPPacket                                      uint32       = 202
	ErrorCause_UnsupportedAttribute                                  uint32       = 401
	ErrorCause_MissingAttribute                                      uint32       = 402
	ErrorCause_NASIdentificationMismatch                             uint32       = 403
	ErrorCause_InvalidRequest                                        uint32       = 404
	ErrorCause_UnsupportedService                                    uint32       = 405
	ErrorCause_UnsupportedExtension                                  uint32       = 406
	ErrorCause_InvalidAttributeValue                                 uint32       = 407
	ErrorCause_AdministrativelyProhibited                            uint32       = 501
	ErrorCause_ProxyRequestNotRoutable                               uint32       = 502
	ErrorCause_SessionContextNotFound                                uint32       = 503
	ErrorCause_SessionContextNotRemovable                            uint32       = 504
	ErrorCause_ProxyProcessingError                                  uint32       = 505
	ErrorCause_ResourcesUnavailable                                  uint32       = 506
	ErrorCause_RequestInitiated                                      uint32       = 507
	ErrorCause_MultipleSessionSelectionUnsupported                   uint32       = 508
	LocationCapable_CivicLocation                                    uint32       = 1
	LocationCapable_GeoLocation                                      uint32       = 2
	LocationCapable_UsersLocation                                    uint32       = 4
	LocationCapable_NASLocation                                      uint32       = 8
	RequestedLocationInfo_CivicLocation                              uint32       = 1
	RequestedLocationInfo_GeoLocation                                uint32       = 2
	RequestedLocationInfo_UsersLocation                              uint32       = 4
	RequestedLocationInfo_NASLocation                                uint32       = 8
	RequestedLocationInfo_FutureRequests                             uint32       = 16
	RequestedLocationInfo_None                                       uint32       = 32
	FramedManagement_SNMP                                            uint32       = 1
	FramedManagement_WebBased                                        uint32       = 2
	FramedManagement_Netconf                                         uint32       = 3
	FramedManagement_FTP                                             uint32       = 4
	FramedManagement_TFTP                                            uint32       = 5
	FramedManagement_SFTP                                            uint32       = 6
	FramedManagement_RCP                                             uint32       = 7
	FramedManagement_SCP                                             uint32       = 8
	ManagementTransportProtection_NoProtection                       uint32       = 1
	ManagementTransportProtection_IntegrityProtection                uint32       = 2
	ManagementTransportProtection_IntegrityConfidentialityProtection uint32       = 3
	EAPLowerLayer_WiredIEEE8021X                                     uint32       = 1
	EAPLowerLayer_IEEE8021XNoPreauth                                 uint32       = 2
	EAPLowerLayer_IEEE8021XPreauth                                   uint32       = 3
	EAPLowerLayer_IEEE80216e                                         uint32       = 4
	EAPLowerLayer_IKEv2                                              uint32       = 5
	EAPLowerLayer_PPP                                                uint32       = 6
	EAPLowerLayer_PANANoPreauth                                      uint32       = 7
	EAPLowerLayer_GSSAPI                                             uint32       = 8
	EAPLowerLayer_PANAPreauth                                        uint32       = 9
)
View Source
const MaxPacketLength = 4095

MaxPacketLength is the maximum possible wire length of a RADIUS packet.

View Source
const VENDOR_SPECIFIC byte = 26

Variables

View Source
var DefaultClient = &Client{}

DefaultClient is the RADIUS client used by the Exchange function.

View Source
var ErrServerShutdown = errors.New("radius: server is shutting down")

ErrServerShutdown is returned from server Serve methods when Shutdown has been called and handlers are still completing.

Functions

func AddTag

func AddTag(value []byte, tag byte) (vsa []byte)

Add a tag to value

func DecodeAVPairByte

func DecodeAVPairByte(vsa []byte) (vendor_id uint32, type_id uint8, value []byte, err error)

Decodes VSA (byte)

func EncodeAVPairByte

func EncodeAVPairByte(vendor_id uint32, type_id uint8, value []byte) (vsa []byte)

Encodes AVPair into Vendor-Specific attribute format (byte)

func EncodeAVPairByteTag

func EncodeAVPairByteTag(vendor_id uint32, type_id uint8, tag uint8, value []byte) (vsa []byte)

Encodes AVPair into Vendor-Specific attribute format with tag (byte)

func IsAuthenticRequest

func IsAuthenticRequest(request, secret []byte) bool

IsAuthenticRequest returns if the given RADIUS request is an authentic request using the given secret.

func IsAuthenticResponse

func IsAuthenticResponse(response, request, secret []byte) bool

IsAuthenticResponse returns if the given RADIUS response is an authentic response to the given request.

func UserPassword

func UserPassword(a Attribute, secret, requestAuthenticator []byte) ([]byte, error)

UserPassword decrypts the given "User-Password"-encrypted (as defined in RFC 2865) Attribute, and returns the plaintext. An error is returned if the attribute length is invalid, the secret is empty, or the requestAuthenticator length is invalid.

Types

type Attribute

type Attribute []byte

Attribute is a RADIUS attribute, which is part of a RADIUS packet.

func NewUserPassword

func NewUserPassword(plaintext, secret, requestAuthenticator []byte) (Attribute, error)

NewUserPassword returns a new "User-Password"-encrypted attribute from the given plaintext, secret, and requestAuthenticator. An error is returned if the plaintext is too long, the secret is empty, or the requestAuthenticator is an invalid length.

type AttributeCodec

type AttributeCodec interface {
	// Note: do not store wire; make a copy of it.
	Decode(wire Attribute) (interface{}, error)
	Encode(value interface{}) (Attribute, error)
}

AttributeCodec defines how an Attribute is encoded and decoded to and from wire data.

type AttributeKey

type AttributeKey uint64

AttributeKey represents a attribute key AttributeKey = VENDOR << 32 | TAG << 8 | Type TAG MUST be zero in dictionary

func MakeAttributeKey

func MakeAttributeKey(oid uint32, tag byte, attrType byte) AttributeKey

func (AttributeKey) String

func (k AttributeKey) String() string

func (AttributeKey) Tag

func (k AttributeKey) Tag() byte

func (AttributeKey) Type

func (k AttributeKey) Type() byte

func (AttributeKey) ValidTag

func (k AttributeKey) ValidTag() bool

func (AttributeKey) Vendor

func (k AttributeKey) Vendor() uint32

func (AttributeKey) WithTag

func (k AttributeKey) WithTag(tag byte) AttributeKey

func (AttributeKey) WithoutTag

func (k AttributeKey) WithoutTag() AttributeKey

type AttributeStringer

type AttributeStringer interface {
	String(value interface{}) string
}

AttributeStringer defines an extension of AttributeCodec. It provides a method for converting an attribute value to a string.

type AttributeTransformer

type AttributeTransformer interface {
	Transform(value interface{}) (interface{}, error)
}

AttributeTransformer defines an extension of AttributeCodec. It provides a method for converting attribute values to ones permitted by the attribute.

type AttributeType

type AttributeType int
const (
	AttributeString AttributeType = iota + 1
	AttributeOctets
	AttributeIPAddr
	AttributeDate
	AttributeInteger
	AttributeSigned
	AttributeShort
	AttributeIPv6Addr
	AttributeIPv6Prefix
	AttributeIFID
	AttributeInteger64

	AttributeVSA
	AttributeUnknown = -1
)

func (AttributeType) String

func (t AttributeType) String() string

type Attributes

type Attributes map[byte][]Attribute

If multiple Attributes with the same Type are present, the order of Attributes with the same Type MUST be preserved by any proxies. The order of Attributes of different Types is not required to be preserved.

func ParseAttributes

func ParseAttributes(b []byte) (Attributes, error)

ParseAttributes parses the wire-encoded RADIUS attributes and returns a new Attributes value. An error is returned if the buffer is malformed.

func (Attributes) AddRaw

func (a Attributes) AddRaw(key AttributeKey, value Attribute)

AddRaw appends the given Attribute to the map entry of the given key.

func (Attributes) Del

func (a Attributes) Del(key AttributeKey)

Del removes all Attributes of the given key from a.

func (Attributes) Get

func (a Attributes) Get(key AttributeKey) interface{}

Get returns the value of the first attribute whose type matches the given type. nil is returned if no such attribute exists.

func (Attributes) GetByName

func (a Attributes) GetByName(name string) interface{}

GetByName returns the value of the first attribute whose dictionary name matches the given name. nil is returned if no such attribute exists.

func (Attributes) GetByNameWithTag

func (a Attributes) GetByNameWithTag(name string, tag byte) interface{}

GetByNameWithTag returns the value of the first attribute whose dictionary name matches the given name and tag. nil is returned if no such attribute exists.

func (Attributes) GetRaw

func (a Attributes) GetRaw(key AttributeKey) Attribute

GetRaw returns the first Attribute of the given key. nil is returned if no Attribute of key exists in a. The tag field will be striped if has.

func (Attributes) GetString

func (a Attributes) GetString(key AttributeKey) string

GetString is a helper for getting a formatted string from the given attribute.

func (Attributes) Len

func (a Attributes) Len() int

Len returns the total number of Attributes in a.

func (Attributes) LookupRaw

func (a Attributes) LookupRaw(key AttributeKey) (Attribute, bool)

LookupRaw returns the first Attribute of the given key. nil and false is returned if no Attribute of Type key exists in a. The tag field will be striped if has.

func (Attributes) Set

func (a Attributes) Set(key AttributeKey, value interface{}) error

Set sets the value of the first attribute whose type matches the given key. If no such attribute exists, a new attribute is added

func (Attributes) SetByName

func (a Attributes) SetByName(name string, value interface{}) error

SetByName sets the value of the first attribute whose dictionary name matches the given name. If no such attribute exists, a new attribute is added

func (Attributes) SetByNameWithTag

func (a Attributes) SetByNameWithTag(name string, tag byte, value interface{}) error

SetByNameWithTag sets the value of the first attribute whose dictionary name matches the given name with a tag. If no such attribute exists, a new attribute is added

func (Attributes) SetRaw

func (a Attributes) SetRaw(key AttributeKey, value Attribute)

SetRaw removes all Attributes of key and appends value.

type Client

type Client struct {
	// Network on which to make the connection. Defaults to "udp".
	Net string

	// Dialer to use when making the outgoing connections.
	Dialer net.Dialer

	// Interval on which to resend packet (zero or negative value means no
	// retry).
	Retry time.Duration

	InsecureSkipVerify bool
}

Client is a RADIUS client that can exchange packets with a RADIUS server.

func (*Client) Exchange

func (c *Client) Exchange(ctx context.Context, packet *Packet, addr string) (*Packet, error)

Exchange sends the packet to the given server and waits for a response. ctx must be non-nil.

type Code

type Code int

Code defines the RADIUS packet type.

const (
	CodeAccessRequest      Code = 1
	CodeAccessAccept       Code = 2
	CodeAccessReject       Code = 3
	CodeAccountingRequest  Code = 4
	CodeAccountingResponse Code = 5
	CodeAccessChallenge    Code = 11
	CodeStatusServer       Code = 12
	CodeStatusClient       Code = 13
	CodeDisconnectRequest  Code = 40
	CodeDisconnectACK      Code = 41
	CodeDisconnectNAK      Code = 42
	CodeCoARequest         Code = 43
	CodeCoAACK             Code = 44
	CodeCoANAK             Code = 45
	CodeReserved           Code = 255
)

Standard RADIUS packet codes.

func (Code) String

func (c Code) String() string

String returns a string representation of the code.

type DictEntry

type DictEntry struct {
	Name     string
	Key      AttributeKey
	Encrypt  int
	HasTag   bool
	AttrType AttributeType
}

func (*DictEntry) Codecs

func (d *DictEntry) Codecs() AttributeCodec

Codecs returns the codecs for the given attribute.

type Dictionary

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

Dictionary stores mappings between attribute names and types and AttributeCodecs.

var Builtin *Dictionary

Builtin is the built-in dictionary. It is initially loaded with the attributes defined in RFC 2865 and RFC 2866.

func (*Dictionary) Get

func (d *Dictionary) Get(key AttributeKey) (value *DictEntry, ok bool)

Get returns the registered entry for the given attribute key. ok is false if the given key is not registered.

func (*Dictionary) GetByName

func (d *Dictionary) GetByName(name string) (value *DictEntry, ok bool)

GetByName returns the registered entry for the given attribute name. ok is false if the given name is not registered.

func (*Dictionary) MustRegister

func (d *Dictionary) MustRegister(name string, oid uint32, code byte, hasTag bool, encrypt int, attrType AttributeType)

MustRegisterEx is a helper for Register that panics if it returns an error.

func (*Dictionary) Name

func (d *Dictionary) Name(key AttributeKey) (name string, ok bool)

Name returns the registered name for the given attribute key. ok is false if the given type is not registered.

func (*Dictionary) Register

func (d *Dictionary) Register(name string, oid uint32, t byte, hasTag bool, encrypt int, attrType AttributeType) error

RegisterEx registers the AttributeCodecs for the given attribute options.

func (*Dictionary) TagType

func (d *Dictionary) TagType(key AttributeKey) int

HasTag returns whether the given attribute's type has a tag

type Handler

type Handler interface {
	ServeRADIUS(w ResponseWriter, r *Request)
}

Handler provides a handler to RADIUS server requests. When a RADIUS request is received, ServeRADIUS is called.

type HandlerFunc

type HandlerFunc func(w ResponseWriter, r *Request)

HandlerFunc allows a function to implement Handler.

func (HandlerFunc) ServeRADIUS

func (h HandlerFunc) ServeRADIUS(w ResponseWriter, r *Request)

ServeRADIUS calls h(w, p).

type Packet

type Packet struct {
	Code          Code
	Identifier    byte
	Authenticator [16]byte
	Secret        []byte
	Attributes
}

Packet is a RADIUS packet.

func Exchange

func Exchange(ctx context.Context, packet *Packet, addr string) (*Packet, error)

Exchange uses DefaultClient to send the given RADIUS packet to the server at address addr and waits for a response.

func New

func New(code Code, secret []byte) *Packet

New creates a new packet with the Code, Secret fields set to the given values. The returned packet's Identifier, Authenticator are filled with random values.

func Parse

func Parse(b, secret []byte) (*Packet, error)

Parse parses an encoded RADIUS packet b. An error is returned if the packet is malformed.

func (*Packet) Encode

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

Encode encodes the RADIUS packet to wire format. An error is returned if the encoded packet is too long (due to its Attributes), or if the packet has an unknown Code.

func (*Packet) Response

func (p *Packet) Response(code Code) *Packet

Response returns a new packet that has the same identifier, secret, and authenticator as the current packet.

type PacketServer

type PacketServer struct {
	// The address on which the server listens. Defaults to :1812.
	Addr string
	// The network on which the server listens. Defaults to udp.
	Network      string
	SecretSource SecretSource
	Handler      Handler

	// Skip incoming packet authenticity validation.
	// This should only be set to true for debugging purposes.
	InsecureSkipVerify bool
	// contains filtered or unexported fields
}

PacketServer listens for RADIUS requests on a packet-based protocols (e.g. UDP).

func (*PacketServer) ListenAndServe

func (s *PacketServer) ListenAndServe() error

ListenAndServe starts a RADIUS server on the address given in s.

func (*PacketServer) Serve

func (s *PacketServer) Serve(conn net.PacketConn) error

Serve accepts incoming connections on conn.

func (*PacketServer) Shutdown

func (s *PacketServer) Shutdown(ctx context.Context) error

Shutdown gracefully stops the server. It first closes all connections (which stops accepting new packets) and then waits for running handlers to complete.

Shutdown returns after all handlers have completed, or when ctx is canceled. The PacketServer is ready for re-use once the function returns nil.

type Request

type Request struct {
	LocalAddr  net.Addr
	RemoteAddr net.Addr

	*Packet
	// contains filtered or unexported fields
}

Request is an incoming RADIUS request that is being handled by the server.

func (*Request) Context

func (r *Request) Context() context.Context

Context returns the context of the request. If a context has not been set using WithContext, the Background context is returned.

func (*Request) WithContext

func (r *Request) WithContext(ctx context.Context) *Request

WithContext returns a shallow copy of the request with the new request's context set to the given context.

type ResponseWriter

type ResponseWriter interface {
	Write(packet *Packet) error
}

ResponseWriter is used by RADIUS servers when replying to a RADIUS request.

type SecretSource

type SecretSource interface {
	RADIUSSecret(ctx context.Context, remoteAddr net.Addr) ([]byte, error)
}

SecretSource supplies RADIUS servers with the secret that should be used for authorizing and decrypting packets.

ctx is canceled if the server's Shutdown method is called.

func StaticSecretSource

func StaticSecretSource(secret []byte) SecretSource

StaticSecretSource returns a SecretSource that uses secret for all requests.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL