WIP
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user