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

No files matched your search

+5 -5
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
}