mirror of
https://github.com/bjdgyc/anylink.git
synced 2025-08-10 22:56:11 +08:00
radius 添加 CallingStationID
This commit is contained in:
@@ -40,7 +40,7 @@ func (auth AuthRadius) checkData(authData map[string]interface{}) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (auth AuthRadius) checkUser(name, pwd string, g *Group) error {
|
||||
func (auth AuthRadius) checkUser(name, pwd string, g *Group, ext map[string]interface{}) error {
|
||||
pl := len(pwd)
|
||||
if name == "" || pl < 1 {
|
||||
return fmt.Errorf("%s %s", name, "密码错误")
|
||||
@@ -74,15 +74,23 @@ func (auth AuthRadius) checkUser(name, pwd string, g *Group) error {
|
||||
return fmt.Errorf("%s %s", name, "Radius set nasip 出现错误")
|
||||
}
|
||||
}
|
||||
macAddr := ext["mac_addr"].(string)
|
||||
if macAddr != "" {
|
||||
err = rfc2865.CallingStationID_SetString(packet, macAddr)
|
||||
if err != nil {
|
||||
return fmt.Errorf("%s %s", name, "Radius set CallingStationID 出现错误")
|
||||
}
|
||||
}
|
||||
|
||||
ctx, done := context.WithTimeout(context.Background(), 3*time.Second)
|
||||
defer done()
|
||||
response, err := radius.Exchange(ctx, packet, auth.Addr)
|
||||
if err != nil {
|
||||
return fmt.Errorf("%s %s", name, "Radius服务器连接异常, 请检测服务器和端口")
|
||||
return fmt.Errorf("%s %s %s", name, "Radius服务器连接异常, 请检测服务器和端口", err)
|
||||
}
|
||||
if response.Code != radius.CodeAccessAccept {
|
||||
return fmt.Errorf("%s %s", name, "Radius:用户名或密码错误")
|
||||
}
|
||||
return nil
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user