mirror of
https://github.com/SagerNet/sing-box.git
synced 2025-04-03 20:07:36 +03:00
refactor: Outbound domain resolver
This commit is contained in:
parent
6c9e61a0a0
commit
360b25e53c
33 changed files with 392 additions and 167 deletions
|
@ -4,6 +4,7 @@ import (
|
|||
"context"
|
||||
"errors"
|
||||
"net"
|
||||
"net/netip"
|
||||
"os"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
@ -55,13 +56,21 @@ type NetworkManager struct {
|
|||
}
|
||||
|
||||
func NewNetworkManager(ctx context.Context, logger logger.ContextLogger, routeOptions option.RouteOptions) (*NetworkManager, error) {
|
||||
defaultDomainResolver := common.PtrValueOrDefault(routeOptions.DefaultDomainResolver)
|
||||
nm := &NetworkManager{
|
||||
logger: logger,
|
||||
interfaceFinder: control.NewDefaultInterfaceFinder(),
|
||||
autoDetectInterface: routeOptions.AutoDetectInterface,
|
||||
defaultOptions: adapter.NetworkOptions{
|
||||
BindInterface: routeOptions.DefaultInterface,
|
||||
RoutingMark: uint32(routeOptions.DefaultMark),
|
||||
BindInterface: routeOptions.DefaultInterface,
|
||||
RoutingMark: uint32(routeOptions.DefaultMark),
|
||||
DomainResolver: defaultDomainResolver.Server,
|
||||
DomainResolveOptions: adapter.DNSQueryOptions{
|
||||
Strategy: C.DomainStrategy(defaultDomainResolver.Strategy),
|
||||
DisableCache: defaultDomainResolver.DisableCache,
|
||||
RewriteTTL: defaultDomainResolver.RewriteTTL,
|
||||
ClientSubnet: defaultDomainResolver.ClientSubnet.Build(netip.Prefix{}),
|
||||
},
|
||||
NetworkStrategy: (*C.NetworkStrategy)(routeOptions.DefaultNetworkStrategy),
|
||||
NetworkType: common.Map(routeOptions.DefaultNetworkType, option.InterfaceType.Build),
|
||||
FallbackNetworkType: common.Map(routeOptions.DefaultFallbackNetworkType, option.InterfaceType.Build),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue