token-validator: fix IP assignation when > 254 (there is a lot of student this year)

This commit is contained in:
nemunaire 2021-02-20 19:13:33 +01:00
commit 060831d9c2
3 changed files with 24 additions and 7 deletions

View file

@ -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