Skip to content

Commit

Permalink
🧂 Work around golang/go#52264
Browse files Browse the repository at this point in the history
  • Loading branch information
database64128 committed Apr 10, 2022
1 parent b330ff9 commit 35c742d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions service/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@ func (c *client) Start() (err error) {
c.proxyAddr = rudpaddr.AddrPort()
}

// Workaround for https://github.com/golang/go/issues/52264
if c.proxyAddr.Addr().Is4() {
addr6 := c.proxyAddr.Addr().As16()
ip := netip.AddrFrom16(addr6)
port := c.proxyAddr.Port()
c.proxyAddr = netip.AddrPortFrom(ip, port)
}

// maxProxyPacketSize = MTU - IP header length - UDP header length
if c.proxyAddr.Addr().Is4() {
c.maxProxyPacketSize = c.config.MTU - IPv4HeaderLength - UDPHeaderLength
Expand Down
8 changes: 8 additions & 0 deletions service/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ func (s *server) Start() (err error) {
s.wgAddr = rudpaddr.AddrPort()
}

// Workaround for https://github.com/golang/go/issues/52264
if s.wgAddr.Addr().Is4() {
addr6 := s.wgAddr.Addr().As16()
ip := netip.AddrFrom16(addr6)
port := s.wgAddr.Port()
s.wgAddr = netip.AddrPortFrom(ip, port)
}

// Start listener.
var serr error
s.proxyConn, err, serr = conn.ListenUDP("udp", s.config.ProxyListen, s.config.ProxyFwmark)
Expand Down

0 comments on commit 35c742d

Please sign in to comment.