@@ -11,6 +11,7 @@ import (
11
11
"encoding/hex"
12
12
"errors"
13
13
"fmt"
14
+ N "github.com/sagernet/sing/common/network"
14
15
"github.com/sagernet/tailscale/net/dnscache"
15
16
"io"
16
17
"log"
@@ -122,7 +123,8 @@ type Server struct {
122
123
// field at zero unless you know what you are doing.
123
124
Port uint16
124
125
125
- LookupHook dnscache.LookupHookFunc
126
+ Dialer N.Dialer
127
+ LookupHook dnscache.LookupHookFunc
126
128
127
129
getCertForTesting func (* tls.ClientHelloInfo ) (* tls.Certificate , error )
128
130
@@ -274,7 +276,7 @@ func (s *Server) Loopback() (addr string, proxyCred, localAPICred string, err er
274
276
// out the CONNECT code from tailscaled/proxy.go that uses
275
277
// httputil.ReverseProxy and adding auth support.
276
278
go func () {
277
- lah := localapi .NewHandler (s .lb , s .logf , s .logid )
279
+ lah := localapi .NewHandler (s .lb , s .logf , s .logid , s . netMon . Dialer () )
278
280
lah .PermitWrite = true
279
281
lah .PermitRead = true
280
282
lah .RequiredPassword = s .localAPICred
@@ -557,13 +559,13 @@ func (s *Server) start() (reterr error) {
557
559
return err
558
560
}
559
561
560
- s .netMon , err = netmon .New (tsLogf )
562
+ s .netMon , err = netmon .New (tsLogf , s . Dialer )
561
563
if err != nil {
562
564
return err
563
565
}
564
566
closePool .add (s .netMon )
565
567
566
- s .dialer = & tsdial.Dialer {Logf : tsLogf } // mutated below (before used)
568
+ s .dialer = & tsdial.Dialer {Logf : tsLogf , Dialer : s . Dialer } // mutated below (before used)
567
569
eng , err := wgengine .NewUserspaceEngine (tsLogf , wgengine.Config {
568
570
ListenPort : s .Port ,
569
571
NetMon : s .netMon ,
@@ -668,7 +670,7 @@ func (s *Server) start() (reterr error) {
668
670
//go s.printAuthURLLoop()
669
671
670
672
// Run the localapi handler, to allow fetching LetsEncrypt certs.
671
- lah := localapi .NewHandler (lb , tsLogf , s .logid )
673
+ lah := localapi .NewHandler (lb , tsLogf , s .logid , s . netMon . Dialer () )
672
674
lah .PermitWrite = true
673
675
lah .PermitRead = true
674
676
0 commit comments