token-validator: fix IP assignation when > 254 (there is a lot of student this year)
This commit is contained in:
parent
cc7e738932
commit
060831d9c2
3 changed files with 24 additions and 7 deletions
|
|
@ -4,6 +4,7 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"net"
|
||||
"strings"
|
||||
|
||||
"github.com/julienschmidt/httprouter"
|
||||
|
|
@ -89,7 +90,7 @@ func createStudent(_ httprouter.Params, body []byte) (interface{}, error) {
|
|||
}
|
||||
exist.RegisterAccess(std.IP, std.MAC)
|
||||
|
||||
ip := fmt.Sprintf("172.23.0.%d", IPSuffix(exist))
|
||||
ip := IPSuffix(exist, net.IPNet{net.ParseIP("172.23.0.0"), net.CIDRMask(17, 32)}).String()
|
||||
exist.IP = &ip
|
||||
|
||||
return exist, nil
|
||||
|
|
|
|||
Reference in a new issue