summaryrefslogtreecommitdiff
path: root/modes/transparent_udp/transparent_udp.go
diff options
context:
space:
mode:
Diffstat (limited to 'modes/transparent_udp/transparent_udp.go')
-rw-r--r--modes/transparent_udp/transparent_udp.go97
1 files changed, 61 insertions, 36 deletions
diff --git a/modes/transparent_udp/transparent_udp.go b/modes/transparent_udp/transparent_udp.go
index 506637e..ab0504e 100644
--- a/modes/transparent_udp/transparent_udp.go
+++ b/modes/transparent_udp/transparent_udp.go
@@ -36,6 +36,7 @@ import (
options2 "github.com/OperatorFoundation/shapeshifter-dispatcher/common"
"github.com/OperatorFoundation/shapeshifter-dispatcher/common/log"
"github.com/OperatorFoundation/shapeshifter-dispatcher/common/pt_extras"
+ "github.com/OperatorFoundation/shapeshifter-dispatcher/transports"
"github.com/OperatorFoundation/shapeshifter-ipc"
"github.com/OperatorFoundation/shapeshifter-transports/transports/Dust"
replicant "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant"
@@ -48,7 +49,6 @@ import (
golog "log"
"net"
"net/url"
- "strconv"
//"github.com/OperatorFoundation/shapeshifter-transports/transports/Optimizer"
//"github.com/OperatorFoundation/shapeshifter-transports/transports/shadow"
)
@@ -208,7 +208,7 @@ func dialConn(tracker *ConnTracker, addr string, target string, name string, opt
(*tracker)[addr] = ConnState{remote, false}
}
-func ServerSetup(ptServerInfo pt.ServerInfo, options string) (launched bool, listeners []net.Listener) {
+func ServerSetup(ptServerInfo pt.ServerInfo, stateDir string, options string) (launched bool, listeners []net.Listener) {
fmt.Println("ServerSetup")
// Launch each of the server listeners.
@@ -218,7 +218,7 @@ func ServerSetup(ptServerInfo pt.ServerInfo, options string) (launched bool, lis
var listen func(address string) net.Listener
- args, argsErr := pt.ParsePT2ClientParameters(options)
+ args, argsErr := options2.ParseServerOptions(options)
if argsErr != nil {
log.Errorf("Error parsing transport options: %s", options)
return
@@ -230,67 +230,92 @@ func ServerSetup(ptServerInfo pt.ServerInfo, options string) (launched bool, lis
transport := obfs2.NewObfs2Transport()
listen = transport.Listen
case "obfs4":
- var dialer proxy.Dialer
- if cert, ok := args["cert"]; ok {
- if iatModeStr, ok2 := args["iat-mode"]; ok2 {
- iatMode, err := strconv.Atoi(iatModeStr[0])
- if err != nil {
- transport := obfs4.NewObfs4Client(cert[0], iatMode, dialer)
- listen = transport.Listen
- } else {
- log.Errorf("obfs4 transport bad iat-mode value: %s", iatModeStr)
- return
- }
- } else {
- log.Errorf("obfs4 transport missing cert argument: %s", args)
- return
- }
- } else {
- log.Errorf("obfs4 transport missing cert argument: %s", args)
- return
- }
+ transport := obfs4.NewObfs4Server(stateDir)
+ listen = transport.Listen
case "Replicant":
- config, ok := args.Get("config")
- fmt.Println(config)
- if !ok {
+ shargs, aok := args["Replicant"]
+ if !aok {
return false, nil
}
- transport := replicant.New(replicant.Config{})
+ config, err := transports.ParseReplicantConfig(shargs)
+ if err != nil {
+ return false, nil
+ }
+ transport := replicant.New(*config)
listen = transport.Listen
case "Dust":
- idPath, ok := args.Get("idPath")
- if !ok {
+ shargs, aok := args["Dust"]
+ if !aok {
return false, nil
}
+ untypedIdPath, ok := shargs["Url"]
+ if !ok {
+ return false, nil
+ }
+ idPath, err := options2.CoerceToString(untypedIdPath)
+ if err != nil {
+ log.Errorf("could not coerce Dust Url to string")
+ return false, nil
+ }
transport := Dust.NewDustServer(idPath)
listen = transport.Listen
case "meeklite":
- Url, ok := args.Get("Url")
+ args, aok := args["meeklite"]
+ if !aok {
+ return false, nil
+ }
+
+ untypedUrl, ok := args["Url"]
if !ok {
return false, nil
}
- Front, ok2 := args.Get("Front")
- if !ok2 {
+ Url, err := options2.CoerceToString(untypedUrl)
+ if err != nil {
+ log.Errorf("could not coerce meeklite Url to string")
+ }
+
+ untypedFront, ok := args["front"]
+ if !ok {
return false, nil
}
- transport := meeklite.NewMeekTransportWithFront(Url, Front)
+ front, err2 := options2.CoerceToString(untypedFront)
+ if err2 != nil {
+ log.Errorf("could not coerce meeklite front to string")
+ }
+
+ transport := meeklite.NewMeekTransportWithFront(Url, front)
listen = transport.Listen
case "shadow":
- password, ok := args.Get("password")
+ args, aok := args["shadow"]
+ if !aok {
+ return false, nil
+ }
+
+ untypedPassword, ok := args["password"]
if !ok {
return false, nil
}
- cipherName, ok2 := args.Get("cipherName")
- if !ok2 {
+ Password, err := options2.CoerceToString(untypedPassword)
+ if err != nil {
+ log.Errorf("could not coerce shadow password to string")
+ }
+
+ untypedCertString, ok := args["Url"]
+ if !ok {
return false, nil
}
- transport := shadow.NewShadowServer(password, cipherName)
+ certString, err2 := options2.CoerceToString(untypedCertString)
+ if err2 != nil {
+ log.Errorf("could not coerce meeklite Url to string")
+ }
+
+ transport := shadow.NewShadowServer(Password, certString)
listen = transport.Listen
default:
log.Errorf("Unknown transport: %s", name)