Documentation ¶
Index ¶
- Constants
- Variables
- func RunServer(address string, secret []byte, handler Handler) func() error
- func RunServerWithPacketHandler(address string, secret []byte, handler PacketHandler) func() error
- type AVP
- type AVPType
- type AcctRequest
- type AcctStatusTypeEnum
- type AcctTerminateCauseEnum
- type BinaryAVP
- type BinaryVSA
- type Code
- type EapAVP
- type Handler
- type IpAVP
- type MSMPPEEncryptionPolicy
- type MSMPPEEncryptionTypes
- type MSMPPESendOrRecvKeyVSA
- type NASPortTypeEnum
- type Packet
- func (p *Packet) AddAVP(avp AVP)
- func (p *Packet) Copy() *Packet
- func (p *Packet) DeleteOneType(attrType AVPType)
- func (p *Packet) Encode() (b []byte, err error)
- func (p *Packet) GetAVP(attrType AVPType) AVP
- func (p *Packet) GetAcctSessionId() string
- func (p *Packet) GetAcctSessionTime() uint32
- func (p *Packet) GetAcctStatusType() AcctStatusTypeEnum
- func (p *Packet) GetAcctTotalInputOctets() uint64
- func (p *Packet) GetAcctTotalOutputOctets() uint64
- func (p *Packet) GetEAPMessage() eap.Packet
- func (p *Packet) GetNASIdentifier() string
- func (p *Packet) GetNASPort() uint32
- func (p *Packet) GetNasIpAddress() (ip net.IP)
- func (p *Packet) GetPassword() (password string)
- func (p *Packet) GetState() []byte
- func (p *Packet) GetUsername() (username string)
- func (p *Packet) GetVsa(typ VendorType) VSA
- func (p *Packet) Reply() *Packet
- func (p *Packet) Send(c net.PacketConn, addr net.Addr) error
- func (p *Packet) SetAVP(avp AVP)
- func (p *Packet) SetAcctInterimInterval(second int)
- func (p *Packet) SetState(state []byte)
- func (p *Packet) String() string
- func (p *Packet) ToStringMap() map[string]string
- type PacketHandler
- type PasswordAVP
- type ServiceTypeEnum
- type StringAVP
- type Stringer
- type Uint32AVP
- type Uint32EnumAVP
- type Uint32EnumVSA
- type VSA
- type VendorId
- type VendorSpecificAVP
- type VendorType
Constants ¶
View Source
const (
VendorIdMicrosoft = 311
)
Variables ¶
View Source
var ErrMessageAuthenticatorCheckFail = fmt.Errorf("RADIUS Response-Authenticator verification failed")
Functions ¶
func RunServer ¶
异步运行服务器, TODO 返回Closer以便可以关闭服务器,所有无法运行的错误panic出来,其他错误丢到kmgLog error里面. 如果不需要Closer可以直接忽略
func RunServerWithPacketHandler ¶
func RunServerWithPacketHandler(address string, secret []byte, handler PacketHandler) func() error
异步运行服务器,返回Closer以便可以关闭服务器,所有无法运行的错误panic出来,其他错误丢到kmgLog error里面.
Types ¶
type AVPType ¶
type AVPType uint8
const ( //start rfc2865 AVPTypeUserName AVPType = 1 AVPTypeUserPassword AVPType = 2 AVPTypeCHAPPassword AVPType = 3 AVPTypeNASIPAddress AVPType = 4 AVPTypeNASPort AVPType = 5 AVPTypeServiceType AVPType = 6 AVPTypeFramedProtocol AVPType = 7 AVPTypeFramedIPAddress AVPType = 8 //8 AVPTypeFramedIPNetmask AVPType = 9 //9 AVPTypeFramedRouting AVPType = 10 //10 AVPTypeFilterId AVPType = 11 //11 AVPTypeFramedMTU AVPType = 12 //12 AVPTypeFramedCompression AVPType = 13 //13 AVPTypeLoginIPHost AVPType = 14 //14 AVPTypeLoginService AVPType = 15 //15 AVPTypeLoginTCPPort AVPType = 16 //16 AVPTypeReplyMessage AVPType = 18 //18 AVPTypeCallbackNumber AVPType = 19 //19 AVPTypeCallbackId AVPType = 20 //20 AVPTypeFramedRoute AVPType = 22 //22 AVPTypeFramedIPXNetwork AVPType = 23 //23 AVPTypeState AVPType = 24 //24 AVPTypeClass AVPType = 25 //25 AVPTypeVendorSpecific AVPType = 26 AVPTypeSessionTimeout AVPType = 27 AVPTypeIdleTimeout AVPType = 28 AVPTypeTerminationAction AVPType = 29 AVPTypeCalledStationId AVPType = 30 AVPTypeCallingStationId AVPType = 31 AVPTypeNASIdentifier AVPType = 32 AVPTypeProxyState AVPType = 33 AVPTypeLoginLATService AVPType = 34 AVPTypeLoginLATNode AVPType = 35 AVPTypeLoginLATGroup AVPType = 36 AVPTypeFramedAppleTalkLink AVPType = 37 AVPTypeFramedAppleTalkNetwork AVPType = 38 AVPTypeFramedAppleTalkZone AVPType = 39 AVPTypeAcctStatusType AVPType = 40 AVPTypeAcctDelayTime AVPType = 41 AVPTypeAcctInputOctets AVPType = 42 AVPTypeAcctOutputOctets AVPType = 43 AVPTypeAcctSessionId AVPType = 44 AVPTypeAcctAuthentic AVPType = 45 AVPTypeAcctSessionTime AVPType = 46 AVPTypeAcctInputPackets AVPType = 47 AVPTypeAcctOutputPackets AVPType = 48 AVPTypeAcctTerminateCause AVPType = 49 AVPTypeAcctMultiSessionId AVPType = 50 AVPTypeAcctLinkCount AVPType = 51 AVPTypeAcctInputGigawords AVPType = 52 //52 AVPTypeAcctOutputGigawords AVPType = 53 AVPTypeUnassigned1 AVPType = 54 AVPTypeEventTimestamp AVPType = 55 AVPTypeEgressVLANID AVPType = 56 AVPTypeIngressFilters AVPType = 57 AVPTypeEgressVLANName AVPType = 58 AVPTypeUserPriorityTable AVPType = 59 //59 AVPTypeCHAPChallenge AVPType = 60 AVPTypeNASPortType AVPType = 61 AVPTypePortLimit AVPType = 62 AVPTypeLoginLATPort AVPType = 63 //end rfc2865 rfc 2866 AVPTypeTunnelType AVPType = 64 //64 AVPTypeTunnelMediumType AVPType = 65 AVPTypeTunnelClientEndpoint AVPType = 66 AVPTypeTunnelServerEndpoint AVPType = 67 AVPTypeAcctTunnelConnection AVPType = 68 AVPTypeTunnelPassword AVPType = 69 AVPTypeARAPPassword AVPType = 70 AVPTypeARAPFeatures AVPType = 71 AVPTypeARAPZoneAccess AVPType = 72 AVPTypeARAPSecurity AVPType = 73 AVPTypeARAPSecurityData AVPType = 74 AVPTypePasswordRetry AVPType = 75 AVPTypePrompt AVPType = 76 AVPTypeConnectInfo AVPType = 77 AVPTypeConfigurationToken AVPType = 78 AVPTypeEAPMessage AVPType = 79 AVPTypeMessageAuthenticator AVPType = 80 AVPTypeTunnelPrivateGroupID AVPType = 81 AVPTypeTunnelAssignmentID AVPType = 82 AVPTypeTunnelPreference AVPType = 83 AVPTypeARAPChallengeResponse AVPType = 84 AVPTypeAcctInterimInterval AVPType = 85 AVPTypeAcctTunnelPacketsLost AVPType = 86 AVPTypeNASPortId AVPType = 87 AVPTypeFramedPool AVPType = 88 AVPTypeCUI AVPType = 89 AVPTypeTunnelClientAuthID AVPType = 90 AVPTypeTunnelServerAuthID AVPType = 91 AVPTypeNASFilterRule AVPType = 92 AVPTypeUnassigned AVPType = 93 AVPTypeOriginatingLineInfo AVPType = 94 AVPTypeNASIPv6Address AVPType = 95 AVPTypeFramedInterfaceId AVPType = 96 AVPTypeFramedIPv6Prefix AVPType = 97 AVPTypeLoginIPv6Host AVPType = 98 AVPTypeFramedIPv6Route AVPType = 99 AVPTypeFramedIPv6Pool AVPType = 100 AVPTypeErrorCause AVPType = 101 AVPTypeEAPKeyName AVPType = 102 AVPTypeDigestResponse AVPType = 103 AVPTypeDigestRealm AVPType = 104 AVPTypeDigestNonce AVPType = 105 AVPTypeDigestResponseAuth AVPType = 106 AVPTypeDigestNextnonce AVPType = 107 AVPTypeDigestMethod AVPType = 108 AVPTypeDigestURI AVPType = 109 AVPTypeDigestQop AVPType = 110 AVPTypeDigestAlgorithm AVPType = 111 AVPTypeDigestEntityBodyHash AVPType = 112 AVPTypeDigestCNonce AVPType = 113 AVPTypeDigestNonceCount AVPType = 114 AVPTypeDigestUsername AVPType = 115 AVPTypeDigestOpaque AVPType = 116 AVPTypeDigestAuthParam AVPType = 117 AVPTypeDigestAKAAuts AVPType = 118 AVPTypeDigestDomain AVPType = 119 AVPTypeDigestStale AVPType = 120 AVPTypeDigestHA1 AVPType = 121 AVPTypeSIPAOR AVPType = 122 AVPTypeDelegatedIPv6Prefix AVPType = 123 AVPTypeMIP6FeatureVector AVPType = 124 AVPTypeMIP6HomeLinkPrefix AVPType = 125 AVPTypeOperatorName AVPType = 126 AVPTypeLocationInformation AVPType = 127 AVPTypeLocationData AVPType = 128 AVPTypeBasicLocationPolicyRules AVPType = 129 AVPTypeExtendedLocationPolicyRules AVPType = 130 AVPTypeLocationCapable AVPType = 131 AVPTypeRequestedLocationInfo AVPType = 132 AVPTypeFramedManagementProtocol AVPType = 133 AVPTypeManagementTransportProtectio AVPType = 134 AVPTypeManagementPolicyId AVPType = 135 AVPTypeManagementPrivilegeLevel AVPType = 136 AVPTypePKMSSCert AVPType = 137 AVPTypePKMCACert AVPType = 138 AVPTypePKMConfigSettings AVPType = 139 AVPTypePKMCryptosuiteList AVPType = 140 AVPTypePKMSAID AVPType = 141 AVPTypePKMSADescriptor AVPType = 142 AVPTypePKMAuthKey AVPType = 143 AVPTypeDSLiteTunnelName AVPType = 144 AVPTypeMobileNodeIdentifier AVPType = 145 AVPTypeServiceSelection AVPType = 146 AVPTypePMIP6HomeLMAIPv6Address AVPType = 147 AVPTypePMIP6VisitedLMAIPv6Address AVPType = 148 AVPTypePMIP6HomeLMAIPv4Address AVPType = 149 AVPTypePMIP6VisitedLMAIPv4Address AVPType = 150 AVPTypePMIP6HomeHNPrefix AVPType = 151 AVPTypePMIP6VisitedHNPrefix AVPType = 152 AVPTypePMIP6HomeInterfaceID AVPType = 153 AVPTypePMIP6VisitedInterfaceID AVPType = 154 AVPTypePMIP6HomeIPv4HoA AVPType = 155 AVPTypePMIP6VisitedIPv4HoA AVPType = 156 AVPTypePMIP6HomeDHCP4ServerAddress AVPType = 157 AVPTypePMIP6VisitedDHCP4ServerAddre AVPType = 158 AVPTypePMIP6HomeDHCP6ServerAddress AVPType = 159 AVPTypePMIP6VisitedDHCP6ServerAddre AVPType = 160 AVPTypeUnassignedStart AVPType = 161 AVPTypeUnassignedEnd AVPType = 191 AVPTypeExperimentalStart AVPType = 192 AVPTypeExperimentalEnd AVPType = 223 AVPTypeImplementationSpecificStart AVPType = 224 AVPTypeImplementationSpecificEnd AVPType = 240 AVPTypeReservedStart AVPType = 241 AVPTypeReservedEnd AVPType = 254 )
type AcctRequest ¶
type AcctStatusTypeEnum ¶
type AcctStatusTypeEnum uint32
const ( AcctStatusTypeEnumStart AcctStatusTypeEnum = 1 AcctStatusTypeEnumStop AcctStatusTypeEnum = 2 AcctStatusTypeEnumInterimUpdate AcctStatusTypeEnum = 3 AcctStatusTypeEnumAccountingOn AcctStatusTypeEnum = 7 AcctStatusTypeEnumAccountingOff AcctStatusTypeEnum = 8 )
func (AcctStatusTypeEnum) String ¶
func (e AcctStatusTypeEnum) String() string
type AcctTerminateCauseEnum ¶
type AcctTerminateCauseEnum uint32
const ( AcctTerminateCauseEnumUserRequest AcctTerminateCauseEnum = 1 AcctTerminateCauseEnumLostCarrier AcctTerminateCauseEnum = 2 AcctTerminateCauseEnumLostService AcctTerminateCauseEnum = 3 AcctTerminateCauseEnumIdleTimeout AcctTerminateCauseEnum = 4 )
TODO finish it
func (AcctTerminateCauseEnum) String ¶
func (e AcctTerminateCauseEnum) String() string
type BinaryAVP ¶
func (*BinaryAVP) ValueAsString ¶
type BinaryVSA ¶
type BinaryVSA struct { Type VendorType Value []byte }
func (*BinaryVSA) GetType ¶
func (a *BinaryVSA) GetType() VendorType
type EapAVP ¶
func (*EapAVP) ValueAsString ¶
type Handler ¶
type Handler struct { // 有的协议需要明文密码来做各种hash的事情 // exist返回false可以踢掉客户端 // 同步调用 Auth func(username string) (password string, exist bool) // 计费开始,来了一条新连接 // 根据协议规定 此处返回给客户端的包,不能发送任何有效信息(比如踢掉客户端,请采用其他办法踢掉客户端) // 异步调用 AcctStart func(acctReq AcctRequest) // 计费数据更新 // 根据协议规定 此处返回给客户端的包,不能发送任何有效信息(比如踢掉客户端,请采用其他办法踢掉客户端) // 异步调用 AcctUpdate func(acctReq AcctRequest) // 计费结束 // 根据协议规定 此处返回给客户端的包,不能发送任何有效信息(比如踢掉客户端,请采用其他办法踢掉客户端) // 异步调用 AcctStop func(acctReq AcctRequest) }
type IpAVP ¶
func (*IpAVP) ValueAsString ¶
type MSMPPEEncryptionPolicy ¶
type MSMPPEEncryptionPolicy uint32
const ( MSMPPEEncryptionPolicyEncryptionAllowed MSMPPEEncryptionPolicy = 1 MSMPPEEncryptionPolicyEncryptionRequired MSMPPEEncryptionPolicy = 2 )
func (MSMPPEEncryptionPolicy) String ¶
func (a MSMPPEEncryptionPolicy) String() string
type MSMPPEEncryptionTypes ¶
type MSMPPEEncryptionTypes uint32
const ( MSMPPEEncryptionTypesRC4Bit40 MSMPPEEncryptionTypes = 2 MSMPPEEncryptionTypesRC4Bit128 MSMPPEEncryptionTypes = 4 MSMPPEEncryptionTypesRC4Bit40Or128 MSMPPEEncryptionTypes = 6 )
func (MSMPPEEncryptionTypes) String ¶
func (a MSMPPEEncryptionTypes) String() string
type MSMPPESendOrRecvKeyVSA ¶
type MSMPPESendOrRecvKeyVSA struct { Type VendorType Salt [2]byte //最高位要是1 Key []byte // contains filtered or unexported fields }
send or recv key
func NewMSMPPESendOrRecvKeyVSA ¶
func NewMSMPPESendOrRecvKeyVSA(p *Packet, typ VendorType, key []byte) *MSMPPESendOrRecvKeyVSA
随机一个新的 MSMPPESendOrRecvKeyVSA 的对象
func (*MSMPPESendOrRecvKeyVSA) Encode ¶
func (a *MSMPPESendOrRecvKeyVSA) Encode() (b []byte, err error)
func (*MSMPPESendOrRecvKeyVSA) GetType ¶
func (a *MSMPPESendOrRecvKeyVSA) GetType() VendorType
func (*MSMPPESendOrRecvKeyVSA) GetValue ¶
func (a *MSMPPESendOrRecvKeyVSA) GetValue() interface{}
func (*MSMPPESendOrRecvKeyVSA) SetPacket ¶
func (a *MSMPPESendOrRecvKeyVSA) SetPacket(p *Packet)
func (*MSMPPESendOrRecvKeyVSA) String ¶
func (a *MSMPPESendOrRecvKeyVSA) String() string
type NASPortTypeEnum ¶
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 ¶
func (e NASPortTypeEnum) String() string
type Packet ¶
type Packet struct { Secret []byte Code Code Identifier uint8 Authenticator [16]byte //对应的Request请求里面的Authenticator. AVPs []AVP }
func DecodeRequestPacket ¶
这个只能解密各种Request
func DecodeResponsePacket ¶
func DecodeResponsePacket(Secret []byte, buf []byte, RequestAuthenticator [16]byte) (p *Packet, err error)
解密response包
func (*Packet) DeleteOneType ¶
delete all avps with this type
func (*Packet) GetAcctSessionId ¶
func (*Packet) GetAcctSessionTime ¶
func (*Packet) GetAcctStatusType ¶
func (p *Packet) GetAcctStatusType() AcctStatusTypeEnum
func (*Packet) GetAcctTotalInputOctets ¶
func (*Packet) GetAcctTotalOutputOctets ¶
func (*Packet) GetEAPMessage ¶
func (*Packet) GetNASIdentifier ¶
func (*Packet) GetNasIpAddress ¶
func (*Packet) GetPassword ¶
func (*Packet) GetUsername ¶
func (*Packet) GetVsa ¶
func (p *Packet) GetVsa(typ VendorType) VSA
func (*Packet) SetAcctInterimInterval ¶
func (*Packet) ToStringMap ¶
转成字符串map,便于进行log(序列化?),只有实际信息,已经把加密的东西剔除掉了
type PacketHandler ¶
type PasswordAVP ¶
type PasswordAVP struct { Value string // plain of password // contains filtered or unexported fields }
func (*PasswordAVP) Copy ¶
func (a *PasswordAVP) Copy() AVP
func (*PasswordAVP) Encode ¶
func (a *PasswordAVP) Encode() (b []byte, err error)
you need set packet before encode
func (*PasswordAVP) GetType ¶
func (a *PasswordAVP) GetType() AVPType
func (*PasswordAVP) GetValue ¶
func (a *PasswordAVP) GetValue() interface{}
func (*PasswordAVP) SetPacket ¶
func (a *PasswordAVP) SetPacket(p *Packet)
func (*PasswordAVP) String ¶
func (a *PasswordAVP) String() string
func (*PasswordAVP) ValueAsString ¶
func (a *PasswordAVP) ValueAsString() string
type ServiceTypeEnum ¶
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 ¶
func (e ServiceTypeEnum) String() string
type StringAVP ¶
func (*StringAVP) ValueAsString ¶
type Uint32AVP ¶
func (*Uint32AVP) ValueAsString ¶
type Uint32EnumAVP ¶
type Uint32EnumAVP struct { Type AVPType Value Stringer // value should derive from a uint32 type like AcctStatusTypeEnum }
func (*Uint32EnumAVP) Copy ¶
func (a *Uint32EnumAVP) Copy() AVP
func (*Uint32EnumAVP) Encode ¶
func (a *Uint32EnumAVP) Encode() (b []byte, err error)
func (*Uint32EnumAVP) GetType ¶
func (a *Uint32EnumAVP) GetType() AVPType
func (*Uint32EnumAVP) GetValue ¶
func (a *Uint32EnumAVP) GetValue() interface{}
func (*Uint32EnumAVP) String ¶
func (a *Uint32EnumAVP) String() string
func (*Uint32EnumAVP) ValueAsString ¶
func (a *Uint32EnumAVP) ValueAsString() string
type Uint32EnumVSA ¶
type Uint32EnumVSA struct { Type VendorType Value Stringer // value should derive from a uint32 type like AcctStatusTypeEnum }
func (*Uint32EnumVSA) Copy ¶
func (a *Uint32EnumVSA) Copy() VSA
func (*Uint32EnumVSA) Encode ¶
func (a *Uint32EnumVSA) Encode() (b []byte, err error)
func (*Uint32EnumVSA) GetType ¶
func (a *Uint32EnumVSA) GetType() VendorType
func (*Uint32EnumVSA) GetValue ¶
func (a *Uint32EnumVSA) GetValue() interface{}
func (*Uint32EnumVSA) String ¶
func (a *Uint32EnumVSA) String() string
type VSA ¶
type VSA interface { GetType() VendorType String() string Encode() (b []byte, err error) }
Vendor Specific Attributes
type VendorSpecificAVP ¶
type VendorSpecificAVP struct {
Value VSA
}
func (*VendorSpecificAVP) Encode ¶
func (a *VendorSpecificAVP) Encode() (b []byte, err error)
func (*VendorSpecificAVP) GetType ¶
func (a *VendorSpecificAVP) GetType() AVPType
func (*VendorSpecificAVP) GetValue ¶
func (a *VendorSpecificAVP) GetValue() interface{}
func (*VendorSpecificAVP) String ¶
func (a *VendorSpecificAVP) String() string
func (*VendorSpecificAVP) ValueAsString ¶
func (a *VendorSpecificAVP) ValueAsString() string
type VendorType ¶
type VendorType uint8 //微软的?
const ( VendorTypeMSMPPEEncryptionPolicy VendorType = 7 VendorTypeMSMPPEEncryptionTypes VendorType = 8 VendorTypeMSMPPESendKey VendorType = 16 VendorTypeMSMPPERecvKey VendorType = 17 )
func (VendorType) String ¶
func (a VendorType) String() string
func (VendorType) VendorId ¶
func (a VendorType) VendorId() VendorId
Source Files ¶
Click to show internal directories.
Click to hide internal directories.