diff options
Diffstat (limited to 'modes')
-rw-r--r-- | modes/pt_socks5/pt_socks5.go | 40 | ||||
-rw-r--r-- | modes/stun_udp/stun_udp.go | 23 | ||||
-rw-r--r-- | modes/transparent_tcp/transparent_tcp.go | 37 | ||||
-rw-r--r-- | modes/transparent_udp/transparent_udp.go | 21 |
4 files changed, 73 insertions, 48 deletions
diff --git a/modes/pt_socks5/pt_socks5.go b/modes/pt_socks5/pt_socks5.go index dfd7359..59c4a7c 100644 --- a/modes/pt_socks5/pt_socks5.go +++ b/modes/pt_socks5/pt_socks5.go @@ -30,8 +30,11 @@ package pt_socks5 import ( + "fmt" + options2 "github.com/OperatorFoundation/shapeshifter-dispatcher/common" "github.com/OperatorFoundation/shapeshifter-dispatcher/common/pt_extras" "github.com/OperatorFoundation/shapeshifter-transports/transports/Dust" + replicant "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant" "github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite" "github.com/OperatorFoundation/shapeshifter-transports/transports/shadow" "io" @@ -101,14 +104,20 @@ func clientHandler(target string, termMon *termmon.TermMonitor, name string, con } addrStr := log.ElideAddr(socksReq.Target) - var args pt.Args - if needOptions { - args = socksReq.Args - } else { - args, err = pt.ParsePT2ClientParameters(options) - if err != nil { - return - } + //var args pt.Args + //if needOptions { + // args = socksReq.Args + //} else { + // args, err = pt.ParsePT2ClientParameters(options) + // if err != nil { + // return + // } + //} + + args, argsErr := options2.ParseOptions(options) + if argsErr != nil { + log.Errorf("Error parsing transport options: %s", options) + return } var dialer func() (net.Conn, error) @@ -192,13 +201,14 @@ func ServerSetup(termMon *termmon.TermMonitor, bindaddrString string, ptServerIn log.Errorf("obfs4 transport missing cert argument: %s", args) return } - //case "replicant": - // config, ok :=args.Get("config") - // if !ok { - // return false, nil - // } - // transport := replicant.New(config) - // listen = transport.Listen + case "replicant": + config, ok :=args.Get("config") + fmt.Println(config) + if !ok { + return false, nil + } + transport := replicant.New(replicant.Config{}) + listen = transport.Listen case "Dust": idPath, ok :=args.Get("idPath") if !ok { diff --git a/modes/stun_udp/stun_udp.go b/modes/stun_udp/stun_udp.go index f12e69e..70d5565 100644 --- a/modes/stun_udp/stun_udp.go +++ b/modes/stun_udp/stun_udp.go @@ -31,8 +31,10 @@ package stun_udp import ( "fmt" + options2 "github.com/OperatorFoundation/shapeshifter-dispatcher/common" "github.com/OperatorFoundation/shapeshifter-dispatcher/common/pt_extras" "github.com/OperatorFoundation/shapeshifter-transports/transports/Dust" + replicant "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant" "github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite" "github.com/OperatorFoundation/shapeshifter-transports/transports/shadow" "io" @@ -166,7 +168,7 @@ func dialConn(tracker *ConnTracker, addr string, target string, name string, opt fmt.Println("Dialing....") - args, argsErr := pt.ParsePT2ClientParameters(options) + args, argsErr := options2.ParseOptions(options) if argsErr != nil { log.Errorf("Error parsing transport options: %s", options) return @@ -243,14 +245,15 @@ func ServerSetup(termMon *termmon.TermMonitor, bindaddrString string, ptServerIn log.Errorf("meeklite transport missing Front argument: %s", args) return } - //case "replicant": - // if config, ok := args["config"]; ok { - // transport := replicant.New(config[0]) - // listen = transport.Listen - // } else { - // log.Errorf("replicant transport missing config argument: %s", args) - // return - // } + case "replicant": + if config, ok := args["config"]; ok { + fmt.Println(config) + transport := replicant.New(replicant.Config{}) + listen = transport.Listen + } else { + log.Errorf("replicant transport missing config argument: %s", args) + return + } case "Dust": if idPath, ok := args["idPath"]; ok { transport := Dust.NewDustServer(idPath[0]) @@ -434,4 +437,4 @@ func serverHandler(termMon *termmon.TermMonitor, name string, remote net.Conn, i dest.Write(writeBuffer) } -} +}
\ No newline at end of file diff --git a/modes/transparent_tcp/transparent_tcp.go b/modes/transparent_tcp/transparent_tcp.go index 9f9fc18..51ec43b 100644 --- a/modes/transparent_tcp/transparent_tcp.go +++ b/modes/transparent_tcp/transparent_tcp.go @@ -30,8 +30,12 @@ package transparent_tcp import ( + options2 "github.com/OperatorFoundation/shapeshifter-dispatcher/common" + "github.com/OperatorFoundation/shapeshifter-dispatcher/common/pt_extras" + "github.com/OperatorFoundation/shapeshifter-dispatcher/transports" "github.com/OperatorFoundation/shapeshifter-transports/transports/Dust" + replicant "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant" "github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite" "github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2" "io" @@ -92,8 +96,8 @@ func clientHandler(target string, termMon *termmon.TermMonitor, name string, opt defer termMon.OnHandlerFinish() var dialer func() (net.Conn, error) - - args, argsErr := pt.ParsePT2ClientParameters(options) +//this is where the refactoring begins + args, argsErr := options2.ParseOptions(options) if argsErr != nil { log.Errorf("Error parsing transport options: %s", options) return @@ -163,18 +167,22 @@ func ServerSetup(termMon *termmon.TermMonitor, bindaddrString string, ptServerIn case "obfs4": transport := obfs4.NewObfs4Server(statedir) listen = transport.Listen - //case "Replicant": - // shargs, aok := args["Replicant"] - // if !aok { - // return false, nil - // } - // - // config, ok := shargs.Get("config") - // if !ok { - // return false, nil - // } - // transport := replicant.New(config) - // listen = transport.Listen + case "Replicant": + shargs, aok := args["Replicant"] + if !aok { + return false, nil + } + + configString, ok := shargs.Get("config") + if !ok { + return false, nil + } + config, err := transports.ParseReplicantConfig(configString) + if err != nil { + return false, nil + } + transport := replicant.New(config) + listen = transport.Listen case "Dust": shargs, aok := args["Dust"] if !aok { @@ -335,3 +343,4 @@ func copyLoop(a net.Conn, b net.Conn) error { return nil } + diff --git a/modes/transparent_udp/transparent_udp.go b/modes/transparent_udp/transparent_udp.go index 62d0689..eade8c8 100644 --- a/modes/transparent_udp/transparent_udp.go +++ b/modes/transparent_udp/transparent_udp.go @@ -33,8 +33,10 @@ import ( "bytes" "encoding/binary" "fmt" + options2 "github.com/OperatorFoundation/shapeshifter-dispatcher/common" "github.com/OperatorFoundation/shapeshifter-dispatcher/common/pt_extras" "github.com/OperatorFoundation/shapeshifter-transports/transports/Dust" + replicant "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant" "github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite" "github.com/OperatorFoundation/shapeshifter-transports/transports/shadow" "io" @@ -179,7 +181,7 @@ func dialConn(tracker *ConnTracker, addr string, target string, name string, opt fmt.Println("Dialing....") - args, argsErr := pt.ParsePT2ClientParameters(options) + args, argsErr := options2.ParseOptions(options) if argsErr != nil { log.Errorf("Error parsing transport options: %s", options) return @@ -242,14 +244,15 @@ func ServerSetup(termMon *termmon.TermMonitor, bindaddrString string, ptServerIn log.Errorf("obfs4 transport missing cert argument: %s", args) return } - //case "Replicant": - // Config, ok := args.Get("config") - // if !ok { - // return false, nil - // } - // - // transport := replicant.New(Config) - // listen = transport.Listen + case "Replicant": + config, ok := args.Get("config") + fmt.Println(config) + if !ok { + return false, nil + } + + transport := replicant.New(replicant.Config{}) + listen = transport.Listen case "Dust": idPath, ok := args.Get("idPath") if !ok { |