Add DERP inbound

This commit is contained in:
世界 2025-03-28 12:56:43 +08:00
parent 68df19ae13
commit 17962f5e65
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
10 changed files with 555 additions and 19 deletions

View file

@ -149,6 +149,17 @@ func NewEndpoint(ctx context.Context, router adapter.Router, logger log.ContextL
return dnsRouter.Lookup(ctx, host, outboundDialer.(dialer.ResolveDialer).QueryOptions())
},
DNS: &dnsConfigurtor{},
HTTPClient: &http.Client{
Transport: &http.Transport{
ForceAttemptHTTP2: true,
DialContext: func(ctx context.Context, network, address string) (net.Conn, error) {
return outboundDialer.DialContext(ctx, network, M.ParseSocksaddr(address))
},
TLSClientConfig: &tls.Config{
RootCAs: adapter.RootPoolFromContext(ctx),
},
},
},
}
return &Endpoint{
Adapter: endpoint.NewAdapter(C.TypeTailscale, tag, []string{N.NetworkTCP, N.NetworkUDP}, nil),
@ -214,18 +225,6 @@ func (t *Endpoint) Start(stage adapter.StartStage) error {
t.stack = ipStack
localBackend := t.server.ExportLocalBackend()
localBackend.SetHTTPTestClient(&http.Client{
Transport: &http.Transport{
ForceAttemptHTTP2: true,
DialContext: func(ctx context.Context, network, address string) (net.Conn, error) {
return t.server.Dialer.DialContext(ctx, network, M.ParseSocksaddr(address))
},
TLSClientConfig: &tls.Config{
RootCAs: adapter.RootPoolFromContext(t.ctx),
},
},
})
perfs := &ipn.MaskedPrefs{
ExitNodeIPSet: true,
AdvertiseRoutesSet: true,