Skip to content

Commit d051cf4

Browse files
committed
1 parent a219635 commit d051cf4

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

example/client.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
run-type: client
2+
local-addr: 127.0.0.1
3+
local-port: 1080
4+
remote-addr: your_server
5+
remote-port: 443
6+
password:
7+
- your_password
8+
ssl:
9+
sni: your-domain-name.com
10+
mux:
11+
enabled: true
12+
router:
13+
enabled: true
14+
bypass: ['geoip:cn', 'geoip:private', 'geosite:cn', 'geosite:geolocation-cn']
15+
block: ['geosite:category-ads']
16+
proxy: ['geosite:geolocation-!cn']
17+
default_policy: proxy
18+
geoip: /usr/share/trojan-go/geoip.dat
19+
geosite: /usr/share/trojan-go/geosite.dat

example/server.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
run-type: server
2+
local-addr: 0.0.0.0
3+
local-port: 443
4+
remote-addr: 127.0.0.1
5+
remote-port: 80
6+
password:
7+
- your_password
8+
ssl:
9+
cert: your_cert.crt
10+
key: your_key.key
11+
sni: your-domain-name.com
12+
router:
13+
enabled: true
14+
block:
15+
- 'geoip:private'
16+
geoip: /usr/share/trojan-go/geoip.dat
17+
geosite: /usr/share/trojan-go/geosite.dat

proxy/nat/nat.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package nat
55
import (
66
"context"
77

8+
"github.com/p4gefau1t/trojan-go/common"
89
"github.com/p4gefau1t/trojan-go/config"
910
"github.com/p4gefau1t/trojan-go/proxy"
1011
"github.com/p4gefau1t/trojan-go/proxy/client"
@@ -17,9 +18,12 @@ const Name = "NAT"
1718
func init() {
1819
proxy.RegisterProxyCreator(Name, func(ctx context.Context) (*proxy.Proxy, error) {
1920
cfg := config.FromContext(ctx, Name).(*client.Config)
21+
if cfg.Router.Enabled {
22+
return nil, common.NewError("router is not allowed in nat mode")
23+
}
2024
ctx, cancel := context.WithCancel(ctx)
2125
serverStack := []string{tproxy.Name}
22-
clientStack := client.GenerateClientTree(cfg.TransportPlugin.Enabled, cfg.Mux.Enabled, cfg.Websocket.Enabled, cfg.Shadowsocks.Enabled, cfg.Router.Enabled)
26+
clientStack := client.GenerateClientTree(cfg.TransportPlugin.Enabled, cfg.Mux.Enabled, cfg.Websocket.Enabled, cfg.Shadowsocks.Enabled, false)
2327
c, err := proxy.CreateClientStack(ctx, clientStack)
2428
if err != nil {
2529
cancel()

0 commit comments

Comments
 (0)