mirror of
https://github.com/tinygo-org/net.git
synced 2026-08-08 13:43:38 +00:00
net: add UDP listen, resolver, DNSError, and TCP listener APIs for wasm (#63)
* 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. * more complete PR for adding more net support (#64) * format unixsock
This commit is contained in:
@@ -2779,6 +2779,23 @@ type Server struct {
|
||||
// value.
|
||||
ConnContext func(ctx context.Context, c net.Conn) context.Context
|
||||
|
||||
// TLSNextProto optionally specifies a function to take over
|
||||
// ownership of the provided TLS connection when an ALPN
|
||||
// protocol upgrade has occurred. The map key is the protocol
|
||||
// name negotiated. The Handler argument should be used to
|
||||
// handle HTTP requests and will initialize the Request's TLS
|
||||
// and RemoteAddr if not already set. The connection is
|
||||
// automatically closed when the function returns.
|
||||
// If TLSNextProto is not nil, HTTP/2 support is not enabled
|
||||
// automatically.
|
||||
TLSNextProto map[string]func(*Server, *tls.Conn, Handler)
|
||||
|
||||
// HTTP2 configures HTTP/2 connections.
|
||||
//
|
||||
// This field does not yet have any effect.
|
||||
// See https://go.dev/issue/67813.
|
||||
HTTP2 *HTTP2Config
|
||||
|
||||
inShutdown atomicBool // true when server is in shutdown
|
||||
|
||||
disableKeepAlives int32 // accessed atomically.
|
||||
|
||||
Reference in New Issue
Block a user