Skip to content

Commit 0baef6c

Browse files
committed
fix: set default interface values for proxy servers
1 parent e35b333 commit 0baef6c

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

tunnels/wireguard/tcp/tcp.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ type Config struct {
4343
KeepaliveCount int
4444
Tnet *netstack.Net
4545
StackLock *sync.Mutex
46-
Underlying net.Interface
46+
// Underlying net.Interface
4747

4848
Addr tcpip.Address
4949
}
@@ -128,7 +128,7 @@ func checkDst(config *Config, s stack.TransportEndpointID) (net.Conn, bool) {
128128

129129
ctx, cancel := context.WithTimeout(context.Background(), config.ConnTimeout)
130130
defer cancel()
131-
c, err := config.Underlying.DialContext(ctx, "tcp", gnet.JoinHostPort(s.LocalAddress.String(), fmt.Sprint(s.LocalPort)))
131+
c, err := net.DefaultRouteTable.DialContext(ctx, "tcp", gnet.JoinHostPort(s.LocalAddress.String(), fmt.Sprint(s.LocalPort)))
132132

133133
// c, err := gonet.DialTCPWithBind(ctx, config.Tnet.Stack(), tcpip.FullAddress{
134134
// NIC: 1,

tunnels/wireguard/udp/udp.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ var connMapLock = sync.RWMutex{}
5353
type Config struct {
5454
Tnet *netstack.Net
5555
StackLock *sync.Mutex
56+
57+
Underlying net.Interface
5658
}
5759

5860
// Handler handles UDP packets. Returns function that returns true if packet is handled, or false if ICMP Destination Unreachable should be sent.

ui/builtin.go

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -632,8 +632,13 @@ var _builtin_refs_assertions = map[string]Assert{
632632
},
633633
},
634634
"builtin::http::forwardproxier": {
635-
Type: "null",
636-
Desc: "HTTP forward proxy implementation (no configuration needed)",
635+
Type: "map",
636+
Sub: AssertMap{
637+
"interface": {
638+
Type: "ptr",
639+
Default: &net.SysInterface{},
640+
},
641+
},
637642
},
638643
"builtin::http::acme::fileprovider": {
639644
Type: "map",
@@ -946,8 +951,8 @@ var _builtin_refs_assertions = map[string]Assert{
946951
},
947952
},
948953
"interface": {
949-
Type: "ptr",
950-
Required: false,
954+
Type: "ptr",
955+
Default: &net.SysInterface{},
951956
},
952957
},
953958
},
@@ -1442,7 +1447,10 @@ var _builtin_refs = map[string]Inst{
14421447
return Dns, nil
14431448
},
14441449
"builtin::http::forwardproxier": func(spec *ArgNode) (any, error) {
1445-
return &thttp.StdForwardProxy{}, nil
1450+
1451+
underlying := spec.MustGet("interface").Value.(net.Interface)
1452+
1453+
return &thttp.StdForwardProxy{Underlying: underlying}, nil
14461454
},
14471455
// "builtin::http::fwdforwardproxier": func(spec *ArgNode) (any, error) {
14481456
// proxyurl := spec.MustGet("ProxyURL").ToString()

0 commit comments

Comments
 (0)