[skip ci][内容]

1.调整部分代码
This commit is contained in:
gVisor bot 2022-03-20 02:39:48 +08:00
parent 29b8076c75
commit 652759a9ae
3 changed files with 11 additions and 17 deletions

View file

@ -74,16 +74,14 @@ func ApplyConfig(cfg *config.Config, force bool) {
mux.Lock() mux.Lock()
defer mux.Unlock() defer mux.Unlock()
log.SetLevel(log.INFO)
updateUsers(cfg.Users) updateUsers(cfg.Users)
updateHosts(cfg.Hosts) updateHosts(cfg.Hosts)
updateGeneral(cfg.General, force)
updateProxies(cfg.Proxies, cfg.Providers) updateProxies(cfg.Proxies, cfg.Providers)
updateRules(cfg.Rules, cfg.RuleProviders) updateRules(cfg.Rules, cfg.RuleProviders)
updateIPTables(cfg.DNS, cfg.General, cfg.Tun) updateGeneral(cfg.General, force)
updateDNS(cfg.DNS, cfg.Tun) updateDNS(cfg.DNS, cfg.Tun)
updateTun(cfg.Tun) updateTun(cfg.Tun)
updateIPTables(cfg.DNS, cfg.General, cfg.Tun)
updateExperimental(cfg) updateExperimental(cfg)
loadProvider(cfg.RuleProviders, cfg.Providers) loadProvider(cfg.RuleProviders, cfg.Providers)
updateProfile(cfg) updateProfile(cfg)
@ -93,7 +91,7 @@ func ApplyConfig(cfg *config.Config, force bool) {
func GetGeneral() *config.General { func GetGeneral() *config.General {
ports := P.GetPorts() ports := P.GetPorts()
authenticator := []string{} var authenticator []string
if auth := authStore.Authenticator(); auth != nil { if auth := authStore.Authenticator(); auth != nil {
authenticator = auth.Users() authenticator = auth.Users()
} }
@ -218,20 +216,21 @@ func updateTun(tun *config.Tun) {
} }
func updateGeneral(general *config.General, force bool) { func updateGeneral(general *config.General, force bool) {
log.SetLevel(general.LogLevel)
tunnel.SetMode(general.Mode) tunnel.SetMode(general.Mode)
resolver.DisableIPv6 = !general.IPv6 resolver.DisableIPv6 = !general.IPv6
adapter.UnifiedDelay.Store(general.UnifiedDelay) adapter.UnifiedDelay.Store(general.UnifiedDelay)
dialer.DefaultInterface.Store(general.Interface) dialer.DefaultInterface.Store(general.Interface)
if dialer.DefaultInterface.Load() != "" { if dialer.DefaultInterface.Load() != "" {
log.Infoln("Use interface name: %s", general.Interface) log.Infoln("Use interface name: %s", general.Interface)
} }
if general.RoutingMark > 0 || (general.RoutingMark == 0 && general.TProxyPort == 0) { dialer.DefaultRoutingMark.Store(int32(general.RoutingMark))
dialer.DefaultRoutingMark.Store(int32(general.RoutingMark)) if general.RoutingMark > 0 {
if general.RoutingMark > 0 { log.Infoln("Use routing mark: %#x", general.RoutingMark)
log.Infoln("Use routing mark: %#x", general.RoutingMark)
}
} }
iface.FlushCache() iface.FlushCache()

View file

@ -77,9 +77,6 @@ func NewTCPTracker(conn C.Conn, manager *Manager, metadata *C.Metadata, rule C.R
if rule != nil { if rule != nil {
t.trackerInfo.Rule = rule.RuleType().String() t.trackerInfo.Rule = rule.RuleType().String()
t.trackerInfo.RulePayload = rule.Payload() t.trackerInfo.RulePayload = rule.Payload()
//if rule.RuleType() == C.GEOSITE || rule.RuleType() == C.GEOIP {
// t.trackerInfo.Rule = t.trackerInfo.Rule + " (" + rule.Payload() + ")"
//}
} }
manager.Join(t) manager.Join(t)
@ -137,9 +134,6 @@ func NewUDPTracker(conn C.PacketConn, manager *Manager, metadata *C.Metadata, ru
if rule != nil { if rule != nil {
ut.trackerInfo.Rule = rule.RuleType().String() ut.trackerInfo.Rule = rule.RuleType().String()
ut.trackerInfo.RulePayload = rule.Payload() ut.trackerInfo.RulePayload = rule.Payload()
//if rule.RuleType() == C.GEOSITE || rule.RuleType() == C.GEOIP {
// ut.trackerInfo.Rule = ut.trackerInfo.Rule + " (" + rule.Payload() + ")"
//}
} }
manager.Join(ut) manager.Join(ut)

View file

@ -28,8 +28,9 @@ var (
rules []C.Rule rules []C.Rule
proxies = make(map[string]C.Proxy) proxies = make(map[string]C.Proxy)
providers map[string]provider.ProxyProvider providers map[string]provider.ProxyProvider
configMux sync.RWMutex
ruleProviders map[string]*provider.RuleProvider ruleProviders map[string]*provider.RuleProvider
configMux sync.RWMutex
// Outbound Rule // Outbound Rule
mode = Rule mode = Rule