-
-
Notifications
You must be signed in to change notification settings - Fork 588
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid using custom dialers for proxy when not mobile #2229
Avoid using custom dialers for proxy when not mobile #2229
Conversation
|
if runtime.GOOS == "ios" || runtime.GOOS == "android" { | ||
p.localConn, err = nbnet.NewDialer().DialContext(p.ctx, "udp", fmt.Sprintf(":%d", p.localWGListenPort)) | ||
} else { | ||
p.localConn, err = net.Dial("udp", fmt.Sprintf(":%d", p.localWGListenPort)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use DialContext here regardless?
@@ -72,10 +73,10 @@ func (p *WGEBPFProxy) listen() error { | |||
|
|||
addr := net.UDPAddr{ | |||
Port: wgPorxyPort, | |||
IP: net.ParseIP("127.0.0.1"), | |||
IP: net.ParseIP(loopbackIPv4Addres), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe something like net.IP{127, 0, 0, 1}
is a bit better here.
err = nbnet.SetSocketOpt(fd) | ||
if err != nil { | ||
return nil, fmt.Errorf("setting fwmark failed: %w", err) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only block that should be removed. The other stuff should stay, we should still check if os.NewFile returns nil.
@@ -35,7 +36,11 @@ func (p *WGUserSpaceProxy) AddTurnConn(turnConn net.Conn) (net.Addr, error) { | |||
p.remoteConn = turnConn | |||
|
|||
var err error | |||
p.localConn, err = nbnet.NewDialer().DialContext(p.ctx, "udp", fmt.Sprintf(":%d", p.localWGListenPort)) | |||
if runtime.GOOS == "ios" || runtime.GOOS == "android" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be android only, iOS already calls net.Dial
underneath anyway. I'm not sure about Android either, it likely has 127.0.0.0/8
in the local
table as well, so there might be no need to protect the socket there.
Describe your changes
Issue ticket number and link
Checklist