mirror of
https://gitclone.com/github.com/MetaCubeX/Clash.Meta
synced 2025-02-23 20:52:15 +08:00
Chore: move experimental features to stable
This commit is contained in:
parent
14c9cf1b97
commit
2781090405
@ -37,7 +37,7 @@ $ go get -u -v github.com/Dreamacro/clash
|
|||||||
```
|
```
|
||||||
|
|
||||||
Pre-built binaries are available here: [release](https://github.com/Dreamacro/clash/releases)
|
Pre-built binaries are available here: [release](https://github.com/Dreamacro/clash/releases)
|
||||||
Pre-built Premium binaries are available here: [Premium release](https://github.com/Dreamacro/clash/releases/tag/premium). Source is not currently available.
|
Pre-built Premium binaries are available here: [premium release](https://github.com/Dreamacro/clash/releases/tag/premium). Source is not currently available.
|
||||||
|
|
||||||
Check Clash version with:
|
Check Clash version with:
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ $ clash -v
|
|||||||
|
|
||||||
## Daemonize Clash
|
## Daemonize Clash
|
||||||
|
|
||||||
Unfortunately, there is no native or elegant way to implement daemons on Golang. We recommend using third-party daemon management tools like PM2, Supervisor or the like to keep Clash running as a service.
|
We recommend using third-party daemon management tools like PM2, Supervisor or the like to keep Clash running as a service. ([Wiki](https://github.com/Dreamacro/clash/wiki/Clash-as-a-daemon))
|
||||||
|
|
||||||
In the case of [pm2](https://github.com/Unitech/pm2), start the daemon this way:
|
In the case of [pm2](https://github.com/Unitech/pm2), start the daemon this way:
|
||||||
|
|
||||||
@ -114,10 +114,7 @@ external-controller: 127.0.0.1:9090
|
|||||||
# Secret for RESTful API (Optional)
|
# Secret for RESTful API (Optional)
|
||||||
# secret: ""
|
# secret: ""
|
||||||
|
|
||||||
# experimental feature
|
# interface-name: en0 # outbound interface name
|
||||||
experimental:
|
|
||||||
ignore-resolve-fail: true # ignore dns resolve fail, default value is true
|
|
||||||
# interface-name: en0 # outbound interface name
|
|
||||||
|
|
||||||
# authentication of local SOCKS5/HTTP(S) server
|
# authentication of local SOCKS5/HTTP(S) server
|
||||||
# authentication:
|
# authentication:
|
||||||
|
@ -27,9 +27,10 @@ import (
|
|||||||
type General struct {
|
type General struct {
|
||||||
Inbound
|
Inbound
|
||||||
Controller
|
Controller
|
||||||
Mode T.TunnelMode `json:"mode"`
|
Mode T.TunnelMode `json:"mode"`
|
||||||
LogLevel log.LogLevel `json:"log-level"`
|
LogLevel log.LogLevel `json:"log-level"`
|
||||||
IPv6 bool `json:"ipv6"`
|
IPv6 bool `json:"ipv6"`
|
||||||
|
Interface string `json:"interface-name"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inbound
|
// Inbound
|
||||||
@ -70,10 +71,7 @@ type FallbackFilter struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Experimental config
|
// Experimental config
|
||||||
type Experimental struct {
|
type Experimental struct{}
|
||||||
IgnoreResolveFail bool `yaml:"ignore-resolve-fail"`
|
|
||||||
Interface string `yaml:"interface-name"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Config is clash config manager
|
// Config is clash config manager
|
||||||
type Config struct {
|
type Config struct {
|
||||||
@ -119,6 +117,7 @@ type RawConfig struct {
|
|||||||
ExternalController string `yaml:"external-controller"`
|
ExternalController string `yaml:"external-controller"`
|
||||||
ExternalUI string `yaml:"external-ui"`
|
ExternalUI string `yaml:"external-ui"`
|
||||||
Secret string `yaml:"secret"`
|
Secret string `yaml:"secret"`
|
||||||
|
Interface string `yaml:"interface-name"`
|
||||||
|
|
||||||
ProxyProvider map[string]map[string]interface{} `yaml:"proxy-providers"`
|
ProxyProvider map[string]map[string]interface{} `yaml:"proxy-providers"`
|
||||||
Hosts map[string]string `yaml:"hosts"`
|
Hosts map[string]string `yaml:"hosts"`
|
||||||
@ -157,9 +156,6 @@ func UnmarshalRawConfig(buf []byte) (*RawConfig, error) {
|
|||||||
Rule: []string{},
|
Rule: []string{},
|
||||||
Proxy: []map[string]interface{}{},
|
Proxy: []map[string]interface{}{},
|
||||||
ProxyGroup: []map[string]interface{}{},
|
ProxyGroup: []map[string]interface{}{},
|
||||||
Experimental: Experimental{
|
|
||||||
IgnoreResolveFail: true,
|
|
||||||
},
|
|
||||||
DNS: RawDNS{
|
DNS: RawDNS{
|
||||||
Enable: false,
|
Enable: false,
|
||||||
FakeIPRange: "198.18.0.1/16",
|
FakeIPRange: "198.18.0.1/16",
|
||||||
@ -253,9 +249,10 @@ func parseGeneral(cfg *RawConfig) (*General, error) {
|
|||||||
ExternalUI: cfg.ExternalUI,
|
ExternalUI: cfg.ExternalUI,
|
||||||
Secret: cfg.Secret,
|
Secret: cfg.Secret,
|
||||||
},
|
},
|
||||||
Mode: cfg.Mode,
|
Mode: cfg.Mode,
|
||||||
LogLevel: cfg.LogLevel,
|
LogLevel: cfg.LogLevel,
|
||||||
IPv6: cfg.IPv6,
|
IPv6: cfg.IPv6,
|
||||||
|
Interface: cfg.Interface,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,18 +118,7 @@ func GetGeneral() *config.General {
|
|||||||
return general
|
return general
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateExperimental(c *config.Config) {
|
func updateExperimental(c *config.Config) {}
|
||||||
cfg := c.Experimental
|
|
||||||
|
|
||||||
tunnel.UpdateExperimental(cfg.IgnoreResolveFail)
|
|
||||||
if cfg.Interface != "" && c.DNS.Enable {
|
|
||||||
dialer.DialHook = dialer.DialerWithInterface(cfg.Interface)
|
|
||||||
dialer.ListenPacketHook = dialer.ListenPacketWithInterface(cfg.Interface)
|
|
||||||
} else {
|
|
||||||
dialer.DialHook = nil
|
|
||||||
dialer.ListenPacketHook = nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func updateDNS(c *config.DNS) {
|
func updateDNS(c *config.DNS) {
|
||||||
if c.Enable == false {
|
if c.Enable == false {
|
||||||
@ -179,6 +168,14 @@ func updateGeneral(general *config.General, force bool) {
|
|||||||
tunnel.SetMode(general.Mode)
|
tunnel.SetMode(general.Mode)
|
||||||
resolver.DisableIPv6 = !general.IPv6
|
resolver.DisableIPv6 = !general.IPv6
|
||||||
|
|
||||||
|
if cfg.Interface != "" {
|
||||||
|
dialer.DialHook = dialer.DialerWithInterface(cfg.Interface)
|
||||||
|
dialer.ListenPacketHook = dialer.ListenPacketWithInterface(cfg.Interface)
|
||||||
|
} else {
|
||||||
|
dialer.DialHook = nil
|
||||||
|
dialer.ListenPacketHook = nil
|
||||||
|
}
|
||||||
|
|
||||||
if !force {
|
if !force {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -28,9 +28,6 @@ var (
|
|||||||
configMux sync.RWMutex
|
configMux sync.RWMutex
|
||||||
enhancedMode *dns.Resolver
|
enhancedMode *dns.Resolver
|
||||||
|
|
||||||
// experimental features
|
|
||||||
ignoreResolveFail bool
|
|
||||||
|
|
||||||
// Outbound Rule
|
// Outbound Rule
|
||||||
mode = Rule
|
mode = Rule
|
||||||
|
|
||||||
@ -82,13 +79,6 @@ func UpdateProxies(newProxies map[string]C.Proxy, newProviders map[string]provid
|
|||||||
configMux.Unlock()
|
configMux.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateExperimental handle update experimental config
|
|
||||||
func UpdateExperimental(value bool) {
|
|
||||||
configMux.Lock()
|
|
||||||
ignoreResolveFail = value
|
|
||||||
configMux.Unlock()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Mode return current mode
|
// Mode return current mode
|
||||||
func Mode() TunnelMode {
|
func Mode() TunnelMode {
|
||||||
return mode
|
return mode
|
||||||
@ -318,9 +308,6 @@ func match(metadata *C.Metadata) (C.Proxy, C.Rule, error) {
|
|||||||
if !resolved && shouldResolveIP(rule, metadata) {
|
if !resolved && shouldResolveIP(rule, metadata) {
|
||||||
ip, err := resolver.ResolveIP(metadata.Host)
|
ip, err := resolver.ResolveIP(metadata.Host)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !ignoreResolveFail {
|
|
||||||
return nil, nil, fmt.Errorf("[DNS] resolve %s error: %s", metadata.Host, err.Error())
|
|
||||||
}
|
|
||||||
log.Debugln("[DNS] resolve %s error: %s", metadata.Host, err.Error())
|
log.Debugln("[DNS] resolve %s error: %s", metadata.Host, err.Error())
|
||||||
} else {
|
} else {
|
||||||
log.Debugln("[DNS] %s --> %s", metadata.Host, ip.String())
|
log.Debugln("[DNS] %s --> %s", metadata.Host, ip.String())
|
||||||
|
Loading…
Reference in New Issue
Block a user