fix: auto detect interface add param[auto-detect-interface], default is true, only use it when tun is enabled
This commit is contained in:
parent
08bcec8feb
commit
d069d56860
1 changed files with 13 additions and 11 deletions
|
@ -170,11 +170,12 @@ type RawFallbackFilter struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type RawTun struct {
|
type RawTun struct {
|
||||||
Enable bool `yaml:"enable" json:"enable"`
|
Enable bool `yaml:"enable" json:"enable"`
|
||||||
Device string `yaml:"device" json:"device"`
|
Device string `yaml:"device" json:"device"`
|
||||||
Stack C.TUNStack `yaml:"stack" json:"stack"`
|
Stack C.TUNStack `yaml:"stack" json:"stack"`
|
||||||
DNSHijack []string `yaml:"dns-hijack" json:"dns-hijack"`
|
DNSHijack []string `yaml:"dns-hijack" json:"dns-hijack"`
|
||||||
AutoRoute bool `yaml:"auto-route" json:"auto-route"`
|
AutoRoute bool `yaml:"auto-route" json:"auto-route"`
|
||||||
|
AutoDetectInterface bool `yaml:"auto-detect-interface"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type RawConfig struct {
|
type RawConfig struct {
|
||||||
|
@ -237,11 +238,12 @@ func UnmarshalRawConfig(buf []byte) (*RawConfig, error) {
|
||||||
Proxy: []map[string]any{},
|
Proxy: []map[string]any{},
|
||||||
ProxyGroup: []map[string]any{},
|
ProxyGroup: []map[string]any{},
|
||||||
Tun: RawTun{
|
Tun: RawTun{
|
||||||
Enable: false,
|
Enable: false,
|
||||||
Device: "",
|
Device: "",
|
||||||
Stack: C.TunGvisor,
|
AutoDetectInterface: true,
|
||||||
DNSHijack: []string{"0.0.0.0:53"}, // default hijack all dns query
|
Stack: C.TunGvisor,
|
||||||
AutoRoute: true,
|
DNSHijack: []string{"0.0.0.0:53"}, // default hijack all dns query
|
||||||
|
AutoRoute: true,
|
||||||
},
|
},
|
||||||
IPTables: IPTables{
|
IPTables: IPTables{
|
||||||
Enable: false,
|
Enable: false,
|
||||||
|
@ -846,7 +848,7 @@ func parseAuthentication(rawRecords []string) []auth.AuthUser {
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseTun(rawTun RawTun, general *General) (*Tun, error) {
|
func parseTun(rawTun RawTun, general *General) (*Tun, error) {
|
||||||
if (rawTun.Enable || general.TProxyPort != 0) && general.Interface == "" {
|
if rawTun.Enable && rawTun.AutoDetectInterface {
|
||||||
autoDetectInterfaceName, err := commons.GetAutoDetectInterface()
|
autoDetectInterfaceName, err := commons.GetAutoDetectInterface()
|
||||||
if err != nil || autoDetectInterfaceName == "" {
|
if err != nil || autoDetectInterfaceName == "" {
|
||||||
log.Warnln("Can not find auto detect interface.[%s]", err)
|
log.Warnln("Can not find auto detect interface.[%s]", err)
|
||||||
|
|
Loading…
Reference in a new issue