chore: discard domain addr input in sudoku uot
Some checks are pending
Test / test (1.20, macos-15-intel) (push) Waiting to run
Test / test (1.20, macos-latest) (push) Waiting to run
Test / test (1.20, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.20, ubuntu-latest) (push) Waiting to run
Test / test (1.20, windows-latest) (push) Waiting to run
Test / test (1.21, macos-15-intel) (push) Waiting to run
Test / test (1.21, macos-latest) (push) Waiting to run
Test / test (1.21, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.21, ubuntu-latest) (push) Waiting to run
Test / test (1.21, windows-latest) (push) Waiting to run
Test / test (1.22, macos-15-intel) (push) Waiting to run
Test / test (1.22, macos-latest) (push) Waiting to run
Test / test (1.22, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.22, ubuntu-latest) (push) Waiting to run
Test / test (1.22, windows-latest) (push) Waiting to run
Test / test (1.23, macos-15-intel) (push) Waiting to run
Test / test (1.23, macos-latest) (push) Waiting to run
Test / test (1.23, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.23, ubuntu-latest) (push) Waiting to run
Test / test (1.23, windows-latest) (push) Waiting to run
Test / test (1.24, macos-15-intel) (push) Waiting to run
Test / test (1.24, macos-latest) (push) Waiting to run
Test / test (1.24, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.24, ubuntu-latest) (push) Waiting to run
Test / test (1.24, windows-latest) (push) Waiting to run
Test / test (1.25, macos-15-intel) (push) Waiting to run
Test / test (1.25, macos-latest) (push) Waiting to run
Test / test (1.25, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.25, ubuntu-latest) (push) Waiting to run
Test / test (1.25, windows-latest) (push) Waiting to run
Trigger CMFA Update / trigger-CMFA-update (push) Waiting to run

This commit is contained in:
wwqgtxx 2025-12-03 22:49:31 +08:00
parent 30891f8781
commit 32ce513977
2 changed files with 9 additions and 3 deletions

View File

@ -5,6 +5,7 @@ import (
"fmt" "fmt"
"io" "io"
"net" "net"
"strconv"
) )
func EncodeAddress(rawAddr string) ([]byte, error) { func EncodeAddress(rawAddr string) ([]byte, error) {
@ -13,7 +14,7 @@ func EncodeAddress(rawAddr string) ([]byte, error) {
return nil, err return nil, err
} }
portInt, err := net.LookupPort("udp", portStr) portInt, err := strconv.ParseUint(portStr, 10, 16)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -7,6 +7,8 @@ import (
"fmt" "fmt"
"io" "io"
"net" "net"
"net/netip"
"strconv"
"sync" "sync"
"time" "time"
@ -109,11 +111,14 @@ func (c *UoTPacketConn) ReadFrom(p []byte) (int, net.Addr, error) {
return 0, nil, io.ErrShortBuffer return 0, nil, io.ErrShortBuffer
} }
udpAddr, err := net.ResolveUDPAddr("udp", addrStr) host, port, _ := net.SplitHostPort(addrStr)
if err != nil { portInt, _ := strconv.ParseUint(port, 10, 16)
ip, err := netip.ParseAddr(host)
if err != nil { // disallow domain addr at here, just ignore
log.Debugln("[Sudoku][UoT] discard datagram with invalid address %s: %v", addrStr, err) log.Debugln("[Sudoku][UoT] discard datagram with invalid address %s: %v", addrStr, err)
continue continue
} }
udpAddr := net.UDPAddrFromAddrPort(netip.AddrPortFrom(ip.Unmap(), uint16(portInt)))
copy(p, payload) copy(p, payload)
return len(payload), udpAddr, nil return len(payload), udpAddr, nil