@@ -27,13 +27,13 @@ def __init__(self, secret, dict: Dictionary, packet: bytes, socket, address):
27
27
# access-request 需要 Message-Authenticator 字段验证报文合法性; 报文头Authenticator字段是随机生成的
28
28
# log.warning(f'VerifyAuthRequest failed from address: {address}, authenticator: {self.authenticator}')
29
29
assert self .authenticator != b'\x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 '
30
+ self .username = self ['User-Name' ][0 ]
31
+ self .nas_ip = self ['NAS-IP-Address' ][0 ] # 如果获取自报文字段 self['NAS-IP-Address'][0], 会出现ip更新不及时, 与真实IP不一致的问题
30
32
except Exception as e :
31
33
raise PacketError (str (e ))
32
- self . socket , self . address = socket , address
34
+
33
35
# 报文提取
34
- # self['Service-Type'][0] 和 self['Service-Type'][1] 分别对应字典 dictionary.pyrad 里面 VALUE Service-Type Call-Check 10 的第1个和第2个值
35
- self .username = self ['User-Name' ][0 ]
36
- self .nas_ip = self ['NAS-IP-Address' ][0 ] # 如果获取自报文字段 self['NAS-IP-Address'][0], 会出现ip更新不及时, 与真实IP不一致的问题
36
+ # self['Service-Type'][0] 和 self['Service-Type'][1] 对应字典 VALUE Service-Type Call-Check 10 中的字符串 Call-Check 和值 10
37
37
# optional:
38
38
default_string = ('' , 0 )
39
39
self .user_mac = self .get ('Calling-Station-Id' , default_string )[0 ]
@@ -47,6 +47,7 @@ def __init__(self, secret, dict: Dictionary, packet: bytes, socket, address):
47
47
self .ap_mac , self .ssid = self .ap_mac .split (':' , 1 )
48
48
49
49
self .auth_protocol = 'UNKNOWN-AUTH'
50
+ self .socket , self .address = socket , address
50
51
51
52
def get_service_type (self ) -> str :
52
53
return self ['Service-Type' ][0 ] # 2: Framed; 10: Call-Check; https://datatracker.ietf.org/doc/html/rfc2865#page-31
@@ -109,13 +110,13 @@ def __init__(self, secret, dict, packet: bytes, socket, address):
109
110
init_packet_from_receive (super (), code = self .code , id = 0 , secret = secret , authenticator = None , dict = dict , packet = packet )
110
111
# account-request 可使用 Authenticator 字段验证报文合法性
111
112
assert self .VerifyAcctRequest ()
113
+ self .username = self ['User-Name' ][0 ]
114
+ self .nas_ip = self ['NAS-IP-Address' ][0 ] # 如果获取自报文字段 self['NAS-IP-Address'][0], 会出现ip更新不及时, 与真实IP不一致的问题
115
+ self .iut = self ['Acct-Status-Type' ][0 ] # I,U,T包. Start-1; Stop-2; Alive-3; Accounting-On-7; Accounting-Off-8;
112
116
except Exception as e :
113
117
raise PacketError (str (e ))
114
- self . socket , self . address = socket , address
118
+
115
119
# 报文提取
116
- self .username = self ['User-Name' ][0 ]
117
- self .nas_ip = self ['NAS-IP-Address' ][0 ] # 如果获取自报文字段 self['NAS-IP-Address'][0], 会出现ip更新不及时, 与真实IP不一致的问题
118
- self .iut = self ['Acct-Status-Type' ][0 ] # I,U,T包. Start-1; Stop-2; Alive-3; Accounting-On-7; Accounting-Off-8;
119
120
# https://www.h3c.com/cn/Service/Document_Software/Document_Center/Home/Wlan/00-Public/Configure/Radius_Attribute_List/H3C_RADIUS_V7-19485/
120
121
default_string = (0 , 0 )
121
122
self .session_time = self .get ('Acct-Session-Time' , default_string )[0 ] # 秒
@@ -129,6 +130,7 @@ def __init__(self, secret, dict, packet: bytes, socket, address):
129
130
self .user_mac = self .get ('Calling-Station-Id' , default_string )[0 ]
130
131
self .auth_class = self .get ('Class' , default_string )[0 ]
131
132
self .nas_name = self .get ('NAS-Identifier' , default_string )[0 ]
133
+ self .socket , self .address = socket , address
132
134
133
135
def reply_to (self , reply : AcctPacket ):
134
136
log .trace (f'reply: { reply } ' )
0 commit comments