0e96f602fa
matcher: fix IPv6 normalization via netip.ParseAddr, port-range overwrite by switching to []*PortRange map, case-insensitive domain/host matching, glob.MustCompile→Compile to avoid panic on invalid patterns. plugin: guard nil *Options in NewGRPCConn and NewHTTPClient; add HTTPClientTransport helper for idle-connection cleanup. net/*: add doc comments for all exported symbols (no code changes). Add 30 tests (matcher_test.go 22, plugin_test.go 8) covering all matcher types, nil safety, case insensitivity, IPv6 normalization, port ranges, and plugin option composition.
34 lines
782 B
Go
34 lines
782 B
Go
package udp
|
|
|
|
import (
|
|
"io"
|
|
"net"
|
|
|
|
xnet "github.com/go-gost/x/internal/net"
|
|
)
|
|
|
|
// Conn is a net.PacketConn that also supports io.Reader, io.Writer, buffer
|
|
// sizing, syscall access, and remote address exposure.
|
|
type Conn interface {
|
|
net.PacketConn
|
|
io.Reader
|
|
io.Writer
|
|
ReadUDP
|
|
WriteUDP
|
|
xnet.SetBuffer
|
|
xnet.SyscallConn
|
|
xnet.RemoteAddr
|
|
}
|
|
|
|
// ReadUDP supports reading UDP datagrams with metadata.
|
|
type ReadUDP interface {
|
|
ReadFromUDP(b []byte) (n int, addr *net.UDPAddr, err error)
|
|
ReadMsgUDP(b, oob []byte) (n, oobn, flags int, addr *net.UDPAddr, err error)
|
|
}
|
|
|
|
// WriteUDP supports writing UDP datagrams with metadata.
|
|
type WriteUDP interface {
|
|
WriteToUDP(b []byte, addr *net.UDPAddr) (int, error)
|
|
WriteMsgUDP(b, oob []byte, addr *net.UDPAddr) (n, oobn int, err error)
|
|
}
|