This commit is contained in:
jdl
2024-12-12 21:11:17 +01:00
parent 03ff1aac80
commit fdf0066fc2
35 changed files with 1138 additions and 331 deletions

View File

@@ -44,10 +44,10 @@ func Session_Validate(s *Session) error {
func Peer_Sanitize(p *Peer) {
p.Name = strings.TrimSpace(p.Name)
if len(p.IP) != 0 {
addr, ok := netip.AddrFromSlice(p.IP)
if len(p.PublicIP) != 0 {
addr, ok := netip.AddrFromSlice(p.PublicIP)
if ok && addr.Is4() {
p.IP = addr.AsSlice()
p.PublicIP = addr.AsSlice()
}
}
if p.Port == 0 {
@@ -56,8 +56,8 @@ func Peer_Sanitize(p *Peer) {
}
func Peer_Validate(p *Peer) error {
if len(p.IP) > 0 {
_, ok := netip.AddrFromSlice(p.IP)
if len(p.PublicIP) > 0 {
_, ok := netip.AddrFromSlice(p.PublicIP)
if !ok {
return ErrInvalidIP
}