Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
p4gefau1t committed Sep 6, 2020
1 parent a219635 commit d051cf4
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
19 changes: 19 additions & 0 deletions example/client.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
run-type: client
local-addr: 127.0.0.1
local-port: 1080
remote-addr: your_server
remote-port: 443
password:
- your_password
ssl:
sni: your-domain-name.com
mux:
enabled: true
router:
enabled: true
bypass: ['geoip:cn', 'geoip:private', 'geosite:cn', 'geosite:geolocation-cn']
block: ['geosite:category-ads']
proxy: ['geosite:geolocation-!cn']
default_policy: proxy
geoip: /usr/share/trojan-go/geoip.dat
geosite: /usr/share/trojan-go/geosite.dat
17 changes: 17 additions & 0 deletions example/server.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
run-type: server
local-addr: 0.0.0.0
local-port: 443
remote-addr: 127.0.0.1
remote-port: 80
password:
- your_password
ssl:
cert: your_cert.crt
key: your_key.key
sni: your-domain-name.com
router:
enabled: true
block:
- 'geoip:private'
geoip: /usr/share/trojan-go/geoip.dat
geosite: /usr/share/trojan-go/geosite.dat
6 changes: 5 additions & 1 deletion proxy/nat/nat.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package nat
import (
"context"

"github.com/p4gefau1t/trojan-go/common"
"github.com/p4gefau1t/trojan-go/config"
"github.com/p4gefau1t/trojan-go/proxy"
"github.com/p4gefau1t/trojan-go/proxy/client"
Expand All @@ -17,9 +18,12 @@ const Name = "NAT"
func init() {
proxy.RegisterProxyCreator(Name, func(ctx context.Context) (*proxy.Proxy, error) {
cfg := config.FromContext(ctx, Name).(*client.Config)
if cfg.Router.Enabled {
return nil, common.NewError("router is not allowed in nat mode")
}
ctx, cancel := context.WithCancel(ctx)
serverStack := []string{tproxy.Name}
clientStack := client.GenerateClientTree(cfg.TransportPlugin.Enabled, cfg.Mux.Enabled, cfg.Websocket.Enabled, cfg.Shadowsocks.Enabled, cfg.Router.Enabled)
clientStack := client.GenerateClientTree(cfg.TransportPlugin.Enabled, cfg.Mux.Enabled, cfg.Websocket.Enabled, cfg.Shadowsocks.Enabled, false)
c, err := proxy.CreateClientStack(ctx, clientStack)
if err != nil {
cancel()
Expand Down

0 comments on commit d051cf4

Please sign in to comment.