Skip to content

Commit

Permalink
Merge branch 'master' into v2
Browse files Browse the repository at this point in the history
  • Loading branch information
nange committed Dec 8, 2023
2 parents 6292c9c + 6ecb992 commit 45aa56d
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 40 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,7 @@ your-custom-domain.com

手机客户端apk文件可直接在[release页面](https://github.com/nange/easyss/releases)下载。

用法:创建Easyss配置项:点击右上角+图标 -> 手动输入 -> 选择Easyss

注意: 在菜单路由项里面,把绕过:中国域名规则和中国IP规则,勾选上。这样对于绝大部分国内的APP和网站就不会走代理了。
注意: 可将常用的国内大流量APP勾选上跳过,这样可减少电量消耗。当然不选也没关系,Easyss会自动判断该直连还是走代理。

### 服务器端
和客户端一样, 同样先创建配置文件`config.json`,并配置文件和二进制`easyss-server`放同一目录中。
Expand Down
Binary file modified assets/img/tray3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion cmd/easyss/tray.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (st *SysTray) AddProxyRuleMenu() (*systray.MenuItem, *systray.MenuItem, *sy

autoBlock := proxyMenue.AddSubMenuItemCheckbox("自动+屏蔽广告跟踪", "自动判断请求是否走代理或者屏蔽", false)
if st.SS().ProxyRule() == easyss.ProxyRuleAutoBlock {
auto.Check()
autoBlock.Check()
}

reverseAuto := proxyMenue.AddSubMenuItemCheckbox("反向自动(国外访问国内)", "适用国外访问国内IP域名", false)
Expand Down
56 changes: 46 additions & 10 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,52 @@ import (
"github.com/nange/easyss/v2/util"
)

var Methods = map[string]struct{}{
type ProxyRule int

const (
ProxyRuleUnknown ProxyRule = iota
ProxyRuleAuto
ProxyRuleReverseAuto
ProxyRuleProxy
ProxyRuleDirect
ProxyRuleAutoBlock
)

var proxyRules = map[string]ProxyRule{
"auto": ProxyRuleAuto,
"reverse_auto": ProxyRuleReverseAuto,
"proxy": ProxyRuleProxy,
"direct": ProxyRuleDirect,
"auto_block": ProxyRuleAutoBlock,
}

func ParseProxyRuleFromString(rule string) ProxyRule {
if r, ok := proxyRules[rule]; ok {
return r
}

return ProxyRuleUnknown
}

func AllProxyRule() []string {
keys := make([]string, 0, len(proxyRules))
for k := range proxyRules {
keys = append(keys, k)
}
return keys
}

var methods = map[string]struct{}{
"aes-256-gcm": {},
"chacha20-poly1305": {},
}

var ProxyRules = map[string]struct{}{
"auto": {},
"auto_block": {},
"proxy": {},
"direct": {},
func AllMethod() []string {
keys := make([]string, 0, len(methods))
for k := range proxyRules {
keys = append(keys, k)
}
return keys
}

const (
Expand Down Expand Up @@ -134,8 +170,8 @@ func (c *Config) Validate() error {
}
}
if c.Method != "" {
if _, ok := Methods[c.Method]; !ok {
return fmt.Errorf("unsupported method:%s, supported methods:[aes-256-gcm, chacha20-poly1305]", c.Method)
if _, ok := methods[c.Method]; !ok {
return fmt.Errorf("unsupported method:%s, supported methods:%v", c.Method, AllMethod())
}
}
switch c.LogLevel {
Expand All @@ -144,8 +180,8 @@ func (c *Config) Validate() error {
return fmt.Errorf("unsupported log-level:%s, supported log-levels:[debug, info, warn, error]", c.LogLevel)
}
if c.ProxyRule != "" {
if _, ok := ProxyRules[c.ProxyRule]; !ok {
return fmt.Errorf("unsupported proxy rule:%s, supported rules:[auto, auto_block, proxy, direct]", c.ProxyRule)
if _, ok := proxyRules[c.ProxyRule]; !ok {
return fmt.Errorf("unsupported proxy rule:%s, supported rules:%v", c.ProxyRule, AllProxyRule())
}
}
if c.OutboundProto != OutboundProtoNative && c.OutboundProto != OutboundProtoHTTP &&
Expand Down
26 changes: 0 additions & 26 deletions easyss.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,32 +165,6 @@ func (gs *GeoSite) SimpleMatch(domain string, matchSub bool) bool {
return false
}

type ProxyRule int

const (
ProxyRuleUnknown ProxyRule = iota
ProxyRuleAuto
ProxyRuleReverseAuto
ProxyRuleProxy
ProxyRuleDirect
ProxyRuleAutoBlock
)

func ParseProxyRuleFromString(rule string) ProxyRule {
m := map[string]ProxyRule{
"auto": ProxyRuleAuto,
"reverse_auto": ProxyRuleReverseAuto,
"proxy": ProxyRuleProxy,
"direct": ProxyRuleDirect,
"auto_block": ProxyRuleAutoBlock,
}
if r, ok := m[rule]; ok {
return r
}

return ProxyRuleUnknown
}

type HostRule int

const (
Expand Down

0 comments on commit 45aa56d

Please sign in to comment.