Skip to content

Commit

Permalink
updated README and added prints
Browse files Browse the repository at this point in the history
  • Loading branch information
CryptoSax committed May 29, 2022
1 parent e4dd846 commit 3c0f3bb
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 84 deletions.
71 changes: 3 additions & 68 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,23 +57,19 @@ 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:

<https://golang.org/doc/install>

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.
Expand All @@ -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
Expand Down Expand Up @@ -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 <IP ADDRESS>:<PORT> <FINGERPRINT> 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
Expand Down
9 changes: 5 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,18 @@ 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"
"os"
"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"
Expand Down
16 changes: 9 additions & 7 deletions modes/tcp_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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)
Expand Down
10 changes: 8 additions & 2 deletions modes/udp_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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()
Expand Down
Binary file modified shTests/TransparentTCP/testTCPReplicantOutput.txt
Binary file not shown.
4 changes: 2 additions & 2 deletions shTests/TransparentTCP/testTCPShadow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 &
Expand Down
1 change: 0 additions & 1 deletion shTests/TransparentTCP/testTCPShadowOutput.txt
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
data

0 comments on commit 3c0f3bb

Please sign in to comment.