net: add UDP listen, resolver, DNSError, and TCP listener APIs for wasm

TinyGo's net package was missing several symbols that upstream Go's
js/wasm net declares, blocking builds that pull pion/transport, pion/dtls,
and similar (via netbird's WASM client). Add them, backed by the existing
netdev abstraction so they compile for all targets and no-op cleanly under
nopNetdev (matching Go's js runtime behavior):

- DNSError type (dnserror.go), copied from Go 1.26.2.
- Resolver + DefaultResolver with LookupHost/LookupIP/LookupIPAddr/
  LookupNetIP/LookupPort; LookupHost/LookupIP package funcs; Dialer.Resolver
  field for API compatibility.
- UDPConn: ListenUDP, ReadFromUDP(AddrPort), WriteToUDP(AddrPort),
  SetReadBuffer, SetWriteBuffer.
- TCPConn: CloseRead, SetNoDelay, SetReadBuffer, SetWriteBuffer,
  ReadFrom(io.Reader).
- TCPListener: ListenTCP, AcceptTCP, SetDeadline; ListenPacket package func.
- Interface: Addrs, MulticastAddrs stubs.
This commit is contained in:
Patricio Whittingslow
2026-07-01 22:34:14 -03:00
parent 1026408a38
commit 2e825c2b01
6 changed files with 420 additions and 0 deletions
+16
View File
@@ -35,6 +35,22 @@ type Interface struct {
Flags Flags // e.g., FlagUp, FlagLoopback, FlagMulticast
}
// Addrs returns a list of unicast interface addresses for a specific
// interface.
//
// TINYGO: not implemented; netdev exposes no per-interface address list.
func (ifi *Interface) Addrs() ([]Addr, error) {
return nil, errors.New("Interface.Addrs not implemented")
}
// MulticastAddrs returns a list of multicast, joined group addresses
// for a specific interface.
//
// TINYGO: not implemented; netdev exposes no per-interface address list.
func (ifi *Interface) MulticastAddrs() ([]Addr, error) {
return nil, errors.New("Interface.MulticastAddrs not implemented")
}
type Flags uint
const (