mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-11-06 10:12:40 +00:00
WireGuard proxy: Give up on the endpoint lookup at the connection's deadline (#7323)
https://github.com/XTLS/Xray-core/pull/7323#issuecomment-6623261000
This commit is contained in:
@@ -17,7 +17,7 @@ import (
|
||||
|
||||
type bind struct {
|
||||
ctx context.Context
|
||||
resolveFunc func(host string) (net.IP, error)
|
||||
resolveFunc func(ctx context.Context, host string) (net.IP, error)
|
||||
listenFunc func(ctx context.Context) (net.PacketConn, error)
|
||||
downFunc func() error
|
||||
reserved []byte
|
||||
@@ -143,7 +143,11 @@ func (b *bind) ParseEndpoint(s string) (conn.Endpoint, error) {
|
||||
if port < 0 || port > 65535 {
|
||||
return nil, errors.New("invalid port " + sport)
|
||||
}
|
||||
ip, err := b.resolveFunc(host)
|
||||
// up sets the connection's context right before it hands over the endpoint
|
||||
b.mu.Lock()
|
||||
ctx := b.ctx
|
||||
b.mu.Unlock()
|
||||
ip, err := b.resolveFunc(ctx, host)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user