Files
quarkslab-proxyblob/pkg/proxy/socks/udp_native.go
T
Atsika 5b21bc7cda Add WASM agent support for JavaScript runtimes
Compile the agent to WebAssembly for deployment in JS runtimes (Bun,
Node.js, or any runtime implementing the TCPDial/UDPListen interface).

- Split network and UDP code with js/native build tags
- Extract UDP relay into a platform-agnostic shared layer
- Expose runtime-agnostic TCPDial and UDPListen JS hooks
- Add azure-sdk-for-go fork as submodule for WASM-compatible mmf fallback
- Bump aznet dependency
- Document WASM build and JS interface in README
2026-03-21 19:45:24 +01:00

42 lines
751 B
Go

//go:build !js
package proxy
import (
"net"
"time"
)
type nativeUDPConn struct {
conn *net.UDPConn
}
func listenUDP() (UDPRelayConn, error) {
c, err := net.ListenUDP("udp", &net.UDPAddr{})
if err != nil {
return nil, err
}
return &nativeUDPConn{c}, nil
}
func (c *nativeUDPConn) LocalPort() int {
return c.conn.LocalAddr().(*net.UDPAddr).Port
}
func (c *nativeUDPConn) ReadFrom(b []byte) (int, *net.UDPAddr, error) {
return c.conn.ReadFromUDP(b)
}
func (c *nativeUDPConn) WriteTo(b []byte, addr *net.UDPAddr) error {
_, err := c.conn.WriteToUDP(b, addr)
return err
}
func (c *nativeUDPConn) SetReadDeadline(t time.Time) error {
return c.conn.SetReadDeadline(t)
}
func (c *nativeUDPConn) Close() error {
return c.conn.Close()
}