Skip to content

Commit

Permalink
Chore: move experimental features to stable
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreamacro committed Jun 27, 2020
1 parent 14c9cf1 commit 2781090
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 44 deletions.
9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 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:

Expand All @@ -47,7 +47,7 @@ $ clash -v

## 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:

Expand Down Expand Up @@ -114,10 +114,7 @@ external-controller: 127.0.0.1:9090
# Secret for RESTful API (Optional)
# secret: ""

# experimental feature
experimental:
ignore-resolve-fail: true # ignore dns resolve fail, default value is true
# interface-name: en0 # outbound interface name
# interface-name: en0 # outbound interface name

# authentication of local SOCKS5/HTTP(S) server
# authentication:
Expand Down
23 changes: 10 additions & 13 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ import (
type General struct {
Inbound
Controller
Mode T.TunnelMode `json:"mode"`
LogLevel log.LogLevel `json:"log-level"`
IPv6 bool `json:"ipv6"`
Mode T.TunnelMode `json:"mode"`
LogLevel log.LogLevel `json:"log-level"`
IPv6 bool `json:"ipv6"`
Interface string `json:"interface-name"`
}

// Inbound
Expand Down Expand Up @@ -70,10 +71,7 @@ type FallbackFilter struct {
}

// Experimental config
type Experimental struct {
IgnoreResolveFail bool `yaml:"ignore-resolve-fail"`
Interface string `yaml:"interface-name"`
}
type Experimental struct{}

// Config is clash config manager
type Config struct {
Expand Down Expand Up @@ -119,6 +117,7 @@ type RawConfig struct {
ExternalController string `yaml:"external-controller"`
ExternalUI string `yaml:"external-ui"`
Secret string `yaml:"secret"`
Interface string `yaml:"interface-name"`

ProxyProvider map[string]map[string]interface{} `yaml:"proxy-providers"`
Hosts map[string]string `yaml:"hosts"`
Expand Down Expand Up @@ -157,9 +156,6 @@ func UnmarshalRawConfig(buf []byte) (*RawConfig, error) {
Rule: []string{},
Proxy: []map[string]interface{}{},
ProxyGroup: []map[string]interface{}{},
Experimental: Experimental{
IgnoreResolveFail: true,
},
DNS: RawDNS{
Enable: false,
FakeIPRange: "198.18.0.1/16",
Expand Down Expand Up @@ -253,9 +249,10 @@ func parseGeneral(cfg *RawConfig) (*General, error) {
ExternalUI: cfg.ExternalUI,
Secret: cfg.Secret,
},
Mode: cfg.Mode,
LogLevel: cfg.LogLevel,
IPv6: cfg.IPv6,
Mode: cfg.Mode,
LogLevel: cfg.LogLevel,
IPv6: cfg.IPv6,
Interface: cfg.Interface,
}, nil
}

Expand Down
21 changes: 9 additions & 12 deletions hub/executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,18 +118,7 @@ func GetGeneral() *config.General {
return general
}

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 updateExperimental(c *config.Config) {}

func updateDNS(c *config.DNS) {
if c.Enable == false {
Expand Down Expand Up @@ -179,6 +168,14 @@ func updateGeneral(general *config.General, force bool) {
tunnel.SetMode(general.Mode)
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 {
return
}
Expand Down
13 changes: 0 additions & 13 deletions tunnel/tunnel.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ var (
configMux sync.RWMutex
enhancedMode *dns.Resolver

// experimental features
ignoreResolveFail bool

// Outbound Rule
mode = Rule

Expand Down Expand Up @@ -82,13 +79,6 @@ func UpdateProxies(newProxies map[string]C.Proxy, newProviders map[string]provid
configMux.Unlock()
}

// UpdateExperimental handle update experimental config
func UpdateExperimental(value bool) {
configMux.Lock()
ignoreResolveFail = value
configMux.Unlock()
}

// Mode return current mode
func Mode() TunnelMode {
return mode
Expand Down Expand Up @@ -318,9 +308,6 @@ func match(metadata *C.Metadata) (C.Proxy, C.Rule, error) {
if !resolved && shouldResolveIP(rule, metadata) {
ip, err := resolver.ResolveIP(metadata.Host)
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())
} else {
log.Debugln("[DNS] %s --> %s", metadata.Host, ip.String())
Expand Down

0 comments on commit 2781090

Please sign in to comment.