summaryrefslogtreecommitdiff
path: root/modes
diff options
context:
space:
mode:
authorBluesaxorcist <joshua@operatorfoundation.org>2019-09-14 18:56:03 -0500
committerBluesaxorcist <joshua@operatorfoundation.org>2019-09-14 18:56:03 -0500
commit6b048e3e998261a4bc105593e27607cf9d56e223 (patch)
tree713da1e089cfb861da8646ab96239be10c099800 /modes
parentbfc867e0f07555b906ab7f3673aa3f6946a83bf9 (diff)
refactoring the modes
Diffstat (limited to 'modes')
-rw-r--r--modes/pt_socks5/pt_socks5.go38
-rw-r--r--modes/stun_udp/stun_udp.go20
-rw-r--r--modes/transparent_tcp/transparent_tcp.go5
-rw-r--r--modes/transparent_udp/transparent_udp.go3
4 files changed, 39 insertions, 27 deletions
diff --git a/modes/pt_socks5/pt_socks5.go b/modes/pt_socks5/pt_socks5.go
index dfd7359..45cbbf2 100644
--- a/modes/pt_socks5/pt_socks5.go
+++ b/modes/pt_socks5/pt_socks5.go
@@ -30,8 +30,10 @@
package pt_socks5
import (
+ 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 +103,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 +200,13 @@ 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")
+ if !ok {
+ return false, nil
+ }
+ transport := replicant.New(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..564e562 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,14 @@ 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 _, ok := args["config"]; ok {
+ 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])
diff --git a/modes/transparent_tcp/transparent_tcp.go b/modes/transparent_tcp/transparent_tcp.go
index faffa15..a1addf3 100644
--- a/modes/transparent_tcp/transparent_tcp.go
+++ b/modes/transparent_tcp/transparent_tcp.go
@@ -31,6 +31,7 @@ package transparent_tcp
import (
"fmt"
+ options2 "github.com/OperatorFoundation/shapeshifter-dispatcher/common"
"github.com/OperatorFoundation/shapeshifter-dispatcher/common/pt_extras"
"github.com/OperatorFoundation/shapeshifter-transports/transports/Dust"
"github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite"
@@ -91,8 +92,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
diff --git a/modes/transparent_udp/transparent_udp.go b/modes/transparent_udp/transparent_udp.go
index 3352228..05235d7 100644
--- a/modes/transparent_udp/transparent_udp.go
+++ b/modes/transparent_udp/transparent_udp.go
@@ -33,6 +33,7 @@ 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"
"github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite"
@@ -179,7 +180,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