mirror of
https://github.com/soypat/lneto.git
synced 2026-08-17 05:13:27 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4517010070 |
+3
-12
@@ -162,11 +162,9 @@ func (s StackGo) SocketNetip(ctx context.Context, network string, family, sotype
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
uc := udpconn{
|
uc := udpconn{
|
||||||
Conn: &conn,
|
Conn: &conn,
|
||||||
// TODO: use udpaddr until UDPAddrFromAddrPort added to tinygo.
|
localAddr: net.UDPAddrFromAddrPort(laddr),
|
||||||
// https://github.com/tinygo-org/net/issues/45
|
raddr: net.UDPAddrFromAddrPort(raddr),
|
||||||
localAddr: udpaddr(laddr),
|
|
||||||
raddr: udpaddr(raddr),
|
|
||||||
}
|
}
|
||||||
return uc, nil
|
return uc, nil
|
||||||
case "tcp", "tcp4", "tcp6":
|
case "tcp", "tcp4", "tcp6":
|
||||||
@@ -384,13 +382,6 @@ func (c udpconn) ReadFrom(b []byte) (int, net.Addr, error) {
|
|||||||
func (c udpconn) WriteTo(b []byte, _ net.Addr) (int, error) {
|
func (c udpconn) WriteTo(b []byte, _ net.Addr) (int, error) {
|
||||||
return c.Conn.Write(b) // connected UDP: always writes to dialed remote
|
return c.Conn.Write(b) // connected UDP: always writes to dialed remote
|
||||||
}
|
}
|
||||||
func udpaddr(addr netip.AddrPort) net.Addr {
|
|
||||||
return &net.UDPAddr{
|
|
||||||
IP: addr.Addr().AsSlice(),
|
|
||||||
Zone: addr.Addr().Zone(),
|
|
||||||
Port: int(addr.Port()),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// parseNetAddr converts a [net.Addr] to a [netip.AddrPort]. A nil or empty IP
|
// parseNetAddr converts a [net.Addr] to a [netip.AddrPort]. A nil or empty IP
|
||||||
// (e.g. ":22" from a listen address with no host) is treated as 0.0.0.0 so
|
// (e.g. ":22" from a listen address with no host) is treated as 0.0.0.0 so
|
||||||
|
|||||||
Reference in New Issue
Block a user