diff --git a/README.md b/README.md index 444a3f7..9cf6a79 100644 --- a/README.md +++ b/README.md @@ -57,15 +57,11 @@ The dispatcher currently supports the following transports: * Replicant * Optimizer * shadow (Shadowsocks) - * meeklite (client and server) - * obfs4 - * Dust - * obfs2 #### Installation The dispatcher is written in the Go programming language. To compile it you need -to install Go 1.14 or higher: +to install Go 1.17 or higher: @@ -73,7 +69,7 @@ If you already have Go installed, make sure it is a compatible version: go version -The version should be 1.14 or higher. +The version should be 1.17 or higher. If you get the error "go: command not found", then trying exiting your terminal and starting a new one. @@ -85,7 +81,7 @@ Get the git repository for shapeshifter-disptacher: Go into that directory and build the command line executable: cd shapeshifter-dispatcher - go build + go install This will fetch the source code for shapeshifter-dispatcher, and all the dependencies, compile everything, and put the result in @@ -175,67 +171,6 @@ server to the application server, which in the case of this demo is a netcat server. You can also type bytes into the netcat server and they will appear on the telnet client, once again being routed over the transport. -#### Running with obfs4 - -Here are example command lines to run the dispatcher with the obfs4 transport: - -##### Server - -For this example to work, you need an application server running. You can use netcat to run a simple server on port 3333: - - nc -l 3333 - -Now launch the transport server, telling it where to find the application server: - - ~/go/bin/shapeshifter-dispatcher -transparent -server -state state -target 127.0.0.1:3333 -transports obfs4 -bindaddr obfs4-127.0.0.1:2222 -logLevel DEBUG -enableLogging - -This runs the server in transparent TCP proxy mode. The directory "state" is used -to hold transport state. The destination that the server will proxy to is -127.0.0.1, port 3333. The obfs4 transport is enabled and bound to the address 127.0.0.1 and the port -2222. Logging is enabled and set to DEBUG level. To access the Log for debugging purposes, -look at state/dispatcher.log - -When the server is run for the first time, it will generate a new public key -and it will write it to a file in the state directory in a file called -obfs4_bridgeline.txt. This information is needed by the dispatcher client. Look -in the file and retrieve the public key from the bridge line. It will look -similar to this: - - Bridge obfs4 : cert=OfQAPDamjsRO90fDGlnZR5RNG659FZqUKUwxUHcaK7jIbERvNU8+EVF6rmdlvS69jVYrKw iat-mode=0 - -The cert parameter is what is needed for the dispatcher client. - -##### Client - - ~/go/bin/shapeshifter-dispatcher -transparent -client -state state -transports obfs4 -proxylistenaddr 127.0.0.1:1443 -optionsFile ../../ConfigFiles/obfs4.json -logLevel DEBUG -enableLogging - -This runs the client in transparent TCP proxy mode. The directory "state" is -used to hold transport state. The address of the server is specified as -127.0.0.1, port 2222. This is the same address as was specified on the server -command line above. For this demo to work, the dispatcher server needs to be -running on this host and port. The obfs4 transport is enabled and bound to the -address 127.0.0.1 and the port 1443. The -optionsFile parameter is different for -every transport. For obfs4, the "cert" and "iat-mode" parameters are required. -These can be found in the obfs4_bridgeline.txt in the server state directory, -which is generated by the server the first time that it is run. It is important -for the cert parameter to be correct, otherwise obfs4 will silently fail. You can input -your parameters in the Obfs4.json file in the shapeshifter-dispatcher folder or you can put -the parameters in directly on the command line using the -options flag in this format: - -bin/shapeshifter-dispatcher -transparent -client -state state -target 127.0.0.1:2222 -transports obfs4 -proxylistenaddr 127.0.0.1:1443 -options '{"cert": "OfQAPDamjsRO90fDGlnZR5RNG659FZqUKUwxUHcaK7jIbERvNU8+EVF6rmdlvS69jVYrKw", "iat-mode": "0"}' -logLevel DEBUG -enableLogging - -Logging is enabled and set to DEBUG level. - -Once the client is running, you can connect to the client address, which in this -case is 127.0.0.1, port 1443. For instance, you can telnet to this address: - - telnet 127.0.0.1 1443 - -Any bytes sent over this connection will be forwarded through the transport -server to the application server, which in the case of this demo is a netcat -server. You can also type bytes into the netcat server and they will appear -on the telnet client, once again being routed over the transport. - ### Using Environment Variables Using command line flags is convenient for testing. However, when launching the diff --git a/main.go b/main.go index f4be32a..31e07c0 100644 --- a/main.go +++ b/main.go @@ -33,10 +33,6 @@ import ( "errors" "flag" "fmt" - "github.com/OperatorFoundation/shapeshifter-dispatcher/common/pt_extras" - "github.com/OperatorFoundation/shapeshifter-dispatcher/transports" - pt "github.com/OperatorFoundation/shapeshifter-ipc/v3" - "github.com/kataras/golog" "io" "io/ioutil" "net/url" @@ -44,6 +40,11 @@ import ( "path" "strings" + "github.com/OperatorFoundation/shapeshifter-dispatcher/common/pt_extras" + "github.com/OperatorFoundation/shapeshifter-dispatcher/transports" + pt "github.com/OperatorFoundation/shapeshifter-ipc/v3" + "github.com/kataras/golog" + "github.com/OperatorFoundation/shapeshifter-dispatcher/modes/pt_socks5" "github.com/OperatorFoundation/shapeshifter-dispatcher/modes/stun_udp" "github.com/OperatorFoundation/shapeshifter-dispatcher/modes/transparent_tcp" diff --git a/modes/tcp_common.go b/modes/tcp_common.go index b05857f..d55853d 100644 --- a/modes/tcp_common.go +++ b/modes/tcp_common.go @@ -27,15 +27,16 @@ package modes import ( "errors" "fmt" - commonLog "github.com/OperatorFoundation/shapeshifter-dispatcher/common/log" - "github.com/OperatorFoundation/shapeshifter-dispatcher/common/pt_extras" - pt "github.com/OperatorFoundation/shapeshifter-ipc/v3" - "github.com/kataras/golog" "io" "net" "net/url" "os" + commonLog "github.com/OperatorFoundation/shapeshifter-dispatcher/common/log" + "github.com/OperatorFoundation/shapeshifter-dispatcher/common/pt_extras" + pt "github.com/OperatorFoundation/shapeshifter-ipc/v3" + "github.com/kataras/golog" + "github.com/OperatorFoundation/shapeshifter-dispatcher/common/log" ) @@ -91,9 +92,10 @@ func ServerSetupTCP(ptServerInfo pt.ServerInfo, stateDir string, options string, continue } - //print(name) - //print(" listening on ") - //println(bindaddr.Addr.String()) + print(name) + print(" listening on ") + println(bindaddr.Addr.String()) + log.Infof("%s - registered listener: %s", name, log.ElideAddr(bindaddr.Addr.String())) ServerAcceptLoop(name, transportLn, &ptServerInfo, serverHandler) diff --git a/modes/udp_common.go b/modes/udp_common.go index 0b2403c..5ddd24d 100644 --- a/modes/udp_common.go +++ b/modes/udp_common.go @@ -25,12 +25,13 @@ SOFTWARE. package modes import ( + "net" + "net/url" + commonLog "github.com/OperatorFoundation/shapeshifter-dispatcher/common/log" "github.com/OperatorFoundation/shapeshifter-dispatcher/common/pt_extras" pt "github.com/OperatorFoundation/shapeshifter-ipc/v3" "github.com/kataras/golog" - "net" - "net/url" ) func ClientSetupUDP(socksAddr string, ptClientProxy *url.URL, names []string, options string, clientHandler ClientHandlerUDP) bool { @@ -72,6 +73,11 @@ func ServerSetupUDP(ptServerInfo pt.ServerInfo, stateDir string, options string, if LnError != nil { continue } + + print(name) + print(" listening on ") + println(bindaddr.Addr.String()) + golog.Infof("%s - registered listener: %s", name, commonLog.ElideAddr(bindaddr.Addr.String())) ServerAcceptLoop(name, transportLn, &ptServerInfo, serverHandler) transportLnErr := transportLn.Close() diff --git a/shTests/TransparentTCP/testTCPReplicantOutput.txt b/shTests/TransparentTCP/testTCPReplicantOutput.txt index bf91b12..e69de29 100644 Binary files a/shTests/TransparentTCP/testTCPReplicantOutput.txt and b/shTests/TransparentTCP/testTCPReplicantOutput.txt differ diff --git a/shTests/TransparentTCP/testTCPShadow.sh b/shTests/TransparentTCP/testTCPShadow.sh index 6138ae1..f64a51d 100755 --- a/shTests/TransparentTCP/testTCPShadow.sh +++ b/shTests/TransparentTCP/testTCPShadow.sh @@ -9,10 +9,10 @@ GOPATH=${GOPATH:-'$HOME/go'} go install # remove text from the output file -rm $FILENAME +rm shTests/TransparentTCP/$FILENAME # Run a demo application server with netcat and write to the output file -nc -l 3333 >$FILENAME & +nc -l 3333 >shTests/TransparentTCP/$FILENAME & # Run the transport server "$GOPATH"/bin/shapeshifter-dispatcher -transparent -server -state state -target 127.0.0.1:3333 -transports shadow -bindaddr shadow-127.0.0.1:2222 -optionsFile ConfigFiles/shadowServer.json -logLevel DEBUG -enableLogging & diff --git a/shTests/TransparentTCP/testTCPShadowOutput.txt b/shTests/TransparentTCP/testTCPShadowOutput.txt index 6320cd2..e69de29 100644 --- a/shTests/TransparentTCP/testTCPShadowOutput.txt +++ b/shTests/TransparentTCP/testTCPShadowOutput.txt @@ -1 +0,0 @@ -data \ No newline at end of file