Skip to content

Commit

Permalink
Add IsAuthentic to the Request struct
Browse files Browse the repository at this point in the history
  • Loading branch information
stamp committed Jun 3, 2022
1 parent e6a3d5a commit 0129648
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 7 additions & 5 deletions server-packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ func (s *PacketServer) Serve(conn net.PacketConn) error {
return
}

if !s.InsecureSkipVerify && !IsAuthenticRequest(buff, secret) {
isAuthentic := IsAuthenticRequest(buff, secret)
if !s.InsecureSkipVerify && !isAuthentic {
s.logf("radius: packet validation failed; bad secret")
return
}
Expand Down Expand Up @@ -192,10 +193,11 @@ func (s *PacketServer) Serve(conn net.PacketConn) error {
}()

request := Request{
LocalAddr: conn.LocalAddr(),
RemoteAddr: remoteAddr,
Packet: packet,
ctx: s.ctx,
LocalAddr: conn.LocalAddr(),
RemoteAddr: remoteAddr,
IsAuthentic: isAuthentic,
Packet: packet,
ctx: s.ctx,
}

s.Handler.ServeRADIUS(&response, &request)
Expand Down
2 changes: 2 additions & 0 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ type Request struct {
// RemoteAddr is the address from which the incoming RADIUS request
// was sent.
RemoteAddr net.Addr
// IsAuthentic is true if the secret that was used matches the one we have
IsAuthentic bool

// Packet is the RADIUS packet sent in the request.
*Packet
Expand Down

0 comments on commit 0129648

Please sign in to comment.