Skip to content

Commit

Permalink
添加一些直连域名、ip
Browse files Browse the repository at this point in the history
  • Loading branch information
danbai225 committed Jul 8, 2024
1 parent f430302 commit f3e54f1
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 52 deletions.
18 changes: 8 additions & 10 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,19 @@ import (

// App struct
type App struct {
ctx context.Context
conf *config.Config
gamePeer *config.Peer
httpPeer *config.Peer
box *box.Box
processList []string
lock sync.Mutex
ctx context.Context
conf *config.Config
gamePeer *config.Peer
httpPeer *config.Peer
box *box.Box
lock sync.Mutex
}

// NewApp creates a new App application struct
func NewApp() *App {
conf := config.Config{}
app := App{
conf: &conf,
processList: make([]string, 0),
conf: &conf,
}
return &app
}
Expand Down Expand Up @@ -237,7 +235,7 @@ func (a *App) Start() string {
return "running"
}
var err error
a.box, err = client.Client(a.gamePeer, a.httpPeer, a.processList)
a.box, err = client.Client(a.gamePeer, a.httpPeer)
if err != nil {
_, _ = runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{
Type: runtime.ErrorDialog,
Expand Down
112 changes: 71 additions & 41 deletions backend/client/box.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func getOUt(peer *config.Peer) option.Outbound {
out.Tag = uuid.New().String()
return out
}
func Client(gamePeer, httpPeer *config.Peer, processList []string) (*box.Box, error) {
func Client(gamePeer, httpPeer *config.Peer) (*box.Box, error) {
home, _ := os.UserHomeDir()
options := box.Options{
Context: context.Background(),
Expand Down Expand Up @@ -237,53 +237,83 @@ func Client(gamePeer, httpPeer *config.Peer, processList []string) (*box.Box, er
},
},
}
if processList != nil && len(processList) > 0 {
options.Options.Route.Rules = append(options.Options.Route.Rules, option.Rule{
Type: "logical",
LogicalOptions: option.LogicalRule{
Rules: []option.Rule{
{
Type: "default",
DefaultOptions: option.DefaultRule{
ProcessPath: processList,
},
},
},

options.Options.Route.Rules = append(options.Options.Route.Rules, []option.Rule{
{
Type: "default",
DefaultOptions: option.DefaultRule{
Network: option.Listable[string]{"udp"},
Port: []uint16{443},
Outbound: "block",
},
},
{
Type: "default",
DefaultOptions: option.DefaultRule{
Geosite: option.Listable[string]{"cn"},
Outbound: "direct",
Invert: true,
},
})
} else {
options.Options.Route.Rules = append(options.Options.Route.Rules, []option.Rule{
{
Type: "default",
DefaultOptions: option.DefaultRule{
Network: option.Listable[string]{"udp"},
Port: []uint16{443},
Outbound: "block",
},
},
{
Type: "default",
DefaultOptions: option.DefaultRule{
GeoIP: option.Listable[string]{"cn", "private"},
Outbound: "direct",
},
{
Type: "default",
DefaultOptions: option.DefaultRule{
Geosite: option.Listable[string]{"cn"},
Outbound: "direct",
},
{
Type: "default",
DefaultOptions: option.DefaultRule{
DomainSuffix: option.Listable[string]{"vivox.com",
"cm.steampowered.com",
"steamchina.com",
"steamcontent.com",
"steamserver.net",
"steamusercontent.com",
},
Outbound: "direct",
},
{
Type: "default",
DefaultOptions: option.DefaultRule{
GeoIP: option.Listable[string]{"cn", "private"},
Outbound: "direct",
},
}, {
Type: "default",
DefaultOptions: option.DefaultRule{
SourceIPCIDR: option.Listable[string]{"63.251.140.0/24",
"69.25.124.0/23",
"70.42.8.0/24",
"70.42.198.0/23",
"74.201.102.0/23",
"74.201.106.0/23",
"74.201.105.108/30",
"85.236.96.0/21",
"188.42.95.0/24",
"188.42.147.0/24",
"216.52.53.0/24"},
Outbound: "direct",
},
}...)
if httpPeer != nil && httpPeer.Name != gamePeer.Name {
out := getOUt(httpPeer)
options.Options.Outbounds = append(options.Options.Outbounds, out)
options.Options.Route.Rules = append(options.Options.Route.Rules, option.Rule{Type: "default", DefaultOptions: option.DefaultRule{Protocol: option.Listable[string]{"http", "quic", "tls"}, Outbound: out.Tag}})
}
}, {
Type: "default",
DefaultOptions: option.DefaultRule{
Domain: option.Listable[string]{"csgo.wmsj.cn",
"dl.steam.clngaa.com",
"dl.steam.ksyna.com",
"dota2.wmsj.cn",
"st.dl.bscstorage.net",
"st.dl.eccdnx.com",
"st.dl.pinyuncloud.com",
"steampipe.steamcontent.tnkjmec.com",
"steampowered.com.8686c.com",
"steamstatic.com.8686c.com",
"wmsjsteam.com",
"xz.pphimalayanrt.com"},
Outbound: "direct",
},
},
}...)
if httpPeer != nil && httpPeer.Name != gamePeer.Name {
out := getOUt(httpPeer)
options.Options.Outbounds = append(options.Options.Outbounds, out)
options.Options.Route.Rules = append(options.Options.Route.Rules, option.Rule{Type: "default", DefaultOptions: option.DefaultRule{Protocol: option.Listable[string]{"http", "quic", "tls"}, Outbound: out.Tag}})
}

var instance, err = box.New(options)
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/views/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
</n-button>
</n-space>
<n-gradient-text type="success" style="margin-left: 130px;margin-top: 35px">
v1.3.0
v1.3.2
</n-gradient-text>
</n-space>
<div>
Expand Down

0 comments on commit f3e54f1

Please sign in to comment.