From 40ba66c0df5a6930e29d139e348d8eac34f41e4c Mon Sep 17 00:00:00 2001 From: Bluesaxorcist Date: Fri, 19 Jun 2020 15:44:48 -0500 Subject: [PATCH 01/33] created v3 module directories --- transports/Dust/v3/Dust.go | 185 ++++ transports/Dust/v3/Dust_test.go | 84 ++ transports/Dust/v3/LICENSE.md | 40 + transports/Dust/v3/NOTES | 30 + transports/Dust/v3/README.md | 34 + transports/Dust/v3/go.mod | 11 + transports/Dust/v3/go.sum | 26 + transports/Optimizer/v3/Optimizer.go | 269 +++++ transports/Optimizer/v3/Optimizer_test.go | 327 ++++++ transports/Optimizer/v3/README.md | 43 + transports/Optimizer/v3/go.mod | 11 + transports/Optimizer/v3/go.sum | 45 + transports/Replicant/v3/Optimizer.go | 41 + transports/Replicant/v3/README.md | 5 + .../Replicant/v3/ReplicantClientConfig.json | 1 + .../Replicant/v3/ReplicantClientConfig1.json | 1 + .../Replicant/v3/ReplicantServerConfig.json | 1 + .../Replicant/v3/ReplicantServerConfig1.json | 1 + transports/Replicant/v3/config.go | 64 ++ transports/Replicant/v3/go.mod | 11 + transports/Replicant/v3/go.sum | 25 + transports/Replicant/v3/persistence.go | 94 ++ transports/Replicant/v3/persistence_test.go | 197 ++++ transports/Replicant/v3/polish/config.go | 11 + transports/Replicant/v3/polish/polish.go | 16 + transports/Replicant/v3/polish/silver.go | 374 +++++++ transports/Replicant/v3/polish/silver_test.go | 25 + transports/Replicant/v3/pt21.go | 165 +++ transports/Replicant/v3/replicant.go | 149 +++ transports/Replicant/v3/replicant_test.go | 969 ++++++++++++++++++ transports/Replicant/v3/toneburst/config.go | 5 + transports/Replicant/v3/toneburst/monotone.go | 145 +++ .../Replicant/v3/toneburst/monotone_test.go | 63 ++ .../Replicant/v3/toneburst/toneburst.go | 31 + .../Replicant/v3/toneburst/whalesong.go | 32 + transports/meeklite/v3/README.md | 20 + transports/meeklite/v3/go.mod | 8 + transports/meeklite/v3/go.sum | 16 + transports/meeklite/v3/meeklite.go | 465 +++++++++ transports/meeklite/v3/meeklite_test.go | 77 ++ transports/meekserver/v3/certificate.go | 114 +++ transports/meekserver/v3/certificate_test.go | 312 ++++++ transports/meekserver/v3/go.mod | 11 + transports/meekserver/v3/go.sum | 16 + transports/meekserver/v3/meek-server.go | 344 +++++++ transports/meekserver/v3/meekserver_test.go | 29 + transports/meekserver/v3/pt21.go | 225 ++++ transports/meekserver/v3/useraddr.go | 50 + transports/meekserver/v3/useraddr_test.go | 163 +++ transports/obfs2/v3/go.mod | 11 + transports/obfs2/v3/go.sum | 42 + transports/obfs2/v3/obfs2.go | 431 ++++++++ transports/obfs2/v3/obfs2_test.go | 160 +++ transports/obfs4/v3/README.md | 31 + transports/obfs4/v3/framing/framing.go | 306 ++++++ transports/obfs4/v3/framing/framing_test.go | 169 +++ transports/obfs4/v3/go.mod | 10 + transports/obfs4/v3/go.sum | 20 + transports/obfs4/v3/handshake_ntor.go | 424 ++++++++ transports/obfs4/v3/handshake_ntor_test.go | 242 +++++ transports/obfs4/v3/obfs4.go | 732 +++++++++++++ transports/obfs4/v3/obfs4_test.go | 75 ++ transports/obfs4/v3/packet.go | 175 ++++ transports/obfs4/v3/statefile.go | 263 +++++ transports/obfs4/v3/test_utils.go | 101 ++ transports/shadow/v3/LICENSE | 21 + transports/shadow/v3/README.md | 33 + transports/shadow/v3/go.mod | 9 + transports/shadow/v3/go.sum | 8 + transports/shadow/v3/shadow.go | 104 ++ transports/shadow/v3/shadow_test.go | 96 ++ 71 files changed, 8844 insertions(+) create mode 100644 transports/Dust/v3/Dust.go create mode 100644 transports/Dust/v3/Dust_test.go create mode 100644 transports/Dust/v3/LICENSE.md create mode 100644 transports/Dust/v3/NOTES create mode 100644 transports/Dust/v3/README.md create mode 100644 transports/Dust/v3/go.mod create mode 100644 transports/Dust/v3/go.sum create mode 100644 transports/Optimizer/v3/Optimizer.go create mode 100644 transports/Optimizer/v3/Optimizer_test.go create mode 100644 transports/Optimizer/v3/README.md create mode 100644 transports/Optimizer/v3/go.mod create mode 100644 transports/Optimizer/v3/go.sum create mode 100644 transports/Replicant/v3/Optimizer.go create mode 100644 transports/Replicant/v3/README.md create mode 100644 transports/Replicant/v3/ReplicantClientConfig.json create mode 100644 transports/Replicant/v3/ReplicantClientConfig1.json create mode 100644 transports/Replicant/v3/ReplicantServerConfig.json create mode 100644 transports/Replicant/v3/ReplicantServerConfig1.json create mode 100644 transports/Replicant/v3/config.go create mode 100644 transports/Replicant/v3/go.mod create mode 100644 transports/Replicant/v3/go.sum create mode 100644 transports/Replicant/v3/persistence.go create mode 100644 transports/Replicant/v3/persistence_test.go create mode 100644 transports/Replicant/v3/polish/config.go create mode 100644 transports/Replicant/v3/polish/polish.go create mode 100644 transports/Replicant/v3/polish/silver.go create mode 100644 transports/Replicant/v3/polish/silver_test.go create mode 100644 transports/Replicant/v3/pt21.go create mode 100644 transports/Replicant/v3/replicant.go create mode 100644 transports/Replicant/v3/replicant_test.go create mode 100644 transports/Replicant/v3/toneburst/config.go create mode 100644 transports/Replicant/v3/toneburst/monotone.go create mode 100644 transports/Replicant/v3/toneburst/monotone_test.go create mode 100644 transports/Replicant/v3/toneburst/toneburst.go create mode 100644 transports/Replicant/v3/toneburst/whalesong.go create mode 100644 transports/meeklite/v3/README.md create mode 100644 transports/meeklite/v3/go.mod create mode 100644 transports/meeklite/v3/go.sum create mode 100644 transports/meeklite/v3/meeklite.go create mode 100644 transports/meeklite/v3/meeklite_test.go create mode 100644 transports/meekserver/v3/certificate.go create mode 100644 transports/meekserver/v3/certificate_test.go create mode 100644 transports/meekserver/v3/go.mod create mode 100644 transports/meekserver/v3/go.sum create mode 100644 transports/meekserver/v3/meek-server.go create mode 100644 transports/meekserver/v3/meekserver_test.go create mode 100644 transports/meekserver/v3/pt21.go create mode 100644 transports/meekserver/v3/useraddr.go create mode 100644 transports/meekserver/v3/useraddr_test.go create mode 100644 transports/obfs2/v3/go.mod create mode 100644 transports/obfs2/v3/go.sum create mode 100644 transports/obfs2/v3/obfs2.go create mode 100644 transports/obfs2/v3/obfs2_test.go create mode 100644 transports/obfs4/v3/README.md create mode 100644 transports/obfs4/v3/framing/framing.go create mode 100644 transports/obfs4/v3/framing/framing_test.go create mode 100644 transports/obfs4/v3/go.mod create mode 100644 transports/obfs4/v3/go.sum create mode 100644 transports/obfs4/v3/handshake_ntor.go create mode 100644 transports/obfs4/v3/handshake_ntor_test.go create mode 100644 transports/obfs4/v3/obfs4.go create mode 100644 transports/obfs4/v3/obfs4_test.go create mode 100644 transports/obfs4/v3/packet.go create mode 100644 transports/obfs4/v3/statefile.go create mode 100644 transports/obfs4/v3/test_utils.go create mode 100644 transports/shadow/v3/LICENSE create mode 100644 transports/shadow/v3/README.md create mode 100644 transports/shadow/v3/go.mod create mode 100644 transports/shadow/v3/go.sum create mode 100644 transports/shadow/v3/shadow.go create mode 100644 transports/shadow/v3/shadow_test.go diff --git a/transports/Dust/v3/Dust.go b/transports/Dust/v3/Dust.go new file mode 100644 index 0000000..727364b --- /dev/null +++ b/transports/Dust/v3/Dust.go @@ -0,0 +1,185 @@ +package Dust + +/* + * Copyright (c) 2019, Operator Foundation + * + */ + +// Package Dust provides a PT 2.1 Go API wrapper around the Dust transport + +import ( + "fmt" + "github.com/OperatorFoundation/obfs4/common/log" + "golang.org/x/net/proxy" + "net" + "time" + + "github.com/OperatorFoundation/shapeshifter-ipc" + "github.com/blanu/Dust/go/v2/interface" +) + +type dustClient struct { + serverPubkey *Dust.ServerPublic + dialer proxy.Dialer +} + +type dustServer struct { + serverPrivkey *Dust.ServerPrivate + dialer proxy.Dialer +} + +func NewDustClient(serverPublic string, dialer proxy.Dialer) *dustClient { + unparsed := make(map[string]string) + unparsed["p"]=serverPublic + + spub, err := Dust.ParseServerPublic(unparsed) + if err != nil { + return nil + } + + return &dustClient{serverPubkey: spub, dialer: dialer} +} + +type dustTransportListener struct { + listener *net.TCPListener + transport *dustServer +} + +//begin optimizer code +type Transport struct { + ServerPublic string + Address string + Dialer proxy.Dialer +} + +type Config struct { + ServerPublic string `json:"server-public"` +} +func (transport Transport) Dial() (net.Conn, error) { + dustTransport := NewDustClient(transport.ServerPublic, transport.Dialer) + conn, err := dustTransport.Dial(transport.Address) + if err != nil { + return nil, err + } else { + return conn, nil + } +} +//end optimizer code + +func newDustTransportListener(listener *net.TCPListener, transport *dustServer) *dustTransportListener { + return &dustTransportListener{listener: listener, transport: transport} +} + +// Create outgoing transport connection +func (transport *dustClient) Dial(address string) (net.Conn, error) { + conn, dialErr := net.Dial("tcp", address) + if dialErr != nil { + return conn, dialErr + } + + transportConn, err := Dust.BeginRawStreamClient(conn, transport.serverPubkey) + if err != nil { + closeErr := conn.Close() + if closeErr != nil { + log.Errorf("could not close") + } + return conn, dialErr + } + + return transportConn, err +} + +// Create listener for incoming transport connection +func (transport *dustServer) Listen(address string) net.Listener { + addr, resolveErr := pt.ResolveAddr(address) + if resolveErr != nil { + fmt.Println(resolveErr.Error()) + return nil + } + + ln, err := net.ListenTCP("tcp", addr) + if err != nil { + fmt.Println(err.Error()) + return nil + } + + return newDustTransportListener(ln, transport) +} + +func (listener *dustTransportListener) Addr() net.Addr { + interfaces, _ := net.Interfaces() + addrs, _ := interfaces[0].Addrs() + return addrs[0] +} + +// Accept waits for and returns the next connection to the listener. +func (listener *dustTransportListener) Accept() (net.Conn, error) { + conn, err := listener.listener.Accept() + if err != nil { + return nil, err + } + + ssconn, streamerr := Dust.BeginRawStreamServer(conn, listener.transport.serverPrivkey) + if streamerr != nil { + return nil, streamerr + } + + dsconn, dserr := newDustServerConn(ssconn) + if dserr != nil { + return nil, dserr + } + + return dsconn, nil +} + +// Close closes the transport listener. +// Any blocked Accept operations will be unblocked and return errors. +func (listener *dustTransportListener) Close() error { + return listener.listener.Close() +} + +type dustConn struct { + conn *Dust.RawStreamConn +} + +func (sconn *dustConn) Read(b []byte) (int, error) { + return sconn.conn.Read(b) +} + +func (sconn *dustConn) Write(b []byte) (int, error) { + return sconn.conn.Write(b) +} + +func (sconn *dustConn) Close() error { + return sconn.conn.Close() +} + +func (sconn *dustConn) LocalAddr() net.Addr { + return sconn.conn.LocalAddr() +} + +func (sconn *dustConn) RemoteAddr() net.Addr { + return sconn.conn.RemoteAddr() +} + +func (sconn *dustConn) SetDeadline(t time.Time) error { + return sconn.conn.SetDeadline(t) +} + +func (sconn *dustConn) SetReadDeadline(t time.Time) error { + return sconn.conn.SetReadDeadline(t) +} + +func (sconn *dustConn) SetWriteDeadline(t time.Time) error { + return sconn.conn.SetWriteDeadline(t) +} + +func newDustServerConn(conn *Dust.RawStreamConn) (c *dustConn, err error) { + // Initialize a server connection. + c = &dustConn{conn} + + return +} + +var _ net.Listener = (*dustTransportListener)(nil) +var _ net.Conn = (*dustConn)(nil) diff --git a/transports/Dust/v3/Dust_test.go b/transports/Dust/v3/Dust_test.go new file mode 100644 index 0000000..2aaacc5 --- /dev/null +++ b/transports/Dust/v3/Dust_test.go @@ -0,0 +1,84 @@ +package Dust + +/* + * Copyright (c) 2019, Operator Foundation + * + */ + +// Package Dust provides a PT 2.1 Go API wrapper around the Dust transport + + +import ( + "testing" +) + +const data = "test" + +func TestDust(t *testing.T) { + //create a server + serverConfig := dustServer{ + serverPrivkey: nil, + dialer: nil, + } + clientConfig := dustClient{ + serverPubkey: nil, + dialer: nil, + } + + //call listen on the server + serverListener := serverConfig.Listen("127.0.0.1:1234") + if serverListener == nil { + t.Fail() + return + } + + //Create Server connection and format it for concurrency + go func() { + //create server buffer + serverBuffer := make([]byte, 4) + + //create serverConn + serverConn, acceptErr := serverListener.Accept() + if acceptErr != nil { + t.Fail() + return + } + + //read on server side + _, serverReadErr := serverConn.Read(serverBuffer) + if serverReadErr != nil { + t.Fail() + return + } + + //write data from serverConn for client to read + _, serverWriteErr := serverConn.Write([]byte(data)) + if serverWriteErr != nil { + t.Fail() + return + } + }() + + //create client buffer + clientBuffer := make([]byte, 4) + //call dial on client and check error + clientConn, dialErr := clientConfig.Dial("127.0.0.1:1234") + if dialErr != nil { + t.Fail() + return + } + + //write data from clientConn for server to read + _, clientWriteErr := clientConn.Write([]byte(data)) + if clientWriteErr != nil { + t.Fail() + return + } + + //read on client side + _, clientReadErr := clientConn.Read(clientBuffer) + if clientReadErr != nil { + t.Fail() + return + } +} diff --git a/transports/Dust/v3/LICENSE.md b/transports/Dust/v3/LICENSE.md new file mode 100644 index 0000000..f98047a --- /dev/null +++ b/transports/Dust/v3/LICENSE.md @@ -0,0 +1,40 @@ +# Licenses for software included in this directory + +## Main Dust packages and first-party support packages + +The directories 'v2' and 'sillyHex' compose the main Dust packages for Go. The directories 'buf', 'huffman', 'model1', 'prim1', and 'proc' compose the first-party support packages. These are all subject to the following terms: + +* Copyright © 2015 Drake Wilson <drake@dasyatidae.com> + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +## Skein + +The directory 'skein' contains a modified version of Dmitry Chestnykh's Skein-512 code. It is subject to the following terms: + +* Copyright © 2012 Dmitry Chestnykh <dmitry@codingrobots.com> +* Copyright © 2015 Drake Wilson <drake@dasyatidae.com> +* All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +## Dist + +The directory 'dist' contains a local copy of the random distribution code from gonum. + +(TODO: copy appropriate file for this here) + + diff --git a/transports/Dust/v3/NOTES b/transports/Dust/v3/NOTES new file mode 100644 index 0000000..7c92c3a --- /dev/null +++ b/transports/Dust/v3/NOTES @@ -0,0 +1,30 @@ +#+TITLE: Working notes on Dust Go implementation +Updated: [2015-04-13 Mon] + +* Tasks +** Dust2 juggling +*** Reimplement close/interrupt support for newly juggled crypting layer API +** General +*** Adjust Huffman coder to be able to use restricted symbol set +*** Implementation documentation pass started [2015-04-11 Sat] +- [ ] buf +- [ ] huffman +- [ ] prim1 +- [ ] proc +- [ ] skein +- [ ] v2/crypting +- [ ] v2/shaping +- [ ] v2/engine +*** Use 'byte' terminology consistently +*** Use consistent error terminology +*** Pull license for 'dist' package +** Mostly optional +*** Refactor CLI parts + +* (metadata) + +Local variables: +mode: org +mode: auto-fill +fill-column: 110 +End: diff --git a/transports/Dust/v3/README.md b/transports/Dust/v3/README.md new file mode 100644 index 0000000..6d6fa53 --- /dev/null +++ b/transports/Dust/v3/README.md @@ -0,0 +1,34 @@ +# Overview of Dust for Go + +(This is still in an unstable state! It is not suitable for production deployment.) + +## Using Dust + +An application that wishes to use Dust will generally link with the main Dust engine package plus one or more model packages. By convention: + +0. Model codecs are generated as Go code, usually via the programs in ../modelgen. They are placed in a package or packages in the namespace of the client application. +1. A client application imports all of its model packages for side effects. +2. The model packages call into the Dust package to register their names at init time. +3. The client application can then request models by short-string names for establishing connections. + +Currently, the only available Dust engine package is in ./v2/engine; its full import path is therefore github.com/blanu/Dust/go/v2/engine. + +## Server identities in Dust 2 + +The Dust engine uses ASCII key-value parameters for representing public and private server identity and endpoint configuration information. Keys that have a question mark as the last character are considered optional hints; these may be discarded by software versions or configurations that do not support them, without causing connection failures. Neither a key nor a value may contain newlines. A key may not contain horizontal whitespace or the # character. A value may not begin with horizontal whitespace. + +Endpoint configuration parameters used by either side include: + +- `m=MODEL-NAME` (required): the model name being requested, out of an application-specific set. +- `m.KEY=VALUE`: possible model-specific parameters. +- `mtu=DECIMAL`: maximum size of datagrams that can be delivered over each Dust connection. The default is 1500. + +Parameters given to a client to identify a server also include: + +- `p=PUBLIC-KEY` (required): the uniform representative of the long-term Curve25519 public key of the server in Base32. +- `n=OPAQUE` (required): the 32-octet opaque name of the server in Base32. + +Parameters given to a server to identify itself instead include: + +- `px!=PRIVATE-KEY` (required): the long-term Curve25519 private key of the server in Base32. +- `n=OPAQUE` (required): the 32-octet opaque name of the server in Base32. diff --git a/transports/Dust/v3/go.mod b/transports/Dust/v3/go.mod new file mode 100644 index 0000000..9b8d6eb --- /dev/null +++ b/transports/Dust/v3/go.mod @@ -0,0 +1,11 @@ +module github.com/OperatorFoundation/shapeshifter-transports/transports/Dust/v2 + +go 1.12 + +require ( + github.com/OperatorFoundation/obfs4 v1.0.0 + github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0 + github.com/blanu/Dust v1.0.1 // indirect + github.com/blanu/Dust/go/v2/interface v1.0.1 + golang.org/x/net v0.0.0-20200226121028-0de0cce0169b +) diff --git a/transports/Dust/v3/go.sum b/transports/Dust/v3/go.sum new file mode 100644 index 0000000..609dff0 --- /dev/null +++ b/transports/Dust/v3/go.sum @@ -0,0 +1,26 @@ +git.torproject.org/pluggable-transports/goptlib.git v1.1.0/go.mod h1:YT4XMSkuEXbtqlydr9+OxqFAyspUv0Gr9qhM3B++o/Q= +github.com/OperatorFoundation/ed25519 v0.0.0-20200225224545-b22b4bd3ddef h1:1xEtDEuNE9/yybZaHS94OIjx5FUo4e8M3UwcK9bFC9s= +github.com/OperatorFoundation/ed25519 v0.0.0-20200225224545-b22b4bd3ddef/go.mod h1:gQNGvsyT4Zmps9H/yzCqdc+RQzt8ZxCndRNtGTYnBzQ= +github.com/OperatorFoundation/obfs4 v1.0.0 h1:OcfdNMzv69fKQrLTkTSwpaBkHyBZMLjigA5M3txZpAg= +github.com/OperatorFoundation/obfs4 v1.0.0/go.mod h1:6apgxOLYwyvbpzujpFHWu6Jlc+mjn1aFK7WvNijIVWc= +github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0 h1:zDYt6FDJwDSX4woVFVK2EMt7fkxU5L5qDNLUjQwA+BQ= +github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0/go.mod h1:kB00Ak8Dgn1uZlZHLc/WsUta58Jc+n/ZhCetcPkh42Q= +github.com/blanu/Dust v1.0.0/go.mod h1:jLFQI2Ufz4kBnGiTzh8O9+/p4U/9MLbouXkaympnTI0= +github.com/blanu/Dust v1.0.1 h1:C1IiRXr9YP1A4iiuhhpQOCgl8785LoVq78lbDrVRVqc= +github.com/blanu/Dust v1.0.1/go.mod h1:jLFQI2Ufz4kBnGiTzh8O9+/p4U/9MLbouXkaympnTI0= +github.com/blanu/Dust/go/v2/interface v1.0.1 h1:lIQrNXljx8vgTTwB+gObrkA6jBhokmgH/uHp1OxbqxE= +github.com/blanu/Dust/go/v2/interface v1.0.1/go.mod h1:0NnpBd5fkRrG2I/pf6bcUaL5jpp84LeShsQzn4gCOCw= +github.com/dchest/siphash v1.2.1/go.mod h1:q+IRvb2gOSrUnYoPqHiyHXS0FOBBOdl6tONBlVnOnt4= +github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88= +github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= +github.com/willscott/goturn v0.0.0-20170802220503-19f41278d0c9/go.mod h1:PfwRjodCaQXOsHnh2DeVaXqCFCIrbn5WLj1+A5bQkD4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d h1:1ZiEyfaQIg3Qh0EoqpwAakHVhecoE5wlSg5GjnafJGw= +golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b h1:0mm1VjtFUOIlE1SbDlwjYaDxZVDP2S5ou6y0gSgXHu8= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/transports/Optimizer/v3/Optimizer.go b/transports/Optimizer/v3/Optimizer.go new file mode 100644 index 0000000..ba77fb7 --- /dev/null +++ b/transports/Optimizer/v3/Optimizer.go @@ -0,0 +1,269 @@ +/* + * Copyright (c) 2019, Operator Foundation + * + */ + +// Package optimizer provides a PT 2.0 Go API wrapper around the connections used +package optimizer + +import ( + "errors" + "net" + "time" +) + +const timeoutInSeconds = 60 + +//Transport is a program that transforms network traffic +type Transport interface { + Dial() (net.Conn, error) +} + +//Client contains the two parameters needed to use Optimizer. +type Client struct { + Transports []Transport + Strategy Strategy +} + +//NewOptimizerClient is the initializer +func NewOptimizerClient(Transports []Transport, Strategy Strategy) *Client { + return &Client{Transports, Strategy} +} + +//Dial connects to the address on the named network +func (OptT *Client) Dial() (net.Conn, error) { + firstTryTime := time.Now() + transport := OptT.Strategy.Choose() + if transport == nil { + return nil, errors.New("optimizer strategy returned nil") + } + conn, err := transport.Dial() + for err != nil { + OptT.Strategy.Report(transport, false, 60) + currentTryTime := time.Now() + durationElapsed := currentTryTime.Sub(firstTryTime) + if durationElapsed >= timeoutInSeconds { + return nil, errors.New("timeout. Dial time exceeded") + } + transport = OptT.Strategy.Choose() + conn, err = transport.Dial() + } + OptT.Strategy.Report(transport, true, 60) + return conn, nil +} + +//Strategy is the method used to choose a transport +type Strategy interface { + Choose() Transport + Report(transport Transport, success bool, durationElapsed float64) +} + +//FirstStrategy returns the first strategy in the array +type FirstStrategy struct { + transports []Transport +} + +//NewFirstStrategy initializes FirstStrategy +func NewFirstStrategy(transports []Transport) Strategy { + return &FirstStrategy{transports} +} + +//Choose selects a transport in the array +func (strategy *FirstStrategy) Choose() Transport { + return strategy.transports[0] +} + +//Report returns if the transport was successful and how long the connection took +func (strategy *FirstStrategy) Report(Transport, bool, float64) { + +} + +//NewRandomStrategy initializes RandomStrategy +func NewRandomStrategy(transports []Transport) Strategy { + return &RandomStrategy{transports} +} + +//RandomStrategy returns a transport at random +type RandomStrategy struct { + transports []Transport +} + +//Choose selects a transport in the array +func (strategy *RandomStrategy) Choose() Transport { + return strategy.transports[0] +} + +//Report returns if the transport was successful and how long the connection took +func (strategy *RandomStrategy) Report(Transport, bool, float64) { + +} + +//NewRotateStrategy initializes RotateStrategy +func NewRotateStrategy(transports []Transport) Strategy { + return &RotateStrategy{transports, 1} +} + +//RotateStrategy cycles through the list of transports, using a different one each time +type RotateStrategy struct { + transports []Transport + index int +} + +//Choose selects a transport in the array +func (strategy *RotateStrategy) Choose() Transport { + transport := strategy.transports[strategy.index] + strategy.index++ + if strategy.index >= len(strategy.transports) { + strategy.index = 0 + } + return transport +} + +//Report returns if the transport was successful and how long the connection took +func (strategy *RotateStrategy) Report(Transport, bool, float64) { + +} + +//TrackStrategy assigns a score to each transport and server that is remembered and used to +//choose the best option +type TrackStrategy struct { + index int + trackMap map[Transport]int + transport []Transport +} + +//NewTrackStrategy initializes TrackStrategy +func NewTrackStrategy(transport []Transport) Strategy { + track := TrackStrategy{0, map[Transport]int{}, transport} + track.trackMap = make(map[Transport]int) + return &track +} + +//Choose selects a transport in the array +func (strategy *TrackStrategy) Choose() Transport { + transport := strategy.transport[strategy.index] + score := strategy.findScore(strategy.transport) + startIndex := strategy.index + strategy.incrementIndex(strategy.transport) + for startIndex != strategy.index { + if score == 1 { + return transport + } + transport = strategy.transport[strategy.index] + score = strategy.findScore(strategy.transport) + strategy.incrementIndex(strategy.transport) + + } + return nil +} + +//findScore is used to find the score given to each transport based on performance +func (strategy *TrackStrategy) findScore(transports []Transport) int { + transport := transports[strategy.index] + score, ok := strategy.trackMap[transport] + if ok { + return score + } + return 1 + +} + +//incrementIndex is used to cycle through the transport index +func (strategy *TrackStrategy) incrementIndex(transports []Transport) { + strategy.index++ + if strategy.index >= len(transports) { + strategy.index = 0 + } +} + +//Report returns if the transport was successful and how long the connection took +func (strategy *TrackStrategy) Report(transport Transport, success bool, _ float64) { + if success { + strategy.trackMap[transport] = 1 + } else { + strategy.trackMap[transport] = 0 + } +} + +//minimizeDialDuration is used to find the transport with the fastest response time +type minimizeDialDuration struct { + index int + trackMap map[Transport]float64 + transports []Transport +} + +//NewMinimizeDialDuration initializes minimizeDialDuration +func NewMinimizeDialDuration(transport []Transport) Strategy { + duration := minimizeDialDuration{0, map[Transport]float64{}, transport} + duration.trackMap = make(map[Transport]float64) + return &duration +} + +//Choose selects a transport in the array +func (strategy *minimizeDialDuration) Choose() Transport { + transport := strategy.transports[strategy.index] + score := strategy.findScore(strategy.transports) + startIndex := strategy.index + strategy.incrementIndex(strategy.transports) + for startIndex != strategy.index { + if score == 0 { + return transport + } + strategy.incrementIndex(strategy.transports) + transport = strategy.minDuration() + if transport == nil { + transport = strategy.transports[strategy.index] + score = strategy.findScore(strategy.transports) + continue + } else { + return transport + } + + } + return nil +} + +//incrementIndex is used to cycle through the transport index +func (strategy *minimizeDialDuration) incrementIndex(transports []Transport) { + strategy.index++ + if strategy.index >= len(transports) { + strategy.index = 0 + } +} + +//findScore is used to find the score given to each transport based on performance +func (strategy *minimizeDialDuration) findScore(transports []Transport) float64 { + transport := transports[strategy.index] + score, ok := strategy.trackMap[transport] + if ok { + return score + } + return 0 + +} + +//Report returns if the transport was successful and how long the connection took +func (strategy *minimizeDialDuration) Report(transport Transport, success bool, durationElapsed float64) { + if success { + if durationElapsed < 60 { + strategy.trackMap[transport] = durationElapsed + } else { + strategy.trackMap[transport] = 60.0 + } + } else { + strategy.trackMap[transport] = 60.0 + } +} + +//minDuration assigns a value to the response time +func (strategy *minimizeDialDuration) minDuration() Transport { + min := 61.0 + var transport Transport = nil + for key, value := range strategy.trackMap { + if value < min { + min = value + transport = key + } + } + return transport +} diff --git a/transports/Optimizer/v3/Optimizer_test.go b/transports/Optimizer/v3/Optimizer_test.go new file mode 100644 index 0000000..04936d4 --- /dev/null +++ b/transports/Optimizer/v3/Optimizer_test.go @@ -0,0 +1,327 @@ +package optimizer + +import ( + "github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v2" + "github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v2" + "github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2" + "github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v2" + "golang.org/x/net/proxy" + "io/ioutil" + "net" + "net/url" + "os" + "os/user" + "path" + "runtime" + "strings" + "testing" +) + +const data = "test" + +func TestMain(m *testing.M) { + config := shadow.NewConfig("1234", "CHACHA20-IETF-POLY1305") + listener := config.Listen("127.0.0.1:1235") + go acceptConnections(listener) + + _ = obfs4.RunLocalObfs4Server("test") + + RunLocalObfs2Server() + + os.Exit(m.Run()) +} + +func acceptConnections(listener net.Listener) { + for { + _, err := listener.Accept() + if err != nil { + return + } + } +} + +func TestMeekliteDial(t *testing.T) { + unparsedURL := "https://d2zfqthxsdq309.cloudfront.net/" + URL, parseErr := url.Parse(unparsedURL) + if parseErr != nil { + t.Fail() + } + meekliteTransport := meeklite.Transport{URL: URL, Front: "a0.awsstatic.com", Address: "127.0.0.1:1235" } + _, err := meekliteTransport.Dial() + if err != nil { + t.Fail() + } +} + +func TestOptimizerMeekliteDial(t *testing.T) { + unparsedURL := "https://d2zfqthxsdq309.cloudfront.net/" + URL, parseErr := url.Parse(unparsedURL) + if parseErr != nil { + t.Fail() + } + meekliteTransport := meeklite.Transport{URL: URL, Front: "a0.awsstatic.com", Address: "127.0.0.1:1235" } + transports := []Transport{meekliteTransport} + strategy := NewFirstStrategy(transports) + optimizerTransport := NewOptimizerClient(transports, strategy) + _, err := optimizerTransport.Dial() + if err != nil { + t.Fail() + } +} + +func TestShadowDial(t *testing.T) { + shadowTransport := shadow.Transport{Password: "1234", CipherName: "CHACHA20-IETF-POLY1305", Address: "127.0.0.1:1235"} + _, err := shadowTransport.Dial() + if err != nil { + t.Fail() + } +} + +func TestOptimizerShadowDial(t *testing.T) { + shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235") + transports := []Transport{&shadowTransport} + strategy := NewFirstStrategy(transports) + optimizerTransport := NewOptimizerClient(transports, strategy) + _, err := optimizerTransport.Dial() + if err != nil { + t.Fail() + } +} + +func TestOptimizerObfs2Dial(t *testing.T) { + obfs2Transport := obfs2.New("127.0.0.1:1237", proxy.Direct) + transports := []Transport{obfs2Transport} + strategy := NewFirstStrategy(transports) + optimizerTransport := NewOptimizerClient(transports, strategy) + _, err := optimizerTransport.Dial() + if err != nil { + t.Fail() + } +} + +func TestObfs4Transport_Dial(t *testing.T) { + obfs4Transport, transportErr := obfs4.RunObfs4Client() + if transportErr != nil { + t.Fail() + return + } + _, err := obfs4Transport.Dial("127.0.0.1:1234") + if err != nil { + t.Fail() + } +} + +func TestOptimizerObfs4Transport_Dial(t *testing.T) { + dialer := proxy.Direct + certstring, certError := getObfs4CertString() + if certError != nil { + t.Fail() + return + } + obfs4Transport := obfs4.OptimizerTransport{ + CertString: *certstring, + IatMode: 0, + Address: "127.0.0.1:1234", + Dialer: dialer} + transports := []Transport{obfs4Transport} + strategy := NewFirstStrategy(transports) + optimizerTransport := NewOptimizerClient(transports, strategy) + _, err := optimizerTransport.Dial() + if err != nil { + t.Fail() + } +} + +func TestOptimizerTransportFirstDial(t *testing.T) { + dialer := proxy.Direct + certstring, certError := getObfs4CertString() + if certError != nil { + t.Fail() + return + } + obfs4Transport := obfs4.OptimizerTransport{ + CertString: *certstring, + IatMode: 0, + Address: "127.0.0.1:1234", + Dialer: dialer} + shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235") + transports := []Transport{obfs4Transport, &shadowTransport} + strategy := NewFirstStrategy(transports) + optimizerTransport := NewOptimizerClient(transports, strategy) + for i := 1; i <= 3; i++ { + _, err := optimizerTransport.Dial() + if err != nil { + t.Fail() + } + } +} + +func TestOptimizerTransportRandomDial(t *testing.T) { + dialer := proxy.Direct + certstring, certError := getObfs4CertString() + if certError != nil { + t.Fail() + return + } + obfs4Transport := obfs4.OptimizerTransport{ + CertString: *certstring, + IatMode: 0, + Address: "127.0.0.1:1234", + Dialer: dialer, + } + shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235") + transports := []Transport{obfs4Transport, &shadowTransport} + strategy := NewRandomStrategy(transports) + optimizerTransport := NewOptimizerClient(transports, strategy) + + for i := 1; i <= 3; i++ { + _, err := optimizerTransport.Dial() + if err != nil { + t.Fail() + } + } +} + +func TestOptimizerTransportRotateDial(t *testing.T) { + dialer := proxy.Direct + certstring, certError := getObfs4CertString() + if certError != nil { + t.Fail() + return + } + obfs4Transport := obfs4.OptimizerTransport{ + CertString: *certstring, + IatMode: 0, + Address: "127.0.0.1:1234", + Dialer: dialer, +} + shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235") + transports := []Transport{obfs4Transport, &shadowTransport} + strategy := NewRotateStrategy(transports) + optimizerTransport := NewOptimizerClient(transports, strategy) + + for i := 1; i <= 3; i++ { + _, err := optimizerTransport.Dial() + if err != nil { + t.Fail() + } + } +} + +func TestOptimizerTransportTrackDial(t *testing.T) { + dialer := proxy.Direct + certstring, certError := getObfs4CertString() + if certError != nil { + t.Fail() + return + } + obfs4Transport := obfs4.OptimizerTransport{ + CertString: *certstring, + IatMode: 0, + Address: "127.0.0.1:1234", + Dialer: dialer, +} + shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235") + transports := []Transport{obfs4Transport, &shadowTransport} + strategy := NewTrackStrategy(transports) + optimizerTransport := NewOptimizerClient(transports, strategy) + + for i := 1; i <= 3; i++ { + _, err := optimizerTransport.Dial() + if err != nil { + t.Fail() + } + } +} + +func TestOptimizerTransportMinimizeDialDurationDial(t *testing.T) { + dialer := proxy.Direct + certstring, certError := getObfs4CertString() + if certError != nil { + t.Fail() + return + } + obfs4Transport := obfs4.OptimizerTransport{ + CertString: *certstring, + IatMode: 0, + Address: "127.0.0.1:1234", + Dialer: dialer, + } + shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235") + transports := []Transport{obfs4Transport, &shadowTransport} + strategy := NewMinimizeDialDuration(transports) + optimizerTransport := NewOptimizerClient(transports, strategy) + + for i := 1; i <= 3; i++ { + _, err := optimizerTransport.Dial() + if err != nil { + t.Fail() + } + } +} + +func getObfs4CertString() (*string, error) { + usr, userError := user.Current() + if userError != nil { + return nil, userError + } + home := usr.HomeDir + var fPath string + if runtime.GOOS == "darwin" { + fPath = path.Join(home, "shapeshifter-transports/stateDir/obfs4_bridgeline.txt") + } else { + fPath = path.Join(home, "gopath/src/github.com/OperatorFoundation/shapeshifter-transports/stateDir/obfs4_bridgeline.txt") + } + bytes, fileError := ioutil.ReadFile(fPath) + if fileError != nil { + return nil, fileError + } + //print(bytes) + byteString := string(bytes) + //print(byteString) + lines := strings.Split(byteString, "\n") + //print(lines) + bridgeLine := lines[len(lines)-2] + //println(bridgeLine) + bridgeParts1 := strings.Split(bridgeLine, " ") + bridgePart := bridgeParts1[5] + certstring := bridgePart[5:] + + return &certstring, nil +} +func RunLocalObfs2Server() { + //create a server + config := obfs2.NewObfs2Transport() + + //call listen on the server + serverListener := config.Listen("127.0.0.1:1237") + if serverListener == nil { + return + } + + //Create Server connection and format it for concurrency + go func() { + //create server buffer + serverBuffer := make([]byte, 4) + + //create serverConn + for { + serverConn, acceptErr := serverListener.Accept() + if acceptErr != nil { + return + } + + //read on server side + _, serverReadErr := serverConn.Read(serverBuffer) + if serverReadErr != nil { + return + } + + //write data from serverConn for client to read + _, serverWriteErr := serverConn.Write([]byte(data)) + if serverWriteErr != nil { + return + } + } + }() +} \ No newline at end of file diff --git a/transports/Optimizer/v3/README.md b/transports/Optimizer/v3/README.md new file mode 100644 index 0000000..ec9a19b --- /dev/null +++ b/transports/Optimizer/v3/README.md @@ -0,0 +1,43 @@ +# Optimizer + + +Optimizer is a pluggable transport that uses one of several possible “Strategies” to choose between the transports you provide to create a connection. It is not a standalone transport, but is rather a mechanism for choosing between various transports in order to find the one best suited for the user’s needs. For more information about pluggable transports, please refer to [pluggabletransports.info](https://www.pluggabletransports.info/). + +Here is a list of the currently available Optimizer strategies: + +**Rotate Strategy**: This strategy simply rotates through the list of provided transports and tries the next one in the list each time a connection is needed. + +**Choose Random Strategy**: A transport is selected at random from the list for each connection request. + +**Track Strategy**: A strategy that attempts to connect with each of the provided transports. It keeps track of which transports are connecting successfully and favors using those. + +**Minimize Dial Strategy**: The transport is chosen based on which has been shown to connect the fastest. + +## Using Optimizer + + +### Go Version: + +Optimizer is one of the transports available in the [Shapeshifter-Transports library](https://github.com/OperatorFoundation/Shapeshifter-Transports). + +1. First you will need to initialize the transports you would like Optimizer to use: + `dialer := proxy.Direct + obfs4Transport := obfs4.Transport{ + CertString: "InsertCertStringHere", + IatMode: 0 or 1, + Address: "InsertAddressHere", + Dialer: dialer, + }` + `shadowTransport := shadow.Transport{"InsertPasswordHere", "InsertCipherNameHere", "InsertAddressHere"}` + +2. Create an array with these transports: + `transports := []Transport{obfs4Transport, shadowTransport}` + +3. Initialize the strategy of your choice using the array of transports you created: + `strategy := NewMinimizeDialDuration(transports)` + +4. Create an instance of OptimizerConnectionFactory using your new Strategy instance: + `optimizerTransport := NewOptimizerClient(transports, strategy)` + +5. Call Dial on optimizerTransport: + `_, err := optimizerTransport.Dial()` diff --git a/transports/Optimizer/v3/go.mod b/transports/Optimizer/v3/go.mod new file mode 100644 index 0000000..8353f14 --- /dev/null +++ b/transports/Optimizer/v3/go.mod @@ -0,0 +1,11 @@ +module github.com/OperatorFoundation/shapeshifter-transports/transports/Optimizer/v2 + +go 1.12 + +require ( + github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v2 v2.1.22 + github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v2 v2.1.22 + github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2 v2.1.22 + github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v2 v2.1.22 + golang.org/x/net v0.0.0-20200226121028-0de0cce0169b +) diff --git a/transports/Optimizer/v3/go.sum b/transports/Optimizer/v3/go.sum new file mode 100644 index 0000000..975af23 --- /dev/null +++ b/transports/Optimizer/v3/go.sum @@ -0,0 +1,45 @@ +git.torproject.org/pluggable-transports/goptlib.git v1.1.0/go.mod h1:YT4XMSkuEXbtqlydr9+OxqFAyspUv0Gr9qhM3B++o/Q= +github.com/OperatorFoundation/ed25519 v0.0.0-20200225224545-b22b4bd3ddef h1:1xEtDEuNE9/yybZaHS94OIjx5FUo4e8M3UwcK9bFC9s= +github.com/OperatorFoundation/ed25519 v0.0.0-20200225224545-b22b4bd3ddef/go.mod h1:gQNGvsyT4Zmps9H/yzCqdc+RQzt8ZxCndRNtGTYnBzQ= +github.com/OperatorFoundation/obfs4 v1.0.0 h1:OcfdNMzv69fKQrLTkTSwpaBkHyBZMLjigA5M3txZpAg= +github.com/OperatorFoundation/obfs4 v1.0.0/go.mod h1:6apgxOLYwyvbpzujpFHWu6Jlc+mjn1aFK7WvNijIVWc= +github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0 h1:zDYt6FDJwDSX4woVFVK2EMt7fkxU5L5qDNLUjQwA+BQ= +github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0/go.mod h1:kB00Ak8Dgn1uZlZHLc/WsUta58Jc+n/ZhCetcPkh42Q= +github.com/OperatorFoundation/shapeshifter-transports v0.0.0-20200211223228-5b0aa21018a5 h1:UrCgBKvfj+Rim1jAUkRqQt1neJgLVHtKt0228tEmFKY= +github.com/OperatorFoundation/shapeshifter-transports v0.0.0-20200211223228-5b0aa21018a5/go.mod h1:u3jvRgYV13oHabVAdXekh3yk9PHfpCKvB8uolQEs4jA= +github.com/OperatorFoundation/shapeshifter-transports/transports/Optimizer/v2 v2.1.12/go.mod h1:+A6vQ50ZAHi76GOGtpH730VFirwb1p8E6VJM8M50gNk= +github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v2 v2.1.11/go.mod h1:yPCbCoTjLIG+p0xiuRDwW5t+DivxTHqGU5njf89AkHY= +github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v2 v2.1.22 h1:BuiRy5QWa5hI3dNcOGw/Co4GYpU3PONrjrAlUB3pzt4= +github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v2 v2.1.22/go.mod h1:DEfaE6lfJKEG5CkCRks4rXTMi1xYwbYR0sa+JKsgsr0= +github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v2 v2.1.22 h1:ygZ3s1ROaeyfrIjIo1pFAiq73UtOv8iBxZtV5MGZjVc= +github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v2 v2.1.22/go.mod h1:S2qmYjCQzB7XGJ5JMuVDTp2IbQveaAhXQ9BVOx+6KD8= +github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2 v2.1.11/go.mod h1:OUFBnkMmjMHTWqEQlanDOMTgBjU5QARjklwQv9Qovr4= +github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2 v2.1.22 h1:WIs1AFLM7qNWcO6QEksWdldnH2H4WXaD5d25iogN8Nk= +github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2 v2.1.22/go.mod h1:OUFBnkMmjMHTWqEQlanDOMTgBjU5QARjklwQv9Qovr4= +github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v2 v2.1.11/go.mod h1:GN8ahnEHVGcPbR0raxdpWekjgElppspPNAAOpmNxQxU= +github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v2 v2.1.22 h1:F7YHfgEJ2Nq4f4XQFiXI4uMueuZGlQbEIdEIhN2b60s= +github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v2 v2.1.22/go.mod h1:GN8ahnEHVGcPbR0raxdpWekjgElppspPNAAOpmNxQxU= +github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da h1:KjTM2ks9d14ZYCvmHS9iAKVt9AyzRSqNU1qabPih5BY= +github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da/go.mod h1:eHEWzANqSiWQsof+nXEI9bUVUyV6F53Fp89EuCh2EAA= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dchest/siphash v1.2.1 h1:4cLinnzVJDKxTCl9B01807Yiy+W7ZzVHj/KIroQRvT4= +github.com/dchest/siphash v1.2.1/go.mod h1:q+IRvb2gOSrUnYoPqHiyHXS0FOBBOdl6tONBlVnOnt4= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/shadowsocks/go-shadowsocks2 v0.0.11 h1:dXloqEhYnZV40jblWTK8kWeC0Eb+dgql4S0tj99e8j0= +github.com/shadowsocks/go-shadowsocks2 v0.0.11/go.mod h1:R+KWaoIwRRhnpw6XV+dZil0XHi64Hc1D7hXUyXTjUzQ= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/willscott/goturn v0.0.0-20170802220503-19f41278d0c9/go.mod h1:PfwRjodCaQXOsHnh2DeVaXqCFCIrbn5WLj1+A5bQkD4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d h1:1ZiEyfaQIg3Qh0EoqpwAakHVhecoE5wlSg5GjnafJGw= +golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b h1:0mm1VjtFUOIlE1SbDlwjYaDxZVDP2S5ou6y0gSgXHu8= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/transports/Replicant/v3/Optimizer.go b/transports/Replicant/v3/Optimizer.go new file mode 100644 index 0000000..9af583c --- /dev/null +++ b/transports/Replicant/v3/Optimizer.go @@ -0,0 +1,41 @@ +package replicant + +import ( + "golang.org/x/net/proxy" + "net" +) + +// This makes Replicant compliant with Optimizer +type Transport struct { + Config ClientConfig + Address string + Dialer proxy.Dialer +} + +// TODO: the dial we call currently does not return an error +func (transport Transport) Dial() (net.Conn, error) { + conn, dialErr := transport.Dialer.Dial("tcp", transport.Address) + if dialErr != nil { + return nil, dialErr + } + + dialConn := conn + transportConn, err := NewClientConnection(conn, transport.Config) + if err != nil { + _ = dialConn.Close() + return nil, err + } + + return transportConn, nil + + //replicantTransport := New(transport.Config, transport.Dialer) + //conn := replicantTransport.Dial(transport.Address) + //conn, err:= replicantTransport.Dial(transport.Address), errors.New("connection failed") + //if err != nil { + // return nil, err + //} else { + // return conn, nil + //} + //return conn, nil +} + diff --git a/transports/Replicant/v3/README.md b/transports/Replicant/v3/README.md new file mode 100644 index 0000000..b08b083 --- /dev/null +++ b/transports/Replicant/v3/README.md @@ -0,0 +1,5 @@ +# Overview of Replicant for Go + +(This is still in an unstable state! It is not suitable for production deployment.) + +Replicant is still in progress. more information will appear as development furthers. \ No newline at end of file diff --git a/transports/Replicant/v3/ReplicantClientConfig.json b/transports/Replicant/v3/ReplicantClientConfig.json new file mode 100644 index 0000000..74bb73f --- /dev/null +++ b/transports/Replicant/v3/ReplicantClientConfig.json @@ -0,0 +1 @@ +{"config":"M/+BAwEBDENsaWVudENvbmZpZwH/ggABAgEJVG9uZWJ1cnN0ARAAAQZQb2xpc2gBEAAAAP+8/4IBZmdpdGh1Yi5jb20vT3BlcmF0b3JGb3VuZGF0aW9uL3NoYXBlc2hpZnRlci10cmFuc3BvcnRzL3RyYW5zcG9ydHMvUmVwbGljYW50L3YyL3RvbmVidXJzdC5Nb25vdG9uZUNvbmZpZ/+NAwEBDk1vbm90b25lQ29uZmlnAf+OAAEDAQxBZGRTZXF1ZW5jZXMB/5AAAQ9SZW1vdmVTZXF1ZW5jZXMB/5IAAQpTcGVha0ZpcnN0AQIAAAAq/48DAQEISW5zdGFuY2UB/5AAAQIBBERlc2MB/5IAAQRBcmdzAf+WAAAAJP+RAwEBC0Rlc2NyaXB0aW9uAf+SAAEBAQVQYXJ0cwH/lAAAACH/kwIBARNbXW1vbm9saXRoLk1vbm9saXRoAf+UAAEQAAAo/5UDAQEEQXJncwH/lgABAgEGVmFsdWVzAf+YAAEFSW5kZXgBBAAAABz/lwIBAQ5bXWludGVyZmFjZSB7fQH/mAABEAAA/gG5/45jAQEBATxnaXRodWIuY29tL09wZXJhdG9yRm91bmRhdGlvbi9tb25vbGl0aC1nby9tb25vbGl0aC5CeXRlc1BhcnT/mQMBAQlCeXRlc1BhcnQB/5oAAQEBBUl0ZW1zAf+cAAAAIf+bAgEBE1tdbW9ub2xpdGguQnl0ZVR5cGUB/5wAARAAAHn/mmcBAUBnaXRodWIuY29tL09wZXJhdG9yRm91bmRhdGlvbi9tb25vbGl0aC1nby9tb25vbGl0aC5GaXhlZEJ5dGVUeXBl/50DAQENRml4ZWRCeXRlVHlwZQH/ngABAQEEQnl0ZQEGAAAAB/+eAwETAAAAAQAAAgEAAW1naXRodWIuY29tL09wZXJhdG9yRm91bmRhdGlvbi9zaGFwZXNoaWZ0ZXItdHJhbnNwb3J0cy90cmFuc3BvcnRzL1JlcGxpY2FudC92Mi9wb2xpc2guU2lsdmVyUG9saXNoQ2xpZW50Q29uZmln/4cDAQEYU2lsdmVyUG9saXNoQ2xpZW50Q29uZmlnAf+IAAECAQ9TZXJ2ZXJQdWJsaWNLZXkBCgABCUNodW5rU2l6ZQEEAAAATP+ISAFBBC3oKHT4d7oj7ThJZU+3s3z3YyeGjvG+GsNVHTgjg//DJHLY/Zl40Lvt6exyXCD7XsHvY2b+lPcdSSOPm0C+jmcB/gnsAAA="} \ No newline at end of file diff --git a/transports/Replicant/v3/ReplicantClientConfig1.json b/transports/Replicant/v3/ReplicantClientConfig1.json new file mode 100644 index 0000000..7de0974 --- /dev/null +++ b/transports/Replicant/v3/ReplicantClientConfig1.json @@ -0,0 +1 @@ +{"config":"M/+BAwEBDENsaWVudENvbmZpZwH/ggABAgEJVG9uZWJ1cnN0ARAAAQ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ZXJQb2xpc2hDbGllbnRDb25maWcB/4gAAQIBD1NlcnZlclB1YmxpY0tleQEKAAEJQ2h1bmtTaXplAQQAAABM/4hIAUEECCQBd9PsRLwbvi5fg7JEdC4892DtiM81ZPHereBmCZZV8mUPeV6Xe0oglvhSmF4Xf8tueZY/s0BneVfN52VmjQH+CvoAAA=="} \ No newline at end of file diff --git a/transports/Replicant/v3/ReplicantServerConfig.json b/transports/Replicant/v3/ReplicantServerConfig.json new file mode 100644 index 0000000..db61447 --- /dev/null +++ b/transports/Replicant/v3/ReplicantServerConfig.json @@ -0,0 +1 @@ +{"Replicant":{"config":"M/+JAwEBDFNlcnZlckNvbmZpZwH/igABAgEJVG9uZWJ1cnN0ARAAAQZQb2xpc2gBEAAAAP+8/4oBZmdpdGh1Yi5jb20vT3BlcmF0b3JGb3VuZGF0aW9uL3NoYXBlc2hpZnRlci10cmFuc3BvcnRzL3RyYW5zcG9ydHMvUmVwbGljYW50L3YyL3RvbmVidXJzdC5Nb25vdG9uZUNvbmZpZ/+NAwEBDk1vbm90b25lQ29uZmlnAf+OAAEDAQxBZGRTZXF1ZW5jZXMB/5AAAQ9SZW1vdmVTZXF1ZW5jZXMB/5IAAQpTcGVha0ZpcnN0AQIAAAAq/48DAQEISW5zdGFuY2UB/5AAAQIBBERlc2MB/5IAAQRBcmdzAf+WAAAAJP+RAwEBC0Rlc2NyaXB0aW9uAf+SAAEBAQVQYXJ0cwH/lAAAACH/kwIBARNbXW1vbm9saXRoLk1vbm9saXRoAf+UAAEQAAAo/5UDAQEEQXJncwH/lgABAgEGVmFsdWVzAf+YAAEFSW5kZXgBBAAAABz/lwIBAQ5bXWludGVyZmFjZSB7fQH/mAABEAAA/gHI/45iAgEBPGdpdGh1Yi5jb20vT3BlcmF0b3JGb3VuZGF0aW9uL21vbm9saXRoLWdvL21vbm9saXRoLkJ5dGVzUGFydP+ZAwEBCUJ5dGVzUGFydAH/mgABAQEFSXRlbXMB/5wAAAAh/5sCAQETW11tb25vbGl0aC5CeXRlVHlwZQH/nAABEAAAdP+aZwEBQGdpdGh1Yi5jb20vT3BlcmF0b3JGb3VuZGF0aW9uL21vbm9saXRoLWdvL21vbm9saXRoLkZpeGVkQnl0ZVR5cGX/nQMBAQ1GaXhlZEJ5dGVUeXBlAf+eAAEBAQRCeXRlAQYAAAAH/54DARMAAAAAAW1naXRodWIuY29tL09wZXJhdG9yRm91bmRhdGlvbi9zaGFwZXNoaWZ0ZXItdHJhbnNwb3J0cy90cmFuc3BvcnRzL1JlcGxpY2FudC92Mi9wb2xpc2guU2lsdmVyUG9saXNoU2VydmVyQ29uZmln/4sDAQEYU2lsdmVyUG9saXNoU2VydmVyQ29uZmlnAf+MAAEDAQ9TZXJ2ZXJQdWJsaWNLZXkBCgABEFNlcnZlclByaXZhdGVLZXkBCgABCUNodW5rU2l6ZQEEAAAAbv+MagFBBC3oKHT4d7oj7ThJZU+3s3z3YyeGjvG+GsNVHTgjg//DJHLY/Zl40Lvt6exyXCD7XsHvY2b+lPcdSSOPm0C+jmcBIDdmDHb9vsAB18Y2v4sBUbJlmgSNOndJ/x1oBSMjMq5aAf4J7AAA"}} \ No newline at end of file diff --git a/transports/Replicant/v3/ReplicantServerConfig1.json b/transports/Replicant/v3/ReplicantServerConfig1.json new file mode 100644 index 0000000..7b00a7b --- /dev/null +++ b/transports/Replicant/v3/ReplicantServerConfig1.json @@ -0,0 +1 @@ +{"Replicant":{"config":"M/+JAwEBDFNlcnZlckNvbmZpZwH/igABAgEJVG9uZWJ1cnN0ARAAAQZQb2xpc2gBEAAAAP+8/4oBZmdpdGh1Yi5jb20vT3BlcmF0b3JGb3VuZGF0aW9uL3NoYXBlc2hpZnRlci10cmFuc3BvcnRzL3RyYW5zcG9ydHMvUmVwbGljYW50L3YyL3RvbmVidXJzdC5Nb25vdG9uZUNvbmZpZ/+NAwEBDk1vbm90b25lQ29uZmlnAf+OAAEDAQxBZGRTZXF1ZW5jZXMB/5AAAQ9SZW1vdmVTZXF1ZW5jZXMB/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+gAA"}} \ No newline at end of file diff --git a/transports/Replicant/v3/config.go b/transports/Replicant/v3/config.go new file mode 100644 index 0000000..7d31149 --- /dev/null +++ b/transports/Replicant/v3/config.go @@ -0,0 +1,64 @@ +package replicant + +import ( + "encoding/json" + "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v2/polish" + "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v2/toneburst" +) + +type ClientConfig struct { + Toneburst toneburst.Config + Polish polish.ClientConfig +} + +type ServerConfig struct { + Toneburst toneburst.Config + Polish polish.ServerConfig +} + +func (config ServerConfig) Marshal() (string, error) { + + type ServerJSONInnerConfig struct { + Config string `json:"config"` + } + + type ServerJSONOuterConfig struct { + Replicant ServerJSONInnerConfig + } + + configString, configStringError := config.Encode() + if configStringError != nil { + return "", configStringError + } + + innerConfig := ServerJSONInnerConfig{Config:configString} + outerConfig := ServerJSONOuterConfig{Replicant:innerConfig} + + configBytes, marshalError := json.Marshal(outerConfig) + if marshalError != nil { + return "", marshalError + } + + return string(configBytes), nil +} + +func (config ClientConfig) Marshal() (string, error) { + + type ClientJSONConfig struct { + Config string `json:"config"` + } + + configString, configStringError := config.Encode() + if configStringError != nil { + return "", configStringError + } + + clientConfig := ClientJSONConfig{Config:configString} + + configBytes, marshalError := json.Marshal(clientConfig) + if marshalError != nil { + return "", marshalError + } + + return string(configBytes), nil +} \ No newline at end of file diff --git a/transports/Replicant/v3/go.mod b/transports/Replicant/v3/go.mod new file mode 100644 index 0000000..f317884 --- /dev/null +++ b/transports/Replicant/v3/go.mod @@ -0,0 +1,11 @@ +module github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v2 + +go 1.12 + +require ( + github.com/OperatorFoundation/monolith-go/monolith v1.0.4 + github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0 + github.com/opentracing/opentracing-go v1.1.0 + golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 + golang.org/x/net v0.0.0-20200202094626-16171245cfb2 +) diff --git a/transports/Replicant/v3/go.sum b/transports/Replicant/v3/go.sum new file mode 100644 index 0000000..c0b8e63 --- /dev/null +++ b/transports/Replicant/v3/go.sum @@ -0,0 +1,25 @@ +github.com/OperatorFoundation/monolith-go/monolith v0.0.0-20200211182645-3f416e29e205 h1:ENL3uQkGxIPJbLi6eXse+bFuAGJB7vzK6e+bdZOMm9c= +github.com/OperatorFoundation/monolith-go/monolith v0.0.0-20200211182645-3f416e29e205/go.mod h1:qc60ZvCt83JnWf2ZtLq8nkVH6s1gStEwywhox+2y0FY= +github.com/OperatorFoundation/monolith-go/monolith v1.0.1 h1:krnieqiUjzCGE/Mb4zy6lwr+RkR7WRK2jFP5EpL3Yvg= +github.com/OperatorFoundation/monolith-go/monolith v1.0.1/go.mod h1:qc60ZvCt83JnWf2ZtLq8nkVH6s1gStEwywhox+2y0FY= +github.com/OperatorFoundation/monolith-go/monolith v1.0.3 h1:KVh1TcURzc+aFb98klXSap2gtvDhXlWyJJ0MRvt8khA= +github.com/OperatorFoundation/monolith-go/monolith v1.0.3/go.mod h1:qc60ZvCt83JnWf2ZtLq8nkVH6s1gStEwywhox+2y0FY= +github.com/OperatorFoundation/monolith-go/monolith v1.0.4 h1:9BmDs+f0VvDz94X8GW8G6L3UG6H7ziIFEw9H0AajnHI= +github.com/OperatorFoundation/monolith-go/monolith v1.0.4/go.mod h1:qc60ZvCt83JnWf2ZtLq8nkVH6s1gStEwywhox+2y0FY= +github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0 h1:zDYt6FDJwDSX4woVFVK2EMt7fkxU5L5qDNLUjQwA+BQ= +github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0/go.mod h1:kB00Ak8Dgn1uZlZHLc/WsUta58Jc+n/ZhCetcPkh42Q= +github.com/OperatorFoundation/shapeshifter-transports v2.1.5+incompatible h1:1S3doS1jE/2X0FTiJWakrZVAmknj2IqZ1XL46zBA0XM= +github.com/OperatorFoundation/shapeshifter-transports/transports v0.0.0-20200218224946-cac72fbc8eb3 h1:D0oWnlYienV6VqTbeGPL4YYJoqCeK6kvBOS2wMv5Brk= +github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da h1:KjTM2ks9d14ZYCvmHS9iAKVt9AyzRSqNU1qabPih5BY= +github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da/go.mod h1:eHEWzANqSiWQsof+nXEI9bUVUyV6F53Fp89EuCh2EAA= +github.com/deckarep/golang-set v1.7.1 h1:SCQV0S6gTtp6itiFrTqI+pfmJ4LN85S1YzhDf9rTHJQ= +github.com/deckarep/golang-set v1.7.1/go.mod h1:93vsz/8Wt4joVM7c2AVqh+YRMiUSc14yDtF28KmMOgQ= +github.com/opentracing/opentracing-go v1.1.0 h1:pWlfV3Bxv7k65HYwkikxat0+s3pV4bsqf19k25Ur8rU= +github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/net v0.0.0-20200202094626-16171245cfb2 h1:CCH4IOTTfewWjGOlSp+zGcjutRKlBEZQ6wTn8ozI/nI= +golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/transports/Replicant/v3/persistence.go b/transports/Replicant/v3/persistence.go new file mode 100644 index 0000000..d294de9 --- /dev/null +++ b/transports/Replicant/v3/persistence.go @@ -0,0 +1,94 @@ +package replicant + +import ( + "bytes" + "encoding/base64" + "encoding/gob" + "github.com/OperatorFoundation/monolith-go/monolith" + "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v2/polish" + "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v2/toneburst" +) + +func InitializeGobRegistry() { + monolith.InitializeGobRegistry() + + gob.Register(toneburst.MonotoneConfig{}) + gob.Register(toneburst.WhalesongConfig{}) + gob.Register(polish.SilverPolishClientConfig{}) + gob.Register(polish.SilverPolishServerConfig{}) +} + +func (config ClientConfig) Encode() (string, error) { + InitializeGobRegistry() + + var buffer bytes.Buffer + encoder := gob.NewEncoder(&buffer) + + marshalError := encoder.Encode(config) + if marshalError != nil { + return "", marshalError + } + + encoded := base64.StdEncoding.EncodeToString(buffer.Bytes()) + return encoded, nil +} + +func DecodeClientConfig(encoded string) (*ClientConfig, error) { + InitializeGobRegistry() + + decoded, base64Error := base64.StdEncoding.DecodeString(encoded) + if base64Error != nil { + return nil, base64Error + } + + var buffer bytes.Buffer + buffer.Write(decoded) + + decoder := gob.NewDecoder(&buffer) + + var config ClientConfig + unmarshalError := decoder.Decode(&config) + if unmarshalError != nil { + return nil, unmarshalError + } + + return &config, nil +} + +func (config ServerConfig) Encode() (string, error) { + InitializeGobRegistry() + + var buffer bytes.Buffer + encoder := gob.NewEncoder(&buffer) + + marshalError := encoder.Encode(config) + if marshalError != nil { + return "", marshalError + } + + encoded := base64.StdEncoding.EncodeToString(buffer.Bytes()) + return encoded, nil +} + +func DecodeServerConfig(encoded string) (*ServerConfig, error) { + InitializeGobRegistry() + + decoded, base64Error := base64.StdEncoding.DecodeString(encoded) + if base64Error != nil { + return nil, base64Error + } + + var buffer bytes.Buffer + buffer.Write(decoded) + + decoder := gob.NewDecoder(&buffer) + + var config ServerConfig + unmarshalError := decoder.Decode(&config) + if unmarshalError != nil { + return nil, unmarshalError + } + + return &config, nil +} + diff --git a/transports/Replicant/v3/persistence_test.go b/transports/Replicant/v3/persistence_test.go new file mode 100644 index 0000000..3d3cec9 --- /dev/null +++ b/transports/Replicant/v3/persistence_test.go @@ -0,0 +1,197 @@ +package replicant + +import ( + "encoding/json" + "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v2/polish" + "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v2/toneburst" + "io/ioutil" + "testing" +) + +func TestEncodeClientConfig(t *testing.T) { + toneburstConfig := toneburst.WhalesongConfig{ + AddSequences: []toneburst.Sequence{}, + RemoveSequences: []toneburst.Sequence{}, + } + + polishServerConfig, polishServerError := polish.NewSilverServerConfig() + if polishServerError != nil { + t.Fail() + return + } + polishClientConfig, polishClientError := polish.NewSilverClientConfig(polishServerConfig) + if polishClientError != nil { + t.Fail() + return + } + + config := ClientConfig{ + Toneburst: toneburstConfig, + Polish: polishClientConfig, + } + + _, marshalError := config.Encode() + if marshalError != nil { + t.Fail() + return + } +} + +func TestDecodeClientConfig(t *testing.T) { + toneburstConfig := toneburst.WhalesongConfig{ + AddSequences: []toneburst.Sequence{}, + RemoveSequences: []toneburst.Sequence{}, + } + + polishServerConfig, polishServerError := polish.NewSilverServerConfig() + if polishServerError != nil { + t.Fail() + return + } + polishClientConfig, polishClientError := polish.NewSilverClientConfig(polishServerConfig) + if polishClientError != nil { + t.Fail() + return + } + + config := ClientConfig{ + Toneburst: toneburstConfig, + Polish: polishClientConfig, + } + + result, marshalError := config.Encode() + if marshalError != nil { + t.Fail() + return + } + + _, unmarshalError := DecodeClientConfig(result) + if unmarshalError != nil { + t.Fail() + return + } +} + +func TestEncodeServerConfig(t *testing.T) { + toneburstConfig := toneburst.WhalesongConfig{ + AddSequences: []toneburst.Sequence{}, + RemoveSequences: []toneburst.Sequence{}, + } + + polishServerConfig, polishServerError := polish.NewSilverServerConfig() + if polishServerError != nil { + t.Fail() + return + } + + config := ServerConfig{ + Toneburst: toneburstConfig, + Polish: polishServerConfig, + } + + _, marshalError := config.Encode() + if marshalError != nil { + t.Fail() + return + } +} + +func TestDecodeServerConfig(t *testing.T) { + toneburstConfig := toneburst.WhalesongConfig{ + AddSequences: []toneburst.Sequence{}, + RemoveSequences: []toneburst.Sequence{}, + } + + polishServerConfig, polishServerError := polish.NewSilverServerConfig() + if polishServerError != nil { + t.Fail() + return + } + + config := ServerConfig{ + Toneburst: toneburstConfig, + Polish: polishServerConfig, + } + + result, marshalError := config.Encode() + if marshalError != nil { + t.Fail() + return + } + + _, unmarshalError := DecodeServerConfig(result) + if unmarshalError != nil { + t.Fail() + return + } +} + +type ReplicantJSONConfig struct { + Config string `json:"config"` +} + + +func TestSaveServerConfigPolish(t *testing.T) { + + polishServerConfig, polishServerError := polish.NewSilverServerConfig() + if polishServerError != nil { + t.Fail() + return + } + + config := ServerConfig{ + Toneburst: nil, + Polish: polishServerConfig, + } + + serverConfigString, marshalError := config.Encode() + if marshalError != nil { + t.Fail() + return + } + + // Create a struct + rServerJSON := ReplicantJSONConfig{Config: serverConfigString} + + // Save it to a json file + jsonString, jsonError := json.Marshal(rServerJSON) + if jsonError != nil { + t.Fail() + return + } + + _ = ioutil.WriteFile("/Users/mafalda/Documents/Operator/replicant_server.json", jsonString, 0644) +} + +func TestSaveClientConfigPolish(t *testing.T) { + polishServerConfig, polishServerError := polish.NewSilverServerConfig() + if polishServerError != nil { + t.Fail() + return + } + polishClientConfig, polishClientError := polish.NewSilverClientConfig(polishServerConfig) + if polishClientError != nil { + t.Fail() + return + } + + config := ClientConfig{ + Toneburst: nil, + Polish: polishClientConfig, + } + + clientConfigString, marshalError := config.Encode() + if marshalError != nil { + t.Fail() + return + } + + rClientJSON := ReplicantJSONConfig{clientConfigString} + jsonString, jsonError := json.Marshal(rClientJSON) + if jsonError != nil { + t.Fail() + return + } + + _ = ioutil.WriteFile("/Users/mafalda/Documents/Operator/replicant_client.json", jsonString, 0644) +} \ No newline at end of file diff --git a/transports/Replicant/v3/polish/config.go b/transports/Replicant/v3/polish/config.go new file mode 100644 index 0000000..15f3f25 --- /dev/null +++ b/transports/Replicant/v3/polish/config.go @@ -0,0 +1,11 @@ +package polish + +type ServerConfig interface { + Construct() (Server, error) + GetChunkSize() int +} + +type ClientConfig interface { + Construct() (Connection, error) + GetChunkSize() int +} diff --git a/transports/Replicant/v3/polish/polish.go b/transports/Replicant/v3/polish/polish.go new file mode 100644 index 0000000..afdb7ab --- /dev/null +++ b/transports/Replicant/v3/polish/polish.go @@ -0,0 +1,16 @@ +package polish + +import ( + "net" +) + +type Connection interface { + Handshake(conn net.Conn) error + Polish(input []byte) ([]byte, error) + Unpolish(input []byte) ([]byte, error) + GetChunkSize() int +} + +type Server interface { + NewConnection(net.Conn) Connection +} diff --git a/transports/Replicant/v3/polish/silver.go b/transports/Replicant/v3/polish/silver.go new file mode 100644 index 0000000..194e690 --- /dev/null +++ b/transports/Replicant/v3/polish/silver.go @@ -0,0 +1,374 @@ +package polish + +import ( + "crypto/cipher" + "crypto/elliptic" + "crypto/rand" + "crypto/sha256" + "encoding/binary" + "errors" + "github.com/opentracing/opentracing-go/log" + "golang.org/x/crypto/chacha20poly1305" + "io" + "math/big" + "net" +) + +// Public key size in bytes. +// See "Marshal" in elliptic.go +// Marshal implements section 4.3.6 of ANSI X9.62 +var silverPublicKeySize = 1+2*((elliptic.P256().Params().BitSize + 7) >> 3) + +type SilverPolishClientConfig struct { + ServerPublicKey []byte + ChunkSize int +} + +type SilverPolishServerConfig struct { + ServerPublicKey []byte + ServerPrivateKey []byte + ChunkSize int +} + +func (config SilverPolishServerConfig) Construct() (Server, error) { + return NewSilverServer(config) +} + +func (config SilverPolishServerConfig) GetChunkSize() int { + return config.ChunkSize +} + +func (config SilverPolishClientConfig) Construct() (Connection, error) { + return NewSilverClient(config) +} + +func (config SilverPolishClientConfig) GetChunkSize() int { +return config.ChunkSize +} + +type SilverPolishClient struct { + serverPublicKey []byte + chunkSize int + + clientPublicKey []byte + clientPrivateKey []byte + + sharedKey []byte + polishCipher cipher.AEAD +} + +type SilverPolishServer struct { + serverPublicKey []byte + serverPrivateKey []byte + chunkSize int + + connections map[net.Conn]SilverPolishServerConnection +} + +type SilverPolishServerConnection struct { + serverPublicKey []byte + serverPrivateKey []byte + chunkSize int + + clientPublicKey []byte + + sharedKey []byte + polishCipher cipher.AEAD +} + +type CurvePoint struct { + X *big.Int + Y *big.Int +} + +func NewSilverServerConfig() (*SilverPolishServerConfig, error) { + curve := elliptic.P256() + serverPrivateKey, serverX, serverY, err := elliptic.GenerateKey(curve, rand.Reader) + if err != nil { + return nil, errors.New("error generating server private key") + } + serverPublicKey := elliptic.Marshal(curve, serverX, serverY) + + tempClientPrivateKey, _, _, err := elliptic.GenerateKey(curve, rand.Reader) + if err != nil { + return nil, errors.New("error generating temporary client private key") + } + + tempSharedKeyX, tempSharedKeyY := curve.ScalarMult(serverX, serverY, tempClientPrivateKey) + tempSharedKeySeed := elliptic.Marshal(curve, tempSharedKeyX, tempSharedKeyY) + + // X963 KDF + encryptionKey := X963KDF(tempSharedKeySeed, serverPublicKey) + + tempCipher, err := chacha20poly1305.New(encryptionKey) + if err != nil { + return nil, errors.New("error generating new config") + } + + basePayloadSize := 1024 + payloadSizeRandomness, err := rand.Int(rand.Reader, big.NewInt(512)) + if err != nil { + return nil, errors.New("error generating random number for ChunkSize") + } + + payloadSize := basePayloadSize + int(payloadSizeRandomness.Int64()) + chunkSize := tempCipher.NonceSize() + tempCipher.Overhead() + payloadSize + + config := SilverPolishServerConfig{serverPublicKey, serverPrivateKey, chunkSize} + return &config, nil +} + +func NewSilverClientConfig(serverConfig *SilverPolishServerConfig) (*SilverPolishClientConfig, error) { + config := SilverPolishClientConfig{serverConfig.ServerPublicKey, serverConfig.ChunkSize} + return &config, nil +} + +func NewSilverClient(config SilverPolishClientConfig) (Connection, error) { + // Generate a new random private key + curve := elliptic.P256() + clientPrivateKey, clientX, clientY, err := elliptic.GenerateKey(curve, rand.Reader) + if err != nil { + return nil, errors.New("error generating client private key") + } + + // Marshall uses section 4.3.6 of ANSI X9.62 + clientPublicKey := elliptic.Marshal(curve, clientX, clientY) + + // Derive the shared key from the client private key and server public key + serverX, serverY := elliptic.Unmarshal(curve, config.ServerPublicKey) + + sharedKeyX, sharedKeyY := curve.ScalarMult(serverX, serverY, clientPrivateKey) + sharedKeySeed := elliptic.Marshal(curve, sharedKeyX, sharedKeyY) + + encryptionKey := X963KDF(sharedKeySeed, clientPublicKey) + + polishCipher, err := chacha20poly1305.New(encryptionKey[:]) + if err != nil { + return nil, errors.New("error initializing polish client") + } + polishClient := SilverPolishClient{config.ServerPublicKey, config.ChunkSize, clientPublicKey, clientPrivateKey, encryptionKey, polishCipher} + return &polishClient, nil +} + +func X963KDF(sharedKeySeed []byte, ephemeralPublicKey []byte) []byte { + length := 32 + output := make([]byte, 0) + outlen := 0 + counter := uint32(1) + + for outlen < length { + h := sha256.New() + h.Write(sharedKeySeed) // Key Material: ECDH Key + + counterBuf := make([]byte, 4) + binary.BigEndian.PutUint32(counterBuf, counter) + h.Write(counterBuf) + + h.Write(ephemeralPublicKey) // Shared Info: Our public key + + output = h.Sum(output) + outlen += h.Size() + counter += 1 + } + + return output +} + +func NewSilverServer(config SilverPolishServerConfig) (SilverPolishServer, error) { + polishServer := SilverPolishServer{config.ServerPublicKey, config.ServerPrivateKey, config.ChunkSize, make(map[net.Conn]SilverPolishServerConnection)} + return polishServer, nil +} + +func (config SilverPolishServer) NewConnection(conn net.Conn) Connection { + polishServerConnection := SilverPolishServerConnection{config.serverPublicKey, config.serverPrivateKey, config.chunkSize, nil, nil, nil} + config.connections[conn] = polishServerConnection + + return &polishServerConnection +} + +func (silver SilverPolishClient) Handshake(conn net.Conn) error { + clientPublicKey := silver.clientPublicKey + publicKeyBlock := make([]byte, silver.chunkSize) + _, readError := rand.Read(publicKeyBlock) + if readError != nil { + return readError + } + copy(publicKeyBlock, clientPublicKey[:]) + _, writeError := conn.Write(publicKeyBlock) + if writeError != nil { + return writeError + } + + return nil +} +func Polish(polishCipher cipher.AEAD, chunkSize int, input []byte) ([]byte, error) { + output := make([]byte, 0) + + inputSize := len(input) + nonceSize := polishCipher.NonceSize() + overheadSize := polishCipher.Overhead() + payloadSize := chunkSize - (nonceSize + overheadSize) + maximumInputSize := payloadSize - 2 + payload := make([]byte, payloadSize) + + // Generate random nonce + nonce := make([]byte, nonceSize) + _, readError := rand.Read(nonce) + if readError != nil { + return nil, readError + } + + // Payload size - 2 because the first two bytes indicate the length of the input data + // These 2 bytes are not part of the data itself they describe its length + // Payload = length(2 bytes) + input data + padding + if inputSize <= maximumInputSize { + + inputLengthUInt16 := uint16(inputSize) + // Convert it to two bytes and add it to the beginning of our payload + binary.LittleEndian.PutUint16(payload, inputLengthUInt16) + + //Put input into out payload slice starting at the 3rd byte + copy(payload[2:], input) + + // Encrypt the payload + sealResult := polishCipher.Seal(output, nonce, payload, nil) + result := append(nonce, sealResult...) + + return result, nil + } else { + //Input is larger than chunk size + result := make([]byte, 0) + + for len(input) > 0 { + + // Make sure that we don't try to make a slice that is bigger than input + chunk := make([]byte, 0) + if len(input) < maximumInputSize { + chunk = input[:] + input = make([]byte, 0) + } else { + chunk = input[:maximumInputSize] + input = input[maximumInputSize:] + } + + // polish this chunk of input + polished, polishError := Polish(polishCipher, chunkSize, chunk) + if polishError != nil { + return nil, polishError + } + + result = append(result, polished...) + } + + return result, nil + } +} + +func Unpolish(polishCipher cipher.AEAD, chunkSize int, input []byte) ([]byte, error) { + inputSize := len(input) + nonceSize := polishCipher.NonceSize() + + output := make([]byte, 0) + nonce := input[:nonceSize] + data := input[nonceSize:] + + if inputSize < chunkSize { + return nil, errors.New("silver client - unable to unpolish data, received fewer bytes than chunk size") + } else if inputSize == chunkSize { + unpolished, openError := polishCipher.Open(output, nonce, data, nil) + if openError != nil { + return nil, openError + } + + dataSize := int(binary.LittleEndian.Uint16(unpolished)) + data = unpolished[2:dataSize + 2] + return data, nil + } else { + //More than one chunk + result := make([]byte, 0) + for len(input) > 0 { + + if len(input) < chunkSize { + return nil, errors.New("received input to unpolish that is less than chunk size") + } + + chunk := input[:chunkSize] + input = input[chunkSize:] + + unpolished, unpolishError := Unpolish(polishCipher, chunkSize, chunk) + if unpolishError != nil { + return nil, unpolishError + } + + result = append(result, unpolished...) + } + + return result, nil + } +} + +func (silver SilverPolishClient) Polish(input []byte) ([]byte, error) { + return Polish(silver.polishCipher, silver.chunkSize, input) +} + +func (silver SilverPolishClient) Unpolish(input []byte) ([]byte, error) { + return Unpolish(silver.polishCipher, silver.chunkSize, input) +} + +func (silver SilverPolishClient) GetChunkSize() int { + return silver.chunkSize +} + +func (silver *SilverPolishServerConnection) Handshake(conn net.Conn) error { + curve := elliptic.P256() + + clientPublicKeyBlock := make([]byte, silver.chunkSize) + _, err := io.ReadFull(conn, clientPublicKeyBlock) + if err != nil { + log.Error(errors.New("handshake error initializing polish shared key")) + log.Error(err) + return err + } + + clientPublicKey := make([]byte, silverPublicKeySize) + copy(clientPublicKey[:], clientPublicKeyBlock[:silverPublicKeySize]) + + // Marshall uses section 4.3.6 of ANSI X9.62 + clientX, clientY := elliptic.Unmarshal(curve, clientPublicKey[:]) + if clientX == nil || clientY == nil { + unmarshallError := errors.New("silver server unmarshal error: received a nil response while decoding the client public key") + log.Error(unmarshallError) + return unmarshallError + } + + sharedKeyX, sharedKeyY := curve.ScalarMult(clientX, clientY, silver.serverPrivateKey) + sharedKeySeed := elliptic.Marshal(curve, sharedKeyX, sharedKeyY) + + sharedKey := X963KDF(sharedKeySeed, clientPublicKey) + + silver.polishCipher, err = chacha20poly1305.New(sharedKey) + if err != nil { + log.Error(err) + return err + } + + return nil +} + +func (silver *SilverPolishServerConnection) Polish(input []byte) ([]byte, error) { + return Polish(silver.polishCipher, silver.chunkSize, input) +} + +func (silver *SilverPolishServerConnection) Unpolish(input []byte) ([]byte, error) { + if silver.polishCipher != nil { + return Unpolish(silver.polishCipher, silver.chunkSize, input) + } else { + nilCipherError := errors.New("unable to unpolish input, silver.polishCipher is nil") + log.Error(nilCipherError) + return nil, nilCipherError + } +} + +func (silver *SilverPolishServerConnection) GetChunkSize() int { + return silver.chunkSize +} diff --git a/transports/Replicant/v3/polish/silver_test.go b/transports/Replicant/v3/polish/silver_test.go new file mode 100644 index 0000000..25ab144 --- /dev/null +++ b/transports/Replicant/v3/polish/silver_test.go @@ -0,0 +1,25 @@ +package polish + +import "testing" + +func TestNewSilverServerConfig(t *testing.T) { + _, configError := NewSilverServerConfig() + if configError != nil { + t.Fail() + return + } +} + +func TestNewSilverClientConfig(t *testing.T) { + serverConfig, serverConfigError := NewSilverServerConfig() + if serverConfigError != nil { + t.Fail() + return + } + + _, clientConfigError := NewSilverClientConfig(serverConfig) + if clientConfigError != nil { + t.Fail() + return + } +} \ No newline at end of file diff --git a/transports/Replicant/v3/pt21.go b/transports/Replicant/v3/pt21.go new file mode 100644 index 0000000..f17d7bf --- /dev/null +++ b/transports/Replicant/v3/pt21.go @@ -0,0 +1,165 @@ +package replicant + +import ( + pt "github.com/OperatorFoundation/shapeshifter-ipc" + "net" + "time" +) + +// Create outgoing transport connection +func (config ClientConfig) Dial(address string) net.Conn { + conn, dialErr := net.Dial("tcp", address) + if dialErr != nil { + return nil + } + + transportConn, err := NewClientConnection(conn, config) + if err != nil { + if conn != nil { + _ = conn.Close() + } + return nil + } + + return transportConn +} + +// Create listener for incoming transport connection +func (config ServerConfig) Listen(address string) net.Listener { + addr, resolveErr := pt.ResolveAddr(address) + if resolveErr != nil { + return nil + } + + ln, err := net.ListenTCP("tcp", addr) + if err != nil { + return nil + } + + return newReplicantTransportListener(ln, config) +} + +func (listener *replicantTransportListener) Addr() net.Addr { + interfaces, _ := net.Interfaces() + addrs, _ := interfaces[0].Addrs() + return addrs[0] +} + +// Accept waits for and returns the next connection to the listener. +func (listener *replicantTransportListener) Accept() (net.Conn, error) { + conn, err := listener.listener.Accept() + if err != nil { + return nil, err + } + + config := listener.config + + return NewServerConnection(conn, config) +} + +// Close closes the transport listener. +// Any blocked Accept operations will be unblocked and return errors. +func (listener *replicantTransportListener) Close() error { + return listener.listener.Close() +} + +func (sconn *Connection) Read(b []byte) (int, error) { + if sconn.state.polish != nil { + polished := make([]byte, sconn.state.polish.GetChunkSize()) + + // Read encrypted data from the connection and put it into our polished slice + _, err := sconn.conn.Read(polished) + if err != nil { + return 0, err + } + + // Decrypt the data + unpolished, unpolishError := sconn.state.polish.Unpolish(polished) + if unpolishError != nil { + return 0, unpolishError + } + + // Empty the buffer and write the decrypted data to it + sconn.receiveBuffer.Reset() + sconn.receiveBuffer.Write(unpolished) + + // Read the decrypted data into the provided slice "b" + _, readError := sconn.receiveBuffer.Read(b) + if readError != nil { + return 0, readError + } + sconn.receiveBuffer.Reset() + + return len(b), nil + } else { + // Read from the connection directly into the provided slice "b" + return sconn.conn.Read(b) + } +} + +func (sconn *Connection) Write(b []byte) (int, error) { + + if sconn.state.polish != nil { + // Polish data + unpolished := b + polished, polishError := sconn.state.polish.Polish(unpolished) + if polishError != nil { + return 0, polishError + } + + numberOfBytesToWrite := len(polished) + totalBytesWritten := 0 + + // Write all of the bytes + for numberOfBytesToWrite > totalBytesWritten { + + //Write the bytes in polish slice + bytesWritten, writeError := sconn.conn.Write(polished) + if writeError != nil { + return bytesWritten, writeError + } + + // Keep track of how many bytes we've written so far + totalBytesWritten = totalBytesWritten + bytesWritten + + //If the bytes written are less than the bytes we need to write + if numberOfBytesToWrite > totalBytesWritten { + + //Slice off what has already been written + polished = polished[:bytesWritten] + } + } + + // Return the count of the pre-polished bytes + return len(b), nil + } else { + return sconn.conn.Write(b) + } +} + +func (sconn *Connection) Close() error { + return sconn.conn.Close() +} + +func (sconn *Connection) LocalAddr() net.Addr { + return sconn.conn.LocalAddr() +} + +func (sconn *Connection) RemoteAddr() net.Addr { + return sconn.conn.RemoteAddr() +} + +func (sconn *Connection) SetDeadline(t time.Time) error { + return sconn.conn.SetDeadline(t) +} + +func (sconn *Connection) SetReadDeadline(t time.Time) error { + return sconn.conn.SetReadDeadline(t) +} + +func (sconn *Connection) SetWriteDeadline(t time.Time) error { + return sconn.conn.SetWriteDeadline(t) +} + +var _ net.Listener = (*replicantTransportListener)(nil) +var _ net.Conn = (*Connection)(nil) diff --git a/transports/Replicant/v3/replicant.go b/transports/Replicant/v3/replicant.go new file mode 100644 index 0000000..c32f691 --- /dev/null +++ b/transports/Replicant/v3/replicant.go @@ -0,0 +1,149 @@ +/* + * Copyright (c) 2019, Operator Foundation + * + */ + +// Package replicant provides a PT 2.1 Go API implementation of the Replicant adversary-tunable transport +package replicant + +import ( + "bytes" + "fmt" + "net" + + "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v2/polish" + "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v2/toneburst" +) + +type ConnectionState struct { + toneburst toneburst.ToneBurst + polish polish.Connection +} + +type Connection struct { + state *ConnectionState + conn net.Conn + receiveBuffer *bytes.Buffer +} + +type Server struct { + toneburst toneburst.ToneBurst + polish polish.Server +} + +type replicantTransportListener struct { + listener *net.TCPListener + config ServerConfig +} + +func newReplicantTransportListener(listener *net.TCPListener, config ServerConfig) *replicantTransportListener { + return &replicantTransportListener{listener: listener, config: config} +} + +func NewClientConnection(conn net.Conn, config ClientConfig) (*Connection, error) { + // Initialize a client connection. + var buffer bytes.Buffer + + state, clientError := NewReplicantClientConnectionState(config) + if clientError != nil { + return nil, clientError + } + rconn := &Connection{state, conn, &buffer} + + if state.toneburst != nil { + err := state.toneburst.Perform(conn) + if err != nil { + return nil, err + } + + } + if state.polish != nil { + err := state.polish.Handshake(conn) + if err != nil { + return nil, err + } + } + + return rconn, nil +} + +func NewServerConnection(conn net.Conn, config ServerConfig) (*Connection, error) { + // Initialize a client connection. + var buffer bytes.Buffer + var polishServer polish.Server + var serverError error + + if config.Polish != nil { + polishServer, serverError = config.Polish.Construct() + if serverError != nil { + return nil, serverError + } + } + + state, connError := NewReplicantServerConnectionState(config, polishServer, conn) + if connError != nil { + return nil, connError + } + rconn := &Connection{state, conn, &buffer} + + if state.toneburst != nil { + err := state.toneburst.Perform(conn) + if err != nil { + fmt.Println("> Toneburst error: ", err.Error()) + return nil, err + } + } + + if state.polish != nil { + err := state.polish.Handshake(conn) + if err != nil { + fmt.Println("> Polish handshake failed", err.Error()) + return nil, err + } + } + + return rconn, nil +} + +func NewReplicantClientConnectionState(config ClientConfig) (*ConnectionState, error) { + var tb toneburst.ToneBurst + var toneburstError error + var p polish.Connection + var polishError error + + if config.Toneburst != nil { + tb, toneburstError = config.Toneburst.Construct() + if toneburstError != nil { + return nil, toneburstError + } + } + + if config.Polish != nil { + p, polishError = config.Polish.Construct() + if polishError != nil { + return nil, polishError + } + } + + + return &ConnectionState{tb, p}, nil +} + +func NewReplicantServerConnectionState(config ServerConfig, polishServer polish.Server, conn net.Conn) (*ConnectionState, error) { + var tb toneburst.ToneBurst + var toneburstError error + var p polish.Connection + + if config.Toneburst != nil { + tb, toneburstError = config.Toneburst.Construct() + if toneburstError != nil { + return nil, toneburstError + } + } + + if polishServer != nil { + p = polishServer.NewConnection(conn) + } + + return &ConnectionState{tb, p}, nil +} diff --git a/transports/Replicant/v3/replicant_test.go b/transports/Replicant/v3/replicant_test.go new file mode 100644 index 0000000..a93fc95 --- /dev/null +++ b/transports/Replicant/v3/replicant_test.go @@ -0,0 +1,969 @@ +package replicant + +import ( + "bytes" + "github.com/OperatorFoundation/monolith-go/monolith" + "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v2/polish" + "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v2/toneburst" + "io/ioutil" + "math/rand" + "os" + "strconv" + "testing" + "time" +) + +func TestMain(m *testing.M) { + runReplicantServer() + + os.Exit(m.Run()) +} + +func TestMarshalConfigs(t *testing.T) { + clientConfig, serverConfig := createSilverMonotoneConfigsOneFixedAddByte() + + clientConfigJsonString, clientConfigJsonError := clientConfig.Marshal() + if clientConfigJsonError != nil { + t.Fail() + return + } + + serverConfigJsonString, serverConfigJsonError := serverConfig.Marshal() + if serverConfigJsonError != nil { + t.Fail() + return + } + + serverConfigWriteError := ioutil.WriteFile("ReplicantServerConfig.json", []byte(serverConfigJsonString), 0644) + if serverConfigWriteError != nil { + t.Fail() + return + } + clientConfigWriteError := ioutil.WriteFile("ReplicantClientConfig.json", []byte(clientConfigJsonString), 0644) + if clientConfigWriteError != nil { + t.Fail() + return + } +} + +func TestEmptyConfigs(t *testing.T) { + clientConfig := ClientConfig{ + Toneburst: nil, + Polish: nil, + } + + serverConfig := ServerConfig{ + Toneburst: nil, + Polish: nil, + } + + replicantConnection(clientConfig, serverConfig, t) +} + +func TestEmptyMonotone(t *testing.T) { + clientConfig := createMonotoneClientConfigEmpty() + serverConfig := createMonotoneServerConfigEmpty() + replicantConnection(clientConfig, serverConfig, t) +} + +func TestNilsMonotone(t *testing.T) { + clientConfig := createMonotoneClientConfigNils() + serverConfig := createMonotoneServerConfigNils() + replicantConnection(clientConfig, serverConfig, t) +} + +func TestMarshalSilverRandomEnumeratedConfigs(t *testing.T) { + clientConfig, serverConfig := createSilverMonotoneConfigsRandomEnumeratedItems() + + clientConfigJsonString, clientConfigJsonError := clientConfig.Marshal() + if clientConfigJsonError != nil { + t.Fail() + return + } + + serverConfigJsonString, serverConfigJsonError := serverConfig.Marshal() + if serverConfigJsonError != nil { + t.Fail() + return + } + + serverConfigWriteError := ioutil.WriteFile("ReplicantServerConfig1.json", []byte(serverConfigJsonString), 0644) + if serverConfigWriteError != nil { + t.Fail() + return + } + clientConfigWriteError := ioutil.WriteFile("ReplicantClientConfig1.json", []byte(clientConfigJsonString), 0644) + if clientConfigWriteError != nil { + t.Fail() + return + } +} + +func TestOneFixedByteMonotone(t *testing.T) { + clientConfig := createMonotoneClientConfigOneFixedAddByte() + serverConfig := createMonotoneServerConfigOneFixedRemoveByte() + replicantConnection(clientConfig, serverConfig, t) +} + +func TestOneFixedByteSilverMonotone(t *testing.T) { + clientConfig, serverConfig := createSilverMonotoneConfigsOneFixedAddByte() + replicantConnection(*clientConfig, *serverConfig, t) +} + +func TestOneAddOneRemove(t *testing.T) { + clientConfig := createMonotoneClientConfigOneAddOneRemove() + serverConfig := createMonotoneServerConfigOneAddOneRemove() + replicantConnection(clientConfig, serverConfig, t) +} + +func TestMonotoneEnumerated(t *testing.T) { + clientConfig := createMonotoneClientConfigEnumeratedItems() + serverConfig := createMonotoneServerConfigEnumeratedItems() + replicantConnection(clientConfig, serverConfig, t) +} + +func TestMonotoneRandom(t *testing.T) { + clientConfig := createMonotoneClientConfigRandomItems() + serverConfig := createMonotoneServerConfigRandomItems() + replicantConnection(clientConfig, serverConfig, t) +} + +func TestMonotoneRandomEnumerated(t *testing.T) { + clientConfig := createMonotoneClientConfigRandomEnumeratedItems() + serverConfig := createMonotoneServerConfigRandomEnumeratedItems() + replicantConnection(clientConfig, serverConfig, t) +} + +func TestSilver(t *testing.T) { + clientConfig, serverConfig := createSilverConfigs() + replicantConnection(*clientConfig, *serverConfig, t) +} + +func runReplicantServer() { + serverStarted := make(chan bool) + addr := "127.0.0.1:1234" + serverConfig := ServerConfig{ + Toneburst: nil, + Polish: nil, + } + + go func() { + listener := serverConfig.Listen(addr) + serverStarted <- true + + lConn, lConnError := listener.Accept() + if lConnError != nil { + return + } + + lBuffer := make([]byte, 4) + _, lReadError := lConn.Read(lBuffer) + if lReadError != nil { + return + } + + // Send a response back to person contacting us. + _, lWriteError := lConn.Write([]byte("Message received.")) + if lWriteError != nil { + return + } + }() + + serverFinishedStarting := <-serverStarted + if !serverFinishedStarting { + return + } +} + +// This test uses a more realistic config, like one might use in real deployment. +func TestSampleConfig(t *testing.T) { + clientConfig, serverConfig := createSampleConfigs() + replicantConnection(*clientConfig, *serverConfig, t) +} + +func replicantConnection(clientConfig ClientConfig, serverConfig ServerConfig, t *testing.T) { + serverStarted := make(chan bool) + + // Get a random port + rand.Seed(time.Now().UnixNano()) + min := 1025 + max := 65535 + portNumber := min + rand.Intn(max-min+1) + portString := strconv.Itoa(portNumber) + addr := "127.0.0.1:" + addr += portString + + go func() { + listener := serverConfig.Listen(addr) + serverStarted <- true + + lConn, lConnError := listener.Accept() + if lConnError != nil { + t.Fail() + return + } + + lBuffer := make([]byte, 4) + _, lReadError := lConn.Read(lBuffer) + if lReadError != nil { + t.Fail() + return + } + + // Send a response back to person contacting us. + _, lWriteError := lConn.Write([]byte("Message received.")) + if lWriteError != nil { + t.Fail() + return + } + + _ = listener.Close() + }() + + serverFinishedStarting := <-serverStarted + if !serverFinishedStarting { + t.Fail() + return + } + + cConn := clientConfig.Dial(addr) + if cConn == nil { + t.Fail() + return + } + + writeBytes := []byte{0x0A, 0x11, 0xB0, 0xB1} + _, cWriteError := cConn.Write(writeBytes) + if cWriteError != nil { + t.Fail() + return + } + + readBuffer := make([]byte, 17) + _, cReadError := cConn.Read(readBuffer) + if cReadError != nil { + t.Fail() + return + } + + _ = cConn.Close() + + return +} + +func createMonotoneClientConfigNils() ClientConfig { + monotoneConfig := toneburst.MonotoneConfig{ + AddSequences: nil, + RemoveSequences: nil, + SpeakFirst: false, + } + + clientConfig := ClientConfig{ + Toneburst: monotoneConfig, + Polish: nil, + } + + return clientConfig +} + +func createMonotoneServerConfigNils() ServerConfig { + monotoneConfig := toneburst.MonotoneConfig{ + AddSequences: nil, + RemoveSequences: nil, + SpeakFirst: false, + } + + serverConfig := ServerConfig{ + Toneburst: monotoneConfig, + Polish: nil, + } + + return serverConfig +} + +func createMonotoneClientConfigEmpty() ClientConfig { + parts := make([]monolith.Monolith, 0) + desc := monolith.Description{Parts: parts} + args := monolith.NewEmptyArgs() + monolithInstance := monolith.Instance{ + Desc: desc, + Args: args, + } + + addSequences := monolithInstance + removeSequences := desc + + monotoneConfig := toneburst.MonotoneConfig{ + AddSequences: &addSequences, + RemoveSequences: &removeSequences, + SpeakFirst: false, + } + + clientConfig := ClientConfig{ + Toneburst: monotoneConfig, + Polish: nil, + } + + return clientConfig +} + +func createMonotoneServerConfigEmpty() ServerConfig { + parts := make([]monolith.Monolith, 0) + desc := monolith.Description{Parts: parts} + args := monolith.NewEmptyArgs() + monolithInstance := monolith.Instance{ + Desc: desc, + Args: args, + } + + addSequences := monolithInstance + removeSequences := desc + + monotoneConfig := toneburst.MonotoneConfig{ + AddSequences: &addSequences, + RemoveSequences: &removeSequences, + SpeakFirst: false, + } + + serverConfig := ServerConfig{ + Toneburst: monotoneConfig, + Polish: nil, + } + + return serverConfig +} + +func createMonotoneClientConfigOneFixedAddByte() ClientConfig { + parts := make([]monolith.Monolith, 0) + part := monolith.BytesPart{ + Items: []monolith.ByteType{ + monolith.FixedByteType{Byte: 0x13}, + }, + } + parts = append(parts, part) + desc := monolith.Description{Parts: parts} + args := monolith.NewEmptyArgs() + monolithInstance := monolith.Instance{ + Desc: desc, + Args: args, + } + + addSequences := monolithInstance + + monotoneConfig := toneburst.MonotoneConfig{ + AddSequences: &addSequences, + RemoveSequences: nil, + SpeakFirst: true, + } + + clientConfig := ClientConfig{ + Toneburst: monotoneConfig, + Polish: nil, + } + + return clientConfig +} + +func createMonotoneServerConfigOneFixedRemoveByte() ServerConfig { + parts := make([]monolith.Monolith, 0) + part := monolith.BytesPart{ + Items: []monolith.ByteType{ + monolith.FixedByteType{Byte: 0x13}, + }, + } + parts = append(parts, part) + + desc := monolith.Description{Parts: parts} + removeSequences := desc + + monotoneConfig := toneburst.MonotoneConfig{ + AddSequences: nil, + RemoveSequences: &removeSequences, + SpeakFirst: false, + } + + serverConfig := ServerConfig{ + Toneburst: monotoneConfig, + Polish: nil, + } + + return serverConfig +} + +func createMonotoneClientConfigOneAddOneRemove() ClientConfig { + parts := make([]monolith.Monolith, 0) + part := monolith.BytesPart{ + Items: []monolith.ByteType{ + monolith.FixedByteType{Byte: 0x13}, + }, + } + parts = append(parts, part) + desc := monolith.Description{Parts: parts} + args := monolith.NewEmptyArgs() + monolithInstance := monolith.Instance{ + Desc: desc, + Args: args, + } + + addSequences := monolithInstance + + removeParts := make([]monolith.Monolith, 0) + removePart := monolith.BytesPart{ + Items: []monolith.ByteType{ + monolith.FixedByteType{Byte: 0x14}, + }, + } + removeParts = append(removeParts, removePart) + removeDesc := monolith.Description{Parts: removeParts} + + monotoneConfig := toneburst.MonotoneConfig{ + AddSequences: &addSequences, + RemoveSequences: &removeDesc, + SpeakFirst: true, + } + + clientConfig := ClientConfig{ + Toneburst: monotoneConfig, + Polish: nil, + } + + return clientConfig +} + +func createMonotoneServerConfigOneAddOneRemove() ServerConfig { + removeParts := make([]monolith.Monolith, 0) + removePart := monolith.BytesPart{ + Items: []monolith.ByteType{ + monolith.FixedByteType{Byte: 0x13}, + }, + } + removeParts = append(removeParts, removePart) + + desc := monolith.Description{Parts: removeParts} + removeSequences := desc + + addParts := make([]monolith.Monolith, 0) + addPart := monolith.BytesPart{ + Items: []monolith.ByteType{ + monolith.FixedByteType{Byte: 0x14}, + }, + } + addParts = append(addParts, addPart) + addDesc := monolith.Description{Parts: addParts} + args := monolith.NewEmptyArgs() + monolithInstance := monolith.Instance{ + Desc: addDesc, + Args: args, + } + + monotoneConfig := toneburst.MonotoneConfig{ + AddSequences: &monolithInstance, + RemoveSequences: &removeSequences, + SpeakFirst: false, + } + + serverConfig := ServerConfig{ + Toneburst: monotoneConfig, + Polish: nil, + } + + return serverConfig +} + +func createMonotoneClientConfigEnumeratedItems() ClientConfig { + set := []byte{0x11, 0x12, 0x13, 0x14} + parts := make([]monolith.Monolith, 0) + part := monolith.BytesPart{ + Items: []monolith.ByteType{ + monolith.EnumeratedByteType{Options: set}, + monolith.EnumeratedByteType{Options: set}, + }, + } + parts = append(parts, part) + part = monolith.BytesPart{ + Items: []monolith.ByteType{ + monolith.EnumeratedByteType{Options: set}, + monolith.EnumeratedByteType{Options: set}, + }, + } + parts = append(parts, part) + desc := monolith.Description{Parts: parts} + bargs := []byte{0x14, 0x14, 0x14, 0x14} + iargs := make([]interface{}, len(bargs)) + for index, value := range bargs { + iargs[index] = value + } + args := monolith.NewArgs(iargs) + monolithInstance := monolith.Instance{ + Desc: desc, + Args: args, + } + + addSequences := monolithInstance + removeSequences := desc + + monotoneConfig := toneburst.MonotoneConfig{ + AddSequences: &addSequences, + RemoveSequences: &removeSequences, + SpeakFirst: true, + } + + clientConfig := ClientConfig{ + Toneburst: monotoneConfig, + Polish: nil, + } + + return clientConfig +} + +func createMonotoneServerConfigEnumeratedItems() ServerConfig { + rand.Seed(time.Now().UnixNano()) + set := []byte{0x11, 0x12, 0x13, 0x14} + parts := make([]monolith.Monolith, 0) + part := monolith.BytesPart{ + Items: []monolith.ByteType{ + monolith.EnumeratedByteType{Options: set}, + monolith.EnumeratedByteType{Options: set}, + }, + } + parts = append(parts, part) + part = monolith.BytesPart{ + Items: []monolith.ByteType{ + monolith.EnumeratedByteType{Options: set}, + monolith.EnumeratedByteType{Options: set}, + }, + } + parts = append(parts, part) + desc := monolith.Description{Parts: parts} + bargs := []byte{0x11, 0x11, 0x11, 0x12} + iargs := make([]interface{}, len(bargs)) + for index, value := range bargs { + iargs[index] = value + } + args := monolith.NewArgs(iargs) + monolithInstance := monolith.Instance{ + Desc: desc, + Args: args, + } + + addSequences := monolithInstance + removeSequences := desc + + monotoneConfig := toneburst.MonotoneConfig{ + AddSequences: &addSequences, + RemoveSequences: &removeSequences, + SpeakFirst: false, + } + + serverConfig := ServerConfig{ + Toneburst: monotoneConfig, + Polish: nil, + } + + return serverConfig +} + +func createMonotoneClientConfigRandomItems() ClientConfig { + + rand.Seed(time.Now().UnixNano()) + parts := make([]monolith.Monolith, 0) + part := monolith.BytesPart{ + Items: []monolith.ByteType{ + monolith.RandomByteType{}, + monolith.RandomByteType{}, + }, + } + parts = append(parts, part) + part = monolith.BytesPart{ + Items: []monolith.ByteType{ + monolith.RandomByteType{}, + monolith.RandomByteType{}, + }, + } + parts = append(parts, part) + desc := monolith.Description{Parts: parts} + args := monolith.NewEmptyArgs() + monolithInstance := monolith.Instance{ + Desc: desc, + Args: args, + } + + addSequences := monolithInstance + removeSequences := desc + + monotoneConfig := toneburst.MonotoneConfig{ + AddSequences: &addSequences, + RemoveSequences: &removeSequences, + SpeakFirst: true, + } + + clientConfig := ClientConfig{ + Toneburst: monotoneConfig, + Polish: nil, + } + + return clientConfig +} + +func createMonotoneServerConfigRandomItems() ServerConfig { + rand.Seed(time.Now().UnixNano()) + parts := make([]monolith.Monolith, 0) + part := monolith.BytesPart{ + Items: []monolith.ByteType{ + monolith.RandomByteType{}, + monolith.RandomByteType{}, + }, + } + parts = append(parts, part) + part = monolith.BytesPart{ + Items: []monolith.ByteType{ + monolith.RandomByteType{}, + monolith.RandomByteType{}, + }, + } + parts = append(parts, part) + desc := monolith.Description{Parts: parts} + args := monolith.NewEmptyArgs() + monolithInstance := monolith.Instance{ + Desc: desc, + Args: args, + } + + addSequences := monolithInstance + removeSequences := desc + + monotoneConfig := toneburst.MonotoneConfig{ + AddSequences: &addSequences, + RemoveSequences: &removeSequences, + SpeakFirst: false, + } + + serverConfig := ServerConfig{ + Toneburst: monotoneConfig, + Polish: nil, + } + + return serverConfig +} + +func createSilverMonotoneConfigsRandomEnumeratedItems() (ClientConfig, ServerConfig) { + serverConfig := createMonotoneServerConfigRandomEnumeratedItems() + clientConfig := createMonotoneClientConfigRandomEnumeratedItems() + + silverServerConfig, _ := polish.NewSilverServerConfig() + silverClientConfig, _ := polish.NewSilverClientConfig(silverServerConfig) + + serverConfig.Polish = silverServerConfig + clientConfig.Polish = silverClientConfig + + return clientConfig, serverConfig +} + +func createMonotoneClientConfigRandomEnumeratedItems() ClientConfig { + rand.Seed(time.Now().UnixNano()) + set := []byte{0x11, 0x12, 0x13, 0x14} + parts := make([]monolith.Monolith, 0) + part := monolith.BytesPart{ + Items: []monolith.ByteType{ + monolith.RandomEnumeratedByteType{RandomOptions: set}, + monolith.RandomEnumeratedByteType{RandomOptions: set}, + }, + } + parts = append(parts, part) + part = monolith.BytesPart{ + Items: []monolith.ByteType{ + monolith.RandomEnumeratedByteType{RandomOptions: set}, + monolith.RandomEnumeratedByteType{RandomOptions: set}, + }, + } + parts = append(parts, part) + desc := monolith.Description{Parts: parts} + args := monolith.NewEmptyArgs() + monolithInstance := monolith.Instance{ + Desc: desc, + Args: args, + } + + addSequences := monolithInstance + removeSequences := desc + + monotoneConfig := toneburst.MonotoneConfig{ + AddSequences: &addSequences, + RemoveSequences: &removeSequences, + SpeakFirst: true, + } + + clientConfig := ClientConfig{ + Toneburst: monotoneConfig, + Polish: nil, + } + + return clientConfig +} + +func createMonotoneServerConfigRandomEnumeratedItems() ServerConfig { + rand.Seed(time.Now().UnixNano()) + set := []byte{0x11, 0x12, 0x13, 0x14} + parts := make([]monolith.Monolith, 0) + part := monolith.BytesPart{ + Items: []monolith.ByteType{ + monolith.RandomEnumeratedByteType{RandomOptions: set}, + monolith.RandomEnumeratedByteType{RandomOptions: set}, + }, + } + parts = append(parts, part) + part = monolith.BytesPart{ + Items: []monolith.ByteType{ + monolith.RandomEnumeratedByteType{RandomOptions: set}, + monolith.RandomEnumeratedByteType{RandomOptions: set}, + }, + } + parts = append(parts, part) + desc := monolith.Description{Parts: parts} + args := monolith.NewEmptyArgs() + monolithInstance := monolith.Instance{ + Desc: desc, + Args: args, + } + + addSequences := monolithInstance + removeSequences := desc + + monotoneConfig := toneburst.MonotoneConfig{ + AddSequences: &addSequences, + RemoveSequences: &removeSequences, + SpeakFirst: false, + } + + serverConfig := ServerConfig{ + Toneburst: monotoneConfig, + Polish: nil, + } + + return serverConfig +} + +func createSilverConfigs() (*ClientConfig, *ServerConfig) { + polishServerConfig, polishServerError := polish.NewSilverServerConfig() + if polishServerError != nil { + return nil, nil + } + polishClientConfig, polishClientError := polish.NewSilverClientConfig(polishServerConfig) + if polishClientError != nil { + return nil, nil + } + + clientConfig := ClientConfig{ + Toneburst: nil, + Polish: polishClientConfig, + } + + serverConfig := ServerConfig{ + Toneburst: nil, + Polish: polishServerConfig, + } + + return &clientConfig, &serverConfig +} + +func createSilverMonotoneConfigsOneFixedAddByte() (*ClientConfig, *ServerConfig) { + parts := make([]monolith.Monolith, 0) + part := monolith.BytesPart{ + Items: []monolith.ByteType{ + monolith.FixedByteType{Byte: 0x13}, + }, + } + parts = append(parts, part) + desc := monolith.Description{Parts: parts} + args := monolith.NewEmptyArgs() + monolithInstance := monolith.Instance{ + Desc: desc, + Args: args, + } + + monotoneConfig := toneburst.MonotoneConfig{ + AddSequences: &monolithInstance, + RemoveSequences: nil, + SpeakFirst: true, + } + + polishServerConfig, polishServerError := polish.NewSilverServerConfig() + if polishServerError != nil { + return nil, nil + } + + polishClientConfig, polishClientConfigError := polish.NewSilverClientConfig(polishServerConfig) + if polishClientConfigError != nil { + return nil, nil + } + + clientConfig := ClientConfig{ + Toneburst: monotoneConfig, + Polish: polishClientConfig, + } + + serverParts := make([]monolith.Monolith, 0) + serverPart := monolith.BytesPart{ + Items: []monolith.ByteType{ + monolith.FixedByteType{Byte: 0x13}, + }, + } + serverParts = append(serverParts, serverPart) + + serverDesc := monolith.Description{Parts: serverParts} + serverRemoveSequences := serverDesc + + monotoneServerConfig := toneburst.MonotoneConfig{ + AddSequences: nil, + RemoveSequences: &serverRemoveSequences, + SpeakFirst: false, + } + + serverConfig := ServerConfig{ + Toneburst: monotoneServerConfig, + Polish: polishServerConfig, + } + + return &clientConfig, &serverConfig +} + +// Polish Tests +func TestPolishOnlyConnection(t *testing.T) { + clientConfig, serverConfig := createSilverConfigs() + replicantConnection(*clientConfig, *serverConfig, t) +} + +//Both +func TestWithSilverMonotone(t *testing.T) { + clientConfig, serverConfig := createSilverMonotoneConfigsRandomEnumeratedItems() + replicantConnection(clientConfig, serverConfig, t) +} + +func TestSilverClientPolishUnpolish(t *testing.T) { + silverServerConfig, serverConfigError := polish.NewSilverServerConfig() + if serverConfigError != nil { + t.Fail() + return + } + + if silverServerConfig == nil { + t.Fail() + return + } + + silverClientConfig, clientConfigError := polish.NewSilverClientConfig(silverServerConfig) + if clientConfigError != nil { + t.Fail() + return + } + + if silverClientConfig == nil { + t.Fail() + return + } + + silverClient, clientError := polish.NewSilverClient(*silverClientConfig) + if clientError != nil { + t.Fail() + return + } + + if silverClient == nil { + t.Fail() + return + } + + input := []byte{3, 12, 2, 6, 31} + + polished, polishError := silverClient.Polish(input) + if polishError != nil { + t.Fail() + return + } + + if bytes.Equal(input, polished) { + t.Fail() + return + } + + unpolished, unpolishError := silverClient.Unpolish(polished) + if unpolishError != nil { + t.Fail() + return + } + + if !bytes.Equal(unpolished, input) { + t.Fail() + return + } +} + +func createSampleConfigs() (*ClientConfig, *ServerConfig) { + rand.Seed(time.Now().UnixNano()) + + clientParts := []monolith.Monolith{ + monolith.BytesPart{ + Items: []monolith.ByteType{ + monolith.SemanticIntProducerByteType{Name: "m", Value: monolith.RandomByteType{}}, + }, + }, + &monolith.SemanticSeedConsumerDynamicPart{Name: "m", Item: monolith.RandomByteType{}}, + } + + clientDesc := monolith.Description{Parts: clientParts} + + clientInstance := monolith.Instance{ + Desc: clientDesc, + Args: monolith.NewEmptyArgs(), + } + + serverParts := []monolith.Monolith{ + monolith.BytesPart{ + Items: []monolith.ByteType{ + monolith.SemanticIntProducerByteType{Name: "n", Value: monolith.RandomByteType{}}, + }, + }, + &monolith.SemanticSeedConsumerDynamicPart{Name: "n", Item: monolith.RandomByteType{}}, + } + + serverDesc := monolith.Description{Parts: serverParts} + + serverInstance := monolith.Instance{ + Desc: serverDesc, + Args: monolith.NewEmptyArgs(), + } + + monotoneServerConfig := toneburst.MonotoneConfig{ + AddSequences: &serverInstance, + RemoveSequences: &clientDesc, + SpeakFirst: false, + } + + monotoneClientConfig := toneburst.MonotoneConfig{ + AddSequences: &clientInstance, + RemoveSequences: &serverDesc, + SpeakFirst: true, + } + + polishServerConfig, polishServerError := polish.NewSilverServerConfig() + if polishServerError != nil { + return nil, nil + } + + polishClientConfig, polishClientConfigError := polish.NewSilverClientConfig(polishServerConfig) + if polishClientConfigError != nil { + return nil, nil + } + + clientConfig := ClientConfig{ + Toneburst: monotoneClientConfig, + Polish: polishClientConfig, + } + + serverConfig := ServerConfig{ + Toneburst: monotoneServerConfig, + Polish: polishServerConfig, + } + + return &clientConfig, &serverConfig +} diff --git a/transports/Replicant/v3/toneburst/config.go b/transports/Replicant/v3/toneburst/config.go new file mode 100644 index 0000000..7bb520a --- /dev/null +++ b/transports/Replicant/v3/toneburst/config.go @@ -0,0 +1,5 @@ +package toneburst + +type Config interface { + Construct() (ToneBurst, error) +} diff --git a/transports/Replicant/v3/toneburst/monotone.go b/transports/Replicant/v3/toneburst/monotone.go new file mode 100644 index 0000000..1a2ea7f --- /dev/null +++ b/transports/Replicant/v3/toneburst/monotone.go @@ -0,0 +1,145 @@ +package toneburst + +import ( + "errors" + "github.com/OperatorFoundation/monolith-go/monolith" + "net" +) + +type MonotoneConfig struct { + AddSequences *monolith.Instance + RemoveSequences *monolith.Description + SpeakFirst bool +} + +func (config MonotoneConfig) Construct() (ToneBurst, error) { + return NewMonotone(config), nil +} + +type Monotone struct { + config MonotoneConfig + buffer *monolith.Buffer + context *monolith.Context +} + +func NewMonotone(config MonotoneConfig) *Monotone { + buffer := monolith.NewEmptyBuffer() + context := monolith.NewEmptyContext() + + return &Monotone{ + config: config, + buffer: buffer, + context: context, + } +} + +//TODO: Implement Perform +func (monotone *Monotone) Perform(conn net.Conn) error { + + var addMessages []monolith.Message + var removeParts []monolith.Monolith + + if monotone.config.AddSequences != nil { + addMessages = monotone.config.AddSequences.Messages() + } + + if monotone.config.RemoveSequences != nil { + removeParts = monotone.config.RemoveSequences.Parts + } + + if monotone.config.SpeakFirst { + if addMessages == nil || len(addMessages) < 1 { + println("Invalid configuration, cannot speak first when there is nothing to add.") + return errors.New("invalid configuration, cannot speak first when there is nothing to add") + } + + //Get the first sequence in the list of add sequences + firstMessage := addMessages[0] + addMessages = addMessages[1:] + addBytes := firstMessage.Bytes() + + writeError := writeAll(conn, addBytes) + if writeError != nil { + return writeError + } + } + + for { + if (removeParts == nil || len(removeParts) < 1) && (addMessages == nil || len(addMessages) < 1) { + return nil + } + + if removeParts != nil && len(removeParts) > 0 { + removePart := removeParts[0] + removeParts = removeParts[1:] + + validated, readAllError := monotone.readAll(conn, removePart) + if readAllError != nil { + println("Error reading data: ", readAllError.Error()) + return readAllError + } + + if !validated { + return errors.New("failed to validate toneburst data, invalid remove sequence") + } + } + + if addMessages != nil && len(addMessages) > 0 { + //Get the first sequence in the list of add sequences + firstMessage := addMessages[0] + addMessages = addMessages[1:] + addBytes := firstMessage.Bytes() + + writeError := writeAll(conn, addBytes) + if writeError != nil { + return writeError + } + } + } +} + +func (monotone Monotone) readAll(conn net.Conn, part monolith.Monolith) (bool, error) { + receivedData := make([]byte, part.Count()) + _, readError := conn.Read(receivedData) + if readError != nil { + println("Received an error while trying to receive data: ", readError.Error()) + return false, readError + } + + monotone.buffer.Push(receivedData) + validated := part.Validate(monotone.buffer, monotone.context) + + switch validated { + + case monolith.Valid: + return true, nil + case monolith.Invalid: + println("Failed to validate the received data.") + return false, errors.New("failed to validate the received data") + case monolith.Incomplete: + println("Failed to validate the received data, data was incomplete.") + return false, errors.New("failed to validate the received data, data was incomplete") + default: + println("Validate returned an unknown value.") + return false, errors.New("validate returned an unknown value") + } +} + +func writeAll(conn net.Conn, addBytes []byte) error { + writtenCount, writeError := conn.Write(addBytes) + if writeError != nil { + println("Received an error while attempting to write data: ", writeError) + return writeError + } + + for writtenCount < len(addBytes) { + addBytes = addBytes[writtenCount:] + writtenCount, writeError = conn.Write(addBytes) + if writeError != nil { + println("Received an error while attempting to write data: ", writeError) + return writeError + } + } + + return nil +} diff --git a/transports/Replicant/v3/toneburst/monotone_test.go b/transports/Replicant/v3/toneburst/monotone_test.go new file mode 100644 index 0000000..dfce8ec --- /dev/null +++ b/transports/Replicant/v3/toneburst/monotone_test.go @@ -0,0 +1,63 @@ +package toneburst + +//func TestMonotone_Perform(t *testing.T) { +// thing1 := monolith.FixedByteType{Byte: 0xB0} +// thing2 := monolith.FixedByteType{Byte: 0xB1} +// items := []monolith.Monolith{thing1, thing2} +// part := monolith.BytesPart{Items: items} +// parts := []monolith.Monolith{part} +// description := monolith.Description{Parts:parts} +// +// removeSequences := []monolith.Description{description} +// +// addInstance := monolith.Instance{ +// Desc: description, +// Args: make([]interface{}, 0), +// } +// addSequences := []monolith.Instance{addInstance} +// println("Add Sequences count: ", len(addSequences)) +// +// monotoneConfig := MonotoneConfig{ +// AddSequences: addSequences, +// RemoveSequences: removeSequences, +// SpeakFirst: true, +// } +// +// println("Add Sequences count: ", len(monotoneConfig.AddSequences)) +// monotoneInstance := NewMonotone(monotoneConfig) +// go monotoneServer(monotoneInstance) +// +// clientConn, dialError := net.Dial("tcp", "127.0.0.1:2121") +// if dialError != nil { +// println("Dial error: ") +// println(dialError.Error()) +// t.Fail() +// } +// +// performError := monotoneInstance.Perform(clientConn) +// if performError!= nil { +// println("Error on perform: ") +// println(performError.Error()) +// t.Fail() +// } +//} +// +//func monotoneServer(monotoneInstance *Monotone) { +// l, serverErr := net.Listen("tcp", "0.0.0.0:2121") +// if serverErr != nil { +// println(serverErr.Error()) +// return +// } +// +// serverConn, acceptError := l.Accept() +// if acceptError != nil { +// println(acceptError.Error()) +// return +// } +// +// serverPerformError := monotoneInstance.Perform(serverConn) +// if serverPerformError!= nil { +// println("Error on perform: ", serverPerformError) +// return +// } +//} diff --git a/transports/Replicant/v3/toneburst/toneburst.go b/transports/Replicant/v3/toneburst/toneburst.go new file mode 100644 index 0000000..a378bf5 --- /dev/null +++ b/transports/Replicant/v3/toneburst/toneburst.go @@ -0,0 +1,31 @@ +package toneburst + +import ( + "net" +) + +type ToneBurst interface { + Perform(conn net.Conn) error +} + +// func New(config *Config) ToneBurst { +// if config == nil { +// return nil +// } +// switch config.Selector { +// case "whalesong": +// if config.Whalesong == nil { +// return nil +// } else { +// return NewWhalesong(*config.Whalesong) +// } +// case "monolith": +// if config.Monotone == nil { +// return nil +// } else { +// return NewMonotone(*config.Monotone) +// } +// default: +// return nil +// } +// } diff --git a/transports/Replicant/v3/toneburst/whalesong.go b/transports/Replicant/v3/toneburst/whalesong.go new file mode 100644 index 0000000..2cf1dd1 --- /dev/null +++ b/transports/Replicant/v3/toneburst/whalesong.go @@ -0,0 +1,32 @@ +package toneburst + +import ( + "fmt" + "net" +) + +type WhalesongConfig struct { + AddSequences []Sequence + RemoveSequences []Sequence +} + +func (config WhalesongConfig) Construct() (ToneBurst, error) { + return NewWhalesong(config), nil +} + +type Sequence []byte + +type Whalesong struct { + config WhalesongConfig +} + +func NewWhalesong(config WhalesongConfig) *Whalesong { + return &Whalesong{config: config} +} + + +//TODO: Implement Perform +func (whalesong *Whalesong) Perform(conn net.Conn) error { + fmt.Println(conn) + return nil +} diff --git a/transports/meeklite/v3/README.md b/transports/meeklite/v3/README.md new file mode 100644 index 0000000..aa5b19d --- /dev/null +++ b/transports/meeklite/v3/README.md @@ -0,0 +1,20 @@ +# meeklite + +meeklite tunnels your network traffic through HTTPS, and uses domain fronting to conceal where your traffic is coming from. + +## Using meeklite + +1. Parse the Url from a string to a Url: +`unparsedUrl := "https://TheUrl.Here/" + Url, _ := url.Parse(unparsedUrl)` + +2. Create an instance of a meeklite server: +`meekliteTransport := meeklite.Transport{Url, "Front.Here", "Insert your Address here"` + +3. Call dial on meekliteTransport: +`_, err := meekliteTransport.Dial()` + +### Go Version: + +meeklite is one of the transports available in the [Shapeshifter-Transports library](https://github.com/OperatorFoundation/Shapeshifter-Transports). + diff --git a/transports/meeklite/v3/go.mod b/transports/meeklite/v3/go.mod new file mode 100644 index 0000000..377b94d --- /dev/null +++ b/transports/meeklite/v3/go.mod @@ -0,0 +1,8 @@ +module github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v2 + +go 1.12 + +require ( + github.com/stretchr/testify v1.5.1 + golang.org/x/net v0.0.0-20200202094626-16171245cfb2 +) diff --git a/transports/meeklite/v3/go.sum b/transports/meeklite/v3/go.sum new file mode 100644 index 0000000..fe647ab --- /dev/null +++ b/transports/meeklite/v3/go.sum @@ -0,0 +1,16 @@ +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/net v0.0.0-20200202094626-16171245cfb2 h1:CCH4IOTTfewWjGOlSp+zGcjutRKlBEZQ6wTn8ozI/nI= +golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/transports/meeklite/v3/meeklite.go b/transports/meeklite/v3/meeklite.go new file mode 100644 index 0000000..21d4002 --- /dev/null +++ b/transports/meeklite/v3/meeklite.go @@ -0,0 +1,465 @@ +/* + * Copyright (c) 2015, Yawning Angel + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +// Package meeklite provides an implementation of the Meek circumvention +// protocol. Only a client implementation is provided, and no effort is +// made to normalize the TLS fingerprint. +// +// It borrows quite liberally from the real meek-client code. +package meeklite + +import ( + "bytes" + "crypto/rand" + "crypto/sha256" + "encoding/hex" + "errors" + "fmt" + "golang.org/x/net/proxy" + "io" + "io/ioutil" + "net" + "net/http" + gourl "net/url" + "runtime" + "sync" + "time" +) + +const ( + maxChanBacklog = 16 + + // Constants shamelessly stolen from meek-client.go... + maxPayloadLength = 0x10000 + initPollInterval = 100 * time.Millisecond + maxPollInterval = 5 * time.Second + pollIntervalMultiplier = 1.5 + maxRetries = 10 + retryDelay = 30 * time.Second +) + +var ( + // ErrNotSupported is the error returned for a unsupported operation. + ErrNotSupported = errors.New("meek_lite: operation not supported") + + loopbackAddr = net.IPv4(127, 0, 0, 1) +) + +// MeekTransport that uses domain fronting to shapeshift the application network traffic +type MeekTransport struct { + dialer proxy.Dialer + + clientArgs *meekClientArgs +} + +// NewMeekTransportWithFront is a public initializer method to get a new meek transport +func NewMeekTransportWithFront(url string, front string, dialer proxy.Dialer) *MeekTransport { + clientArgs, err := newClientArgsWithFront(url, front) + if err != nil { + return nil + } + + return &MeekTransport{dialer: dialer, clientArgs: clientArgs} +} + +// Methods that implement the base.Transport interface + +// NetworkDialer is a dialer for the underlying network connection +// The Dialer can be modified to change how the network connections are made. +func (transport *MeekTransport) NetworkDialer() proxy.Dialer { + return transport.dialer +} + +// Dial creates outgoing transport connection +func (transport *MeekTransport) Dial() net.Conn { + // FIXME - should use dialer + transportConn, err := newMeekClientConn(transport.clientArgs) + if err != nil { + return nil + } + + return transportConn +} + +// Listen for the meek transport does not have a corresponding server, only a client +func (transport *MeekTransport) Listen() net.Listener { + return nil +} + +// End methods that implement the base.Transport interface + +type meekClientArgs struct { + url *gourl.URL + front string +} + +func (ca *meekClientArgs) Network() string { + return "meek" +} + +//Transport contains parameters used in Optimizer +type Transport struct { + URL *gourl.URL `json:"url"` + Front string `json:"front"` + Address string + Dialer proxy.Dialer +} + +//Config puts the parameters in a json compatible format +type Config struct { + URL *gourl.URL `json:"url"` + Front string `json:"front"` +} + +// Dial creates outgoing transport connection +func (transport Transport) Dial() (net.Conn, error) { + meekTransport := NewMeekTransportWithFront(transport.URL.String(), transport.Front, transport.Dialer) + conn := meekTransport.Dial() + return conn, nil +} + +func (ca *meekClientArgs) String() string { + return "meek" + ":" + ca.front + ":" + ca.url.String() +} + +func newClientArgsWithFront(url string, front string) (ca *meekClientArgs, err error) { + ca = &meekClientArgs{} + + // Parse the URL argument. + ca.url, err = gourl.Parse(url) + if err != nil { + return nil, fmt.Errorf("malformed url: '%s'", url) + } + switch ca.url.Scheme { + case "http", "https": + default: + return nil, fmt.Errorf("invalid scheme: '%s'", ca.url.Scheme) + } + + // Parse the (optional) front argument. + ca.front = front + + return ca, nil +} + +// Implementation of base.TransportConn, which also requires implementing net.Conn +type meekConn struct { + sync.Mutex + + args *meekClientArgs + sessionID string + transport *http.Transport + + workerRunning bool + workerWrChan chan []byte + workerRdChan chan []byte + workerCloseChan chan bool + rdBuf *bytes.Buffer +} + +// Private initializer methods + +func newMeekClientConn(ca *meekClientArgs) (*meekConn, error) { + id, err := newSessionID() + if err != nil { + return nil, err + } + + tr := &http.Transport{} + conn := &meekConn{ + args: ca, + sessionID: id, + transport: tr, + workerRunning: true, + workerWrChan: make(chan []byte, maxChanBacklog), + workerRdChan: make(chan []byte, maxChanBacklog), + workerCloseChan: make(chan bool), + } + + // Start the I/O worker. + go conn.ioWorker() + + return conn, nil +} + +// End initializer methods + +// Methods that implement the base.TransportConn interface +func (transportConn *meekConn) NetworkConn() net.Conn { + return nil +} + +// End methods that implement the base.TransportConn interface + +// Methods implementing net.Conn +func (transportConn *meekConn) Read(p []byte) (n int, err error) { + // If there is data left over from the previous read, + // service the request using the buffered data. + if transportConn.rdBuf != nil { + if transportConn.rdBuf.Len() == 0 { + panic("empty read buffer") + } + n, err = transportConn.rdBuf.Read(p) + if transportConn.rdBuf.Len() == 0 { + transportConn.rdBuf = nil + } + return + } + select { + case <-time.After(20*time.Second): + return 0, nil + // Wait for the worker to enqueue more incoming data. + case b, ok := <-transportConn.workerRdChan: + if !ok { + // Close() was called and the worker's shutting down. + return 0, io.ErrClosedPipe + } + + // Ew, an extra copy, but who am I kidding, it's meek. + buf := bytes.NewBuffer(b) + n, err = buf.Read(p) + if buf.Len() > 0 { + // If there's data pending, stash the buffer so the next + // Read() call will use it to fulfill the Read(). + transportConn.rdBuf = buf + } + } + return +} + +func (transportConn *meekConn) Write(b []byte) (n int, err error) { + // Check to see if the connection is actually open. + transportConn.Lock() + closed := !transportConn.workerRunning + transportConn.Unlock() + if closed { + return 0, io.ErrClosedPipe + } + + if len(b) == 0 { + return 0, nil + } + + // Copy the data to be written to a new slice, since + // we return immediately after queuing and the peer can + // happily reuse `b` before data has been sent. + toWrite := len(b) + b2 := make([]byte, toWrite) + copy(b2, b) + if ok := transportConn.enqueueWrite(b2); !ok { + // Technically we did enqueue data, but the worker's + // got closed out from under us. + return 0, io.ErrClosedPipe + } + runtime.Gosched() + return len(b), nil +} + +func (transportConn *meekConn) Close() error { + // Ensure that we do this once and only once. + transportConn.Lock() + defer transportConn.Unlock() + if !transportConn.workerRunning { + return nil + } + + // Tear down the worker. + transportConn.workerRunning = false + transportConn.workerCloseChan <- true + + return nil +} + +func (transportConn *meekConn) LocalAddr() net.Addr { + return &net.IPAddr{IP: loopbackAddr} +} + +func (transportConn *meekConn) RemoteAddr() net.Addr { + return transportConn.args +} + +func (transportConn *meekConn) SetDeadline(time.Time) error { + return ErrNotSupported +} + +func (transportConn *meekConn) SetReadDeadline(time.Time) error { + return ErrNotSupported +} + +func (transportConn *meekConn) SetWriteDeadline(time.Time) error { + return ErrNotSupported +} + +// End of methods implementing net.Conn + +// Private methods implementing the domain fronting cipher +func (transportConn *meekConn) enqueueWrite(b []byte) (ok bool) { + defer func() { recover() }() + transportConn.workerWrChan <- b + return true +} + +func (transportConn *meekConn) roundTrip(sndBuf []byte) (recvBuf []byte, err error) { + var req *http.Request + var resp *http.Response + + for retries := 0; retries < maxRetries; retries++ { + url := *transportConn.args.url + host := url.Host + if transportConn.args.front != "" { + url.Host = transportConn.args.front + } + + req, err = http.NewRequest("POST", url.String(), bytes.NewReader(sndBuf)) + if err != nil { + return nil, err + } + + if transportConn.args.front != "" { + req.Host = host + } + + req.Header.Set("X-Session-Id", transportConn.sessionID) + req.Header.Set("User-Agent", "") + + resp, err = transportConn.transport.RoundTrip(req) + if err != nil { + return nil, err + } + + if resp.StatusCode != http.StatusOK { + err = fmt.Errorf("status code was %d, not %d", resp.StatusCode, http.StatusOK) + if resp.StatusCode == http.StatusInternalServerError { + return + } + time.Sleep(retryDelay) + + } else { + _ = resp.Body.Close() + recvBuf, err = ioutil.ReadAll(io.LimitReader(resp.Body, maxPayloadLength)) + return + } + } + + return +} + +func (transportConn *meekConn) ioWorker() { + interval := initPollInterval + var sndBuf, leftBuf []byte +loop: + + for { + sndBuf = nil + select { + case <-time.After(interval): + // If the poll interval has elapsed, issue a request. + case sndBuf = <-transportConn.workerWrChan: + // If there is data pending a send, issue a request. + case _ = <-transportConn.workerCloseChan: + break loop + } + + // Combine short writes as long as data is available to be + // sent immediately and it will not put us over the max + // payload limit. Any excess data is stored and dispatched + // as the next request). + sndBuf = append(leftBuf, sndBuf...) + wrSz := len(sndBuf) + for len(transportConn.workerWrChan) > 0 && wrSz < maxPayloadLength { + + b := <-transportConn.workerWrChan + sndBuf = append(sndBuf, b...) + wrSz = len(sndBuf) + } + if wrSz > maxPayloadLength { + wrSz = maxPayloadLength + } + + // Issue a request. + rdBuf, err := transportConn.roundTrip(sndBuf[:wrSz]) + if err != nil { + // Welp, something went horrifically wrong. + break loop + } + + // Stash the remaining payload if any. + leftBuf = sndBuf[wrSz:] // Store the remaining data + if len(leftBuf) == 0 { + leftBuf = nil + } + + // Determine the next poll interval. + if len(rdBuf) > 0 { + // Received data, enqueue the read. + transportConn.workerRdChan <- rdBuf + + // And poll immediately. + interval = 0 + } else if wrSz > 0 { + // Sent data, poll immediately. + interval = 0 + } else if interval == 0 { + // Neither sent nor received data, initialize the delay. + interval = initPollInterval + } else { + // Apply a multiplicative backoff. + interval = time.Duration(float64(interval) * pollIntervalMultiplier) + if interval > maxPollInterval { + interval = maxPollInterval + } + } + + runtime.Gosched() + } + + // Unblock callers waiting in Read() for data that will never arrive, + // and callers waiting in Write() for data that will never get sent. + close(transportConn.workerRdChan) + close(transportConn.workerWrChan) + + // In case the close was done on an error condition, update the state + // variable so that further calls to Write() will fail. + transportConn.Lock() + defer transportConn.Unlock() + transportConn.workerRunning = false +} + +func newSessionID() (string, error) { + var b [64]byte + if _, err := rand.Read(b[:]); err != nil { + return "", err + } + h := sha256.Sum256(b[:]) + return hex.EncodeToString(h[:16]), nil +} + +// End private methods implementing the ROT13 cipher + +// Force type checks to make sure that instances conform to interfaces +var _ net.Conn = (*meekConn)(nil) +var _ net.Addr = (*meekClientArgs)(nil) diff --git a/transports/meeklite/v3/meeklite_test.go b/transports/meeklite/v3/meeklite_test.go new file mode 100644 index 0000000..b26d710 --- /dev/null +++ b/transports/meeklite/v3/meeklite_test.go @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2015, Yawning Angel + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +// Package meeklite provides an implementation of the Meek circumvention +// protocol. Only a client implementation is provided, and no effort is +// made to normalize the TLS fingerprint. +// +// It borrows quite liberally from the real meek-client code. + +package meeklite + +import ( + "golang.org/x/net/proxy" + "testing" +) + +const data = "test" + +func TestMeeklite(t *testing.T) { + //create a server + config := NewMeekTransportWithFront("https://transport-canary-meek.appspot.com/", "www.google.com", proxy.Direct) + + //create client buffer + clientBuffer := make([]byte, 4) + //call dial on client and check error + clientConn := config.Dial() + if clientConn == nil { + t.Fail() + return + } + + //write data from clientConn for server to read + writeBytes, clientWriteErr := clientConn.Write([]byte(data)) + if clientWriteErr != nil { + t.Fail() + return + } + if writeBytes <= 0 { + t.Fail() + return + } + + //read on client side + readBytes, clientReadErr := clientConn.Read(clientBuffer) + if clientReadErr != nil { + t.Fail() + return + } + if readBytes <= 0 { + t.Fail() + return + } +} diff --git a/transports/meekserver/v3/certificate.go b/transports/meekserver/v3/certificate.go new file mode 100644 index 0000000..4daccf0 --- /dev/null +++ b/transports/meekserver/v3/certificate.go @@ -0,0 +1,114 @@ +// certificate.go - Certificate management for meek-server. + +// +build go1.6 + +package meekserver + +import ( + "crypto/tls" + "log" + "os" + "sync" + "time" +) + +const certLoadErrorRateLimit = 1 * time.Minute + +type certContext struct { + sync.Mutex + + certFile string + keyFile string + + certFileInfo os.FileInfo + keyFileInfo os.FileInfo + cachedCert *tls.Certificate + + lastWarnAt time.Time +} + +func newCertContext(certFilename, keyFilename string) (*certContext, error) { + ctx := new(certContext) + ctx.certFile = certFilename + ctx.keyFile = keyFilename + if _, err := ctx.reloadCertificate(); err != nil { + return nil, err + } + return ctx, nil +} + +func (ctx *certContext) reloadCertificate() (*tls.Certificate, error) { + doReload := true + + // XXX/Yawning: I assume compared to everything else related to TLS + // handshakes, stat() is cheap. If not, ratelimit here. gettimeofday() + // is vDSO-ed so it would be significantly faster than the syscalls. + + var err error + var cfInfo, kfInfo os.FileInfo + if cfInfo, err = os.Stat(ctx.certFile); err == nil { + kfInfo, err = os.Stat(ctx.keyFile) + } + + ctx.Lock() + defer ctx.Unlock() + + // Grab the cached certificate, compare the modification times if able. + cert := ctx.cachedCert + if err != nil { + // If stat fails, we likely aren't going to be able to reload, so + // return early. + return cert, err + } else if ctx.cachedCert != nil { + // Only compare the file times if there's actually a cached cert, + // and reload the cert if either the key or the certificate have + // been modified. + doReload = !ctx.certFileInfo.ModTime().Equal(cfInfo.ModTime()) || !ctx.keyFileInfo.ModTime().Equal(kfInfo.ModTime()) + } + + // Attempt to load the updated certificate, if required. + if doReload { + newCert, err := tls.LoadX509KeyPair(ctx.certFile, ctx.keyFile) + if err != nil { + // If the load fails, return the old certificate, so that it can + // be used till the load succeeds. + return cert, err + } + + // If the user regenerates the cert/key between the stat() and + // LoadX509KeyPair calls, this will race, but will self-correct + // after the next reloadCertificate() call because doReload will + // be true. + + ctx.cachedCert = &newCert + ctx.certFileInfo = cfInfo + ctx.keyFileInfo = kfInfo + + cert = ctx.cachedCert + } + return cert, nil +} + +func (ctx *certContext) GetCertificate(*tls.ClientHelloInfo) (*tls.Certificate, error) { + cert, err := ctx.reloadCertificate() + if err != nil { + // Failure to reload the certificate is a non-fatal error as this + // may be a filesystem related race condition. There is nothing + // preventing the next callback from hopefully succeeding, so rate + // limit an error log. + now := time.Now() + if now.After(ctx.lastWarnAt.Add(certLoadErrorRateLimit)) { + ctx.lastWarnAt = now + log.Printf("failed to reload certificate: %v", err) + } + } + + // This should NEVER happen because we will continue to use the old + // certificate on load failure, and we will never be calling the + // listener GetCertificate() callback if the initial load fails. + if cert == nil { + panic("no cached certificate available") + } + + return cert, nil +} diff --git a/transports/meekserver/v3/certificate_test.go b/transports/meekserver/v3/certificate_test.go new file mode 100644 index 0000000..f2152bb --- /dev/null +++ b/transports/meekserver/v3/certificate_test.go @@ -0,0 +1,312 @@ +package meekserver + +import ( + "bytes" + "crypto/rand" + "crypto/tls" + "encoding/hex" + "io/ioutil" + "os" + "path/filepath" + "testing" + "time" +) + +// openssl genpkey -out key1.pem -algorithm EC -pkeyopt ec_paramgen_curve:P-256 -pkeyopt ec_param_enc:named_curve +const key1PEM = `-----BEGIN PRIVATE KEY----- +MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgwBuadiHWuhiCwUHK +pvzM0MYVySH8FE5T/76qoDBozzChRANCAAQao88iJDj284z5YsSOwynblbNfhRHL +dhInn3bl8dYUr0s88q7yaOHW0riAYAX8Q/G5zoP/P1MgNPFMYV76eSY4 +-----END PRIVATE KEY-----` + +// openssl req -out cert1.pem -x509 -new -nodes -key key1.pem -days 1 -subj "/CN=meek-server.example.com" +const cert1PEM = `-----BEGIN CERTIFICATE----- +MIIBjjCCATSgAwIBAgIJAKpvM1Hu/AeyMAoGCCqGSM49BAMCMCIxIDAeBgNVBAMM +F21lZWstc2VydmVyLmV4YW1wbGUuY29tMB4XDTE3MDMyMTIyNTM0N1oXDTE3MDMy +MjIyNTM0N1owIjEgMB4GA1UEAwwXbWVlay1zZXJ2ZXIuZXhhbXBsZS5jb20wWTAT +BgcqhkjOPQIBBggqhkjOPQMBBwNCAAQao88iJDj284z5YsSOwynblbNfhRHLdhIn +n3bl8dYUr0s88q7yaOHW0riAYAX8Q/G5zoP/P1MgNPFMYV76eSY4o1MwUTAdBgNV +HQ4EFgQU/FIFX5DX58BFhNBSWV0ulWmS+XIwHwYDVR0jBBgwFoAU/FIFX5DX58BF +hNBSWV0ulWmS+XIwDwYDVR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAgNIADBFAiEA +mylhVbnAd0KEQoaIEH1whj9oUxlk2kWU5G8daG5uUjMCIBW6fwv0cbYmyzspCMqJ +eib1vgFnhGTI44K05cunpXJ+ +-----END CERTIFICATE-----` + +// openssl genpkey -out key2.pem -algorithm EC -pkeyopt ec_paramgen_curve:P-256 -pkeyopt ec_param_enc:named_curve +const key2PEM = `-----BEGIN PRIVATE KEY----- +MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgUbNm7exkEPKMv/DT +B3UMv6XevnD2E99W3Rp8L/a1v12hRANCAATqnza9H9uNa8EvoKm2GOLvw25kR7OA +oVHZiyaXdBeB480FBUtRmWUukLZFxp/QStd4OCwaOwWGtXGlspM2LEum +-----END PRIVATE KEY-----` + +// openssl req -out cert2.pem -x509 -new -nodes -key key2.pem -days 1 -subj "/CN=meek-server.example.com" +const cert2PEM = `-----BEGIN CERTIFICATE----- +MIIBjzCCATSgAwIBAgIJAKvKZ4vqwpySMAoGCCqGSM49BAMCMCIxIDAeBgNVBAMM +F21lZWstc2VydmVyLmV4YW1wbGUuY29tMB4XDTE3MDMyMTIyNTQzN1oXDTE3MDMy +MjIyNTQzN1owIjEgMB4GA1UEAwwXbWVlay1zZXJ2ZXIuZXhhbXBsZS5jb20wWTAT +BgcqhkjOPQIBBggqhkjOPQMBBwNCAATqnza9H9uNa8EvoKm2GOLvw25kR7OAoVHZ +iyaXdBeB480FBUtRmWUukLZFxp/QStd4OCwaOwWGtXGlspM2LEumo1MwUTAdBgNV +HQ4EFgQUdqTMumWa7f965k/SLgWJT0tIlcswHwYDVR0jBBgwFoAUdqTMumWa7f96 +5k/SLgWJT0tIlcswDwYDVR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAgNJADBGAiEA +yOhMqBPZLpqnjTGD1OgOc1N1SkS53bdWAazAZgLgwvICIQC7hFOK1j74Frh+1l3h +kLn8Jbjpp6jzNBhQhVHF/nj3CQ== +-----END CERTIFICATE-----` + +const badSyntax = "hello world\n" + +// Backdate file times so any modifications will make them appear different; +// otherwise immediately overwriting the files may happen quickly enough that +// the times don't change. +func backdateFile(filename string) error { + info, err := os.Stat(filename) + if err != nil { + return err + } + timestamp := info.ModTime().Add(-10 * time.Second) + return os.Chtimes(filename, timestamp, timestamp) +} + +func mustBackdateFile(filename string) { + err := backdateFile(filename) + if err != nil { + panic(err) + } +} + +// Return the path to a newly created temporary file with the given contents. +func makeTempFileFromContents(contents []byte) (string, error) { + f, err := ioutil.TempFile("", "meek-server-certificate-test-") + if err != nil { + return "", err + } + + _, err = f.Write(contents) + if err != nil { + f.Close() + return f.Name(), err + } + + err = backdateFile(f.Name()) + f.Close() + return f.Name(), err +} + +func mustMakeTempFileFromContents(contents []byte) string { + f, err := makeTempFileFromContents(contents) + if err != nil { + panic(err) + } + return f +} + +// Return a random filename that is unlikely to exist. +func makeNonexistentFilename() string { + fileBytes := make([]byte, 8) + _, err := rand.Read(fileBytes) + if err != nil { + panic(err) + } + return filepath.Join(os.TempDir(), hex.EncodeToString(fileBytes)) +} + +// Call tls.X509KeyPair and panic if it fails. +func mustLoadCertificate(certPEM, keyPEM []byte) *tls.Certificate { + cert, err := tls.X509KeyPair(certPEM, keyPEM) + if err != nil { + panic(err) + } + return &cert +} + +func mustWriteFile(filename string, data []byte) { + err := ioutil.WriteFile(filename, data, 0600) + if err != nil { + panic(err) + } +} + +// A bunch of temporary certificate filenames and the like. +type testFiles struct { + cert1 *tls.Certificate + cert2 *tls.Certificate + + key1Filename string + key2Filename string + cert1Filename string + cert2Filename string + badSyntaxFilename string + nonexistentFilename string +} + +func loadTestFiles() *testFiles { + var files testFiles + + files.cert1 = mustLoadCertificate([]byte(cert1PEM), []byte(key1PEM)) + files.cert2 = mustLoadCertificate([]byte(cert2PEM), []byte(key2PEM)) + + files.key1Filename = mustMakeTempFileFromContents([]byte(key1PEM)) + files.key2Filename = mustMakeTempFileFromContents([]byte(key2PEM)) + files.cert1Filename = mustMakeTempFileFromContents([]byte(cert1PEM)) + files.cert2Filename = mustMakeTempFileFromContents([]byte(cert2PEM)) + files.badSyntaxFilename = mustMakeTempFileFromContents([]byte(badSyntax)) + files.nonexistentFilename = makeNonexistentFilename() + + return &files +} + +// Delete temporary files created by loadTestFiles (to be called in a defer +// handler). +func (files *testFiles) Cleanup() { + _ = os.Remove(files.key1Filename) + _ = os.Remove(files.key2Filename) + _ = os.Remove(files.cert1Filename) + _ = os.Remove(files.cert2Filename) + _ = os.Remove(files.badSyntaxFilename) +} + +// Check if two certificate chains are equal. +func certificatesEqual(cert1, cert2 *tls.Certificate) bool { + if len(cert1.Certificate) != len(cert2.Certificate) { + return false + } + for i := range cert1.Certificate { + if !bytes.Equal(cert1.Certificate[i], cert2.Certificate[i]) { + return false + } + } + return true +} + +// Call ctx.reloadCertificate and check if the certificate and error status are +// as expected. +func checkCertificate(t *testing.T, ctx *certContext, expectedCert *tls.Certificate, expectedError bool) { + cert, err := ctx.reloadCertificate() + if expectedError && err == nil { + t.Errorf("expected error, got %v\n", err) + } else if !expectedError && err != nil { + t.Errorf("expected no error, got %v\n", err) + } + if !certificatesEqual(cert, expectedCert) { + t.Errorf("certificate was other than expected") + } +} + +func TestNewCertContext(t *testing.T) { + files := loadTestFiles() + defer files.Cleanup() + + var ctx *certContext + var err error + + // Test with one or both files nonexistent. + ctx, err = newCertContext(files.nonexistentFilename, files.nonexistentFilename) + if err == nil { + t.Errorf("did not raise error on nonexistent cert and key") + } + ctx, err = newCertContext(files.cert1Filename, files.nonexistentFilename) + if err == nil { + t.Errorf("did not raise error on nonexistent cert") + } + ctx, err = newCertContext(files.nonexistentFilename, files.key1Filename) + if err == nil { + t.Errorf("did not raise error on nonexistent key") + } + + // Test with bad syntax. + ctx, err = newCertContext(files.badSyntaxFilename, files.badSyntaxFilename) + if err == nil { + t.Errorf("did not raise error on bad-syntax cert and key") + } + ctx, err = newCertContext(files.cert1Filename, files.badSyntaxFilename) + if err == nil { + t.Errorf("did not raise error on bad-syntax cert") + } + ctx, err = newCertContext(files.badSyntaxFilename, files.key1Filename) + if err == nil { + t.Errorf("did not raise error on bad-syntax key") + } + + // Test with certificate and key that don't match. + ctx, err = newCertContext(files.cert1Filename, files.key2Filename) + if err == nil { + t.Errorf("did not raise error on mismatched cert and key") + } + ctx, err = newCertContext(files.cert2Filename, files.key1Filename) + if err == nil { + t.Errorf("did not raise error on mismatched cert and key") + } + + // Test with everything good. + ctx, err = newCertContext(files.cert1Filename, files.key1Filename) + if ctx == nil || err != nil { + t.Fatalf("raised an error: %s", err) + } +} + +// Test that reloadCertificate continues returning the old certificate if files +// are deleted. +func TestDelete(t *testing.T) { + files := loadTestFiles() + defer files.Cleanup() + + var ctx *certContext + var err error + + ctx, err = newCertContext(files.cert1Filename, files.key1Filename) + if ctx == nil || err != nil { + t.Fatalf("raised an error: %s", err) + } + checkCertificate(t, ctx, files.cert1, false) + // Try removing the cert file; cert should be the same but now raise an error. + _ = os.Remove(files.cert1Filename) + checkCertificate(t, ctx, files.cert1, true) + + ctx, err = newCertContext(files.cert2Filename, files.key2Filename) + if ctx == nil || err != nil { + t.Fatalf("raised an error: %s", err) + } + checkCertificate(t, ctx, files.cert2, false) + // Try removing the key file; cert should be the same but now raise an error. + _ = os.Remove(files.key2Filename) + checkCertificate(t, ctx, files.cert2, true) +} + +// Test replacing the contents of cert and key files. +func TestReplace(t *testing.T) { + files := loadTestFiles() + defer files.Cleanup() + + var ctx *certContext + var err error + + ctx, err = newCertContext(files.cert1Filename, files.key1Filename) + if ctx == nil || err != nil { + t.Fatalf("raised an error: %s", err) + } + checkCertificate(t, ctx, files.cert1, false) + + // Replace cert file with junk. + mustWriteFile(files.cert1Filename, []byte(badSyntax)) + checkCertificate(t, ctx, files.cert1, true) + // Put it back to normal. + mustWriteFile(files.cert1Filename, []byte(cert1PEM)) + checkCertificate(t, ctx, files.cert1, false) + + // Replace key file with junk. + mustWriteFile(files.key1Filename, []byte(badSyntax)) + checkCertificate(t, ctx, files.cert1, true) + // Put it back to normal. + mustWriteFile(files.key1Filename, []byte(key1PEM)) + checkCertificate(t, ctx, files.cert1, false) + + mustBackdateFile(files.cert1Filename) + mustBackdateFile(files.key1Filename) + checkCertificate(t, ctx, files.cert1, false) + + // Replace cert1 with cert2 contents; expect to still get cert1, with an error. + mustWriteFile(files.cert1Filename, []byte(cert2PEM)) + checkCertificate(t, ctx, files.cert1, true) + // Replace key1 with key2 contents; now we expect to be using cert2. + mustWriteFile(files.key1Filename, []byte(key2PEM)) + checkCertificate(t, ctx, files.cert2, false) +} diff --git a/transports/meekserver/v3/go.mod b/transports/meekserver/v3/go.mod new file mode 100644 index 0000000..3ac5d1d --- /dev/null +++ b/transports/meekserver/v3/go.mod @@ -0,0 +1,11 @@ +module github.com/OperatorFoundation/shapeshifter-transports/transports/meekserver/v2 + +go 1.12 + +require ( + git.torproject.org/pluggable-transports/goptlib.git v1.1.0 + github.com/deckarep/golang-set v1.7.1 + github.com/mufti1/interconv v0.0.0-20190313040840-d7c72925c656 + golang.org/x/crypto v0.0.0-20200214034016-1d94cc7ab1c6 + golang.org/x/net v0.0.0-20200202094626-16171245cfb2 +) diff --git a/transports/meekserver/v3/go.sum b/transports/meekserver/v3/go.sum new file mode 100644 index 0000000..3bd92d5 --- /dev/null +++ b/transports/meekserver/v3/go.sum @@ -0,0 +1,16 @@ +git.torproject.org/pluggable-transports/goptlib.git v1.1.0 h1:LMQAA8pAho+QtYrrVNimJQiINNEwcwuuD99vezD/PAo= +git.torproject.org/pluggable-transports/goptlib.git v1.1.0/go.mod h1:YT4XMSkuEXbtqlydr9+OxqFAyspUv0Gr9qhM3B++o/Q= +github.com/deckarep/golang-set v1.7.1 h1:SCQV0S6gTtp6itiFrTqI+pfmJ4LN85S1YzhDf9rTHJQ= +github.com/deckarep/golang-set v1.7.1/go.mod h1:93vsz/8Wt4joVM7c2AVqh+YRMiUSc14yDtF28KmMOgQ= +github.com/mufti1/interconv v0.0.0-20190313040840-d7c72925c656 h1:p+IdebEeB9SAEH9IOJVF6oZ535bwvWqUdqWxG1UWeko= +github.com/mufti1/interconv v0.0.0-20190313040840-d7c72925c656/go.mod h1:+db4NNs1NvceiftEzz0ymfu3zKLkynYukafc7llNoMs= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20200214034016-1d94cc7ab1c6 h1:Sy5bstxEqwwbYs6n0/pBuxKENqOeZUgD45Gp3Q3pqLg= +golang.org/x/crypto v0.0.0-20200214034016-1d94cc7ab1c6/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20200202094626-16171245cfb2 h1:CCH4IOTTfewWjGOlSp+zGcjutRKlBEZQ6wTn8ozI/nI= +golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/transports/meekserver/v3/meek-server.go b/transports/meekserver/v3/meek-server.go new file mode 100644 index 0000000..dbd64b0 --- /dev/null +++ b/transports/meekserver/v3/meek-server.go @@ -0,0 +1,344 @@ +// Package meekserver is the server transport plugin for the meek pluggable transport. +// It acts as an HTTP server, keeps track of session ids, and forwards received +// data to a local OR port. +// +// Sample usage in torrc: +// ServerTransportListenAddr meek 0.0.0.0:443 +// ServerTransportPlugin meek exec ./meek-server --acme-hostnames meek-server.example --acme-email admin@meek-server.example --log meek-server.log +// Using your own TLS certificate: +// ServerTransportListenAddr meek 0.0.0.0:8443 +// ServerTransportPlugin meek exec ./meek-server --cert cert.pem --key key.pem --log meek-server.log +// Plain HTTP usage: +// ServerTransportListenAddr meek 0.0.0.0:8080 +// ServerTransportPlugin meek exec ./meek-server --disable-tls --log meek-server.log +// +// The server runs in HTTPS mode by default, getting certificates from Let's +// Encrypt automatically. The server opens an auxiliary ACME listener on port 80 +// in order for the automatic certificates to work. If you have your own +// certificate, use the --cert and --key options. Use --disable-tls option to +// run with plain HTTP. +package meekserver + +import ( + "crypto/tls" + "fmt" + "io" + "log" + "net" + "net/http" + "path" + "path/filepath" + "sync" + "time" + + "github.com/deckarep/golang-set" + "golang.org/x/net/http2" +) + +const ( + // Reject session ids shorter than this, as a weak defense against + // client bugs that send an empty session id or something similarly + // likely to collide. + minSessionIDLength = 8 + // The largest request body we are willing to process, and the largest + // chunk of data we'll send back in a response. + maxPayloadLength = 0x10000 + // Passed as ReadTimeout and WriteTimeout when constructing the + // http.Server. + readWriteTimeout = 20 * time.Second + // Cull unused session ids (with their corresponding OR port connection) + // if we haven't seen any activity for this long. + maxSessionStaleness = 120 * time.Second + // How long to wait for ListenAndServe or ListenAndServeTLS to return an + // error before deciding that it's not going to return. + listenAndServeErrorTimeout = 100 * time.Millisecond +) + +func httpBadRequest(w http.ResponseWriter) { + http.Error(w, "Bad request.", http.StatusBadRequest) +} + +func httpInternalServerError(w http.ResponseWriter) { + http.Error(w, "Internal server error.", http.StatusInternalServerError) +} + +// Session id maps to an existing OR port connection, which we keep open +// between received requests. The first time we see a new session id, we create +// a new OR port connection. +type Session struct { + Or fakeConn + LastSeen time.Time +} + +// Touch marks a session as having been seen just now. +func (session *Session) Touch() { + session.LastSeen = time.Now() +} + +// IsExpired finds out if this session is old enough to be culled +func (session *Session) IsExpired() bool { + return time.Since(session.LastSeen) > maxSessionStaleness +} + +// State serves as the http handler +// There is one state per HTTP listener. In the usual case there is just one +// listener, so there is just one global state. +type State struct { + sessionMap map[string]*Session + lock sync.Mutex + availableSessions mapset.Set +} + +// NewState makes a new state +func NewState() *State { + state := new(State) + state.sessionMap = make(map[string]*Session) + state.availableSessions = mapset.NewSet() + return state +} + +func (state *State) ServeHTTP(w http.ResponseWriter, req *http.Request) { + switch req.Method { + case "GET": + state.Get(w, req) + case "POST": + state.Post(w, req) + default: + httpBadRequest(w) + } +} + +// Get handles a GET request. This doesn't have any purpose apart from diagnostics. +func (state *State) Get(w http.ResponseWriter, req *http.Request) { + if path.Clean(req.URL.Path) != "/" { + http.NotFound(w, req) + return + } + w.Header().Set("Content-Type", "text/plain; charset=utf-8") + w.WriteHeader(http.StatusOK) + _, _ = w.Write([]byte("I’m just a happy little web server.\n")) +} + +// Get a string representing the original client address, if available, as a +// "host:port" string suitable to pass as the addr parameter to pt.DialOr. Never +// fails: if the original client address is not available, returns "". If the +// original client address is available, the returned port number is always 1. + +// GetSession looks up a session by id, or create a new one (with its OR port connection) if +// it doesn't already exist. +func (state *State) GetSession(sessionID string) (*Session, error) { + state.lock.Lock() + defer state.lock.Unlock() + + session := state.sessionMap[sessionID] + if session == nil { + // log.Printf("unknown session id %q; creating new session", sessionID) + + session = &Session{Or: newFakeConn()} + state.sessionMap[sessionID] = session + state.availableSessions.Add(sessionID) + } + session.Touch() + + return session, nil +} + +func newFakeConn() fakeConn { + readBuffer := make([]byte, 0) + writeBuffer := make([]byte, 0) + return fakeConn{ + readBuffer: readBuffer, + writeBuffer: writeBuffer, + } +} + +// scrubbedAddr is a phony net.Addr that returns "[scrubbed]" for all calls. +type scrubbedAddr struct{} + +func (a scrubbedAddr) Network() string { + return "[scrubbed]" +} +func (a scrubbedAddr) String() string { + return "[scrubbed]" +} + +// Replace the Addr in a net.OpError with "[scrubbed]" for logging. +func scrubError(err error) error { + if operr, ok := err.(*net.OpError); ok { + // net.OpError contains Op, Net, Addr, and a subsidiary Err. The + // (Op, Net, Addr) part is responsible for error text prefixes + // like "read tcp X.X.X.X:YYYY:". We want that information but + // don't want to log the literal address. + operr.Addr = scrubbedAddr{} + } + return err +} + +// Feed the body of req into the OR port, and write any data read from the OR +// port back to w. +func transact(session *Session, w http.ResponseWriter, req *http.Request) error { + body := http.MaxBytesReader(w, req.Body, maxPayloadLength+1) + _, err := io.ReadFull(body, session.Or.readBuffer) + if err != nil { + return fmt.Errorf("error copying body to ORPort: %s", scrubError(err)) + } + + buf := make([]byte, maxPayloadLength) + //session.Or.SetReadDeadline(time.Now().Add(turnaroundTimeout)) + n := len(session.Or.writeBuffer) + if n == 0 { + httpInternalServerError(w) + // Don't scrub err here because it always refers to localhost. + return fmt.Errorf("reading from ORPort: %s", err) + } + if n > maxPayloadLength { + copy(buf, session.Or.writeBuffer[:maxPayloadLength]) + session.Or.writeBuffer = session.Or.writeBuffer[maxPayloadLength:] + } else { + copy(buf, session.Or.writeBuffer) + session.Or.writeBuffer = session.Or.writeBuffer[:0] + } + // log.Printf("read %d bytes from ORPort: %q", n, buf[:n]) + // Set a Content-Type to prevent Go and the CDN from trying to guess. + w.Header().Set("Content-Type", "application/octet-stream") + n, err = w.Write(buf) + if err != nil { + return fmt.Errorf("error writing to response: %s", scrubError(err)) + } + // log.Printf("wrote %d bytes to response", n) + return nil +} + +// Post handles a POST request. Look up the session id and then do a transaction. +func (state *State) Post(w http.ResponseWriter, req *http.Request) { + sessionID := req.Header.Get("X-Session-Id") + if len(sessionID) < minSessionIDLength { + httpBadRequest(w) + return + } + + session, err := state.GetSession(sessionID) + if err != nil { + log.Print(err) + httpInternalServerError(w) + return + } + + err = transact(session, w, req) + if err != nil { + log.Print(err) + state.CloseSession(sessionID) + return + } +} + +// CloseSession removes a session from the map and closes its corresponding OR port +// connection. Does nothing if the session id is not known. +func (state *State) CloseSession(sessionID string) { + state.lock.Lock() + defer state.lock.Unlock() + // log.Printf("closing session %q", sessionID) + _, ok := state.sessionMap[sessionID] + if ok { + delete(state.sessionMap, sessionID) + state.availableSessions.Remove(sessionID) + } +} + +// ExpireSessions prevents an endless loop, checking for expired sessions and removing them. +func (state *State) ExpireSessions() { + for { + time.Sleep(maxSessionStaleness / 2) + state.lock.Lock() + for sessionID, session := range state.sessionMap { + if session.IsExpired() { + // log.Printf("deleting expired session %q", sessionID) + delete(state.sessionMap, sessionID) + state.availableSessions.Remove(sessionID) + } + } + state.lock.Unlock() + } +} + +func initServer(addr *net.TCPAddr, + getCertificate func(*tls.ClientHelloInfo) (*tls.Certificate, error), + listenAndServe func(*http.Server, chan<- error)) (*http.Server, *State, error) { + // We're not capable of listening on port 0 (i.e., an ephemeral port + // unknown in advance). The reason is that while the net/http package + // exposes ListenAndServe and ListenAndServeTLS, those functions never + // return, so there's no opportunity to find out what the port number + // is, in between the Listen and Serve steps. + // https://groups.google.com/d/msg/Golang-nuts/3F1VRCCENp8/3hcayZiwYM8J + if addr.Port == 0 { + return nil, nil, fmt.Errorf("cannot listen on port %d; configure a port using ServerTransportListenAddr", addr.Port) + } + + state := NewState() + go state.ExpireSessions() + + server := &http.Server{ + Addr: addr.String(), + Handler: state, + ReadTimeout: readWriteTimeout, + WriteTimeout: readWriteTimeout, + } + // We need to override server.TLSConfig.GetCertificate--but first + // server.TLSConfig needs to be non-nil. If we just create our own new + // &tls.Config, it will lack the default settings that the net/http + // package sets up for things like HTTP/2. Therefore we first call + // http2.ConfigureServer for its side effect of initializing + // server.TLSConfig properly. An alternative would be to make a dummy + // net.Listener, call Serve on it, and let it return. + // https://github.com/golang/go/issues/16588#issuecomment-237386446 + err := http2.ConfigureServer(server, nil) + if err != nil { + return server, state, err + } + server.TLSConfig.GetCertificate = getCertificate + + // Another unfortunate effect of the inseparable net/http ListenAndServe + // is that we can't check for Listen errors like "permission denied" and + // "address already in use" without potentially entering the infinite + // loop of Serve. The hack we apply here is to wait a short time, + // listenAndServeErrorTimeout, to see if an error is returned (because + // it's better if the error message goes to the tor log through + // SMETHOD-ERROR than if it only goes to the meek-server log). + errChan := make(chan error) + go listenAndServe(server, errChan) + select { + case err = <-errChan: + break + case <-time.After(listenAndServeErrorTimeout): + break + } + + return server, state, err +} + +func startServer(addr *net.TCPAddr) (*http.Server, *State, error) { + return initServer(addr, nil, func(server *http.Server, errChan chan<- error) { + log.Printf("listening with plain HTTP on %s", addr) + err := server.ListenAndServe() + if err != nil { + log.Printf("Error in ListenAndServe: %s", err) + } + errChan <- err + }) +} + +func startServerTLS(addr *net.TCPAddr, getCertificate func(*tls.ClientHelloInfo) (*tls.Certificate, error)) (*http.Server, *State, error) { + return initServer(addr, getCertificate, func(server *http.Server, errChan chan<- error) { + log.Printf("listening with HTTPS on %s", addr) + err := server.ListenAndServeTLS("", "") + if err != nil { + log.Printf("Error in ListenAndServeTLS: %s", err) + } + errChan <- err + }) +} + +func getCertificateCacheDir(stateDir string) (string, error) { + + return filepath.Join(stateDir, "meek-certificate-cache"), nil +} diff --git a/transports/meekserver/v3/meekserver_test.go b/transports/meekserver/v3/meekserver_test.go new file mode 100644 index 0000000..0f7788f --- /dev/null +++ b/transports/meekserver/v3/meekserver_test.go @@ -0,0 +1,29 @@ +package meekserver + +import ( + "testing" +) + +//if disableTLS is true, it doesnt require the cert and key +//func TestMeekServerListen(t *testing.T) { +// meekserverTransport := NewMeekTransportServer(true, "", "", "state") +// listener := meekserverTransport.Listen("127.0.0.1:80") +// if listener == nil { +// t.Fail() +// } +//} + +func TestMeekServerListen2(t *testing.T) { + acmeEmail := "brandon@operatorfoundation.org" + keyFileName := "operatorrss.com" + meekserverTransport := NewMeekTransportServer(false, acmeEmail, keyFileName, "state") + if meekserverTransport == nil { + t.Fail() + return + } + listener := meekserverTransport.Listen("127.0.0.1:8080") + if listener == nil { + t.Fail() + return + } +} \ No newline at end of file diff --git a/transports/meekserver/v3/pt21.go b/transports/meekserver/v3/pt21.go new file mode 100644 index 0000000..9aa7242 --- /dev/null +++ b/transports/meekserver/v3/pt21.go @@ -0,0 +1,225 @@ +/* + * Copyright (c) 2015, Yawning Angel + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +// Package meekserver provides an implementation of the Meek circumvention +// protocol. Only a client implementation is provided, and no effort is +// made to normalize the TLS fingerprint. +// +// It borrows quite liberally from the real meek-client code. +package meekserver + +import ( + "errors" + interconv "github.com/mufti1/interconv/package" + "golang.org/x/crypto/acme/autocert" + "log" + "net" + "net/http" + "strings" + "time" +) + +//MeekServer is a Transport that uses domain fronting to shapeshift the application network traffic +type MeekServer struct { + DisableTLS bool + AcmeEmail string + AcmeHostname string + CertManager *autocert.Manager +} + +//Config contains arguments formatted for a json file +type Config struct { + AcmeEmail string `json:"acme-email"` + AcmeHostname string `json:"acme-hostnames"` +} + +type meekListener struct { + server *http.Server + state *State +} + +type meekServerConn struct { + session *Session + state *State + sessionID string +} + +type fakeConn struct { + readBuffer []byte + writeBuffer []byte +} + +func (listener meekListener) Accept() (net.Conn, error) { + state := listener.state + state.lock.Lock() + defer state.lock.Unlock() + if state.availableSessions.Cardinality() == 0 { + return nil, errors.New("no connections available in accept") + } + sessionID := state.availableSessions.Pop() + sessionIDString, err := interconv.ParseString(sessionID) + if err != nil { + return nil, errors.New("could not convert sessionID to string") + } + return NewMeekServerConnection(state, sessionIDString), nil + +} + +//NewMeekServerConnection initializes the server connection +func NewMeekServerConnection(state *State, sessionID string) net.Conn { + session := state.sessionMap[sessionID] + return meekServerConn{session, state, sessionID} +} + +func (listener meekListener) Close() error { + return listener.server.Close() +} + +func (listener meekListener) Addr() net.Addr { + interfaces, _ := net.Interfaces() + addrs, _ := interfaces[0].Addrs() + return addrs[0] +} + +func (conn meekServerConn) Read(b []byte) (n int, err error) { + if len(conn.session.Or.readBuffer) == 0 { + return 0, nil + } + copy(b, conn.session.Or.readBuffer) + conn.session.Or.readBuffer = conn.session.Or.readBuffer[:0] + + return len(b), nil +} + +func (conn meekServerConn) Write(b []byte) (n int, err error) { + conn.session.Or.writeBuffer = append(conn.session.Or.writeBuffer, b...) + return len(b), nil +} + +func (conn meekServerConn) Close() error { + conn.state.CloseSession(conn.sessionID) + return nil +} + +//end critical importance +func (conn meekServerConn) LocalAddr() net.Addr { + return nil +} + +func (conn meekServerConn) RemoteAddr() net.Addr { + return nil +} + +func (conn meekServerConn) SetDeadline(time.Time) error { + return errors.New("unimplemented") +} + +func (conn meekServerConn) SetReadDeadline(time.Time) error { + return errors.New("unimplemented") +} + +func (conn meekServerConn) SetWriteDeadline(time.Time) error { + return errors.New("unimplemented") +} + +// NewMeekTransportServer is a public initializer method to get a new meek transport +func NewMeekTransportServer(disableTLS bool, acmeEmail string, acmeHostnamesCommas string, stateDir string) *MeekServer { + var certManager *autocert.Manager + if disableTLS { + if acmeEmail != "" || acmeHostnamesCommas != "" { + return nil + } + } else { + if acmeEmail == "" || acmeHostnamesCommas == "" { + return nil + } + if acmeHostnamesCommas != "" { + acmeHostnames := strings.Split(acmeHostnamesCommas, ",") + log.Printf("ACME hostnames: %q", acmeHostnames) + + // The ACME HTTP-01 responder only works when it is running on + // port 80. + // https://github.com/ietf-wg-acme/acme/blob/master/draft-ietf-acme-acme.md#http-challenge + + var cache autocert.Cache + cacheDir, err := getCertificateCacheDir(stateDir) + if err == nil { + log.Printf("caching ACME certificates in directory %q", cacheDir) + cache = autocert.DirCache(cacheDir) + } else { + log.Printf("disabling ACME certificate cache: %s", err) + } + + certManager = &autocert.Manager{ + Prompt: autocert.AcceptTOS, + HostPolicy: autocert.HostWhitelist(acmeHostnames...), + Email: acmeEmail, + Cache: cache, + } + } + } + return &MeekServer{disableTLS, acmeEmail, acmeHostnamesCommas, certManager} +} + +// Methods that implement the base.Transport interface + +// Listen on the meek transport does not have a corresponding server, only a client +func (transport *MeekServer) Listen(address string) net.Listener { + var ln net.Listener + var state *State + var err error + addr, resolverr := net.ResolveTCPAddr("tcp", address) + if resolverr != nil { + return ln + } + acmeAddr := net.TCPAddr{ + IP: addr.IP, + Port: 80, + Zone: "", + } + acmeAddr.Port = 80 + log.Printf("starting HTTP-01 ACME listener on %s", acmeAddr.String()) + lnHTTP01, err := net.ListenTCP("tcp", &acmeAddr) + if err != nil { + log.Printf("error opening HTTP-01 ACME listener: %s", err) + return nil + } + go func() { + log.Fatal(http.Serve(lnHTTP01, transport.CertManager.HTTPHandler(nil))) + }() + var server *http.Server + if transport.DisableTLS { + server, state, err = startServer(addr) + } else { + server, state, err = startServerTLS(addr, transport.CertManager.GetCertificate) + } + if err != nil { + + return nil + } + return meekListener{server, state} +} diff --git a/transports/meekserver/v3/useraddr.go b/transports/meekserver/v3/useraddr.go new file mode 100644 index 0000000..599ca6f --- /dev/null +++ b/transports/meekserver/v3/useraddr.go @@ -0,0 +1,50 @@ +package meekserver + +import ( + "fmt" + "net" + "net/http" + "strings" +) + +// Get the first hostname in an X-Forwarded-For header field value. +// +// The X-Forwarded-For header is set automatically by CDNs (and other proxies). +// There doesn't seem to be any formal specification of it. +// https://en.wikipedia.org/wiki/X-Forwarded-For says it was originally +// implemented in Squid. The format appears to be: one or more IPv4 or IPv6 +// addresses, without port numbers, separated by commas and optional whitespace. +// Because the format is unspecified, we only look at whatever is before the +// first comma (or end of string). +func getXForwardedFor(xForwardedFor string) (string, error) { + parts := strings.SplitN(xForwardedFor, ",", 2) + if len(parts) < 1 { + return "", fmt.Errorf("bad X-Forwarded-For value %q", xForwardedFor) + } + return strings.TrimSpace(parts[0]), nil +} + +// Return the original client IP address as best as it can be determined. +func originalClientIP(req *http.Request) (net.IP, error) { + var host string + var err error + + xForwardedFor := req.Header.Get("Meek-IP") + if xForwardedFor == "" { + xForwardedFor = req.Header.Get("X-Forwarded-For") + } + if xForwardedFor != "" { + host, err = getXForwardedFor(xForwardedFor) + } else { + host, _, err = net.SplitHostPort(req.RemoteAddr) + } + if err != nil { + return nil, err + } + + ip := net.ParseIP(host) + if ip == nil { + return nil, fmt.Errorf("cannot parse %q as IP address", host) + } + return ip, nil +} diff --git a/transports/meekserver/v3/useraddr_test.go b/transports/meekserver/v3/useraddr_test.go new file mode 100644 index 0000000..b37ec0c --- /dev/null +++ b/transports/meekserver/v3/useraddr_test.go @@ -0,0 +1,163 @@ +package meekserver + +import ( + "net" + "net/http" + "testing" +) + +func checkExpected(t *testing.T, req *http.Request, expected net.IP) { + ip, err := originalClientIP(req) + // If ip is nil, then err must not be nil; and if ip is not nil, then + // err must be nil. + if (ip == nil && err == nil) || (ip != nil && err != nil) { + t.Errorf("%v returned ip=%v and err=%v", req, ip, expected) + return + } + // Either both are nil or ip is equal to expected. + if (ip == nil && expected != nil) || + (ip != nil && !ip.Equal(expected)) { + t.Errorf("%v got %v, expected %v", req, ip, expected) + } +} + +// Test that in the absence of headers indicating the original client IP +// address, originalClientIP returns an answer based on RemoteAddr. +func TestOriginalClientIPRemoteAddr(t *testing.T) { + tests := []struct { + RemoteAddr string + Expected net.IP + }{ + {"", nil}, + {"1.2.3.4:1234", net.IPv4(1, 2, 3, 4)}, + {"[1:2::3:4]:1234", net.IP{0, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 4}}, + // Bad syntax. + {"1.2.3.4", nil}, + {"1:2::3:4:1234", nil}, + {"xyz", nil}, + } + + for _, test := range tests { + req := &http.Request{ + RemoteAddr: test.RemoteAddr, + } + checkExpected(t, req, test.Expected) + } +} + +// Test that originalClientIP reads the Meek-IP and X-Forwarded-For headers if +// present. +func TestOriginalClientXForwardedFor(t *testing.T) { + tests := []struct { + XForwardedFor string + Expected net.IP + }{ + {"", nil}, + {"1.2.3.4", net.IPv4(1, 2, 3, 4)}, + {"1:2::3:4", net.IP{0, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 4}}, + {"1.2.3.4,1:2::3:4", net.IPv4(1, 2, 3, 4)}, + {"1.2.3.4, 1:2::3:4", net.IPv4(1, 2, 3, 4)}, + {"1:2::3:4, 1.2.3.4", net.IP{0, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 4}}, + // Bad syntax. + {"xyz", nil}, + {"1.2.3.4:1234", nil}, + // Only try to parse the first element + {"1.2.3.4, xyz", net.IPv4(1, 2, 3, 4)}, + {"1.2.3.4,,,", net.IPv4(1, 2, 3, 4)}, + {"xyz, 1.2.3.4", nil}, + // X-Forwarded-For doesn't use square brackets on IPv6. + {"[1:2::3:4]", nil}, + {"[1:2::3:4]:1234", nil}, + } + + for _, test := range tests { + req := &http.Request{ + Header: make(http.Header), + } + req.Header.Set("Meek-IP", test.XForwardedFor) + checkExpected(t, req, test.Expected) + req.Header.Set("X-Forwarded-For", test.XForwardedFor) + checkExpected(t, req, test.Expected) + } +} + +// Test that headers prevent reading RemoteAddr, even if the headers cannot be +// parsed. +func TestOriginalClientPrecedence(t *testing.T) { + tests := []struct { + Req http.Request + Expected net.IP + }{ + { + http.Request{}, + nil, + }, + { + http.Request{ + RemoteAddr: "5.6.7.8:5678", + }, + net.IPv4(5, 6, 7, 8), + }, + { + http.Request{ + RemoteAddr: "5.6.7.8:5678", + Header: http.Header{ + http.CanonicalHeaderKey("Meek-IP"): []string{"1.2.3.4"}, + }, + }, + net.IPv4(1, 2, 3, 4), + }, + { + http.Request{ + RemoteAddr: "5.6.7.8:5678", + Header: http.Header{ + http.CanonicalHeaderKey("Meek-IP"): []string{"1:2::3:4"}, + }, + }, + net.IP{0, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 4}, + }, + { + http.Request{ + RemoteAddr: "5.6.7.8:5678", + Header: http.Header{ + http.CanonicalHeaderKey("X-Forwarded-For"): []string{"1.2.3.4"}, + }, + }, + net.IPv4(1, 2, 3, 4), + }, + { + http.Request{ + RemoteAddr: "5.6.7.8:5678", + Header: http.Header{ + http.CanonicalHeaderKey("X-Forwarded-For"): []string{"1:2::3:4"}, + }, + }, + net.IP{0, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 4}, + }, + // Meek-IP has precedence over X-Forwarded-For if both are set. + { + http.Request{ + RemoteAddr: "5.6.7.8:5678", + Header: http.Header{ + http.CanonicalHeaderKey("Meek-IP"): []string{"1.2.3.4"}, + http.CanonicalHeaderKey("X-Forwarded-For"): []string{"2.2.2.2"}, + }, + }, + net.IPv4(1, 2, 3, 4), + }, + // X-Forwarded-For shadows RemoteAddr, even if bad syntax. + { + http.Request{ + RemoteAddr: "5.6.7.8:5678", + Header: http.Header{ + http.CanonicalHeaderKey("X-Forwarded-For"): []string{"xyz"}, + }, + }, + nil, + }, + } + + for _, test := range tests { + checkExpected(t, &test.Req, test.Expected) + } +} diff --git a/transports/obfs2/v3/go.mod b/transports/obfs2/v3/go.mod new file mode 100644 index 0000000..9793304 --- /dev/null +++ b/transports/obfs2/v3/go.mod @@ -0,0 +1,11 @@ +module github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v2 + +go 1.12 + +require ( + github.com/OperatorFoundation/obfs4 v1.0.0 + github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0 + github.com/OperatorFoundation/shapeshifter-transports v0.0.0-20200211223228-5b0aa21018a5 + github.com/OperatorFoundation/shapeshifter-transports/transports/Optimizer/v2 v2.1.12 + golang.org/x/net v0.0.0-20200226121028-0de0cce0169b +) diff --git a/transports/obfs2/v3/go.sum b/transports/obfs2/v3/go.sum new file mode 100644 index 0000000..3f3e8e8 --- /dev/null +++ b/transports/obfs2/v3/go.sum @@ -0,0 +1,42 @@ +git.torproject.org/pluggable-transports/goptlib.git v1.1.0/go.mod h1:YT4XMSkuEXbtqlydr9+OxqFAyspUv0Gr9qhM3B++o/Q= +github.com/OperatorFoundation/ed25519 v0.0.0-20200225224545-b22b4bd3ddef h1:1xEtDEuNE9/yybZaHS94OIjx5FUo4e8M3UwcK9bFC9s= +github.com/OperatorFoundation/ed25519 v0.0.0-20200225224545-b22b4bd3ddef/go.mod h1:gQNGvsyT4Zmps9H/yzCqdc+RQzt8ZxCndRNtGTYnBzQ= +github.com/OperatorFoundation/obfs4 v0.0.0-20161108041644-17f2cb99c264 h1:8UbFvUSYrlcEU9W92tohq74kYvtXJo11WLI16TMi904= +github.com/OperatorFoundation/obfs4 v0.0.0-20161108041644-17f2cb99c264/go.mod h1:oxwvRzQ4FDp7ysA1En4F/pyOh2Jfef4YTo1YhHUsBOA= +github.com/OperatorFoundation/obfs4 v1.0.0 h1:OcfdNMzv69fKQrLTkTSwpaBkHyBZMLjigA5M3txZpAg= +github.com/OperatorFoundation/obfs4 v1.0.0/go.mod h1:6apgxOLYwyvbpzujpFHWu6Jlc+mjn1aFK7WvNijIVWc= +github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0 h1:zDYt6FDJwDSX4woVFVK2EMt7fkxU5L5qDNLUjQwA+BQ= +github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0/go.mod h1:kB00Ak8Dgn1uZlZHLc/WsUta58Jc+n/ZhCetcPkh42Q= +github.com/OperatorFoundation/shapeshifter-transports v0.0.0-20200211223228-5b0aa21018a5 h1:UrCgBKvfj+Rim1jAUkRqQt1neJgLVHtKt0228tEmFKY= +github.com/OperatorFoundation/shapeshifter-transports v0.0.0-20200211223228-5b0aa21018a5/go.mod h1:u3jvRgYV13oHabVAdXekh3yk9PHfpCKvB8uolQEs4jA= +github.com/OperatorFoundation/shapeshifter-transports v2.1.11+incompatible h1:Icbjg/r1BC9NlQ4yk0XVhjJ4PtWRwd1uS6IrvPSuje4= +github.com/OperatorFoundation/shapeshifter-transports/transports/Optimizer/v2 v2.1.12 h1:BCDQ0UhF4RGxK7eYIBW94uQpOCQvpYbMkdJxSX5s6ZE= +github.com/OperatorFoundation/shapeshifter-transports/transports/Optimizer/v2 v2.1.12/go.mod h1:+A6vQ50ZAHi76GOGtpH730VFirwb1p8E6VJM8M50gNk= +github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v2 v2.1.11 h1:LpSrJLqvqLG3dDK2/FJBMrNEq+Bez1V7kE5CTUYQvT8= +github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v2 v2.1.11/go.mod h1:yPCbCoTjLIG+p0xiuRDwW5t+DivxTHqGU5njf89AkHY= +github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2 v2.1.11 h1:YWL++KLcWh0t755gwZlc8p0DqDAIfWVLdISpoY7RFhw= +github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2 v2.1.11/go.mod h1:OUFBnkMmjMHTWqEQlanDOMTgBjU5QARjklwQv9Qovr4= +github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v2 v2.1.11 h1:gKY17mRkP/VvBWvXzLuivJpFXt0AxkVUx7pv4PX2sUs= +github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v2 v2.1.11/go.mod h1:GN8ahnEHVGcPbR0raxdpWekjgElppspPNAAOpmNxQxU= +github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da h1:KjTM2ks9d14ZYCvmHS9iAKVt9AyzRSqNU1qabPih5BY= +github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da/go.mod h1:eHEWzANqSiWQsof+nXEI9bUVUyV6F53Fp89EuCh2EAA= +github.com/agl/ed25519 v0.0.0-20200225211852-fd4d107ace12 h1:iPf1jQ8yKTms6k6L5vYSE7RZJpjEe5vLTOmzRZdpnKc= +github.com/dchest/siphash v1.2.1 h1:4cLinnzVJDKxTCl9B01807Yiy+W7ZzVHj/KIroQRvT4= +github.com/dchest/siphash v1.2.1/go.mod h1:q+IRvb2gOSrUnYoPqHiyHXS0FOBBOdl6tONBlVnOnt4= +github.com/shadowsocks/go-shadowsocks2 v0.0.11 h1:dXloqEhYnZV40jblWTK8kWeC0Eb+dgql4S0tj99e8j0= +github.com/shadowsocks/go-shadowsocks2 v0.0.11/go.mod h1:R+KWaoIwRRhnpw6XV+dZil0XHi64Hc1D7hXUyXTjUzQ= +github.com/willscott/goturn v0.0.0-20170802220503-19f41278d0c9/go.mod h1:PfwRjodCaQXOsHnh2DeVaXqCFCIrbn5WLj1+A5bQkD4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d h1:1ZiEyfaQIg3Qh0EoqpwAakHVhecoE5wlSg5GjnafJGw= +golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20200202094626-16171245cfb2 h1:CCH4IOTTfewWjGOlSp+zGcjutRKlBEZQ6wTn8ozI/nI= +golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b h1:0mm1VjtFUOIlE1SbDlwjYaDxZVDP2S5ou6y0gSgXHu8= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/transports/obfs2/v3/obfs2.go b/transports/obfs2/v3/obfs2.go new file mode 100644 index 0000000..1052fe7 --- /dev/null +++ b/transports/obfs2/v3/obfs2.go @@ -0,0 +1,431 @@ +/* + * Copyright (c) 2014, Yawning Angel + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +// Package obfs2 provides an implementation of the Tor Project's obfs2 +// obfuscation protocol. This protocol is considered trivially broken by most +// sophisticated adversaries. +package obfs2 + +import ( + "crypto/aes" + "crypto/cipher" + "crypto/sha256" + "encoding/binary" + "fmt" + + "io" + "net" + "time" + + "golang.org/x/net/proxy" + + "github.com/OperatorFoundation/obfs4/common/csrand" + "github.com/OperatorFoundation/shapeshifter-ipc" +) + +const ( + clientHandshakeTimeout = time.Duration(30) * time.Second + serverHandshakeTimeout = time.Duration(30) * time.Second + + magicValue = 0x2bf5ca7e + initiatorPadString = "Initiator obfuscation padding" + responderPadString = "Responder obfuscation padding" + initiatorKdfString = "Initiator obfuscated data" + responderKdfString = "Responder obfuscated data" + maxPadding = 8192 + keyLen = 16 + seedLen = 16 + hsLen = 4 + 4 +) + +//OptimizerTransport contains params needed for Optimizer +type OptimizerTransport struct { + Address string + Dialer proxy.Dialer +} + +//Dial connects to a specified address. +//this dial function is made to be Optimizer compatible +func (transport OptimizerTransport) Dial() (net.Conn, error) { + + dialFn := transport.Dialer.Dial + conn, dialErr := dialFn("tcp", transport.Address) + if dialErr != nil { + return nil, dialErr + } + + dialConn := conn + transportConn, err := newObfs2ClientConn(conn) + if err != nil { + _ = dialConn.Close() + return nil, err + } + + return transportConn, nil +} + +// Transport is the obfs2 implementation of the base.Transport interface. +type Transport struct { + dialer proxy.Dialer +} + +//New initializes obfs2 for Optimizer +func New(address string, dialer proxy.Dialer) *OptimizerTransport { + result := OptimizerTransport{ + Address: address, + Dialer: dialer, + } + return &result +} + +//NewObfs2Transport is the initializer for obfs2 without a dialer +func NewObfs2Transport() *Transport { + return &Transport{dialer: nil} +} + +//NewObfs2Transport is the initializer for obfs2 with a dialer +func NewObfs2TransportWithDialer(dialer proxy.Dialer) *Transport { + return &Transport{dialer: dialer} +} + +//obfs2TransportListener defines a TCP network listener. +type obfs2TransportListener struct { + listener *net.TCPListener +} + +//newObfs4TransportListener initializes the TCP network listener +func newObfs2TransportListener(listener *net.TCPListener) *obfs2TransportListener { + return &obfs2TransportListener{listener: listener} +} + +// Dial creates outgoing transport connection +func (transport *Transport) Dial(address string) (net.Conn, error) { + var dialFn func(string, string) (net.Conn, error) + if transport.dialer != nil { + dialerValue := transport.dialer + dialFn = dialerValue.Dial + } else { + dialFn = proxy.Direct.Dial + } + conn, dialErr := dialFn("tcp", address) + if dialErr != nil { + return nil, dialErr + } + + dialConn := conn + transportConn, err := newObfs2ClientConn(conn) + if err != nil { + _ = dialConn.Close() + return nil, err + } + + return transportConn, nil +} + +// Listen creates listener for incoming transport connection +func (transport *Transport) Listen(address string) net.Listener { + addr, resolveErr := pt.ResolveAddr(address) + if resolveErr != nil { + fmt.Println(resolveErr.Error()) + return nil + } + + ln, err := net.ListenTCP("tcp", addr) + if err != nil { + fmt.Println(err.Error()) + return nil + } + + return newObfs2TransportListener(ln) +} + +// Methods that implement the net.Conn interface +func (transportConn *obfs2Conn) NetworkConn() net.Conn { + return transportConn +} + +// Methods that implement the net.Listener interface +// Listener for underlying network connection +func (listener *obfs2TransportListener) NetworkListener() net.Listener { + return listener.listener +} + +// Accept waits for and returns the next connection to the listener. +func (listener *obfs2TransportListener) Accept() (net.Conn, error) { + conn, err := listener.listener.Accept() + if err != nil { + return nil, err + } + + return newObfs2ServerConn(conn) +} + +func (listener *obfs2TransportListener) Addr() net.Addr { + interfaces, _ := net.Interfaces() + addrs, _ := interfaces[0].Addrs() + return addrs[0] +} + +// Close closes the transport listener. +// Any blocked Accept operations will be unblocked and return errors. +func (listener *obfs2TransportListener) Close() error { + return listener.listener.Close() +} + +type obfs2Conn struct { + net.Conn + + isInitiator bool + + rx *cipher.StreamReader + tx *cipher.StreamWriter +} + +func (transportConn *obfs2Conn) Read(b []byte) (int, error) { + return transportConn.rx.Read(b) +} + +func (transportConn *obfs2Conn) Write(b []byte) (int, error) { + return transportConn.tx.Write(b) +} + +func newObfs2ClientConn(conn net.Conn) (c *obfs2Conn, err error) { + // Initialize a client connection, and start the handshake timeout. + c = &obfs2Conn{conn, true, nil, nil} + deadline := time.Now().Add(clientHandshakeTimeout) + if err = c.SetDeadline(deadline); err != nil { + return nil, err + } + + // Handshake. + if err = c.handshake(); err != nil { + return nil, err + } + + // Disarm the handshake timer. + if err = c.SetDeadline(time.Time{}); err != nil { + return nil, err + } + + return +} + +func newObfs2ServerConn(conn net.Conn) (c *obfs2Conn, err error) { + // Initialize a server connection, and start the handshake timeout. + c = &obfs2Conn{conn, false, nil, nil} + deadline := time.Now().Add(serverHandshakeTimeout) + if err = c.SetDeadline(deadline); err != nil { + return nil, err + } + + // Handshake. + if err = c.handshake(); err != nil { + return nil, err + } + + // Disarm the handshake timer. + if err = c.SetDeadline(time.Time{}); err != nil { + return nil, err + } + + return +} + +func (transportConn *obfs2Conn) handshake() error { + // Each begins by generating a seed and a padding key as follows. + // The initiator generates: + // + // INIT_SEED = SR(SEED_LENGTH) + // INIT_PAD_KEY = MAC("Initiator obfuscation padding", INIT_SEED)[:KEYLEN] + // + // And the responder generates: + // + // RESP_SEED = SR(SEED_LENGTH) + // RESP_PAD_KEY = MAC("Responder obfuscation padding", INIT_SEED)[:KEYLEN] + // + // Each then generates a random number PADLEN in range from 0 through + // MAX_PADDING (inclusive). + var seed [seedLen]byte + if err := csrand.Bytes(seed[:]); err != nil { + return err + } + var padMagic []byte + if transportConn.isInitiator { + padMagic = []byte(initiatorPadString) + } else { + padMagic = []byte(responderPadString) + } + padKey, padIV := hsKdf(padMagic, seed[:]) + padLen := uint32(csrand.IntRange(0, maxPadding)) + + hsBlob := make([]byte, hsLen+padLen) + binary.BigEndian.PutUint32(hsBlob[0:4], magicValue) + binary.BigEndian.PutUint32(hsBlob[4:8], padLen) + if padLen > 0 { + if err := csrand.Bytes(hsBlob[8:]); err != nil { + return err + } + } + + // The initiator then sends: + // + // INIT_SEED | E(INIT_PAD_KEY, UINT32(MAGIC_VALUE) | UINT32(PADLEN) | WR(PADLEN)) + // + // and the responder sends: + // + // RESP_SEED | E(RESP_PAD_KEY, UINT32(MAGIC_VALUE) | UINT32(PADLEN) | WR(PADLEN)) + txBlock, err := aes.NewCipher(padKey) + if err != nil { + return err + } + txStream := cipher.NewCTR(txBlock, padIV) + transportConn.tx = &cipher.StreamWriter{S: txStream, W: transportConn.Conn} + if _, err := transportConn.Conn.Write(seed[:]); err != nil { + return err + } + if _, err := transportConn.Write(hsBlob); err != nil { + return err + } + + // Upon receiving the SEED from the other party, each party derives + // the other party's padding key value as above, and decrypts the next + // 8 bytes of the key establishment message. + var peerSeed [seedLen]byte + if _, err := io.ReadFull(transportConn.Conn, peerSeed[:]); err != nil { + return err + } + var peerPadMagic []byte + if transportConn.isInitiator { + peerPadMagic = []byte(responderPadString) + } else { + peerPadMagic = []byte(initiatorPadString) + } + peerKey, peerIV := hsKdf(peerPadMagic, peerSeed[:]) + rxBlock, err := aes.NewCipher(peerKey) + if err != nil { + return err + } + rxStream := cipher.NewCTR(rxBlock, peerIV) + transportConn.rx = &cipher.StreamReader{S: rxStream, R: transportConn.Conn} + hsHdr := make([]byte, hsLen) + if _, err := io.ReadFull(transportConn, hsHdr[:]); err != nil { + return err + } + + // If the MAGIC_VALUE does not match, or the PADLEN value is greater than + // MAX_PADDING, the party receiving it should close the connection + // immediately. + if peerMagic := binary.BigEndian.Uint32(hsHdr[0:4]); peerMagic != magicValue { + return fmt.Errorf("invalid magic value: %x", peerMagic) + } + padLen = binary.BigEndian.Uint32(hsHdr[4:8]) + if padLen > maxPadding { + return fmt.Errorf("padlen too long: %d", padLen) + } + + // Otherwise, it should read the remaining PADLEN bytes of padding data + // and discard them. + tmp := make([]byte, padLen) + if _, err := io.ReadFull(transportConn.Conn, tmp); err != nil { // Note: Skips AES. + return err + } + + // Derive the actual keys. + if err := transportConn.kdf(seed[:], peerSeed[:]); err != nil { + return err + } + + return nil +} + +func (transportConn *obfs2Conn) kdf(seed, peerSeed []byte) error { + // Additional keys are then derived as: + // + // INIT_SECRET = MAC("Initiator obfuscated data", INIT_SEED|RESP_SEED) + // RESP_SECRET = MAC("Responder obfuscated data", INIT_SEED|RESP_SEED) + // INIT_KEY = INIT_SECRET[:KEYLEN] + // INIT_IV = INIT_SECRET[KEYLEN:] + // RESP_KEY = RESP_SECRET[:KEYLEN] + // RESP_IV = RESP_SECRET[KEYLEN:] + combSeed := make([]byte, 0, seedLen*2) + if transportConn.isInitiator { + combSeed = append(combSeed, seed...) + combSeed = append(combSeed, peerSeed...) + } else { + combSeed = append(combSeed, peerSeed...) + combSeed = append(combSeed, seed...) + } + + initKey, initIV := hsKdf([]byte(initiatorKdfString), combSeed) + initBlock, err := aes.NewCipher(initKey) + if err != nil { + return err + } + initStream := cipher.NewCTR(initBlock, initIV) + + respKey, respIV := hsKdf([]byte(responderKdfString), combSeed) + respBlock, err := aes.NewCipher(respKey) + if err != nil { + return err + } + respStream := cipher.NewCTR(respBlock, respIV) + + if transportConn.isInitiator { + transportConn.tx.S = initStream + transportConn.rx.S = respStream + } else { + transportConn.tx.S = respStream + transportConn.rx.S = initStream + } + + return nil +} + +func hsKdf(magic, seed []byte) (padKey, padIV []byte) { + // The actual key/IV is derived in the form of: + // m = MAC(magic, seed) + // KEY = m[:KEYLEN] + // IV = m[KEYLEN:] + m := mac(magic, seed) + padKey = m[:keyLen] + padIV = m[keyLen:] + + return +} + +func mac(s, x []byte) []byte { + // H(x) is SHA256 of x. + // MAC(s, x) = H(s | x | s) + h := sha256.New() + h.Write(s) + h.Write(x) + h.Write(s) + return h.Sum(nil) +} + +var _ net.Listener = (*obfs2TransportListener)(nil) +var _ net.Conn = (*obfs2Conn)(nil) diff --git a/transports/obfs2/v3/obfs2_test.go b/transports/obfs2/v3/obfs2_test.go new file mode 100644 index 0000000..c118e07 --- /dev/null +++ b/transports/obfs2/v3/obfs2_test.go @@ -0,0 +1,160 @@ +/* + * Copyright (c) 2014, Yawning Angel + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +// Package obfs2 provides an implementation of the Tor Project's obfs2 +// obfuscation protocol. This protocol is considered trivially broken by most +// sophisticated adversaries. + +package obfs2 + +import ( + "golang.org/x/net/proxy" + "os" + "testing" +) + +const data = "test" + +func TestMain(m *testing.M) { + RunLocalObfs2Server() + os.Exit(m.Run()) +} + +func TestObfs2(t *testing.T) { + config := NewObfs2Transport() + //create client buffer + clientBuffer := make([]byte, 4) + //call dial on client and check error + clientConn, dialErr := config.Dial("127.0.0.1:1237") + if dialErr != nil { + t.Fail() + return + } + + //write data from clientConn for server to read + _, clientWriteErr := clientConn.Write([]byte(data)) + if clientWriteErr != nil { + t.Fail() + return + } + + //read on client side + _, clientReadErr := clientConn.Read(clientBuffer) + if clientReadErr != nil { + t.Fail() + return + } +} + +func TestObfs2WithDialer(t *testing.T) { + config := NewObfs2TransportWithDialer(proxy.Direct) + //create client buffer + clientBuffer := make([]byte, 4) + //call dial on client and check error + clientConn, dialErr := config.Dial("127.0.0.1:1237") + if dialErr != nil { + t.Fail() + return + } + + //write data from clientConn for server to read + _, clientWriteErr := clientConn.Write([]byte(data)) + if clientWriteErr != nil { + t.Fail() + return + } + + //read on client side + _, clientReadErr := clientConn.Read(clientBuffer) + if clientReadErr != nil { + t.Fail() + return + } +} + +func TestObfs2OptimizerTransportWithDialer(t *testing.T) { + config := New("127.0.0.1:1237", proxy.Direct) + //create client buffer + clientBuffer := make([]byte, 4) + //call dial on client and check error + clientConn, dialErr := config.Dial() + if dialErr != nil { + t.Fail() + return + } + + //write data from clientConn for server to read + _, clientWriteErr := clientConn.Write([]byte(data)) + if clientWriteErr != nil { + t.Fail() + return + } + + //read on client side + _, clientReadErr := clientConn.Read(clientBuffer) + if clientReadErr != nil { + t.Fail() + return + } +} + +func RunLocalObfs2Server() { + //create a server + config := NewObfs2Transport() + + //call listen on the server + serverListener := config.Listen("127.0.0.1:1237") + if serverListener == nil { + return + } + + //Create Server connection and format it for concurrency + go func() { + //create server buffer + serverBuffer := make([]byte, 4) + + //create serverConn + for { + serverConn, acceptErr := serverListener.Accept() + if acceptErr != nil { + return + } + + //read on server side + _, serverReadErr := serverConn.Read(serverBuffer) + if serverReadErr != nil { + return + } + + //write data from serverConn for client to read + _, serverWriteErr := serverConn.Write([]byte(data)) + if serverWriteErr != nil { + return + } + } + }() +} \ No newline at end of file diff --git a/transports/obfs4/v3/README.md b/transports/obfs4/v3/README.md new file mode 100644 index 0000000..6894167 --- /dev/null +++ b/transports/obfs4/v3/README.md @@ -0,0 +1,31 @@ +# obfs4 + + +This is a look-like nothing obfuscation protocol that incorporates ideas and concepts from Philipp Winter's ScrambleSuit protocol. The obfs naming was chosen primarily because it was shorter, in terms of protocol ancestery obfs4 is much closer to ScrambleSuit than obfs2/obfs3. + +The notable differences between ScrambleSuit and obfs4: + +* The handshake always does a full key exchange (no such thing as a Session Ticket Handshake). +* The handshake uses the Tor Project's ntor handshake with public keys obfuscated via the Elligator 2 mapping. +* The link layer encryption uses NaCl secret boxes (Poly1305/XSalsa20). +* As an added bonus, obfs4proxy also supports acting as an obfs2/3 client and bridge to ease the transition to the new protocol. + +## Using obfs4 + + +### Go Version: + +obfs4 is one of the transports available in the [Shapeshifter-Transports library](https://github.com/OperatorFoundation/Shapeshifter-Transports). + +1. First, you need to create a dialer + `dialer := proxy.Direct` + +2. Create an instance of an obfs4 server + `obfs4Transport := obfs4.Transport{ + CertString: "InsertCertStringHere", + IatMode: 0 or 1, + Address: "InsertAddressHere", + Dialer: dialer,}` + +5. Call Dial on obfs4Transport: + `_, err := obfs4Transport.Dial()` diff --git a/transports/obfs4/v3/framing/framing.go b/transports/obfs4/v3/framing/framing.go new file mode 100644 index 0000000..636d6c6 --- /dev/null +++ b/transports/obfs4/v3/framing/framing.go @@ -0,0 +1,306 @@ +/* + * Copyright (c) 2014, Yawning Angel + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +// +// Package framing implements the obfs4 link framing and cryptography. +// +// The Encoder/Decoder shared secret format is: +// uint8_t[32] NaCl secretbox key +// uint8_t[16] NaCl Nonce prefix +// uint8_t[16] SipHash-2-4 key (used to obfuscate length) +// uint8_t[8] SipHash-2-4 IV +// +// The frame format is: +// uint16_t length (obfsucated, big endian) +// NaCl secretbox (Poly1305/XSalsa20) containing: +// uint8_t[16] tag (Part of the secretbox construct) +// uint8_t[] payload +// +// The length field is length of the NaCl secretbox XORed with the truncated +// SipHash-2-4 digest ran in OFB mode. +// +// Initialize K, IV[0] with values from the shared secret. +// On each packet, IV[n] = H(K, IV[n - 1]) +// mask[n] = IV[n][0:2] +// obfsLen = length ^ mask[n] +// +// The NaCl secretbox (Poly1305/XSalsa20) nonce format is: +// uint8_t[24] prefix (Fixed) +// uint64_t counter (Big endian) +// +// The counter is initialized to 1, and is incremented on each frame. Since +// the protocol is designed to be used over a reliable medium, the nonce is not +// transmitted over the wire as both sides of the conversation know the prefix +// and the initial counter value. It is imperative that the counter does not +// wrap, and sessions MUST terminate before 2^64 frames are sent. +// +package framing + +import ( + "bytes" + "encoding/binary" + "errors" + "fmt" + "io" + + "golang.org/x/crypto/nacl/secretbox" + + "github.com/OperatorFoundation/obfs4/common/csrand" + "github.com/OperatorFoundation/obfs4/common/drbg" +) + +const ( + // MaximumSegmentLength is the length of the largest possible segment + // including overhead. + MaximumSegmentLength = 1500 - (40 + 12) + + lengthLength = 2 + + // FrameOverhead is the length of the framing overhead. + FrameOverhead = lengthLength + secretbox.Overhead + + // MaximumFramePayloadLength is the length of the maximum allowed payload + // per frame. + MaximumFramePayloadLength = MaximumSegmentLength - FrameOverhead + + // KeyLength is the length of the Encoder/Decoder secret key. + KeyLength = keyLength + noncePrefixLength + drbg.SeedLength + + maxFrameLength = MaximumSegmentLength - lengthLength + minFrameLength = FrameOverhead - lengthLength + + keyLength = 32 + + noncePrefixLength = 16 + nonceCounterLength = 8 + nonceLength = noncePrefixLength + nonceCounterLength +) + +// Error returned when Decoder.Decode() requires more data to continue. +var ErrAgain = errors.New("framing: More data needed to decode") + +// Error returned when Decoder.Decode() fails to authenticate a frame. +var ErrTagMismatch = errors.New("framing: Poly1305 tag mismatch") + +// Error returned when the NaCl secretbox nonce's counter wraps (FATAL). +var ErrNonceCounterWrapped = errors.New("framing: Nonce counter wrapped") + +// InvalidPayloadLengthError is the error returned when Encoder.Encode() +// rejects the payload length. +type InvalidPayloadLengthError int + +func (e InvalidPayloadLengthError) Error() string { + return fmt.Sprintf("framing: Invalid payload length: %d", int(e)) +} + +type boxNonce struct { + prefix [noncePrefixLength]byte + counter uint64 +} + +func (nonce *boxNonce) init(prefix []byte) { + if noncePrefixLength != len(prefix) { + panic(fmt.Sprintf("BUG: Nonce prefix length invalid: %d", len(prefix))) + } + + copy(nonce.prefix[:], prefix) + nonce.counter = 1 +} + +func (nonce boxNonce) bytes(out *[nonceLength]byte) error { + // The security guarantee of Poly1305 is broken if a nonce is ever reused + // for a given key. Detect this by checking for counter wraparound since + // we start each counter at 1. If it ever happens that more than 2^64 - 1 + // frames are transmitted over a given connection, support for rekeying + // will be necessary, but that's unlikely to happen. + if nonce.counter == 0 { + return ErrNonceCounterWrapped + } + + copy(out[:], nonce.prefix[:]) + binary.BigEndian.PutUint64(out[noncePrefixLength:], nonce.counter) + + return nil +} + +// Encoder is a frame encoder instance. +type Encoder struct { + key [keyLength]byte + nonce boxNonce + drbg *drbg.HashDrbg +} + +// NewEncoder creates a new Encoder instance. It must be supplied a slice +// containing exactly KeyLength bytes of keying material. +func NewEncoder(key []byte) *Encoder { + if len(key) != KeyLength { + panic(fmt.Sprintf("BUG: Invalid encoder key length: %d", len(key))) + } + + encoder := new(Encoder) + copy(encoder.key[:], key[0:keyLength]) + encoder.nonce.init(key[keyLength : keyLength+noncePrefixLength]) + seed, err := drbg.SeedFromBytes(key[keyLength+noncePrefixLength:]) + if err != nil { + panic(fmt.Sprintf("BUG: Failed to initialize DRBG: %s", err)) + } + encoder.drbg, _ = drbg.NewHashDrbg(seed) + + return encoder +} + +// Encode encodes a single frame worth of payload and returns the encoded +// length. InvalidPayloadLengthError is recoverable, all other errors MUST be +// treated as fatal and the session aborted. +func (encoder *Encoder) Encode(frame, payload []byte) (n int, err error) { + payloadLen := len(payload) + if MaximumFramePayloadLength < payloadLen { + return 0, InvalidPayloadLengthError(payloadLen) + } + if len(frame) < payloadLen+FrameOverhead { + return 0, io.ErrShortBuffer + } + + // Generate a new nonce. + var nonce [nonceLength]byte + if err = encoder.nonce.bytes(&nonce); err != nil { + return 0, err + } + encoder.nonce.counter++ + + // Encrypt and MAC payload. + box := secretbox.Seal(frame[:lengthLength], payload, &nonce, &encoder.key) + + // Obfuscate the length. + length := uint16(len(box) - lengthLength) + lengthMask := encoder.drbg.NextBlock() + length ^= binary.BigEndian.Uint16(lengthMask) + binary.BigEndian.PutUint16(frame[:2], length) + + // Return the frame. + return len(box), nil +} + +// Decoder is a frame decoder instance. +type Decoder struct { + key [keyLength]byte + nonce boxNonce + drbg *drbg.HashDrbg + + nextNonce [nonceLength]byte + nextLength uint16 + nextLengthInvalid bool +} + +// NewDecoder creates a new Decoder instance. It must be supplied a slice +// containing exactly KeyLength bytes of keying material. +func NewDecoder(key []byte) *Decoder { + if len(key) != KeyLength { + panic(fmt.Sprintf("BUG: Invalid decoder key length: %d", len(key))) + } + + decoder := new(Decoder) + copy(decoder.key[:], key[0:keyLength]) + decoder.nonce.init(key[keyLength : keyLength+noncePrefixLength]) + seed, err := drbg.SeedFromBytes(key[keyLength+noncePrefixLength:]) + if err != nil { + panic(fmt.Sprintf("BUG: Failed to initialize DRBG: %s", err)) + } + decoder.drbg, _ = drbg.NewHashDrbg(seed) + + return decoder +} + +// Decode decodes a stream of data and returns the length if any. ErrAgain is +// a temporary failure, all other errors MUST be treated as fatal and the +// session aborted. +func (decoder *Decoder) Decode(data []byte, frames *bytes.Buffer) (int, error) { + // A length of 0 indicates that we do not know how big the next frame is + // going to be. + if decoder.nextLength == 0 { + // Attempt to pull out the next frame length. + if lengthLength > frames.Len() { + return 0, ErrAgain + } + + // Remove the length field from the buffer. + var obfsLen [lengthLength]byte + _, err := io.ReadFull(frames, obfsLen[:]) + if err != nil { + return 0, err + } + + // Derive the nonce the peer used. + if err = decoder.nonce.bytes(&decoder.nextNonce); err != nil { + return 0, err + } + + // Deobfuscate the length field. + length := binary.BigEndian.Uint16(obfsLen[:]) + lengthMask := decoder.drbg.NextBlock() + length ^= binary.BigEndian.Uint16(lengthMask) + if maxFrameLength < length || minFrameLength > length { + // Per "Plaintext Recovery Attacks Against SSH" by + // Martin R. Albrecht, Kenneth G. Paterson and Gaven J. Watson, + // there are a class of attacks against protocols that use similar + // sorts of framing schemes. + // + // While obfs4 should not allow plaintext recovery (CBC mode is + // not used), attempt to mitigate out of bound frame length errors + // by pretending that the length was a random valid range as per + // the countermeasure suggested by Denis Bider in section 6 of the + // paper. + + decoder.nextLengthInvalid = true + length = uint16(csrand.IntRange(minFrameLength, maxFrameLength)) + } + decoder.nextLength = length + } + + if int(decoder.nextLength) > frames.Len() { + return 0, ErrAgain + } + + // Unseal the frame. + var box [maxFrameLength]byte + n, err := io.ReadFull(frames, box[:decoder.nextLength]) + if err != nil { + return 0, err + } + out, ok := secretbox.Open(data[:0], box[:n], &decoder.nextNonce, &decoder.key) + if !ok || decoder.nextLengthInvalid { + // When a random length is used (on length error) the tag should always + // mismatch, but be paranoid. + return 0, ErrTagMismatch + } + + // Clean up and prepare for the next frame. + decoder.nextLength = 0 + decoder.nonce.counter++ + + return len(out), nil +} diff --git a/transports/obfs4/v3/framing/framing_test.go b/transports/obfs4/v3/framing/framing_test.go new file mode 100644 index 0000000..1c31165 --- /dev/null +++ b/transports/obfs4/v3/framing/framing_test.go @@ -0,0 +1,169 @@ +/* + * Copyright (c) 2014, Yawning Angel + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +package framing + +import ( + "bytes" + "crypto/rand" + "testing" +) + +func generateRandomKey() []byte { + key := make([]byte, KeyLength) + + _, err := rand.Read(key) + if err != nil { + panic(err) + } + + return key +} + +func newEncoder(t *testing.T) *Encoder { + // Generate a key to use. + key := generateRandomKey() + + encoder := NewEncoder(key) + if encoder == nil { + t.Fatalf("NewEncoder returned nil") + } + + return encoder +} + +// TestNewEncoder tests the Encoder ctor. +func TestNewEncoder(t *testing.T) { + encoder := newEncoder(t) + _ = encoder +} + +// TestEncoder_Encode tests Encoder.Encode. +func TestEncoder_Encode(t *testing.T) { + encoder := newEncoder(t) + + buf := make([]byte, MaximumFramePayloadLength) + _, _ = rand.Read(buf) // YOLO + for i := 0; i <= MaximumFramePayloadLength; i++ { + var frame [MaximumSegmentLength]byte + n, err := encoder.Encode(frame[:], buf[0:i]) + if err != nil { + t.Fatalf("Encoder.encode([%d]byte), failed: %s", i, err) + } + if n != i+FrameOverhead { + t.Fatalf("Unexpected encoded framesize: %d, expecting %d", n, i+ + FrameOverhead) + } + } +} + +// TestEncoder_Encode_Oversize tests oversized frame rejection. +func TestEncoder_Encode_Oversize(t *testing.T) { + encoder := newEncoder(t) + + var frame [MaximumSegmentLength]byte + var buf [MaximumFramePayloadLength + 1]byte + _, _ = rand.Read(buf[:]) // YOLO + _, err := encoder.Encode(frame[:], buf[:]) + if _, ok := err.(InvalidPayloadLengthError); !ok { + t.Error("Encoder.encode() returned unexpected error:", err) + } +} + +// TestNewDecoder tests the Decoder ctor. +func TestNewDecoder(t *testing.T) { + key := generateRandomKey() + decoder := NewDecoder(key) + if decoder == nil { + t.Fatalf("NewDecoder returned nil") + } +} + +// TestDecoder_Decode tests Decoder.Decode. +func TestDecoder_Decode(t *testing.T) { + key := generateRandomKey() + + encoder := NewEncoder(key) + decoder := NewDecoder(key) + + var buf [MaximumFramePayloadLength]byte + _, _ = rand.Read(buf[:]) // YOLO + for i := 0; i <= MaximumFramePayloadLength; i++ { + var frame [MaximumSegmentLength]byte + encLen, err := encoder.Encode(frame[:], buf[0:i]) + if err != nil { + t.Fatalf("Encoder.encode([%d]byte), failed: %s", i, err) + } + if encLen != i+FrameOverhead { + t.Fatalf("Unexpected encoded framesize: %d, expecting %d", encLen, + i+FrameOverhead) + } + + var decoded [MaximumFramePayloadLength]byte + + decLen, err := decoder.Decode(decoded[:], bytes.NewBuffer(frame[:encLen])) + if err != nil { + t.Fatalf("Decoder.decode([%d]byte), failed: %s", i, err) + } + if decLen != i { + t.Fatalf("Unexpected decoded framesize: %d, expecting %d", + decLen, i) + } + + if 0 != bytes.Compare(decoded[:decLen], buf[:i]) { + t.Fatalf("Frame %d does not match encoder input", i) + } + } +} + +// BenchmarkEncoder_Encode benchmarks Encoder.Encode processing 1 MiB +// of payload. +func BenchmarkEncoder_Encode(b *testing.B) { + var chopBuf [MaximumFramePayloadLength]byte + var frame [MaximumSegmentLength]byte + payload := make([]byte, 1024*1024) + encoder := NewEncoder(generateRandomKey()) + b.ResetTimer() + + for i := 0; i < b.N; i++ { + transferred := 0 + buffer := bytes.NewBuffer(payload) + for 0 < buffer.Len() { + n, err := buffer.Read(chopBuf[:]) + if err != nil { + b.Fatal("buffer.Read() failed:", err) + } + + n, err = encoder.Encode(frame[:], chopBuf[:n]) + transferred += n - FrameOverhead + } + if transferred != len(payload) { + b.Fatalf("Transfered length mismatch: %d != %d", transferred, + len(payload)) + } + } +} diff --git a/transports/obfs4/v3/go.mod b/transports/obfs4/v3/go.mod new file mode 100644 index 0000000..68baf42 --- /dev/null +++ b/transports/obfs4/v3/go.mod @@ -0,0 +1,10 @@ +module github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2 + +go 1.12 + +require ( + github.com/OperatorFoundation/obfs4 v1.0.0 + github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0 + golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d + golang.org/x/net v0.0.0-20200226121028-0de0cce0169b +) diff --git a/transports/obfs4/v3/go.sum b/transports/obfs4/v3/go.sum new file mode 100644 index 0000000..8a6f976 --- /dev/null +++ b/transports/obfs4/v3/go.sum @@ -0,0 +1,20 @@ +git.torproject.org/pluggable-transports/goptlib.git v1.1.0/go.mod h1:YT4XMSkuEXbtqlydr9+OxqFAyspUv0Gr9qhM3B++o/Q= +github.com/OperatorFoundation/ed25519 v0.0.0-20200225224545-b22b4bd3ddef h1:1xEtDEuNE9/yybZaHS94OIjx5FUo4e8M3UwcK9bFC9s= +github.com/OperatorFoundation/ed25519 v0.0.0-20200225224545-b22b4bd3ddef/go.mod h1:gQNGvsyT4Zmps9H/yzCqdc+RQzt8ZxCndRNtGTYnBzQ= +github.com/OperatorFoundation/obfs4 v1.0.0 h1:OcfdNMzv69fKQrLTkTSwpaBkHyBZMLjigA5M3txZpAg= +github.com/OperatorFoundation/obfs4 v1.0.0/go.mod h1:6apgxOLYwyvbpzujpFHWu6Jlc+mjn1aFK7WvNijIVWc= +github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0 h1:zDYt6FDJwDSX4woVFVK2EMt7fkxU5L5qDNLUjQwA+BQ= +github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0/go.mod h1:kB00Ak8Dgn1uZlZHLc/WsUta58Jc+n/ZhCetcPkh42Q= +github.com/dchest/siphash v1.2.1 h1:4cLinnzVJDKxTCl9B01807Yiy+W7ZzVHj/KIroQRvT4= +github.com/dchest/siphash v1.2.1/go.mod h1:q+IRvb2gOSrUnYoPqHiyHXS0FOBBOdl6tONBlVnOnt4= +github.com/willscott/goturn v0.0.0-20170802220503-19f41278d0c9/go.mod h1:PfwRjodCaQXOsHnh2DeVaXqCFCIrbn5WLj1+A5bQkD4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d h1:1ZiEyfaQIg3Qh0EoqpwAakHVhecoE5wlSg5GjnafJGw= +golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b h1:0mm1VjtFUOIlE1SbDlwjYaDxZVDP2S5ou6y0gSgXHu8= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/transports/obfs4/v3/handshake_ntor.go b/transports/obfs4/v3/handshake_ntor.go new file mode 100644 index 0000000..6ff9624 --- /dev/null +++ b/transports/obfs4/v3/handshake_ntor.go @@ -0,0 +1,424 @@ +/* + * Copyright (c) 2014, Yawning Angel + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +package obfs4 + +import ( + "bytes" + "crypto/hmac" + "crypto/sha256" + "encoding/hex" + "errors" + "fmt" + "hash" + "strconv" + "time" + + "github.com/OperatorFoundation/obfs4/common/csrand" + "github.com/OperatorFoundation/obfs4/common/ntor" + "github.com/OperatorFoundation/obfs4/common/replayfilter" + "github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2/framing" +) + +const ( + maxHandshakeLength = 8192 + + clientMinPadLength = (serverMinHandshakeLength + inlineSeedFrameLength) - + clientMinHandshakeLength + clientMaxPadLength = maxHandshakeLength - clientMinHandshakeLength + clientMinHandshakeLength = ntor.RepresentativeLength + markLength + macLength + + serverMinPadLength = 0 + serverMaxPadLength = maxHandshakeLength - (serverMinHandshakeLength + + inlineSeedFrameLength) + serverMinHandshakeLength = ntor.RepresentativeLength + ntor.AuthLength + + markLength + macLength + + markLength = sha256.Size / 2 + macLength = sha256.Size / 2 + + inlineSeedFrameLength = framing.FrameOverhead + packetOverhead + seedPacketPayloadLength +) + +// ErrMarkNotFoundYet is the error returned when the obfs4 handshake is +// incomplete and requires more data to continue. This error is non-fatal and +// is the equivalent to EAGAIN/EWOULDBLOCK. +var ErrMarkNotFoundYet = errors.New("handshake: M_[C,S] not found yet") + +// ErrInvalidHandshake is the error returned when the obfs4 handshake fails due +// to the peer not sending the correct mark. This error is fatal and the +// connection MUST be dropped. +var ErrInvalidHandshake = errors.New("handshake: Failed to find M_[C,S]") + +// ErrReplayedHandshake is the error returned when the obfs4 handshake fails +// due it being replayed. This error is fatal and the connection MUST be +// dropped. +var ErrReplayedHandshake = errors.New("handshake: Replay detected") + +// ErrNtorFailed is the error returned when the ntor handshake fails. This +// error is fatal and the connection MUST be dropped. +var ErrNtorFailed = errors.New("handshake: ntor handshake failure") + +// InvalidMacError is the error returned when the handshake MACs do not match. +// This error is fatal and the connection MUST be dropped. +type InvalidMacError struct { + Derived []byte + Received []byte +} + +func (e *InvalidMacError) Error() string { + return fmt.Sprintf("handshake: MAC mismatch: Dervied: %s Received: %s.", + hex.EncodeToString(e.Derived), hex.EncodeToString(e.Received)) +} + +// InvalidAuthError is the error returned when the ntor AUTH tags do not match. +// This error is fatal and the connection MUST be dropped. +type InvalidAuthError struct { + Derived *ntor.Auth + Received *ntor.Auth +} + +func (e *InvalidAuthError) Error() string { + return fmt.Sprintf("handshake: ntor AUTH mismatch: Derived: %s Received:%s.", + hex.EncodeToString(e.Derived.Bytes()[:]), + hex.EncodeToString(e.Received.Bytes()[:])) +} + +type clientHandshake struct { + keypair *ntor.Keypair + nodeID *ntor.NodeID + serverIdentity *ntor.PublicKey + epochHour []byte + + padLen int + mac hash.Hash + + serverRepresentative *ntor.Representative + serverAuth *ntor.Auth + serverMark []byte +} + +func newClientHandshake(nodeID *ntor.NodeID, serverIdentity *ntor.PublicKey, sessionKey *ntor.Keypair) *clientHandshake { + hs := new(clientHandshake) + hs.keypair = sessionKey + hs.nodeID = nodeID + hs.serverIdentity = serverIdentity + hs.padLen = csrand.IntRange(clientMinPadLength, clientMaxPadLength) + hs.mac = hmac.New(sha256.New, append(hs.serverIdentity.Bytes()[:], hs.nodeID.Bytes()[:]...)) + + return hs +} + +func (hs *clientHandshake) generateHandshake() ([]byte, error) { + var buf bytes.Buffer + + hs.mac.Reset() + hs.mac.Write(hs.keypair.Representative().Bytes()[:]) + mark := hs.mac.Sum(nil)[:markLength] + + // The client handshake is X | P_C | M_C | MAC(X | P_C | M_C | E) where: + // * X is the client's ephemeral Curve25519 public key representative. + // * P_C is [clientMinPadLength,clientMaxPadLength] bytes of random padding. + // * M_C is HMAC-SHA256-128(serverIdentity | NodeID, X) + // * MAC is HMAC-SHA256-128(serverIdentity | NodeID, X .... E) + // * E is the string representation of the number of hours since the UNIX + // epoch. + + // Generate the padding + pad, err := makePad(hs.padLen) + if err != nil { + return nil, err + } + + // Write X, P_C, M_C. + buf.Write(hs.keypair.Representative().Bytes()[:]) + buf.Write(pad) + buf.Write(mark) + + // Calculate and write the MAC. + hs.mac.Reset() + hs.mac.Write(buf.Bytes()) + hs.epochHour = []byte(strconv.FormatInt(getEpochHour(), 10)) + hs.mac.Write(hs.epochHour) + buf.Write(hs.mac.Sum(nil)[:macLength]) + + return buf.Bytes(), nil +} + +func (hs *clientHandshake) parseServerHandshake(resp []byte) (int, []byte, error) { + // No point in examining the data unless the minimum plausible response has + // been received. + if serverMinHandshakeLength > len(resp) { + return 0, nil, ErrMarkNotFoundYet + } + + if hs.serverRepresentative == nil || hs.serverAuth == nil { + // Pull out the representative/AUTH. (XXX: Add actors to ntor) + hs.serverRepresentative = new(ntor.Representative) + copy(hs.serverRepresentative.Bytes()[:], resp[0:ntor.RepresentativeLength]) + hs.serverAuth = new(ntor.Auth) + copy(hs.serverAuth.Bytes()[:], resp[ntor.RepresentativeLength:]) + + // Derive the mark. + hs.mac.Reset() + hs.mac.Write(hs.serverRepresentative.Bytes()[:]) + hs.serverMark = hs.mac.Sum(nil)[:markLength] + } + + // Attempt to find the mark + MAC. + pos := findMarkMac(hs.serverMark, resp, ntor.RepresentativeLength+ntor.AuthLength+serverMinPadLength, + maxHandshakeLength, false) + if pos == -1 { + if len(resp) >= maxHandshakeLength { + return 0, nil, ErrInvalidHandshake + } + return 0, nil, ErrMarkNotFoundYet + } + + // Validate the MAC. + hs.mac.Reset() + hs.mac.Write(resp[:pos+markLength]) + hs.mac.Write(hs.epochHour) + macCmp := hs.mac.Sum(nil)[:macLength] + macRx := resp[pos+markLength : pos+markLength+macLength] + if !hmac.Equal(macCmp, macRx) { + return 0, nil, &InvalidMacError{macCmp, macRx} + } + + // Complete the handshake. + serverPublic := hs.serverRepresentative.ToPublic() + ok, seed, auth := ntor.ClientHandshake(hs.keypair, serverPublic, + hs.serverIdentity, hs.nodeID) + if !ok { + return 0, nil, ErrNtorFailed + } + if !ntor.CompareAuth(auth, hs.serverAuth.Bytes()[:]) { + return 0, nil, &InvalidAuthError{auth, hs.serverAuth} + } + + return pos + markLength + macLength, seed.Bytes()[:], nil +} + +type serverHandshake struct { + keypair *ntor.Keypair + nodeID *ntor.NodeID + serverIdentity *ntor.Keypair + epochHour []byte + serverAuth *ntor.Auth + + padLen int + mac hash.Hash + + clientRepresentative *ntor.Representative + clientMark []byte +} + +func newServerHandshake(nodeID *ntor.NodeID, serverIdentity *ntor.Keypair, sessionKey *ntor.Keypair) *serverHandshake { + hs := new(serverHandshake) + hs.keypair = sessionKey + hs.nodeID = nodeID + hs.serverIdentity = serverIdentity + hs.padLen = csrand.IntRange(serverMinPadLength, serverMaxPadLength) + hs.mac = hmac.New(sha256.New, append(hs.serverIdentity.Public().Bytes()[:], hs.nodeID.Bytes()[:]...)) + + return hs +} + +func (hs *serverHandshake) parseClientHandshake(filter *replayfilter.ReplayFilter, resp []byte) ([]byte, error) { + // No point in examining the data unless the minimum plausible response has + // been received. + if clientMinHandshakeLength > len(resp) { + return nil, ErrMarkNotFoundYet + } + + if hs.clientRepresentative == nil { + // Pull out the representative/AUTH. (XXX: Add actors to ntor) + hs.clientRepresentative = new(ntor.Representative) + copy(hs.clientRepresentative.Bytes()[:], resp[0:ntor.RepresentativeLength]) + + // Derive the mark. + hs.mac.Reset() + hs.mac.Write(hs.clientRepresentative.Bytes()[:]) + hs.clientMark = hs.mac.Sum(nil)[:markLength] + } + + // Attempt to find the mark + MAC. + pos := findMarkMac(hs.clientMark, resp, ntor.RepresentativeLength+clientMinPadLength, + maxHandshakeLength, true) + if pos == -1 { + if len(resp) >= maxHandshakeLength { + return nil, ErrInvalidHandshake + } + return nil, ErrMarkNotFoundYet + } + + // Validate the MAC. + macFound := false + for _, off := range []int64{0, -1, 1} { + // Allow epoch to be off by up to a hour in either direction. + epochHour := []byte(strconv.FormatInt(getEpochHour()+off, 10)) + hs.mac.Reset() + hs.mac.Write(resp[:pos+markLength]) + hs.mac.Write(epochHour) + macCmp := hs.mac.Sum(nil)[:macLength] + macRx := resp[pos+markLength : pos+markLength+macLength] + if hmac.Equal(macCmp, macRx) { + // Ensure that this handshake has not been seen previously. + if filter.TestAndSet(time.Now(), macRx) { + // The client either happened to generate exactly the same + // session key and padding, or someone is replaying a previous + // handshake. In either case, fuck them. + return nil, ErrReplayedHandshake + } + + macFound = true + hs.epochHour = epochHour + + // We could break out here, but in the name of reducing timing + // variation, evaluate all 3 MACs. + } + } + if !macFound { + // This probably should be an InvalidMacError, but conveying the 3 MACS + // that would be accepted is annoying so just return a generic fatal + // failure. + return nil, ErrInvalidHandshake + } + + // Client should never sent trailing garbage. + if len(resp) != pos+markLength+macLength { + return nil, ErrInvalidHandshake + } + + clientPublic := hs.clientRepresentative.ToPublic() + ok, seed, auth := ntor.ServerHandshake(clientPublic, hs.keypair, + hs.serverIdentity, hs.nodeID) + if !ok { + return nil, ErrNtorFailed + } + hs.serverAuth = auth + + return seed.Bytes()[:], nil +} + +func (hs *serverHandshake) generateHandshake() ([]byte, error) { + var buf bytes.Buffer + + hs.mac.Reset() + hs.mac.Write(hs.keypair.Representative().Bytes()[:]) + mark := hs.mac.Sum(nil)[:markLength] + + // The server handshake is Y | AUTH | P_S | M_S | MAC(Y | AUTH | P_S | M_S | E) where: + // * Y is the server's ephemeral Curve25519 public key representative. + // * AUTH is the ntor handshake AUTH value. + // * P_S is [serverMinPadLength,serverMaxPadLength] bytes of random padding. + // * M_S is HMAC-SHA256-128(serverIdentity | NodeID, Y) + // * MAC is HMAC-SHA256-128(serverIdentity | NodeID, Y .... E) + // * E is the string representation of the number of hours since the UNIX + // epoch. + + // Generate the padding + pad, err := makePad(hs.padLen) + if err != nil { + return nil, err + } + + // Write Y, AUTH, P_S, M_S. + buf.Write(hs.keypair.Representative().Bytes()[:]) + buf.Write(hs.serverAuth.Bytes()[:]) + buf.Write(pad) + buf.Write(mark) + + // Calculate and write the MAC. + hs.mac.Reset() + hs.mac.Write(buf.Bytes()) + hs.mac.Write(hs.epochHour) // Set in hs.parseClientHandshake() + buf.Write(hs.mac.Sum(nil)[:macLength]) + + return buf.Bytes(), nil +} + +// getEpochHour returns the number of hours since the UNIX epoch. +func getEpochHour() int64 { + return time.Now().Unix() / 3600 +} + +func findMarkMac(mark, buf []byte, startPos, maxPos int, fromTail bool) (pos int) { + if len(mark) != markLength { + panic(fmt.Sprintf("BUG: Invalid mark length: %d", len(mark))) + } + + endPos := len(buf) + if startPos > len(buf) { + return -1 + } + if endPos > maxPos { + endPos = maxPos + } + if endPos-startPos < markLength+macLength { + return -1 + } + + if fromTail { + // The server can optimize the search process by only examining the + // tail of the buffer. The client can't send valid data past M_C | + // MAC_C as it does not have the server's public key yet. + pos = endPos - (markLength + macLength) + if !hmac.Equal(buf[pos:pos+markLength], mark) { + return -1 + } + + return + } + + // The client has to actually do a substring search since the server can + // and will send payload trailing the response. + // + // XXX: bytes.Index() uses a naive search, which kind of sucks. + pos = bytes.Index(buf[startPos:endPos], mark) + if pos == -1 { + return -1 + } + + // Ensure that there is enough trailing data for the MAC. + if startPos+pos+markLength+macLength > endPos { + return -1 + } + + // Return the index relative to the start of the slice. + pos += startPos + return +} + +func makePad(padLen int) ([]byte, error) { + pad := make([]byte, padLen) + if err := csrand.Bytes(pad); err != nil { + return nil, err + } + + return pad, nil +} diff --git a/transports/obfs4/v3/handshake_ntor_test.go b/transports/obfs4/v3/handshake_ntor_test.go new file mode 100644 index 0000000..d7c43f8 --- /dev/null +++ b/transports/obfs4/v3/handshake_ntor_test.go @@ -0,0 +1,242 @@ +/* + * Copyright (c) 2014, Yawning Angel + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +package obfs4 + +import ( + "bytes" + "testing" + + "github.com/OperatorFoundation/obfs4/common/ntor" + "github.com/OperatorFoundation/obfs4/common/replayfilter" +) + +func TestHandshakeNtorClient(t *testing.T) { + // Generate the server node id and id keypair, and ephemeral session keys. + nodeID, _ := ntor.NewNodeID([]byte("\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13")) + idKeypair, _ := ntor.NewKeypair(false) + serverFilter, _ := replayfilter.New(replayTTL) + clientKeypair, err := ntor.NewKeypair(true) + if err != nil { + t.Fatalf("client: ntor.NewKeypair failed: %s", err) + } + serverKeypair, err := ntor.NewKeypair(true) + if err != nil { + t.Fatalf("server: ntor.NewKeypair failed: %s", err) + } + + // Test client handshake padding. + for l := clientMinPadLength; l <= clientMaxPadLength; l++ { + // Generate the client state and override the pad length. + clientHs := newClientHandshake(nodeID, idKeypair.Public(), clientKeypair) + clientHs.padLen = l + + // Generate what the client will send to the server. + clientBlob, err := clientHs.generateHandshake() + if err != nil { + t.Fatalf("[%d:0] clientHandshake.generateHandshake() failed: %s", l, err) + } + if len(clientBlob) > maxHandshakeLength { + t.Fatalf("[%d:0] Generated client body is oversized: %d", l, len(clientBlob)) + } + if len(clientBlob) < clientMinHandshakeLength { + t.Fatalf("[%d:0] Generated client body is undersized: %d", l, len(clientBlob)) + } + if len(clientBlob) != clientMinHandshakeLength+l { + t.Fatalf("[%d:0] Generated client body incorrect size: %d", l, len(clientBlob)) + } + + // Generate the server state and override the pad length. + serverHs := newServerHandshake(nodeID, idKeypair, serverKeypair) + serverHs.padLen = serverMinPadLength + + // Parse the client handshake message. + serverSeed, err := serverHs.parseClientHandshake(serverFilter, clientBlob) + if err != nil { + t.Fatalf("[%d:0] serverHandshake.parseClientHandshake() failed: %s", l, err) + } + + // Generate what the server will send to the client. + serverBlob, err := serverHs.generateHandshake() + if err != nil { + t.Fatalf("[%d:0]: serverHandshake.generateHandshake() failed: %s", l, err) + } + + // Parse the server handshake message. + clientHs.serverRepresentative = nil + n, clientSeed, err := clientHs.parseServerHandshake(serverBlob) + if err != nil { + t.Fatalf("[%d:0] clientHandshake.parseServerHandshake() failed: %s", l, err) + } + if n != len(serverBlob) { + t.Fatalf("[%d:0] clientHandshake.parseServerHandshake() has bytes remaining: %d", l, n) + } + + // Ensure the derived shared secret is the same. + if 0 != bytes.Compare(clientSeed, serverSeed) { + t.Fatalf("[%d:0] client/server seed mismatch", l) + } + } + + // Test oversized client padding. + clientHs := newClientHandshake(nodeID, idKeypair.Public(), clientKeypair) + clientHs.padLen = clientMaxPadLength + 1 + clientBlob, err := clientHs.generateHandshake() + if err != nil { + t.Fatalf("clientHandshake.generateHandshake() (forced oversize) failed: %s", err) + } + serverHs := newServerHandshake(nodeID, idKeypair, serverKeypair) + _, err = serverHs.parseClientHandshake(serverFilter, clientBlob) + if err == nil { + t.Fatalf("serverHandshake.parseClientHandshake() succeded (oversized)") + } + + // Test undersized client padding. + clientHs.padLen = clientMinPadLength - 1 + clientBlob, err = clientHs.generateHandshake() + if err != nil { + t.Fatalf("clientHandshake.generateHandshake() (forced undersize) failed: %s", err) + } + serverHs = newServerHandshake(nodeID, idKeypair, serverKeypair) + _, err = serverHs.parseClientHandshake(serverFilter, clientBlob) + if err == nil { + t.Fatalf("serverHandshake.parseClientHandshake() succeded (undersized)") + } +} + +func TestHandshakeNtorServer(t *testing.T) { + // Generate the server node id and id keypair, and ephemeral session keys. + nodeID, _ := ntor.NewNodeID([]byte("\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13")) + idKeypair, _ := ntor.NewKeypair(false) + serverFilter, _ := replayfilter.New(replayTTL) + clientKeypair, err := ntor.NewKeypair(true) + if err != nil { + t.Fatalf("client: ntor.NewKeypair failed: %s", err) + } + serverKeypair, err := ntor.NewKeypair(true) + if err != nil { + t.Fatalf("server: ntor.NewKeypair failed: %s", err) + } + + // Test server handshake padding. + for l := serverMinPadLength; l <= serverMaxPadLength+inlineSeedFrameLength; l++ { + // Generate the client state and override the pad length. + clientHs := newClientHandshake(nodeID, idKeypair.Public(), clientKeypair) + clientHs.padLen = clientMinPadLength + + // Generate what the client will send to the server. + clientBlob, err := clientHs.generateHandshake() + if err != nil { + t.Fatalf("[%d:1] clientHandshake.generateHandshake() failed: %s", l, err) + } + if len(clientBlob) > maxHandshakeLength { + t.Fatalf("[%d:1] Generated client body is oversized: %d", l, len(clientBlob)) + } + + // Generate the server state and override the pad length. + serverHs := newServerHandshake(nodeID, idKeypair, serverKeypair) + serverHs.padLen = l + + // Parse the client handshake message. + serverSeed, err := serverHs.parseClientHandshake(serverFilter, clientBlob) + if err != nil { + t.Fatalf("[%d:1] serverHandshake.parseClientHandshake() failed: %s", l, err) + } + + // Generate what the server will send to the client. + serverBlob, err := serverHs.generateHandshake() + if err != nil { + t.Fatalf("[%d:1]: serverHandshake.generateHandshake() failed: %s", l, err) + } + + // Parse the server handshake message. + n, clientSeed, err := clientHs.parseServerHandshake(serverBlob) + if err != nil { + t.Fatalf("[%d:1] clientHandshake.parseServerHandshake() failed: %s", l, err) + } + if n != len(serverBlob) { + t.Fatalf("[%d:1] clientHandshake.parseServerHandshake() has bytes remaining: %d", l, n) + } + + // Ensure the derived shared secret is the same. + if 0 != bytes.Compare(clientSeed, serverSeed) { + t.Fatalf("[%d:1] client/server seed mismatch", l) + } + } + + // Test oversized client padding. + clientHs := newClientHandshake(nodeID, idKeypair.Public(), clientKeypair) + clientHs.padLen = clientMaxPadLength + 1 + clientBlob, err := clientHs.generateHandshake() + if err != nil { + t.Fatalf("clientHandshake.generateHandshake() (forced oversize) failed: %s", err) + } + serverHs := newServerHandshake(nodeID, idKeypair, serverKeypair) + _, err = serverHs.parseClientHandshake(serverFilter, clientBlob) + if err == nil { + t.Fatalf("serverHandshake.parseClientHandshake() succeded (oversized)") + } + + // Test undersized client padding. + clientHs.padLen = clientMinPadLength - 1 + clientBlob, err = clientHs.generateHandshake() + if err != nil { + t.Fatalf("clientHandshake.generateHandshake() (forced undersize) failed: %s", err) + } + serverHs = newServerHandshake(nodeID, idKeypair, serverKeypair) + _, err = serverHs.parseClientHandshake(serverFilter, clientBlob) + if err == nil { + t.Fatalf("serverHandshake.parseClientHandshake() succeded (undersized)") + } + + // Test oversized server padding. + // + // NB: serverMaxPadLength isn't the real maxPadLength that triggers client + // rejection, because the implementation is written with the assumption + // that the PRNG_SEED is also inlined with the response. Thus the client + // actually accepts longer padding. The server handshake test and this + // test adjust around that. + clientHs.padLen = clientMinPadLength + clientBlob, err = clientHs.generateHandshake() + if err != nil { + t.Fatalf("clientHandshake.generateHandshake() failed: %s", err) + } + serverHs = newServerHandshake(nodeID, idKeypair, serverKeypair) + serverHs.padLen = serverMaxPadLength + inlineSeedFrameLength + 1 + _, err = serverHs.parseClientHandshake(serverFilter, clientBlob) + if err != nil { + t.Fatalf("serverHandshake.parseClientHandshake() failed: %s", err) + } + serverBlob, err := serverHs.generateHandshake() + if err != nil { + t.Fatalf("serverHandshake.generateHandshake() (forced oversize) failed: %s", err) + } + _, _, err = clientHs.parseServerHandshake(serverBlob) + if err == nil { + t.Fatalf("clientHandshake.parseServerHandshake() succeded (oversized)") + } +} diff --git a/transports/obfs4/v3/obfs4.go b/transports/obfs4/v3/obfs4.go new file mode 100644 index 0000000..ecb0aeb --- /dev/null +++ b/transports/obfs4/v3/obfs4.go @@ -0,0 +1,732 @@ +/* + * Copyright (c) 2014, Yawning Angel + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +// Package obfs4 provides an implementation of the Tor Project's obfs4 +// obfuscation protocol. +package obfs4 + +import ( + "bytes" + "crypto/sha256" + "flag" + "fmt" + "github.com/OperatorFoundation/obfs4/common/drbg" + "github.com/OperatorFoundation/obfs4/common/log" + "github.com/OperatorFoundation/obfs4/common/ntor" + "github.com/OperatorFoundation/obfs4/common/probdist" + "github.com/OperatorFoundation/obfs4/common/replayfilter" + "github.com/OperatorFoundation/shapeshifter-ipc" + "github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2/framing" + "golang.org/x/net/proxy" + "math/rand" + "net" + "strconv" + "syscall" + "time" +) + +const ( + nodeIDArg = "node-id" + privateKeyArg = "private-key" + seedArg = "drbg-seed" + iatArg = "iat-mode" + certArg = "cert" + + biasCmdArg = "obfs4-distBias" + + seedLength = drbg.SeedLength + headerLength = framing.FrameOverhead + packetOverhead + clientHandshakeTimeout = time.Duration(60) * time.Second + serverHandshakeTimeout = time.Duration(30) * time.Second + replayTTL = time.Duration(3) * time.Hour + + maxIATDelay = 100 + maxCloseDelayBytes = maxHandshakeLength + maxCloseDelay = 60 +) + +const ( + iatNone = iota + iatEnabled + iatParanoid +) + +// biasedDist controls if the probability table will be ScrambleSuit style or +// uniformly distributed. +var biasedDist bool + +// Transport that uses the obfs4 protocol to shapeshift the application network traffic +type Transport struct { + dialer proxy.Dialer + + serverFactory *ServerFactory + clientArgs *ClientArgs +} + +//ServerFactory contains arguments for server side +type ServerFactory struct { + args *pt.Args + + nodeID *ntor.NodeID + identityKey *ntor.Keypair + lenSeed *drbg.Seed + iatSeed *drbg.Seed + iatMode int + replayFilter *replayfilter.ReplayFilter + + closeDelayBytes int + closeDelay int +} + +//ClientArgs contains arguments for client side +type ClientArgs struct { + nodeID *ntor.NodeID + publicKey *ntor.PublicKey + sessionKey *ntor.Keypair + iatMode int +} + +//NewObfs4Server initializes the obfs4 server side +func NewObfs4Server(stateDir string) (*Transport, error) { + args := make(pt.Args) + st, err := serverStateFromArgs(stateDir, &args) + if err != nil { + return nil, err + } + + var iatSeed *drbg.Seed + if st.iatMode != iatNone { + iatSeedSrc := sha256.Sum256(st.drbgSeed.Bytes()[:]) + var err error + iatSeed, err = drbg.SeedFromBytes(iatSeedSrc[:]) + if err != nil { + return nil, err + } + } + + // Store the arguments that should appear in our descriptor for the clients. + ptArgs := pt.Args{} + ptArgs.Add(certArg, st.cert.String()) + log.Infof("certstring %s", certArg) + ptArgs.Add(iatArg, strconv.Itoa(st.iatMode)) + + // Initialize the replay filter. + filter, err := replayfilter.New(replayTTL) + if err != nil { + return nil, err + } + + // Initialize the close thresholds for failed connections. + hashDrbg, err := drbg.NewHashDrbg(st.drbgSeed) + if err != nil { + return nil, err + } + rng := rand.New(hashDrbg) + + sf := &ServerFactory{&ptArgs, st.nodeID, st.identityKey, st.drbgSeed, iatSeed, st.iatMode, filter, rng.Intn(maxCloseDelayBytes), rng.Intn(maxCloseDelay)} + + return &Transport{dialer: nil, serverFactory: sf, clientArgs: nil}, nil +} + +//NewObfs4Client initializes the obfs4 client side +func NewObfs4Client(certString string, iatMode int, dialer proxy.Dialer) (*Transport, error) { + var nodeID *ntor.NodeID + var publicKey *ntor.PublicKey + + // The "new" (version >= 0.0.3) bridge lines use a unified "cert" argument + // for the Node ID and Public Key. + cert, err := serverCertFromString(certString) + if err != nil { + return nil, err + } + nodeID, publicKey = cert.unpack() + + // Generate the session key pair before connection to hide the Elligator2 + // rejection sampling from network observers. + sessionKey, err := ntor.NewKeypair(true) + if err != nil { + return nil, err + } + + if dialer == nil { + return &Transport{dialer: proxy.Direct, serverFactory: nil, clientArgs: &ClientArgs{nodeID, publicKey, sessionKey, iatMode}}, nil + } + return &Transport{dialer: dialer, serverFactory: nil, clientArgs: &ClientArgs{nodeID, publicKey, sessionKey, iatMode}}, nil + +} + +// Dial creates outgoing transport connection +func (transport *Transport) Dial(address string) (net.Conn, error) { + dialFn := transport.dialer.Dial + conn, dialErr := dialFn("tcp", address) + if dialErr != nil { + return nil, dialErr + } + + dialConn := conn + transportConn, err := newObfs4ClientConn(conn, transport.clientArgs) + if err != nil { + closeErr := dialConn.Close() + if closeErr != nil { + log.Errorf("could not close") + } + return nil, err + } + + return transportConn, nil +} + + +//OptimizerTransport contains parameters to be used in Optimizer +type OptimizerTransport struct { + CertString string + IatMode int + Address string + Dialer proxy.Dialer +} + +//Config contains arguments formatted for a json file +type Config struct { + CertString string `json:"cert"` + IatMode string `json:"iat-mode"` +} + +// Dial creates outgoing transport connection +func (transport OptimizerTransport) Dial() (net.Conn, error) { + Obfs4Transport, err := NewObfs4Client(transport.CertString, transport.IatMode, transport.Dialer) + if err != nil { + return nil, err + } + conn, err := Obfs4Transport.Dial(transport.Address) + if err != nil { + return nil, err + } + return conn, nil +} + +// Listen creates listener for incoming transport connection +func (transport *Transport) Listen(address string) net.Listener { + addr, resolveErr := pt.ResolveAddr(address) + if resolveErr != nil { + fmt.Println(resolveErr.Error()) + return nil + } + + ln, err := net.ListenTCP("tcp", addr) + if err != nil { + fmt.Println(err.Error()) + return nil + } + + return newObfs4TransportListener(transport.serverFactory, ln) +} + +// Close closes the transport listener. +func (transport *Transport) Close() error { + return nil +} + +// End methods that implement the base.Transport interface + +// Listener that accepts connections using the obfs4 transport to communicate +type obfs4TransportListener struct { + serverFactory *ServerFactory + + listener *net.TCPListener +} + +// Private initializer for the obfs4 listener. +// You get a new listener instance by calling the Listen method on the Transport. +func newObfs4TransportListener(sf *ServerFactory, listener *net.TCPListener) *obfs4TransportListener { + return &obfs4TransportListener{serverFactory: sf, listener: listener} +} + +// Methods that implement the net.Listener interface + +// NetworkListener listens for underlying network connection +func (listener *obfs4TransportListener) NetworkListener() net.Listener { + return listener.listener +} + +// Accept waits for and returns the next connection to the listener. +func (listener *obfs4TransportListener) Accept() (net.Conn, error) { + conn, err := listener.listener.Accept() + if err != nil { + return nil, err + } + + return newObfs4ServerConn(conn, listener.serverFactory) +} + +func (listener *obfs4TransportListener) Addr() net.Addr { + interfaces, _ := net.Interfaces() + addrs, _ := interfaces[0].Addrs() + return addrs[0] +} + +// Close closes the transport listener. +// Any blocked Accept operations will be unblocked and return errors. +func (listener *obfs4TransportListener) Close() error { + return listener.listener.Close() +} + +// End methods that implement the net.Listener interface + +// Implementation of net.Conn, which also requires implementing net.Conn +type obfs4Conn struct { + net.Conn + + isServer bool + + lenDist *probdist.WeightedDist + iatDist *probdist.WeightedDist + iatMode int + + receiveBuffer *bytes.Buffer + receiveDecodedBuffer *bytes.Buffer + readBuffer []byte + + encoder *framing.Encoder + decoder *framing.Decoder +} + +// Private initializer methods + +func newObfs4ClientConn(conn net.Conn, args *ClientArgs) (c *obfs4Conn, err error) { + // Generate the initial protocol polymorphism distribution(s). + var seed *drbg.Seed + if seed, err = drbg.NewSeed(); err != nil { + return + } + lenDist := probdist.New(seed, 0, framing.MaximumSegmentLength, biasedDist) + var iatDist *probdist.WeightedDist + if args.iatMode != iatNone { + var iatSeed *drbg.Seed + iatSeedSrc := sha256.Sum256(seed.Bytes()[:]) + if iatSeed, err = drbg.SeedFromBytes(iatSeedSrc[:]); err != nil { + return + } + iatDist = probdist.New(iatSeed, 0, maxIATDelay, biasedDist) + } + + // Allocate the client structure. + c = &obfs4Conn{conn, false, lenDist, iatDist, args.iatMode, bytes.NewBuffer(nil), bytes.NewBuffer(nil), make([]byte, consumeReadSize), nil, nil} + + // Start the handshake timeout. + deadline := time.Now().Add(clientHandshakeTimeout) + if err = conn.SetDeadline(deadline); err != nil { + return nil, err + } + + if err = c.clientHandshake(args.nodeID, args.publicKey, args.sessionKey); err != nil { + return nil, err + } + + // Stop the handshake timeout. + if err = conn.SetDeadline(time.Time{}); err != nil { + return nil, err + } + + return +} + +func newObfs4ServerConn(conn net.Conn, sf *ServerFactory) (*obfs4Conn, error) { + // Not much point in having a separate newObfs4ServerConn routine when + // wrapping requires using values from the factory instance. + + // Generate the session keypair *before* consuming data from the peer, to + // attempt to mask the rejection sampling due to use of Elligator2. This + // might be futile, but the timing differential isn't very large on modern + // hardware, and there are far easier statistical attacks that can be + // mounted as a distinguisher. + sessionKey, err := ntor.NewKeypair(true) + if err != nil { + return nil, err + } + + lenDist := probdist.New(sf.lenSeed, 0, framing.MaximumSegmentLength, biasedDist) + var iatDist *probdist.WeightedDist + if sf.iatSeed != nil { + iatDist = probdist.New(sf.iatSeed, 0, maxIATDelay, biasedDist) + } + + c := &obfs4Conn{conn, true, lenDist, iatDist, sf.iatMode, bytes.NewBuffer(nil), bytes.NewBuffer(nil), make([]byte, consumeReadSize), nil, nil} + + startTime := time.Now() + + if err = c.serverHandshake(sf, sessionKey); err != nil { + c.closeAfterDelay(sf, startTime) + return nil, err + } + + return c, nil +} + +// End initializer methods + +// Methods that implement the net.Conn interface +func (transportConn *obfs4Conn) NetworkConn() net.Conn { + return transportConn.Conn +} + +// End methods that implement the net.Conn interface + +// Methods implementing net.Conn +func (transportConn *obfs4Conn) Read(b []byte) (n int, err error) { + // If there is no payload from the previous Read() calls, consume data off + // the network. Not all data received is guaranteed to be usable payload, + // so do this in a loop till data is present or an error occurs. + for transportConn.receiveDecodedBuffer.Len() == 0 { + err = transportConn.readPackets() + if err == framing.ErrAgain { + // Don't propagate this back up the call stack if we happen to break + // out of the loop. + err = nil + continue + } else if err != nil { + break + } + } + + // Even if err is set, attempt to do the read anyway so that all decoded + // data gets relayed before the connection is torn down. + if transportConn.receiveDecodedBuffer.Len() > 0 { + var berr error + n, berr = transportConn.receiveDecodedBuffer.Read(b) + if err == nil { + // Only propagate berr if there are not more important (fatal) + // errors from the network/crypto/packet processing. + err = berr + } + } + + return +} + +func (transportConn *obfs4Conn) Write(b []byte) (n int, err error) { + chopBuf := bytes.NewBuffer(b) + var payload [maxPacketPayloadLength]byte + var frameBuf bytes.Buffer + + // Chop the pending data into payload frames. + for chopBuf.Len() > 0 { + // Send maximum sized frames. + rdLen := 0 + rdLen, err = chopBuf.Read(payload[:]) + if err != nil { + return 0, err + } else if rdLen == 0 { + panic(fmt.Sprintf("BUG: Write(), chopping length was 0")) + } + n += rdLen + + err = transportConn.makePacket(&frameBuf, packetTypePayload, payload[:rdLen], 0) + if err != nil { + return 0, err + } + } + + if transportConn.iatMode != iatParanoid { + // For non-paranoid IAT, pad once per burst. Paranoid IAT handles + // things differently. + if err = transportConn.padBurst(&frameBuf, transportConn.lenDist.Sample()); err != nil { + return 0, err + } + } + + // Write the pending data onto the network. Partial writes are fatal, + // because the frame encoder state is advanced, and the code doesn't keep + // frameBuf around. In theory, write timeouts and whatnot could be + // supported if this wasn't the case, but that complicates the code. + if transportConn.iatMode != iatNone { + var iatFrame [framing.MaximumSegmentLength]byte + for frameBuf.Len() > 0 { + iatWrLen := 0 + + switch transportConn.iatMode { + case iatEnabled: + // Standard (ScrambleSuit-style) IAT obfuscation optimizes for + // bulk transport and will write ~MTU sized frames when + // possible. + iatWrLen, err = frameBuf.Read(iatFrame[:]) + + case iatParanoid: + // Paranoid IAT obfuscation throws performance out of the + // window and will sample the length distribution every time a + // write is scheduled. + targetLen := transportConn.lenDist.Sample() + if frameBuf.Len() < targetLen { + // There's not enough data buffered for the target write, + // so padding must be inserted. + if err = transportConn.padBurst(&frameBuf, targetLen); err != nil { + return 0, err + } + if frameBuf.Len() != targetLen { + // Ugh, padding came out to a value that required more + // than one frame, this is relatively unlikely so just + // re-sample since there's enough data to ensure that + // the next sample will be written. + continue + } + } + iatWrLen, err = frameBuf.Read(iatFrame[:targetLen]) + } + if err != nil { + return 0, err + } else if iatWrLen == 0 { + panic(fmt.Sprintf("BUG: Write(), iat length was 0")) + } + + // Calculate the delay. The delay resolution is 100 usec, leading + // to a maximum delay of 10 msec. + iatDelta := time.Duration(transportConn.iatDist.Sample() * 100) + + // Write then sleep. + _, err = transportConn.Conn.Write(iatFrame[:iatWrLen]) + if err != nil { + return 0, err + } + time.Sleep(iatDelta * time.Microsecond) + } + } else { + _, err = transportConn.Conn.Write(frameBuf.Bytes()) + } + + return +} + +func (transportConn *obfs4Conn) Close() error { + return transportConn.Conn.Close() +} + +func (transportConn *obfs4Conn) LocalAddr() net.Addr { + return transportConn.Conn.LocalAddr() +} + +func (transportConn *obfs4Conn) RemoteAddr() net.Addr { + return transportConn.Conn.RemoteAddr() +} + +func (transportConn *obfs4Conn) SetDeadline(time.Time) error { + return syscall.ENOTSUP +} + +func (transportConn *obfs4Conn) SetReadDeadline(t time.Time) error { + return transportConn.Conn.SetReadDeadline(t) +} + +func (transportConn *obfs4Conn) SetWriteDeadline(time.Time) error { + return syscall.ENOTSUP +} + +// End of methods implementing net.Conn + +// Private methods implementing the obfs4 protocol + +func (transportConn *obfs4Conn) clientHandshake(nodeID *ntor.NodeID, peerIdentityKey *ntor.PublicKey, sessionKey *ntor.Keypair) error { + if transportConn.isServer { + return fmt.Errorf("clientHandshake called on server connection") + } + + // Generate and send the client handshake. + hs := newClientHandshake(nodeID, peerIdentityKey, sessionKey) + blob, err := hs.generateHandshake() + if err != nil { + return err + } + if _, err = transportConn.Conn.Write(blob); err != nil { + return err + } + + // Consume the server handshake. + var hsBuf [maxHandshakeLength]byte + for { + n, err := transportConn.Conn.Read(hsBuf[:]) + if err != nil { + // The Read() could have returned data and an error, but there is + // no point in continuing on an EOF or whatever. + return err + } + transportConn.receiveBuffer.Write(hsBuf[:n]) + + n, seed, err := hs.parseServerHandshake(transportConn.receiveBuffer.Bytes()) + if err == ErrMarkNotFoundYet { + continue + } else if err != nil { + return err + } + _ = transportConn.receiveBuffer.Next(n) + + // Use the derived key material to initialize the link crypto. + okm := ntor.Kdf(seed, framing.KeyLength*2) + transportConn.encoder = framing.NewEncoder(okm[:framing.KeyLength]) + transportConn.decoder = framing.NewDecoder(okm[framing.KeyLength:]) + + return nil + } +} + +func (transportConn *obfs4Conn) serverHandshake(sf *ServerFactory, sessionKey *ntor.Keypair) error { + if !transportConn.isServer { + return fmt.Errorf("serverHandshake called on client connection") + } + + // Generate the server handshake, and arm the base timeout. + hs := newServerHandshake(sf.nodeID, sf.identityKey, sessionKey) + if err := transportConn.Conn.SetDeadline(time.Now().Add(serverHandshakeTimeout)); err != nil { + return err + } + + // Consume the client handshake. + var hsBuf [maxHandshakeLength]byte + for { + n, err := transportConn.Conn.Read(hsBuf[:]) + if err != nil { + // The Read() could have returned data and an error, but there is + // no point in continuing on an EOF or whatever. + return err + } + transportConn.receiveBuffer.Write(hsBuf[:n]) + + seed, err := hs.parseClientHandshake(sf.replayFilter, transportConn.receiveBuffer.Bytes()) + if err == ErrMarkNotFoundYet { + continue + } else if err != nil { + return err + } + transportConn.receiveBuffer.Reset() + + if err := transportConn.Conn.SetDeadline(time.Time{}); err != nil { + return nil + } + + // Use the derived key material to initialize the link crypto. + okm := ntor.Kdf(seed, framing.KeyLength*2) + transportConn.encoder = framing.NewEncoder(okm[framing.KeyLength:]) + transportConn.decoder = framing.NewDecoder(okm[:framing.KeyLength]) + + break + } + + // Since the current and only implementation always sends a PRNG seed for + // the length obfuscation, this makes the amount of data received from the + // server inconsistent with the length sent from the client. + // + // Re-balance this by tweaking the client minimum padding/server maximum + // padding, and sending the PRNG seed un-padded (As in, treat the PRNG seed + // as part of the server response). See inlineSeedFrameLength in + // handshake_ntor.go. + + // Generate/send the response. + blob, err := hs.generateHandshake() + if err != nil { + return err + } + var frameBuf bytes.Buffer + if _, err = frameBuf.Write(blob); err != nil { + return err + } + + // Send the PRNG seed as the first packet. + if err := transportConn.makePacket(&frameBuf, packetTypePrngSeed, sf.lenSeed.Bytes()[:], 0); err != nil { + return err + } + if _, err = transportConn.Conn.Write(frameBuf.Bytes()); err != nil { + return err + } + + return nil +} + +func (transportConn *obfs4Conn) closeAfterDelay(sf *ServerFactory, startTime time.Time) { + // I-it's not like I w-wanna handshake with you or anything. B-b-baka! + //defer transportConn.Conn.Close() + + delay := time.Duration(sf.closeDelay)*time.Second + serverHandshakeTimeout + deadline := startTime.Add(delay) + if time.Now().After(deadline) { + return + } + + if err := transportConn.Conn.SetReadDeadline(deadline); err != nil { + return + } + + // Consume and discard data on this connection until either the specified + // interval passes or a certain size has been reached. + discarded := 0 + var buf [framing.MaximumSegmentLength]byte + for discarded < sf.closeDelayBytes { + n, err := transportConn.Conn.Read(buf[:]) + if err != nil { + return + } + discarded += n + } +} + +func (transportConn *obfs4Conn) padBurst(burst *bytes.Buffer, toPadTo int) (err error) { + tailLen := burst.Len() % framing.MaximumSegmentLength + + padLen := 0 + if toPadTo >= tailLen { + padLen = toPadTo - tailLen + } else { + padLen = (framing.MaximumSegmentLength - tailLen) + toPadTo + } + + if padLen > headerLength { + err = transportConn.makePacket(burst, packetTypePayload, []byte{}, + uint16(padLen-headerLength)) + if err != nil { + return + } + } else if padLen > 0 { + err = transportConn.makePacket(burst, packetTypePayload, []byte{}, + maxPacketPayloadLength) + if err != nil { + return + } + err = transportConn.makePacket(burst, packetTypePayload, []byte{}, + uint16(padLen)) + if err != nil { + return + } + } + + return +} + +func init() { + flag.BoolVar(&biasedDist, biasCmdArg, false, "Enable obfs4 using ScrambleSuit style table generation") +} + +// End private methods implementing the obfs4 protocol + +// Force type checks to make sure that instances conform to interfaces +var _ net.Listener = (*obfs4TransportListener)(nil) +var _ net.Conn = (*obfs4Conn)(nil) diff --git a/transports/obfs4/v3/obfs4_test.go b/transports/obfs4/v3/obfs4_test.go new file mode 100644 index 0000000..9f2beec --- /dev/null +++ b/transports/obfs4/v3/obfs4_test.go @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2014, Yawning Angel + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +// Package obfs4 provides an implementation of the Tor Project's obfs4 +// obfuscation protocol. +package obfs4 + +import ( + "os" + "runtime" + "testing" +) + +const data = "test" + +func TestMain(m *testing.M) { + _ = RunLocalObfs4Server("test") + + os.Exit(m.Run()) +} + +func TestObfs4(t *testing.T) { + print(runtime.GOOS) + clientConfig, launchErr := RunObfs4Client() + if launchErr != nil { + t.Fail() + return + } + //create client buffer + clientBuffer := make([]byte, 4) + //call dial on client and check error + clientConn, dialErr := clientConfig.Dial("127.0.0.1:1234") + if dialErr != nil { + t.Fail() + return + } + + //write data from clientConn for server to read + _, clientWriteErr := clientConn.Write([]byte(data)) + if clientWriteErr != nil { + t.Fail() + return + } + + //read on client side + _, clientReadErr := clientConn.Read(clientBuffer) + if clientReadErr != nil { + t.Fail() + return + } +} diff --git a/transports/obfs4/v3/packet.go b/transports/obfs4/v3/packet.go new file mode 100644 index 0000000..c6a0562 --- /dev/null +++ b/transports/obfs4/v3/packet.go @@ -0,0 +1,175 @@ +/* + * Copyright (c) 2014, Yawning Angel + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +package obfs4 + +import ( + "crypto/sha256" + "encoding/binary" + "fmt" + "io" + + "github.com/OperatorFoundation/obfs4/common/drbg" + "github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2/framing" +) + +const ( + packetOverhead = 2 + 1 + maxPacketPayloadLength = framing.MaximumFramePayloadLength - packetOverhead + maxPacketPaddingLength = maxPacketPayloadLength + seedPacketPayloadLength = seedLength + + consumeReadSize = framing.MaximumSegmentLength * 16 +) + +const ( + packetTypePayload = iota + packetTypePrngSeed +) + +// InvalidPacketLengthError is the error returned when decodePacket detects a +// invalid packet length/ +type InvalidPacketLengthError int + +func (e InvalidPacketLengthError) Error() string { + return fmt.Sprintf("packet: Invalid packet length: %d", int(e)) +} + +// InvalidPayloadLengthError is the error returned when decodePacket rejects the +// payload length. +type InvalidPayloadLengthError int + +func (e InvalidPayloadLengthError) Error() string { + return fmt.Sprintf("packet: Invalid payload length: %d", int(e)) +} + +var zeroPadBytes [maxPacketPaddingLength]byte + +func (transportConn *obfs4Conn) makePacket(w io.Writer, pktType uint8, data []byte, padLen uint16) error { + var pkt [framing.MaximumFramePayloadLength]byte + + if len(data)+int(padLen) > maxPacketPayloadLength { + panic(fmt.Sprintf("BUG: makePacket() len(data) + padLen > maxPacketPayloadLength: %d + %d > %d", + len(data), padLen, maxPacketPayloadLength)) + } + + // Packets are: + // uint8_t type packetTypePayload (0x00) + // uint16_t length Length of the payload (Big Endian). + // uint8_t[] payload Data payload. + // uint8_t[] padding Padding. + pkt[0] = pktType + binary.BigEndian.PutUint16(pkt[1:], uint16(len(data))) + if len(data) > 0 { + copy(pkt[3:], data[:]) + } + copy(pkt[3+len(data):], zeroPadBytes[:padLen]) + + pktLen := packetOverhead + len(data) + int(padLen) + + // Encode the packet in an AEAD frame. + var frame [framing.MaximumSegmentLength]byte + frameLen, err := transportConn.encoder.Encode(frame[:], pkt[:pktLen]) + if err != nil { + // All encoder errors are fatal. + return err + } + wrLen, err := w.Write(frame[:frameLen]) + if err != nil { + return err + } else if wrLen < frameLen { + return io.ErrShortWrite + } + + return nil +} + +func (transportConn *obfs4Conn) readPackets() (err error) { + // Attempt to read off the network. + rdLen, rdErr := transportConn.Conn.Read(transportConn.readBuffer) + transportConn.receiveBuffer.Write(transportConn.readBuffer[:rdLen]) + + var decoded [framing.MaximumFramePayloadLength]byte + for transportConn.receiveBuffer.Len() > 0 { + // Decrypt an AEAD frame. + decLen := 0 + decLen, err = transportConn.decoder.Decode(decoded[:], transportConn.receiveBuffer) + if err == framing.ErrAgain { + break + } else if err != nil { + break + } else if decLen < packetOverhead { + err = InvalidPacketLengthError(decLen) + break + } + + // Decode the packet. + pkt := decoded[0:decLen] + pktType := pkt[0] + payloadLen := binary.BigEndian.Uint16(pkt[1:]) + if int(payloadLen) > len(pkt)-packetOverhead { + err = InvalidPayloadLengthError(int(payloadLen)) + break + } + payload := pkt[3 : 3+payloadLen] + + switch pktType { + case packetTypePayload: + if payloadLen > 0 { + transportConn.receiveDecodedBuffer.Write(payload) + } + case packetTypePrngSeed: + // Only regenerate the distribution if we are the client. + if len(payload) == seedPacketPayloadLength && !transportConn.isServer { + var seed *drbg.Seed + seed, err = drbg.SeedFromBytes(payload) + if err != nil { + break + } + transportConn.lenDist.Reset(seed) + if transportConn.iatDist != nil { + iatSeedSrc := sha256.Sum256(seed.Bytes()[:]) + iatSeed, err := drbg.SeedFromBytes(iatSeedSrc[:]) + if err != nil { + break + } + transportConn.iatDist.Reset(iatSeed) + } + } + default: + // Ignore unknown packet types. + } + } + + // Read errors (all fatal) take priority over various frame processing + // errors. + if rdErr != nil { + return rdErr + } + + return +} diff --git a/transports/obfs4/v3/statefile.go b/transports/obfs4/v3/statefile.go new file mode 100644 index 0000000..f0707de --- /dev/null +++ b/transports/obfs4/v3/statefile.go @@ -0,0 +1,263 @@ +/* + * Copyright (c) 2014, Yawning Angel + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +package obfs4 + +import ( + "encoding/base64" + "encoding/json" + "fmt" + "io/ioutil" + "os" + "path" + "strconv" + "strings" + + "github.com/OperatorFoundation/obfs4/common/csrand" + "github.com/OperatorFoundation/obfs4/common/drbg" + "github.com/OperatorFoundation/obfs4/common/ntor" + "github.com/OperatorFoundation/shapeshifter-ipc" +) + +const ( + stateFile = "obfs4_state.json" + bridgeFile = "obfs4_bridgeline.txt" + + certSuffix = "==" + certLength = ntor.NodeIDLength + ntor.PublicKeyLength +) + +type jsonServerState struct { + NodeID string `json:"node-id"` + PrivateKey string `json:"private-key"` + PublicKey string `json:"public-key"` + DrbgSeed string `json:"drbg-seed"` + IATMode int `json:"iat-mode"` +} + +type obfs4ServerCert struct { + raw []byte +} + +func (cert *obfs4ServerCert) String() string { + return strings.TrimSuffix(base64.StdEncoding.EncodeToString(cert.raw), certSuffix) +} + +func (cert *obfs4ServerCert) unpack() (*ntor.NodeID, *ntor.PublicKey) { + if len(cert.raw) != certLength { + panic(fmt.Sprintf("cert length %d is invalid", len(cert.raw))) + } + + nodeID, _ := ntor.NewNodeID(cert.raw[:ntor.NodeIDLength]) + pubKey, _ := ntor.NewPublicKey(cert.raw[ntor.NodeIDLength:]) + + return nodeID, pubKey +} + +func serverCertFromString(encoded string) (*obfs4ServerCert, error) { + decoded, err := base64.StdEncoding.DecodeString(encoded + certSuffix) + if err != nil { + println("encoded: ", encoded) + println("certSuffix: ", certSuffix) + println("together: ", encoded + certSuffix) + return nil, fmt.Errorf("failed to decode cert: %s", err) + } + + if len(decoded) != certLength { + return nil, fmt.Errorf("cert length %d is invalid", len(decoded)) + } + + return &obfs4ServerCert{raw: decoded}, nil +} + +func serverCertFromState(st *obfs4ServerState) *obfs4ServerCert { + cert := new(obfs4ServerCert) + cert.raw = append(st.nodeID.Bytes()[:], st.identityKey.Public().Bytes()[:]...) + return cert +} + +type obfs4ServerState struct { + nodeID *ntor.NodeID + identityKey *ntor.Keypair + drbgSeed *drbg.Seed + iatMode int + + cert *obfs4ServerCert +} + +func (st *obfs4ServerState) clientString() string { + return fmt.Sprintf("%s=%s %s=%d", certArg, st.cert, iatArg, st.iatMode) +} + +func serverStateFromArgs(stateDir string, args *pt.Args) (*obfs4ServerState, error) { + var js jsonServerState + var nodeIDOk, privKeyOk, seedOk bool + + js.NodeID, nodeIDOk = args.Get(nodeIDArg) + js.PrivateKey, privKeyOk = args.Get(privateKeyArg) + js.DrbgSeed, seedOk = args.Get(seedArg) + iatStr, iatOk := args.Get(iatArg) + + // Either a private key, node id, and seed are ALL specified, or + // they should be loaded from the state file. + if !privKeyOk && !nodeIDOk && !seedOk { + if err := jsonServerStateFromFile(stateDir, &js); err != nil { + return nil, err + } + } else if !privKeyOk { + return nil, fmt.Errorf("missing argument '%s'", privateKeyArg) + } else if !nodeIDOk { + return nil, fmt.Errorf("missing argument '%s'", nodeIDArg) + } else if !seedOk { + return nil, fmt.Errorf("missing argument '%s'", seedArg) + } + + // The IAT mode should be independently configurable. + if iatOk { + // If the IAT mode is specified, attempt to parse and apply it + // as an override. + iatMode, err := strconv.Atoi(iatStr) + if err != nil { + return nil, fmt.Errorf("malformed iat-mode '%s'", iatStr) + } + js.IATMode = iatMode + } + + return serverStateFromJSONServerState(stateDir, &js) +} + +func serverStateFromJSONServerState(stateDir string, js *jsonServerState) (*obfs4ServerState, error) { + var err error + + st := new(obfs4ServerState) + if st.nodeID, err = ntor.NodeIDFromHex(js.NodeID); err != nil { + return nil, err + } + if st.identityKey, err = ntor.KeypairFromHex(js.PrivateKey); err != nil { + return nil, err + } + if st.drbgSeed, err = drbg.SeedFromHex(js.DrbgSeed); err != nil { + return nil, err + } + if js.IATMode < iatNone || js.IATMode > iatParanoid { + return nil, fmt.Errorf("invalid iat-mode '%d'", js.IATMode) + } + st.iatMode = js.IATMode + st.cert = serverCertFromState(st) + + // Generate a human readable summary of the configured endpoint. + if err = newBridgeFile(stateDir, st); err != nil { + return nil, err + } + + // Write back the possibly updated server state. + return st, writeJSONServerState(stateDir, js) +} + +func jsonServerStateFromFile(stateDir string, js *jsonServerState) error { + fPath := path.Join(stateDir, stateFile) + f, err := ioutil.ReadFile(fPath) + if err != nil { + if os.IsNotExist(err) { + if err = newJSONServerState(stateDir, js); err == nil { + return nil + } + } + return err + } + + if err := json.Unmarshal(f, js); err != nil { + return fmt.Errorf("failed to load statefile '%s': %s", fPath, err) + } + + return nil +} + +func newJSONServerState(stateDir string, js *jsonServerState) (err error) { + // Generate everything a server needs, using the cryptographic PRNG. + var st obfs4ServerState + rawID := make([]byte, ntor.NodeIDLength) + if err = csrand.Bytes(rawID); err != nil { + return + } + if st.nodeID, err = ntor.NewNodeID(rawID); err != nil { + return + } + if st.identityKey, err = ntor.NewKeypair(false); err != nil { + return + } + if st.drbgSeed, err = drbg.NewSeed(); err != nil { + return + } + st.iatMode = iatNone + + // Encode it into JSON format and write the state file. + js.NodeID = st.nodeID.Hex() + js.PrivateKey = st.identityKey.Private().Hex() + js.PublicKey = st.identityKey.Public().Hex() + js.DrbgSeed = st.drbgSeed.Hex() + js.IATMode = st.iatMode + + return writeJSONServerState(stateDir, js) +} + +func writeJSONServerState(stateDir string, js *jsonServerState) error { + var err error + var encoded []byte + if encoded, err = json.Marshal(js); err != nil { + return err + } + if err = ioutil.WriteFile(path.Join(stateDir, stateFile), encoded, 0600); err != nil { + return err + } + + return nil +} + +func newBridgeFile(stateDir string, st *obfs4ServerState) error { + const prefix = "# obfs4 torrc client bridge line\n" + + "#\n" + + "# This file is an automatically generated bridge line based on\n" + + "# the current obfs4proxy configuration. EDITING IT WILL HAVE\n" + + "# NO EFFECT.\n" + + "#\n" + + "# Before distributing this Bridge, edit the placeholder fields\n" + + "# to contain the actual values:\n" + + "# - The public IP Address of your obfs4 bridge.\n" + + "# - The TCP/IP port of your obfs4 bridge.\n" + + "# - The bridge's fingerprint.\n\n" + + bridgeLine := fmt.Sprintf("Bridge obfs4 : %s\n", + st.clientString()) + + tmp := []byte(prefix + bridgeLine) + if err := ioutil.WriteFile(path.Join(stateDir, bridgeFile), tmp, 0600); err != nil { + return err + } + + return nil +} diff --git a/transports/obfs4/v3/test_utils.go b/transports/obfs4/v3/test_utils.go new file mode 100644 index 0000000..ce8484f --- /dev/null +++ b/transports/obfs4/v3/test_utils.go @@ -0,0 +1,101 @@ +package obfs4 + +import ( + "io/ioutil" + "os" + "os/user" + "path" + "runtime" + "strings" +) + +//RunLocalObfs4Server runs the server side in the background for the test +func RunLocalObfs4Server(data string) bool { + //create a server + usr, userError := user.Current() + if userError != nil { + return false + } + home := usr.HomeDir + var fPath string + if runtime.GOOS == "darwin" { + fPath = path.Join(home, "shapeshifter-transports/stateDir") + } else { + fPath = path.Join(home, "gopath/src/github.com/OperatorFoundation/shapeshifter-transports/stateDir") + } + directoryErr := os.Mkdir(fPath, 0775) + if directoryErr != nil { + if !os.IsExist(directoryErr){ + return false + } + } + serverConfig, confError := NewObfs4Server(fPath) + if confError != nil { + return false + } + //call listen on the server + serverListener := serverConfig.Listen("127.0.0.1:1234") + if serverListener == nil { + return false + } + //Create Server connection and format it for concurrency + go func() { + //create server buffer + serverBuffer := make([]byte, 4) + + for { + //create serverConn + serverConn, acceptErr := serverListener.Accept() + if acceptErr != nil { + return + } + + go func() { + //read on server side + _, serverReadErr := serverConn.Read(serverBuffer) + if serverReadErr != nil { + return + } + + //write data from serverConn for client to read + _, serverWriteErr := serverConn.Write([]byte(data)) + if serverWriteErr != nil { + return + } + }() + } + }() + return true +} + +//RunObfs4Client runs the client side in the background for the test +func RunObfs4Client() (*Transport, error) { + usr, userError := user.Current() + if userError != nil { + return nil, userError + } + home := usr.HomeDir + var fPath string + if runtime.GOOS == "darwin" { + fPath = path.Join(home, "shapeshifter-transports/stateDir/obfs4_bridgeline.txt") + } else { + fPath = path.Join(home, "gopath/src/github.com/OperatorFoundation/shapeshifter-transports/stateDir/obfs4_bridgeline.txt") + } + bytes, fileError := ioutil.ReadFile(fPath) + if fileError != nil { + return nil, fileError + } + //print(bytes) + byteString := string(bytes) + //print(byteString) + lines := strings.Split(byteString, "\n") + //print(lines) + bridgeLine := lines[len(lines)-2] + //println(bridgeLine) + bridgeParts1 := strings.Split(bridgeLine, " ") + bridgePart := bridgeParts1[5] + certstring := bridgePart[5:] + //println(certstring) + clientConfig, confError := NewObfs4Client(certstring, 0, nil) + return clientConfig, confError +} diff --git a/transports/shadow/v3/LICENSE b/transports/shadow/v3/LICENSE new file mode 100644 index 0000000..dfad7b5 --- /dev/null +++ b/transports/shadow/v3/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 Operator Foundation + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/transports/shadow/v3/README.md b/transports/shadow/v3/README.md new file mode 100644 index 0000000..8e0e829 --- /dev/null +++ b/transports/shadow/v3/README.md @@ -0,0 +1,33 @@ +# shadow + +Shadowsocks is a fast, free, and open-source encrypted proxy project, used to circumvent Internet censorship by utilizing a simple, but effective encryption and a shared password. + +## Using shadow + +### Go Version: + +shadow is one of the transports available in the [Shapeshifter Transports library](https://github.com/OperatorFoundation/shapeshifter-transports). + +#### Create a shadow server + +config := NewConfig("password", "aes-128-ctr") + +serverListener, listenError := config.Listen("127.0.0.1:1234") +if listenError != nil { + return +} + +serverConn, acceptErr := serverListener.Accept() +if acceptErr != nil { + return +} + +#### Create a shadow client + +config := NewConfig("password", "aes-128-ctr") + +clientConn, dialErr := config.Dial("127.0.0.1:1234") +if dialErr != nil { + t.Fail() + return +} diff --git a/transports/shadow/v3/go.mod b/transports/shadow/v3/go.mod new file mode 100644 index 0000000..361d52b --- /dev/null +++ b/transports/shadow/v3/go.mod @@ -0,0 +1,9 @@ +module github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v2 + +go 1.12 + +require ( + github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da // indirect + github.com/shadowsocks/go-shadowsocks2 v0.0.11 + golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 // indirect +) diff --git a/transports/shadow/v3/go.sum b/transports/shadow/v3/go.sum new file mode 100644 index 0000000..41a91f8 --- /dev/null +++ b/transports/shadow/v3/go.sum @@ -0,0 +1,8 @@ +github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da h1:KjTM2ks9d14ZYCvmHS9iAKVt9AyzRSqNU1qabPih5BY= +github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da/go.mod h1:eHEWzANqSiWQsof+nXEI9bUVUyV6F53Fp89EuCh2EAA= +github.com/shadowsocks/go-shadowsocks2 v0.0.11 h1:dXloqEhYnZV40jblWTK8kWeC0Eb+dgql4S0tj99e8j0= +github.com/shadowsocks/go-shadowsocks2 v0.0.11/go.mod h1:R+KWaoIwRRhnpw6XV+dZil0XHi64Hc1D7hXUyXTjUzQ= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= diff --git a/transports/shadow/v3/shadow.go b/transports/shadow/v3/shadow.go new file mode 100644 index 0000000..c1bbb05 --- /dev/null +++ b/transports/shadow/v3/shadow.go @@ -0,0 +1,104 @@ +/* + MIT License + + Copyright (c) 2020 Operator Foundation + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +// Package shadow provides a PT 2.1 Go API wrapper around the connections used by Shadowsocks +package shadow + +import ( + "log" + "net" + + shadowsocks "github.com/shadowsocks/go-shadowsocks2/core" +) + +//Config contains the necessary command like arguments to run shadow +type Config struct { + Password string `json:"password"` + CipherName string `json:"cipherName"` +} + +//Transport contains the arguments to be used with Optimizer +type Transport struct { + Password string + CipherName string + Address string +} + +//NewConfig is used to create a config for testing +func NewConfig(password string, cipherName string) Config { + return Config{ + Password: password, + CipherName: cipherName, + } +} + +//NewTransport is used for creating a transport for Optimizer +func NewTransport(password string, cipherName string, address string) Transport { + return Transport{ + Password: password, + CipherName: cipherName, + Address: address, + } +} + +//Listen checks for a working connection +func (config Config) Listen(address string) net.Listener { + cipher, err := shadowsocks.PickCipher(config.CipherName, nil, config.Password) + if err != nil { + log.Fatal("Failed generating ciphers:", err) + return nil + } + + listener, listenerErr := shadowsocks.Listen("tcp", address, cipher) + if listenerErr != nil { + log.Fatal("Failed to start listener:", listenerErr) + return nil + } + return listener +} + +//Dial connects to the address on the named network +func (config Config) Dial(address string) (net.Conn, error) { + cipher, err := shadowsocks.PickCipher(config.CipherName, nil, config.Password) + if err != nil { + log.Fatal("Failed generating ciphers:", err) + } + + conn, err := shadowsocks.Dial("tcp", address, cipher) + if err != nil { + return nil, err + } + + return conn, nil +} + +// Dial creates outgoing transport connection +func (transport *Transport) Dial() (net.Conn, error) { + cipher, err := shadowsocks.PickCipher(transport.CipherName, nil, transport.Password) + if err != nil { + log.Fatal("Failed generating ciphers:", err) + } + + return shadowsocks.Dial("tcp", transport.Address, cipher) +} diff --git a/transports/shadow/v3/shadow_test.go b/transports/shadow/v3/shadow_test.go new file mode 100644 index 0000000..fb05dd1 --- /dev/null +++ b/transports/shadow/v3/shadow_test.go @@ -0,0 +1,96 @@ +/* + MIT License + + Copyright (c) 2020 Operator Foundation + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + +package shadow + +import ( + "fmt" + "net" + "os" + "testing" +) + +const data = "test" + +func TestMain(m *testing.M) { + config := NewConfig("1234", "CHACHA20-IETF-POLY1305") + listener := config.Listen("127.0.0.1:1236") + go acceptConnections(listener) + + os.Exit(m.Run()) +} + +func acceptConnections(listener net.Listener) { + serverBuffer := make([]byte, 4) + for { + serverConn, err := listener.Accept() + if err != nil { + return + } + go func() { + //read on server side + _, serverReadErr := serverConn.Read(serverBuffer) + if serverReadErr != nil { + return + } + + //write data from serverConn for client to read + _, serverWriteErr := serverConn.Write([]byte(data)) + if serverWriteErr != nil { + return + } + }() + } +} + +func TestShadow(t *testing.T) { + //create a server + config := NewConfig("1234", "CHACHA20-IETF-POLY1305") + + //create client buffer + clientBuffer := make([]byte, 4) + //call dial on client and check error + clientConn, dialErr := config.Dial("127.0.0.1:1236") + if dialErr != nil { + fmt.Println("clientConn Dial error") + t.Fail() + return + } + + //write data from clientConn for server to read + _, clientWriteErr := clientConn.Write([]byte(data)) + if clientWriteErr != nil { + fmt.Println("client write error") + t.Fail() + return + } + + //read on client side + _, clientReadErr := clientConn.Read(clientBuffer) + if clientReadErr != nil { + fmt.Println("client read error") + t.Fail() + return + } +} From 5202c633c828de80598f880e86c09a171e951dc8 Mon Sep 17 00:00:00 2001 From: Bluesaxorcist Date: Fri, 19 Jun 2020 15:59:53 -0500 Subject: [PATCH 02/33] Updated imports to use v3 --- .travis.yml | 16 ++--- transports/Dust/v3/Dust.go | 2 +- transports/Dust/v3/go.mod | 2 +- transports/Optimizer/v3/Optimizer_test.go | 8 +-- transports/Optimizer/v3/go.mod | 10 +-- transports/Replicant/v3/config.go | 4 +- transports/Replicant/v3/go.mod | 2 +- transports/Replicant/v3/go.sum | 1 + transports/Replicant/v3/persistence.go | 4 +- transports/Replicant/v3/persistence_test.go | 4 +- transports/Replicant/v3/replicant.go | 4 +- transports/Replicant/v3/replicant_test.go | 4 +- .../Replicant/v3/toneburst/monotone_test.go | 63 ------------------- transports/meeklite/v3/go.mod | 3 +- transports/meekserver/v3/go.mod | 3 +- transports/obfs2/v3/go.mod | 4 +- transports/obfs4/v3/go.mod | 2 +- transports/obfs4/v3/handshake_ntor.go | 2 +- transports/obfs4/v3/obfs4.go | 2 +- transports/obfs4/v3/packet.go | 2 +- transports/shadow/v3/go.mod | 2 +- 21 files changed, 39 insertions(+), 105 deletions(-) delete mode 100644 transports/Replicant/v3/toneburst/monotone_test.go diff --git a/.travis.yml b/.travis.yml index 7b89348..409b77b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,12 +8,12 @@ env: script: - cd transports - #- cd transports/Dust/v2; go test -v - #- cd transports/meeklite/v2; go test -v - #- cd transports/meekserver/v2; go test -v - - cd obfs2/v2; go test -v - - cd ../../obfs4/v2; go test -v - - cd ../../Optimizer/v2; go test -v - - cd ../../Replicant/v2; go test -v - - cd ../../shadow/v2; go test -v + #- cd transports/Dust/v3; go test -v + #- cd transports/meeklite/v3; go test -v + #- cd transports/meekserver/v3; go test -v + - cd obfs2/v3; go test -v + - cd ../../obfs4/v3; go test -v + - cd ../../Optimizer/v3; go test -v + - cd ../../Replicant/v3; go test -v + - cd ../../shadow/v3; go test -v diff --git a/transports/Dust/v3/Dust.go b/transports/Dust/v3/Dust.go index 727364b..7711e62 100644 --- a/transports/Dust/v3/Dust.go +++ b/transports/Dust/v3/Dust.go @@ -10,12 +10,12 @@ package Dust import ( "fmt" "github.com/OperatorFoundation/obfs4/common/log" + Dust "github.com/blanu/Dust/go/v2/interface" "golang.org/x/net/proxy" "net" "time" "github.com/OperatorFoundation/shapeshifter-ipc" - "github.com/blanu/Dust/go/v2/interface" ) type dustClient struct { diff --git a/transports/Dust/v3/go.mod b/transports/Dust/v3/go.mod index 9b8d6eb..6fe8fc4 100644 --- a/transports/Dust/v3/go.mod +++ b/transports/Dust/v3/go.mod @@ -1,4 +1,4 @@ -module github.com/OperatorFoundation/shapeshifter-transports/transports/Dust/v2 +module github.com/OperatorFoundation/shapeshifter-transports/transports/Dust/v3 go 1.12 diff --git a/transports/Optimizer/v3/Optimizer_test.go b/transports/Optimizer/v3/Optimizer_test.go index 04936d4..83fa3a9 100644 --- a/transports/Optimizer/v3/Optimizer_test.go +++ b/transports/Optimizer/v3/Optimizer_test.go @@ -1,10 +1,10 @@ package optimizer import ( - "github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v2" - "github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v2" - "github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2" - "github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v2" + "github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3" + "github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3" + "github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3" + "github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3" "golang.org/x/net/proxy" "io/ioutil" "net" diff --git a/transports/Optimizer/v3/go.mod b/transports/Optimizer/v3/go.mod index 8353f14..6dea4f9 100644 --- a/transports/Optimizer/v3/go.mod +++ b/transports/Optimizer/v3/go.mod @@ -1,11 +1,11 @@ -module github.com/OperatorFoundation/shapeshifter-transports/transports/Optimizer/v2 +module github.com/OperatorFoundation/shapeshifter-transports/transports/Optimizer/v3 go 1.12 require ( - github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v2 v2.1.22 - github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v2 v2.1.22 - github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2 v2.1.22 - github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v2 v2.1.22 + github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3 v3.0.1 + github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 v3.0.1 + github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 v3.0.1 + github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 v3.0.1 golang.org/x/net v0.0.0-20200226121028-0de0cce0169b ) diff --git a/transports/Replicant/v3/config.go b/transports/Replicant/v3/config.go index 7d31149..60282f0 100644 --- a/transports/Replicant/v3/config.go +++ b/transports/Replicant/v3/config.go @@ -2,8 +2,8 @@ package replicant import ( "encoding/json" - "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v2/polish" - "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v2/toneburst" + "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v3/polish" + "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v3/toneburst" ) type ClientConfig struct { diff --git a/transports/Replicant/v3/go.mod b/transports/Replicant/v3/go.mod index f317884..37b89b5 100644 --- a/transports/Replicant/v3/go.mod +++ b/transports/Replicant/v3/go.mod @@ -1,4 +1,4 @@ -module github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v2 +module github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v3 go 1.12 diff --git a/transports/Replicant/v3/go.sum b/transports/Replicant/v3/go.sum index c0b8e63..179b733 100644 --- a/transports/Replicant/v3/go.sum +++ b/transports/Replicant/v3/go.sum @@ -9,6 +9,7 @@ github.com/OperatorFoundation/monolith-go/monolith v1.0.4/go.mod h1:qc60ZvCt83Jn github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0 h1:zDYt6FDJwDSX4woVFVK2EMt7fkxU5L5qDNLUjQwA+BQ= github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0/go.mod h1:kB00Ak8Dgn1uZlZHLc/WsUta58Jc+n/ZhCetcPkh42Q= github.com/OperatorFoundation/shapeshifter-transports v2.1.5+incompatible h1:1S3doS1jE/2X0FTiJWakrZVAmknj2IqZ1XL46zBA0XM= +github.com/OperatorFoundation/shapeshifter-transports v2.1.27+incompatible h1:fSIxaLi4g+EPDmb5Ps89wnyWnq57wBhSjV2LfdUMtlE= github.com/OperatorFoundation/shapeshifter-transports/transports v0.0.0-20200218224946-cac72fbc8eb3 h1:D0oWnlYienV6VqTbeGPL4YYJoqCeK6kvBOS2wMv5Brk= github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da h1:KjTM2ks9d14ZYCvmHS9iAKVt9AyzRSqNU1qabPih5BY= github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da/go.mod h1:eHEWzANqSiWQsof+nXEI9bUVUyV6F53Fp89EuCh2EAA= diff --git a/transports/Replicant/v3/persistence.go b/transports/Replicant/v3/persistence.go index d294de9..ad04b5f 100644 --- a/transports/Replicant/v3/persistence.go +++ b/transports/Replicant/v3/persistence.go @@ -5,8 +5,8 @@ import ( "encoding/base64" "encoding/gob" "github.com/OperatorFoundation/monolith-go/monolith" - "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v2/polish" - "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v2/toneburst" + "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v3/polish" + "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v3/toneburst" ) func InitializeGobRegistry() { diff --git a/transports/Replicant/v3/persistence_test.go b/transports/Replicant/v3/persistence_test.go index 3d3cec9..6216e8c 100644 --- a/transports/Replicant/v3/persistence_test.go +++ b/transports/Replicant/v3/persistence_test.go @@ -2,8 +2,8 @@ package replicant import ( "encoding/json" - "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v2/polish" - "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v2/toneburst" + "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v3/polish" + "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v3/toneburst" "io/ioutil" "testing" ) diff --git a/transports/Replicant/v3/replicant.go b/transports/Replicant/v3/replicant.go index c32f691..7ade0e1 100644 --- a/transports/Replicant/v3/replicant.go +++ b/transports/Replicant/v3/replicant.go @@ -11,8 +11,8 @@ import ( "fmt" "net" - "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v2/polish" - "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v2/toneburst" + "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v3/polish" + "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v3/toneburst" ) type ConnectionState struct { diff --git a/transports/Replicant/v3/replicant_test.go b/transports/Replicant/v3/replicant_test.go index a93fc95..a40b502 100644 --- a/transports/Replicant/v3/replicant_test.go +++ b/transports/Replicant/v3/replicant_test.go @@ -3,8 +3,8 @@ package replicant import ( "bytes" "github.com/OperatorFoundation/monolith-go/monolith" - "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v2/polish" - "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v2/toneburst" + "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v3/polish" + "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v3/toneburst" "io/ioutil" "math/rand" "os" diff --git a/transports/Replicant/v3/toneburst/monotone_test.go b/transports/Replicant/v3/toneburst/monotone_test.go deleted file mode 100644 index dfce8ec..0000000 --- a/transports/Replicant/v3/toneburst/monotone_test.go +++ /dev/null @@ -1,63 +0,0 @@ -package toneburst - -//func TestMonotone_Perform(t *testing.T) { -// thing1 := monolith.FixedByteType{Byte: 0xB0} -// thing2 := monolith.FixedByteType{Byte: 0xB1} -// items := []monolith.Monolith{thing1, thing2} -// part := monolith.BytesPart{Items: items} -// parts := []monolith.Monolith{part} -// description := monolith.Description{Parts:parts} -// -// removeSequences := []monolith.Description{description} -// -// addInstance := monolith.Instance{ -// Desc: description, -// Args: make([]interface{}, 0), -// } -// addSequences := []monolith.Instance{addInstance} -// println("Add Sequences count: ", len(addSequences)) -// -// monotoneConfig := MonotoneConfig{ -// AddSequences: addSequences, -// RemoveSequences: removeSequences, -// SpeakFirst: true, -// } -// -// println("Add Sequences count: ", len(monotoneConfig.AddSequences)) -// monotoneInstance := NewMonotone(monotoneConfig) -// go monotoneServer(monotoneInstance) -// -// clientConn, dialError := net.Dial("tcp", "127.0.0.1:2121") -// if dialError != nil { -// println("Dial error: ") -// println(dialError.Error()) -// t.Fail() -// } -// -// performError := monotoneInstance.Perform(clientConn) -// if performError!= nil { -// println("Error on perform: ") -// println(performError.Error()) -// t.Fail() -// } -//} -// -//func monotoneServer(monotoneInstance *Monotone) { -// l, serverErr := net.Listen("tcp", "0.0.0.0:2121") -// if serverErr != nil { -// println(serverErr.Error()) -// return -// } -// -// serverConn, acceptError := l.Accept() -// if acceptError != nil { -// println(acceptError.Error()) -// return -// } -// -// serverPerformError := monotoneInstance.Perform(serverConn) -// if serverPerformError!= nil { -// println("Error on perform: ", serverPerformError) -// return -// } -//} diff --git a/transports/meeklite/v3/go.mod b/transports/meeklite/v3/go.mod index 377b94d..36d48f9 100644 --- a/transports/meeklite/v3/go.mod +++ b/transports/meeklite/v3/go.mod @@ -1,8 +1,7 @@ -module github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v2 +module github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3 go 1.12 require ( - github.com/stretchr/testify v1.5.1 golang.org/x/net v0.0.0-20200202094626-16171245cfb2 ) diff --git a/transports/meekserver/v3/go.mod b/transports/meekserver/v3/go.mod index 3ac5d1d..b3ae1e8 100644 --- a/transports/meekserver/v3/go.mod +++ b/transports/meekserver/v3/go.mod @@ -1,9 +1,8 @@ -module github.com/OperatorFoundation/shapeshifter-transports/transports/meekserver/v2 +module github.com/OperatorFoundation/shapeshifter-transports/transports/meekserver/v3 go 1.12 require ( - git.torproject.org/pluggable-transports/goptlib.git v1.1.0 github.com/deckarep/golang-set v1.7.1 github.com/mufti1/interconv v0.0.0-20190313040840-d7c72925c656 golang.org/x/crypto v0.0.0-20200214034016-1d94cc7ab1c6 diff --git a/transports/obfs2/v3/go.mod b/transports/obfs2/v3/go.mod index 9793304..ce72adc 100644 --- a/transports/obfs2/v3/go.mod +++ b/transports/obfs2/v3/go.mod @@ -1,11 +1,9 @@ -module github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v2 +module github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 go 1.12 require ( github.com/OperatorFoundation/obfs4 v1.0.0 github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0 - github.com/OperatorFoundation/shapeshifter-transports v0.0.0-20200211223228-5b0aa21018a5 - github.com/OperatorFoundation/shapeshifter-transports/transports/Optimizer/v2 v2.1.12 golang.org/x/net v0.0.0-20200226121028-0de0cce0169b ) diff --git a/transports/obfs4/v3/go.mod b/transports/obfs4/v3/go.mod index 68baf42..bf7f6e1 100644 --- a/transports/obfs4/v3/go.mod +++ b/transports/obfs4/v3/go.mod @@ -1,4 +1,4 @@ -module github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2 +module github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 go 1.12 diff --git a/transports/obfs4/v3/handshake_ntor.go b/transports/obfs4/v3/handshake_ntor.go index 6ff9624..6e7e9ac 100644 --- a/transports/obfs4/v3/handshake_ntor.go +++ b/transports/obfs4/v3/handshake_ntor.go @@ -41,7 +41,7 @@ import ( "github.com/OperatorFoundation/obfs4/common/csrand" "github.com/OperatorFoundation/obfs4/common/ntor" "github.com/OperatorFoundation/obfs4/common/replayfilter" - "github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2/framing" + "github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3/framing" ) const ( diff --git a/transports/obfs4/v3/obfs4.go b/transports/obfs4/v3/obfs4.go index ecb0aeb..6e896db 100644 --- a/transports/obfs4/v3/obfs4.go +++ b/transports/obfs4/v3/obfs4.go @@ -40,7 +40,7 @@ import ( "github.com/OperatorFoundation/obfs4/common/probdist" "github.com/OperatorFoundation/obfs4/common/replayfilter" "github.com/OperatorFoundation/shapeshifter-ipc" - "github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2/framing" + "github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3/framing" "golang.org/x/net/proxy" "math/rand" "net" diff --git a/transports/obfs4/v3/packet.go b/transports/obfs4/v3/packet.go index c6a0562..441c113 100644 --- a/transports/obfs4/v3/packet.go +++ b/transports/obfs4/v3/packet.go @@ -34,7 +34,7 @@ import ( "io" "github.com/OperatorFoundation/obfs4/common/drbg" - "github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2/framing" + "github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3/framing" ) const ( diff --git a/transports/shadow/v3/go.mod b/transports/shadow/v3/go.mod index 361d52b..c3db847 100644 --- a/transports/shadow/v3/go.mod +++ b/transports/shadow/v3/go.mod @@ -1,4 +1,4 @@ -module github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v2 +module github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 go 1.12 From 254ebbdbf5181c4eef27cb1eaf095b2f24972c89 Mon Sep 17 00:00:00 2001 From: Bluesaxorcist Date: Fri, 19 Jun 2020 16:00:59 -0500 Subject: [PATCH 03/33] Update go.mod --- transports/Optimizer/v3/go.mod | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/transports/Optimizer/v3/go.mod b/transports/Optimizer/v3/go.mod index 6dea4f9..64e38d3 100644 --- a/transports/Optimizer/v3/go.mod +++ b/transports/Optimizer/v3/go.mod @@ -3,9 +3,9 @@ module github.com/OperatorFoundation/shapeshifter-transports/transports/Optimize go 1.12 require ( - github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3 v3.0.1 - github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 v3.0.1 - github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 v3.0.1 - github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 v3.0.1 + github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3 v3.0.0 + github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 v3.0.0 + github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 v3.0.0 + github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 v3.0.0 golang.org/x/net v0.0.0-20200226121028-0de0cce0169b ) From 39a0973374ca808ec85b5ab50e6546386cb01be6 Mon Sep 17 00:00:00 2001 From: Bluesaxorcist Date: Fri, 19 Jun 2020 16:36:32 -0500 Subject: [PATCH 04/33] switched everything to v3 --- transports/Dust/v3/Dust.go | 10 +++++----- transports/Dust/v3/Dust_test.go | 4 ++-- transports/Optimizer/v3/Optimizer_test.go | 9 ++++++--- transports/Optimizer/v3/go.mod | 8 ++++---- transports/Optimizer/v3/go.sum | 20 +++++++++++-------- .../Replicant/v3/ReplicantClientConfig.json | 2 +- .../Replicant/v3/ReplicantClientConfig1.json | 2 +- .../Replicant/v3/ReplicantServerConfig.json | 2 +- .../Replicant/v3/ReplicantServerConfig1.json | 2 +- transports/Replicant/v3/go.sum | 1 - transports/Replicant/v3/polish/silver.go | 2 ++ transports/Replicant/v3/pt21.go | 16 +++++++-------- transports/Replicant/v3/replicant_test.go | 8 ++++---- transports/meeklite/v3/go.mod | 1 + transports/meeklite/v3/meeklite.go | 18 ++++++++++------- transports/meeklite/v3/meeklite_test.go | 4 ++-- transports/meekserver/v3/go.mod | 1 + transports/meekserver/v3/meekserver_test.go | 4 ++-- transports/meekserver/v3/pt21.go | 10 +++++----- transports/obfs2/v3/go.mod | 2 ++ transports/obfs2/v3/obfs2.go | 8 ++++---- transports/obfs2/v3/obfs2_test.go | 4 ++-- transports/obfs4/v3/obfs4.go | 8 ++++---- transports/obfs4/v3/test_utils.go | 4 ++-- transports/shadow/v3/shadow.go | 8 ++++---- transports/shadow/v3/shadow_test.go | 5 ++++- 26 files changed, 91 insertions(+), 72 deletions(-) diff --git a/transports/Dust/v3/Dust.go b/transports/Dust/v3/Dust.go index 7711e62..6d4a7b8 100644 --- a/transports/Dust/v3/Dust.go +++ b/transports/Dust/v3/Dust.go @@ -10,12 +10,12 @@ package Dust import ( "fmt" "github.com/OperatorFoundation/obfs4/common/log" - Dust "github.com/blanu/Dust/go/v2/interface" "golang.org/x/net/proxy" "net" "time" "github.com/OperatorFoundation/shapeshifter-ipc" + "github.com/blanu/Dust/go/v2/interface" ) type dustClient struct { @@ -90,20 +90,20 @@ func (transport *dustClient) Dial(address string) (net.Conn, error) { } // Create listener for incoming transport connection -func (transport *dustServer) Listen(address string) net.Listener { +func (transport *dustServer) Listen(address string) (net.Listener, error) { addr, resolveErr := pt.ResolveAddr(address) if resolveErr != nil { fmt.Println(resolveErr.Error()) - return nil + return nil, resolveErr } ln, err := net.ListenTCP("tcp", addr) if err != nil { fmt.Println(err.Error()) - return nil + return nil, err } - return newDustTransportListener(ln, transport) + return newDustTransportListener(ln, transport), nil } func (listener *dustTransportListener) Addr() net.Addr { diff --git a/transports/Dust/v3/Dust_test.go b/transports/Dust/v3/Dust_test.go index 2aaacc5..8f01c5b 100644 --- a/transports/Dust/v3/Dust_test.go +++ b/transports/Dust/v3/Dust_test.go @@ -26,8 +26,8 @@ func TestDust(t *testing.T) { } //call listen on the server - serverListener := serverConfig.Listen("127.0.0.1:1234") - if serverListener == nil { + serverListener, listenErr := serverConfig.Listen("127.0.0.1:1234") + if listenErr != nil { t.Fail() return } diff --git a/transports/Optimizer/v3/Optimizer_test.go b/transports/Optimizer/v3/Optimizer_test.go index 83fa3a9..469ba32 100644 --- a/transports/Optimizer/v3/Optimizer_test.go +++ b/transports/Optimizer/v3/Optimizer_test.go @@ -21,7 +21,10 @@ const data = "test" func TestMain(m *testing.M) { config := shadow.NewConfig("1234", "CHACHA20-IETF-POLY1305") - listener := config.Listen("127.0.0.1:1235") + listener, listenErr := config.Listen("127.0.0.1:1235") + if listenErr != nil { + return + } go acceptConnections(listener) _ = obfs4.RunLocalObfs4Server("test") @@ -294,8 +297,8 @@ func RunLocalObfs2Server() { config := obfs2.NewObfs2Transport() //call listen on the server - serverListener := config.Listen("127.0.0.1:1237") - if serverListener == nil { + serverListener, listenErr := config.Listen("127.0.0.1:1237") + if listenErr != nil { return } diff --git a/transports/Optimizer/v3/go.mod b/transports/Optimizer/v3/go.mod index 64e38d3..6dea4f9 100644 --- a/transports/Optimizer/v3/go.mod +++ b/transports/Optimizer/v3/go.mod @@ -3,9 +3,9 @@ module github.com/OperatorFoundation/shapeshifter-transports/transports/Optimize go 1.12 require ( - github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3 v3.0.0 - github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 v3.0.0 - github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 v3.0.0 - github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 v3.0.0 + github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3 v3.0.1 + github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 v3.0.1 + github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 v3.0.1 + github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 v3.0.1 golang.org/x/net v0.0.0-20200226121028-0de0cce0169b ) diff --git a/transports/Optimizer/v3/go.sum b/transports/Optimizer/v3/go.sum index 975af23..4a8ffb2 100644 --- a/transports/Optimizer/v3/go.sum +++ b/transports/Optimizer/v3/go.sum @@ -9,16 +9,20 @@ github.com/OperatorFoundation/shapeshifter-transports v0.0.0-20200211223228-5b0a github.com/OperatorFoundation/shapeshifter-transports v0.0.0-20200211223228-5b0aa21018a5/go.mod h1:u3jvRgYV13oHabVAdXekh3yk9PHfpCKvB8uolQEs4jA= github.com/OperatorFoundation/shapeshifter-transports/transports/Optimizer/v2 v2.1.12/go.mod h1:+A6vQ50ZAHi76GOGtpH730VFirwb1p8E6VJM8M50gNk= github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v2 v2.1.11/go.mod h1:yPCbCoTjLIG+p0xiuRDwW5t+DivxTHqGU5njf89AkHY= -github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v2 v2.1.22 h1:BuiRy5QWa5hI3dNcOGw/Co4GYpU3PONrjrAlUB3pzt4= -github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v2 v2.1.22/go.mod h1:DEfaE6lfJKEG5CkCRks4rXTMi1xYwbYR0sa+JKsgsr0= -github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v2 v2.1.22 h1:ygZ3s1ROaeyfrIjIo1pFAiq73UtOv8iBxZtV5MGZjVc= -github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v2 v2.1.22/go.mod h1:S2qmYjCQzB7XGJ5JMuVDTp2IbQveaAhXQ9BVOx+6KD8= +github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v2 v2.1.25 h1:A8e22dUVgKa+wV8uk0rDMiWrKPYSuwt/Dsi1amNQrIA= +github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v2 v2.1.25/go.mod h1:DEfaE6lfJKEG5CkCRks4rXTMi1xYwbYR0sa+JKsgsr0= +github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3 v3.0.0/go.mod h1:/bbH9BHoTGrmFJFBAYn0NKxQY2C8Au3ZC+IMiSsh42Y= +github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v2 v2.1.25 h1:+Bhvplcf7BNuSoFZ3d0zGAxjP0DyIsHyYQSb0eB6h+k= +github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v2 v2.1.25/go.mod h1:S2qmYjCQzB7XGJ5JMuVDTp2IbQveaAhXQ9BVOx+6KD8= +github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 v3.0.0/go.mod h1:3ZXeGsk1VvTnKpSpH44BukvnWm611AM4l5mcrK35k9k= github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2 v2.1.11/go.mod h1:OUFBnkMmjMHTWqEQlanDOMTgBjU5QARjklwQv9Qovr4= -github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2 v2.1.22 h1:WIs1AFLM7qNWcO6QEksWdldnH2H4WXaD5d25iogN8Nk= -github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2 v2.1.22/go.mod h1:OUFBnkMmjMHTWqEQlanDOMTgBjU5QARjklwQv9Qovr4= +github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2 v2.1.25 h1:s0PD5dU56PjMOJT3EYVDxQMx32ylNCZUbyEP1LavVpg= +github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2 v2.1.25/go.mod h1:OUFBnkMmjMHTWqEQlanDOMTgBjU5QARjklwQv9Qovr4= +github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 v3.0.0/go.mod h1:x62zTwzgTsuG316sGLBc35ijWiJ4a9gSDbLIcvGNZr4= github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v2 v2.1.11/go.mod h1:GN8ahnEHVGcPbR0raxdpWekjgElppspPNAAOpmNxQxU= -github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v2 v2.1.22 h1:F7YHfgEJ2Nq4f4XQFiXI4uMueuZGlQbEIdEIhN2b60s= -github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v2 v2.1.22/go.mod h1:GN8ahnEHVGcPbR0raxdpWekjgElppspPNAAOpmNxQxU= +github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v2 v2.1.25 h1:dCvYI1J7t01UrsJfNpU7kPaRwj2EqZmL3n5Hqam9xEU= +github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v2 v2.1.25/go.mod h1:GN8ahnEHVGcPbR0raxdpWekjgElppspPNAAOpmNxQxU= +github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 v3.0.0/go.mod h1:UBXOdrFoTJKCq9bd5ae+u95S0YPtH+I70IHbVw+qjnQ= github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da h1:KjTM2ks9d14ZYCvmHS9iAKVt9AyzRSqNU1qabPih5BY= github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da/go.mod h1:eHEWzANqSiWQsof+nXEI9bUVUyV6F53Fp89EuCh2EAA= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/transports/Replicant/v3/ReplicantClientConfig.json b/transports/Replicant/v3/ReplicantClientConfig.json index 74bb73f..c75cf9e 100644 --- a/transports/Replicant/v3/ReplicantClientConfig.json +++ b/transports/Replicant/v3/ReplicantClientConfig.json @@ -1 +1 @@ -{"config":"M/+BAwEBDENsaWVudENvbmZpZwH/ggABAgEJVG9uZWJ1cnN0ARAAAQZQb2xpc2gBEAAAAP+8/4IBZmdpdGh1Yi5jb20vT3BlcmF0b3JGb3VuZGF0aW9uL3NoYXBlc2hpZnRlci10cmFuc3BvcnRzL3RyYW5zcG9ydHMvUmVwbGljYW50L3YyL3RvbmVidXJzdC5Nb25vdG9uZUNvbmZpZ/+NAwEBDk1vbm90b25lQ29uZmlnAf+OAAEDAQxBZGRTZXF1ZW5jZXMB/5AAAQ9SZW1vdmVTZXF1ZW5jZXMB/5IAAQpTcGVha0ZpcnN0AQIAAAAq/48DAQEISW5zdGFuY2UB/5AAAQIBBERlc2MB/5IAAQRBcmdzAf+WAAAAJP+RAwEBC0Rlc2NyaXB0aW9uAf+SAAEBAQVQYXJ0cwH/lAAAACH/kwIBARNbXW1vbm9saXRoLk1vbm9saXRoAf+UAAEQAAAo/5UDAQEEQXJncwH/lgABAgEGVmFsdWVzAf+YAAEFSW5kZXgBBAAAABz/lwIBAQ5bXWludGVyZmFjZSB7fQH/mAABEAAA/gG5/45jAQEBATxnaXRodWIuY29tL09wZXJhdG9yRm91bmRhdGlvbi9tb25vbGl0aC1nby9tb25vbGl0aC5CeXRlc1BhcnT/mQMBAQlCeXRlc1BhcnQB/5oAAQEBBUl0ZW1zAf+cAAAAIf+bAgEBE1tdbW9ub2xpdGguQnl0ZVR5cGUB/5wAARAAAHn/mmcBAUBnaXRodWIuY29tL09wZXJhdG9yRm91bmRhdGlvbi9tb25vbGl0aC1nby9tb25vbGl0aC5GaXhlZEJ5dGVUeXBl/50DAQENRml4ZWRCeXRlVHlwZQH/ngABAQEEQnl0ZQEGAAAAB/+eAwETAAAAAQAAAgEAAW1naXRodWIuY29tL09wZXJhdG9yRm91bmRhdGlvbi9zaGFwZXNoaWZ0Z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AAAHn/mmcBAUBnaXRodWIuY29tL09wZXJhdG9yRm91bmRhdGlvbi9tb25vbGl0aC1nby9tb25vbGl0aC5GaXhlZEJ5dGVUeXBl/50DAQENRml4ZWRCeXRlVHlwZQH/ngABAQEEQnl0ZQEGAAAAB/+eAwETAAAAAQAAAgEAAW1naXRodWIuY29tL09wZXJhdG9yRm91bmRhdGlvbi9zaGFwZXNoaWZ0ZXItdHJhbnNwb3J0cy90cmFuc3BvcnRzL1JlcGxpY2FudC92Mi9wb2xpc2guU2lsdmVyUG9saXNoQ2xpZW50Q29uZmln/4cDAQEYU2lsdmVyUG9saXNoQ2xpZW50Q29uZmlnAf+IAAECAQ9TZXJ2ZXJQdWJsaWNLZXkBCgABCUNodW5rU2l6ZQEEAAAATP+ISAFBBOC0bmC6fLUPXiHE00MxBSHmK8AuL74xhbkrKm1ClLjNGFBVahobB3nWq06TEl/GmGC72MbHk2RAb4s5bIBYqv8B/go+AAA="} \ No newline at end of file diff --git a/transports/Replicant/v3/ReplicantClientConfig1.json b/transports/Replicant/v3/ReplicantClientConfig1.json index 7de0974..ba436ee 100644 --- a/transports/Replicant/v3/ReplicantClientConfig1.json +++ b/transports/Replicant/v3/ReplicantClientConfig1.json @@ -1 +1 @@ -{"config":"M/+BAwEBDENsaWVudENvbmZpZwH/ggABAgEJVG9uZWJ1cnN0ARAAAQZQb2xpc2gBEAAAAP+8/4IBZmdpdGh1Yi5jb20vT3BlcmF0b3JGb3VuZGF0aW9uL3NoYXBlc2hpZnRlci10cmFuc3BvcnRzL3RyYW5zcG9ydHMvUmVwbGljYW50L3YyL3RvbmVidXJzdC5Nb25vdG9uZUNvbmZpZ/+NAwEBDk1vbm90b25lQ29uZmlnAf+OAAEDAQxBZGRTZXF1ZW5jZXMB/5AAAQ9SZW1vdmVTZXF1ZW5jZXMB/5IAAQpTcGVha0ZpcnN0AQIAAAAq/48DAQEISW5zdGFuY2UB/5AAAQIBBERlc2MB/5IAAQRBcmdzAf+WAAAAJP+RAwEB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QWfb8pahGIPAueYdNyrFn/Bpl/tk+2kA/lzW7syF7AbqMIT0kGD8UskSh15h4mADnffIfwQZwfHMHdDl4zLewAH+DAgAAA=="} \ No newline at end of file diff --git a/transports/Replicant/v3/ReplicantServerConfig.json b/transports/Replicant/v3/ReplicantServerConfig.json index db61447..3a551f7 100644 --- a/transports/Replicant/v3/ReplicantServerConfig.json +++ b/transports/Replicant/v3/ReplicantServerConfig.json @@ -1 +1 @@ -{"Replicant":{"config":"M/+JAwEBDFNlcnZlckNvbmZpZwH/igABAgEJVG9uZWJ1cnN0ARAAAQZQb2xpc2gBEAAAAP+8/4oBZmdpdGh1Yi5jb20vT3BlcmF0b3JGb3VuZGF0aW9uL3NoYXBlc2hpZnRlci10cmFuc3BvcnRzL3RyYW5zcG9ydHMvUmVwbGljYW50L3YyL3RvbmVidXJzdC5Nb25vdG9uZUNvbmZpZ/+NAwEBDk1vbm90b25lQ29uZmlnAf+OAAEDAQxBZGRTZXF1ZW5jZXMB/5AAAQ9SZW1vdmVTZXF1ZW5jZXMB/5IAAQpTcGVha0ZpcnN0AQIAAAAq/48DAQEISW5zdGFuY2UB/5AAAQIBBERlc2MB/5IAAQRBcmdzAf+WAAAAJP+RAwEBC0Rlc2NyaXB0aW9uAf+SAAEBAQVQYXJ0cwH/lAAAACH/kwIBARNbXW1vbm9saXRoLk1vbm9saXRoAf+UAAEQAAAo/5UDAQEEQXJncwH/lgABAgEGVmFsdWVzAf+YAAEFSW5kZXgBBAAAABz/lwIBAQ5bXWludGVyZmFjZSB7fQH/mAABEAAA/gHI/45iAgEBPGdpdGh1Yi5jb20vT3BlcmF0b3JGb3VuZGF0aW9uL21vbm9saXRoLWdvL21vbm9saXRoLkJ5dGVzUGFydP+ZAwEBCUJ5dGVzUGFydAH/mgABAQEFSXRlbXMB/5wAAAAh/5sCAQETW11tb25vbGl0aC5CeXRlVHlwZQH/nAABEAAAdP+aZwEBQGdpdGh1Yi5jb20vT3BlcmF0b3JGb3VuZGF0aW9uL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FsdWVzAf+YAAEFSW5kZXgBBAAAABz/lwIBAQ5bXWludGVyZmFjZSB7fQH/mAABEAAA/gHI/45iAgEBPGdpdGh1Yi5jb20vT3BlcmF0b3JGb3VuZGF0aW9uL21vbm9saXRoLWdvL21vbm9saXRoLkJ5dGVzUGFydP+ZAwEBCUJ5dGVzUGFydAH/mgABAQEFSXRlbXMB/5wAAAAh/5sCAQETW11tb25vbGl0aC5CeXRlVHlwZQH/nAABEAAAdP+aZwEBQGdpdGh1Yi5jb20vT3BlcmF0b3JGb3VuZGF0aW9uL21vbm9saXRoLWdvL21vbm9saXRoLkZpeGVkQnl0ZVR5cGX/nQMBAQ1GaXhlZEJ5dGVUeXBlAf+eAAEBAQRCeXRlAQYAAAAH/54DARMAAAAAAW1naXRodWIuY29tL09wZXJhdG9yRm91bmRhdGlvbi9zaGFwZXNoaWZ0ZXItdHJhbnNwb3J0cy90cmFuc3BvcnRzL1JlcGxpY2FudC92Mi9wb2xpc2guU2lsdmVyUG9saXNoU2VydmVyQ29uZmln/4sDAQEYU2lsdmVyUG9saXNoU2VydmVyQ29uZmlnAf+MAAEDAQ9TZXJ2ZXJQdWJsaWNLZXkBCgABEFNlcnZlclByaXZhdGVLZXkBCgABCUNodW5rU2l6ZQEEAAAAbv+MagFBBOC0bmC6fLUPXiHE00MxBSHmK8AuL74xhbkrKm1ClLjNGFBVahobB3nWq06TEl/GmGC72MbHk2RAb4s5bIBYqv8BIFAdzShgbHE2q5BpC39qq3rjM8fq5VTxcnx8IcH1XbqwAf4KPgAA"}} \ No newline at end of file diff --git a/transports/Replicant/v3/ReplicantServerConfig1.json b/transports/Replicant/v3/ReplicantServerConfig1.json index 7b00a7b..322368d 100644 --- a/transports/Replicant/v3/ReplicantServerConfig1.json +++ b/transports/Replicant/v3/ReplicantServerConfig1.json @@ -1 +1 @@ -{"Replicant":{"config":"M/+JAwEBDFNlcnZlckNvbmZpZwH/igABAgEJVG9uZWJ1cnN0ARAAAQZQb2xpc2gBEAAAAP+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tRW51bWVyYXRlZEJ5dGVUeXBl/6AHAQQREhMUAEtnaXRodWIuY29tL09wZXJhdG9yRm91bmRhdGlvbi9tb25vbGl0aC1nby9tb25vbGl0aC5SYW5kb21FbnVtZXJhdGVkQnl0ZVR5cGX/oAcBBBESExQAAAAAAW1naXRodWIuY29tL09wZXJhdG9yRm91bmRhdGlvbi9zaGFwZXNoaWZ0ZXItdHJhbnNwb3J0cy90cmFuc3BvcnRzL1JlcGxpY2FudC92Mi9wb2xpc2guU2lsdmVyUG9saXNoU2VydmVyQ29uZmln/4sDAQEYU2lsdmVyUG9saXNoU2VydmVyQ29uZmlnAf+MAAEDAQ9TZXJ2ZXJQdWJsaWNLZXkBCgABEFNlcnZlclByaXZhdGVLZXkBCgABCUNodW5rU2l6ZQEEAAAAbv+MagFBBEFn2/KWoRiDwLnmHTcqxZ/waZf7ZPtpAP5c1u7MhewG6jCE9JBg/FLJEodeYeJgA533yH8EGcHxzB3Q5eMy3sABILO3MRLki0bDKBvrchjhDV4R/RJWZpj7NngFWTIdDW7PAf4MCAAA"}} \ No newline at end of file diff --git a/transports/Replicant/v3/go.sum b/transports/Replicant/v3/go.sum index 179b733..c0b8e63 100644 --- a/transports/Replicant/v3/go.sum +++ b/transports/Replicant/v3/go.sum @@ -9,7 +9,6 @@ github.com/OperatorFoundation/monolith-go/monolith v1.0.4/go.mod h1:qc60ZvCt83Jn github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0 h1:zDYt6FDJwDSX4woVFVK2EMt7fkxU5L5qDNLUjQwA+BQ= github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0/go.mod h1:kB00Ak8Dgn1uZlZHLc/WsUta58Jc+n/ZhCetcPkh42Q= github.com/OperatorFoundation/shapeshifter-transports v2.1.5+incompatible h1:1S3doS1jE/2X0FTiJWakrZVAmknj2IqZ1XL46zBA0XM= -github.com/OperatorFoundation/shapeshifter-transports v2.1.27+incompatible h1:fSIxaLi4g+EPDmb5Ps89wnyWnq57wBhSjV2LfdUMtlE= github.com/OperatorFoundation/shapeshifter-transports/transports v0.0.0-20200218224946-cac72fbc8eb3 h1:D0oWnlYienV6VqTbeGPL4YYJoqCeK6kvBOS2wMv5Brk= github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da h1:KjTM2ks9d14ZYCvmHS9iAKVt9AyzRSqNU1qabPih5BY= github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da/go.mod h1:eHEWzANqSiWQsof+nXEI9bUVUyV6F53Fp89EuCh2EAA= diff --git a/transports/Replicant/v3/polish/silver.go b/transports/Replicant/v3/polish/silver.go index 194e690..132dac1 100644 --- a/transports/Replicant/v3/polish/silver.go +++ b/transports/Replicant/v3/polish/silver.go @@ -151,6 +151,8 @@ func NewSilverClient(config SilverPolishClientConfig) (Connection, error) { } func X963KDF(sharedKeySeed []byte, ephemeralPublicKey []byte) []byte { + + //FIXME: Is this a correct X963 KDF length := 32 output := make([]byte, 0) outlen := 0 diff --git a/transports/Replicant/v3/pt21.go b/transports/Replicant/v3/pt21.go index f17d7bf..e0d0f2c 100644 --- a/transports/Replicant/v3/pt21.go +++ b/transports/Replicant/v3/pt21.go @@ -7,10 +7,10 @@ import ( ) // Create outgoing transport connection -func (config ClientConfig) Dial(address string) net.Conn { +func (config ClientConfig) Dial(address string) (net.Conn, error) { conn, dialErr := net.Dial("tcp", address) if dialErr != nil { - return nil + return nil, dialErr } transportConn, err := NewClientConnection(conn, config) @@ -18,25 +18,25 @@ func (config ClientConfig) Dial(address string) net.Conn { if conn != nil { _ = conn.Close() } - return nil + return nil, err } - return transportConn + return transportConn, nil } // Create listener for incoming transport connection -func (config ServerConfig) Listen(address string) net.Listener { +func (config ServerConfig) Listen(address string) (net.Listener, error) { addr, resolveErr := pt.ResolveAddr(address) if resolveErr != nil { - return nil + return nil, resolveErr } ln, err := net.ListenTCP("tcp", addr) if err != nil { - return nil + return nil, err } - return newReplicantTransportListener(ln, config) + return newReplicantTransportListener(ln, config), nil } func (listener *replicantTransportListener) Addr() net.Addr { diff --git a/transports/Replicant/v3/replicant_test.go b/transports/Replicant/v3/replicant_test.go index a40b502..7289b6c 100644 --- a/transports/Replicant/v3/replicant_test.go +++ b/transports/Replicant/v3/replicant_test.go @@ -148,7 +148,7 @@ func runReplicantServer() { } go func() { - listener := serverConfig.Listen(addr) + listener, _ := serverConfig.Listen(addr) serverStarted <- true lConn, lConnError := listener.Accept() @@ -194,7 +194,7 @@ func replicantConnection(clientConfig ClientConfig, serverConfig ServerConfig, t addr += portString go func() { - listener := serverConfig.Listen(addr) + listener, _ := serverConfig.Listen(addr) serverStarted <- true lConn, lConnError := listener.Accept() @@ -226,8 +226,8 @@ func replicantConnection(clientConfig ClientConfig, serverConfig ServerConfig, t return } - cConn := clientConfig.Dial(addr) - if cConn == nil { + cConn, connErr := clientConfig.Dial(addr) + if connErr != nil { t.Fail() return } diff --git a/transports/meeklite/v3/go.mod b/transports/meeklite/v3/go.mod index 36d48f9..c3fe6e7 100644 --- a/transports/meeklite/v3/go.mod +++ b/transports/meeklite/v3/go.mod @@ -3,5 +3,6 @@ module github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite go 1.12 require ( + github.com/stretchr/testify v1.5.1 golang.org/x/net v0.0.0-20200202094626-16171245cfb2 ) diff --git a/transports/meeklite/v3/meeklite.go b/transports/meeklite/v3/meeklite.go index 21d4002..9a8a765 100644 --- a/transports/meeklite/v3/meeklite.go +++ b/transports/meeklite/v3/meeklite.go @@ -95,19 +95,19 @@ func (transport *MeekTransport) NetworkDialer() proxy.Dialer { } // Dial creates outgoing transport connection -func (transport *MeekTransport) Dial() net.Conn { +func (transport *MeekTransport) Dial() (net.Conn, error) { // FIXME - should use dialer transportConn, err := newMeekClientConn(transport.clientArgs) if err != nil { - return nil + return nil, err } - return transportConn + return transportConn, nil } // Listen for the meek transport does not have a corresponding server, only a client -func (transport *MeekTransport) Listen() net.Listener { - return nil +func (transport *MeekTransport) Listen() (net.Listener, error) { + return nil, nil } // End methods that implement the base.Transport interface @@ -138,8 +138,12 @@ type Config struct { // Dial creates outgoing transport connection func (transport Transport) Dial() (net.Conn, error) { meekTransport := NewMeekTransportWithFront(transport.URL.String(), transport.Front, transport.Dialer) - conn := meekTransport.Dial() - return conn, nil + conn, dialErr := meekTransport.Dial() + if dialErr != nil { + return nil, errors.New("failed to dial") + } else { + return conn, nil + } } func (ca *meekClientArgs) String() string { diff --git a/transports/meeklite/v3/meeklite_test.go b/transports/meeklite/v3/meeklite_test.go index b26d710..c26342a 100644 --- a/transports/meeklite/v3/meeklite_test.go +++ b/transports/meeklite/v3/meeklite_test.go @@ -47,8 +47,8 @@ func TestMeeklite(t *testing.T) { //create client buffer clientBuffer := make([]byte, 4) //call dial on client and check error - clientConn := config.Dial() - if clientConn == nil { + clientConn, connErr := config.Dial() + if connErr != nil { t.Fail() return } diff --git a/transports/meekserver/v3/go.mod b/transports/meekserver/v3/go.mod index b3ae1e8..bc18a26 100644 --- a/transports/meekserver/v3/go.mod +++ b/transports/meekserver/v3/go.mod @@ -3,6 +3,7 @@ module github.com/OperatorFoundation/shapeshifter-transports/transports/meekserv go 1.12 require ( + git.torproject.org/pluggable-transports/goptlib.git v1.1.0 github.com/deckarep/golang-set v1.7.1 github.com/mufti1/interconv v0.0.0-20190313040840-d7c72925c656 golang.org/x/crypto v0.0.0-20200214034016-1d94cc7ab1c6 diff --git a/transports/meekserver/v3/meekserver_test.go b/transports/meekserver/v3/meekserver_test.go index 0f7788f..82607d2 100644 --- a/transports/meekserver/v3/meekserver_test.go +++ b/transports/meekserver/v3/meekserver_test.go @@ -21,8 +21,8 @@ func TestMeekServerListen2(t *testing.T) { t.Fail() return } - listener := meekserverTransport.Listen("127.0.0.1:8080") - if listener == nil { + _, listenErr := meekserverTransport.Listen("127.0.0.1:8080") + if listenErr != nil { t.Fail() return } diff --git a/transports/meekserver/v3/pt21.go b/transports/meekserver/v3/pt21.go index 9aa7242..072b63e 100644 --- a/transports/meekserver/v3/pt21.go +++ b/transports/meekserver/v3/pt21.go @@ -188,13 +188,13 @@ func NewMeekTransportServer(disableTLS bool, acmeEmail string, acmeHostnamesComm // Methods that implement the base.Transport interface // Listen on the meek transport does not have a corresponding server, only a client -func (transport *MeekServer) Listen(address string) net.Listener { +func (transport *MeekServer) Listen(address string) (net.Listener, error) { var ln net.Listener var state *State var err error addr, resolverr := net.ResolveTCPAddr("tcp", address) if resolverr != nil { - return ln + return ln, resolverr } acmeAddr := net.TCPAddr{ IP: addr.IP, @@ -206,7 +206,7 @@ func (transport *MeekServer) Listen(address string) net.Listener { lnHTTP01, err := net.ListenTCP("tcp", &acmeAddr) if err != nil { log.Printf("error opening HTTP-01 ACME listener: %s", err) - return nil + return nil, err } go func() { log.Fatal(http.Serve(lnHTTP01, transport.CertManager.HTTPHandler(nil))) @@ -219,7 +219,7 @@ func (transport *MeekServer) Listen(address string) net.Listener { } if err != nil { - return nil + return nil, err } - return meekListener{server, state} + return meekListener{server, state}, nil } diff --git a/transports/obfs2/v3/go.mod b/transports/obfs2/v3/go.mod index ce72adc..e8e146c 100644 --- a/transports/obfs2/v3/go.mod +++ b/transports/obfs2/v3/go.mod @@ -5,5 +5,7 @@ go 1.12 require ( github.com/OperatorFoundation/obfs4 v1.0.0 github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0 + github.com/OperatorFoundation/shapeshifter-transports v0.0.0-20200211223228-5b0aa21018a5 + github.com/OperatorFoundation/shapeshifter-transports/transports/Optimizer/v2 v2.1.12 golang.org/x/net v0.0.0-20200226121028-0de0cce0169b ) diff --git a/transports/obfs2/v3/obfs2.go b/transports/obfs2/v3/obfs2.go index 1052fe7..58f9c22 100644 --- a/transports/obfs2/v3/obfs2.go +++ b/transports/obfs2/v3/obfs2.go @@ -147,20 +147,20 @@ func (transport *Transport) Dial(address string) (net.Conn, error) { } // Listen creates listener for incoming transport connection -func (transport *Transport) Listen(address string) net.Listener { +func (transport *Transport) Listen(address string) (net.Listener, error) { addr, resolveErr := pt.ResolveAddr(address) if resolveErr != nil { fmt.Println(resolveErr.Error()) - return nil + return nil, resolveErr } ln, err := net.ListenTCP("tcp", addr) if err != nil { fmt.Println(err.Error()) - return nil + return nil, err } - return newObfs2TransportListener(ln) + return newObfs2TransportListener(ln), nil } // Methods that implement the net.Conn interface diff --git a/transports/obfs2/v3/obfs2_test.go b/transports/obfs2/v3/obfs2_test.go index c118e07..5f73e1d 100644 --- a/transports/obfs2/v3/obfs2_test.go +++ b/transports/obfs2/v3/obfs2_test.go @@ -127,8 +127,8 @@ func RunLocalObfs2Server() { config := NewObfs2Transport() //call listen on the server - serverListener := config.Listen("127.0.0.1:1237") - if serverListener == nil { + serverListener, listenErr := config.Listen("127.0.0.1:1237") + if listenErr != nil { return } diff --git a/transports/obfs4/v3/obfs4.go b/transports/obfs4/v3/obfs4.go index 6e896db..7773462 100644 --- a/transports/obfs4/v3/obfs4.go +++ b/transports/obfs4/v3/obfs4.go @@ -229,20 +229,20 @@ func (transport OptimizerTransport) Dial() (net.Conn, error) { } // Listen creates listener for incoming transport connection -func (transport *Transport) Listen(address string) net.Listener { +func (transport *Transport) Listen(address string) (net.Listener, error) { addr, resolveErr := pt.ResolveAddr(address) if resolveErr != nil { fmt.Println(resolveErr.Error()) - return nil + return nil, resolveErr } ln, err := net.ListenTCP("tcp", addr) if err != nil { fmt.Println(err.Error()) - return nil + return nil, err } - return newObfs4TransportListener(transport.serverFactory, ln) + return newObfs4TransportListener(transport.serverFactory, ln), nil } // Close closes the transport listener. diff --git a/transports/obfs4/v3/test_utils.go b/transports/obfs4/v3/test_utils.go index ce8484f..19726b6 100644 --- a/transports/obfs4/v3/test_utils.go +++ b/transports/obfs4/v3/test_utils.go @@ -34,8 +34,8 @@ func RunLocalObfs4Server(data string) bool { return false } //call listen on the server - serverListener := serverConfig.Listen("127.0.0.1:1234") - if serverListener == nil { + serverListener, listenErr := serverConfig.Listen("127.0.0.1:1234") + if listenErr != nil { return false } //Create Server connection and format it for concurrency diff --git a/transports/shadow/v3/shadow.go b/transports/shadow/v3/shadow.go index c1bbb05..f876c07 100644 --- a/transports/shadow/v3/shadow.go +++ b/transports/shadow/v3/shadow.go @@ -63,19 +63,19 @@ func NewTransport(password string, cipherName string, address string) Transport } //Listen checks for a working connection -func (config Config) Listen(address string) net.Listener { +func (config Config) Listen(address string) (net.Listener, error) { cipher, err := shadowsocks.PickCipher(config.CipherName, nil, config.Password) if err != nil { log.Fatal("Failed generating ciphers:", err) - return nil + return nil, err } listener, listenerErr := shadowsocks.Listen("tcp", address, cipher) if listenerErr != nil { log.Fatal("Failed to start listener:", listenerErr) - return nil + return nil, listenerErr } - return listener + return listener, nil } //Dial connects to the address on the named network diff --git a/transports/shadow/v3/shadow_test.go b/transports/shadow/v3/shadow_test.go index fb05dd1..56ca9cf 100644 --- a/transports/shadow/v3/shadow_test.go +++ b/transports/shadow/v3/shadow_test.go @@ -35,7 +35,10 @@ const data = "test" func TestMain(m *testing.M) { config := NewConfig("1234", "CHACHA20-IETF-POLY1305") - listener := config.Listen("127.0.0.1:1236") + listener, listenErr := config.Listen("127.0.0.1:1236") + if listenErr != nil { + return + } go acceptConnections(listener) os.Exit(m.Run()) From 2f99699f2b64bca16290f12a3aec31fd46ea775f Mon Sep 17 00:00:00 2001 From: Bluesaxorcist Date: Thu, 25 Jun 2020 14:04:42 -0500 Subject: [PATCH 05/33] implemented factory listen on shadow and Optimizer --- transports/Optimizer/v3/Optimizer.go | 80 ++++++++++++----------- transports/Optimizer/v3/Optimizer_test.go | 18 ++--- transports/Optimizer/v3/go.mod | 8 +-- transports/shadow/v3/shadow.go | 15 +++++ 4 files changed, 70 insertions(+), 51 deletions(-) diff --git a/transports/Optimizer/v3/Optimizer.go b/transports/Optimizer/v3/Optimizer.go index ba77fb7..434abec 100644 --- a/transports/Optimizer/v3/Optimizer.go +++ b/transports/Optimizer/v3/Optimizer.go @@ -14,19 +14,23 @@ import ( const timeoutInSeconds = 60 -//Transport is a program that transforms network traffic -type Transport interface { +//TransportDialer is a program that transforms network traffic +type TransportDialer interface { Dial() (net.Conn, error) } +type TransportListener interface { + Listen() (net.Listener, error) +} + //Client contains the two parameters needed to use Optimizer. type Client struct { - Transports []Transport + Transports []TransportDialer Strategy Strategy } //NewOptimizerClient is the initializer -func NewOptimizerClient(Transports []Transport, Strategy Strategy) *Client { +func NewOptimizerClient(Transports []TransportDialer, Strategy Strategy) *Client { return &Client{Transports, Strategy} } @@ -54,63 +58,63 @@ func (OptT *Client) Dial() (net.Conn, error) { //Strategy is the method used to choose a transport type Strategy interface { - Choose() Transport - Report(transport Transport, success bool, durationElapsed float64) + Choose() TransportDialer + Report(transport TransportDialer, success bool, durationElapsed float64) } //FirstStrategy returns the first strategy in the array type FirstStrategy struct { - transports []Transport + transports []TransportDialer } //NewFirstStrategy initializes FirstStrategy -func NewFirstStrategy(transports []Transport) Strategy { +func NewFirstStrategy(transports []TransportDialer) Strategy { return &FirstStrategy{transports} } //Choose selects a transport in the array -func (strategy *FirstStrategy) Choose() Transport { +func (strategy *FirstStrategy) Choose() TransportDialer { return strategy.transports[0] } //Report returns if the transport was successful and how long the connection took -func (strategy *FirstStrategy) Report(Transport, bool, float64) { +func (strategy *FirstStrategy) Report(TransportDialer, bool, float64) { } //NewRandomStrategy initializes RandomStrategy -func NewRandomStrategy(transports []Transport) Strategy { +func NewRandomStrategy(transports []TransportDialer) Strategy { return &RandomStrategy{transports} } //RandomStrategy returns a transport at random type RandomStrategy struct { - transports []Transport + transports []TransportDialer } //Choose selects a transport in the array -func (strategy *RandomStrategy) Choose() Transport { +func (strategy *RandomStrategy) Choose() TransportDialer { return strategy.transports[0] } //Report returns if the transport was successful and how long the connection took -func (strategy *RandomStrategy) Report(Transport, bool, float64) { +func (strategy *RandomStrategy) Report(TransportDialer, bool, float64) { } //NewRotateStrategy initializes RotateStrategy -func NewRotateStrategy(transports []Transport) Strategy { +func NewRotateStrategy(transports []TransportDialer) Strategy { return &RotateStrategy{transports, 1} } //RotateStrategy cycles through the list of transports, using a different one each time type RotateStrategy struct { - transports []Transport + transports []TransportDialer index int } //Choose selects a transport in the array -func (strategy *RotateStrategy) Choose() Transport { +func (strategy *RotateStrategy) Choose() TransportDialer { transport := strategy.transports[strategy.index] strategy.index++ if strategy.index >= len(strategy.transports) { @@ -120,7 +124,7 @@ func (strategy *RotateStrategy) Choose() Transport { } //Report returns if the transport was successful and how long the connection took -func (strategy *RotateStrategy) Report(Transport, bool, float64) { +func (strategy *RotateStrategy) Report(TransportDialer, bool, float64) { } @@ -128,19 +132,19 @@ func (strategy *RotateStrategy) Report(Transport, bool, float64) { //choose the best option type TrackStrategy struct { index int - trackMap map[Transport]int - transport []Transport + trackMap map[TransportDialer]int + transport []TransportDialer } //NewTrackStrategy initializes TrackStrategy -func NewTrackStrategy(transport []Transport) Strategy { - track := TrackStrategy{0, map[Transport]int{}, transport} - track.trackMap = make(map[Transport]int) +func NewTrackStrategy(transport []TransportDialer) Strategy { + track := TrackStrategy{0, map[TransportDialer]int{}, transport} + track.trackMap = make(map[TransportDialer]int) return &track } //Choose selects a transport in the array -func (strategy *TrackStrategy) Choose() Transport { +func (strategy *TrackStrategy) Choose() TransportDialer { transport := strategy.transport[strategy.index] score := strategy.findScore(strategy.transport) startIndex := strategy.index @@ -158,7 +162,7 @@ func (strategy *TrackStrategy) Choose() Transport { } //findScore is used to find the score given to each transport based on performance -func (strategy *TrackStrategy) findScore(transports []Transport) int { +func (strategy *TrackStrategy) findScore(transports []TransportDialer) int { transport := transports[strategy.index] score, ok := strategy.trackMap[transport] if ok { @@ -169,7 +173,7 @@ func (strategy *TrackStrategy) findScore(transports []Transport) int { } //incrementIndex is used to cycle through the transport index -func (strategy *TrackStrategy) incrementIndex(transports []Transport) { +func (strategy *TrackStrategy) incrementIndex(transports []TransportDialer) { strategy.index++ if strategy.index >= len(transports) { strategy.index = 0 @@ -177,7 +181,7 @@ func (strategy *TrackStrategy) incrementIndex(transports []Transport) { } //Report returns if the transport was successful and how long the connection took -func (strategy *TrackStrategy) Report(transport Transport, success bool, _ float64) { +func (strategy *TrackStrategy) Report(transport TransportDialer, success bool, _ float64) { if success { strategy.trackMap[transport] = 1 } else { @@ -188,19 +192,19 @@ func (strategy *TrackStrategy) Report(transport Transport, success bool, _ float //minimizeDialDuration is used to find the transport with the fastest response time type minimizeDialDuration struct { index int - trackMap map[Transport]float64 - transports []Transport + trackMap map[TransportDialer]float64 + transports []TransportDialer } //NewMinimizeDialDuration initializes minimizeDialDuration -func NewMinimizeDialDuration(transport []Transport) Strategy { - duration := minimizeDialDuration{0, map[Transport]float64{}, transport} - duration.trackMap = make(map[Transport]float64) +func NewMinimizeDialDuration(transport []TransportDialer) Strategy { + duration := minimizeDialDuration{0, map[TransportDialer]float64{}, transport} + duration.trackMap = make(map[TransportDialer]float64) return &duration } //Choose selects a transport in the array -func (strategy *minimizeDialDuration) Choose() Transport { +func (strategy *minimizeDialDuration) Choose() TransportDialer { transport := strategy.transports[strategy.index] score := strategy.findScore(strategy.transports) startIndex := strategy.index @@ -224,7 +228,7 @@ func (strategy *minimizeDialDuration) Choose() Transport { } //incrementIndex is used to cycle through the transport index -func (strategy *minimizeDialDuration) incrementIndex(transports []Transport) { +func (strategy *minimizeDialDuration) incrementIndex(transports []TransportDialer) { strategy.index++ if strategy.index >= len(transports) { strategy.index = 0 @@ -232,7 +236,7 @@ func (strategy *minimizeDialDuration) incrementIndex(transports []Transport) { } //findScore is used to find the score given to each transport based on performance -func (strategy *minimizeDialDuration) findScore(transports []Transport) float64 { +func (strategy *minimizeDialDuration) findScore(transports []TransportDialer) float64 { transport := transports[strategy.index] score, ok := strategy.trackMap[transport] if ok { @@ -243,7 +247,7 @@ func (strategy *minimizeDialDuration) findScore(transports []Transport) float64 } //Report returns if the transport was successful and how long the connection took -func (strategy *minimizeDialDuration) Report(transport Transport, success bool, durationElapsed float64) { +func (strategy *minimizeDialDuration) Report(transport TransportDialer, success bool, durationElapsed float64) { if success { if durationElapsed < 60 { strategy.trackMap[transport] = durationElapsed @@ -256,9 +260,9 @@ func (strategy *minimizeDialDuration) Report(transport Transport, success bool, } //minDuration assigns a value to the response time -func (strategy *minimizeDialDuration) minDuration() Transport { +func (strategy *minimizeDialDuration) minDuration() TransportDialer { min := 61.0 - var transport Transport = nil + var transport TransportDialer = nil for key, value := range strategy.trackMap { if value < min { min = value diff --git a/transports/Optimizer/v3/Optimizer_test.go b/transports/Optimizer/v3/Optimizer_test.go index 469ba32..864e767 100644 --- a/transports/Optimizer/v3/Optimizer_test.go +++ b/transports/Optimizer/v3/Optimizer_test.go @@ -63,7 +63,7 @@ func TestOptimizerMeekliteDial(t *testing.T) { t.Fail() } meekliteTransport := meeklite.Transport{URL: URL, Front: "a0.awsstatic.com", Address: "127.0.0.1:1235" } - transports := []Transport{meekliteTransport} + transports := []TransportDialer{meekliteTransport} strategy := NewFirstStrategy(transports) optimizerTransport := NewOptimizerClient(transports, strategy) _, err := optimizerTransport.Dial() @@ -82,7 +82,7 @@ func TestShadowDial(t *testing.T) { func TestOptimizerShadowDial(t *testing.T) { shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235") - transports := []Transport{&shadowTransport} + transports := []TransportDialer{&shadowTransport} strategy := NewFirstStrategy(transports) optimizerTransport := NewOptimizerClient(transports, strategy) _, err := optimizerTransport.Dial() @@ -93,7 +93,7 @@ func TestOptimizerShadowDial(t *testing.T) { func TestOptimizerObfs2Dial(t *testing.T) { obfs2Transport := obfs2.New("127.0.0.1:1237", proxy.Direct) - transports := []Transport{obfs2Transport} + transports := []TransportDialer{obfs2Transport} strategy := NewFirstStrategy(transports) optimizerTransport := NewOptimizerClient(transports, strategy) _, err := optimizerTransport.Dial() @@ -126,7 +126,7 @@ func TestOptimizerObfs4Transport_Dial(t *testing.T) { IatMode: 0, Address: "127.0.0.1:1234", Dialer: dialer} - transports := []Transport{obfs4Transport} + transports := []TransportDialer{obfs4Transport} strategy := NewFirstStrategy(transports) optimizerTransport := NewOptimizerClient(transports, strategy) _, err := optimizerTransport.Dial() @@ -148,7 +148,7 @@ func TestOptimizerTransportFirstDial(t *testing.T) { Address: "127.0.0.1:1234", Dialer: dialer} shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235") - transports := []Transport{obfs4Transport, &shadowTransport} + transports := []TransportDialer{obfs4Transport, &shadowTransport} strategy := NewFirstStrategy(transports) optimizerTransport := NewOptimizerClient(transports, strategy) for i := 1; i <= 3; i++ { @@ -173,7 +173,7 @@ func TestOptimizerTransportRandomDial(t *testing.T) { Dialer: dialer, } shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235") - transports := []Transport{obfs4Transport, &shadowTransport} + transports := []TransportDialer{obfs4Transport, &shadowTransport} strategy := NewRandomStrategy(transports) optimizerTransport := NewOptimizerClient(transports, strategy) @@ -199,7 +199,7 @@ func TestOptimizerTransportRotateDial(t *testing.T) { Dialer: dialer, } shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235") - transports := []Transport{obfs4Transport, &shadowTransport} + transports := []TransportDialer{obfs4Transport, &shadowTransport} strategy := NewRotateStrategy(transports) optimizerTransport := NewOptimizerClient(transports, strategy) @@ -225,7 +225,7 @@ func TestOptimizerTransportTrackDial(t *testing.T) { Dialer: dialer, } shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235") - transports := []Transport{obfs4Transport, &shadowTransport} + transports := []TransportDialer{obfs4Transport, &shadowTransport} strategy := NewTrackStrategy(transports) optimizerTransport := NewOptimizerClient(transports, strategy) @@ -251,7 +251,7 @@ func TestOptimizerTransportMinimizeDialDurationDial(t *testing.T) { Dialer: dialer, } shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235") - transports := []Transport{obfs4Transport, &shadowTransport} + transports := []TransportDialer{obfs4Transport, &shadowTransport} strategy := NewMinimizeDialDuration(transports) optimizerTransport := NewOptimizerClient(transports, strategy) diff --git a/transports/Optimizer/v3/go.mod b/transports/Optimizer/v3/go.mod index 6dea4f9..9630b6e 100644 --- a/transports/Optimizer/v3/go.mod +++ b/transports/Optimizer/v3/go.mod @@ -3,9 +3,9 @@ module github.com/OperatorFoundation/shapeshifter-transports/transports/Optimize go 1.12 require ( - github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3 v3.0.1 - github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 v3.0.1 - github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 v3.0.1 - github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 v3.0.1 + github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3 v3.0.2 + github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 v3.0.2 + github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 v3.0.2 + github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 v3.0.2 golang.org/x/net v0.0.0-20200226121028-0de0cce0169b ) diff --git a/transports/shadow/v3/shadow.go b/transports/shadow/v3/shadow.go index f876c07..eff972a 100644 --- a/transports/shadow/v3/shadow.go +++ b/transports/shadow/v3/shadow.go @@ -102,3 +102,18 @@ func (transport *Transport) Dial() (net.Conn, error) { return shadowsocks.Dial("tcp", transport.Address, cipher) } + +func (transport *Transport) Listen() (net.Listener, error) { + cipher, err := shadowsocks.PickCipher(transport.CipherName, nil, transport.Password) + if err != nil { + log.Fatal("Failed generating ciphers:", err) + return nil, err + } + + listener, listenerErr := shadowsocks.Listen("tcp", transport.Address, cipher) + if listenerErr != nil { + log.Fatal("Failed to start listener:", listenerErr) + return nil, listenerErr + } + return listener, nil +} \ No newline at end of file From 3d339911383e0ebb392bcb6ff60a2f9051f583d9 Mon Sep 17 00:00:00 2001 From: Bluesaxorcist Date: Mon, 29 Jun 2020 14:04:51 -0500 Subject: [PATCH 06/33] added factory listener on the other transports --- transports/Dust/v3/Dust.go | 16 +++++++ transports/Optimizer/v3/go.mod | 8 ++-- transports/Replicant/v3/Optimizer.go | 21 ++++++++- .../Replicant/v3/ReplicantClientConfig.json | 2 +- .../Replicant/v3/ReplicantClientConfig1.json | 2 +- .../Replicant/v3/ReplicantServerConfig.json | 2 +- .../Replicant/v3/ReplicantServerConfig1.json | 2 +- transports/meekserver/v3/pt21.go | 47 ++++++++++++++++++- transports/obfs2/v3/obfs2.go | 16 +++++++ transports/obfs4/v3/obfs4.go | 16 +++++++ 10 files changed, 120 insertions(+), 12 deletions(-) diff --git a/transports/Dust/v3/Dust.go b/transports/Dust/v3/Dust.go index 6d4a7b8..85de4e6 100644 --- a/transports/Dust/v3/Dust.go +++ b/transports/Dust/v3/Dust.go @@ -64,6 +64,22 @@ func (transport Transport) Dial() (net.Conn, error) { return conn, nil } } + +func (transport Transport) Listen() (net.Listener, error) { + addr, resolveErr := pt.ResolveAddr(transport.Address) + if resolveErr != nil { + fmt.Println(resolveErr.Error()) + return nil, resolveErr + } + + ln, err := net.ListenTCP("tcp", addr) + if err != nil { + fmt.Println(err.Error()) + return nil, err + } +//TODO do we need to write an initializer function that imitates newDustTransportListener or add a parameter to Transport? + return ln, nil +} //end optimizer code func newDustTransportListener(listener *net.TCPListener, transport *dustServer) *dustTransportListener { diff --git a/transports/Optimizer/v3/go.mod b/transports/Optimizer/v3/go.mod index 9630b6e..c754734 100644 --- a/transports/Optimizer/v3/go.mod +++ b/transports/Optimizer/v3/go.mod @@ -3,9 +3,9 @@ module github.com/OperatorFoundation/shapeshifter-transports/transports/Optimize go 1.12 require ( - github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3 v3.0.2 - github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 v3.0.2 - github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 v3.0.2 - github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 v3.0.2 + github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3 v3.0.3 + github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 v3.0.3 + github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 v3.0.3 + github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 v3.0.3 golang.org/x/net v0.0.0-20200226121028-0de0cce0169b ) diff --git a/transports/Replicant/v3/Optimizer.go b/transports/Replicant/v3/Optimizer.go index 9af583c..90fce50 100644 --- a/transports/Replicant/v3/Optimizer.go +++ b/transports/Replicant/v3/Optimizer.go @@ -1,6 +1,7 @@ package replicant import ( + pt "github.com/OperatorFoundation/shapeshifter-ipc" "golang.org/x/net/proxy" "net" ) @@ -8,11 +9,13 @@ import ( // This makes Replicant compliant with Optimizer type Transport struct { Config ClientConfig + Sconfig ServerConfig + //TODO was adding Sconfig the right move? after running the tests, nothing in the initial code was broken or failing + //TODO Do we need to add a test for the dial and listen that take nothing? Address string Dialer proxy.Dialer } -// TODO: the dial we call currently does not return an error func (transport Transport) Dial() (net.Conn, error) { conn, dialErr := transport.Dialer.Dial("tcp", transport.Address) if dialErr != nil { @@ -27,7 +30,21 @@ func (transport Transport) Dial() (net.Conn, error) { } return transportConn, nil + } + +func (transport Transport) Listen() (net.Listener, error) { + addr, resolveErr := pt.ResolveAddr(transport.Address) + if resolveErr != nil { + return nil, resolveErr + } + + ln, err := net.ListenTCP("tcp", addr) + if err != nil { + return nil, err + } + return newReplicantTransportListener(ln, transport.Sconfig), nil +} //replicantTransport := New(transport.Config, transport.Dialer) //conn := replicantTransport.Dial(transport.Address) //conn, err:= replicantTransport.Dial(transport.Address), errors.New("connection failed") @@ -37,5 +54,5 @@ func (transport Transport) Dial() (net.Conn, error) { // return conn, nil //} //return conn, nil -} + diff --git a/transports/Replicant/v3/ReplicantClientConfig.json b/transports/Replicant/v3/ReplicantClientConfig.json index c75cf9e..9851ff3 100644 --- a/transports/Replicant/v3/ReplicantClientConfig.json +++ b/transports/Replicant/v3/ReplicantClientConfig.json @@ -1 +1 @@ -{"config":"M/+BAwE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ZWRCeXRlVHlwZQH/ngABAQEEQnl0ZQEGAAAAB/+eAwETAAAAAQAAAgEAAW1naXRodWIuY29tL09wZXJhdG9yRm91bmRhdGlvbi9zaGFwZXNoaWZ0ZXItdHJhbnNwb3J0cy90cmFuc3BvcnRzL1JlcGxpY2FudC92My9wb2xpc2guU2lsdmVyUG9saXNoQ2xpZW50Q29uZmln/4cDAQEYU2lsdmVyUG9saXNoQ2xpZW50Q29uZmlnAf+IAAECAQ9TZXJ2ZXJQdWJsaWNLZXkBCgABCUNodW5rU2l6ZQEEAAAATP+ISAFBBP/v79qkXCOE7ekcRqXYyEoCP6f1orHF1aegFLQtXNgEhe7udVJ72f3sMHAhN8sqJyzMdPWz7ZPRi5gmvNwrEPEB/griAAA="} \ No newline at end of file diff --git a/transports/Replicant/v3/ReplicantClientConfig1.json b/transports/Replicant/v3/ReplicantClientConfig1.json index ba436ee..5ff8337 100644 --- a/transports/Replicant/v3/ReplicantClientConfig1.json +++ b/transports/Replicant/v3/ReplicantClientConfig1.json @@ -1 +1 @@ -{"config":"M/+BAwEBDENsaWVudENvbmZpZwH/ggABAgEJVG9uZWJ1cnN0ARAAAQZQb2xpc2gBEAAAAP+8/4IBZmdpdGh1Yi5jb20vT3BlcmF0b3JGb3VuZGF0aW9uL3NoYXBlc2hpZnRlci10cmFuc3BvcnRzL3RyYW5zcG9ydHMvUmVwbGljYW50L3YyL3RvbmVidXJzdC5Nb25vdG9uZUNvbmZpZ/+NAwEBDk1vbm90b25lQ29uZmlnAf+OAAEDAQxBZGRTZXF1ZW5jZXMB/5AAAQ9SZW1vdmVTZXF1ZW5jZXMB/5IAAQpTcGVha0ZpcnN0AQIAAAAq/48DAQEISW5zdGFuY2UB/5AAAQIBBERlc2MB/5IAAQRBcmdzAf+WAAAAJP+RAwEBC0Rlc2NyaXB0aW9uAf+SAAEBAQVQYXJ0cwH/lAAAACH/kwIBARNbXW1vbm9saXRoLk1vbm9saXRoAf+UAAEQAAAo/5UDAQEEQXJncwH/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file diff --git a/transports/Replicant/v3/ReplicantServerConfig.json b/transports/Replicant/v3/ReplicantServerConfig.json index 3a551f7..b6082a4 100644 --- a/transports/Replicant/v3/ReplicantServerConfig.json +++ b/transports/Replicant/v3/ReplicantServerConfig.json @@ -1 +1 @@ -{"Replicant":{"config":"M/+JAwEBDFNlcnZlckNvbmZpZwH/igABAgEJVG9uZWJ1cnN0ARAAAQZQb2xpc2gBEAAAAP+8/4oBZmdpdGh1Yi5jb20vT3BlcmF0b3JGb3VuZGF0aW9uL3NoYXBlc2hpZnRlci10cmFuc3BvcnRzL3RyYW5zcG9ydHMvUmVwbGljYW50L3YyL3RvbmVidXJzdC5Nb25vdG9uZUNvbmZpZ/+NAwEBDk1vbm90b25lQ29uZmlnAf+OAAEDAQxBZGRTZXF1ZW5jZXMB/5AAAQ9SZW1vdmVTZXF1ZW5jZXMB/5IAAQpTcGVha0ZpcnN0AQIAAAAq/48DAQEISW5zdGFuY2UB/5AAAQIBBERlc2MB/5IAAQRBcmdzAf+WAAAAJP+RAwEBC0Rlc2NyaXB0aW9uAf+SAAEBAQVQYXJ0cwH/lAAAACH/kwIBARNbXW1vbm9saXRoLk1vbm9saXRoAf+UAAEQAAAo/5UDAQEEQXJncwH/lgABAgEGVmFsdWVzAf+YAAEFSW5kZXgBBAAAABz/lwIBAQ5bXWludGVyZmFjZSB7fQH/mAABEAAA/gHI/45iAgEBPGdpdGh1Yi5jb20vT3BlcmF0b3JGb3VuZGF0aW9uL21vbm9saXRoLWdvL21vbm9saXRoLkJ5dGVzUGFydP+ZAwEBCUJ5dGVzUGFydAH/mgABAQEFSXRlbXMB/5wAAAAh/5sCAQETW11tb25vbGl0aC5CeXRlVHlwZQH/nAABEAAAdP+aZwEBQGdpdGh1Yi5jb20vT3BlcmF0b3JGb3VuZGF0aW9uL21vbm9saXRoLWdvL21vbm9saXRoLkZpeGVkQnl0ZVR5cGX/nQMBAQ1GaXhlZEJ5dGVUeXBlAf+eAAEBAQRCeXRlAQYAAAAH/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b3VuZGF0aW9uL21vbm9saXRoLWdvL21vbm9saXRoLkJ5dGVzUGFydP+ZAwEBCUJ5dGVzUGFydAH/mgABAQEFSXRlbXMB/5wAAAAh/5sCAQETW11tb25vbGl0aC5CeXRlVHlwZQH/nAABEAAAdP+aZwEBQGdpdGh1Yi5jb20vT3BlcmF0b3JGb3VuZGF0aW9uL21vbm9saXRoLWdvL21vbm9saXRoLkZpeGVkQnl0ZVR5cGX/nQMBAQ1GaXhlZEJ5dGVUeXBlAf+eAAEBAQRCeXRlAQYAAAAH/54DARMAAAAAAW1naXRodWIuY29tL09wZXJhdG9yRm91bmRhdGlvbi9zaGFwZXNoaWZ0ZXItdHJhbnNwb3J0cy90cmFuc3BvcnRzL1JlcGxpY2FudC92My9wb2xpc2guU2lsdmVyUG9saXNoU2VydmVyQ29uZmln/4sDAQEYU2lsdmVyUG9saXNoU2VydmVyQ29uZmlnAf+MAAEDAQ9TZXJ2ZXJQdWJsaWNLZXkBCgABEFNlcnZlclByaXZhdGVLZXkBCgABCUNodW5rU2l6ZQEEAAAAbv+MagFBBP/v79qkXCOE7ekcRqXYyEoCP6f1orHF1aegFLQtXNgEhe7udVJ72f3sMHAhN8sqJyzMdPWz7ZPRi5gmvNwrEPEBIO842+Q4BCDUNO4PFisyuhjqRO/WUi+3f8hpAhiO/yHYAf4K4gAA"}} \ No newline at end of file diff --git a/transports/Replicant/v3/ReplicantServerConfig1.json b/transports/Replicant/v3/ReplicantServerConfig1.json index 322368d..a34a20c 100644 --- a/transports/Replicant/v3/ReplicantServerConfig1.json +++ b/transports/Replicant/v3/ReplicantServerConfig1.json @@ -1 +1 @@ -{"Replicant":{"config":"M/+JAwEBDFNlcnZlckNvbmZpZwH/igABAgEJVG9uZWJ1cnN0ARAAAQZQb2xpc2gBEAAAAP+8/4oBZmdpdGh1Yi5jb20vT3BlcmF0b3JGb3VuZGF0aW9uL3NoYXBlc2hpZnRlci10cmFuc3BvcnRzL3RyYW5zcG9ydHMvUmVwbGljYW50L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kb21FbnVtZXJhdGVkQnl0ZVR5cGX/oAcBBBESExQAAAAAAW1naXRodWIuY29tL09wZXJhdG9yRm91bmRhdGlvbi9zaGFwZXNoaWZ0ZXItdHJhbnNwb3J0cy90cmFuc3BvcnRzL1JlcGxpY2FudC92My9wb2xpc2guU2lsdmVyUG9saXNoU2VydmVyQ29uZmln/4sDAQEYU2lsdmVyUG9saXNoU2VydmVyQ29uZmlnAf+MAAEDAQ9TZXJ2ZXJQdWJsaWNLZXkBCgABEFNlcnZlclByaXZhdGVLZXkBCgABCUNodW5rU2l6ZQEEAAAAbv+MagFBBPMGS1h+Mg1uPraVAs8z92ejZ1TxXy9+Qgr0g/EnFa7MmQiAs5rlYrMENgOMqfmpled7AuYD89eRSfH7/Jo0e0sBILX69hSt+cQzUYAPLKn/16JJ7h/0vcIecMdpA5PomnfHAf4J2AAA"}} \ No newline at end of file diff --git a/transports/meekserver/v3/pt21.go b/transports/meekserver/v3/pt21.go index 072b63e..ef550df 100644 --- a/transports/meekserver/v3/pt21.go +++ b/transports/meekserver/v3/pt21.go @@ -50,6 +50,13 @@ type MeekServer struct { AcmeHostname string CertManager *autocert.Manager } +//TODO I added this struct imitating MeekServer struct that has only the bare minimum parameters that the listener uses with the addition of Address +//TODO Was this a 'pro-gamer move'? +type Transport struct { + DisableTLS bool + CertManager *autocert.Manager + Address string +} //Config contains arguments formatted for a json file type Config struct { @@ -109,8 +116,8 @@ func (conn meekServerConn) Read(b []byte) (n int, err error) { if len(conn.session.Or.readBuffer) == 0 { return 0, nil } - copy(b, conn.session.Or.readBuffer) - conn.session.Or.readBuffer = conn.session.Or.readBuffer[:0] + copy(b, conn.session.Or.readBuffer) + conn.session.Or.readBuffer = conn.session.Or.readBuffer[:0] return len(b), nil } @@ -223,3 +230,39 @@ func (transport *MeekServer) Listen(address string) (net.Listener, error) { } return meekListener{server, state}, nil } + +func (transport *Transport) Listen() (net.Listener, error) { + var ln net.Listener + var state *State + var err error + addr, resolverr := net.ResolveTCPAddr("tcp", transport.Address) + if resolverr != nil { + return ln, resolverr + } + acmeAddr := net.TCPAddr{ + IP: addr.IP, + Port: 80, + Zone: "", + } + acmeAddr.Port = 80 + log.Printf("starting HTTP-01 ACME listener on %s", acmeAddr.String()) + lnHTTP01, err := net.ListenTCP("tcp", &acmeAddr) + if err != nil { + log.Printf("error opening HTTP-01 ACME listener: %s", err) + return nil, err + } + go func() { + log.Fatal(http.Serve(lnHTTP01, transport.CertManager.HTTPHandler(nil))) + }() + var server *http.Server + if transport.DisableTLS { + server, state, err = startServer(addr) + } else { + server, state, err = startServerTLS(addr, transport.CertManager.GetCertificate) + } + if err != nil { + + return nil, err + } + return meekListener{server, state}, nil +} diff --git a/transports/obfs2/v3/obfs2.go b/transports/obfs2/v3/obfs2.go index 58f9c22..e485e88 100644 --- a/transports/obfs2/v3/obfs2.go +++ b/transports/obfs2/v3/obfs2.go @@ -88,6 +88,22 @@ func (transport OptimizerTransport) Dial() (net.Conn, error) { return transportConn, nil } +func (transport OptimizerTransport) Listen() (net.Listener, error) { + addr, resolveErr := pt.ResolveAddr(transport.Address) + if resolveErr != nil { + fmt.Println(resolveErr.Error()) + return nil, resolveErr + } + + ln, err := net.ListenTCP("tcp", addr) + if err != nil { + fmt.Println(err.Error()) + return nil, err + } + + return newObfs2TransportListener(ln), nil +} + // Transport is the obfs2 implementation of the base.Transport interface. type Transport struct { dialer proxy.Dialer diff --git a/transports/obfs4/v3/obfs4.go b/transports/obfs4/v3/obfs4.go index 7773462..2f76824 100644 --- a/transports/obfs4/v3/obfs4.go +++ b/transports/obfs4/v3/obfs4.go @@ -245,6 +245,22 @@ func (transport *Transport) Listen(address string) (net.Listener, error) { return newObfs4TransportListener(transport.serverFactory, ln), nil } +func (transport *OptimizerTransport) Listen() (net.Listener, error) { + addr, resolveErr := pt.ResolveAddr(transport.Address) + if resolveErr != nil { + fmt.Println(resolveErr.Error()) + return nil, resolveErr + } + + ln, err := net.ListenTCP("tcp", addr) + if err != nil { + fmt.Println(err.Error()) + return nil, err + } +//TODO Do we need to write a function to imitate newObfs4TransportListener or add another parameter to OptimizerTransport? + return ln, nil +} + // Close closes the transport listener. func (transport *Transport) Close() error { return nil From 15070f3541abd7bbeb4963ff2d15b4b7cb93b225 Mon Sep 17 00:00:00 2001 From: Bluesaxorcist Date: Wed, 8 Jul 2020 15:43:35 -0500 Subject: [PATCH 07/33] added more factory functions --- transports/Dust/v3/Dust.go | 15 ++++++- transports/Dust/v3/Dust_test.go | 67 ++++++++++++++++++++++++++++ transports/Replicant/v3/Optimizer.go | 33 +++++++++++--- transports/meekserver/v3/pt21.go | 7 +++ transports/obfs4/v3/obfs4.go | 46 ++++++++++++++----- transports/obfs4/v3/obfs4_test.go | 1 + 6 files changed, 150 insertions(+), 19 deletions(-) diff --git a/transports/Dust/v3/Dust.go b/transports/Dust/v3/Dust.go index 85de4e6..64b9e25 100644 --- a/transports/Dust/v3/Dust.go +++ b/transports/Dust/v3/Dust.go @@ -50,11 +50,22 @@ type Transport struct { ServerPublic string Address string Dialer proxy.Dialer + ServerConfig *dustServer } type Config struct { ServerPublic string `json:"server-public"` } + +func New(serverPublic string, address string, dialer proxy.Dialer, serverConfig *dustServer) Transport { + return Transport{ + ServerPublic: serverPublic, + Address: address, + Dialer: dialer, + ServerConfig: serverConfig, + } +} + func (transport Transport) Dial() (net.Conn, error) { dustTransport := NewDustClient(transport.ServerPublic, transport.Dialer) conn, err := dustTransport.Dial(transport.Address) @@ -77,8 +88,8 @@ func (transport Transport) Listen() (net.Listener, error) { fmt.Println(err.Error()) return nil, err } -//TODO do we need to write an initializer function that imitates newDustTransportListener or add a parameter to Transport? - return ln, nil + + return newDustTransportListener(ln, transport.ServerConfig), nil } //end optimizer code diff --git a/transports/Dust/v3/Dust_test.go b/transports/Dust/v3/Dust_test.go index 8f01c5b..11daf1d 100644 --- a/transports/Dust/v3/Dust_test.go +++ b/transports/Dust/v3/Dust_test.go @@ -9,6 +9,7 @@ package Dust import ( + "golang.org/x/net/proxy" "testing" ) @@ -82,3 +83,69 @@ func TestDust(t *testing.T) { return } } + +func TestDustV3(t *testing.T) { + //create a server + serverConfig := dustServer{ + serverPrivkey: nil, + dialer: nil, + } + + transport := New("", "127.0.0.1:1234", proxy.Direct, &serverConfig) + //call listen on the server + serverListener, listenErr := transport.Listen() + if listenErr != nil { + t.Fail() + return + } + + //Create Server connection and format it for concurrency + go func() { + //create server buffer + serverBuffer := make([]byte, 4) + + //create serverConn + serverConn, acceptErr := serverListener.Accept() + if acceptErr != nil { + t.Fail() + return + } + + //read on server side + _, serverReadErr := serverConn.Read(serverBuffer) + if serverReadErr != nil { + t.Fail() + return + } + + //write data from serverConn for client to read + _, serverWriteErr := serverConn.Write([]byte(data)) + if serverWriteErr != nil { + t.Fail() + return + } + }() + + //create client buffer + clientBuffer := make([]byte, 4) + //call dial on client and check error + clientConn, dialErr := transport.Dial() + if dialErr != nil { + t.Fail() + return + } + + //write data from clientConn for server to read + _, clientWriteErr := clientConn.Write([]byte(data)) + if clientWriteErr != nil { + t.Fail() + return + } + + //read on client side + _, clientReadErr := clientConn.Read(clientBuffer) + if clientReadErr != nil { + t.Fail() + return + } +} diff --git a/transports/Replicant/v3/Optimizer.go b/transports/Replicant/v3/Optimizer.go index 90fce50..9576405 100644 --- a/transports/Replicant/v3/Optimizer.go +++ b/transports/Replicant/v3/Optimizer.go @@ -7,16 +7,35 @@ import ( ) // This makes Replicant compliant with Optimizer -type Transport struct { +type TransportClient struct { Config ClientConfig - Sconfig ServerConfig - //TODO was adding Sconfig the right move? after running the tests, nothing in the initial code was broken or failing - //TODO Do we need to add a test for the dial and listen that take nothing? Address string Dialer proxy.Dialer } -func (transport Transport) Dial() (net.Conn, error) { +type TransportServer struct { + Config ServerConfig + Address string + Dialer proxy.Dialer +} + +func NewClient(config ClientConfig, address string, dialer proxy.Dialer) TransportClient { + return TransportClient{ + Config: config, + Address: address, + Dialer: dialer, + } +} + +func NewServer(config ServerConfig, address string, dialer proxy.Dialer) TransportServer { + return TransportServer{ + Config: config, + Address: address, + Dialer: dialer, + } +} + +func (transport TransportClient) Dial() (net.Conn, error) { conn, dialErr := transport.Dialer.Dial("tcp", transport.Address) if dialErr != nil { return nil, dialErr @@ -32,7 +51,7 @@ func (transport Transport) Dial() (net.Conn, error) { return transportConn, nil } -func (transport Transport) Listen() (net.Listener, error) { +func (transport TransportServer) Listen() (net.Listener, error) { addr, resolveErr := pt.ResolveAddr(transport.Address) if resolveErr != nil { return nil, resolveErr @@ -43,7 +62,7 @@ func (transport Transport) Listen() (net.Listener, error) { return nil, err } - return newReplicantTransportListener(ln, transport.Sconfig), nil + return newReplicantTransportListener(ln, transport.Config), nil } //replicantTransport := New(transport.Config, transport.Dialer) //conn := replicantTransport.Dial(transport.Address) diff --git a/transports/meekserver/v3/pt21.go b/transports/meekserver/v3/pt21.go index ef550df..564d34d 100644 --- a/transports/meekserver/v3/pt21.go +++ b/transports/meekserver/v3/pt21.go @@ -80,6 +80,13 @@ type fakeConn struct { writeBuffer []byte } +func New(disableTLS bool, certManager *autocert.Manager, address string) Transport { + return Transport{ + DisableTLS: disableTLS, + CertManager: certManager, + Address: address, + } +} func (listener meekListener) Accept() (net.Conn, error) { state := listener.state state.lock.Lock() diff --git a/transports/obfs4/v3/obfs4.go b/transports/obfs4/v3/obfs4.go index 2f76824..afbad20 100644 --- a/transports/obfs4/v3/obfs4.go +++ b/transports/obfs4/v3/obfs4.go @@ -111,7 +111,7 @@ type ClientArgs struct { } //NewObfs4Server initializes the obfs4 server side -func NewObfs4Server(stateDir string) (*Transport, error) { +func NewObfs4Server(stateDir string) (*ServerFactory, error) { args := make(pt.Args) st, err := serverStateFromArgs(stateDir, &args) if err != nil { @@ -149,7 +149,7 @@ func NewObfs4Server(stateDir string) (*Transport, error) { sf := &ServerFactory{&ptArgs, st.nodeID, st.identityKey, st.drbgSeed, iatSeed, st.iatMode, filter, rng.Intn(maxCloseDelayBytes), rng.Intn(maxCloseDelay)} - return &Transport{dialer: nil, serverFactory: sf, clientArgs: nil}, nil + return sf, nil } //NewObfs4Client initializes the obfs4 client side @@ -175,7 +175,7 @@ func NewObfs4Client(certString string, iatMode int, dialer proxy.Dialer) (*Trans if dialer == nil { return &Transport{dialer: proxy.Direct, serverFactory: nil, clientArgs: &ClientArgs{nodeID, publicKey, sessionKey, iatMode}}, nil } - return &Transport{dialer: dialer, serverFactory: nil, clientArgs: &ClientArgs{nodeID, publicKey, sessionKey, iatMode}}, nil + return &Transport{dialer: dialer, serverFactory: nil, clientArgs: &ClientArgs{nodeID, publicKey, sessionKey, iatMode}}, nil } @@ -200,23 +200,49 @@ func (transport *Transport) Dial(address string) (net.Conn, error) { return transportConn, nil } - -//OptimizerTransport contains parameters to be used in Optimizer -type OptimizerTransport struct { +//TransportClient contains parameters to be used in Optimizer +type TransportClient struct { CertString string IatMode int Address string Dialer proxy.Dialer } +type TransportServer struct { + ServerFactory *ServerFactory + Address string +} + //Config contains arguments formatted for a json file type Config struct { CertString string `json:"cert"` IatMode string `json:"iat-mode"` } +func NewClient(certString string, iatMode int, address string, dialer proxy.Dialer) TransportClient { + return TransportClient{ + CertString: certString, + IatMode: iatMode, + Address: address, + Dialer: dialer, + } +} + +func NewServer(stateDir string, address string) (*TransportServer, error) { + sf, sFError := NewObfs4Server(stateDir) + + if sFError != nil { + return nil, sFError + } + transport := &TransportServer{ + ServerFactory: sf, + Address: address, + } + return transport, nil +} + // Dial creates outgoing transport connection -func (transport OptimizerTransport) Dial() (net.Conn, error) { +func (transport TransportClient) Dial() (net.Conn, error) { Obfs4Transport, err := NewObfs4Client(transport.CertString, transport.IatMode, transport.Dialer) if err != nil { return nil, err @@ -245,7 +271,7 @@ func (transport *Transport) Listen(address string) (net.Listener, error) { return newObfs4TransportListener(transport.serverFactory, ln), nil } -func (transport *OptimizerTransport) Listen() (net.Listener, error) { +func (transport *TransportServer) Listen() (net.Listener, error) { addr, resolveErr := pt.ResolveAddr(transport.Address) if resolveErr != nil { fmt.Println(resolveErr.Error()) @@ -257,8 +283,8 @@ func (transport *OptimizerTransport) Listen() (net.Listener, error) { fmt.Println(err.Error()) return nil, err } -//TODO Do we need to write a function to imitate newObfs4TransportListener or add another parameter to OptimizerTransport? - return ln, nil + + return newObfs4TransportListener(transport.ServerFactory, ln), nil } // Close closes the transport listener. diff --git a/transports/obfs4/v3/obfs4_test.go b/transports/obfs4/v3/obfs4_test.go index 9f2beec..49db723 100644 --- a/transports/obfs4/v3/obfs4_test.go +++ b/transports/obfs4/v3/obfs4_test.go @@ -73,3 +73,4 @@ func TestObfs4(t *testing.T) { return } } + From 9094dbf09328c504e6b7315222c843dc009264ab Mon Sep 17 00:00:00 2001 From: Bluesaxorcist Date: Thu, 9 Jul 2020 18:16:41 -0500 Subject: [PATCH 08/33] fixed the shapeshifter-ipc being the wrong version --- transports/Dust/v3/Dust.go | 2 +- transports/Dust/v3/go.mod | 2 +- transports/Dust/v3/go.sum | 4 ++-- transports/Replicant/v3/Optimizer.go | 2 +- transports/Replicant/v3/go.mod | 2 +- transports/Replicant/v3/go.sum | 14 ++------------ transports/Replicant/v3/pt21.go | 2 +- transports/obfs2/v3/go.mod | 4 +--- transports/obfs2/v3/go.sum | 24 ++---------------------- transports/obfs2/v3/obfs2.go | 2 +- transports/obfs4/v3/go.mod | 1 + transports/obfs4/v3/go.sum | 2 ++ transports/obfs4/v3/obfs4.go | 16 ++++++++-------- transports/obfs4/v3/statefile.go | 11 +++++------ 14 files changed, 29 insertions(+), 59 deletions(-) diff --git a/transports/Dust/v3/Dust.go b/transports/Dust/v3/Dust.go index 64b9e25..bcf6262 100644 --- a/transports/Dust/v3/Dust.go +++ b/transports/Dust/v3/Dust.go @@ -14,7 +14,7 @@ import ( "net" "time" - "github.com/OperatorFoundation/shapeshifter-ipc" + "github.com/OperatorFoundation/shapeshifter-ipc/v2" "github.com/blanu/Dust/go/v2/interface" ) diff --git a/transports/Dust/v3/go.mod b/transports/Dust/v3/go.mod index 6fe8fc4..e6761dc 100644 --- a/transports/Dust/v3/go.mod +++ b/transports/Dust/v3/go.mod @@ -4,7 +4,7 @@ go 1.12 require ( github.com/OperatorFoundation/obfs4 v1.0.0 - github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0 + github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0 github.com/blanu/Dust v1.0.1 // indirect github.com/blanu/Dust/go/v2/interface v1.0.1 golang.org/x/net v0.0.0-20200226121028-0de0cce0169b diff --git a/transports/Dust/v3/go.sum b/transports/Dust/v3/go.sum index 609dff0..dd89648 100644 --- a/transports/Dust/v3/go.sum +++ b/transports/Dust/v3/go.sum @@ -3,8 +3,8 @@ github.com/OperatorFoundation/ed25519 v0.0.0-20200225224545-b22b4bd3ddef h1:1xEt github.com/OperatorFoundation/ed25519 v0.0.0-20200225224545-b22b4bd3ddef/go.mod h1:gQNGvsyT4Zmps9H/yzCqdc+RQzt8ZxCndRNtGTYnBzQ= github.com/OperatorFoundation/obfs4 v1.0.0 h1:OcfdNMzv69fKQrLTkTSwpaBkHyBZMLjigA5M3txZpAg= github.com/OperatorFoundation/obfs4 v1.0.0/go.mod h1:6apgxOLYwyvbpzujpFHWu6Jlc+mjn1aFK7WvNijIVWc= -github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0 h1:zDYt6FDJwDSX4woVFVK2EMt7fkxU5L5qDNLUjQwA+BQ= -github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0/go.mod h1:kB00Ak8Dgn1uZlZHLc/WsUta58Jc+n/ZhCetcPkh42Q= +github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0 h1:6aQs+TF3KULMarpzbKu8DhFOF9D2UBCaAN5ZtbK53nQ= +github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0/go.mod h1:gb/QiZH0QDXLSQ9PskyJ2oTflB7tsP4AYc8y+FppvB0= github.com/blanu/Dust v1.0.0/go.mod h1:jLFQI2Ufz4kBnGiTzh8O9+/p4U/9MLbouXkaympnTI0= github.com/blanu/Dust v1.0.1 h1:C1IiRXr9YP1A4iiuhhpQOCgl8785LoVq78lbDrVRVqc= github.com/blanu/Dust v1.0.1/go.mod h1:jLFQI2Ufz4kBnGiTzh8O9+/p4U/9MLbouXkaympnTI0= diff --git a/transports/Replicant/v3/Optimizer.go b/transports/Replicant/v3/Optimizer.go index 9576405..c3f4217 100644 --- a/transports/Replicant/v3/Optimizer.go +++ b/transports/Replicant/v3/Optimizer.go @@ -1,7 +1,7 @@ package replicant import ( - pt "github.com/OperatorFoundation/shapeshifter-ipc" + pt "github.com/OperatorFoundation/shapeshifter-ipc/v2" "golang.org/x/net/proxy" "net" ) diff --git a/transports/Replicant/v3/go.mod b/transports/Replicant/v3/go.mod index 37b89b5..2d0d408 100644 --- a/transports/Replicant/v3/go.mod +++ b/transports/Replicant/v3/go.mod @@ -4,7 +4,7 @@ go 1.12 require ( github.com/OperatorFoundation/monolith-go/monolith v1.0.4 - github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0 + github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0 github.com/opentracing/opentracing-go v1.1.0 golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 golang.org/x/net v0.0.0-20200202094626-16171245cfb2 diff --git a/transports/Replicant/v3/go.sum b/transports/Replicant/v3/go.sum index c0b8e63..fa3bd56 100644 --- a/transports/Replicant/v3/go.sum +++ b/transports/Replicant/v3/go.sum @@ -1,17 +1,7 @@ -github.com/OperatorFoundation/monolith-go/monolith v0.0.0-20200211182645-3f416e29e205 h1:ENL3uQkGxIPJbLi6eXse+bFuAGJB7vzK6e+bdZOMm9c= -github.com/OperatorFoundation/monolith-go/monolith v0.0.0-20200211182645-3f416e29e205/go.mod h1:qc60ZvCt83JnWf2ZtLq8nkVH6s1gStEwywhox+2y0FY= -github.com/OperatorFoundation/monolith-go/monolith v1.0.1 h1:krnieqiUjzCGE/Mb4zy6lwr+RkR7WRK2jFP5EpL3Yvg= -github.com/OperatorFoundation/monolith-go/monolith v1.0.1/go.mod h1:qc60ZvCt83JnWf2ZtLq8nkVH6s1gStEwywhox+2y0FY= -github.com/OperatorFoundation/monolith-go/monolith v1.0.3 h1:KVh1TcURzc+aFb98klXSap2gtvDhXlWyJJ0MRvt8khA= -github.com/OperatorFoundation/monolith-go/monolith v1.0.3/go.mod h1:qc60ZvCt83JnWf2ZtLq8nkVH6s1gStEwywhox+2y0FY= github.com/OperatorFoundation/monolith-go/monolith v1.0.4 h1:9BmDs+f0VvDz94X8GW8G6L3UG6H7ziIFEw9H0AajnHI= github.com/OperatorFoundation/monolith-go/monolith v1.0.4/go.mod h1:qc60ZvCt83JnWf2ZtLq8nkVH6s1gStEwywhox+2y0FY= -github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0 h1:zDYt6FDJwDSX4woVFVK2EMt7fkxU5L5qDNLUjQwA+BQ= -github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0/go.mod h1:kB00Ak8Dgn1uZlZHLc/WsUta58Jc+n/ZhCetcPkh42Q= -github.com/OperatorFoundation/shapeshifter-transports v2.1.5+incompatible h1:1S3doS1jE/2X0FTiJWakrZVAmknj2IqZ1XL46zBA0XM= -github.com/OperatorFoundation/shapeshifter-transports/transports v0.0.0-20200218224946-cac72fbc8eb3 h1:D0oWnlYienV6VqTbeGPL4YYJoqCeK6kvBOS2wMv5Brk= -github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da h1:KjTM2ks9d14ZYCvmHS9iAKVt9AyzRSqNU1qabPih5BY= -github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da/go.mod h1:eHEWzANqSiWQsof+nXEI9bUVUyV6F53Fp89EuCh2EAA= +github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0 h1:6aQs+TF3KULMarpzbKu8DhFOF9D2UBCaAN5ZtbK53nQ= +github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0/go.mod h1:gb/QiZH0QDXLSQ9PskyJ2oTflB7tsP4AYc8y+FppvB0= github.com/deckarep/golang-set v1.7.1 h1:SCQV0S6gTtp6itiFrTqI+pfmJ4LN85S1YzhDf9rTHJQ= github.com/deckarep/golang-set v1.7.1/go.mod h1:93vsz/8Wt4joVM7c2AVqh+YRMiUSc14yDtF28KmMOgQ= github.com/opentracing/opentracing-go v1.1.0 h1:pWlfV3Bxv7k65HYwkikxat0+s3pV4bsqf19k25Ur8rU= diff --git a/transports/Replicant/v3/pt21.go b/transports/Replicant/v3/pt21.go index e0d0f2c..986ff94 100644 --- a/transports/Replicant/v3/pt21.go +++ b/transports/Replicant/v3/pt21.go @@ -1,7 +1,7 @@ package replicant import ( - pt "github.com/OperatorFoundation/shapeshifter-ipc" + pt "github.com/OperatorFoundation/shapeshifter-ipc/v2" "net" "time" ) diff --git a/transports/obfs2/v3/go.mod b/transports/obfs2/v3/go.mod index e8e146c..c7b2c05 100644 --- a/transports/obfs2/v3/go.mod +++ b/transports/obfs2/v3/go.mod @@ -4,8 +4,6 @@ go 1.12 require ( github.com/OperatorFoundation/obfs4 v1.0.0 - github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0 - github.com/OperatorFoundation/shapeshifter-transports v0.0.0-20200211223228-5b0aa21018a5 - github.com/OperatorFoundation/shapeshifter-transports/transports/Optimizer/v2 v2.1.12 + github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0 golang.org/x/net v0.0.0-20200226121028-0de0cce0169b ) diff --git a/transports/obfs2/v3/go.sum b/transports/obfs2/v3/go.sum index 3f3e8e8..af33490 100644 --- a/transports/obfs2/v3/go.sum +++ b/transports/obfs2/v3/go.sum @@ -1,38 +1,18 @@ git.torproject.org/pluggable-transports/goptlib.git v1.1.0/go.mod h1:YT4XMSkuEXbtqlydr9+OxqFAyspUv0Gr9qhM3B++o/Q= github.com/OperatorFoundation/ed25519 v0.0.0-20200225224545-b22b4bd3ddef h1:1xEtDEuNE9/yybZaHS94OIjx5FUo4e8M3UwcK9bFC9s= github.com/OperatorFoundation/ed25519 v0.0.0-20200225224545-b22b4bd3ddef/go.mod h1:gQNGvsyT4Zmps9H/yzCqdc+RQzt8ZxCndRNtGTYnBzQ= -github.com/OperatorFoundation/obfs4 v0.0.0-20161108041644-17f2cb99c264 h1:8UbFvUSYrlcEU9W92tohq74kYvtXJo11WLI16TMi904= -github.com/OperatorFoundation/obfs4 v0.0.0-20161108041644-17f2cb99c264/go.mod h1:oxwvRzQ4FDp7ysA1En4F/pyOh2Jfef4YTo1YhHUsBOA= github.com/OperatorFoundation/obfs4 v1.0.0 h1:OcfdNMzv69fKQrLTkTSwpaBkHyBZMLjigA5M3txZpAg= github.com/OperatorFoundation/obfs4 v1.0.0/go.mod h1:6apgxOLYwyvbpzujpFHWu6Jlc+mjn1aFK7WvNijIVWc= -github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0 h1:zDYt6FDJwDSX4woVFVK2EMt7fkxU5L5qDNLUjQwA+BQ= -github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0/go.mod h1:kB00Ak8Dgn1uZlZHLc/WsUta58Jc+n/ZhCetcPkh42Q= -github.com/OperatorFoundation/shapeshifter-transports v0.0.0-20200211223228-5b0aa21018a5 h1:UrCgBKvfj+Rim1jAUkRqQt1neJgLVHtKt0228tEmFKY= -github.com/OperatorFoundation/shapeshifter-transports v0.0.0-20200211223228-5b0aa21018a5/go.mod h1:u3jvRgYV13oHabVAdXekh3yk9PHfpCKvB8uolQEs4jA= -github.com/OperatorFoundation/shapeshifter-transports v2.1.11+incompatible h1:Icbjg/r1BC9NlQ4yk0XVhjJ4PtWRwd1uS6IrvPSuje4= -github.com/OperatorFoundation/shapeshifter-transports/transports/Optimizer/v2 v2.1.12 h1:BCDQ0UhF4RGxK7eYIBW94uQpOCQvpYbMkdJxSX5s6ZE= -github.com/OperatorFoundation/shapeshifter-transports/transports/Optimizer/v2 v2.1.12/go.mod h1:+A6vQ50ZAHi76GOGtpH730VFirwb1p8E6VJM8M50gNk= -github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v2 v2.1.11 h1:LpSrJLqvqLG3dDK2/FJBMrNEq+Bez1V7kE5CTUYQvT8= -github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v2 v2.1.11/go.mod h1:yPCbCoTjLIG+p0xiuRDwW5t+DivxTHqGU5njf89AkHY= -github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2 v2.1.11 h1:YWL++KLcWh0t755gwZlc8p0DqDAIfWVLdISpoY7RFhw= -github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2 v2.1.11/go.mod h1:OUFBnkMmjMHTWqEQlanDOMTgBjU5QARjklwQv9Qovr4= -github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v2 v2.1.11 h1:gKY17mRkP/VvBWvXzLuivJpFXt0AxkVUx7pv4PX2sUs= -github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v2 v2.1.11/go.mod h1:GN8ahnEHVGcPbR0raxdpWekjgElppspPNAAOpmNxQxU= -github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da h1:KjTM2ks9d14ZYCvmHS9iAKVt9AyzRSqNU1qabPih5BY= -github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da/go.mod h1:eHEWzANqSiWQsof+nXEI9bUVUyV6F53Fp89EuCh2EAA= -github.com/agl/ed25519 v0.0.0-20200225211852-fd4d107ace12 h1:iPf1jQ8yKTms6k6L5vYSE7RZJpjEe5vLTOmzRZdpnKc= +github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0 h1:6aQs+TF3KULMarpzbKu8DhFOF9D2UBCaAN5ZtbK53nQ= +github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0/go.mod h1:gb/QiZH0QDXLSQ9PskyJ2oTflB7tsP4AYc8y+FppvB0= github.com/dchest/siphash v1.2.1 h1:4cLinnzVJDKxTCl9B01807Yiy+W7ZzVHj/KIroQRvT4= github.com/dchest/siphash v1.2.1/go.mod h1:q+IRvb2gOSrUnYoPqHiyHXS0FOBBOdl6tONBlVnOnt4= -github.com/shadowsocks/go-shadowsocks2 v0.0.11 h1:dXloqEhYnZV40jblWTK8kWeC0Eb+dgql4S0tj99e8j0= -github.com/shadowsocks/go-shadowsocks2 v0.0.11/go.mod h1:R+KWaoIwRRhnpw6XV+dZil0XHi64Hc1D7hXUyXTjUzQ= github.com/willscott/goturn v0.0.0-20170802220503-19f41278d0c9/go.mod h1:PfwRjodCaQXOsHnh2DeVaXqCFCIrbn5WLj1+A5bQkD4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d h1:1ZiEyfaQIg3Qh0EoqpwAakHVhecoE5wlSg5GjnafJGw= golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20200202094626-16171245cfb2 h1:CCH4IOTTfewWjGOlSp+zGcjutRKlBEZQ6wTn8ozI/nI= -golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b h1:0mm1VjtFUOIlE1SbDlwjYaDxZVDP2S5ou6y0gSgXHu8= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU= diff --git a/transports/obfs2/v3/obfs2.go b/transports/obfs2/v3/obfs2.go index e485e88..98ca51e 100644 --- a/transports/obfs2/v3/obfs2.go +++ b/transports/obfs2/v3/obfs2.go @@ -44,7 +44,7 @@ import ( "golang.org/x/net/proxy" "github.com/OperatorFoundation/obfs4/common/csrand" - "github.com/OperatorFoundation/shapeshifter-ipc" + "github.com/OperatorFoundation/shapeshifter-ipc/v2" ) const ( diff --git a/transports/obfs4/v3/go.mod b/transports/obfs4/v3/go.mod index bf7f6e1..3cf1f1b 100644 --- a/transports/obfs4/v3/go.mod +++ b/transports/obfs4/v3/go.mod @@ -5,6 +5,7 @@ go 1.12 require ( github.com/OperatorFoundation/obfs4 v1.0.0 github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0 + github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0 golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d golang.org/x/net v0.0.0-20200226121028-0de0cce0169b ) diff --git a/transports/obfs4/v3/go.sum b/transports/obfs4/v3/go.sum index 8a6f976..3f1d5b3 100644 --- a/transports/obfs4/v3/go.sum +++ b/transports/obfs4/v3/go.sum @@ -5,6 +5,8 @@ github.com/OperatorFoundation/obfs4 v1.0.0 h1:OcfdNMzv69fKQrLTkTSwpaBkHyBZMLjigA github.com/OperatorFoundation/obfs4 v1.0.0/go.mod h1:6apgxOLYwyvbpzujpFHWu6Jlc+mjn1aFK7WvNijIVWc= github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0 h1:zDYt6FDJwDSX4woVFVK2EMt7fkxU5L5qDNLUjQwA+BQ= github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0/go.mod h1:kB00Ak8Dgn1uZlZHLc/WsUta58Jc+n/ZhCetcPkh42Q= +github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0 h1:6aQs+TF3KULMarpzbKu8DhFOF9D2UBCaAN5ZtbK53nQ= +github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0/go.mod h1:gb/QiZH0QDXLSQ9PskyJ2oTflB7tsP4AYc8y+FppvB0= github.com/dchest/siphash v1.2.1 h1:4cLinnzVJDKxTCl9B01807Yiy+W7ZzVHj/KIroQRvT4= github.com/dchest/siphash v1.2.1/go.mod h1:q+IRvb2gOSrUnYoPqHiyHXS0FOBBOdl6tONBlVnOnt4= github.com/willscott/goturn v0.0.0-20170802220503-19f41278d0c9/go.mod h1:PfwRjodCaQXOsHnh2DeVaXqCFCIrbn5WLj1+A5bQkD4= diff --git a/transports/obfs4/v3/obfs4.go b/transports/obfs4/v3/obfs4.go index afbad20..217d315 100644 --- a/transports/obfs4/v3/obfs4.go +++ b/transports/obfs4/v3/obfs4.go @@ -39,7 +39,7 @@ import ( "github.com/OperatorFoundation/obfs4/common/ntor" "github.com/OperatorFoundation/obfs4/common/probdist" "github.com/OperatorFoundation/obfs4/common/replayfilter" - "github.com/OperatorFoundation/shapeshifter-ipc" + "github.com/OperatorFoundation/shapeshifter-ipc/v2" "github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3/framing" "golang.org/x/net/proxy" "math/rand" @@ -89,7 +89,7 @@ type Transport struct { //ServerFactory contains arguments for server side type ServerFactory struct { - args *pt.Args + args map[string]string nodeID *ntor.NodeID identityKey *ntor.Keypair @@ -112,8 +112,8 @@ type ClientArgs struct { //NewObfs4Server initializes the obfs4 server side func NewObfs4Server(stateDir string) (*ServerFactory, error) { - args := make(pt.Args) - st, err := serverStateFromArgs(stateDir, &args) + args := make(map[string]string) + st, err := serverStateFromArgs(stateDir, args) if err != nil { return nil, err } @@ -129,10 +129,10 @@ func NewObfs4Server(stateDir string) (*ServerFactory, error) { } // Store the arguments that should appear in our descriptor for the clients. - ptArgs := pt.Args{} - ptArgs.Add(certArg, st.cert.String()) + ptArgs := make(map[string]string) + ptArgs[certArg] = st.cert.String() log.Infof("certstring %s", certArg) - ptArgs.Add(iatArg, strconv.Itoa(st.iatMode)) + ptArgs[iatArg] = strconv.Itoa(st.iatMode) // Initialize the replay filter. filter, err := replayfilter.New(replayTTL) @@ -147,7 +147,7 @@ func NewObfs4Server(stateDir string) (*ServerFactory, error) { } rng := rand.New(hashDrbg) - sf := &ServerFactory{&ptArgs, st.nodeID, st.identityKey, st.drbgSeed, iatSeed, st.iatMode, filter, rng.Intn(maxCloseDelayBytes), rng.Intn(maxCloseDelay)} + sf := &ServerFactory{ptArgs, st.nodeID, st.identityKey, st.drbgSeed, iatSeed, st.iatMode, filter, rng.Intn(maxCloseDelayBytes), rng.Intn(maxCloseDelay)} return sf, nil } diff --git a/transports/obfs4/v3/statefile.go b/transports/obfs4/v3/statefile.go index f0707de..c1f8e03 100644 --- a/transports/obfs4/v3/statefile.go +++ b/transports/obfs4/v3/statefile.go @@ -40,7 +40,6 @@ import ( "github.com/OperatorFoundation/obfs4/common/csrand" "github.com/OperatorFoundation/obfs4/common/drbg" "github.com/OperatorFoundation/obfs4/common/ntor" - "github.com/OperatorFoundation/shapeshifter-ipc" ) const ( @@ -113,14 +112,14 @@ func (st *obfs4ServerState) clientString() string { return fmt.Sprintf("%s=%s %s=%d", certArg, st.cert, iatArg, st.iatMode) } -func serverStateFromArgs(stateDir string, args *pt.Args) (*obfs4ServerState, error) { +func serverStateFromArgs(stateDir string, args map[string]string) (*obfs4ServerState, error) { var js jsonServerState var nodeIDOk, privKeyOk, seedOk bool - js.NodeID, nodeIDOk = args.Get(nodeIDArg) - js.PrivateKey, privKeyOk = args.Get(privateKeyArg) - js.DrbgSeed, seedOk = args.Get(seedArg) - iatStr, iatOk := args.Get(iatArg) + js.NodeID, nodeIDOk = args[nodeIDArg] + js.PrivateKey, privKeyOk = args[privateKeyArg] + js.DrbgSeed, seedOk = args[seedArg] + iatStr, iatOk := args[iatArg] // Either a private key, node id, and seed are ALL specified, or // they should be loaded from the state file. From f1ff67afed36f43d378eeced94595a4aff2b190b Mon Sep 17 00:00:00 2001 From: Bluesaxorcist Date: Thu, 9 Jul 2020 18:39:11 -0500 Subject: [PATCH 09/33] fixed obfs4 and added .sh test --- runAllTests.sh | 10 ++++++++ transports/Optimizer/v3/go.sum | 8 ++++++ transports/obfs4/v3/obfs4.go | 47 +++++++++++++++++----------------- 3 files changed, 42 insertions(+), 23 deletions(-) create mode 100755 runAllTests.sh diff --git a/runAllTests.sh b/runAllTests.sh new file mode 100755 index 0000000..0e31b2d --- /dev/null +++ b/runAllTests.sh @@ -0,0 +1,10 @@ +cd transports +#cd transports/Dust/v3; go test -v +#cd transports/meeklite/v3; go test -v +#cd transports/meekserver/v3; go test -v +cd obfs2/v3; go build; go test -v +cd ../../obfs4/v3; go build; go test -v +cd ../../Optimizer/v3; go build; go test -v +cd ../../Replicant/v3; go build; go test -v +cd ../../shadow/v3; go build; go test -v + diff --git a/transports/Optimizer/v3/go.sum b/transports/Optimizer/v3/go.sum index 4a8ffb2..55dfbbc 100644 --- a/transports/Optimizer/v3/go.sum +++ b/transports/Optimizer/v3/go.sum @@ -12,17 +12,25 @@ github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v2 v2. github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v2 v2.1.25 h1:A8e22dUVgKa+wV8uk0rDMiWrKPYSuwt/Dsi1amNQrIA= github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v2 v2.1.25/go.mod h1:DEfaE6lfJKEG5CkCRks4rXTMi1xYwbYR0sa+JKsgsr0= github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3 v3.0.0/go.mod h1:/bbH9BHoTGrmFJFBAYn0NKxQY2C8Au3ZC+IMiSsh42Y= +github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3 v3.0.3 h1:Bz7Cub+ij62h/O+o0mLt/wtyirCaChJy2wPFZe4I9Cg= +github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3 v3.0.3/go.mod h1:vmd701MBvvskTdbXxJ+opzqHeGSD3k8kC0PhWDKtLWM= github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v2 v2.1.25 h1:+Bhvplcf7BNuSoFZ3d0zGAxjP0DyIsHyYQSb0eB6h+k= github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v2 v2.1.25/go.mod h1:S2qmYjCQzB7XGJ5JMuVDTp2IbQveaAhXQ9BVOx+6KD8= github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 v3.0.0/go.mod h1:3ZXeGsk1VvTnKpSpH44BukvnWm611AM4l5mcrK35k9k= +github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 v3.0.3 h1:cmIUzCVUzO03W6T46x+CpO/MeWz1L1t9EIN7W0nRR6M= +github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 v3.0.3/go.mod h1:A0yyI69SvJjCZyfOuD0r56QkNReUaeU/sWGGaWLKo3E= github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2 v2.1.11/go.mod h1:OUFBnkMmjMHTWqEQlanDOMTgBjU5QARjklwQv9Qovr4= github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2 v2.1.25 h1:s0PD5dU56PjMOJT3EYVDxQMx32ylNCZUbyEP1LavVpg= github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2 v2.1.25/go.mod h1:OUFBnkMmjMHTWqEQlanDOMTgBjU5QARjklwQv9Qovr4= github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 v3.0.0/go.mod h1:x62zTwzgTsuG316sGLBc35ijWiJ4a9gSDbLIcvGNZr4= +github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 v3.0.3 h1:54CDC79ao5wUAVHXW/S+l9SX0YgTfdkN7P/yE4B/yyI= +github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 v3.0.3/go.mod h1:x62zTwzgTsuG316sGLBc35ijWiJ4a9gSDbLIcvGNZr4= github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v2 v2.1.11/go.mod h1:GN8ahnEHVGcPbR0raxdpWekjgElppspPNAAOpmNxQxU= github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v2 v2.1.25 h1:dCvYI1J7t01UrsJfNpU7kPaRwj2EqZmL3n5Hqam9xEU= github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v2 v2.1.25/go.mod h1:GN8ahnEHVGcPbR0raxdpWekjgElppspPNAAOpmNxQxU= github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 v3.0.0/go.mod h1:UBXOdrFoTJKCq9bd5ae+u95S0YPtH+I70IHbVw+qjnQ= +github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 v3.0.3 h1:6fJXPsr9JdGmhWa+OxcTNqPeUBQakGBedGC1zB2SGYE= +github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 v3.0.3/go.mod h1:UBXOdrFoTJKCq9bd5ae+u95S0YPtH+I70IHbVw+qjnQ= github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da h1:KjTM2ks9d14ZYCvmHS9iAKVt9AyzRSqNU1qabPih5BY= github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da/go.mod h1:eHEWzANqSiWQsof+nXEI9bUVUyV6F53Fp89EuCh2EAA= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/transports/obfs4/v3/obfs4.go b/transports/obfs4/v3/obfs4.go index 217d315..9dac888 100644 --- a/transports/obfs4/v3/obfs4.go +++ b/transports/obfs4/v3/obfs4.go @@ -111,7 +111,7 @@ type ClientArgs struct { } //NewObfs4Server initializes the obfs4 server side -func NewObfs4Server(stateDir string) (*ServerFactory, error) { +func NewObfs4Server(stateDir string) (*Transport, error) { args := make(map[string]string) st, err := serverStateFromArgs(stateDir, args) if err != nil { @@ -149,7 +149,7 @@ func NewObfs4Server(stateDir string) (*ServerFactory, error) { sf := &ServerFactory{ptArgs, st.nodeID, st.identityKey, st.drbgSeed, iatSeed, st.iatMode, filter, rng.Intn(maxCloseDelayBytes), rng.Intn(maxCloseDelay)} - return sf, nil + return &Transport{dialer: nil, serverFactory: sf, clientArgs: nil}, nil } //NewObfs4Client initializes the obfs4 client side @@ -219,27 +219,28 @@ type Config struct { IatMode string `json:"iat-mode"` } -func NewClient(certString string, iatMode int, address string, dialer proxy.Dialer) TransportClient { - return TransportClient{ - CertString: certString, - IatMode: iatMode, - Address: address, - Dialer: dialer, - } -} - -func NewServer(stateDir string, address string) (*TransportServer, error) { - sf, sFError := NewObfs4Server(stateDir) - - if sFError != nil { - return nil, sFError - } - transport := &TransportServer{ - ServerFactory: sf, - Address: address, - } - return transport, nil -} +//TODO i dont remember if these are used here but they arent in the dev branch and NewServer expects the wrong thing +//func NewClient(certString string, iatMode int, address string, dialer proxy.Dialer) TransportClient { +// return TransportClient{ +// CertString: certString, +// IatMode: iatMode, +// Address: address, +// Dialer: dialer, +// } +//} +// +//func NewServer(stateDir string, address string) (*TransportServer, error) { +// sf, sFError := NewObfs4Server(stateDir) +// +// if sFError != nil { +// return nil, sFError +// } +// transport := &TransportServer{ +// ServerFactory: sf, +// Address: address, +// } +// return transport, nil +//} // Dial creates outgoing transport connection func (transport TransportClient) Dial() (net.Conn, error) { From 9bb5a1e0534bf66070f7e075f0c495146f600a22 Mon Sep 17 00:00:00 2001 From: Bluesaxorcist Date: Tue, 14 Jul 2020 14:35:16 -0500 Subject: [PATCH 10/33] Update go.mod --- transports/Optimizer/v3/go.mod | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/transports/Optimizer/v3/go.mod b/transports/Optimizer/v3/go.mod index c754734..8e3cc57 100644 --- a/transports/Optimizer/v3/go.mod +++ b/transports/Optimizer/v3/go.mod @@ -3,9 +3,9 @@ module github.com/OperatorFoundation/shapeshifter-transports/transports/Optimize go 1.12 require ( - github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3 v3.0.3 - github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 v3.0.3 - github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 v3.0.3 - github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 v3.0.3 + github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3 v3.0.4 + github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 v3.0.4 + github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 v3.0.4 + github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 v3.0.4 golang.org/x/net v0.0.0-20200226121028-0de0cce0169b ) From 4389cee2f4f4cd84dd0ef0bb050b0511bc7ffaa9 Mon Sep 17 00:00:00 2001 From: Bluesaxorcist Date: Wed, 15 Jul 2020 10:12:25 -0500 Subject: [PATCH 11/33] added tests for factory interface --- transports/Optimizer/v3/Optimizer_test.go | 12 +++--- transports/Optimizer/v3/go.sum | 36 +++++------------ transports/meeklite/v3/meeklite.go | 3 ++ transports/meeklite/v3/meeklite_test.go | 44 +++++++++++++++++++++ transports/meekserver/v3/meekserver_test.go | 19 ++++++++- transports/obfs4/v3/obfs4.go | 15 +++---- transports/shadow/v3/shadow_test.go | 30 ++++++++++++++ 7 files changed, 115 insertions(+), 44 deletions(-) diff --git a/transports/Optimizer/v3/Optimizer_test.go b/transports/Optimizer/v3/Optimizer_test.go index 864e767..789c736 100644 --- a/transports/Optimizer/v3/Optimizer_test.go +++ b/transports/Optimizer/v3/Optimizer_test.go @@ -121,7 +121,7 @@ func TestOptimizerObfs4Transport_Dial(t *testing.T) { t.Fail() return } - obfs4Transport := obfs4.OptimizerTransport{ + obfs4Transport := obfs4.TransportClient{ CertString: *certstring, IatMode: 0, Address: "127.0.0.1:1234", @@ -142,7 +142,7 @@ func TestOptimizerTransportFirstDial(t *testing.T) { t.Fail() return } - obfs4Transport := obfs4.OptimizerTransport{ + obfs4Transport := obfs4.TransportClient{ CertString: *certstring, IatMode: 0, Address: "127.0.0.1:1234", @@ -166,7 +166,7 @@ func TestOptimizerTransportRandomDial(t *testing.T) { t.Fail() return } - obfs4Transport := obfs4.OptimizerTransport{ + obfs4Transport := obfs4.TransportClient{ CertString: *certstring, IatMode: 0, Address: "127.0.0.1:1234", @@ -192,7 +192,7 @@ func TestOptimizerTransportRotateDial(t *testing.T) { t.Fail() return } - obfs4Transport := obfs4.OptimizerTransport{ + obfs4Transport := obfs4.TransportClient{ CertString: *certstring, IatMode: 0, Address: "127.0.0.1:1234", @@ -218,7 +218,7 @@ func TestOptimizerTransportTrackDial(t *testing.T) { t.Fail() return } - obfs4Transport := obfs4.OptimizerTransport{ + obfs4Transport := obfs4.TransportClient{ CertString: *certstring, IatMode: 0, Address: "127.0.0.1:1234", @@ -244,7 +244,7 @@ func TestOptimizerTransportMinimizeDialDurationDial(t *testing.T) { t.Fail() return } - obfs4Transport := obfs4.OptimizerTransport{ + obfs4Transport := obfs4.TransportClient{ CertString: *certstring, IatMode: 0, Address: "127.0.0.1:1234", diff --git a/transports/Optimizer/v3/go.sum b/transports/Optimizer/v3/go.sum index 55dfbbc..b6b7b69 100644 --- a/transports/Optimizer/v3/go.sum +++ b/transports/Optimizer/v3/go.sum @@ -5,32 +5,16 @@ github.com/OperatorFoundation/obfs4 v1.0.0 h1:OcfdNMzv69fKQrLTkTSwpaBkHyBZMLjigA github.com/OperatorFoundation/obfs4 v1.0.0/go.mod h1:6apgxOLYwyvbpzujpFHWu6Jlc+mjn1aFK7WvNijIVWc= github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0 h1:zDYt6FDJwDSX4woVFVK2EMt7fkxU5L5qDNLUjQwA+BQ= github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0/go.mod h1:kB00Ak8Dgn1uZlZHLc/WsUta58Jc+n/ZhCetcPkh42Q= -github.com/OperatorFoundation/shapeshifter-transports v0.0.0-20200211223228-5b0aa21018a5 h1:UrCgBKvfj+Rim1jAUkRqQt1neJgLVHtKt0228tEmFKY= -github.com/OperatorFoundation/shapeshifter-transports v0.0.0-20200211223228-5b0aa21018a5/go.mod h1:u3jvRgYV13oHabVAdXekh3yk9PHfpCKvB8uolQEs4jA= -github.com/OperatorFoundation/shapeshifter-transports/transports/Optimizer/v2 v2.1.12/go.mod h1:+A6vQ50ZAHi76GOGtpH730VFirwb1p8E6VJM8M50gNk= -github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v2 v2.1.11/go.mod h1:yPCbCoTjLIG+p0xiuRDwW5t+DivxTHqGU5njf89AkHY= -github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v2 v2.1.25 h1:A8e22dUVgKa+wV8uk0rDMiWrKPYSuwt/Dsi1amNQrIA= -github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v2 v2.1.25/go.mod h1:DEfaE6lfJKEG5CkCRks4rXTMi1xYwbYR0sa+JKsgsr0= -github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3 v3.0.0/go.mod h1:/bbH9BHoTGrmFJFBAYn0NKxQY2C8Au3ZC+IMiSsh42Y= -github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3 v3.0.3 h1:Bz7Cub+ij62h/O+o0mLt/wtyirCaChJy2wPFZe4I9Cg= -github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3 v3.0.3/go.mod h1:vmd701MBvvskTdbXxJ+opzqHeGSD3k8kC0PhWDKtLWM= -github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v2 v2.1.25 h1:+Bhvplcf7BNuSoFZ3d0zGAxjP0DyIsHyYQSb0eB6h+k= -github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v2 v2.1.25/go.mod h1:S2qmYjCQzB7XGJ5JMuVDTp2IbQveaAhXQ9BVOx+6KD8= -github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 v3.0.0/go.mod h1:3ZXeGsk1VvTnKpSpH44BukvnWm611AM4l5mcrK35k9k= -github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 v3.0.3 h1:cmIUzCVUzO03W6T46x+CpO/MeWz1L1t9EIN7W0nRR6M= -github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 v3.0.3/go.mod h1:A0yyI69SvJjCZyfOuD0r56QkNReUaeU/sWGGaWLKo3E= -github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2 v2.1.11/go.mod h1:OUFBnkMmjMHTWqEQlanDOMTgBjU5QARjklwQv9Qovr4= -github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2 v2.1.25 h1:s0PD5dU56PjMOJT3EYVDxQMx32ylNCZUbyEP1LavVpg= -github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2 v2.1.25/go.mod h1:OUFBnkMmjMHTWqEQlanDOMTgBjU5QARjklwQv9Qovr4= -github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 v3.0.0/go.mod h1:x62zTwzgTsuG316sGLBc35ijWiJ4a9gSDbLIcvGNZr4= -github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 v3.0.3 h1:54CDC79ao5wUAVHXW/S+l9SX0YgTfdkN7P/yE4B/yyI= -github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 v3.0.3/go.mod h1:x62zTwzgTsuG316sGLBc35ijWiJ4a9gSDbLIcvGNZr4= -github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v2 v2.1.11/go.mod h1:GN8ahnEHVGcPbR0raxdpWekjgElppspPNAAOpmNxQxU= -github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v2 v2.1.25 h1:dCvYI1J7t01UrsJfNpU7kPaRwj2EqZmL3n5Hqam9xEU= -github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v2 v2.1.25/go.mod h1:GN8ahnEHVGcPbR0raxdpWekjgElppspPNAAOpmNxQxU= -github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 v3.0.0/go.mod h1:UBXOdrFoTJKCq9bd5ae+u95S0YPtH+I70IHbVw+qjnQ= -github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 v3.0.3 h1:6fJXPsr9JdGmhWa+OxcTNqPeUBQakGBedGC1zB2SGYE= -github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 v3.0.3/go.mod h1:UBXOdrFoTJKCq9bd5ae+u95S0YPtH+I70IHbVw+qjnQ= +github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0 h1:6aQs+TF3KULMarpzbKu8DhFOF9D2UBCaAN5ZtbK53nQ= +github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0/go.mod h1:gb/QiZH0QDXLSQ9PskyJ2oTflB7tsP4AYc8y+FppvB0= +github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3 v3.0.4 h1:G/QFqjBHDI98SXnEubABJEVSEO4I5Mp7Lt1CliaEBlA= +github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3 v3.0.4/go.mod h1:vmd701MBvvskTdbXxJ+opzqHeGSD3k8kC0PhWDKtLWM= +github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 v3.0.4 h1:c73lxT+T92cM42mhgyUtcxyjIB0Fa0hWq6Ti/vZPWu4= +github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 v3.0.4/go.mod h1:Jy0DdH5gfALoQvxLv7J06TdydoZ5fFfeN9jVN/hLMdw= +github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 v3.0.4 h1:3OoYnC43wy0+M4pMaFFUpDx39zJ13fAtraFHLVlsbzc= +github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 v3.0.4/go.mod h1:bAGX3ChJElvQMxEsNdjP+yW3CFcVqdiPWfLg7jipbu8= +github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 v3.0.4 h1:nN9agys5DKv2WLd8KhhO0BO5q76CqnRmuslPtkoOcJQ= +github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 v3.0.4/go.mod h1:UBXOdrFoTJKCq9bd5ae+u95S0YPtH+I70IHbVw+qjnQ= github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da h1:KjTM2ks9d14ZYCvmHS9iAKVt9AyzRSqNU1qabPih5BY= github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da/go.mod h1:eHEWzANqSiWQsof+nXEI9bUVUyV6F53Fp89EuCh2EAA= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/transports/meeklite/v3/meeklite.go b/transports/meeklite/v3/meeklite.go index 9a8a765..d5492ec 100644 --- a/transports/meeklite/v3/meeklite.go +++ b/transports/meeklite/v3/meeklite.go @@ -135,6 +135,9 @@ type Config struct { Front string `json:"front"` } +func NewMeekFactoryTransportWithFront(url *gourl.URL, front string, address string, dialer proxy.Dialer) *Transport { + return &Transport{url, front, address,dialer} +} // Dial creates outgoing transport connection func (transport Transport) Dial() (net.Conn, error) { meekTransport := NewMeekTransportWithFront(transport.URL.String(), transport.Front, transport.Dialer) diff --git a/transports/meeklite/v3/meeklite_test.go b/transports/meeklite/v3/meeklite_test.go index c26342a..80bcf4f 100644 --- a/transports/meeklite/v3/meeklite_test.go +++ b/transports/meeklite/v3/meeklite_test.go @@ -35,6 +35,7 @@ package meeklite import ( "golang.org/x/net/proxy" + gourl "net/url" "testing" ) @@ -75,3 +76,46 @@ func TestMeeklite(t *testing.T) { return } } + +func TestFactoryMeeklite(t *testing.T) { + //create a server + urlString := "https://transport-canary-meek.appspot.com/" + Url, err := gourl.Parse(urlString) + if err != nil { + t.Fail() + return + } + + config := NewMeekFactoryTransportWithFront(Url, "www.google.com", "", proxy.Direct) + + //create client buffer + clientBuffer := make([]byte, 4) + //call dial on client and check error + clientConn, connErr := config.Dial() + if connErr != nil { + t.Fail() + return + } + + //write data from clientConn for server to read + writeBytes, clientWriteErr := clientConn.Write([]byte(data)) + if clientWriteErr != nil { + t.Fail() + return + } + if writeBytes <= 0 { + t.Fail() + return + } + + //read on client side + readBytes, clientReadErr := clientConn.Read(clientBuffer) + if clientReadErr != nil { + t.Fail() + return + } + if readBytes <= 0 { + t.Fail() + return + } +} diff --git a/transports/meekserver/v3/meekserver_test.go b/transports/meekserver/v3/meekserver_test.go index 82607d2..1e5c89e 100644 --- a/transports/meekserver/v3/meekserver_test.go +++ b/transports/meekserver/v3/meekserver_test.go @@ -1,6 +1,7 @@ package meekserver import ( + "golang.org/x/crypto/acme/autocert" "testing" ) @@ -12,8 +13,7 @@ import ( // t.Fail() // } //} - -func TestMeekServerListen2(t *testing.T) { +func TestMeekServerListen(t *testing.T) { acmeEmail := "brandon@operatorfoundation.org" keyFileName := "operatorrss.com" meekserverTransport := NewMeekTransportServer(false, acmeEmail, keyFileName, "state") @@ -26,4 +26,19 @@ func TestMeekServerListen2(t *testing.T) { t.Fail() return } +} + +func TestMeekServerFactoryListen(t *testing.T) { + cert:= autocert.Manager{} + meekserverTransport := New(false, &cert,"127.0.0.1:8080" ) + //TODO why does it try to convert nil into type Transport? Is a nil check needed here? + //if meekserverTransport == nil { + // t.Fail() + // return + //} + _, listenErr := meekserverTransport.Listen() + if listenErr != nil { + t.Fail() + return + } } \ No newline at end of file diff --git a/transports/obfs4/v3/obfs4.go b/transports/obfs4/v3/obfs4.go index 9dac888..54f76df 100644 --- a/transports/obfs4/v3/obfs4.go +++ b/transports/obfs4/v3/obfs4.go @@ -219,16 +219,10 @@ type Config struct { IatMode string `json:"iat-mode"` } -//TODO i dont remember if these are used here but they arent in the dev branch and NewServer expects the wrong thing -//func NewClient(certString string, iatMode int, address string, dialer proxy.Dialer) TransportClient { -// return TransportClient{ -// CertString: certString, -// IatMode: iatMode, -// Address: address, -// Dialer: dialer, -// } -//} -// +func NewClient(certString string, iatMode int, address string, dialer proxy.Dialer) (TransportClient, error) { + return TransportClient{CertString: certString, IatMode: iatMode, Address: address, Dialer: dialer}, nil +} + //func NewServer(stateDir string, address string) (*TransportServer, error) { // sf, sFError := NewObfs4Server(stateDir) // @@ -236,6 +230,7 @@ type Config struct { // return nil, sFError // } // transport := &TransportServer{ +////TODO since sf is type *Transport, how do we make it into a type *ServerFactory // ServerFactory: sf, // Address: address, // } diff --git a/transports/shadow/v3/shadow_test.go b/transports/shadow/v3/shadow_test.go index 56ca9cf..c94c9aa 100644 --- a/transports/shadow/v3/shadow_test.go +++ b/transports/shadow/v3/shadow_test.go @@ -97,3 +97,33 @@ func TestShadow(t *testing.T) { return } } +func TestShadowFactory(t *testing.T) { + //create a server + transport := NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1236") + + //create client buffer + clientBuffer := make([]byte, 4) + //call dial on client and check error + clientConn, dialErr := transport.Dial() + if dialErr != nil { + fmt.Println("clientConn Dial error") + t.Fail() + return + } + + //write data from clientConn for server to read + _, clientWriteErr := clientConn.Write([]byte(data)) + if clientWriteErr != nil { + fmt.Println("client write error") + t.Fail() + return + } + + //read on client side + _, clientReadErr := clientConn.Read(clientBuffer) + if clientReadErr != nil { + fmt.Println("client read error") + t.Fail() + return + } +} From 4bee69a27a5884f35a99654ad92f160dd73a68a3 Mon Sep 17 00:00:00 2001 From: Bluesaxorcist Date: Wed, 15 Jul 2020 13:12:24 -0500 Subject: [PATCH 12/33] added more factory tests --- transports/Replicant/v3/replicant_test.go | 127 +++++++++++++++++++- transports/meekserver/v3/meekserver_test.go | 15 ++- transports/meekserver/v3/pt21.go | 56 +++++++-- transports/obfs4/v3/obfs4.go | 67 +++++++++-- transports/obfs4/v3/obfs4_test.go | 32 ++++- transports/obfs4/v3/test_utils.go | 91 ++++++++++++++ 6 files changed, 354 insertions(+), 34 deletions(-) diff --git a/transports/Replicant/v3/replicant_test.go b/transports/Replicant/v3/replicant_test.go index 7289b6c..9b1b028 100644 --- a/transports/Replicant/v3/replicant_test.go +++ b/transports/Replicant/v3/replicant_test.go @@ -5,6 +5,7 @@ import ( "github.com/OperatorFoundation/monolith-go/monolith" "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v3/polish" "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v3/toneburst" + "golang.org/x/net/proxy" "io/ioutil" "math/rand" "os" @@ -15,7 +16,7 @@ import ( func TestMain(m *testing.M) { runReplicantServer() - + runReplicantFactoryServer() os.Exit(m.Run()) } @@ -134,6 +135,12 @@ func TestMonotoneRandomEnumerated(t *testing.T) { replicantConnection(clientConfig, serverConfig, t) } +func TestFactoryMonotoneRandomEnumerated(t *testing.T) { + clientConfig := createMonotoneClientConfigRandomEnumeratedItems() + serverConfig := createMonotoneServerConfigRandomEnumeratedItems() + replicantFactoryConnection(clientConfig, serverConfig, t) +} + func TestSilver(t *testing.T) { clientConfig, serverConfig := createSilverConfigs() replicantConnection(*clientConfig, *serverConfig, t) @@ -171,7 +178,49 @@ func runReplicantServer() { serverFinishedStarting := <-serverStarted if !serverFinishedStarting { - return + return + } +} + +func runReplicantFactoryServer() { + serverStarted := make(chan bool) + addr := "127.0.0.1:3001" + + serverConfig := ServerConfig{ + Toneburst: nil, + Polish: nil, + } + + server := NewServer(serverConfig, addr, proxy.Direct) + + go func() { + listener, listenError := server.Listen() + if listenError != nil { + return + } + serverStarted <- true + + lConn, lConnError := listener.Accept() + if lConnError != nil { + return + } + + lBuffer := make([]byte, 4) + _, lReadError := lConn.Read(lBuffer) + if lReadError != nil { + return + } + + // Send a response back to person contacting us. + _, lWriteError := lConn.Write([]byte("Message received.")) + if lWriteError != nil { + return + } + }() + + serverFinishedStarting := <-serverStarted + if !serverFinishedStarting { + return } } @@ -251,6 +300,80 @@ func replicantConnection(clientConfig ClientConfig, serverConfig ServerConfig, t return } +func replicantFactoryConnection(clientConfig ClientConfig, serverConfig ServerConfig, t *testing.T) { + serverStarted := make(chan bool) + + // Get a random port + rand.Seed(time.Now().UnixNano()) + min := 1025 + max := 65535 + portNumber := min + rand.Intn(max-min+1) + portString := strconv.Itoa(portNumber) + addr := "127.0.0.1:" + addr += portString + + go func() { + server := NewServer(serverConfig, addr, proxy.Direct) + listener, listenError := server.Listen() + if listenError != nil { + return + } + serverStarted <- true + + lConn, lConnError := listener.Accept() + if lConnError != nil { + t.Fail() + return + } + + lBuffer := make([]byte, 4) + _, lReadError := lConn.Read(lBuffer) + if lReadError != nil { + t.Fail() + return + } + + // Send a response back to person contacting us. + _, lWriteError := lConn.Write([]byte("Message received.")) + if lWriteError != nil { + t.Fail() + return + } + + _ = listener.Close() + }() + + serverFinishedStarting := <-serverStarted + if !serverFinishedStarting { + t.Fail() + return + } + client := NewClient(clientConfig, addr, proxy.Direct) + cConn, connErr := client.Dial() + if connErr != nil { + t.Fail() + return + } + + writeBytes := []byte{0x0A, 0x11, 0xB0, 0xB1} + _, cWriteError := cConn.Write(writeBytes) + if cWriteError != nil { + t.Fail() + return + } + + readBuffer := make([]byte, 17) + _, cReadError := cConn.Read(readBuffer) + if cReadError != nil { + t.Fail() + return + } + + _ = cConn.Close() + + return +} + func createMonotoneClientConfigNils() ClientConfig { monotoneConfig := toneburst.MonotoneConfig{ AddSequences: nil, diff --git a/transports/meekserver/v3/meekserver_test.go b/transports/meekserver/v3/meekserver_test.go index 1e5c89e..f614c4e 100644 --- a/transports/meekserver/v3/meekserver_test.go +++ b/transports/meekserver/v3/meekserver_test.go @@ -1,7 +1,6 @@ package meekserver import ( - "golang.org/x/crypto/acme/autocert" "testing" ) @@ -29,13 +28,13 @@ func TestMeekServerListen(t *testing.T) { } func TestMeekServerFactoryListen(t *testing.T) { - cert:= autocert.Manager{} - meekserverTransport := New(false, &cert,"127.0.0.1:8080" ) - //TODO why does it try to convert nil into type Transport? Is a nil check needed here? - //if meekserverTransport == nil { - // t.Fail() - // return - //} + acmeEmail := "brandon@operatorfoundation.org" + acmeHostNames := "operatorrss.com" + meekserverTransport, newError := New(false, acmeHostNames, acmeEmail,"127.0.0.1:8080", "state") + if newError != nil { + t.Fail() + return + } _, listenErr := meekserverTransport.Listen() if listenErr != nil { t.Fail() diff --git a/transports/meekserver/v3/pt21.go b/transports/meekserver/v3/pt21.go index 564d34d..f1bac34 100644 --- a/transports/meekserver/v3/pt21.go +++ b/transports/meekserver/v3/pt21.go @@ -50,12 +50,11 @@ type MeekServer struct { AcmeHostname string CertManager *autocert.Manager } -//TODO I added this struct imitating MeekServer struct that has only the bare minimum parameters that the listener uses with the addition of Address -//TODO Was this a 'pro-gamer move'? + type Transport struct { - DisableTLS bool - CertManager *autocert.Manager - Address string + DisableTLS bool + CertManager *autocert.Manager + Address string } //Config contains arguments formatted for a json file @@ -80,11 +79,48 @@ type fakeConn struct { writeBuffer []byte } -func New(disableTLS bool, certManager *autocert.Manager, address string) Transport { - return Transport{ - DisableTLS: disableTLS, - CertManager: certManager, - Address: address, +func New(disableTLS bool, acmeHostnamesCommas string, acmeEmail string, address string, stateDir string) (*Transport, error) { + var certManager *autocert.Manager + if disableTLS { + if acmeEmail != "" || acmeHostnamesCommas != "" { + return nil, errors.New("acmeEmail and acmeHostnames must be empty when disableTLS is enabled") + } + return nil, errors.New("disableTLS mode is not yet supported") + } else { + if acmeEmail == "" || acmeHostnamesCommas == "" { + return nil, errors.New("acmeEmail and acmeHostnames must be empty when disableTLS is disabled") + } + if acmeHostnamesCommas != "" { + acmeHostnames := strings.Split(acmeHostnamesCommas, ",") + log.Printf("ACME hostnames: %q", acmeHostnames) + + // The ACME HTTP-01 responder only works when it is running on + // port 80. + // https://github.com/ietf-wg-acme/acme/blob/master/draft-ietf-acme-acme.md#http-challenge + + var cache autocert.Cache + cacheDir, err := getCertificateCacheDir(stateDir) + if err == nil { + log.Printf("caching ACME certificates in directory %q", cacheDir) + cache = autocert.DirCache(cacheDir) + } else { + log.Printf("disabling ACME certificate cache: %s", err) + } + + certManager = &autocert.Manager{ + Prompt: autocert.AcceptTOS, + HostPolicy: autocert.HostWhitelist(acmeHostnames...), + Email: acmeEmail, + Cache: cache, + } + return &Transport{ + DisableTLS: disableTLS, + CertManager: certManager, + Address: address, + }, nil + } else { + return nil, errors.New("must set acmeEmail") + } } } func (listener meekListener) Accept() (net.Conn, error) { diff --git a/transports/obfs4/v3/obfs4.go b/transports/obfs4/v3/obfs4.go index 54f76df..e51ba3f 100644 --- a/transports/obfs4/v3/obfs4.go +++ b/transports/obfs4/v3/obfs4.go @@ -223,19 +223,60 @@ func NewClient(certString string, iatMode int, address string, dialer proxy.Dial return TransportClient{CertString: certString, IatMode: iatMode, Address: address, Dialer: dialer}, nil } -//func NewServer(stateDir string, address string) (*TransportServer, error) { -// sf, sFError := NewObfs4Server(stateDir) -// -// if sFError != nil { -// return nil, sFError -// } -// transport := &TransportServer{ -////TODO since sf is type *Transport, how do we make it into a type *ServerFactory -// ServerFactory: sf, -// Address: address, -// } -// return transport, nil -//} +func NewServer(stateDir string, address string) (*TransportServer, error) { + sf, sFError := NewObfs4ServerFactory(stateDir) + + if sFError != nil { + return nil, sFError + } + transport := &TransportServer{ + ServerFactory: sf, + Address: address, + } + return transport, nil +} + +//NewObfs4Server initializes the obfs4 server side +func NewObfs4ServerFactory(stateDir string) (*ServerFactory, error) { + args := make(map[string]string) + st, err := serverStateFromArgs(stateDir, args) + if err != nil { + return nil, err + } + + var iatSeed *drbg.Seed + if st.iatMode != iatNone { + iatSeedSrc := sha256.Sum256(st.drbgSeed.Bytes()[:]) + var err error + iatSeed, err = drbg.SeedFromBytes(iatSeedSrc[:]) + if err != nil { + return nil, err + } + } + + // Store the arguments that should appear in our descriptor for the clients. + ptArgs := make(map[string]string) + ptArgs[certArg] = st.cert.String() + log.Infof("certstring %s", certArg) + ptArgs[iatArg] = strconv.Itoa(st.iatMode) + + // Initialize the replay filter. + filter, err := replayfilter.New(replayTTL) + if err != nil { + return nil, err + } + + // Initialize the close thresholds for failed connections. + hashDrbg, err := drbg.NewHashDrbg(st.drbgSeed) + if err != nil { + return nil, err + } + rng := rand.New(hashDrbg) + + sf := &ServerFactory{ptArgs, st.nodeID, st.identityKey, st.drbgSeed, iatSeed, st.iatMode, filter, rng.Intn(maxCloseDelayBytes), rng.Intn(maxCloseDelay)} + + return sf, nil +} // Dial creates outgoing transport connection func (transport TransportClient) Dial() (net.Conn, error) { diff --git a/transports/obfs4/v3/obfs4_test.go b/transports/obfs4/v3/obfs4_test.go index 49db723..2a63d1b 100644 --- a/transports/obfs4/v3/obfs4_test.go +++ b/transports/obfs4/v3/obfs4_test.go @@ -39,7 +39,7 @@ const data = "test" func TestMain(m *testing.M) { _ = RunLocalObfs4Server("test") - + _ = RunLocalObfs4ServerFactory("test") os.Exit(m.Run()) } @@ -74,3 +74,33 @@ func TestObfs4(t *testing.T) { } } +func TestObfs4Factory(t *testing.T) { + print(runtime.GOOS) + clientConfig, launchErr := RunObfs4ClientFactory() + if launchErr != nil { + t.Fail() + return + } + //create client buffer + clientBuffer := make([]byte, 4) + //call dial on client and check error + clientConn, dialErr := clientConfig.Dial() + if dialErr != nil { + t.Fail() + return + } + + //write data from clientConn for server to read + _, clientWriteErr := clientConn.Write([]byte(data)) + if clientWriteErr != nil { + t.Fail() + return + } + + //read on client side + _, clientReadErr := clientConn.Read(clientBuffer) + if clientReadErr != nil { + t.Fail() + return + } +} \ No newline at end of file diff --git a/transports/obfs4/v3/test_utils.go b/transports/obfs4/v3/test_utils.go index 19726b6..480d65c 100644 --- a/transports/obfs4/v3/test_utils.go +++ b/transports/obfs4/v3/test_utils.go @@ -1,6 +1,7 @@ package obfs4 import ( + "golang.org/x/net/proxy" "io/ioutil" "os" "os/user" @@ -68,6 +69,64 @@ func RunLocalObfs4Server(data string) bool { return true } +func RunLocalObfs4ServerFactory(data string) bool { + //create a server + usr, userError := user.Current() + if userError != nil { + return false + } + home := usr.HomeDir + var fPath string + if runtime.GOOS == "darwin" { + fPath = path.Join(home, "shapeshifter-transports/stateDir") + } else { + fPath = path.Join(home, "gopath/src/github.com/OperatorFoundation/shapeshifter-transports/stateDir") + } + directoryErr := os.Mkdir(fPath, 0775) + if directoryErr != nil { + if !os.IsExist(directoryErr){ + return false + } + } + serverConfig, confError := NewServer(fPath, "127.0.0.1:2234") + if confError != nil { + return false + } + //call listen on the server + serverListener, listenErr := serverConfig.Listen() + if listenErr != nil { + return false + } + //Create Server connection and format it for concurrency + go func() { + //create server buffer + serverBuffer := make([]byte, 4) + + for { + //create serverConn + serverConn, acceptErr := serverListener.Accept() + if acceptErr != nil { + return + } + + go func() { + //read on server side + _, serverReadErr := serverConn.Read(serverBuffer) + if serverReadErr != nil { + return + } + + //write data from serverConn for client to read + _, serverWriteErr := serverConn.Write([]byte(data)) + if serverWriteErr != nil { + return + } + }() + } + }() + return true +} + //RunObfs4Client runs the client side in the background for the test func RunObfs4Client() (*Transport, error) { usr, userError := user.Current() @@ -99,3 +158,35 @@ func RunObfs4Client() (*Transport, error) { clientConfig, confError := NewObfs4Client(certstring, 0, nil) return clientConfig, confError } + +//RunObfs4Client runs the client side in the background for the test +func RunObfs4ClientFactory() (*TransportClient, error) { + usr, userError := user.Current() + if userError != nil { + return nil, userError + } + home := usr.HomeDir + var fPath string + if runtime.GOOS == "darwin" { + fPath = path.Join(home, "shapeshifter-transports/stateDir/obfs4_bridgeline.txt") + } else { + fPath = path.Join(home, "gopath/src/github.com/OperatorFoundation/shapeshifter-transports/stateDir/obfs4_bridgeline.txt") + } + bytes, fileError := ioutil.ReadFile(fPath) + if fileError != nil { + return nil, fileError + } + //print(bytes) + byteString := string(bytes) + //print(byteString) + lines := strings.Split(byteString, "\n") + //print(lines) + bridgeLine := lines[len(lines)-2] + //println(bridgeLine) + bridgeParts1 := strings.Split(bridgeLine, " ") + bridgePart := bridgeParts1[5] + certstring := bridgePart[5:] + //println(certstring) + clientConfig, confError := NewClient(certstring, 0, "127.0.0.1:2234", proxy.Direct) + return &clientConfig, confError +} From e31bd4fa0697358a3f47817740ec56e589f8a342 Mon Sep 17 00:00:00 2001 From: Bluesaxorcist Date: Sun, 26 Jul 2020 21:02:34 -0500 Subject: [PATCH 13/33] added advanced logging API's to obfs4 --- transports/obfs4/v3/go.mod | 2 +- transports/obfs4/v3/go.sum | 4 ++-- transports/obfs4/v3/obfs4.go | 24 ++++++++++++++---------- transports/obfs4/v3/test_utils.go | 20 ++++++++++++++++---- 4 files changed, 33 insertions(+), 17 deletions(-) diff --git a/transports/obfs4/v3/go.mod b/transports/obfs4/v3/go.mod index 3cf1f1b..9ecef17 100644 --- a/transports/obfs4/v3/go.mod +++ b/transports/obfs4/v3/go.mod @@ -4,8 +4,8 @@ go 1.12 require ( github.com/OperatorFoundation/obfs4 v1.0.0 - github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0 github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0 + github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d golang.org/x/net v0.0.0-20200226121028-0de0cce0169b ) diff --git a/transports/obfs4/v3/go.sum b/transports/obfs4/v3/go.sum index 3f1d5b3..b996e03 100644 --- a/transports/obfs4/v3/go.sum +++ b/transports/obfs4/v3/go.sum @@ -3,12 +3,12 @@ github.com/OperatorFoundation/ed25519 v0.0.0-20200225224545-b22b4bd3ddef h1:1xEt github.com/OperatorFoundation/ed25519 v0.0.0-20200225224545-b22b4bd3ddef/go.mod h1:gQNGvsyT4Zmps9H/yzCqdc+RQzt8ZxCndRNtGTYnBzQ= github.com/OperatorFoundation/obfs4 v1.0.0 h1:OcfdNMzv69fKQrLTkTSwpaBkHyBZMLjigA5M3txZpAg= github.com/OperatorFoundation/obfs4 v1.0.0/go.mod h1:6apgxOLYwyvbpzujpFHWu6Jlc+mjn1aFK7WvNijIVWc= -github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0 h1:zDYt6FDJwDSX4woVFVK2EMt7fkxU5L5qDNLUjQwA+BQ= -github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0/go.mod h1:kB00Ak8Dgn1uZlZHLc/WsUta58Jc+n/ZhCetcPkh42Q= github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0 h1:6aQs+TF3KULMarpzbKu8DhFOF9D2UBCaAN5ZtbK53nQ= github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0/go.mod h1:gb/QiZH0QDXLSQ9PskyJ2oTflB7tsP4AYc8y+FppvB0= github.com/dchest/siphash v1.2.1 h1:4cLinnzVJDKxTCl9B01807Yiy+W7ZzVHj/KIroQRvT4= github.com/dchest/siphash v1.2.1/go.mod h1:q+IRvb2gOSrUnYoPqHiyHXS0FOBBOdl6tONBlVnOnt4= +github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88= +github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/willscott/goturn v0.0.0-20170802220503-19f41278d0c9/go.mod h1:PfwRjodCaQXOsHnh2DeVaXqCFCIrbn5WLj1+A5bQkD4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d h1:1ZiEyfaQIg3Qh0EoqpwAakHVhecoE5wlSg5GjnafJGw= diff --git a/transports/obfs4/v3/obfs4.go b/transports/obfs4/v3/obfs4.go index e51ba3f..b43bb51 100644 --- a/transports/obfs4/v3/obfs4.go +++ b/transports/obfs4/v3/obfs4.go @@ -35,12 +35,13 @@ import ( "flag" "fmt" "github.com/OperatorFoundation/obfs4/common/drbg" - "github.com/OperatorFoundation/obfs4/common/log" + common"github.com/OperatorFoundation/obfs4/common/log" "github.com/OperatorFoundation/obfs4/common/ntor" "github.com/OperatorFoundation/obfs4/common/probdist" "github.com/OperatorFoundation/obfs4/common/replayfilter" "github.com/OperatorFoundation/shapeshifter-ipc/v2" "github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3/framing" + "github.com/op/go-logging" "golang.org/x/net/proxy" "math/rand" "net" @@ -131,7 +132,7 @@ func NewObfs4Server(stateDir string) (*Transport, error) { // Store the arguments that should appear in our descriptor for the clients. ptArgs := make(map[string]string) ptArgs[certArg] = st.cert.String() - log.Infof("certstring %s", certArg) + common.Infof("certstring %s", certArg) ptArgs[iatArg] = strconv.Itoa(st.iatMode) // Initialize the replay filter. @@ -192,7 +193,7 @@ func (transport *Transport) Dial(address string) (net.Conn, error) { if err != nil { closeErr := dialConn.Close() if closeErr != nil { - log.Errorf("could not close") + common.Errorf("could not close") } return nil, err } @@ -206,11 +207,13 @@ type TransportClient struct { IatMode int Address string Dialer proxy.Dialer + log *logging.Logger } type TransportServer struct { ServerFactory *ServerFactory Address string + log *logging.Logger } //Config contains arguments formatted for a json file @@ -219,12 +222,12 @@ type Config struct { IatMode string `json:"iat-mode"` } -func NewClient(certString string, iatMode int, address string, dialer proxy.Dialer) (TransportClient, error) { - return TransportClient{CertString: certString, IatMode: iatMode, Address: address, Dialer: dialer}, nil +func NewClient(certString string, iatMode int, address string, dialer proxy.Dialer, log *logging.Logger) (TransportClient, error) { + return TransportClient{CertString: certString, IatMode: iatMode, Address: address, Dialer: dialer, log: log}, nil } -func NewServer(stateDir string, address string) (*TransportServer, error) { - sf, sFError := NewObfs4ServerFactory(stateDir) +func NewServer(stateDir string, address string, log *logging.Logger) (*TransportServer, error) { + sf, sFError := NewObfs4ServerFactory(stateDir, log) if sFError != nil { return nil, sFError @@ -232,12 +235,13 @@ func NewServer(stateDir string, address string) (*TransportServer, error) { transport := &TransportServer{ ServerFactory: sf, Address: address, + log: log, } return transport, nil } //NewObfs4Server initializes the obfs4 server side -func NewObfs4ServerFactory(stateDir string) (*ServerFactory, error) { +func NewObfs4ServerFactory(stateDir string, log *logging.Logger) (*ServerFactory, error) { args := make(map[string]string) st, err := serverStateFromArgs(stateDir, args) if err != nil { @@ -311,13 +315,13 @@ func (transport *Transport) Listen(address string) (net.Listener, error) { func (transport *TransportServer) Listen() (net.Listener, error) { addr, resolveErr := pt.ResolveAddr(transport.Address) if resolveErr != nil { - fmt.Println(resolveErr.Error()) + transport.log.Error(resolveErr.Error()) return nil, resolveErr } ln, err := net.ListenTCP("tcp", addr) if err != nil { - fmt.Println(err.Error()) + transport.log.Error(err.Error()) return nil, err } diff --git a/transports/obfs4/v3/test_utils.go b/transports/obfs4/v3/test_utils.go index 480d65c..03adbe4 100644 --- a/transports/obfs4/v3/test_utils.go +++ b/transports/obfs4/v3/test_utils.go @@ -1,6 +1,7 @@ package obfs4 import ( + "github.com/op/go-logging" "golang.org/x/net/proxy" "io/ioutil" "os" @@ -26,7 +27,7 @@ func RunLocalObfs4Server(data string) bool { } directoryErr := os.Mkdir(fPath, 0775) if directoryErr != nil { - if !os.IsExist(directoryErr){ + if !os.IsExist(directoryErr) { return false } } @@ -71,6 +72,7 @@ func RunLocalObfs4Server(data string) bool { func RunLocalObfs4ServerFactory(data string) bool { //create a server + log := MakeLog() usr, userError := user.Current() if userError != nil { return false @@ -84,11 +86,11 @@ func RunLocalObfs4ServerFactory(data string) bool { } directoryErr := os.Mkdir(fPath, 0775) if directoryErr != nil { - if !os.IsExist(directoryErr){ + if !os.IsExist(directoryErr) { return false } } - serverConfig, confError := NewServer(fPath, "127.0.0.1:2234") + serverConfig, confError := NewServer(fPath, "127.0.0.1:2234", log) if confError != nil { return false } @@ -161,6 +163,7 @@ func RunObfs4Client() (*Transport, error) { //RunObfs4Client runs the client side in the background for the test func RunObfs4ClientFactory() (*TransportClient, error) { + log := MakeLog() usr, userError := user.Current() if userError != nil { return nil, userError @@ -187,6 +190,15 @@ func RunObfs4ClientFactory() (*TransportClient, error) { bridgePart := bridgeParts1[5] certstring := bridgePart[5:] //println(certstring) - clientConfig, confError := NewClient(certstring, 0, "127.0.0.1:2234", proxy.Direct) + clientConfig, confError := NewClient(certstring, 0, "127.0.0.1:2234", proxy.Direct, log) return &clientConfig, confError } + +func MakeLog() *logging.Logger { + var log = logging.MustGetLogger("obfs4") + backend := logging.NewLogBackend(os.Stderr, "", 0) + backendLeveled := logging.AddModuleLevel(backend) + backendLeveled.SetLevel(logging.DEBUG, "") + log.SetBackend(backendLeveled) + return log +} From aff82ac136697deefb6cdf36cea1761581bdea4e Mon Sep 17 00:00:00 2001 From: Bluesaxorcist Date: Sun, 26 Jul 2020 22:29:30 -0500 Subject: [PATCH 14/33] added improved logging to obfs2 --- transports/obfs2/v2/go.mod | 3 +-- transports/obfs2/v2/go.sum | 22 ++-------------------- transports/obfs2/v2/obfs2.go | 11 +++++++---- transports/obfs2/v2/obfs2_test.go | 4 +++- 4 files changed, 13 insertions(+), 27 deletions(-) diff --git a/transports/obfs2/v2/go.mod b/transports/obfs2/v2/go.mod index 9793304..e15edaa 100644 --- a/transports/obfs2/v2/go.mod +++ b/transports/obfs2/v2/go.mod @@ -5,7 +5,6 @@ go 1.12 require ( github.com/OperatorFoundation/obfs4 v1.0.0 github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0 - github.com/OperatorFoundation/shapeshifter-transports v0.0.0-20200211223228-5b0aa21018a5 - github.com/OperatorFoundation/shapeshifter-transports/transports/Optimizer/v2 v2.1.12 + github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 golang.org/x/net v0.0.0-20200226121028-0de0cce0169b ) diff --git a/transports/obfs2/v2/go.sum b/transports/obfs2/v2/go.sum index 3f3e8e8..7a5e130 100644 --- a/transports/obfs2/v2/go.sum +++ b/transports/obfs2/v2/go.sum @@ -1,38 +1,20 @@ git.torproject.org/pluggable-transports/goptlib.git v1.1.0/go.mod h1:YT4XMSkuEXbtqlydr9+OxqFAyspUv0Gr9qhM3B++o/Q= github.com/OperatorFoundation/ed25519 v0.0.0-20200225224545-b22b4bd3ddef h1:1xEtDEuNE9/yybZaHS94OIjx5FUo4e8M3UwcK9bFC9s= github.com/OperatorFoundation/ed25519 v0.0.0-20200225224545-b22b4bd3ddef/go.mod h1:gQNGvsyT4Zmps9H/yzCqdc+RQzt8ZxCndRNtGTYnBzQ= -github.com/OperatorFoundation/obfs4 v0.0.0-20161108041644-17f2cb99c264 h1:8UbFvUSYrlcEU9W92tohq74kYvtXJo11WLI16TMi904= -github.com/OperatorFoundation/obfs4 v0.0.0-20161108041644-17f2cb99c264/go.mod h1:oxwvRzQ4FDp7ysA1En4F/pyOh2Jfef4YTo1YhHUsBOA= github.com/OperatorFoundation/obfs4 v1.0.0 h1:OcfdNMzv69fKQrLTkTSwpaBkHyBZMLjigA5M3txZpAg= github.com/OperatorFoundation/obfs4 v1.0.0/go.mod h1:6apgxOLYwyvbpzujpFHWu6Jlc+mjn1aFK7WvNijIVWc= github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0 h1:zDYt6FDJwDSX4woVFVK2EMt7fkxU5L5qDNLUjQwA+BQ= github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0/go.mod h1:kB00Ak8Dgn1uZlZHLc/WsUta58Jc+n/ZhCetcPkh42Q= -github.com/OperatorFoundation/shapeshifter-transports v0.0.0-20200211223228-5b0aa21018a5 h1:UrCgBKvfj+Rim1jAUkRqQt1neJgLVHtKt0228tEmFKY= -github.com/OperatorFoundation/shapeshifter-transports v0.0.0-20200211223228-5b0aa21018a5/go.mod h1:u3jvRgYV13oHabVAdXekh3yk9PHfpCKvB8uolQEs4jA= -github.com/OperatorFoundation/shapeshifter-transports v2.1.11+incompatible h1:Icbjg/r1BC9NlQ4yk0XVhjJ4PtWRwd1uS6IrvPSuje4= -github.com/OperatorFoundation/shapeshifter-transports/transports/Optimizer/v2 v2.1.12 h1:BCDQ0UhF4RGxK7eYIBW94uQpOCQvpYbMkdJxSX5s6ZE= -github.com/OperatorFoundation/shapeshifter-transports/transports/Optimizer/v2 v2.1.12/go.mod h1:+A6vQ50ZAHi76GOGtpH730VFirwb1p8E6VJM8M50gNk= -github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v2 v2.1.11 h1:LpSrJLqvqLG3dDK2/FJBMrNEq+Bez1V7kE5CTUYQvT8= -github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v2 v2.1.11/go.mod h1:yPCbCoTjLIG+p0xiuRDwW5t+DivxTHqGU5njf89AkHY= -github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2 v2.1.11 h1:YWL++KLcWh0t755gwZlc8p0DqDAIfWVLdISpoY7RFhw= -github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2 v2.1.11/go.mod h1:OUFBnkMmjMHTWqEQlanDOMTgBjU5QARjklwQv9Qovr4= -github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v2 v2.1.11 h1:gKY17mRkP/VvBWvXzLuivJpFXt0AxkVUx7pv4PX2sUs= -github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v2 v2.1.11/go.mod h1:GN8ahnEHVGcPbR0raxdpWekjgElppspPNAAOpmNxQxU= -github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da h1:KjTM2ks9d14ZYCvmHS9iAKVt9AyzRSqNU1qabPih5BY= -github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da/go.mod h1:eHEWzANqSiWQsof+nXEI9bUVUyV6F53Fp89EuCh2EAA= -github.com/agl/ed25519 v0.0.0-20200225211852-fd4d107ace12 h1:iPf1jQ8yKTms6k6L5vYSE7RZJpjEe5vLTOmzRZdpnKc= github.com/dchest/siphash v1.2.1 h1:4cLinnzVJDKxTCl9B01807Yiy+W7ZzVHj/KIroQRvT4= github.com/dchest/siphash v1.2.1/go.mod h1:q+IRvb2gOSrUnYoPqHiyHXS0FOBBOdl6tONBlVnOnt4= -github.com/shadowsocks/go-shadowsocks2 v0.0.11 h1:dXloqEhYnZV40jblWTK8kWeC0Eb+dgql4S0tj99e8j0= -github.com/shadowsocks/go-shadowsocks2 v0.0.11/go.mod h1:R+KWaoIwRRhnpw6XV+dZil0XHi64Hc1D7hXUyXTjUzQ= +github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88= +github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/willscott/goturn v0.0.0-20170802220503-19f41278d0c9/go.mod h1:PfwRjodCaQXOsHnh2DeVaXqCFCIrbn5WLj1+A5bQkD4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d h1:1ZiEyfaQIg3Qh0EoqpwAakHVhecoE5wlSg5GjnafJGw= golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20200202094626-16171245cfb2 h1:CCH4IOTTfewWjGOlSp+zGcjutRKlBEZQ6wTn8ozI/nI= -golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b h1:0mm1VjtFUOIlE1SbDlwjYaDxZVDP2S5ou6y0gSgXHu8= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU= diff --git a/transports/obfs2/v2/obfs2.go b/transports/obfs2/v2/obfs2.go index 1052fe7..3f869fa 100644 --- a/transports/obfs2/v2/obfs2.go +++ b/transports/obfs2/v2/obfs2.go @@ -36,7 +36,7 @@ import ( "crypto/sha256" "encoding/binary" "fmt" - + "github.com/op/go-logging" "io" "net" "time" @@ -66,6 +66,7 @@ const ( type OptimizerTransport struct { Address string Dialer proxy.Dialer + Log *logging.Logger } //Dial connects to a specified address. @@ -91,25 +92,27 @@ func (transport OptimizerTransport) Dial() (net.Conn, error) { // Transport is the obfs2 implementation of the base.Transport interface. type Transport struct { dialer proxy.Dialer + log logging.Logger } //New initializes obfs2 for Optimizer -func New(address string, dialer proxy.Dialer) *OptimizerTransport { +func New(address string, dialer proxy.Dialer, log *logging.Logger) *OptimizerTransport { result := OptimizerTransport{ Address: address, Dialer: dialer, + Log: log, } return &result } //NewObfs2Transport is the initializer for obfs2 without a dialer func NewObfs2Transport() *Transport { - return &Transport{dialer: nil} + return &Transport{dialer: nil, log: logging.Logger{}} } //NewObfs2Transport is the initializer for obfs2 with a dialer func NewObfs2TransportWithDialer(dialer proxy.Dialer) *Transport { - return &Transport{dialer: dialer} + return &Transport{dialer: dialer, log: logging.Logger{}} } //obfs2TransportListener defines a TCP network listener. diff --git a/transports/obfs2/v2/obfs2_test.go b/transports/obfs2/v2/obfs2_test.go index c118e07..da1ef56 100644 --- a/transports/obfs2/v2/obfs2_test.go +++ b/transports/obfs2/v2/obfs2_test.go @@ -32,6 +32,7 @@ package obfs2 import ( + "github.com/op/go-logging" "golang.org/x/net/proxy" "os" "testing" @@ -97,7 +98,8 @@ func TestObfs2WithDialer(t *testing.T) { } func TestObfs2OptimizerTransportWithDialer(t *testing.T) { - config := New("127.0.0.1:1237", proxy.Direct) + var log = logging.MustGetLogger("obfs2") + config := New("127.0.0.1:1237", proxy.Direct, log) //create client buffer clientBuffer := make([]byte, 4) //call dial on client and check error From f60317a44ebdeb5a34c9ac7d82d8f75fbd2626e0 Mon Sep 17 00:00:00 2001 From: Bluesaxorcist Date: Mon, 27 Jul 2020 01:02:18 -0500 Subject: [PATCH 15/33] added better logging to all transports --- transports/Dust/v3/Dust.go | 7 ++++++- transports/Dust/v3/Dust_test.go | 4 +++- transports/Replicant/v3/Optimizer.go | 9 +++++++-- transports/Replicant/v3/ReplicantClientConfig.json | 2 +- transports/Replicant/v3/ReplicantClientConfig1.json | 2 +- transports/Replicant/v3/ReplicantServerConfig.json | 2 +- transports/Replicant/v3/ReplicantServerConfig1.json | 2 +- transports/Replicant/v3/go.mod | 1 + transports/Replicant/v3/go.sum | 2 ++ transports/Replicant/v3/replicant_test.go | 10 ++++++---- transports/meeklite/v3/go.mod | 2 +- transports/meeklite/v3/go.sum | 13 ++----------- transports/meeklite/v3/meeklite.go | 6 ++++-- transports/meeklite/v3/meeklite_test.go | 4 +++- transports/meekserver/v3/go.mod | 2 +- transports/meekserver/v3/go.sum | 4 ++-- transports/meekserver/v3/meekserver_test.go | 4 +++- transports/meekserver/v3/pt21.go | 5 ++++- transports/obfs2/v3/go.mod | 1 + transports/obfs2/v3/go.sum | 2 ++ transports/obfs2/v3/obfs2.go | 5 ++++- transports/obfs2/v3/obfs2_test.go | 4 +++- transports/shadow/v3/go.mod | 1 + transports/shadow/v3/go.sum | 2 ++ transports/shadow/v3/shadow.go | 7 +++++-- transports/shadow/v3/shadow_test.go | 4 +++- 26 files changed, 70 insertions(+), 37 deletions(-) diff --git a/transports/Dust/v3/Dust.go b/transports/Dust/v3/Dust.go index bcf6262..1336097 100644 --- a/transports/Dust/v3/Dust.go +++ b/transports/Dust/v3/Dust.go @@ -10,6 +10,9 @@ package Dust import ( "fmt" "github.com/OperatorFoundation/obfs4/common/log" + + //"github.com/OperatorFoundation/obfs4/common/log" + "github.com/op/go-logging" "golang.org/x/net/proxy" "net" "time" @@ -51,18 +54,20 @@ type Transport struct { Address string Dialer proxy.Dialer ServerConfig *dustServer + Log *logging.Logger } type Config struct { ServerPublic string `json:"server-public"` } -func New(serverPublic string, address string, dialer proxy.Dialer, serverConfig *dustServer) Transport { +func New(serverPublic string, address string, dialer proxy.Dialer, serverConfig *dustServer, log *logging.Logger) Transport { return Transport{ ServerPublic: serverPublic, Address: address, Dialer: dialer, ServerConfig: serverConfig, + Log: log, } } diff --git a/transports/Dust/v3/Dust_test.go b/transports/Dust/v3/Dust_test.go index 11daf1d..3068e09 100644 --- a/transports/Dust/v3/Dust_test.go +++ b/transports/Dust/v3/Dust_test.go @@ -9,6 +9,7 @@ package Dust import ( + "github.com/op/go-logging" "golang.org/x/net/proxy" "testing" ) @@ -86,12 +87,13 @@ func TestDust(t *testing.T) { func TestDustV3(t *testing.T) { //create a server + var log = logging.MustGetLogger("dust") serverConfig := dustServer{ serverPrivkey: nil, dialer: nil, } - transport := New("", "127.0.0.1:1234", proxy.Direct, &serverConfig) + transport := New("", "127.0.0.1:1234", proxy.Direct, &serverConfig, log) //call listen on the server serverListener, listenErr := transport.Listen() if listenErr != nil { diff --git a/transports/Replicant/v3/Optimizer.go b/transports/Replicant/v3/Optimizer.go index c3f4217..7edb522 100644 --- a/transports/Replicant/v3/Optimizer.go +++ b/transports/Replicant/v3/Optimizer.go @@ -2,6 +2,7 @@ package replicant import ( pt "github.com/OperatorFoundation/shapeshifter-ipc/v2" + "github.com/op/go-logging" "golang.org/x/net/proxy" "net" ) @@ -11,27 +12,31 @@ type TransportClient struct { Config ClientConfig Address string Dialer proxy.Dialer + Log *logging.Logger } type TransportServer struct { Config ServerConfig Address string Dialer proxy.Dialer + Log *logging.Logger } -func NewClient(config ClientConfig, address string, dialer proxy.Dialer) TransportClient { +func NewClient(config ClientConfig, address string, dialer proxy.Dialer, log *logging.Logger) TransportClient { return TransportClient{ Config: config, Address: address, Dialer: dialer, + Log: log, } } -func NewServer(config ServerConfig, address string, dialer proxy.Dialer) TransportServer { +func NewServer(config ServerConfig, address string, dialer proxy.Dialer, log *logging.Logger) TransportServer { return TransportServer{ Config: config, Address: address, Dialer: dialer, + Log: log, } } diff --git a/transports/Replicant/v3/ReplicantClientConfig.json b/transports/Replicant/v3/ReplicantClientConfig.json index 9851ff3..ec2382f 100644 --- a/transports/Replicant/v3/ReplicantClientConfig.json +++ b/transports/Replicant/v3/ReplicantClientConfig.json @@ -1 +1 @@ -{"config":"M/+BAwEBDENsaWVudENvbmZpZwH/ggABAgEJVG9uZWJ1cnN0ARAAAQZQb2xpc2gBEAAAAP+8/4IBZmdpdGh1Yi5jb20vT3BlcmF0b3JGb3VuZGF0aW9uL3NoYXBlc2hpZnRlci10cmFuc3BvcnRzL3RyYW5zcG9ydHMvUmVwbGljYW50L3YzL3RvbmVidXJzdC5Nb25vdG9uZUNvbmZpZ/+NAwEBDk1vbm90b25lQ29uZmlnAf+OAAEDAQxBZGRTZXF1ZW5jZXMB/5AAAQ9SZW1vdmVTZXF1ZW5jZXMB/5IAAQpTcGVha0ZpcnN0AQIAAAAq/48DAQEISW5zdGFuY2UB/5AAAQIBBERlc2MB/5IAAQRBcmdzAf+WAAAAJP+RAwEBC0Rlc2NyaXB0aW9uAf+SAAEBAQVQYXJ0cwH/lAAAACH/kwIBARNbXW1vbm9saXRoLk1vbm9saXRoAf+UAAEQAAAo/5UDAQEEQXJncwH/lgABAgEGVmFsdWVzAf+YAAEFSW5kZXgBBAAAABz/lwIBAQ5bXWludGVyZmFjZSB7fQH/mAABEAAA/gG5/45jAQEBATxnaXRodWIuY29tL09wZXJhdG9yRm91bmRhdGlvbi9tb25vbGl0aC1nby9tb25vbGl0aC5CeXRlc1BhcnT/mQMBAQlCeXRlc1BhcnQB/5oAAQEBBUl0ZW1zAf+cAAAAIf+bAgEBE1tdbW9ub2xpdGguQnl0ZVR5cGUB/5wAARAAAHn/mmcBAUBnaXRodWIuY29tL09wZXJhdG9yRm91bmRhdGlvbi9tb25vbGl0aC1nby9tb25vbGl0aC5GaXhlZEJ5dGVUeXBl/50DAQENRml4ZWRCeXRlVHlwZQH/ngABAQEEQnl0ZQEGAAAAB/+eAwETAAA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Ul0ZW1zAf+cAAAAIf+bAgEBE1tdbW9ub2xpdGguQnl0ZVR5cGUB/5wAARAAAHn/mmcBAUBnaXRodWIuY29tL09wZXJhdG9yRm91bmRhdGlvbi9tb25vbGl0aC1nby9tb25vbGl0aC5GaXhlZEJ5dGVUeXBl/50DAQENRml4ZWRCeXRlVHlwZQH/ngABAQEEQnl0ZQEGAAAAB/+eAwETAAAAAQAAAgEAAW1naXRodWIuY29tL09wZXJhdG9yRm91bmRhdGlvbi9zaGFwZXNoaWZ0ZXItdHJhbnNwb3J0cy90cmFuc3BvcnRzL1JlcGxpY2FudC92My9wb2xpc2guU2lsdmVyUG9saXNoQ2xpZW50Q29uZmln/4cDAQEYU2lsdmVyUG9saXNoQ2xpZW50Q29uZmlnAf+IAAECAQ9TZXJ2ZXJQdWJsaWNLZXkBCgABCUNodW5rU2l6ZQEEAAAATP+ISAFBBK/Bwa0RrYc3813sA8lIx2uT7pcwEOCIYvjy/7khB1uU8eiUOlAyZdhLmkJRGzXRzoub27HOkYDK2qX35o4GhHoB/goQAAA="} \ No newline at end of file diff --git a/transports/Replicant/v3/ReplicantClientConfig1.json b/transports/Replicant/v3/ReplicantClientConfig1.json index 5ff8337..e80bcab 100644 --- a/transports/Replicant/v3/ReplicantClientConfig1.json +++ b/transports/Replicant/v3/ReplicantClientConfig1.json @@ -1 +1 @@ -{"config":"M/+BAwEBDENsaWVudENvbmZpZwH/ggABAgEJVG9uZWJ1cnN0ARAAAQZQb2xpc2gBEAAAAP+8/4IBZmdpdGh1Yi5jb20vT3BlcmF0b3JGb3VuZGF0aW9uL3NoYXBlc2hpZnRlci10cmFuc3BvcnRzL3RyYW5zcG9ydHMvUmVwbGljYW50L3YzL3RvbmVidXJzdC5Nb25vdG9uZUNvbmZpZ/+NAwEBDk1vbm90b25lQ29uZmlnAf+OAAEDAQxBZGRTZXF1ZW5jZXMB/5AAAQ9SZW1vdmVTZXF1ZW5jZXMB/5IAAQpTcGVha0ZpcnN0AQIAAAAq/48DA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4gAAQIBD1NlcnZlclB1YmxpY0tleQEKAAEJQ2h1bmtTaXplAQQAAABM/4hIAUEEQn3x8ZubAgf6TspbDBmwaJRz7rCM4sDzcP/012t8cRwlHLdOdbYUx6N7gUBEgKpY6e5utXOkAXJSDFrXDAzQnwH+CZgAAA=="} \ No newline at end of file diff --git a/transports/Replicant/v3/ReplicantServerConfig.json b/transports/Replicant/v3/ReplicantServerConfig.json index b6082a4..5ad3a44 100644 --- a/transports/Replicant/v3/ReplicantServerConfig.json +++ b/transports/Replicant/v3/ReplicantServerConfig.json @@ -1 +1 @@ -{"Replicant":{"config":"M/+JAwEBDFNlcnZlckNvbmZpZwH/igABAgEJVG9uZWJ1cnN0ARAAAQZQb2xpc2gBEAAAAP+8/4oBZmdpdGh1Yi5jb20vT3BlcmF0b3JGb3VuZGF0aW9uL3NoYXBlc2hpZnRlci10cmFuc3BvcnRzL3RyYW5zcG9ydHMvUmVwbGljYW50L3YzL3RvbmVidXJzdC5Nb25vdG9uZUNvbmZpZ/+NAwEBDk1vbm90b25lQ29uZmlnAf+OAAEDAQxBZGRTZXF1ZW5jZXMB/5AAAQ9SZW1vdmVTZXF1ZW5jZXMB/5IAAQpTcGVha0ZpcnN0AQIAAAAq/48DAQEISW5zdGFuY2UB/5AAAQIBBERlc2MB/5IAAQRBcmdzAf+WAAAAJP+RAwEBC0Rlc2NyaXB0aW9uAf+SAAEBAQVQYXJ0cwH/lAAAACH/kwIBARNbXW1vbm9saXRoLk1vbm9saXRoAf+UAAEQAAAo/5UDAQEEQXJncwH/lgABAgEGVmFsdWVzAf+YAAEFSW5kZXgBBAAAABz/lwIBAQ5bXWludGVyZmFjZSB7fQH/mAABEAAA/gHI/45iAgEBPGdpdGh1Yi5jb20vT3BlcmF0b3JGb3VuZGF0aW9uL21vbm9saXRoLWdvL21vbm9saXRoLkJ5dGVzUGFydP+ZAwEBCUJ5dGVzUGFydAH/mgABAQEFSXRlbXMB/5wAAAAh/5sCAQETW11tb25vbGl0aC5CeX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NbXW1vbm9saXRoLk1vbm9saXRoAf+UAAEQAAAo/5UDAQEEQXJncwH/lgABAgEGVmFsdWVzAf+YAAEFSW5kZXgBBAAAABz/lwIBAQ5bXWludGVyZmFjZSB7fQH/mAABEAAA/gHI/45iAgEBPGdpdGh1Yi5jb20vT3BlcmF0b3JGb3VuZGF0aW9uL21vbm9saXRoLWdvL21vbm9saXRoLkJ5dGVzUGFydP+ZAwEBCUJ5dGVzUGFydAH/mgABAQEFSXRlbXMB/5wAAAAh/5sCAQETW11tb25vbGl0aC5CeXRlVHlwZQH/nAABEAAAdP+aZwEBQGdpdGh1Yi5jb20vT3BlcmF0b3JGb3VuZGF0aW9uL21vbm9saXRoLWdvL21vbm9saXRoLkZpeGVkQnl0ZVR5cGX/nQMBAQ1GaXhlZEJ5dGVUeXBlAf+eAAEBAQRCeXRlAQYAAAAH/54DARMAAAAAAW1naXRodWIuY29tL09wZXJhdG9yRm91bmRhdGlvbi9zaGFwZXNoaWZ0ZXItdHJhbnNwb3J0cy90cmFuc3BvcnRzL1JlcGxpY2FudC92My9wb2xpc2guU2lsdmVyUG9saXNoU2VydmVyQ29uZmln/4sDAQEYU2lsdmVyUG9saXNoU2VydmVyQ29uZmlnAf+MAAEDAQ9TZXJ2ZXJQdWJsaWNLZXkBCgABEFNlcnZlclByaXZhdGVLZXkBCgABCUNodW5rU2l6ZQEEAAAAbv+MagFBBK/Bwa0RrYc3813sA8lIx2uT7pcwEOCIYvjy/7khB1uU8eiUOlAyZdhLmkJRGzXRzoub27HOkYDK2qX35o4GhHoBIO70TnPmS+W3C3MogewTb33cx692J4C1q+hGwpx7yIwYAf4KEAAA"}} \ No newline at end of file diff --git a/transports/Replicant/v3/ReplicantServerConfig1.json b/transports/Replicant/v3/ReplicantServerConfig1.json index a34a20c..3293ef6 100644 --- a/transports/Replicant/v3/ReplicantServerConfig1.json +++ b/transports/Replicant/v3/ReplicantServerConfig1.json @@ -1 +1 @@ -{"Replicant":{"config":"M/+JAwEBDFNlcn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YXRvckZvdW5kYXRpb24vbW9ub2xpdGgtZ28vbW9ub2xpdGguUmFuZG9tRW51bWVyYXRlZEJ5dGVUeXBl/6AHAQQREhMUAEtnaXRodWIuY29tL09wZXJhdG9yRm91bmRhdGlvbi9tb25vbGl0aC1nby9tb25vbGl0aC5SYW5kb21FbnVtZXJhdGVkQnl0ZVR5cGX/oAcBBBESExQAAAAAAW1naXRodWIuY29tL09wZXJhdG9yRm91bmRhdGlvbi9zaGFwZXNoaWZ0ZXItdHJhbnNwb3J0cy90cmFuc3BvcnRzL1JlcGxpY2FudC92My9wb2xpc2guU2lsdmVyUG9saXNoU2VydmVyQ29uZmln/4sDAQEYU2lsdmVyUG9saXNoU2VydmVyQ29uZmlnAf+MAAEDAQ9TZXJ2ZXJQdWJsaWNLZXkBCgABEFNlcnZlclByaXZhdGVLZXkBCgABCUNodW5rU2l6ZQEEAAAAbv+MagFBBEJ98fGbmwIH+k7KWwwZsGiUc+6wjOLA83D/9NdrfHEcJRy3TnW2FMeje4FARICqWOnubrVzpAFyUgxa1wwM0J8BIAuZ5JWpLJJ4Se3weAHCdOTXmq7Ymt3P69QFBbeVAeIIAf4JmAAA"}} \ No newline at end of file diff --git a/transports/Replicant/v3/go.mod b/transports/Replicant/v3/go.mod index 2d0d408..48fdc06 100644 --- a/transports/Replicant/v3/go.mod +++ b/transports/Replicant/v3/go.mod @@ -5,6 +5,7 @@ go 1.12 require ( github.com/OperatorFoundation/monolith-go/monolith v1.0.4 github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0 + github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 github.com/opentracing/opentracing-go v1.1.0 golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 golang.org/x/net v0.0.0-20200202094626-16171245cfb2 diff --git a/transports/Replicant/v3/go.sum b/transports/Replicant/v3/go.sum index fa3bd56..3d39d37 100644 --- a/transports/Replicant/v3/go.sum +++ b/transports/Replicant/v3/go.sum @@ -4,6 +4,8 @@ github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0 h1:6aQs+TF3KULMarpzbKu8 github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0/go.mod h1:gb/QiZH0QDXLSQ9PskyJ2oTflB7tsP4AYc8y+FppvB0= github.com/deckarep/golang-set v1.7.1 h1:SCQV0S6gTtp6itiFrTqI+pfmJ4LN85S1YzhDf9rTHJQ= github.com/deckarep/golang-set v1.7.1/go.mod h1:93vsz/8Wt4joVM7c2AVqh+YRMiUSc14yDtF28KmMOgQ= +github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88= +github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/opentracing/opentracing-go v1.1.0 h1:pWlfV3Bxv7k65HYwkikxat0+s3pV4bsqf19k25Ur8rU= github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= diff --git a/transports/Replicant/v3/replicant_test.go b/transports/Replicant/v3/replicant_test.go index 9b1b028..e1b05ae 100644 --- a/transports/Replicant/v3/replicant_test.go +++ b/transports/Replicant/v3/replicant_test.go @@ -5,6 +5,7 @@ import ( "github.com/OperatorFoundation/monolith-go/monolith" "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v3/polish" "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v3/toneburst" + "github.com/op/go-logging" "golang.org/x/net/proxy" "io/ioutil" "math/rand" @@ -183,6 +184,7 @@ func runReplicantServer() { } func runReplicantFactoryServer() { + var log = logging.MustGetLogger("replicant") serverStarted := make(chan bool) addr := "127.0.0.1:3001" @@ -191,7 +193,7 @@ func runReplicantFactoryServer() { Polish: nil, } - server := NewServer(serverConfig, addr, proxy.Direct) + server := NewServer(serverConfig, addr, proxy.Direct, log) go func() { listener, listenError := server.Listen() @@ -302,7 +304,7 @@ func replicantConnection(clientConfig ClientConfig, serverConfig ServerConfig, t func replicantFactoryConnection(clientConfig ClientConfig, serverConfig ServerConfig, t *testing.T) { serverStarted := make(chan bool) - + var log = logging.MustGetLogger("replicant") // Get a random port rand.Seed(time.Now().UnixNano()) min := 1025 @@ -313,7 +315,7 @@ func replicantFactoryConnection(clientConfig ClientConfig, serverConfig ServerCo addr += portString go func() { - server := NewServer(serverConfig, addr, proxy.Direct) + server := NewServer(serverConfig, addr, proxy.Direct, log) listener, listenError := server.Listen() if listenError != nil { return @@ -348,7 +350,7 @@ func replicantFactoryConnection(clientConfig ClientConfig, serverConfig ServerCo t.Fail() return } - client := NewClient(clientConfig, addr, proxy.Direct) + client := NewClient(clientConfig, addr, proxy.Direct, log) cConn, connErr := client.Dial() if connErr != nil { t.Fail() diff --git a/transports/meeklite/v3/go.mod b/transports/meeklite/v3/go.mod index c3fe6e7..e7e77d9 100644 --- a/transports/meeklite/v3/go.mod +++ b/transports/meeklite/v3/go.mod @@ -3,6 +3,6 @@ module github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite go 1.12 require ( - github.com/stretchr/testify v1.5.1 + github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 golang.org/x/net v0.0.0-20200202094626-16171245cfb2 ) diff --git a/transports/meeklite/v3/go.sum b/transports/meeklite/v3/go.sum index fe647ab..6ca77db 100644 --- a/transports/meeklite/v3/go.sum +++ b/transports/meeklite/v3/go.sum @@ -1,16 +1,7 @@ -github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88= +github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/net v0.0.0-20200202094626-16171245cfb2 h1:CCH4IOTTfewWjGOlSp+zGcjutRKlBEZQ6wTn8ozI/nI= golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/transports/meeklite/v3/meeklite.go b/transports/meeklite/v3/meeklite.go index d5492ec..1ba28f6 100644 --- a/transports/meeklite/v3/meeklite.go +++ b/transports/meeklite/v3/meeklite.go @@ -39,6 +39,7 @@ import ( "encoding/hex" "errors" "fmt" + "github.com/op/go-logging" "golang.org/x/net/proxy" "io" "io/ioutil" @@ -127,6 +128,7 @@ type Transport struct { Front string `json:"front"` Address string Dialer proxy.Dialer + log *logging.Logger } //Config puts the parameters in a json compatible format @@ -135,8 +137,8 @@ type Config struct { Front string `json:"front"` } -func NewMeekFactoryTransportWithFront(url *gourl.URL, front string, address string, dialer proxy.Dialer) *Transport { - return &Transport{url, front, address,dialer} +func NewMeekFactoryTransportWithFront(url *gourl.URL, front string, address string, dialer proxy.Dialer, log *logging.Logger) *Transport { + return &Transport{url, front, address,dialer, log} } // Dial creates outgoing transport connection func (transport Transport) Dial() (net.Conn, error) { diff --git a/transports/meeklite/v3/meeklite_test.go b/transports/meeklite/v3/meeklite_test.go index 80bcf4f..6dd9475 100644 --- a/transports/meeklite/v3/meeklite_test.go +++ b/transports/meeklite/v3/meeklite_test.go @@ -34,6 +34,7 @@ package meeklite import ( + "github.com/op/go-logging" "golang.org/x/net/proxy" gourl "net/url" "testing" @@ -78,6 +79,7 @@ func TestMeeklite(t *testing.T) { } func TestFactoryMeeklite(t *testing.T) { + var log = logging.MustGetLogger("meeklite") //create a server urlString := "https://transport-canary-meek.appspot.com/" Url, err := gourl.Parse(urlString) @@ -86,7 +88,7 @@ func TestFactoryMeeklite(t *testing.T) { return } - config := NewMeekFactoryTransportWithFront(Url, "www.google.com", "", proxy.Direct) + config := NewMeekFactoryTransportWithFront(Url, "www.google.com", "", proxy.Direct, log) //create client buffer clientBuffer := make([]byte, 4) diff --git a/transports/meekserver/v3/go.mod b/transports/meekserver/v3/go.mod index bc18a26..9cae6a7 100644 --- a/transports/meekserver/v3/go.mod +++ b/transports/meekserver/v3/go.mod @@ -3,9 +3,9 @@ module github.com/OperatorFoundation/shapeshifter-transports/transports/meekserv go 1.12 require ( - git.torproject.org/pluggable-transports/goptlib.git v1.1.0 github.com/deckarep/golang-set v1.7.1 github.com/mufti1/interconv v0.0.0-20190313040840-d7c72925c656 + github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 golang.org/x/crypto v0.0.0-20200214034016-1d94cc7ab1c6 golang.org/x/net v0.0.0-20200202094626-16171245cfb2 ) diff --git a/transports/meekserver/v3/go.sum b/transports/meekserver/v3/go.sum index 3bd92d5..cbdb217 100644 --- a/transports/meekserver/v3/go.sum +++ b/transports/meekserver/v3/go.sum @@ -1,9 +1,9 @@ -git.torproject.org/pluggable-transports/goptlib.git v1.1.0 h1:LMQAA8pAho+QtYrrVNimJQiINNEwcwuuD99vezD/PAo= -git.torproject.org/pluggable-transports/goptlib.git v1.1.0/go.mod h1:YT4XMSkuEXbtqlydr9+OxqFAyspUv0Gr9qhM3B++o/Q= github.com/deckarep/golang-set v1.7.1 h1:SCQV0S6gTtp6itiFrTqI+pfmJ4LN85S1YzhDf9rTHJQ= github.com/deckarep/golang-set v1.7.1/go.mod h1:93vsz/8Wt4joVM7c2AVqh+YRMiUSc14yDtF28KmMOgQ= github.com/mufti1/interconv v0.0.0-20190313040840-d7c72925c656 h1:p+IdebEeB9SAEH9IOJVF6oZ535bwvWqUdqWxG1UWeko= github.com/mufti1/interconv v0.0.0-20190313040840-d7c72925c656/go.mod h1:+db4NNs1NvceiftEzz0ymfu3zKLkynYukafc7llNoMs= +github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88= +github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20200214034016-1d94cc7ab1c6 h1:Sy5bstxEqwwbYs6n0/pBuxKENqOeZUgD45Gp3Q3pqLg= golang.org/x/crypto v0.0.0-20200214034016-1d94cc7ab1c6/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= diff --git a/transports/meekserver/v3/meekserver_test.go b/transports/meekserver/v3/meekserver_test.go index f614c4e..fe4c8a9 100644 --- a/transports/meekserver/v3/meekserver_test.go +++ b/transports/meekserver/v3/meekserver_test.go @@ -1,6 +1,7 @@ package meekserver import ( + "github.com/op/go-logging" "testing" ) @@ -28,9 +29,10 @@ func TestMeekServerListen(t *testing.T) { } func TestMeekServerFactoryListen(t *testing.T) { + var log = logging.MustGetLogger("meekserver") acmeEmail := "brandon@operatorfoundation.org" acmeHostNames := "operatorrss.com" - meekserverTransport, newError := New(false, acmeHostNames, acmeEmail,"127.0.0.1:8080", "state") + meekserverTransport, newError := New(false, acmeHostNames, acmeEmail,"127.0.0.1:8080", "state", log) if newError != nil { t.Fail() return diff --git a/transports/meekserver/v3/pt21.go b/transports/meekserver/v3/pt21.go index f1bac34..b5f268d 100644 --- a/transports/meekserver/v3/pt21.go +++ b/transports/meekserver/v3/pt21.go @@ -35,6 +35,7 @@ package meekserver import ( "errors" interconv "github.com/mufti1/interconv/package" + "github.com/op/go-logging" "golang.org/x/crypto/acme/autocert" "log" "net" @@ -55,6 +56,7 @@ type Transport struct { DisableTLS bool CertManager *autocert.Manager Address string + log *logging.Logger } //Config contains arguments formatted for a json file @@ -79,7 +81,7 @@ type fakeConn struct { writeBuffer []byte } -func New(disableTLS bool, acmeHostnamesCommas string, acmeEmail string, address string, stateDir string) (*Transport, error) { +func New(disableTLS bool, acmeHostnamesCommas string, acmeEmail string, address string, stateDir string, Log *logging.Logger) (*Transport, error) { var certManager *autocert.Manager if disableTLS { if acmeEmail != "" || acmeHostnamesCommas != "" { @@ -117,6 +119,7 @@ func New(disableTLS bool, acmeHostnamesCommas string, acmeEmail string, address DisableTLS: disableTLS, CertManager: certManager, Address: address, + log: Log, }, nil } else { return nil, errors.New("must set acmeEmail") diff --git a/transports/obfs2/v3/go.mod b/transports/obfs2/v3/go.mod index c7b2c05..b2fa78f 100644 --- a/transports/obfs2/v3/go.mod +++ b/transports/obfs2/v3/go.mod @@ -5,5 +5,6 @@ go 1.12 require ( github.com/OperatorFoundation/obfs4 v1.0.0 github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0 + github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 golang.org/x/net v0.0.0-20200226121028-0de0cce0169b ) diff --git a/transports/obfs2/v3/go.sum b/transports/obfs2/v3/go.sum index af33490..139977a 100644 --- a/transports/obfs2/v3/go.sum +++ b/transports/obfs2/v3/go.sum @@ -7,6 +7,8 @@ github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0 h1:6aQs+TF3KULMarpzbKu8 github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0/go.mod h1:gb/QiZH0QDXLSQ9PskyJ2oTflB7tsP4AYc8y+FppvB0= github.com/dchest/siphash v1.2.1 h1:4cLinnzVJDKxTCl9B01807Yiy+W7ZzVHj/KIroQRvT4= github.com/dchest/siphash v1.2.1/go.mod h1:q+IRvb2gOSrUnYoPqHiyHXS0FOBBOdl6tONBlVnOnt4= +github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88= +github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/willscott/goturn v0.0.0-20170802220503-19f41278d0c9/go.mod h1:PfwRjodCaQXOsHnh2DeVaXqCFCIrbn5WLj1+A5bQkD4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= diff --git a/transports/obfs2/v3/obfs2.go b/transports/obfs2/v3/obfs2.go index 98ca51e..36b8b0e 100644 --- a/transports/obfs2/v3/obfs2.go +++ b/transports/obfs2/v3/obfs2.go @@ -36,6 +36,7 @@ import ( "crypto/sha256" "encoding/binary" "fmt" + "github.com/op/go-logging" "io" "net" @@ -66,6 +67,7 @@ const ( type OptimizerTransport struct { Address string Dialer proxy.Dialer + log *logging.Logger } //Dial connects to a specified address. @@ -110,10 +112,11 @@ type Transport struct { } //New initializes obfs2 for Optimizer -func New(address string, dialer proxy.Dialer) *OptimizerTransport { +func New(address string, dialer proxy.Dialer, log *logging.Logger) *OptimizerTransport { result := OptimizerTransport{ Address: address, Dialer: dialer, + log: log, } return &result } diff --git a/transports/obfs2/v3/obfs2_test.go b/transports/obfs2/v3/obfs2_test.go index 5f73e1d..5145a45 100644 --- a/transports/obfs2/v3/obfs2_test.go +++ b/transports/obfs2/v3/obfs2_test.go @@ -32,6 +32,7 @@ package obfs2 import ( + "github.com/op/go-logging" "golang.org/x/net/proxy" "os" "testing" @@ -97,7 +98,8 @@ func TestObfs2WithDialer(t *testing.T) { } func TestObfs2OptimizerTransportWithDialer(t *testing.T) { - config := New("127.0.0.1:1237", proxy.Direct) + var log = logging.MustGetLogger("obfs2") + config := New("127.0.0.1:1237", proxy.Direct, log) //create client buffer clientBuffer := make([]byte, 4) //call dial on client and check error diff --git a/transports/shadow/v3/go.mod b/transports/shadow/v3/go.mod index c3db847..40c8604 100644 --- a/transports/shadow/v3/go.mod +++ b/transports/shadow/v3/go.mod @@ -4,6 +4,7 @@ go 1.12 require ( github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da // indirect + github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 github.com/shadowsocks/go-shadowsocks2 v0.0.11 golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 // indirect ) diff --git a/transports/shadow/v3/go.sum b/transports/shadow/v3/go.sum index 41a91f8..e71d517 100644 --- a/transports/shadow/v3/go.sum +++ b/transports/shadow/v3/go.sum @@ -1,5 +1,7 @@ github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da h1:KjTM2ks9d14ZYCvmHS9iAKVt9AyzRSqNU1qabPih5BY= github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da/go.mod h1:eHEWzANqSiWQsof+nXEI9bUVUyV6F53Fp89EuCh2EAA= +github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88= +github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/shadowsocks/go-shadowsocks2 v0.0.11 h1:dXloqEhYnZV40jblWTK8kWeC0Eb+dgql4S0tj99e8j0= github.com/shadowsocks/go-shadowsocks2 v0.0.11/go.mod h1:R+KWaoIwRRhnpw6XV+dZil0XHi64Hc1D7hXUyXTjUzQ= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= diff --git a/transports/shadow/v3/shadow.go b/transports/shadow/v3/shadow.go index eff972a..eea4699 100644 --- a/transports/shadow/v3/shadow.go +++ b/transports/shadow/v3/shadow.go @@ -26,6 +26,7 @@ package shadow import ( + "github.com/op/go-logging" "log" "net" @@ -43,6 +44,7 @@ type Transport struct { Password string CipherName string Address string + Log *logging.Logger } //NewConfig is used to create a config for testing @@ -54,11 +56,12 @@ func NewConfig(password string, cipherName string) Config { } //NewTransport is used for creating a transport for Optimizer -func NewTransport(password string, cipherName string, address string) Transport { +func NewTransport(password string, cipherName string, address string, log *logging.Logger) Transport { return Transport{ Password: password, CipherName: cipherName, Address: address, + Log: log, } } @@ -116,4 +119,4 @@ func (transport *Transport) Listen() (net.Listener, error) { return nil, listenerErr } return listener, nil -} \ No newline at end of file +} diff --git a/transports/shadow/v3/shadow_test.go b/transports/shadow/v3/shadow_test.go index c94c9aa..92479f3 100644 --- a/transports/shadow/v3/shadow_test.go +++ b/transports/shadow/v3/shadow_test.go @@ -26,6 +26,7 @@ package shadow import ( "fmt" + "github.com/op/go-logging" "net" "os" "testing" @@ -99,7 +100,8 @@ func TestShadow(t *testing.T) { } func TestShadowFactory(t *testing.T) { //create a server - transport := NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1236") + var log = logging.MustGetLogger("shadow") + transport := NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1236", log) //create client buffer clientBuffer := make([]byte, 4) From c26934eef8dc741b7b6a06e30d8647473e7286fd Mon Sep 17 00:00:00 2001 From: Bluesaxorcist Date: Mon, 27 Jul 2020 10:49:36 -0500 Subject: [PATCH 16/33] added better logging to Optimizer tests --- transports/Optimizer/v3/Optimizer_test.go | 15 +++++++------ transports/Optimizer/v3/go.mod | 9 ++++---- transports/Optimizer/v3/go.sum | 26 +++++++++-------------- 3 files changed, 23 insertions(+), 27 deletions(-) diff --git a/transports/Optimizer/v3/Optimizer_test.go b/transports/Optimizer/v3/Optimizer_test.go index 789c736..c9afc04 100644 --- a/transports/Optimizer/v3/Optimizer_test.go +++ b/transports/Optimizer/v3/Optimizer_test.go @@ -5,6 +5,7 @@ import ( "github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3" "github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3" "github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3" + "github.com/op/go-logging" "golang.org/x/net/proxy" "io/ioutil" "net" @@ -81,7 +82,7 @@ func TestShadowDial(t *testing.T) { } func TestOptimizerShadowDial(t *testing.T) { - shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235") + shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235", &logging.Logger{}) transports := []TransportDialer{&shadowTransport} strategy := NewFirstStrategy(transports) optimizerTransport := NewOptimizerClient(transports, strategy) @@ -92,7 +93,7 @@ func TestOptimizerShadowDial(t *testing.T) { } func TestOptimizerObfs2Dial(t *testing.T) { - obfs2Transport := obfs2.New("127.0.0.1:1237", proxy.Direct) + obfs2Transport := obfs2.New("127.0.0.1:1237", proxy.Direct, &logging.Logger{}) transports := []TransportDialer{obfs2Transport} strategy := NewFirstStrategy(transports) optimizerTransport := NewOptimizerClient(transports, strategy) @@ -147,7 +148,7 @@ func TestOptimizerTransportFirstDial(t *testing.T) { IatMode: 0, Address: "127.0.0.1:1234", Dialer: dialer} - shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235") + shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235", &logging.Logger{}) transports := []TransportDialer{obfs4Transport, &shadowTransport} strategy := NewFirstStrategy(transports) optimizerTransport := NewOptimizerClient(transports, strategy) @@ -172,7 +173,7 @@ func TestOptimizerTransportRandomDial(t *testing.T) { Address: "127.0.0.1:1234", Dialer: dialer, } - shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235") + shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235", &logging.Logger{}) transports := []TransportDialer{obfs4Transport, &shadowTransport} strategy := NewRandomStrategy(transports) optimizerTransport := NewOptimizerClient(transports, strategy) @@ -198,7 +199,7 @@ func TestOptimizerTransportRotateDial(t *testing.T) { Address: "127.0.0.1:1234", Dialer: dialer, } - shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235") + shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235", &logging.Logger{}) transports := []TransportDialer{obfs4Transport, &shadowTransport} strategy := NewRotateStrategy(transports) optimizerTransport := NewOptimizerClient(transports, strategy) @@ -224,7 +225,7 @@ func TestOptimizerTransportTrackDial(t *testing.T) { Address: "127.0.0.1:1234", Dialer: dialer, } - shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235") + shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235", &logging.Logger{}) transports := []TransportDialer{obfs4Transport, &shadowTransport} strategy := NewTrackStrategy(transports) optimizerTransport := NewOptimizerClient(transports, strategy) @@ -250,7 +251,7 @@ func TestOptimizerTransportMinimizeDialDurationDial(t *testing.T) { Address: "127.0.0.1:1234", Dialer: dialer, } - shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235") + shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235", &logging.Logger{}) transports := []TransportDialer{obfs4Transport, &shadowTransport} strategy := NewMinimizeDialDuration(transports) optimizerTransport := NewOptimizerClient(transports, strategy) diff --git a/transports/Optimizer/v3/go.mod b/transports/Optimizer/v3/go.mod index 8e3cc57..e76bf43 100644 --- a/transports/Optimizer/v3/go.mod +++ b/transports/Optimizer/v3/go.mod @@ -3,9 +3,10 @@ module github.com/OperatorFoundation/shapeshifter-transports/transports/Optimize go 1.12 require ( - github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3 v3.0.4 - github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 v3.0.4 - github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 v3.0.4 - github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 v3.0.4 + github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3 v3.0.6 + github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 v3.0.6 + github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 v3.0.6 + github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 v3.0.6 + github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 golang.org/x/net v0.0.0-20200226121028-0de0cce0169b ) diff --git a/transports/Optimizer/v3/go.sum b/transports/Optimizer/v3/go.sum index b6b7b69..f9258d4 100644 --- a/transports/Optimizer/v3/go.sum +++ b/transports/Optimizer/v3/go.sum @@ -3,28 +3,24 @@ github.com/OperatorFoundation/ed25519 v0.0.0-20200225224545-b22b4bd3ddef h1:1xEt github.com/OperatorFoundation/ed25519 v0.0.0-20200225224545-b22b4bd3ddef/go.mod h1:gQNGvsyT4Zmps9H/yzCqdc+RQzt8ZxCndRNtGTYnBzQ= github.com/OperatorFoundation/obfs4 v1.0.0 h1:OcfdNMzv69fKQrLTkTSwpaBkHyBZMLjigA5M3txZpAg= github.com/OperatorFoundation/obfs4 v1.0.0/go.mod h1:6apgxOLYwyvbpzujpFHWu6Jlc+mjn1aFK7WvNijIVWc= -github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0 h1:zDYt6FDJwDSX4woVFVK2EMt7fkxU5L5qDNLUjQwA+BQ= -github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0/go.mod h1:kB00Ak8Dgn1uZlZHLc/WsUta58Jc+n/ZhCetcPkh42Q= github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0 h1:6aQs+TF3KULMarpzbKu8DhFOF9D2UBCaAN5ZtbK53nQ= github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0/go.mod h1:gb/QiZH0QDXLSQ9PskyJ2oTflB7tsP4AYc8y+FppvB0= -github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3 v3.0.4 h1:G/QFqjBHDI98SXnEubABJEVSEO4I5Mp7Lt1CliaEBlA= -github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3 v3.0.4/go.mod h1:vmd701MBvvskTdbXxJ+opzqHeGSD3k8kC0PhWDKtLWM= -github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 v3.0.4 h1:c73lxT+T92cM42mhgyUtcxyjIB0Fa0hWq6Ti/vZPWu4= -github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 v3.0.4/go.mod h1:Jy0DdH5gfALoQvxLv7J06TdydoZ5fFfeN9jVN/hLMdw= -github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 v3.0.4 h1:3OoYnC43wy0+M4pMaFFUpDx39zJ13fAtraFHLVlsbzc= -github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 v3.0.4/go.mod h1:bAGX3ChJElvQMxEsNdjP+yW3CFcVqdiPWfLg7jipbu8= -github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 v3.0.4 h1:nN9agys5DKv2WLd8KhhO0BO5q76CqnRmuslPtkoOcJQ= -github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 v3.0.4/go.mod h1:UBXOdrFoTJKCq9bd5ae+u95S0YPtH+I70IHbVw+qjnQ= +github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3 v3.0.5 h1:UYwk4CrDS2kwC0BALiRHPHmH84T2aUY7sPO7S+njjtk= +github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3 v3.0.5/go.mod h1:gW1GFU+PS/+snW7IK7gcObExPKCzsvIL1z2g9N/5ubM= +github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 v3.0.5 h1:MdQoHHz+zAHJ37HCJsu6xCtrrA2HMi2uvELlfLzmdAo= +github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 v3.0.5/go.mod h1:i8hkRv+UCu0YbOll8NqoDzDBsRR6XgMa1bykKsTUxTg= +github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 v3.0.5 h1:cJjpLLspo1FqwpFW+TOF83zpMZ4kjT4IV68W1WXqBzY= +github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 v3.0.5/go.mod h1:jdYrSKfsppvvtY/WHSL2mN2FdFNiQ7S/XzQxrty0+2I= +github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 v3.0.5 h1:VhqKDPPYCKTntpnWYgZgL9VACiXCpZZOItLLZW4d/uY= +github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 v3.0.5/go.mod h1:EQS0MxXaaSQO2IoAwVyXsgx7RBWL6Yy+gMiEn2YJRbo= github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da h1:KjTM2ks9d14ZYCvmHS9iAKVt9AyzRSqNU1qabPih5BY= github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da/go.mod h1:eHEWzANqSiWQsof+nXEI9bUVUyV6F53Fp89EuCh2EAA= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dchest/siphash v1.2.1 h1:4cLinnzVJDKxTCl9B01807Yiy+W7ZzVHj/KIroQRvT4= github.com/dchest/siphash v1.2.1/go.mod h1:q+IRvb2gOSrUnYoPqHiyHXS0FOBBOdl6tONBlVnOnt4= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88= +github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/shadowsocks/go-shadowsocks2 v0.0.11 h1:dXloqEhYnZV40jblWTK8kWeC0Eb+dgql4S0tj99e8j0= github.com/shadowsocks/go-shadowsocks2 v0.0.11/go.mod h1:R+KWaoIwRRhnpw6XV+dZil0XHi64Hc1D7hXUyXTjUzQ= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/willscott/goturn v0.0.0-20170802220503-19f41278d0c9/go.mod h1:PfwRjodCaQXOsHnh2DeVaXqCFCIrbn5WLj1+A5bQkD4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d h1:1ZiEyfaQIg3Qh0EoqpwAakHVhecoE5wlSg5GjnafJGw= @@ -37,5 +33,3 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= From 5a4a6a4a3f49ba7643fbda8e872f207c7b0a50e9 Mon Sep 17 00:00:00 2001 From: Bluesaxorcist Date: Mon, 27 Jul 2020 11:05:09 -0500 Subject: [PATCH 17/33] made the licensing more evident --- transports/Dust/v3/Dust.go | 27 +++++++-- transports/Optimizer/v3/LICENSE | 19 +++++++ transports/Optimizer/v3/Optimizer.go | 25 ++++++++- transports/Replicant/v3/LICENSE | 19 +++++++ transports/Replicant/v3/Optimizer.go | 24 ++++++++ transports/Replicant/v3/config.go | 24 ++++++++ transports/Replicant/v3/persistence.go | 24 ++++++++ transports/Replicant/v3/polish/config.go | 24 ++++++++ transports/Replicant/v3/polish/polish.go | 24 ++++++++ transports/Replicant/v3/polish/silver.go | 24 ++++++++ transports/Replicant/v3/pt21.go | 24 ++++++++ transports/Replicant/v3/replicant.go | 25 ++++++++- transports/Replicant/v3/toneburst/config.go | 24 ++++++++ transports/Replicant/v3/toneburst/monotone.go | 24 ++++++++ .../Replicant/v3/toneburst/toneburst.go | 24 ++++++++ .../Replicant/v3/toneburst/whalesong.go | 24 ++++++++ transports/meeklite/v3/LICENSE | 55 +++++++++++++++++++ transports/meekserver/v3/LICENSE | 55 +++++++++++++++++++ transports/meekserver/v3/certificate.go | 27 +++++++++ transports/meekserver/v3/meek-server.go | 27 +++++++++ transports/meekserver/v3/pt21.go | 27 +++++++++ transports/meekserver/v3/useraddr.go | 27 +++++++++ transports/obfs2/v3/LICENSE | 55 +++++++++++++++++++ transports/obfs4/v3/LICENSE | 55 +++++++++++++++++++ transports/obfs4/v3/test_utils.go | 24 ++++++++ transports/shadow/v3/LICENSE | 6 +- 26 files changed, 722 insertions(+), 15 deletions(-) create mode 100644 transports/Optimizer/v3/LICENSE create mode 100644 transports/Replicant/v3/LICENSE create mode 100644 transports/meeklite/v3/LICENSE create mode 100644 transports/meekserver/v3/LICENSE create mode 100644 transports/obfs2/v3/LICENSE create mode 100644 transports/obfs4/v3/LICENSE diff --git a/transports/Dust/v3/Dust.go b/transports/Dust/v3/Dust.go index 1336097..f1686fd 100644 --- a/transports/Dust/v3/Dust.go +++ b/transports/Dust/v3/Dust.go @@ -1,11 +1,28 @@ package Dust /* - * Copyright (c) 2019, Operator Foundation - * - */ - -// Package Dust provides a PT 2.1 Go API wrapper around the Dust transport + MIT License + + Copyright (c) 2020 Operator Foundation + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ import ( "fmt" diff --git a/transports/Optimizer/v3/LICENSE b/transports/Optimizer/v3/LICENSE new file mode 100644 index 0000000..97e8749 --- /dev/null +++ b/transports/Optimizer/v3/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2020 Operator Foundation + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/transports/Optimizer/v3/Optimizer.go b/transports/Optimizer/v3/Optimizer.go index 434abec..f9daefb 100644 --- a/transports/Optimizer/v3/Optimizer.go +++ b/transports/Optimizer/v3/Optimizer.go @@ -1,7 +1,26 @@ /* - * Copyright (c) 2019, Operator Foundation - * - */ + MIT License + + Copyright (c) 2020 Operator Foundation + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ // Package optimizer provides a PT 2.0 Go API wrapper around the connections used package optimizer diff --git a/transports/Replicant/v3/LICENSE b/transports/Replicant/v3/LICENSE new file mode 100644 index 0000000..97e8749 --- /dev/null +++ b/transports/Replicant/v3/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2020 Operator Foundation + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/transports/Replicant/v3/Optimizer.go b/transports/Replicant/v3/Optimizer.go index 7edb522..5fdedc1 100644 --- a/transports/Replicant/v3/Optimizer.go +++ b/transports/Replicant/v3/Optimizer.go @@ -1,3 +1,27 @@ +/* + MIT License + + Copyright (c) 2020 Operator Foundation + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + package replicant import ( diff --git a/transports/Replicant/v3/config.go b/transports/Replicant/v3/config.go index 60282f0..092fba1 100644 --- a/transports/Replicant/v3/config.go +++ b/transports/Replicant/v3/config.go @@ -1,3 +1,27 @@ +/* + MIT License + + Copyright (c) 2020 Operator Foundation + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + package replicant import ( diff --git a/transports/Replicant/v3/persistence.go b/transports/Replicant/v3/persistence.go index ad04b5f..9f87825 100644 --- a/transports/Replicant/v3/persistence.go +++ b/transports/Replicant/v3/persistence.go @@ -1,3 +1,27 @@ +/* + MIT License + + Copyright (c) 2020 Operator Foundation + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + package replicant import ( diff --git a/transports/Replicant/v3/polish/config.go b/transports/Replicant/v3/polish/config.go index 15f3f25..40bd4f6 100644 --- a/transports/Replicant/v3/polish/config.go +++ b/transports/Replicant/v3/polish/config.go @@ -1,3 +1,27 @@ +/* + MIT License + + Copyright (c) 2020 Operator Foundation + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + package polish type ServerConfig interface { diff --git a/transports/Replicant/v3/polish/polish.go b/transports/Replicant/v3/polish/polish.go index afdb7ab..d3abaa7 100644 --- a/transports/Replicant/v3/polish/polish.go +++ b/transports/Replicant/v3/polish/polish.go @@ -1,3 +1,27 @@ +/* + MIT License + + Copyright (c) 2020 Operator Foundation + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + package polish import ( diff --git a/transports/Replicant/v3/polish/silver.go b/transports/Replicant/v3/polish/silver.go index 132dac1..62b300f 100644 --- a/transports/Replicant/v3/polish/silver.go +++ b/transports/Replicant/v3/polish/silver.go @@ -1,3 +1,27 @@ +/* + MIT License + + Copyright (c) 2020 Operator Foundation + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + package polish import ( diff --git a/transports/Replicant/v3/pt21.go b/transports/Replicant/v3/pt21.go index 986ff94..3e98423 100644 --- a/transports/Replicant/v3/pt21.go +++ b/transports/Replicant/v3/pt21.go @@ -1,3 +1,27 @@ +/* + MIT License + + Copyright (c) 2020 Operator Foundation + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + package replicant import ( diff --git a/transports/Replicant/v3/replicant.go b/transports/Replicant/v3/replicant.go index 7ade0e1..bb8c59f 100644 --- a/transports/Replicant/v3/replicant.go +++ b/transports/Replicant/v3/replicant.go @@ -1,7 +1,26 @@ /* - * Copyright (c) 2019, Operator Foundation - * - */ + MIT License + + Copyright (c) 2020 Operator Foundation + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ // Package replicant provides a PT 2.1 Go API implementation of the Replicant adversary-tunable transport package replicant diff --git a/transports/Replicant/v3/toneburst/config.go b/transports/Replicant/v3/toneburst/config.go index 7bb520a..d32e905 100644 --- a/transports/Replicant/v3/toneburst/config.go +++ b/transports/Replicant/v3/toneburst/config.go @@ -1,3 +1,27 @@ +/* + MIT License + + Copyright (c) 2020 Operator Foundation + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + package toneburst type Config interface { diff --git a/transports/Replicant/v3/toneburst/monotone.go b/transports/Replicant/v3/toneburst/monotone.go index 1a2ea7f..5572fcd 100644 --- a/transports/Replicant/v3/toneburst/monotone.go +++ b/transports/Replicant/v3/toneburst/monotone.go @@ -1,3 +1,27 @@ +/* + MIT License + + Copyright (c) 2020 Operator Foundation + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + package toneburst import ( diff --git a/transports/Replicant/v3/toneburst/toneburst.go b/transports/Replicant/v3/toneburst/toneburst.go index a378bf5..345be1f 100644 --- a/transports/Replicant/v3/toneburst/toneburst.go +++ b/transports/Replicant/v3/toneburst/toneburst.go @@ -1,3 +1,27 @@ +/* + MIT License + + Copyright (c) 2020 Operator Foundation + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + package toneburst import ( diff --git a/transports/Replicant/v3/toneburst/whalesong.go b/transports/Replicant/v3/toneburst/whalesong.go index 2cf1dd1..611e4ca 100644 --- a/transports/Replicant/v3/toneburst/whalesong.go +++ b/transports/Replicant/v3/toneburst/whalesong.go @@ -1,3 +1,27 @@ +/* + MIT License + + Copyright (c) 2020 Operator Foundation + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + package toneburst import ( diff --git a/transports/meeklite/v3/LICENSE b/transports/meeklite/v3/LICENSE new file mode 100644 index 0000000..6b89f8c --- /dev/null +++ b/transports/meeklite/v3/LICENSE @@ -0,0 +1,55 @@ +Copyright (c) 2014, Yawning Angel +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +============================================================================== + +Copyright (c) 2012 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + diff --git a/transports/meekserver/v3/LICENSE b/transports/meekserver/v3/LICENSE new file mode 100644 index 0000000..6b89f8c --- /dev/null +++ b/transports/meekserver/v3/LICENSE @@ -0,0 +1,55 @@ +Copyright (c) 2014, Yawning Angel +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +============================================================================== + +Copyright (c) 2012 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + diff --git a/transports/meekserver/v3/certificate.go b/transports/meekserver/v3/certificate.go index 4daccf0..8375137 100644 --- a/transports/meekserver/v3/certificate.go +++ b/transports/meekserver/v3/certificate.go @@ -1,3 +1,30 @@ +/* + * Copyright (c) 2014, Yawning Angel + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + // certificate.go - Certificate management for meek-server. // +build go1.6 diff --git a/transports/meekserver/v3/meek-server.go b/transports/meekserver/v3/meek-server.go index dbd64b0..ddf9a81 100644 --- a/transports/meekserver/v3/meek-server.go +++ b/transports/meekserver/v3/meek-server.go @@ -1,3 +1,30 @@ +/* + * Copyright (c) 2014, Yawning Angel + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + // Package meekserver is the server transport plugin for the meek pluggable transport. // It acts as an HTTP server, keeps track of session ids, and forwards received // data to a local OR port. diff --git a/transports/meekserver/v3/pt21.go b/transports/meekserver/v3/pt21.go index b5f268d..bb3d92d 100644 --- a/transports/meekserver/v3/pt21.go +++ b/transports/meekserver/v3/pt21.go @@ -24,6 +24,33 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ +/* + * Copyright (c) 2014, Yawning Angel + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + // Package meekserver provides an implementation of the Meek circumvention // protocol. Only a client implementation is provided, and no effort is diff --git a/transports/meekserver/v3/useraddr.go b/transports/meekserver/v3/useraddr.go index 599ca6f..a2ff086 100644 --- a/transports/meekserver/v3/useraddr.go +++ b/transports/meekserver/v3/useraddr.go @@ -1,3 +1,30 @@ +/* + * Copyright (c) 2014, Yawning Angel + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + package meekserver import ( diff --git a/transports/obfs2/v3/LICENSE b/transports/obfs2/v3/LICENSE new file mode 100644 index 0000000..6b89f8c --- /dev/null +++ b/transports/obfs2/v3/LICENSE @@ -0,0 +1,55 @@ +Copyright (c) 2014, Yawning Angel +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +============================================================================== + +Copyright (c) 2012 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + diff --git a/transports/obfs4/v3/LICENSE b/transports/obfs4/v3/LICENSE new file mode 100644 index 0000000..6b89f8c --- /dev/null +++ b/transports/obfs4/v3/LICENSE @@ -0,0 +1,55 @@ +Copyright (c) 2014, Yawning Angel +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +============================================================================== + +Copyright (c) 2012 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + diff --git a/transports/obfs4/v3/test_utils.go b/transports/obfs4/v3/test_utils.go index 03adbe4..0c44ae3 100644 --- a/transports/obfs4/v3/test_utils.go +++ b/transports/obfs4/v3/test_utils.go @@ -1,3 +1,27 @@ +/* + MIT License + + Copyright (c) 2020 Operator Foundation + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + package obfs4 import ( diff --git a/transports/shadow/v3/LICENSE b/transports/shadow/v3/LICENSE index dfad7b5..97e8749 100644 --- a/transports/shadow/v3/LICENSE +++ b/transports/shadow/v3/LICENSE @@ -1,5 +1,3 @@ -MIT License - Copyright (c) 2020 Operator Foundation Permission is hereby granted, free of charge, to any person obtaining a copy @@ -14,8 +12,8 @@ copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +SOFTWARE. \ No newline at end of file From d655047e8307bdac020e7dc2a730f646148f7c1a Mon Sep 17 00:00:00 2001 From: Bluesaxorcist Date: Mon, 27 Jul 2020 11:56:47 -0500 Subject: [PATCH 18/33] Update go.sum --- transports/Optimizer/v3/go.sum | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/transports/Optimizer/v3/go.sum b/transports/Optimizer/v3/go.sum index f9258d4..28acf49 100644 --- a/transports/Optimizer/v3/go.sum +++ b/transports/Optimizer/v3/go.sum @@ -5,14 +5,14 @@ github.com/OperatorFoundation/obfs4 v1.0.0 h1:OcfdNMzv69fKQrLTkTSwpaBkHyBZMLjigA github.com/OperatorFoundation/obfs4 v1.0.0/go.mod h1:6apgxOLYwyvbpzujpFHWu6Jlc+mjn1aFK7WvNijIVWc= github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0 h1:6aQs+TF3KULMarpzbKu8DhFOF9D2UBCaAN5ZtbK53nQ= github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0/go.mod h1:gb/QiZH0QDXLSQ9PskyJ2oTflB7tsP4AYc8y+FppvB0= -github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3 v3.0.5 h1:UYwk4CrDS2kwC0BALiRHPHmH84T2aUY7sPO7S+njjtk= -github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3 v3.0.5/go.mod h1:gW1GFU+PS/+snW7IK7gcObExPKCzsvIL1z2g9N/5ubM= -github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 v3.0.5 h1:MdQoHHz+zAHJ37HCJsu6xCtrrA2HMi2uvELlfLzmdAo= -github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 v3.0.5/go.mod h1:i8hkRv+UCu0YbOll8NqoDzDBsRR6XgMa1bykKsTUxTg= -github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 v3.0.5 h1:cJjpLLspo1FqwpFW+TOF83zpMZ4kjT4IV68W1WXqBzY= -github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 v3.0.5/go.mod h1:jdYrSKfsppvvtY/WHSL2mN2FdFNiQ7S/XzQxrty0+2I= -github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 v3.0.5 h1:VhqKDPPYCKTntpnWYgZgL9VACiXCpZZOItLLZW4d/uY= -github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 v3.0.5/go.mod h1:EQS0MxXaaSQO2IoAwVyXsgx7RBWL6Yy+gMiEn2YJRbo= +github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3 v3.0.6 h1:CzFbaRDdcg1xXxIa+N20StrDN8P0hGfoBOv+Idfepn4= +github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3 v3.0.6/go.mod h1:gW1GFU+PS/+snW7IK7gcObExPKCzsvIL1z2g9N/5ubM= +github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 v3.0.6 h1:xmos+1ED0y2UbqtEXGxtcxIqTDGPuw0te5Obqlspj9s= +github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 v3.0.6/go.mod h1:i8hkRv+UCu0YbOll8NqoDzDBsRR6XgMa1bykKsTUxTg= +github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 v3.0.6 h1:/aEcDgGu3VA+gndxMv02LvfbZ6rg0lUYYnPkTlbgaSM= +github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 v3.0.6/go.mod h1:jdYrSKfsppvvtY/WHSL2mN2FdFNiQ7S/XzQxrty0+2I= +github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 v3.0.6 h1:nqdVkCLaotgyabOWXf+sVLrGDQTRt8HqAAT/EZwysLM= +github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 v3.0.6/go.mod h1:EQS0MxXaaSQO2IoAwVyXsgx7RBWL6Yy+gMiEn2YJRbo= github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da h1:KjTM2ks9d14ZYCvmHS9iAKVt9AyzRSqNU1qabPih5BY= github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da/go.mod h1:eHEWzANqSiWQsof+nXEI9bUVUyV6F53Fp89EuCh2EAA= github.com/dchest/siphash v1.2.1 h1:4cLinnzVJDKxTCl9B01807Yiy+W7ZzVHj/KIroQRvT4= From e2d27e1e9edb444fc087715b05404f88ac3721f9 Mon Sep 17 00:00:00 2001 From: Bluesaxorcist Date: Mon, 27 Jul 2020 12:42:36 -0500 Subject: [PATCH 19/33] changed logging to a new liibrary --- ChangeLog | 4 ++-- doc/obfs4proxy.1 | 10 ++++---- transports/Dust/v2/go.sum | 4 ++-- transports/Dust/v3/Dust.go | 11 ++++----- transports/Dust/v3/Dust_test.go | 4 ++-- transports/Dust/v3/go.mod | 1 + transports/Dust/v3/go.sum | 5 ++++ transports/Optimizer/v3/Optimizer_test.go | 16 ++++++------- transports/Optimizer/v3/go.mod | 2 +- transports/Optimizer/v3/go.sum | 4 ++++ transports/Replicant/v3/Optimizer.go | 10 ++++---- transports/Replicant/v3/go.mod | 1 - transports/Replicant/v3/go.sum | 4 ++-- transports/Replicant/v3/replicant_test.go | 6 ++--- transports/meeklite/v3/go.mod | 2 +- transports/meeklite/v3/go.sum | 4 ++-- transports/meeklite/v3/meeklite.go | 6 ++--- transports/meeklite/v3/meeklite_test.go | 4 ++-- transports/meekserver/v2/meek-server.go | 2 +- transports/meekserver/v3/go.mod | 2 +- transports/meekserver/v3/go.sum | 4 ++-- transports/meekserver/v3/meek-server.go | 2 +- transports/meekserver/v3/meekserver_test.go | 4 ++-- transports/meekserver/v3/pt21.go | 6 ++--- transports/obfs2/v2/go.mod | 2 +- transports/obfs2/v2/go.sum | 4 ++-- transports/obfs2/v2/obfs2.go | 12 +++++----- transports/obfs2/v2/obfs2_test.go | 4 ++-- transports/obfs2/v3/go.mod | 2 +- transports/obfs2/v3/go.sum | 4 ++-- transports/obfs2/v3/obfs2.go | 6 ++--- transports/obfs2/v3/obfs2_test.go | 4 ++-- transports/obfs4/v3/go.mod | 2 +- transports/obfs4/v3/go.sum | 6 +++-- transports/obfs4/v3/obfs4.go | 26 +++++++++------------ transports/obfs4/v3/test_utils.go | 20 +++++++--------- transports/shadow/v3/go.mod | 2 +- transports/shadow/v3/go.sum | 8 +++++-- transports/shadow/v3/shadow.go | 8 +++---- transports/shadow/v3/shadow_test.go | 4 ++-- 40 files changed, 118 insertions(+), 114 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8c89813..d10cddf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,7 +10,7 @@ Changes in version 0.0.7 - 2016-11-15: reduce memory consumption. Patch by oxtoacart. Changes in version 0.0.6 - 2016-01-25: - - Delay transport factory initialization till after logging has been + - Delay transport factory initialization till after golog has been initialized. - Add a meek client implementation (WARNING: Does not support using a helper to normalize TLS signatures). The brave people that want to use @@ -22,7 +22,7 @@ Changes in version 0.0.5 - 2015-04-15: - Changed the go.net import path to the new location (golang.org/x/net). - Added limited support for detecting if the parent process crashes. - Support for tor feature #15335 (stdin based termination notification). - - Moved the leveled logging wrappers into common/log so they are usable + - Moved the leveled golog wrappers into common/log so they are usable in transport implementations. - Added a DEBUG log level. - Use a bundled SOCKS 5 server instead of goptlib's SocksListener. diff --git a/doc/obfs4proxy.1 b/doc/obfs4proxy.1 index 13b89fd..17c640a 100644 --- a/doc/obfs4proxy.1 +++ b/doc/obfs4proxy.1 @@ -24,15 +24,15 @@ Display usage information and exit. \fB\-\-version\fR Display version information and exit. .TP -\fB\-\-enableLogging\fR -Enable logging. +\fB\-\-enablegolog\fR +Enable golog. .TP \fB\-\-logLevel\fR=\fIlevel\fR Specify the maximum log severity to log out of "\fBERROR\fR", "\fBWARN\fR", "\fBINFO\fR", and "\fBDEBUG\fR". .TP -\fB\-\-unsafeLogging\fR -Disable the IP address scrubber when logging, storing personally identifiable +\fB\-\-unsafegolog\fR +Disable the IP address scrubber when golog, storing personally identifiable information in the logs. .TP \fB\-\-obfs4\-distBias\fR @@ -45,7 +45,7 @@ Pluggable Transport Specification. .PP \fIDataDirectory\fR\fB/pt_state/obfs4proxy.log\fR .RS 4 -The log file, assuming logging is enabled. +The log file, assuming golog is enabled. .RE .PP \fIDataDirectory\fR\fB/pt_state/obfs4_state.json\fR diff --git a/transports/Dust/v2/go.sum b/transports/Dust/v2/go.sum index 609dff0..3284541 100644 --- a/transports/Dust/v2/go.sum +++ b/transports/Dust/v2/go.sum @@ -11,8 +11,8 @@ github.com/blanu/Dust v1.0.1/go.mod h1:jLFQI2Ufz4kBnGiTzh8O9+/p4U/9MLbouXkaympnT github.com/blanu/Dust/go/v2/interface v1.0.1 h1:lIQrNXljx8vgTTwB+gObrkA6jBhokmgH/uHp1OxbqxE= github.com/blanu/Dust/go/v2/interface v1.0.1/go.mod h1:0NnpBd5fkRrG2I/pf6bcUaL5jpp84LeShsQzn4gCOCw= github.com/dchest/siphash v1.2.1/go.mod h1:q+IRvb2gOSrUnYoPqHiyHXS0FOBBOdl6tONBlVnOnt4= -github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88= -github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= + h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88= +/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/willscott/goturn v0.0.0-20170802220503-19f41278d0c9/go.mod h1:PfwRjodCaQXOsHnh2DeVaXqCFCIrbn5WLj1+A5bQkD4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= diff --git a/transports/Dust/v3/Dust.go b/transports/Dust/v3/Dust.go index f1686fd..8e369d5 100644 --- a/transports/Dust/v3/Dust.go +++ b/transports/Dust/v3/Dust.go @@ -26,10 +26,7 @@ package Dust import ( "fmt" - "github.com/OperatorFoundation/obfs4/common/log" - - //"github.com/OperatorFoundation/obfs4/common/log" - "github.com/op/go-logging" + "github.com/kataras/golog" "golang.org/x/net/proxy" "net" "time" @@ -71,14 +68,14 @@ type Transport struct { Address string Dialer proxy.Dialer ServerConfig *dustServer - Log *logging.Logger + Log *golog.Logger } type Config struct { ServerPublic string `json:"server-public"` } -func New(serverPublic string, address string, dialer proxy.Dialer, serverConfig *dustServer, log *logging.Logger) Transport { +func New(serverPublic string, address string, dialer proxy.Dialer, serverConfig *dustServer, log *golog.Logger) Transport { return Transport{ ServerPublic: serverPublic, Address: address, @@ -130,7 +127,7 @@ func (transport *dustClient) Dial(address string) (net.Conn, error) { if err != nil { closeErr := conn.Close() if closeErr != nil { - log.Errorf("could not close") + golog.Error("could not close") } return conn, dialErr } diff --git a/transports/Dust/v3/Dust_test.go b/transports/Dust/v3/Dust_test.go index 3068e09..ec86131 100644 --- a/transports/Dust/v3/Dust_test.go +++ b/transports/Dust/v3/Dust_test.go @@ -9,7 +9,7 @@ package Dust import ( - "github.com/op/go-logging" + "github.com/kataras/golog" "golang.org/x/net/proxy" "testing" ) @@ -87,7 +87,7 @@ func TestDust(t *testing.T) { func TestDustV3(t *testing.T) { //create a server - var log = logging.MustGetLogger("dust") + var log = golog.MustGetLogger("dust") serverConfig := dustServer{ serverPrivkey: nil, dialer: nil, diff --git a/transports/Dust/v3/go.mod b/transports/Dust/v3/go.mod index e6761dc..b3c6090 100644 --- a/transports/Dust/v3/go.mod +++ b/transports/Dust/v3/go.mod @@ -7,5 +7,6 @@ require ( github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0 github.com/blanu/Dust v1.0.1 // indirect github.com/blanu/Dust/go/v2/interface v1.0.1 + github.com/kataras/golog v0.0.18 golang.org/x/net v0.0.0-20200226121028-0de0cce0169b ) diff --git a/transports/Dust/v3/go.sum b/transports/Dust/v3/go.sum index dd89648..799dbcf 100644 --- a/transports/Dust/v3/go.sum +++ b/transports/Dust/v3/go.sum @@ -11,6 +11,10 @@ github.com/blanu/Dust v1.0.1/go.mod h1:jLFQI2Ufz4kBnGiTzh8O9+/p4U/9MLbouXkaympnT github.com/blanu/Dust/go/v2/interface v1.0.1 h1:lIQrNXljx8vgTTwB+gObrkA6jBhokmgH/uHp1OxbqxE= github.com/blanu/Dust/go/v2/interface v1.0.1/go.mod h1:0NnpBd5fkRrG2I/pf6bcUaL5jpp84LeShsQzn4gCOCw= github.com/dchest/siphash v1.2.1/go.mod h1:q+IRvb2gOSrUnYoPqHiyHXS0FOBBOdl6tONBlVnOnt4= +github.com/kataras/golog v0.0.18 h1:Td7hcKN25yzqB/0SO5iohOsMk5Mq5V9kDtM5apaJLY0= +github.com/kataras/golog v0.0.18/go.mod h1:jRYl7dFYqP8aQj9VkwdBUXYZSfUktm+YYg1arJILfyw= +github.com/kataras/pio v0.0.8 h1:6pX6nHJk7DAV3x1dEimibQF2CmJLlo0jWVmM9yE9KY8= +github.com/kataras/pio v0.0.8/go.mod h1:NFfMp2kVP1rmV4N6gH6qgWpuoDKlrOeYi3VrAIWCGsE= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/willscott/goturn v0.0.0-20170802220503-19f41278d0c9/go.mod h1:PfwRjodCaQXOsHnh2DeVaXqCFCIrbn5WLj1+A5bQkD4= @@ -22,5 +26,6 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20200226121028-0de0cce0169b h1:0mm1VjtFUOIlE1SbDlwjYaDxZVDP2S5ou6y0gSgXHu8= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/transports/Optimizer/v3/Optimizer_test.go b/transports/Optimizer/v3/Optimizer_test.go index c9afc04..bd6dfc0 100644 --- a/transports/Optimizer/v3/Optimizer_test.go +++ b/transports/Optimizer/v3/Optimizer_test.go @@ -5,7 +5,7 @@ import ( "github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3" "github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3" "github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3" - "github.com/op/go-logging" + "github.com/kataras/golog" "golang.org/x/net/proxy" "io/ioutil" "net" @@ -82,7 +82,7 @@ func TestShadowDial(t *testing.T) { } func TestOptimizerShadowDial(t *testing.T) { - shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235", &logging.Logger{}) + shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235", &golog.Logger{}) transports := []TransportDialer{&shadowTransport} strategy := NewFirstStrategy(transports) optimizerTransport := NewOptimizerClient(transports, strategy) @@ -93,7 +93,7 @@ func TestOptimizerShadowDial(t *testing.T) { } func TestOptimizerObfs2Dial(t *testing.T) { - obfs2Transport := obfs2.New("127.0.0.1:1237", proxy.Direct, &logging.Logger{}) + obfs2Transport := obfs2.New("127.0.0.1:1237", proxy.Direct, &golog.Logger{}) transports := []TransportDialer{obfs2Transport} strategy := NewFirstStrategy(transports) optimizerTransport := NewOptimizerClient(transports, strategy) @@ -148,7 +148,7 @@ func TestOptimizerTransportFirstDial(t *testing.T) { IatMode: 0, Address: "127.0.0.1:1234", Dialer: dialer} - shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235", &logging.Logger{}) + shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235", &golog.Logger{}) transports := []TransportDialer{obfs4Transport, &shadowTransport} strategy := NewFirstStrategy(transports) optimizerTransport := NewOptimizerClient(transports, strategy) @@ -173,7 +173,7 @@ func TestOptimizerTransportRandomDial(t *testing.T) { Address: "127.0.0.1:1234", Dialer: dialer, } - shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235", &logging.Logger{}) + shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235", &golog.Logger{}) transports := []TransportDialer{obfs4Transport, &shadowTransport} strategy := NewRandomStrategy(transports) optimizerTransport := NewOptimizerClient(transports, strategy) @@ -199,7 +199,7 @@ func TestOptimizerTransportRotateDial(t *testing.T) { Address: "127.0.0.1:1234", Dialer: dialer, } - shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235", &logging.Logger{}) + shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235", &golog.Logger{}) transports := []TransportDialer{obfs4Transport, &shadowTransport} strategy := NewRotateStrategy(transports) optimizerTransport := NewOptimizerClient(transports, strategy) @@ -225,7 +225,7 @@ func TestOptimizerTransportTrackDial(t *testing.T) { Address: "127.0.0.1:1234", Dialer: dialer, } - shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235", &logging.Logger{}) + shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235", &golog.Logger{}) transports := []TransportDialer{obfs4Transport, &shadowTransport} strategy := NewTrackStrategy(transports) optimizerTransport := NewOptimizerClient(transports, strategy) @@ -251,7 +251,7 @@ func TestOptimizerTransportMinimizeDialDurationDial(t *testing.T) { Address: "127.0.0.1:1234", Dialer: dialer, } - shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235", &logging.Logger{}) + shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235", &golog.Logger{}) transports := []TransportDialer{obfs4Transport, &shadowTransport} strategy := NewMinimizeDialDuration(transports) optimizerTransport := NewOptimizerClient(transports, strategy) diff --git a/transports/Optimizer/v3/go.mod b/transports/Optimizer/v3/go.mod index e76bf43..25eb265 100644 --- a/transports/Optimizer/v3/go.mod +++ b/transports/Optimizer/v3/go.mod @@ -7,6 +7,6 @@ require ( github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 v3.0.6 github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 v3.0.6 github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 v3.0.6 - github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 + github.com/kataras/golog v0.0.18 golang.org/x/net v0.0.0-20200226121028-0de0cce0169b ) diff --git a/transports/Optimizer/v3/go.sum b/transports/Optimizer/v3/go.sum index 28acf49..f1e1d12 100644 --- a/transports/Optimizer/v3/go.sum +++ b/transports/Optimizer/v3/go.sum @@ -17,6 +17,10 @@ github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da h1:KjTM2ks9d14ZYCvmH github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da/go.mod h1:eHEWzANqSiWQsof+nXEI9bUVUyV6F53Fp89EuCh2EAA= github.com/dchest/siphash v1.2.1 h1:4cLinnzVJDKxTCl9B01807Yiy+W7ZzVHj/KIroQRvT4= github.com/dchest/siphash v1.2.1/go.mod h1:q+IRvb2gOSrUnYoPqHiyHXS0FOBBOdl6tONBlVnOnt4= +github.com/kataras/golog v0.0.18 h1:Td7hcKN25yzqB/0SO5iohOsMk5Mq5V9kDtM5apaJLY0= +github.com/kataras/golog v0.0.18/go.mod h1:jRYl7dFYqP8aQj9VkwdBUXYZSfUktm+YYg1arJILfyw= +github.com/kataras/pio v0.0.8 h1:6pX6nHJk7DAV3x1dEimibQF2CmJLlo0jWVmM9yE9KY8= +github.com/kataras/pio v0.0.8/go.mod h1:NFfMp2kVP1rmV4N6gH6qgWpuoDKlrOeYi3VrAIWCGsE= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/shadowsocks/go-shadowsocks2 v0.0.11 h1:dXloqEhYnZV40jblWTK8kWeC0Eb+dgql4S0tj99e8j0= diff --git a/transports/Replicant/v3/Optimizer.go b/transports/Replicant/v3/Optimizer.go index 5fdedc1..c7e28b7 100644 --- a/transports/Replicant/v3/Optimizer.go +++ b/transports/Replicant/v3/Optimizer.go @@ -26,7 +26,7 @@ package replicant import ( pt "github.com/OperatorFoundation/shapeshifter-ipc/v2" - "github.com/op/go-logging" + "github.com/kataras/golog" "golang.org/x/net/proxy" "net" ) @@ -36,17 +36,17 @@ type TransportClient struct { Config ClientConfig Address string Dialer proxy.Dialer - Log *logging.Logger + Log *golog.Logger } type TransportServer struct { Config ServerConfig Address string Dialer proxy.Dialer - Log *logging.Logger + Log *golog.Logger } -func NewClient(config ClientConfig, address string, dialer proxy.Dialer, log *logging.Logger) TransportClient { +func NewClient(config ClientConfig, address string, dialer proxy.Dialer, log *golog.Logger) TransportClient { return TransportClient{ Config: config, Address: address, @@ -55,7 +55,7 @@ func NewClient(config ClientConfig, address string, dialer proxy.Dialer, log *lo } } -func NewServer(config ServerConfig, address string, dialer proxy.Dialer, log *logging.Logger) TransportServer { +func NewServer(config ServerConfig, address string, dialer proxy.Dialer, log *golog.Logger) TransportServer { return TransportServer{ Config: config, Address: address, diff --git a/transports/Replicant/v3/go.mod b/transports/Replicant/v3/go.mod index 48fdc06..2d0d408 100644 --- a/transports/Replicant/v3/go.mod +++ b/transports/Replicant/v3/go.mod @@ -5,7 +5,6 @@ go 1.12 require ( github.com/OperatorFoundation/monolith-go/monolith v1.0.4 github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0 - github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 github.com/opentracing/opentracing-go v1.1.0 golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 golang.org/x/net v0.0.0-20200202094626-16171245cfb2 diff --git a/transports/Replicant/v3/go.sum b/transports/Replicant/v3/go.sum index 3d39d37..3382e0b 100644 --- a/transports/Replicant/v3/go.sum +++ b/transports/Replicant/v3/go.sum @@ -4,8 +4,8 @@ github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0 h1:6aQs+TF3KULMarpzbKu8 github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0/go.mod h1:gb/QiZH0QDXLSQ9PskyJ2oTflB7tsP4AYc8y+FppvB0= github.com/deckarep/golang-set v1.7.1 h1:SCQV0S6gTtp6itiFrTqI+pfmJ4LN85S1YzhDf9rTHJQ= github.com/deckarep/golang-set v1.7.1/go.mod h1:93vsz/8Wt4joVM7c2AVqh+YRMiUSc14yDtF28KmMOgQ= -github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88= -github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= + h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88= +/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/opentracing/opentracing-go v1.1.0 h1:pWlfV3Bxv7k65HYwkikxat0+s3pV4bsqf19k25Ur8rU= github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= diff --git a/transports/Replicant/v3/replicant_test.go b/transports/Replicant/v3/replicant_test.go index e1b05ae..fa89943 100644 --- a/transports/Replicant/v3/replicant_test.go +++ b/transports/Replicant/v3/replicant_test.go @@ -5,7 +5,7 @@ import ( "github.com/OperatorFoundation/monolith-go/monolith" "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v3/polish" "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v3/toneburst" - "github.com/op/go-logging" + "github.com/kataras/golog" "golang.org/x/net/proxy" "io/ioutil" "math/rand" @@ -184,7 +184,7 @@ func runReplicantServer() { } func runReplicantFactoryServer() { - var log = logging.MustGetLogger("replicant") + var log = golog.MustGetLogger("replicant") serverStarted := make(chan bool) addr := "127.0.0.1:3001" @@ -304,7 +304,7 @@ func replicantConnection(clientConfig ClientConfig, serverConfig ServerConfig, t func replicantFactoryConnection(clientConfig ClientConfig, serverConfig ServerConfig, t *testing.T) { serverStarted := make(chan bool) - var log = logging.MustGetLogger("replicant") + var log = golog.MustGetLogger("replicant") // Get a random port rand.Seed(time.Now().UnixNano()) min := 1025 diff --git a/transports/meeklite/v3/go.mod b/transports/meeklite/v3/go.mod index e7e77d9..8d9bbeb 100644 --- a/transports/meeklite/v3/go.mod +++ b/transports/meeklite/v3/go.mod @@ -3,6 +3,6 @@ module github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite go 1.12 require ( - github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 + golang.org/x/net v0.0.0-20200202094626-16171245cfb2 ) diff --git a/transports/meeklite/v3/go.sum b/transports/meeklite/v3/go.sum index 6ca77db..3fcd773 100644 --- a/transports/meeklite/v3/go.sum +++ b/transports/meeklite/v3/go.sum @@ -1,5 +1,5 @@ -github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88= -github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= + h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88= +/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/net v0.0.0-20200202094626-16171245cfb2 h1:CCH4IOTTfewWjGOlSp+zGcjutRKlBEZQ6wTn8ozI/nI= golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= diff --git a/transports/meeklite/v3/meeklite.go b/transports/meeklite/v3/meeklite.go index 1ba28f6..7281ed8 100644 --- a/transports/meeklite/v3/meeklite.go +++ b/transports/meeklite/v3/meeklite.go @@ -39,7 +39,7 @@ import ( "encoding/hex" "errors" "fmt" - "github.com/op/go-logging" + "github.com/kataras/golog" "golang.org/x/net/proxy" "io" "io/ioutil" @@ -128,7 +128,7 @@ type Transport struct { Front string `json:"front"` Address string Dialer proxy.Dialer - log *logging.Logger + log *golog.Logger } //Config puts the parameters in a json compatible format @@ -137,7 +137,7 @@ type Config struct { Front string `json:"front"` } -func NewMeekFactoryTransportWithFront(url *gourl.URL, front string, address string, dialer proxy.Dialer, log *logging.Logger) *Transport { +func NewMeekFactoryTransportWithFront(url *gourl.URL, front string, address string, dialer proxy.Dialer, log *golog.Logger) *Transport { return &Transport{url, front, address,dialer, log} } // Dial creates outgoing transport connection diff --git a/transports/meeklite/v3/meeklite_test.go b/transports/meeklite/v3/meeklite_test.go index 6dd9475..5aa6c80 100644 --- a/transports/meeklite/v3/meeklite_test.go +++ b/transports/meeklite/v3/meeklite_test.go @@ -34,7 +34,7 @@ package meeklite import ( - "github.com/op/go-logging" + "github.com/kataras/golog" "golang.org/x/net/proxy" gourl "net/url" "testing" @@ -79,7 +79,7 @@ func TestMeeklite(t *testing.T) { } func TestFactoryMeeklite(t *testing.T) { - var log = logging.MustGetLogger("meeklite") + var log = golog.MustGetLogger("meeklite") //create a server urlString := "https://transport-canary-meek.appspot.com/" Url, err := gourl.Parse(urlString) diff --git a/transports/meekserver/v2/meek-server.go b/transports/meekserver/v2/meek-server.go index dbd64b0..c4035f1 100644 --- a/transports/meekserver/v2/meek-server.go +++ b/transports/meekserver/v2/meek-server.go @@ -162,7 +162,7 @@ func (a scrubbedAddr) String() string { return "[scrubbed]" } -// Replace the Addr in a net.OpError with "[scrubbed]" for logging. +// Replace the Addr in a net.OpError with "[scrubbed]" for golog. func scrubError(err error) error { if operr, ok := err.(*net.OpError); ok { // net.OpError contains Op, Net, Addr, and a subsidiary Err. The diff --git a/transports/meekserver/v3/go.mod b/transports/meekserver/v3/go.mod index 9cae6a7..0108cfd 100644 --- a/transports/meekserver/v3/go.mod +++ b/transports/meekserver/v3/go.mod @@ -5,7 +5,7 @@ go 1.12 require ( github.com/deckarep/golang-set v1.7.1 github.com/mufti1/interconv v0.0.0-20190313040840-d7c72925c656 - github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 + golang.org/x/crypto v0.0.0-20200214034016-1d94cc7ab1c6 golang.org/x/net v0.0.0-20200202094626-16171245cfb2 ) diff --git a/transports/meekserver/v3/go.sum b/transports/meekserver/v3/go.sum index cbdb217..569ab80 100644 --- a/transports/meekserver/v3/go.sum +++ b/transports/meekserver/v3/go.sum @@ -2,8 +2,8 @@ github.com/deckarep/golang-set v1.7.1 h1:SCQV0S6gTtp6itiFrTqI+pfmJ4LN85S1YzhDf9r github.com/deckarep/golang-set v1.7.1/go.mod h1:93vsz/8Wt4joVM7c2AVqh+YRMiUSc14yDtF28KmMOgQ= github.com/mufti1/interconv v0.0.0-20190313040840-d7c72925c656 h1:p+IdebEeB9SAEH9IOJVF6oZ535bwvWqUdqWxG1UWeko= github.com/mufti1/interconv v0.0.0-20190313040840-d7c72925c656/go.mod h1:+db4NNs1NvceiftEzz0ymfu3zKLkynYukafc7llNoMs= -github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88= -github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= + h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88= +/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20200214034016-1d94cc7ab1c6 h1:Sy5bstxEqwwbYs6n0/pBuxKENqOeZUgD45Gp3Q3pqLg= golang.org/x/crypto v0.0.0-20200214034016-1d94cc7ab1c6/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= diff --git a/transports/meekserver/v3/meek-server.go b/transports/meekserver/v3/meek-server.go index ddf9a81..4bbb1b8 100644 --- a/transports/meekserver/v3/meek-server.go +++ b/transports/meekserver/v3/meek-server.go @@ -189,7 +189,7 @@ func (a scrubbedAddr) String() string { return "[scrubbed]" } -// Replace the Addr in a net.OpError with "[scrubbed]" for logging. +// Replace the Addr in a net.OpError with "[scrubbed]" for golog. func scrubError(err error) error { if operr, ok := err.(*net.OpError); ok { // net.OpError contains Op, Net, Addr, and a subsidiary Err. The diff --git a/transports/meekserver/v3/meekserver_test.go b/transports/meekserver/v3/meekserver_test.go index fe4c8a9..305cc7f 100644 --- a/transports/meekserver/v3/meekserver_test.go +++ b/transports/meekserver/v3/meekserver_test.go @@ -1,7 +1,7 @@ package meekserver import ( - "github.com/op/go-logging" + "github.com/kataras/golog" "testing" ) @@ -29,7 +29,7 @@ func TestMeekServerListen(t *testing.T) { } func TestMeekServerFactoryListen(t *testing.T) { - var log = logging.MustGetLogger("meekserver") + var log = golog.MustGetLogger("meekserver") acmeEmail := "brandon@operatorfoundation.org" acmeHostNames := "operatorrss.com" meekserverTransport, newError := New(false, acmeHostNames, acmeEmail,"127.0.0.1:8080", "state", log) diff --git a/transports/meekserver/v3/pt21.go b/transports/meekserver/v3/pt21.go index bb3d92d..290ef1c 100644 --- a/transports/meekserver/v3/pt21.go +++ b/transports/meekserver/v3/pt21.go @@ -62,7 +62,7 @@ package meekserver import ( "errors" interconv "github.com/mufti1/interconv/package" - "github.com/op/go-logging" + "github.com/kataras/golog" "golang.org/x/crypto/acme/autocert" "log" "net" @@ -83,7 +83,7 @@ type Transport struct { DisableTLS bool CertManager *autocert.Manager Address string - log *logging.Logger + log *golog.Logger } //Config contains arguments formatted for a json file @@ -108,7 +108,7 @@ type fakeConn struct { writeBuffer []byte } -func New(disableTLS bool, acmeHostnamesCommas string, acmeEmail string, address string, stateDir string, Log *logging.Logger) (*Transport, error) { +func New(disableTLS bool, acmeHostnamesCommas string, acmeEmail string, address string, stateDir string, Log *golog.Logger) (*Transport, error) { var certManager *autocert.Manager if disableTLS { if acmeEmail != "" || acmeHostnamesCommas != "" { diff --git a/transports/obfs2/v2/go.mod b/transports/obfs2/v2/go.mod index e15edaa..c6fcae7 100644 --- a/transports/obfs2/v2/go.mod +++ b/transports/obfs2/v2/go.mod @@ -5,6 +5,6 @@ go 1.12 require ( github.com/OperatorFoundation/obfs4 v1.0.0 github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0 - github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 + golang.org/x/net v0.0.0-20200226121028-0de0cce0169b ) diff --git a/transports/obfs2/v2/go.sum b/transports/obfs2/v2/go.sum index 7a5e130..facf2e0 100644 --- a/transports/obfs2/v2/go.sum +++ b/transports/obfs2/v2/go.sum @@ -7,8 +7,8 @@ github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0/go.mod h1:kB00Ak8Dgn1uZlZHLc/WsUta58Jc+n/ZhCetcPkh42Q= github.com/dchest/siphash v1.2.1 h1:4cLinnzVJDKxTCl9B01807Yiy+W7ZzVHj/KIroQRvT4= github.com/dchest/siphash v1.2.1/go.mod h1:q+IRvb2gOSrUnYoPqHiyHXS0FOBBOdl6tONBlVnOnt4= -github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88= -github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= + h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88= +/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/willscott/goturn v0.0.0-20170802220503-19f41278d0c9/go.mod h1:PfwRjodCaQXOsHnh2DeVaXqCFCIrbn5WLj1+A5bQkD4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= diff --git a/transports/obfs2/v2/obfs2.go b/transports/obfs2/v2/obfs2.go index 3f869fa..b3f9a23 100644 --- a/transports/obfs2/v2/obfs2.go +++ b/transports/obfs2/v2/obfs2.go @@ -36,7 +36,7 @@ import ( "crypto/sha256" "encoding/binary" "fmt" - "github.com/op/go-logging" + "github.com/kataras/golog" "io" "net" "time" @@ -66,7 +66,7 @@ const ( type OptimizerTransport struct { Address string Dialer proxy.Dialer - Log *logging.Logger + Log *golog.Logger } //Dial connects to a specified address. @@ -92,11 +92,11 @@ func (transport OptimizerTransport) Dial() (net.Conn, error) { // Transport is the obfs2 implementation of the base.Transport interface. type Transport struct { dialer proxy.Dialer - log logging.Logger + log golog.Logger } //New initializes obfs2 for Optimizer -func New(address string, dialer proxy.Dialer, log *logging.Logger) *OptimizerTransport { +func New(address string, dialer proxy.Dialer, log *golog.Logger) *OptimizerTransport { result := OptimizerTransport{ Address: address, Dialer: dialer, @@ -107,12 +107,12 @@ func New(address string, dialer proxy.Dialer, log *logging.Logger) *OptimizerTra //NewObfs2Transport is the initializer for obfs2 without a dialer func NewObfs2Transport() *Transport { - return &Transport{dialer: nil, log: logging.Logger{}} + return &Transport{dialer: nil, log: golog.Logger{}} } //NewObfs2Transport is the initializer for obfs2 with a dialer func NewObfs2TransportWithDialer(dialer proxy.Dialer) *Transport { - return &Transport{dialer: dialer, log: logging.Logger{}} + return &Transport{dialer: dialer, log: golog.Logger{}} } //obfs2TransportListener defines a TCP network listener. diff --git a/transports/obfs2/v2/obfs2_test.go b/transports/obfs2/v2/obfs2_test.go index da1ef56..5205992 100644 --- a/transports/obfs2/v2/obfs2_test.go +++ b/transports/obfs2/v2/obfs2_test.go @@ -32,7 +32,7 @@ package obfs2 import ( - "github.com/op/go-logging" + "github.com/kataras/golog" "golang.org/x/net/proxy" "os" "testing" @@ -98,7 +98,7 @@ func TestObfs2WithDialer(t *testing.T) { } func TestObfs2OptimizerTransportWithDialer(t *testing.T) { - var log = logging.MustGetLogger("obfs2") + var log = golog.MustGetLogger("obfs2") config := New("127.0.0.1:1237", proxy.Direct, log) //create client buffer clientBuffer := make([]byte, 4) diff --git a/transports/obfs2/v3/go.mod b/transports/obfs2/v3/go.mod index b2fa78f..4205bdf 100644 --- a/transports/obfs2/v3/go.mod +++ b/transports/obfs2/v3/go.mod @@ -5,6 +5,6 @@ go 1.12 require ( github.com/OperatorFoundation/obfs4 v1.0.0 github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0 - github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 + golang.org/x/net v0.0.0-20200226121028-0de0cce0169b ) diff --git a/transports/obfs2/v3/go.sum b/transports/obfs2/v3/go.sum index 139977a..c080a26 100644 --- a/transports/obfs2/v3/go.sum +++ b/transports/obfs2/v3/go.sum @@ -7,8 +7,8 @@ github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0 h1:6aQs+TF3KULMarpzbKu8 github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0/go.mod h1:gb/QiZH0QDXLSQ9PskyJ2oTflB7tsP4AYc8y+FppvB0= github.com/dchest/siphash v1.2.1 h1:4cLinnzVJDKxTCl9B01807Yiy+W7ZzVHj/KIroQRvT4= github.com/dchest/siphash v1.2.1/go.mod h1:q+IRvb2gOSrUnYoPqHiyHXS0FOBBOdl6tONBlVnOnt4= -github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88= -github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= + h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88= +/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/willscott/goturn v0.0.0-20170802220503-19f41278d0c9/go.mod h1:PfwRjodCaQXOsHnh2DeVaXqCFCIrbn5WLj1+A5bQkD4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= diff --git a/transports/obfs2/v3/obfs2.go b/transports/obfs2/v3/obfs2.go index 36b8b0e..6412ceb 100644 --- a/transports/obfs2/v3/obfs2.go +++ b/transports/obfs2/v3/obfs2.go @@ -36,7 +36,7 @@ import ( "crypto/sha256" "encoding/binary" "fmt" - "github.com/op/go-logging" + "github.com/kataras/golog" "io" "net" @@ -67,7 +67,7 @@ const ( type OptimizerTransport struct { Address string Dialer proxy.Dialer - log *logging.Logger + log *golog.Logger } //Dial connects to a specified address. @@ -112,7 +112,7 @@ type Transport struct { } //New initializes obfs2 for Optimizer -func New(address string, dialer proxy.Dialer, log *logging.Logger) *OptimizerTransport { +func New(address string, dialer proxy.Dialer, log *golog.Logger) *OptimizerTransport { result := OptimizerTransport{ Address: address, Dialer: dialer, diff --git a/transports/obfs2/v3/obfs2_test.go b/transports/obfs2/v3/obfs2_test.go index 5145a45..e855778 100644 --- a/transports/obfs2/v3/obfs2_test.go +++ b/transports/obfs2/v3/obfs2_test.go @@ -32,7 +32,7 @@ package obfs2 import ( - "github.com/op/go-logging" + "github.com/kataras/golog" "golang.org/x/net/proxy" "os" "testing" @@ -98,7 +98,7 @@ func TestObfs2WithDialer(t *testing.T) { } func TestObfs2OptimizerTransportWithDialer(t *testing.T) { - var log = logging.MustGetLogger("obfs2") + var log = golog.MustGetLogger("obfs2") config := New("127.0.0.1:1237", proxy.Direct, log) //create client buffer clientBuffer := make([]byte, 4) diff --git a/transports/obfs4/v3/go.mod b/transports/obfs4/v3/go.mod index 9ecef17..12d8731 100644 --- a/transports/obfs4/v3/go.mod +++ b/transports/obfs4/v3/go.mod @@ -5,7 +5,7 @@ go 1.12 require ( github.com/OperatorFoundation/obfs4 v1.0.0 github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0 - github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 + github.com/kataras/golog v0.0.18 golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d golang.org/x/net v0.0.0-20200226121028-0de0cce0169b ) diff --git a/transports/obfs4/v3/go.sum b/transports/obfs4/v3/go.sum index b996e03..f1673f2 100644 --- a/transports/obfs4/v3/go.sum +++ b/transports/obfs4/v3/go.sum @@ -7,8 +7,10 @@ github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0 h1:6aQs+TF3KULMarpzbKu8 github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0/go.mod h1:gb/QiZH0QDXLSQ9PskyJ2oTflB7tsP4AYc8y+FppvB0= github.com/dchest/siphash v1.2.1 h1:4cLinnzVJDKxTCl9B01807Yiy+W7ZzVHj/KIroQRvT4= github.com/dchest/siphash v1.2.1/go.mod h1:q+IRvb2gOSrUnYoPqHiyHXS0FOBBOdl6tONBlVnOnt4= -github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88= -github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= +github.com/kataras/golog v0.0.18 h1:Td7hcKN25yzqB/0SO5iohOsMk5Mq5V9kDtM5apaJLY0= +github.com/kataras/golog v0.0.18/go.mod h1:jRYl7dFYqP8aQj9VkwdBUXYZSfUktm+YYg1arJILfyw= +github.com/kataras/pio v0.0.8 h1:6pX6nHJk7DAV3x1dEimibQF2CmJLlo0jWVmM9yE9KY8= +github.com/kataras/pio v0.0.8/go.mod h1:NFfMp2kVP1rmV4N6gH6qgWpuoDKlrOeYi3VrAIWCGsE= github.com/willscott/goturn v0.0.0-20170802220503-19f41278d0c9/go.mod h1:PfwRjodCaQXOsHnh2DeVaXqCFCIrbn5WLj1+A5bQkD4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d h1:1ZiEyfaQIg3Qh0EoqpwAakHVhecoE5wlSg5GjnafJGw= diff --git a/transports/obfs4/v3/obfs4.go b/transports/obfs4/v3/obfs4.go index b43bb51..bf615a6 100644 --- a/transports/obfs4/v3/obfs4.go +++ b/transports/obfs4/v3/obfs4.go @@ -35,13 +35,12 @@ import ( "flag" "fmt" "github.com/OperatorFoundation/obfs4/common/drbg" - common"github.com/OperatorFoundation/obfs4/common/log" "github.com/OperatorFoundation/obfs4/common/ntor" "github.com/OperatorFoundation/obfs4/common/probdist" "github.com/OperatorFoundation/obfs4/common/replayfilter" "github.com/OperatorFoundation/shapeshifter-ipc/v2" "github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3/framing" - "github.com/op/go-logging" + "github.com/kataras/golog" "golang.org/x/net/proxy" "math/rand" "net" @@ -132,7 +131,7 @@ func NewObfs4Server(stateDir string) (*Transport, error) { // Store the arguments that should appear in our descriptor for the clients. ptArgs := make(map[string]string) ptArgs[certArg] = st.cert.String() - common.Infof("certstring %s", certArg) + golog.Infof("certstring %s", certArg) ptArgs[iatArg] = strconv.Itoa(st.iatMode) // Initialize the replay filter. @@ -193,7 +192,7 @@ func (transport *Transport) Dial(address string) (net.Conn, error) { if err != nil { closeErr := dialConn.Close() if closeErr != nil { - common.Errorf("could not close") + golog.Errorf("could not close") } return nil, err } @@ -207,13 +206,11 @@ type TransportClient struct { IatMode int Address string Dialer proxy.Dialer - log *logging.Logger } type TransportServer struct { ServerFactory *ServerFactory Address string - log *logging.Logger } //Config contains arguments formatted for a json file @@ -222,12 +219,12 @@ type Config struct { IatMode string `json:"iat-mode"` } -func NewClient(certString string, iatMode int, address string, dialer proxy.Dialer, log *logging.Logger) (TransportClient, error) { - return TransportClient{CertString: certString, IatMode: iatMode, Address: address, Dialer: dialer, log: log}, nil +func NewClient(certString string, iatMode int, address string, dialer proxy.Dialer) (TransportClient, error) { + return TransportClient{CertString: certString, IatMode: iatMode, Address: address, Dialer: dialer}, nil } -func NewServer(stateDir string, address string, log *logging.Logger) (*TransportServer, error) { - sf, sFError := NewObfs4ServerFactory(stateDir, log) +func NewServer(stateDir string, address string) (*TransportServer, error) { + sf, sFError := NewObfs4ServerFactory(stateDir) if sFError != nil { return nil, sFError @@ -235,13 +232,12 @@ func NewServer(stateDir string, address string, log *logging.Logger) (*Transport transport := &TransportServer{ ServerFactory: sf, Address: address, - log: log, } return transport, nil } //NewObfs4Server initializes the obfs4 server side -func NewObfs4ServerFactory(stateDir string, log *logging.Logger) (*ServerFactory, error) { +func NewObfs4ServerFactory(stateDir string) (*ServerFactory, error) { args := make(map[string]string) st, err := serverStateFromArgs(stateDir, args) if err != nil { @@ -261,7 +257,7 @@ func NewObfs4ServerFactory(stateDir string, log *logging.Logger) (*ServerFactory // Store the arguments that should appear in our descriptor for the clients. ptArgs := make(map[string]string) ptArgs[certArg] = st.cert.String() - log.Infof("certstring %s", certArg) + golog.Infof("certstring %s", certArg) ptArgs[iatArg] = strconv.Itoa(st.iatMode) // Initialize the replay filter. @@ -315,13 +311,13 @@ func (transport *Transport) Listen(address string) (net.Listener, error) { func (transport *TransportServer) Listen() (net.Listener, error) { addr, resolveErr := pt.ResolveAddr(transport.Address) if resolveErr != nil { - transport.log.Error(resolveErr.Error()) + golog.Error(resolveErr.Error()) return nil, resolveErr } ln, err := net.ListenTCP("tcp", addr) if err != nil { - transport.log.Error(err.Error()) + golog.Error(err.Error()) return nil, err } diff --git a/transports/obfs4/v3/test_utils.go b/transports/obfs4/v3/test_utils.go index 0c44ae3..b0aded0 100644 --- a/transports/obfs4/v3/test_utils.go +++ b/transports/obfs4/v3/test_utils.go @@ -25,7 +25,7 @@ package obfs4 import ( - "github.com/op/go-logging" + "github.com/kataras/golog" "golang.org/x/net/proxy" "io/ioutil" "os" @@ -96,7 +96,7 @@ func RunLocalObfs4Server(data string) bool { func RunLocalObfs4ServerFactory(data string) bool { //create a server - log := MakeLog() + MakeLog() usr, userError := user.Current() if userError != nil { return false @@ -114,7 +114,7 @@ func RunLocalObfs4ServerFactory(data string) bool { return false } } - serverConfig, confError := NewServer(fPath, "127.0.0.1:2234", log) + serverConfig, confError := NewServer(fPath, "127.0.0.1:2234") if confError != nil { return false } @@ -187,7 +187,7 @@ func RunObfs4Client() (*Transport, error) { //RunObfs4Client runs the client side in the background for the test func RunObfs4ClientFactory() (*TransportClient, error) { - log := MakeLog() + MakeLog() usr, userError := user.Current() if userError != nil { return nil, userError @@ -214,15 +214,11 @@ func RunObfs4ClientFactory() (*TransportClient, error) { bridgePart := bridgeParts1[5] certstring := bridgePart[5:] //println(certstring) - clientConfig, confError := NewClient(certstring, 0, "127.0.0.1:2234", proxy.Direct, log) + clientConfig, confError := NewClient(certstring, 0, "127.0.0.1:2234", proxy.Direct) return &clientConfig, confError } -func MakeLog() *logging.Logger { - var log = logging.MustGetLogger("obfs4") - backend := logging.NewLogBackend(os.Stderr, "", 0) - backendLeveled := logging.AddModuleLevel(backend) - backendLeveled.SetLevel(logging.DEBUG, "") - log.SetBackend(backendLeveled) - return log +func MakeLog() { + golog.SetLevel("debug") + golog.SetOutput(os.Stderr) } diff --git a/transports/shadow/v3/go.mod b/transports/shadow/v3/go.mod index 40c8604..6363ad1 100644 --- a/transports/shadow/v3/go.mod +++ b/transports/shadow/v3/go.mod @@ -4,7 +4,7 @@ go 1.12 require ( github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da // indirect - github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 + github.com/kataras/golog v0.0.18 github.com/shadowsocks/go-shadowsocks2 v0.0.11 golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 // indirect ) diff --git a/transports/shadow/v3/go.sum b/transports/shadow/v3/go.sum index e71d517..1bd4d64 100644 --- a/transports/shadow/v3/go.sum +++ b/transports/shadow/v3/go.sum @@ -1,7 +1,11 @@ github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da h1:KjTM2ks9d14ZYCvmHS9iAKVt9AyzRSqNU1qabPih5BY= github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da/go.mod h1:eHEWzANqSiWQsof+nXEI9bUVUyV6F53Fp89EuCh2EAA= -github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88= -github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= +github.com/kataras/golog v0.0.18 h1:Td7hcKN25yzqB/0SO5iohOsMk5Mq5V9kDtM5apaJLY0= +github.com/kataras/golog v0.0.18/go.mod h1:jRYl7dFYqP8aQj9VkwdBUXYZSfUktm+YYg1arJILfyw= +github.com/kataras/pio v0.0.8 h1:6pX6nHJk7DAV3x1dEimibQF2CmJLlo0jWVmM9yE9KY8= +github.com/kataras/pio v0.0.8/go.mod h1:NFfMp2kVP1rmV4N6gH6qgWpuoDKlrOeYi3VrAIWCGsE= + h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88= +/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/shadowsocks/go-shadowsocks2 v0.0.11 h1:dXloqEhYnZV40jblWTK8kWeC0Eb+dgql4S0tj99e8j0= github.com/shadowsocks/go-shadowsocks2 v0.0.11/go.mod h1:R+KWaoIwRRhnpw6XV+dZil0XHi64Hc1D7hXUyXTjUzQ= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= diff --git a/transports/shadow/v3/shadow.go b/transports/shadow/v3/shadow.go index eea4699..74437d1 100644 --- a/transports/shadow/v3/shadow.go +++ b/transports/shadow/v3/shadow.go @@ -26,7 +26,7 @@ package shadow import ( - "github.com/op/go-logging" + "github.com/kataras/golog" "log" "net" @@ -44,7 +44,7 @@ type Transport struct { Password string CipherName string Address string - Log *logging.Logger + Log *golog.Logger } //NewConfig is used to create a config for testing @@ -56,7 +56,7 @@ func NewConfig(password string, cipherName string) Config { } //NewTransport is used for creating a transport for Optimizer -func NewTransport(password string, cipherName string, address string, log *logging.Logger) Transport { +func NewTransport(password string, cipherName string, address string, log *golog.Logger) Transport { return Transport{ Password: password, CipherName: cipherName, @@ -69,7 +69,7 @@ func NewTransport(password string, cipherName string, address string, log *loggi func (config Config) Listen(address string) (net.Listener, error) { cipher, err := shadowsocks.PickCipher(config.CipherName, nil, config.Password) if err != nil { - log.Fatal("Failed generating ciphers:", err) + golog.Errorf("Failed generating ciphers:", err) return nil, err } diff --git a/transports/shadow/v3/shadow_test.go b/transports/shadow/v3/shadow_test.go index 92479f3..5197911 100644 --- a/transports/shadow/v3/shadow_test.go +++ b/transports/shadow/v3/shadow_test.go @@ -26,7 +26,7 @@ package shadow import ( "fmt" - "github.com/op/go-logging" + "github.com/kataras/golog" "net" "os" "testing" @@ -100,7 +100,7 @@ func TestShadow(t *testing.T) { } func TestShadowFactory(t *testing.T) { //create a server - var log = logging.MustGetLogger("shadow") + var log = golog.MustGetLogger("shadow") transport := NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1236", log) //create client buffer From 4ab5b8d9158cbfa86b5d83a08dd36bf592c3e9e1 Mon Sep 17 00:00:00 2001 From: Bluesaxorcist Date: Mon, 27 Jul 2020 14:41:02 -0500 Subject: [PATCH 20/33] Update LICENSE.md --- transports/Dust/v3/LICENSE.md | 59 +++++++++++------------------------ 1 file changed, 19 insertions(+), 40 deletions(-) diff --git a/transports/Dust/v3/LICENSE.md b/transports/Dust/v3/LICENSE.md index f98047a..97e8749 100644 --- a/transports/Dust/v3/LICENSE.md +++ b/transports/Dust/v3/LICENSE.md @@ -1,40 +1,19 @@ -# Licenses for software included in this directory - -## Main Dust packages and first-party support packages - -The directories 'v2' and 'sillyHex' compose the main Dust packages for Go. The directories 'buf', 'huffman', 'model1', 'prim1', and 'proc' compose the first-party support packages. These are all subject to the following terms: - -* Copyright © 2015 Drake Wilson <drake@dasyatidae.com> - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -## Skein - -The directory 'skein' contains a modified version of Dmitry Chestnykh's Skein-512 code. It is subject to the following terms: - -* Copyright © 2012 Dmitry Chestnykh <dmitry@codingrobots.com> -* Copyright © 2015 Drake Wilson <drake@dasyatidae.com> -* All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - -* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -## Dist - -The directory 'dist' contains a local copy of the random distribution code from gonum. - -(TODO: copy appropriate file for this here) - - +Copyright (c) 2020 Operator Foundation + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file From ab9d52808cb489660f7d44c2390cdf8bea07db46 Mon Sep 17 00:00:00 2001 From: Bluesaxorcist Date: Mon, 27 Jul 2020 14:59:22 -0500 Subject: [PATCH 21/33] began implementation of make server address part of transport config --- transports/Replicant/v3/Optimizer.go | 42 ++++++++++++---------------- transports/Replicant/v3/config.go | 2 ++ transports/Replicant/v3/go.mod | 1 + transports/Replicant/v3/go.sum | 6 ++-- 4 files changed, 25 insertions(+), 26 deletions(-) diff --git a/transports/Replicant/v3/Optimizer.go b/transports/Replicant/v3/Optimizer.go index c7e28b7..c51db1d 100644 --- a/transports/Replicant/v3/Optimizer.go +++ b/transports/Replicant/v3/Optimizer.go @@ -26,7 +26,6 @@ package replicant import ( pt "github.com/OperatorFoundation/shapeshifter-ipc/v2" - "github.com/kataras/golog" "golang.org/x/net/proxy" "net" ) @@ -36,31 +35,27 @@ type TransportClient struct { Config ClientConfig Address string Dialer proxy.Dialer - Log *golog.Logger } type TransportServer struct { - Config ServerConfig + Config ServerConfig Address string Dialer proxy.Dialer - Log *golog.Logger } -func NewClient(config ClientConfig, address string, dialer proxy.Dialer, log *golog.Logger) TransportClient { +func NewClient(config ClientConfig, dialer proxy.Dialer) TransportClient { return TransportClient{ - Config: config, - Address: address, - Dialer: dialer, - Log: log, + Config: config, + Address: config.Address, + Dialer: dialer, } } -func NewServer(config ServerConfig, address string, dialer proxy.Dialer, log *golog.Logger) TransportServer { +func NewServer(config ServerConfig, address string, dialer proxy.Dialer) TransportServer { return TransportServer{ - Config: config, + Config: config, Address: address, - Dialer: dialer, - Log: log, + Dialer: dialer, } } @@ -78,7 +73,7 @@ func (transport TransportClient) Dial() (net.Conn, error) { } return transportConn, nil - } +} func (transport TransportServer) Listen() (net.Listener, error) { addr, resolveErr := pt.ResolveAddr(transport.Address) @@ -93,14 +88,13 @@ func (transport TransportServer) Listen() (net.Listener, error) { return newReplicantTransportListener(ln, transport.Config), nil } - //replicantTransport := New(transport.Config, transport.Dialer) - //conn := replicantTransport.Dial(transport.Address) - //conn, err:= replicantTransport.Dial(transport.Address), errors.New("connection failed") - //if err != nil { - // return nil, err - //} else { - // return conn, nil - //} - //return conn, nil - +//replicantTransport := New(transport.Config, transport.Dialer) +//conn := replicantTransport.Dial(transport.Address) +//conn, err:= replicantTransport.Dial(transport.Address), errors.New("connection failed") +//if err != nil { +// return nil, err +//} else { +// return conn, nil +//} +//return conn, nil diff --git a/transports/Replicant/v3/config.go b/transports/Replicant/v3/config.go index 092fba1..37426ce 100644 --- a/transports/Replicant/v3/config.go +++ b/transports/Replicant/v3/config.go @@ -33,6 +33,7 @@ import ( type ClientConfig struct { Toneburst toneburst.Config Polish polish.ClientConfig + Address string } type ServerConfig struct { @@ -70,6 +71,7 @@ func (config ClientConfig) Marshal() (string, error) { type ClientJSONConfig struct { Config string `json:"config"` + Address string `json:"address"` } configString, configStringError := config.Encode() diff --git a/transports/Replicant/v3/go.mod b/transports/Replicant/v3/go.mod index 2d0d408..063ac28 100644 --- a/transports/Replicant/v3/go.mod +++ b/transports/Replicant/v3/go.mod @@ -5,6 +5,7 @@ go 1.12 require ( github.com/OperatorFoundation/monolith-go/monolith v1.0.4 github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0 + github.com/kataras/golog v0.0.18 github.com/opentracing/opentracing-go v1.1.0 golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 golang.org/x/net v0.0.0-20200202094626-16171245cfb2 diff --git a/transports/Replicant/v3/go.sum b/transports/Replicant/v3/go.sum index 3382e0b..8d20f0d 100644 --- a/transports/Replicant/v3/go.sum +++ b/transports/Replicant/v3/go.sum @@ -4,8 +4,10 @@ github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0 h1:6aQs+TF3KULMarpzbKu8 github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0/go.mod h1:gb/QiZH0QDXLSQ9PskyJ2oTflB7tsP4AYc8y+FppvB0= github.com/deckarep/golang-set v1.7.1 h1:SCQV0S6gTtp6itiFrTqI+pfmJ4LN85S1YzhDf9rTHJQ= github.com/deckarep/golang-set v1.7.1/go.mod h1:93vsz/8Wt4joVM7c2AVqh+YRMiUSc14yDtF28KmMOgQ= - h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88= -/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= +github.com/kataras/golog v0.0.18 h1:Td7hcKN25yzqB/0SO5iohOsMk5Mq5V9kDtM5apaJLY0= +github.com/kataras/golog v0.0.18/go.mod h1:jRYl7dFYqP8aQj9VkwdBUXYZSfUktm+YYg1arJILfyw= +github.com/kataras/pio v0.0.8 h1:6pX6nHJk7DAV3x1dEimibQF2CmJLlo0jWVmM9yE9KY8= +github.com/kataras/pio v0.0.8/go.mod h1:NFfMp2kVP1rmV4N6gH6qgWpuoDKlrOeYi3VrAIWCGsE= github.com/opentracing/opentracing-go v1.1.0 h1:pWlfV3Bxv7k65HYwkikxat0+s3pV4bsqf19k25Ur8rU= github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= From e523d483c10fbda1410e1dbf767b1f93d9afd78a Mon Sep 17 00:00:00 2001 From: Bluesaxorcist Date: Mon, 27 Jul 2020 15:08:09 -0500 Subject: [PATCH 22/33] made config structs public accessible --- transports/Replicant/v3/config.go | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/transports/Replicant/v3/config.go b/transports/Replicant/v3/config.go index 37426ce..3227cb5 100644 --- a/transports/Replicant/v3/config.go +++ b/transports/Replicant/v3/config.go @@ -41,16 +41,20 @@ type ServerConfig struct { Polish polish.ServerConfig } -func (config ServerConfig) Marshal() (string, error) { +type ClientJSONConfig struct { + Config string `json:"config"` + Address string `json:"address"` +} - type ServerJSONInnerConfig struct { - Config string `json:"config"` - } +type ServerJSONInnerConfig struct { + Config string `json:"config"` +} - type ServerJSONOuterConfig struct { - Replicant ServerJSONInnerConfig - } +type ServerJSONOuterConfig struct { + Replicant ServerJSONInnerConfig +} +func (config ServerConfig) Marshal() (string, error) { configString, configStringError := config.Encode() if configStringError != nil { return "", configStringError @@ -69,11 +73,6 @@ func (config ServerConfig) Marshal() (string, error) { func (config ClientConfig) Marshal() (string, error) { - type ClientJSONConfig struct { - Config string `json:"config"` - Address string `json:"address"` - } - configString, configStringError := config.Encode() if configStringError != nil { return "", configStringError From 8d839fdb1a43f421f49ea8205753755cd5912246 Mon Sep 17 00:00:00 2001 From: Bluesaxorcist Date: Fri, 31 Jul 2020 10:30:43 -0500 Subject: [PATCH 23/33] implemented more v3 proposals --- transports/Dust/v3/Dust.go | 21 +++++--- transports/Dust/v3/Dust_test.go | 11 ++-- transports/Optimizer/v3/Optimizer_test.go | 15 +++--- transports/Replicant/v3/config.go | 1 - transports/Replicant/v3/pt21.go | 7 +++ transports/Replicant/v3/replicant_test.go | 11 ++-- transports/meeklite/v3/go.mod | 2 +- transports/meeklite/v3/go.sum | 7 ++- transports/meeklite/v3/meeklite.go | 58 ++++++++++++--------- transports/meeklite/v3/meeklite_test.go | 6 +-- transports/meekserver/v3/certificate.go | 4 +- transports/meekserver/v3/go.mod | 2 +- transports/meekserver/v3/go.sum | 7 ++- transports/meekserver/v3/meek-server.go | 14 ++--- transports/meekserver/v3/meekserver_test.go | 5 +- transports/meekserver/v3/pt21.go | 37 +++++++------ transports/obfs2/v2/obfs2.go | 10 ++-- transports/obfs2/v3/go.mod | 2 +- transports/obfs2/v3/go.sum | 9 ++-- transports/obfs2/v3/obfs2.go | 15 ++++-- transports/obfs2/v3/obfs2_test.go | 5 +- transports/obfs4/v3/obfs4.go | 3 +- transports/shadow/v3/go.sum | 2 - transports/shadow/v3/shadow.go | 35 ++++++++++--- transports/shadow/v3/shadow_test.go | 9 ++-- 25 files changed, 172 insertions(+), 126 deletions(-) diff --git a/transports/Dust/v3/Dust.go b/transports/Dust/v3/Dust.go index 8e369d5..dee00b6 100644 --- a/transports/Dust/v3/Dust.go +++ b/transports/Dust/v3/Dust.go @@ -29,15 +29,22 @@ import ( "github.com/kataras/golog" "golang.org/x/net/proxy" "net" + "os" "time" "github.com/OperatorFoundation/shapeshifter-ipc/v2" "github.com/blanu/Dust/go/v2/interface" ) +func MakeLog() { + golog.SetLevel("debug") + golog.SetOutput(os.Stderr) +} + type dustClient struct { serverPubkey *Dust.ServerPublic dialer proxy.Dialer + Address string `json:"address"` } type dustServer struct { @@ -45,16 +52,16 @@ type dustServer struct { dialer proxy.Dialer } -func NewDustClient(serverPublic string, dialer proxy.Dialer) *dustClient { +func NewDustClient(serverPublic string, dialer proxy.Dialer, address string) *dustClient { unparsed := make(map[string]string) - unparsed["p"]=serverPublic + unparsed["p"] = serverPublic spub, err := Dust.ParseServerPublic(unparsed) if err != nil { return nil } - return &dustClient{serverPubkey: spub, dialer: dialer} + return &dustClient{serverPubkey: spub, dialer: dialer, Address: address} } type dustTransportListener struct { @@ -68,25 +75,24 @@ type Transport struct { Address string Dialer proxy.Dialer ServerConfig *dustServer - Log *golog.Logger } type Config struct { ServerPublic string `json:"server-public"` + Address string `json:"address"` } -func New(serverPublic string, address string, dialer proxy.Dialer, serverConfig *dustServer, log *golog.Logger) Transport { +func New(serverPublic string, address string, dialer proxy.Dialer, serverConfig *dustServer) Transport { return Transport{ ServerPublic: serverPublic, Address: address, Dialer: dialer, ServerConfig: serverConfig, - Log: log, } } func (transport Transport) Dial() (net.Conn, error) { - dustTransport := NewDustClient(transport.ServerPublic, transport.Dialer) + dustTransport := NewDustClient(transport.ServerPublic, transport.Dialer, transport.Address) conn, err := dustTransport.Dial(transport.Address) if err != nil { return nil, err @@ -110,6 +116,7 @@ func (transport Transport) Listen() (net.Listener, error) { return newDustTransportListener(ln, transport.ServerConfig), nil } + //end optimizer code func newDustTransportListener(listener *net.TCPListener, transport *dustServer) *dustTransportListener { diff --git a/transports/Dust/v3/Dust_test.go b/transports/Dust/v3/Dust_test.go index ec86131..64b7133 100644 --- a/transports/Dust/v3/Dust_test.go +++ b/transports/Dust/v3/Dust_test.go @@ -7,9 +7,7 @@ package Dust // Package Dust provides a PT 2.1 Go API wrapper around the Dust transport - import ( - "github.com/kataras/golog" "golang.org/x/net/proxy" "testing" ) @@ -17,11 +15,14 @@ import ( const data = "test" func TestDust(t *testing.T) { + + MakeLog() //create a server serverConfig := dustServer{ serverPrivkey: nil, dialer: nil, } + clientConfig := dustClient{ serverPubkey: nil, dialer: nil, @@ -86,14 +87,16 @@ func TestDust(t *testing.T) { } func TestDustV3(t *testing.T) { + + MakeLog() + //create a server - var log = golog.MustGetLogger("dust") serverConfig := dustServer{ serverPrivkey: nil, dialer: nil, } - transport := New("", "127.0.0.1:1234", proxy.Direct, &serverConfig, log) + transport := New("", "127.0.0.1:1234", proxy.Direct, &serverConfig) //call listen on the server serverListener, listenErr := transport.Listen() if listenErr != nil { diff --git a/transports/Optimizer/v3/Optimizer_test.go b/transports/Optimizer/v3/Optimizer_test.go index bd6dfc0..789c736 100644 --- a/transports/Optimizer/v3/Optimizer_test.go +++ b/transports/Optimizer/v3/Optimizer_test.go @@ -5,7 +5,6 @@ import ( "github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3" "github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3" "github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3" - "github.com/kataras/golog" "golang.org/x/net/proxy" "io/ioutil" "net" @@ -82,7 +81,7 @@ func TestShadowDial(t *testing.T) { } func TestOptimizerShadowDial(t *testing.T) { - shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235", &golog.Logger{}) + shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235") transports := []TransportDialer{&shadowTransport} strategy := NewFirstStrategy(transports) optimizerTransport := NewOptimizerClient(transports, strategy) @@ -93,7 +92,7 @@ func TestOptimizerShadowDial(t *testing.T) { } func TestOptimizerObfs2Dial(t *testing.T) { - obfs2Transport := obfs2.New("127.0.0.1:1237", proxy.Direct, &golog.Logger{}) + obfs2Transport := obfs2.New("127.0.0.1:1237", proxy.Direct) transports := []TransportDialer{obfs2Transport} strategy := NewFirstStrategy(transports) optimizerTransport := NewOptimizerClient(transports, strategy) @@ -148,7 +147,7 @@ func TestOptimizerTransportFirstDial(t *testing.T) { IatMode: 0, Address: "127.0.0.1:1234", Dialer: dialer} - shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235", &golog.Logger{}) + shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235") transports := []TransportDialer{obfs4Transport, &shadowTransport} strategy := NewFirstStrategy(transports) optimizerTransport := NewOptimizerClient(transports, strategy) @@ -173,7 +172,7 @@ func TestOptimizerTransportRandomDial(t *testing.T) { Address: "127.0.0.1:1234", Dialer: dialer, } - shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235", &golog.Logger{}) + shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235") transports := []TransportDialer{obfs4Transport, &shadowTransport} strategy := NewRandomStrategy(transports) optimizerTransport := NewOptimizerClient(transports, strategy) @@ -199,7 +198,7 @@ func TestOptimizerTransportRotateDial(t *testing.T) { Address: "127.0.0.1:1234", Dialer: dialer, } - shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235", &golog.Logger{}) + shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235") transports := []TransportDialer{obfs4Transport, &shadowTransport} strategy := NewRotateStrategy(transports) optimizerTransport := NewOptimizerClient(transports, strategy) @@ -225,7 +224,7 @@ func TestOptimizerTransportTrackDial(t *testing.T) { Address: "127.0.0.1:1234", Dialer: dialer, } - shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235", &golog.Logger{}) + shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235") transports := []TransportDialer{obfs4Transport, &shadowTransport} strategy := NewTrackStrategy(transports) optimizerTransport := NewOptimizerClient(transports, strategy) @@ -251,7 +250,7 @@ func TestOptimizerTransportMinimizeDialDurationDial(t *testing.T) { Address: "127.0.0.1:1234", Dialer: dialer, } - shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235", &golog.Logger{}) + shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235") transports := []TransportDialer{obfs4Transport, &shadowTransport} strategy := NewMinimizeDialDuration(transports) optimizerTransport := NewOptimizerClient(transports, strategy) diff --git a/transports/Replicant/v3/config.go b/transports/Replicant/v3/config.go index 3227cb5..579a3a6 100644 --- a/transports/Replicant/v3/config.go +++ b/transports/Replicant/v3/config.go @@ -43,7 +43,6 @@ type ServerConfig struct { type ClientJSONConfig struct { Config string `json:"config"` - Address string `json:"address"` } type ServerJSONInnerConfig struct { diff --git a/transports/Replicant/v3/pt21.go b/transports/Replicant/v3/pt21.go index 3e98423..e37bbbd 100644 --- a/transports/Replicant/v3/pt21.go +++ b/transports/Replicant/v3/pt21.go @@ -26,10 +26,17 @@ package replicant import ( pt "github.com/OperatorFoundation/shapeshifter-ipc/v2" + "github.com/kataras/golog" "net" + "os" "time" ) +func MakeLog() { + golog.SetLevel("debug") + golog.SetOutput(os.Stderr) +} + // Create outgoing transport connection func (config ClientConfig) Dial(address string) (net.Conn, error) { conn, dialErr := net.Dial("tcp", address) diff --git a/transports/Replicant/v3/replicant_test.go b/transports/Replicant/v3/replicant_test.go index fa89943..1d219ce 100644 --- a/transports/Replicant/v3/replicant_test.go +++ b/transports/Replicant/v3/replicant_test.go @@ -5,7 +5,6 @@ import ( "github.com/OperatorFoundation/monolith-go/monolith" "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v3/polish" "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v3/toneburst" - "github.com/kataras/golog" "golang.org/x/net/proxy" "io/ioutil" "math/rand" @@ -184,7 +183,7 @@ func runReplicantServer() { } func runReplicantFactoryServer() { - var log = golog.MustGetLogger("replicant") + MakeLog() serverStarted := make(chan bool) addr := "127.0.0.1:3001" @@ -193,7 +192,7 @@ func runReplicantFactoryServer() { Polish: nil, } - server := NewServer(serverConfig, addr, proxy.Direct, log) + server := NewServer(serverConfig, addr, proxy.Direct) go func() { listener, listenError := server.Listen() @@ -304,7 +303,7 @@ func replicantConnection(clientConfig ClientConfig, serverConfig ServerConfig, t func replicantFactoryConnection(clientConfig ClientConfig, serverConfig ServerConfig, t *testing.T) { serverStarted := make(chan bool) - var log = golog.MustGetLogger("replicant") + MakeLog() // Get a random port rand.Seed(time.Now().UnixNano()) min := 1025 @@ -315,7 +314,7 @@ func replicantFactoryConnection(clientConfig ClientConfig, serverConfig ServerCo addr += portString go func() { - server := NewServer(serverConfig, addr, proxy.Direct, log) + server := NewServer(serverConfig, addr, proxy.Direct) listener, listenError := server.Listen() if listenError != nil { return @@ -350,7 +349,7 @@ func replicantFactoryConnection(clientConfig ClientConfig, serverConfig ServerCo t.Fail() return } - client := NewClient(clientConfig, addr, proxy.Direct, log) + client := NewClient(clientConfig, proxy.Direct) cConn, connErr := client.Dial() if connErr != nil { t.Fail() diff --git a/transports/meeklite/v3/go.mod b/transports/meeklite/v3/go.mod index 8d9bbeb..9fccd7f 100644 --- a/transports/meeklite/v3/go.mod +++ b/transports/meeklite/v3/go.mod @@ -3,6 +3,6 @@ module github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite go 1.12 require ( - + github.com/kataras/golog v0.0.18 golang.org/x/net v0.0.0-20200202094626-16171245cfb2 ) diff --git a/transports/meeklite/v3/go.sum b/transports/meeklite/v3/go.sum index 3fcd773..93924bc 100644 --- a/transports/meeklite/v3/go.sum +++ b/transports/meeklite/v3/go.sum @@ -1,7 +1,10 @@ - h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88= -/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= +github.com/kataras/golog v0.0.18 h1:Td7hcKN25yzqB/0SO5iohOsMk5Mq5V9kDtM5apaJLY0= +github.com/kataras/golog v0.0.18/go.mod h1:jRYl7dFYqP8aQj9VkwdBUXYZSfUktm+YYg1arJILfyw= +github.com/kataras/pio v0.0.8 h1:6pX6nHJk7DAV3x1dEimibQF2CmJLlo0jWVmM9yE9KY8= +github.com/kataras/pio v0.0.8/go.mod h1:NFfMp2kVP1rmV4N6gH6qgWpuoDKlrOeYi3VrAIWCGsE= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/net v0.0.0-20200202094626-16171245cfb2 h1:CCH4IOTTfewWjGOlSp+zGcjutRKlBEZQ6wTn8ozI/nI= golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/transports/meeklite/v3/meeklite.go b/transports/meeklite/v3/meeklite.go index 7281ed8..7322a0e 100644 --- a/transports/meeklite/v3/meeklite.go +++ b/transports/meeklite/v3/meeklite.go @@ -46,6 +46,7 @@ import ( "net" "net/http" gourl "net/url" + "os" "runtime" "sync" "time" @@ -70,6 +71,11 @@ var ( loopbackAddr = net.IPv4(127, 0, 0, 1) ) +func MakeLog() { + golog.SetLevel("debug") + golog.SetOutput(os.Stderr) +} + // MeekTransport that uses domain fronting to shapeshift the application network traffic type MeekTransport struct { dialer proxy.Dialer @@ -124,22 +130,22 @@ func (ca *meekClientArgs) Network() string { //Transport contains parameters used in Optimizer type Transport struct { - URL *gourl.URL `json:"url"` - Front string `json:"front"` - Address string - Dialer proxy.Dialer - log *golog.Logger + URL *gourl.URL + Front string + Dialer proxy.Dialer } //Config puts the parameters in a json compatible format type Config struct { - URL *gourl.URL `json:"url"` - Front string `json:"front"` + URL *gourl.URL `json:"url"` + Front string `json:"front"` + Address string `json:"address"` } -func NewMeekFactoryTransportWithFront(url *gourl.URL, front string, address string, dialer proxy.Dialer, log *golog.Logger) *Transport { - return &Transport{url, front, address,dialer, log} +func NewMeekFactoryTransportWithFront(url *gourl.URL, front string, dialer proxy.Dialer) *Transport { + return &Transport{url, front, dialer} } + // Dial creates outgoing transport connection func (transport Transport) Dial() (net.Conn, error) { meekTransport := NewMeekTransportWithFront(transport.URL.String(), transport.Front, transport.Dialer) @@ -239,23 +245,23 @@ func (transportConn *meekConn) Read(p []byte) (n int, err error) { return } select { - case <-time.After(20*time.Second): - return 0, nil - // Wait for the worker to enqueue more incoming data. - case b, ok := <-transportConn.workerRdChan: - if !ok { - // Close() was called and the worker's shutting down. - return 0, io.ErrClosedPipe - } + case <-time.After(20 * time.Second): + return 0, nil + // Wait for the worker to enqueue more incoming data. + case b, ok := <-transportConn.workerRdChan: + if !ok { + // Close() was called and the worker's shutting down. + return 0, io.ErrClosedPipe + } - // Ew, an extra copy, but who am I kidding, it's meek. - buf := bytes.NewBuffer(b) - n, err = buf.Read(p) - if buf.Len() > 0 { - // If there's data pending, stash the buffer so the next - // Read() call will use it to fulfill the Read(). - transportConn.rdBuf = buf - } + // Ew, an extra copy, but who am I kidding, it's meek. + buf := bytes.NewBuffer(b) + n, err = buf.Read(p) + if buf.Len() > 0 { + // If there's data pending, stash the buffer so the next + // Read() call will use it to fulfill the Read(). + transportConn.rdBuf = buf + } } return } @@ -365,7 +371,7 @@ func (transportConn *meekConn) roundTrip(sndBuf []byte) (recvBuf []byte, err err if resp.StatusCode == http.StatusInternalServerError { return } - time.Sleep(retryDelay) + time.Sleep(retryDelay) } else { _ = resp.Body.Close() diff --git a/transports/meeklite/v3/meeklite_test.go b/transports/meeklite/v3/meeklite_test.go index 5aa6c80..ea9162d 100644 --- a/transports/meeklite/v3/meeklite_test.go +++ b/transports/meeklite/v3/meeklite_test.go @@ -34,7 +34,6 @@ package meeklite import ( - "github.com/kataras/golog" "golang.org/x/net/proxy" gourl "net/url" "testing" @@ -43,6 +42,7 @@ import ( const data = "test" func TestMeeklite(t *testing.T) { + MakeLog() //create a server config := NewMeekTransportWithFront("https://transport-canary-meek.appspot.com/", "www.google.com", proxy.Direct) @@ -79,7 +79,7 @@ func TestMeeklite(t *testing.T) { } func TestFactoryMeeklite(t *testing.T) { - var log = golog.MustGetLogger("meeklite") + MakeLog() //create a server urlString := "https://transport-canary-meek.appspot.com/" Url, err := gourl.Parse(urlString) @@ -88,7 +88,7 @@ func TestFactoryMeeklite(t *testing.T) { return } - config := NewMeekFactoryTransportWithFront(Url, "www.google.com", "", proxy.Direct, log) + config := NewMeekFactoryTransportWithFront(Url, "www.google.com", proxy.Direct) //create client buffer clientBuffer := make([]byte, 4) diff --git a/transports/meekserver/v3/certificate.go b/transports/meekserver/v3/certificate.go index 8375137..9f9edf7 100644 --- a/transports/meekserver/v3/certificate.go +++ b/transports/meekserver/v3/certificate.go @@ -33,7 +33,7 @@ package meekserver import ( "crypto/tls" - "log" + "github.com/kataras/golog" "os" "sync" "time" @@ -126,7 +126,7 @@ func (ctx *certContext) GetCertificate(*tls.ClientHelloInfo) (*tls.Certificate, now := time.Now() if now.After(ctx.lastWarnAt.Add(certLoadErrorRateLimit)) { ctx.lastWarnAt = now - log.Printf("failed to reload certificate: %v", err) + golog.Infof("failed to reload certificate: %v", err) } } diff --git a/transports/meekserver/v3/go.mod b/transports/meekserver/v3/go.mod index 0108cfd..afc636b 100644 --- a/transports/meekserver/v3/go.mod +++ b/transports/meekserver/v3/go.mod @@ -4,8 +4,8 @@ go 1.12 require ( github.com/deckarep/golang-set v1.7.1 + github.com/kataras/golog v0.0.18 github.com/mufti1/interconv v0.0.0-20190313040840-d7c72925c656 - golang.org/x/crypto v0.0.0-20200214034016-1d94cc7ab1c6 golang.org/x/net v0.0.0-20200202094626-16171245cfb2 ) diff --git a/transports/meekserver/v3/go.sum b/transports/meekserver/v3/go.sum index 569ab80..891e062 100644 --- a/transports/meekserver/v3/go.sum +++ b/transports/meekserver/v3/go.sum @@ -1,9 +1,11 @@ github.com/deckarep/golang-set v1.7.1 h1:SCQV0S6gTtp6itiFrTqI+pfmJ4LN85S1YzhDf9rTHJQ= github.com/deckarep/golang-set v1.7.1/go.mod h1:93vsz/8Wt4joVM7c2AVqh+YRMiUSc14yDtF28KmMOgQ= +github.com/kataras/golog v0.0.18 h1:Td7hcKN25yzqB/0SO5iohOsMk5Mq5V9kDtM5apaJLY0= +github.com/kataras/golog v0.0.18/go.mod h1:jRYl7dFYqP8aQj9VkwdBUXYZSfUktm+YYg1arJILfyw= +github.com/kataras/pio v0.0.8 h1:6pX6nHJk7DAV3x1dEimibQF2CmJLlo0jWVmM9yE9KY8= +github.com/kataras/pio v0.0.8/go.mod h1:NFfMp2kVP1rmV4N6gH6qgWpuoDKlrOeYi3VrAIWCGsE= github.com/mufti1/interconv v0.0.0-20190313040840-d7c72925c656 h1:p+IdebEeB9SAEH9IOJVF6oZ535bwvWqUdqWxG1UWeko= github.com/mufti1/interconv v0.0.0-20190313040840-d7c72925c656/go.mod h1:+db4NNs1NvceiftEzz0ymfu3zKLkynYukafc7llNoMs= - h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88= -/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20200214034016-1d94cc7ab1c6 h1:Sy5bstxEqwwbYs6n0/pBuxKENqOeZUgD45Gp3Q3pqLg= golang.org/x/crypto v0.0.0-20200214034016-1d94cc7ab1c6/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= @@ -11,6 +13,7 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20200202094626-16171245cfb2 h1:CCH4IOTTfewWjGOlSp+zGcjutRKlBEZQ6wTn8ozI/nI= golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/transports/meekserver/v3/meek-server.go b/transports/meekserver/v3/meek-server.go index 4bbb1b8..a74bbdf 100644 --- a/transports/meekserver/v3/meek-server.go +++ b/transports/meekserver/v3/meek-server.go @@ -49,8 +49,8 @@ package meekserver import ( "crypto/tls" "fmt" + "github.com/kataras/golog" "io" - "log" "net" "net/http" "path" @@ -246,14 +246,14 @@ func (state *State) Post(w http.ResponseWriter, req *http.Request) { session, err := state.GetSession(sessionID) if err != nil { - log.Print(err) + golog.Error(err) httpInternalServerError(w) return } err = transact(session, w, req) if err != nil { - log.Print(err) + golog.Error(err) state.CloseSession(sessionID) return } @@ -345,10 +345,10 @@ func initServer(addr *net.TCPAddr, func startServer(addr *net.TCPAddr) (*http.Server, *State, error) { return initServer(addr, nil, func(server *http.Server, errChan chan<- error) { - log.Printf("listening with plain HTTP on %s", addr) + golog.Errorf("listening with plain HTTP on %s", addr) err := server.ListenAndServe() if err != nil { - log.Printf("Error in ListenAndServe: %s", err) + golog.Errorf("Error in ListenAndServe: %s", err) } errChan <- err }) @@ -356,10 +356,10 @@ func startServer(addr *net.TCPAddr) (*http.Server, *State, error) { func startServerTLS(addr *net.TCPAddr, getCertificate func(*tls.ClientHelloInfo) (*tls.Certificate, error)) (*http.Server, *State, error) { return initServer(addr, getCertificate, func(server *http.Server, errChan chan<- error) { - log.Printf("listening with HTTPS on %s", addr) + golog.Errorf("listening with HTTPS on %s", addr) err := server.ListenAndServeTLS("", "") if err != nil { - log.Printf("Error in ListenAndServeTLS: %s", err) + golog.Errorf("Error in ListenAndServeTLS: %s", err) } errChan <- err }) diff --git a/transports/meekserver/v3/meekserver_test.go b/transports/meekserver/v3/meekserver_test.go index 305cc7f..2c8fb3c 100644 --- a/transports/meekserver/v3/meekserver_test.go +++ b/transports/meekserver/v3/meekserver_test.go @@ -1,7 +1,6 @@ package meekserver import ( - "github.com/kataras/golog" "testing" ) @@ -29,10 +28,10 @@ func TestMeekServerListen(t *testing.T) { } func TestMeekServerFactoryListen(t *testing.T) { - var log = golog.MustGetLogger("meekserver") +MakeLog() acmeEmail := "brandon@operatorfoundation.org" acmeHostNames := "operatorrss.com" - meekserverTransport, newError := New(false, acmeHostNames, acmeEmail,"127.0.0.1:8080", "state", log) + meekserverTransport, newError := New(false, acmeHostNames, acmeEmail,"127.0.0.1:8080", "state") if newError != nil { t.Fail() return diff --git a/transports/meekserver/v3/pt21.go b/transports/meekserver/v3/pt21.go index 290ef1c..3c66bd1 100644 --- a/transports/meekserver/v3/pt21.go +++ b/transports/meekserver/v3/pt21.go @@ -61,16 +61,21 @@ package meekserver import ( "errors" - interconv "github.com/mufti1/interconv/package" "github.com/kataras/golog" + interconv "github.com/mufti1/interconv/package" "golang.org/x/crypto/acme/autocert" - "log" "net" "net/http" + "os" "strings" "time" ) +func MakeLog() { + golog.SetLevel("debug") + golog.SetOutput(os.Stderr) +} + //MeekServer is a Transport that uses domain fronting to shapeshift the application network traffic type MeekServer struct { DisableTLS bool @@ -83,7 +88,6 @@ type Transport struct { DisableTLS bool CertManager *autocert.Manager Address string - log *golog.Logger } //Config contains arguments formatted for a json file @@ -108,7 +112,7 @@ type fakeConn struct { writeBuffer []byte } -func New(disableTLS bool, acmeHostnamesCommas string, acmeEmail string, address string, stateDir string, Log *golog.Logger) (*Transport, error) { +func New(disableTLS bool, acmeHostnamesCommas string, acmeEmail string, address string, stateDir string) (*Transport, error) { var certManager *autocert.Manager if disableTLS { if acmeEmail != "" || acmeHostnamesCommas != "" { @@ -121,7 +125,7 @@ func New(disableTLS bool, acmeHostnamesCommas string, acmeEmail string, address } if acmeHostnamesCommas != "" { acmeHostnames := strings.Split(acmeHostnamesCommas, ",") - log.Printf("ACME hostnames: %q", acmeHostnames) + golog.Infof("ACME hostnames: %q", acmeHostnames) // The ACME HTTP-01 responder only works when it is running on // port 80. @@ -130,10 +134,10 @@ func New(disableTLS bool, acmeHostnamesCommas string, acmeEmail string, address var cache autocert.Cache cacheDir, err := getCertificateCacheDir(stateDir) if err == nil { - log.Printf("caching ACME certificates in directory %q", cacheDir) + golog.Infof("caching ACME certificates in directory %q", cacheDir) cache = autocert.DirCache(cacheDir) } else { - log.Printf("disabling ACME certificate cache: %s", err) + golog.Infof("disabling ACME certificate cache: %s", err) } certManager = &autocert.Manager{ @@ -146,7 +150,6 @@ func New(disableTLS bool, acmeHostnamesCommas string, acmeEmail string, address DisableTLS: disableTLS, CertManager: certManager, Address: address, - log: Log, }, nil } else { return nil, errors.New("must set acmeEmail") @@ -239,7 +242,7 @@ func NewMeekTransportServer(disableTLS bool, acmeEmail string, acmeHostnamesComm } if acmeHostnamesCommas != "" { acmeHostnames := strings.Split(acmeHostnamesCommas, ",") - log.Printf("ACME hostnames: %q", acmeHostnames) + golog.Infof("ACME hostnames: %q", acmeHostnames) // The ACME HTTP-01 responder only works when it is running on // port 80. @@ -248,10 +251,10 @@ func NewMeekTransportServer(disableTLS bool, acmeEmail string, acmeHostnamesComm var cache autocert.Cache cacheDir, err := getCertificateCacheDir(stateDir) if err == nil { - log.Printf("caching ACME certificates in directory %q", cacheDir) + golog.Infof("caching ACME certificates in directory %q", cacheDir) cache = autocert.DirCache(cacheDir) } else { - log.Printf("disabling ACME certificate cache: %s", err) + golog.Infof("disabling ACME certificate cache: %s", err) } certManager = &autocert.Manager{ @@ -282,14 +285,14 @@ func (transport *MeekServer) Listen(address string) (net.Listener, error) { Zone: "", } acmeAddr.Port = 80 - log.Printf("starting HTTP-01 ACME listener on %s", acmeAddr.String()) + golog.Infof("starting HTTP-01 ACME listener on %s", acmeAddr.String()) lnHTTP01, err := net.ListenTCP("tcp", &acmeAddr) if err != nil { - log.Printf("error opening HTTP-01 ACME listener: %s", err) + golog.Infof("error opening HTTP-01 ACME listener: %s", err) return nil, err } go func() { - log.Fatal(http.Serve(lnHTTP01, transport.CertManager.HTTPHandler(nil))) + golog.Fatal(http.Serve(lnHTTP01, transport.CertManager.HTTPHandler(nil))) }() var server *http.Server if transport.DisableTLS { @@ -318,14 +321,14 @@ func (transport *Transport) Listen() (net.Listener, error) { Zone: "", } acmeAddr.Port = 80 - log.Printf("starting HTTP-01 ACME listener on %s", acmeAddr.String()) + golog.Infof("starting HTTP-01 ACME listener on %s", acmeAddr.String()) lnHTTP01, err := net.ListenTCP("tcp", &acmeAddr) if err != nil { - log.Printf("error opening HTTP-01 ACME listener: %s", err) + golog.Infof("error opening HTTP-01 ACME listener: %s", err) return nil, err } go func() { - log.Fatal(http.Serve(lnHTTP01, transport.CertManager.HTTPHandler(nil))) + golog.Fatal(http.Serve(lnHTTP01, transport.CertManager.HTTPHandler(nil))) }() var server *http.Server if transport.DisableTLS { diff --git a/transports/obfs2/v2/obfs2.go b/transports/obfs2/v2/obfs2.go index b3f9a23..b57a779 100644 --- a/transports/obfs2/v2/obfs2.go +++ b/transports/obfs2/v2/obfs2.go @@ -36,7 +36,6 @@ import ( "crypto/sha256" "encoding/binary" "fmt" - "github.com/kataras/golog" "io" "net" "time" @@ -66,7 +65,6 @@ const ( type OptimizerTransport struct { Address string Dialer proxy.Dialer - Log *golog.Logger } //Dial connects to a specified address. @@ -92,27 +90,25 @@ func (transport OptimizerTransport) Dial() (net.Conn, error) { // Transport is the obfs2 implementation of the base.Transport interface. type Transport struct { dialer proxy.Dialer - log golog.Logger } //New initializes obfs2 for Optimizer -func New(address string, dialer proxy.Dialer, log *golog.Logger) *OptimizerTransport { +func New(address string, dialer proxy.Dialer) *OptimizerTransport { result := OptimizerTransport{ Address: address, Dialer: dialer, - Log: log, } return &result } //NewObfs2Transport is the initializer for obfs2 without a dialer func NewObfs2Transport() *Transport { - return &Transport{dialer: nil, log: golog.Logger{}} + return &Transport{dialer: nil} } //NewObfs2Transport is the initializer for obfs2 with a dialer func NewObfs2TransportWithDialer(dialer proxy.Dialer) *Transport { - return &Transport{dialer: dialer, log: golog.Logger{}} + return &Transport{dialer: dialer} } //obfs2TransportListener defines a TCP network listener. diff --git a/transports/obfs2/v3/go.mod b/transports/obfs2/v3/go.mod index 4205bdf..c9ed2e6 100644 --- a/transports/obfs2/v3/go.mod +++ b/transports/obfs2/v3/go.mod @@ -5,6 +5,6 @@ go 1.12 require ( github.com/OperatorFoundation/obfs4 v1.0.0 github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0 - + github.com/kataras/golog v0.0.18 golang.org/x/net v0.0.0-20200226121028-0de0cce0169b ) diff --git a/transports/obfs2/v3/go.sum b/transports/obfs2/v3/go.sum index c080a26..9e479db 100644 --- a/transports/obfs2/v3/go.sum +++ b/transports/obfs2/v3/go.sum @@ -7,17 +7,16 @@ github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0 h1:6aQs+TF3KULMarpzbKu8 github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0/go.mod h1:gb/QiZH0QDXLSQ9PskyJ2oTflB7tsP4AYc8y+FppvB0= github.com/dchest/siphash v1.2.1 h1:4cLinnzVJDKxTCl9B01807Yiy+W7ZzVHj/KIroQRvT4= github.com/dchest/siphash v1.2.1/go.mod h1:q+IRvb2gOSrUnYoPqHiyHXS0FOBBOdl6tONBlVnOnt4= - h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88= -/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= +github.com/kataras/golog v0.0.18 h1:Td7hcKN25yzqB/0SO5iohOsMk5Mq5V9kDtM5apaJLY0= +github.com/kataras/golog v0.0.18/go.mod h1:jRYl7dFYqP8aQj9VkwdBUXYZSfUktm+YYg1arJILfyw= +github.com/kataras/pio v0.0.8 h1:6pX6nHJk7DAV3x1dEimibQF2CmJLlo0jWVmM9yE9KY8= +github.com/kataras/pio v0.0.8/go.mod h1:NFfMp2kVP1rmV4N6gH6qgWpuoDKlrOeYi3VrAIWCGsE= github.com/willscott/goturn v0.0.0-20170802220503-19f41278d0c9/go.mod h1:PfwRjodCaQXOsHnh2DeVaXqCFCIrbn5WLj1+A5bQkD4= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d h1:1ZiEyfaQIg3Qh0EoqpwAakHVhecoE5wlSg5GjnafJGw= golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b h1:0mm1VjtFUOIlE1SbDlwjYaDxZVDP2S5ou6y0gSgXHu8= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= diff --git a/transports/obfs2/v3/obfs2.go b/transports/obfs2/v3/obfs2.go index 6412ceb..88071ac 100644 --- a/transports/obfs2/v3/obfs2.go +++ b/transports/obfs2/v3/obfs2.go @@ -37,9 +37,9 @@ import ( "encoding/binary" "fmt" "github.com/kataras/golog" - "io" "net" + "os" "time" "golang.org/x/net/proxy" @@ -63,11 +63,19 @@ const ( hsLen = 4 + 4 ) +func MakeLog() { + golog.SetLevel("debug") + golog.SetOutput(os.Stderr) +} + //OptimizerTransport contains params needed for Optimizer type OptimizerTransport struct { Address string Dialer proxy.Dialer - log *golog.Logger +} + +type Config struct { + Address string `json:"address"` } //Dial connects to a specified address. @@ -112,11 +120,10 @@ type Transport struct { } //New initializes obfs2 for Optimizer -func New(address string, dialer proxy.Dialer, log *golog.Logger) *OptimizerTransport { +func New(address string, dialer proxy.Dialer) *OptimizerTransport { result := OptimizerTransport{ Address: address, Dialer: dialer, - log: log, } return &result } diff --git a/transports/obfs2/v3/obfs2_test.go b/transports/obfs2/v3/obfs2_test.go index e855778..1009c4f 100644 --- a/transports/obfs2/v3/obfs2_test.go +++ b/transports/obfs2/v3/obfs2_test.go @@ -32,7 +32,6 @@ package obfs2 import ( - "github.com/kataras/golog" "golang.org/x/net/proxy" "os" "testing" @@ -98,8 +97,8 @@ func TestObfs2WithDialer(t *testing.T) { } func TestObfs2OptimizerTransportWithDialer(t *testing.T) { - var log = golog.MustGetLogger("obfs2") - config := New("127.0.0.1:1237", proxy.Direct, log) +MakeLog() + config := New("127.0.0.1:1237", proxy.Direct) //create client buffer clientBuffer := make([]byte, 4) //call dial on client and check error diff --git a/transports/obfs4/v3/obfs4.go b/transports/obfs4/v3/obfs4.go index bf615a6..e87a169 100644 --- a/transports/obfs4/v3/obfs4.go +++ b/transports/obfs4/v3/obfs4.go @@ -204,7 +204,7 @@ func (transport *Transport) Dial(address string) (net.Conn, error) { type TransportClient struct { CertString string IatMode int - Address string + Address string `json:"address"` Dialer proxy.Dialer } @@ -217,6 +217,7 @@ type TransportServer struct { type Config struct { CertString string `json:"cert"` IatMode string `json:"iat-mode"` + Address string `json:"address"` } func NewClient(certString string, iatMode int, address string, dialer proxy.Dialer) (TransportClient, error) { diff --git a/transports/shadow/v3/go.sum b/transports/shadow/v3/go.sum index 1bd4d64..8b0b225 100644 --- a/transports/shadow/v3/go.sum +++ b/transports/shadow/v3/go.sum @@ -4,8 +4,6 @@ github.com/kataras/golog v0.0.18 h1:Td7hcKN25yzqB/0SO5iohOsMk5Mq5V9kDtM5apaJLY0= github.com/kataras/golog v0.0.18/go.mod h1:jRYl7dFYqP8aQj9VkwdBUXYZSfUktm+YYg1arJILfyw= github.com/kataras/pio v0.0.8 h1:6pX6nHJk7DAV3x1dEimibQF2CmJLlo0jWVmM9yE9KY8= github.com/kataras/pio v0.0.8/go.mod h1:NFfMp2kVP1rmV4N6gH6qgWpuoDKlrOeYi3VrAIWCGsE= - h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88= -/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/shadowsocks/go-shadowsocks2 v0.0.11 h1:dXloqEhYnZV40jblWTK8kWeC0Eb+dgql4S0tj99e8j0= github.com/shadowsocks/go-shadowsocks2 v0.0.11/go.mod h1:R+KWaoIwRRhnpw6XV+dZil0XHi64Hc1D7hXUyXTjUzQ= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= diff --git a/transports/shadow/v3/shadow.go b/transports/shadow/v3/shadow.go index 74437d1..681a3bb 100644 --- a/transports/shadow/v3/shadow.go +++ b/transports/shadow/v3/shadow.go @@ -29,14 +29,27 @@ import ( "github.com/kataras/golog" "log" "net" + "os" shadowsocks "github.com/shadowsocks/go-shadowsocks2/core" ) +func MakeLog() { + golog.SetLevel("debug") + golog.SetOutput(os.Stderr) +} + //Config contains the necessary command like arguments to run shadow -type Config struct { +type ClientConfig struct { + Password string `json:"password"` + CipherName string `json:"cipherName"` + Address string `json:"address"` +} + +type ServerConfig struct { Password string `json:"password"` CipherName string `json:"cipherName"` + Address string `json:"address"` } //Transport contains the arguments to be used with Optimizer @@ -44,29 +57,35 @@ type Transport struct { Password string CipherName string Address string - Log *golog.Logger } //NewConfig is used to create a config for testing -func NewConfig(password string, cipherName string) Config { - return Config{ +func NewClientConfig(password string, cipherName string, address string) ClientConfig { + return ClientConfig{ + Password: password, + CipherName: cipherName, + Address: address, + } +} + +func NewServerConfig(password string, cipherName string) ServerConfig { + return ServerConfig{ Password: password, CipherName: cipherName, } } //NewTransport is used for creating a transport for Optimizer -func NewTransport(password string, cipherName string, address string, log *golog.Logger) Transport { +func NewTransport(password string, cipherName string, address string) Transport { return Transport{ Password: password, CipherName: cipherName, Address: address, - Log: log, } } //Listen checks for a working connection -func (config Config) Listen(address string) (net.Listener, error) { +func (config ServerConfig) Listen(address string) (net.Listener, error) { cipher, err := shadowsocks.PickCipher(config.CipherName, nil, config.Password) if err != nil { golog.Errorf("Failed generating ciphers:", err) @@ -82,7 +101,7 @@ func (config Config) Listen(address string) (net.Listener, error) { } //Dial connects to the address on the named network -func (config Config) Dial(address string) (net.Conn, error) { +func (config ClientConfig) Dial(address string) (net.Conn, error) { cipher, err := shadowsocks.PickCipher(config.CipherName, nil, config.Password) if err != nil { log.Fatal("Failed generating ciphers:", err) diff --git a/transports/shadow/v3/shadow_test.go b/transports/shadow/v3/shadow_test.go index 5197911..2c741db 100644 --- a/transports/shadow/v3/shadow_test.go +++ b/transports/shadow/v3/shadow_test.go @@ -26,7 +26,6 @@ package shadow import ( "fmt" - "github.com/kataras/golog" "net" "os" "testing" @@ -35,7 +34,7 @@ import ( const data = "test" func TestMain(m *testing.M) { - config := NewConfig("1234", "CHACHA20-IETF-POLY1305") + config := NewServerConfig("1234", "CHACHA20-IETF-POLY1305") listener, listenErr := config.Listen("127.0.0.1:1236") if listenErr != nil { return @@ -70,7 +69,7 @@ func acceptConnections(listener net.Listener) { func TestShadow(t *testing.T) { //create a server - config := NewConfig("1234", "CHACHA20-IETF-POLY1305") + config := NewClientConfig("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1236") //create client buffer clientBuffer := make([]byte, 4) @@ -100,8 +99,8 @@ func TestShadow(t *testing.T) { } func TestShadowFactory(t *testing.T) { //create a server - var log = golog.MustGetLogger("shadow") - transport := NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1236", log) + MakeLog() + transport := NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1236") //create client buffer clientBuffer := make([]byte, 4) From 327cd81cf378ada3198180ed7077ba9cc2ea690a Mon Sep 17 00:00:00 2001 From: Bluesaxorcist Date: Fri, 31 Jul 2020 10:34:54 -0500 Subject: [PATCH 24/33] Update go.mod --- transports/Optimizer/v3/go.mod | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/transports/Optimizer/v3/go.mod b/transports/Optimizer/v3/go.mod index 25eb265..69eeebe 100644 --- a/transports/Optimizer/v3/go.mod +++ b/transports/Optimizer/v3/go.mod @@ -3,10 +3,10 @@ module github.com/OperatorFoundation/shapeshifter-transports/transports/Optimize go 1.12 require ( - github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3 v3.0.6 - github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 v3.0.6 - github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 v3.0.6 - github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 v3.0.6 + github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3 v3.0.10 + github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 v3.0.10 + github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 v3.0.10 + github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 v3.0.10 github.com/kataras/golog v0.0.18 golang.org/x/net v0.0.0-20200226121028-0de0cce0169b ) From fbe43263cbbc483b930ad701e68482b9b12e42a3 Mon Sep 17 00:00:00 2001 From: Bluesaxorcist Date: Fri, 31 Jul 2020 10:49:29 -0500 Subject: [PATCH 25/33] updated the Optimizer test --- transports/Optimizer/v3/Optimizer_test.go | 6 +++--- transports/Optimizer/v3/go.sum | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/transports/Optimizer/v3/Optimizer_test.go b/transports/Optimizer/v3/Optimizer_test.go index 789c736..0ab9669 100644 --- a/transports/Optimizer/v3/Optimizer_test.go +++ b/transports/Optimizer/v3/Optimizer_test.go @@ -20,7 +20,7 @@ import ( const data = "test" func TestMain(m *testing.M) { - config := shadow.NewConfig("1234", "CHACHA20-IETF-POLY1305") + config := shadow.NewServerConfig("1234", "CHACHA20-IETF-POLY1305") listener, listenErr := config.Listen("127.0.0.1:1235") if listenErr != nil { return @@ -49,7 +49,7 @@ func TestMeekliteDial(t *testing.T) { if parseErr != nil { t.Fail() } - meekliteTransport := meeklite.Transport{URL: URL, Front: "a0.awsstatic.com", Address: "127.0.0.1:1235" } + meekliteTransport := meeklite.Transport{URL: URL, Front: "a0.awsstatic.com"} _, err := meekliteTransport.Dial() if err != nil { t.Fail() @@ -62,7 +62,7 @@ func TestOptimizerMeekliteDial(t *testing.T) { if parseErr != nil { t.Fail() } - meekliteTransport := meeklite.Transport{URL: URL, Front: "a0.awsstatic.com", Address: "127.0.0.1:1235" } + meekliteTransport := meeklite.Transport{URL: URL, Front: "a0.awsstatic.com"} transports := []TransportDialer{meekliteTransport} strategy := NewFirstStrategy(transports) optimizerTransport := NewOptimizerClient(transports, strategy) diff --git a/transports/Optimizer/v3/go.sum b/transports/Optimizer/v3/go.sum index f1e1d12..f3f9cb8 100644 --- a/transports/Optimizer/v3/go.sum +++ b/transports/Optimizer/v3/go.sum @@ -7,12 +7,20 @@ github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0 h1:6aQs+TF3KULMarpzbKu8 github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0/go.mod h1:gb/QiZH0QDXLSQ9PskyJ2oTflB7tsP4AYc8y+FppvB0= github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3 v3.0.6 h1:CzFbaRDdcg1xXxIa+N20StrDN8P0hGfoBOv+Idfepn4= github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3 v3.0.6/go.mod h1:gW1GFU+PS/+snW7IK7gcObExPKCzsvIL1z2g9N/5ubM= +github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3 v3.0.10 h1:D2CK7Vbr7eh7Z+2npal98SaXfqQvhWFptyskmnh3+cQ= +github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3 v3.0.10/go.mod h1:wQZC/2AdEDj3fnuI0Bu0dL1kvUeaE7MvoyeLlLu2nfQ= github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 v3.0.6 h1:xmos+1ED0y2UbqtEXGxtcxIqTDGPuw0te5Obqlspj9s= github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 v3.0.6/go.mod h1:i8hkRv+UCu0YbOll8NqoDzDBsRR6XgMa1bykKsTUxTg= +github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 v3.0.10 h1:hKOpe/wHRjIdv10ZWarm3hebce6BtfMpxsr9ZRS+ei0= +github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 v3.0.10/go.mod h1:nnE7S0srPoXZDatJ7sTWhClwo/3vyMXykSDPHAdi2xo= github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 v3.0.6 h1:/aEcDgGu3VA+gndxMv02LvfbZ6rg0lUYYnPkTlbgaSM= github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 v3.0.6/go.mod h1:jdYrSKfsppvvtY/WHSL2mN2FdFNiQ7S/XzQxrty0+2I= +github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 v3.0.10 h1:ATbRmWxRg7AHAGgU54DPrVpiy7zteqhCQYXc1T/U0Po= +github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 v3.0.10/go.mod h1:k1ga949kVeIGplqIb1lBE8Qi957Om/bz/GDMymQr+kA= github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 v3.0.6 h1:nqdVkCLaotgyabOWXf+sVLrGDQTRt8HqAAT/EZwysLM= github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 v3.0.6/go.mod h1:EQS0MxXaaSQO2IoAwVyXsgx7RBWL6Yy+gMiEn2YJRbo= +github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 v3.0.10 h1:rRRsTQycB1WeVGZSbgfTn0R9woiCi1RpyFEYoRU8uLo= +github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 v3.0.10/go.mod h1:eI5kZwV2A9NBKB3UgzjY1ThIsV2sSUETBmjGbPncaf0= github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da h1:KjTM2ks9d14ZYCvmHS9iAKVt9AyzRSqNU1qabPih5BY= github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da/go.mod h1:eHEWzANqSiWQsof+nXEI9bUVUyV6F53Fp89EuCh2EAA= github.com/dchest/siphash v1.2.1 h1:4cLinnzVJDKxTCl9B01807Yiy+W7ZzVHj/KIroQRvT4= From 5f44a5542d02e42bf81e27978f27809a0410da18 Mon Sep 17 00:00:00 2001 From: Bluesaxorcist Date: Mon, 3 Aug 2020 12:52:24 -0500 Subject: [PATCH 26/33] removed address field in serverConfig --- transports/shadow/v3/shadow.go | 1 - 1 file changed, 1 deletion(-) diff --git a/transports/shadow/v3/shadow.go b/transports/shadow/v3/shadow.go index 681a3bb..30e0bd5 100644 --- a/transports/shadow/v3/shadow.go +++ b/transports/shadow/v3/shadow.go @@ -49,7 +49,6 @@ type ClientConfig struct { type ServerConfig struct { Password string `json:"password"` CipherName string `json:"cipherName"` - Address string `json:"address"` } //Transport contains the arguments to be used with Optimizer From 2a2a31755e8941922699a85238123f79ce12985d Mon Sep 17 00:00:00 2001 From: Bluesaxorcist Date: Wed, 5 Aug 2020 14:46:14 -0500 Subject: [PATCH 27/33] finished the improved logging --- transports/Dust/v3/Dust.go | 6 ------ transports/Dust/v3/Dust_test.go | 7 +++++++ transports/Optimizer/v3/Optimizer_test.go | 18 ++++++++++++++++++ transports/Optimizer/v3/go.mod | 8 ++++---- .../Replicant/v3/ReplicantClientConfig.json | 2 +- .../Replicant/v3/ReplicantClientConfig1.json | 2 +- .../Replicant/v3/ReplicantServerConfig.json | 2 +- .../Replicant/v3/ReplicantServerConfig1.json | 2 +- transports/Replicant/v3/pt21.go | 7 ------- transports/Replicant/v3/replicant_test.go | 7 +++++++ transports/meeklite/v3/meeklite.go | 7 ------- transports/meeklite/v3/meeklite_test.go | 7 +++++++ transports/meekserver/v3/meekserver_test.go | 7 +++++++ transports/meekserver/v3/pt21.go | 6 ------ transports/obfs2/v3/obfs2.go | 7 ------- transports/obfs2/v3/obfs2_test.go | 6 ++++++ transports/shadow/v3/shadow.go | 9 +-------- transports/shadow/v3/shadow_test.go | 6 ++++++ 18 files changed, 67 insertions(+), 49 deletions(-) diff --git a/transports/Dust/v3/Dust.go b/transports/Dust/v3/Dust.go index dee00b6..cb0f905 100644 --- a/transports/Dust/v3/Dust.go +++ b/transports/Dust/v3/Dust.go @@ -29,18 +29,12 @@ import ( "github.com/kataras/golog" "golang.org/x/net/proxy" "net" - "os" "time" "github.com/OperatorFoundation/shapeshifter-ipc/v2" "github.com/blanu/Dust/go/v2/interface" ) -func MakeLog() { - golog.SetLevel("debug") - golog.SetOutput(os.Stderr) -} - type dustClient struct { serverPubkey *Dust.ServerPublic dialer proxy.Dialer diff --git a/transports/Dust/v3/Dust_test.go b/transports/Dust/v3/Dust_test.go index 64b7133..71fe8d5 100644 --- a/transports/Dust/v3/Dust_test.go +++ b/transports/Dust/v3/Dust_test.go @@ -8,7 +8,9 @@ package Dust // Package Dust provides a PT 2.1 Go API wrapper around the Dust transport import ( + "github.com/kataras/golog" "golang.org/x/net/proxy" + "os" "testing" ) @@ -154,3 +156,8 @@ func TestDustV3(t *testing.T) { return } } + +func MakeLog() { + golog.SetLevel("debug") + golog.SetOutput(os.Stderr) +} \ No newline at end of file diff --git a/transports/Optimizer/v3/Optimizer_test.go b/transports/Optimizer/v3/Optimizer_test.go index 0ab9669..600590b 100644 --- a/transports/Optimizer/v3/Optimizer_test.go +++ b/transports/Optimizer/v3/Optimizer_test.go @@ -5,6 +5,7 @@ import ( "github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3" "github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3" "github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3" + "github.com/kataras/golog" "golang.org/x/net/proxy" "io/ioutil" "net" @@ -44,6 +45,7 @@ func acceptConnections(listener net.Listener) { } func TestMeekliteDial(t *testing.T) { + MakeLog() unparsedURL := "https://d2zfqthxsdq309.cloudfront.net/" URL, parseErr := url.Parse(unparsedURL) if parseErr != nil { @@ -57,6 +59,7 @@ func TestMeekliteDial(t *testing.T) { } func TestOptimizerMeekliteDial(t *testing.T) { + MakeLog() unparsedURL := "https://d2zfqthxsdq309.cloudfront.net/" URL, parseErr := url.Parse(unparsedURL) if parseErr != nil { @@ -73,6 +76,7 @@ func TestOptimizerMeekliteDial(t *testing.T) { } func TestShadowDial(t *testing.T) { + MakeLog() shadowTransport := shadow.Transport{Password: "1234", CipherName: "CHACHA20-IETF-POLY1305", Address: "127.0.0.1:1235"} _, err := shadowTransport.Dial() if err != nil { @@ -81,6 +85,7 @@ func TestShadowDial(t *testing.T) { } func TestOptimizerShadowDial(t *testing.T) { + MakeLog() shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235") transports := []TransportDialer{&shadowTransport} strategy := NewFirstStrategy(transports) @@ -92,6 +97,7 @@ func TestOptimizerShadowDial(t *testing.T) { } func TestOptimizerObfs2Dial(t *testing.T) { + MakeLog() obfs2Transport := obfs2.New("127.0.0.1:1237", proxy.Direct) transports := []TransportDialer{obfs2Transport} strategy := NewFirstStrategy(transports) @@ -103,6 +109,7 @@ func TestOptimizerObfs2Dial(t *testing.T) { } func TestObfs4Transport_Dial(t *testing.T) { + MakeLog() obfs4Transport, transportErr := obfs4.RunObfs4Client() if transportErr != nil { t.Fail() @@ -115,6 +122,7 @@ func TestObfs4Transport_Dial(t *testing.T) { } func TestOptimizerObfs4Transport_Dial(t *testing.T) { + MakeLog() dialer := proxy.Direct certstring, certError := getObfs4CertString() if certError != nil { @@ -136,6 +144,7 @@ func TestOptimizerObfs4Transport_Dial(t *testing.T) { } func TestOptimizerTransportFirstDial(t *testing.T) { + MakeLog() dialer := proxy.Direct certstring, certError := getObfs4CertString() if certError != nil { @@ -160,6 +169,7 @@ func TestOptimizerTransportFirstDial(t *testing.T) { } func TestOptimizerTransportRandomDial(t *testing.T) { + MakeLog() dialer := proxy.Direct certstring, certError := getObfs4CertString() if certError != nil { @@ -186,6 +196,7 @@ func TestOptimizerTransportRandomDial(t *testing.T) { } func TestOptimizerTransportRotateDial(t *testing.T) { + MakeLog() dialer := proxy.Direct certstring, certError := getObfs4CertString() if certError != nil { @@ -212,6 +223,7 @@ func TestOptimizerTransportRotateDial(t *testing.T) { } func TestOptimizerTransportTrackDial(t *testing.T) { + MakeLog() dialer := proxy.Direct certstring, certError := getObfs4CertString() if certError != nil { @@ -238,6 +250,7 @@ func TestOptimizerTransportTrackDial(t *testing.T) { } func TestOptimizerTransportMinimizeDialDurationDial(t *testing.T) { + MakeLog() dialer := proxy.Direct certstring, certError := getObfs4CertString() if certError != nil { @@ -327,4 +340,9 @@ func RunLocalObfs2Server() { } } }() +} + +func MakeLog() { + golog.SetLevel("debug") + golog.SetOutput(os.Stderr) } \ No newline at end of file diff --git a/transports/Optimizer/v3/go.mod b/transports/Optimizer/v3/go.mod index 69eeebe..1ec247f 100644 --- a/transports/Optimizer/v3/go.mod +++ b/transports/Optimizer/v3/go.mod @@ -3,10 +3,10 @@ module github.com/OperatorFoundation/shapeshifter-transports/transports/Optimize go 1.12 require ( - github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3 v3.0.10 - github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 v3.0.10 - github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 v3.0.10 - github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 v3.0.10 + github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3 v3.0.11 + github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 v3.0.11 + github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 v3.0.11 + github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 v3.0.11 github.com/kataras/golog v0.0.18 golang.org/x/net v0.0.0-20200226121028-0de0cce0169b ) diff --git a/transports/Replicant/v3/ReplicantClientConfig.json b/transports/Replicant/v3/ReplicantClientConfig.json index ec2382f..b710236 100644 --- a/transports/Replicant/v3/ReplicantClientConfig.json +++ b/transports/Replicant/v3/ReplicantClientConfig.json @@ -1 +1 @@ -{"config":"M/+BAwEBDENsaWVudENvbmZpZwH/ggABAgEJVG9uZWJ1cnN0ARAAAQZQb2xpc2gBEAAAAP+8/4IBZmdpdGh1Yi5jb20vT3BlcmF0b3JGb3VuZGF0aW9uL3NoYXBlc2hpZnRlci10cmFuc3BvcnRzL3RyYW5zcG9ydHMvUmVwbGljYW50L3YzL3RvbmVidXJzdC5Nb25vdG9uZUNvbmZpZ/+NAwEBDk1vbm90b25lQ29uZmlnAf+OAAEDAQxBZGRTZXF1ZW5jZXMB/5AAAQ9SZW1vdmVTZXF1ZW5jZXMB/5IAAQpTcGVha0ZpcnN0AQIAAAAq/48DAQEISW5zdGFuY2UB/5AAAQIBBERlc2MB/5IAAQRBcmdzAf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/gLTvfifR7p1kTFXd060zD+099p2oqSV6OaMB/glaAAA="} \ No newline at end of file diff --git a/transports/Replicant/v3/ReplicantClientConfig1.json b/transports/Replicant/v3/ReplicantClientConfig1.json index e80bcab..f7c451a 100644 --- a/transports/Replicant/v3/ReplicantClientConfig1.json +++ b/transports/Replicant/v3/ReplicantClientConfig1.json @@ -1 +1 @@ -{"config":"M/+BAwEBDENsaWVudENvbmZpZwH/ggABAgEJVG9uZWJ1cnN0ARAAAQZQb2xpc2gBEAAAAP+8/4IBZmdpdGh1Yi5jb20vT3BlcmF0b3JGb3VuZGF0aW9uL3NoYXBlc2hpZnRlci10cmFuc3BvcnRzL3RyYW5zcG9ydHMvUmVwbGljYW50L3YzL3RvbmVidXJzdC5Nb25vdG9uZUNvbmZpZ/+NAwEBDk1vbm90b25lQ29uZmlnAf+OAAEDAQxBZGRTZXF1ZW5jZXMB/5AAAQ9SZW1vdmVTZXF1ZW5jZXMB/5IAAQpTcGVha0ZpcnN0AQIAAAAq/48DAQEISW5zdGFuY2UB/5AAAQIBBERlc2MB/5IAAQRBcmdzAf+WAAAAJP+RAwEBC0Rlc2NyaXB0aW9uAf+SAAEBAQVQYXJ0cwH/lAAAACH/kwIBARNbXW1vbm9saXRoLk1vbm9saXRoAf+UAAEQAAAo/5UDAQEEQXJncwH/lgABAgEGVmFsdWVzAf+YAAEFSW5kZXgBBAAAABz/lwIBAQ5bXWludGVyZmFjZSB7fQH/mAABEAAA/gUJ/45jAQEBAjxnaXRodWIuY29tL09wZXJhdG9yRm91bmRhdGlvbi9tb25vbGl0aC1nby9tb25vbGl0aC5CeXRlc1BhcnT/mQMBAQlCeXRlc1BhcnQB/5oAAQEBBUl0ZW1zAf+cAAAAIf+bAgEBE1tdbW9ub2xpdGguQnl0ZVR5cGUB/5wAARAAAP4Dx/+a/4YBAktnaXRodWIuY29tL09wZXJhdG9yRm91bmRhdGlvbi9tb25vbGl0aC1nby9tb25vbGl0aC5SYW5kb21FbnVtZXJhdGVkQnl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l0aC5SYW5kb21FbnVtZXJhdGVkQnl0ZVR5cGX/oAcBBBESExQAADxnaXRodWIuY29tL09wZXJhdG9yRm91bmRhdGlvbi9tb25vbGl0aC1nby9tb25vbGl0aC5CeXRlc1BhcnT/mv+vAQJLZ2l0aHViLmNvbS9PcGVyYXRvckZvdW5kYXRpb24vbW9ub2xpdGgtZ28vbW9ub2xpdGguUmFuZG9tRW51bWVyYXRlZEJ5dGVUeXBl/6AHAQQREhMUAEtnaXRodWIuY29tL09wZXJhdG9yRm91bmRhdGlvbi9tb25vbGl0aC1nby9tb25vbGl0aC5SYW5kb21FbnVtZXJhdGVkQnl0ZVR5cGX/oAcBBBESExQAAAABAQABbWdpdGh1Yi5jb20vT3BlcmF0b3JGb3VuZGF0aW9uL3NoYXBlc2hpZnRlci10cmFuc3BvcnRzL3RyYW5zcG9ydHMvUmVwbGljYW50L3YzL3BvbGlzaC5TaWx2ZXJQb2xpc2hDbGllbnRDb25maWf/hwMBARhTaWx2ZXJQb2xpc2hDbGllbnRDb25maWcB/4gAAQIBD1NlcnZlclB1YmxpY0tleQEKAAEJQ2h1bmtTaXplAQQAAABM/4hIAUEEPy7UR8K4ws8wBa9BqC31wmpjgPEPUkogCxrL1/9FouyyVG6bs7LTkFcjlK1e16ySbrqrOiDw9Ph2mF/kacL57gH+Cp4AAA=="} \ No newline at end of file diff --git a/transports/Replicant/v3/ReplicantServerConfig.json b/transports/Replicant/v3/ReplicantServerConfig.json index 5ad3a44..efee501 100644 --- a/transports/Replicant/v3/ReplicantServerConfig.json +++ b/transports/Replicant/v3/ReplicantServerConfig.json @@ -1 +1 @@ -{"Replicant":{"config":"M/+JAwEBDFNlcnZlckNvbmZpZwH/igABAgEJVG9uZWJ1cnN0ARAAAQZQb2xpc2gBEAAAAP+8/4oBZmdpdGh1Yi5jb20vT3BlcmF0b3JGb3VuZGF0aW9uL3NoYXBlc2hpZnRlci10cmFuc3BvcnRzL3RyYW5zcG9ydHMvUmVwbGljYW50L3YzL3Rvb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aWZ0ZXItdHJhbnNwb3J0cy90cmFuc3BvcnRzL1JlcGxpY2FudC92My9wb2xpc2guU2lsdmVyUG9saXNoU2VydmVyQ29uZmln/4sDAQEYU2lsdmVyUG9saXNoU2VydmVyQ29uZmlnAf+MAAEDAQ9TZXJ2ZXJQdWJsaWNLZXkBCgABEFNlcnZlclByaXZhdGVLZXkBCgABCUNodW5rU2l6ZQEEAAAAbv+MagFBBLd8zoUelx+g4T0o6OU6EZrDFXIEgD7seIX+0bIoFQbFw35nkA+/gLTvfifR7p1kTFXd060zD+099p2oqSV6OaMBIPq/E8xDxstEZNB05fQ2J5zpkEoNbfr8vjhobT6cmFVcAf4JWgAA"}} \ No newline at end of file diff --git a/transports/Replicant/v3/ReplicantServerConfig1.json b/transports/Replicant/v3/ReplicantServerConfig1.json index 3293ef6..157a724 100644 --- a/transports/Replicant/v3/ReplicantServerConfig1.json +++ b/transports/Replicant/v3/ReplicantServerConfig1.json @@ -1 +1 @@ -{"Replicant":{"config":"M/+JAwEBDFNlcnZlckNvbmZpZwH/igABAgEJVG9uZWJ1cnN0ARAAAQZQb2xpc2gBEAAAAP+8/4oBZmdpdGh1Yi5jb20vT3BlcmF0b3JGb3VuZGF0aW9uL3NoYXBlc2hpZnRlci10cmFuc3BvcnRzL3RyYW5zcG9ydHMvUmVwbGljYW50L3YzL3RvbmVidXJzdC5Nb25vdG9uZUNvbmZpZ/+NAwEBDk1vbm90b25lQ29uZmlnAf+OAAEDAQxBZGRTZXF1ZW5jZXMB/5AAAQ9SZW1vdmVTZXF1ZW5jZXMB/5IAAQpTcGVha0ZpcnN0AQIAAAAq/48DAQEISW5zdGFuY2UB/5AAAQIBBERlc2MB/5IAAQRBcmdzAf+WAAAAJP+RAwEBC0Rlc2NyaXB0aW9uAf+SAAEBAQVQYXJ0cwH/lAAAACH/kwIBARNbXW1vbm9saXRoLk1vbm9saXRoAf+UAAEQAAAo/5UDAQEEQXJncwH/lgABAgEGVmFsdWVzAf+YAAEFSW5kZXgB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say9f/RaLsslRum7Oy05BXI5StXteskm66qzog8PT4dphf5GnC+e4BIIBLchU1rtGnBcGXOPR/nMbz9PcfevBPsm+0/EDZODkpAf4KngAA"}} \ No newline at end of file diff --git a/transports/Replicant/v3/pt21.go b/transports/Replicant/v3/pt21.go index e37bbbd..3e98423 100644 --- a/transports/Replicant/v3/pt21.go +++ b/transports/Replicant/v3/pt21.go @@ -26,17 +26,10 @@ package replicant import ( pt "github.com/OperatorFoundation/shapeshifter-ipc/v2" - "github.com/kataras/golog" "net" - "os" "time" ) -func MakeLog() { - golog.SetLevel("debug") - golog.SetOutput(os.Stderr) -} - // Create outgoing transport connection func (config ClientConfig) Dial(address string) (net.Conn, error) { conn, dialErr := net.Dial("tcp", address) diff --git a/transports/Replicant/v3/replicant_test.go b/transports/Replicant/v3/replicant_test.go index 1d219ce..50ba459 100644 --- a/transports/Replicant/v3/replicant_test.go +++ b/transports/Replicant/v3/replicant_test.go @@ -5,6 +5,7 @@ import ( "github.com/OperatorFoundation/monolith-go/monolith" "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v3/polish" "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v3/toneburst" + "github.com/kataras/golog" "golang.org/x/net/proxy" "io/ioutil" "math/rand" @@ -135,6 +136,7 @@ func TestMonotoneRandomEnumerated(t *testing.T) { replicantConnection(clientConfig, serverConfig, t) } +//TODO this test looks identical to the test above apart from naming func TestFactoryMonotoneRandomEnumerated(t *testing.T) { clientConfig := createMonotoneClientConfigRandomEnumeratedItems() serverConfig := createMonotoneServerConfigRandomEnumeratedItems() @@ -1091,3 +1093,8 @@ func createSampleConfigs() (*ClientConfig, *ServerConfig) { return &clientConfig, &serverConfig } + +func MakeLog() { + golog.SetLevel("debug") + golog.SetOutput(os.Stderr) +} \ No newline at end of file diff --git a/transports/meeklite/v3/meeklite.go b/transports/meeklite/v3/meeklite.go index 7322a0e..d70b971 100644 --- a/transports/meeklite/v3/meeklite.go +++ b/transports/meeklite/v3/meeklite.go @@ -39,14 +39,12 @@ import ( "encoding/hex" "errors" "fmt" - "github.com/kataras/golog" "golang.org/x/net/proxy" "io" "io/ioutil" "net" "net/http" gourl "net/url" - "os" "runtime" "sync" "time" @@ -71,11 +69,6 @@ var ( loopbackAddr = net.IPv4(127, 0, 0, 1) ) -func MakeLog() { - golog.SetLevel("debug") - golog.SetOutput(os.Stderr) -} - // MeekTransport that uses domain fronting to shapeshift the application network traffic type MeekTransport struct { dialer proxy.Dialer diff --git a/transports/meeklite/v3/meeklite_test.go b/transports/meeklite/v3/meeklite_test.go index ea9162d..92c42d3 100644 --- a/transports/meeklite/v3/meeklite_test.go +++ b/transports/meeklite/v3/meeklite_test.go @@ -34,8 +34,10 @@ package meeklite import ( + "github.com/kataras/golog" "golang.org/x/net/proxy" gourl "net/url" + "os" "testing" ) @@ -121,3 +123,8 @@ func TestFactoryMeeklite(t *testing.T) { return } } + +func MakeLog() { + golog.SetLevel("debug") + golog.SetOutput(os.Stderr) +} \ No newline at end of file diff --git a/transports/meekserver/v3/meekserver_test.go b/transports/meekserver/v3/meekserver_test.go index 2c8fb3c..4d19edd 100644 --- a/transports/meekserver/v3/meekserver_test.go +++ b/transports/meekserver/v3/meekserver_test.go @@ -1,6 +1,8 @@ package meekserver import ( + "github.com/kataras/golog" + "os" "testing" ) @@ -41,4 +43,9 @@ MakeLog() t.Fail() return } +} + +func MakeLog() { + golog.SetLevel("debug") + golog.SetOutput(os.Stderr) } \ No newline at end of file diff --git a/transports/meekserver/v3/pt21.go b/transports/meekserver/v3/pt21.go index 3c66bd1..6e67333 100644 --- a/transports/meekserver/v3/pt21.go +++ b/transports/meekserver/v3/pt21.go @@ -66,16 +66,10 @@ import ( "golang.org/x/crypto/acme/autocert" "net" "net/http" - "os" "strings" "time" ) -func MakeLog() { - golog.SetLevel("debug") - golog.SetOutput(os.Stderr) -} - //MeekServer is a Transport that uses domain fronting to shapeshift the application network traffic type MeekServer struct { DisableTLS bool diff --git a/transports/obfs2/v3/obfs2.go b/transports/obfs2/v3/obfs2.go index 88071ac..1052bae 100644 --- a/transports/obfs2/v3/obfs2.go +++ b/transports/obfs2/v3/obfs2.go @@ -36,10 +36,8 @@ import ( "crypto/sha256" "encoding/binary" "fmt" - "github.com/kataras/golog" "io" "net" - "os" "time" "golang.org/x/net/proxy" @@ -63,11 +61,6 @@ const ( hsLen = 4 + 4 ) -func MakeLog() { - golog.SetLevel("debug") - golog.SetOutput(os.Stderr) -} - //OptimizerTransport contains params needed for Optimizer type OptimizerTransport struct { Address string diff --git a/transports/obfs2/v3/obfs2_test.go b/transports/obfs2/v3/obfs2_test.go index 1009c4f..b4e070b 100644 --- a/transports/obfs2/v3/obfs2_test.go +++ b/transports/obfs2/v3/obfs2_test.go @@ -32,6 +32,7 @@ package obfs2 import ( + "github.com/kataras/golog" "golang.org/x/net/proxy" "os" "testing" @@ -158,4 +159,9 @@ func RunLocalObfs2Server() { } } }() +} + +func MakeLog() { + golog.SetLevel("debug") + golog.SetOutput(os.Stderr) } \ No newline at end of file diff --git a/transports/shadow/v3/shadow.go b/transports/shadow/v3/shadow.go index 30e0bd5..84e5df9 100644 --- a/transports/shadow/v3/shadow.go +++ b/transports/shadow/v3/shadow.go @@ -27,18 +27,11 @@ package shadow import ( "github.com/kataras/golog" + shadowsocks "github.com/shadowsocks/go-shadowsocks2/core" "log" "net" - "os" - - shadowsocks "github.com/shadowsocks/go-shadowsocks2/core" ) -func MakeLog() { - golog.SetLevel("debug") - golog.SetOutput(os.Stderr) -} - //Config contains the necessary command like arguments to run shadow type ClientConfig struct { Password string `json:"password"` diff --git a/transports/shadow/v3/shadow_test.go b/transports/shadow/v3/shadow_test.go index 2c741db..b4e3b3b 100644 --- a/transports/shadow/v3/shadow_test.go +++ b/transports/shadow/v3/shadow_test.go @@ -26,6 +26,7 @@ package shadow import ( "fmt" + "github.com/kataras/golog" "net" "os" "testing" @@ -128,3 +129,8 @@ func TestShadowFactory(t *testing.T) { return } } + +func MakeLog() { + golog.SetLevel("debug") + golog.SetOutput(os.Stderr) +} \ No newline at end of file From 50658850b3a4409be4d78145c6c7668aa53f13f6 Mon Sep 17 00:00:00 2001 From: Bluesaxorcist Date: Mon, 10 Aug 2020 13:01:07 -0500 Subject: [PATCH 28/33] began merging v2 into v3 --- transports/Dust/v2/Dust.go | 2 +- transports/Dust/v2/go.mod | 2 +- transports/Dust/v2/go.sum | 8 +- transports/Optimizer/v2/LICENSE | 21 +++ transports/Optimizer/v2/Optimizer.go | 25 +++- transports/Optimizer/v2/Optimizer_test.go | 1 + transports/Optimizer/v2/go.mod | 8 +- transports/Optimizer/v2/go.sum | 26 ++-- transports/Replicant/v2/.DS_Store | Bin 6148 -> 0 bytes transports/Replicant/v2/LICENSE | 21 +++ transports/Replicant/v2/Optimizer.go | 24 ++++ .../Replicant/v2/ReplicantClientConfig.json | 2 +- .../Replicant/v2/ReplicantClientConfig1.json | 2 +- .../Replicant/v2/ReplicantServerConfig.json | 2 +- .../Replicant/v2/ReplicantServerConfig1.json | 2 +- transports/Replicant/v2/config.go | 24 ++++ transports/Replicant/v2/go.mod | 2 +- transports/Replicant/v2/go.sum | 14 +- transports/Replicant/v2/persistence.go | 24 ++++ transports/Replicant/v2/polish/config.go | 24 ++++ transports/Replicant/v2/polish/polish.go | 24 ++++ transports/Replicant/v2/polish/silver.go | 24 ++++ transports/Replicant/v2/pt21.go | 124 +++++++++++++++--- transports/Replicant/v2/replicant.go | 25 +++- transports/Replicant/v2/replicant_test.go | 2 +- transports/Replicant/v2/toneburst/config.go | 24 ++++ transports/Replicant/v2/toneburst/monotone.go | 24 ++++ .../Replicant/v2/toneburst/toneburst.go | 24 ++++ .../Replicant/v2/toneburst/whalesong.go | 24 ++++ transports/meeklite/v2/LICENSE | 0 transports/meekserver/v2/meek-server.go | 2 +- transports/meekserver/v2/pt21.go | 10 +- transports/obfs2/v2/go.mod | 3 +- transports/obfs2/v2/go.sum | 8 +- transports/obfs2/v2/obfs2.go | 10 +- transports/obfs2/v2/obfs2_test.go | 4 +- transports/obfs4/v2/go.mod | 2 +- transports/obfs4/v2/go.sum | 4 + transports/obfs4/v2/obfs4.go | 66 +++++----- transports/obfs4/v2/statefile.go | 11 +- transports/shadow/v2/go.sum | 2 + transports/shadow/v2/shadow.go | 6 +- transports/shadow/v2/shadow_test.go | 31 +++++ 43 files changed, 562 insertions(+), 126 deletions(-) create mode 100644 transports/Optimizer/v2/LICENSE delete mode 100644 transports/Replicant/v2/.DS_Store create mode 100644 transports/Replicant/v2/LICENSE create mode 100644 transports/meeklite/v2/LICENSE diff --git a/transports/Dust/v2/Dust.go b/transports/Dust/v2/Dust.go index 727364b..66c9eeb 100644 --- a/transports/Dust/v2/Dust.go +++ b/transports/Dust/v2/Dust.go @@ -14,7 +14,7 @@ import ( "net" "time" - "github.com/OperatorFoundation/shapeshifter-ipc" + "github.com/OperatorFoundation/shapeshifter-ipc/v2" "github.com/blanu/Dust/go/v2/interface" ) diff --git a/transports/Dust/v2/go.mod b/transports/Dust/v2/go.mod index 9b8d6eb..2a6a0aa 100644 --- a/transports/Dust/v2/go.mod +++ b/transports/Dust/v2/go.mod @@ -4,7 +4,7 @@ go 1.12 require ( github.com/OperatorFoundation/obfs4 v1.0.0 - github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0 + github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0 github.com/blanu/Dust v1.0.1 // indirect github.com/blanu/Dust/go/v2/interface v1.0.1 golang.org/x/net v0.0.0-20200226121028-0de0cce0169b diff --git a/transports/Dust/v2/go.sum b/transports/Dust/v2/go.sum index 3284541..dd89648 100644 --- a/transports/Dust/v2/go.sum +++ b/transports/Dust/v2/go.sum @@ -3,16 +3,16 @@ github.com/OperatorFoundation/ed25519 v0.0.0-20200225224545-b22b4bd3ddef h1:1xEt github.com/OperatorFoundation/ed25519 v0.0.0-20200225224545-b22b4bd3ddef/go.mod h1:gQNGvsyT4Zmps9H/yzCqdc+RQzt8ZxCndRNtGTYnBzQ= github.com/OperatorFoundation/obfs4 v1.0.0 h1:OcfdNMzv69fKQrLTkTSwpaBkHyBZMLjigA5M3txZpAg= github.com/OperatorFoundation/obfs4 v1.0.0/go.mod h1:6apgxOLYwyvbpzujpFHWu6Jlc+mjn1aFK7WvNijIVWc= -github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0 h1:zDYt6FDJwDSX4woVFVK2EMt7fkxU5L5qDNLUjQwA+BQ= -github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0/go.mod h1:kB00Ak8Dgn1uZlZHLc/WsUta58Jc+n/ZhCetcPkh42Q= +github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0 h1:6aQs+TF3KULMarpzbKu8DhFOF9D2UBCaAN5ZtbK53nQ= +github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0/go.mod h1:gb/QiZH0QDXLSQ9PskyJ2oTflB7tsP4AYc8y+FppvB0= github.com/blanu/Dust v1.0.0/go.mod h1:jLFQI2Ufz4kBnGiTzh8O9+/p4U/9MLbouXkaympnTI0= github.com/blanu/Dust v1.0.1 h1:C1IiRXr9YP1A4iiuhhpQOCgl8785LoVq78lbDrVRVqc= github.com/blanu/Dust v1.0.1/go.mod h1:jLFQI2Ufz4kBnGiTzh8O9+/p4U/9MLbouXkaympnTI0= github.com/blanu/Dust/go/v2/interface v1.0.1 h1:lIQrNXljx8vgTTwB+gObrkA6jBhokmgH/uHp1OxbqxE= github.com/blanu/Dust/go/v2/interface v1.0.1/go.mod h1:0NnpBd5fkRrG2I/pf6bcUaL5jpp84LeShsQzn4gCOCw= github.com/dchest/siphash v1.2.1/go.mod h1:q+IRvb2gOSrUnYoPqHiyHXS0FOBBOdl6tONBlVnOnt4= - h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88= -/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= +github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88= +github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/willscott/goturn v0.0.0-20170802220503-19f41278d0c9/go.mod h1:PfwRjodCaQXOsHnh2DeVaXqCFCIrbn5WLj1+A5bQkD4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= diff --git a/transports/Optimizer/v2/LICENSE b/transports/Optimizer/v2/LICENSE new file mode 100644 index 0000000..dfad7b5 --- /dev/null +++ b/transports/Optimizer/v2/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 Operator Foundation + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/transports/Optimizer/v2/Optimizer.go b/transports/Optimizer/v2/Optimizer.go index ba77fb7..49d06cf 100644 --- a/transports/Optimizer/v2/Optimizer.go +++ b/transports/Optimizer/v2/Optimizer.go @@ -1,7 +1,26 @@ /* - * Copyright (c) 2019, Operator Foundation - * - */ + MIT License + + Copyright (c) 2020 Operator Foundation + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ // Package optimizer provides a PT 2.0 Go API wrapper around the connections used package optimizer diff --git a/transports/Optimizer/v2/Optimizer_test.go b/transports/Optimizer/v2/Optimizer_test.go index 04936d4..2d13bc3 100644 --- a/transports/Optimizer/v2/Optimizer_test.go +++ b/transports/Optimizer/v2/Optimizer_test.go @@ -5,6 +5,7 @@ import ( "github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v2" "github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2" "github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v2" + "golang.org/x/net/proxy" "io/ioutil" "net" diff --git a/transports/Optimizer/v2/go.mod b/transports/Optimizer/v2/go.mod index 8353f14..7f791ae 100644 --- a/transports/Optimizer/v2/go.mod +++ b/transports/Optimizer/v2/go.mod @@ -3,9 +3,9 @@ module github.com/OperatorFoundation/shapeshifter-transports/transports/Optimize go 1.12 require ( - github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v2 v2.1.22 - github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v2 v2.1.22 - github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2 v2.1.22 - github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v2 v2.1.22 + github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v2 v2.2.5 + github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v2 v2.2.5 + github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2 v2.2.5 + github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v2 v2.2.5 golang.org/x/net v0.0.0-20200226121028-0de0cce0169b ) diff --git a/transports/Optimizer/v2/go.sum b/transports/Optimizer/v2/go.sum index 975af23..7927a9a 100644 --- a/transports/Optimizer/v2/go.sum +++ b/transports/Optimizer/v2/go.sum @@ -3,22 +3,16 @@ github.com/OperatorFoundation/ed25519 v0.0.0-20200225224545-b22b4bd3ddef h1:1xEt github.com/OperatorFoundation/ed25519 v0.0.0-20200225224545-b22b4bd3ddef/go.mod h1:gQNGvsyT4Zmps9H/yzCqdc+RQzt8ZxCndRNtGTYnBzQ= github.com/OperatorFoundation/obfs4 v1.0.0 h1:OcfdNMzv69fKQrLTkTSwpaBkHyBZMLjigA5M3txZpAg= github.com/OperatorFoundation/obfs4 v1.0.0/go.mod h1:6apgxOLYwyvbpzujpFHWu6Jlc+mjn1aFK7WvNijIVWc= -github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0 h1:zDYt6FDJwDSX4woVFVK2EMt7fkxU5L5qDNLUjQwA+BQ= -github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0/go.mod h1:kB00Ak8Dgn1uZlZHLc/WsUta58Jc+n/ZhCetcPkh42Q= -github.com/OperatorFoundation/shapeshifter-transports v0.0.0-20200211223228-5b0aa21018a5 h1:UrCgBKvfj+Rim1jAUkRqQt1neJgLVHtKt0228tEmFKY= -github.com/OperatorFoundation/shapeshifter-transports v0.0.0-20200211223228-5b0aa21018a5/go.mod h1:u3jvRgYV13oHabVAdXekh3yk9PHfpCKvB8uolQEs4jA= -github.com/OperatorFoundation/shapeshifter-transports/transports/Optimizer/v2 v2.1.12/go.mod h1:+A6vQ50ZAHi76GOGtpH730VFirwb1p8E6VJM8M50gNk= -github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v2 v2.1.11/go.mod h1:yPCbCoTjLIG+p0xiuRDwW5t+DivxTHqGU5njf89AkHY= -github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v2 v2.1.22 h1:BuiRy5QWa5hI3dNcOGw/Co4GYpU3PONrjrAlUB3pzt4= -github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v2 v2.1.22/go.mod h1:DEfaE6lfJKEG5CkCRks4rXTMi1xYwbYR0sa+JKsgsr0= -github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v2 v2.1.22 h1:ygZ3s1ROaeyfrIjIo1pFAiq73UtOv8iBxZtV5MGZjVc= -github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v2 v2.1.22/go.mod h1:S2qmYjCQzB7XGJ5JMuVDTp2IbQveaAhXQ9BVOx+6KD8= -github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2 v2.1.11/go.mod h1:OUFBnkMmjMHTWqEQlanDOMTgBjU5QARjklwQv9Qovr4= -github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2 v2.1.22 h1:WIs1AFLM7qNWcO6QEksWdldnH2H4WXaD5d25iogN8Nk= -github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2 v2.1.22/go.mod h1:OUFBnkMmjMHTWqEQlanDOMTgBjU5QARjklwQv9Qovr4= -github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v2 v2.1.11/go.mod h1:GN8ahnEHVGcPbR0raxdpWekjgElppspPNAAOpmNxQxU= -github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v2 v2.1.22 h1:F7YHfgEJ2Nq4f4XQFiXI4uMueuZGlQbEIdEIhN2b60s= -github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v2 v2.1.22/go.mod h1:GN8ahnEHVGcPbR0raxdpWekjgElppspPNAAOpmNxQxU= +github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0 h1:6aQs+TF3KULMarpzbKu8DhFOF9D2UBCaAN5ZtbK53nQ= +github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0/go.mod h1:gb/QiZH0QDXLSQ9PskyJ2oTflB7tsP4AYc8y+FppvB0= +github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v2 v2.2.5 h1:EqRoJz0kdLmnxpaOv6PbXRJohdbIvio6FkYkyWs2U0w= +github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v2 v2.2.5/go.mod h1:DEfaE6lfJKEG5CkCRks4rXTMi1xYwbYR0sa+JKsgsr0= +github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v2 v2.2.5 h1:AcAPnmUoi9qsK5vOQUvJIM7+YXtaLDhfOiBz8EA9bGM= +github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v2 v2.2.5/go.mod h1:W9OJqDkmHbSB86NOlGqECLDtSvr9MoVVlYrvjFqBMG0= +github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2 v2.2.5 h1:NudLXkarpDevMLpW/s081LHDwTmKURMCHZ67ZNSXWBc= +github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2 v2.2.5/go.mod h1:WbvdPacTr1IvoVsd9fYk4sDaWoxxCZIQDks9jRveRC0= +github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v2 v2.2.5 h1:DsKNTTXO/rjm/y8wG/0wUZ3KSFx+OqU1UuYzIHN0m0Q= +github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v2 v2.2.5/go.mod h1:GN8ahnEHVGcPbR0raxdpWekjgElppspPNAAOpmNxQxU= github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da h1:KjTM2ks9d14ZYCvmHS9iAKVt9AyzRSqNU1qabPih5BY= github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da/go.mod h1:eHEWzANqSiWQsof+nXEI9bUVUyV6F53Fp89EuCh2EAA= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/transports/Replicant/v2/.DS_Store b/transports/Replicant/v2/.DS_Store deleted file mode 100644 index 5008ddfcf53c02e82d7eee2e57c38e5672ef89f6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0 0 { + if len(b) <= sconn.receiveBuffer.Len() { + // Read the decrypted data into the provided slice "b" + readLen, readError := sconn.receiveBuffer.Read(b) + if readError != nil { + return 0, readError + } + + // We've delivered all unpolished data from the buffer, let's clear it out + // Read just moves the offset but leaves the data in place, we need to reset the buffer + if sconn.receiveBuffer.Len() == 0 { + sconn.receiveBuffer.Reset() + } + + return readLen, nil + } else { + result := make([]byte, len(b)) + + // Read the decrypted data into the provided slice "b" + readLen, readError := sconn.receiveBuffer.Read(result) + sconn.receiveBuffer.Reset() + if readError != nil { + return 0, readError + } + + stillNeeded := result[readLen:] + snReadLen, snReadError := sconn.Read(stillNeeded) + if snReadError != nil { + return 0, snReadError + } + + // Keep reading until we get the full requested length, or an error + for snReadLen < len(stillNeeded) { + // Keep reading, we didn't get enough data + stillNeeded = stillNeeded[snReadLen:] + snReadLen, snReadError = sconn.Read(stillNeeded) + if snReadError != nil { + return 0, snReadError + } + } + + copy(b, result) + return len(result), nil + } + } + + // Make sure to discard stale data by overwriting b with zeros + zeros := make([]byte, len(b)) + copy(b, zeros) + + chunkSize := sconn.state.polish.GetChunkSize() + polished := make([]byte, chunkSize) // Read encrypted data from the connection and put it into our polished slice - _, err := sconn.conn.Read(polished) - if err != nil { - return 0, err + connReadLen, connReadError := sconn.conn.Read(polished) + if connReadError != nil { + return 0, connReadError + } + + for connReadLen < chunkSize { + // Keep reading, we didn't get enough data + partialPolish := polished[connReadLen:] + connReadLen, connReadError = sconn.conn.Read(partialPolish) + if connReadError != nil { + return 0, connReadError + } } // Decrypt the data @@ -79,18 +168,23 @@ func (sconn *Connection) Read(b []byte) (int, error) { return 0, unpolishError } - // Empty the buffer and write the decrypted data to it - sconn.receiveBuffer.Reset() - sconn.receiveBuffer.Write(unpolished) + if len(unpolished) <= len(b) { + copy(b, unpolished) + return len(unpolished), nil + } else { + // This will copy only up to the length of b from unpolished to b + copy(b, unpolished) + + remainingUnpolished := unpolished[len(b):] - // Read the decrypted data into the provided slice "b" - _, readError := sconn.receiveBuffer.Read(b) - if readError != nil { - return 0, readError + // Empty the buffer and write the decrypted data to it + sconn.receiveBuffer.Reset() + sconn.receiveBuffer.Write(remainingUnpolished) + + // Return b, and leave the remaining unpolished in the buffer + return len(b), nil } - sconn.receiveBuffer.Reset() - return len(b), nil } else { // Read from the connection directly into the provided slice "b" return sconn.conn.Read(b) diff --git a/transports/Replicant/v2/replicant.go b/transports/Replicant/v2/replicant.go index c32f691..a778a56 100644 --- a/transports/Replicant/v2/replicant.go +++ b/transports/Replicant/v2/replicant.go @@ -1,7 +1,26 @@ /* - * Copyright (c) 2019, Operator Foundation - * - */ + MIT License + + Copyright (c) 2020 Operator Foundation + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ // Package replicant provides a PT 2.1 Go API implementation of the Replicant adversary-tunable transport package replicant diff --git a/transports/Replicant/v2/replicant_test.go b/transports/Replicant/v2/replicant_test.go index a93fc95..7985c07 100644 --- a/transports/Replicant/v2/replicant_test.go +++ b/transports/Replicant/v2/replicant_test.go @@ -72,7 +72,7 @@ func TestNilsMonotone(t *testing.T) { replicantConnection(clientConfig, serverConfig, t) } -func TestMarshalSilverRandomEnumeratedConfigs(t *testing.T) { +func MarshalSilverRandomEnumeratedConfigs(t *testing.T) { clientConfig, serverConfig := createSilverMonotoneConfigsRandomEnumeratedItems() clientConfigJsonString, clientConfigJsonError := clientConfig.Marshal() diff --git a/transports/Replicant/v2/toneburst/config.go b/transports/Replicant/v2/toneburst/config.go index 7bb520a..d32e905 100644 --- a/transports/Replicant/v2/toneburst/config.go +++ b/transports/Replicant/v2/toneburst/config.go @@ -1,3 +1,27 @@ +/* + MIT License + + Copyright (c) 2020 Operator Foundation + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + package toneburst type Config interface { diff --git a/transports/Replicant/v2/toneburst/monotone.go b/transports/Replicant/v2/toneburst/monotone.go index 1a2ea7f..5572fcd 100644 --- a/transports/Replicant/v2/toneburst/monotone.go +++ b/transports/Replicant/v2/toneburst/monotone.go @@ -1,3 +1,27 @@ +/* + MIT License + + Copyright (c) 2020 Operator Foundation + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + package toneburst import ( diff --git a/transports/Replicant/v2/toneburst/toneburst.go b/transports/Replicant/v2/toneburst/toneburst.go index a378bf5..345be1f 100644 --- a/transports/Replicant/v2/toneburst/toneburst.go +++ b/transports/Replicant/v2/toneburst/toneburst.go @@ -1,3 +1,27 @@ +/* + MIT License + + Copyright (c) 2020 Operator Foundation + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + package toneburst import ( diff --git a/transports/Replicant/v2/toneburst/whalesong.go b/transports/Replicant/v2/toneburst/whalesong.go index 2cf1dd1..611e4ca 100644 --- a/transports/Replicant/v2/toneburst/whalesong.go +++ b/transports/Replicant/v2/toneburst/whalesong.go @@ -1,3 +1,27 @@ +/* + MIT License + + Copyright (c) 2020 Operator Foundation + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + package toneburst import ( diff --git a/transports/meeklite/v2/LICENSE b/transports/meeklite/v2/LICENSE new file mode 100644 index 0000000..e69de29 diff --git a/transports/meekserver/v2/meek-server.go b/transports/meekserver/v2/meek-server.go index c4035f1..dbd64b0 100644 --- a/transports/meekserver/v2/meek-server.go +++ b/transports/meekserver/v2/meek-server.go @@ -162,7 +162,7 @@ func (a scrubbedAddr) String() string { return "[scrubbed]" } -// Replace the Addr in a net.OpError with "[scrubbed]" for golog. +// Replace the Addr in a net.OpError with "[scrubbed]" for logging. func scrubError(err error) error { if operr, ok := err.(*net.OpError); ok { // net.OpError contains Op, Net, Addr, and a subsidiary Err. The diff --git a/transports/meekserver/v2/pt21.go b/transports/meekserver/v2/pt21.go index 9aa7242..63c12b7 100644 --- a/transports/meekserver/v2/pt21.go +++ b/transports/meekserver/v2/pt21.go @@ -106,13 +106,13 @@ func (listener meekListener) Addr() net.Addr { } func (conn meekServerConn) Read(b []byte) (n int, err error) { - if len(conn.session.Or.readBuffer) == 0 { + if len(conn.session.Or.readBuffer) == 0 || len(b) == 0 { return 0, nil + } else { + copyLength := copy(b, conn.session.Or.readBuffer) + conn.session.Or.readBuffer = conn.session.Or.readBuffer[copyLength:] + return copyLength, nil } - copy(b, conn.session.Or.readBuffer) - conn.session.Or.readBuffer = conn.session.Or.readBuffer[:0] - - return len(b), nil } func (conn meekServerConn) Write(b []byte) (n int, err error) { diff --git a/transports/obfs2/v2/go.mod b/transports/obfs2/v2/go.mod index c6fcae7..acfdfab 100644 --- a/transports/obfs2/v2/go.mod +++ b/transports/obfs2/v2/go.mod @@ -4,7 +4,6 @@ go 1.12 require ( github.com/OperatorFoundation/obfs4 v1.0.0 - github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0 - + github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0 golang.org/x/net v0.0.0-20200226121028-0de0cce0169b ) diff --git a/transports/obfs2/v2/go.sum b/transports/obfs2/v2/go.sum index facf2e0..139977a 100644 --- a/transports/obfs2/v2/go.sum +++ b/transports/obfs2/v2/go.sum @@ -3,12 +3,12 @@ github.com/OperatorFoundation/ed25519 v0.0.0-20200225224545-b22b4bd3ddef h1:1xEt github.com/OperatorFoundation/ed25519 v0.0.0-20200225224545-b22b4bd3ddef/go.mod h1:gQNGvsyT4Zmps9H/yzCqdc+RQzt8ZxCndRNtGTYnBzQ= github.com/OperatorFoundation/obfs4 v1.0.0 h1:OcfdNMzv69fKQrLTkTSwpaBkHyBZMLjigA5M3txZpAg= github.com/OperatorFoundation/obfs4 v1.0.0/go.mod h1:6apgxOLYwyvbpzujpFHWu6Jlc+mjn1aFK7WvNijIVWc= -github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0 h1:zDYt6FDJwDSX4woVFVK2EMt7fkxU5L5qDNLUjQwA+BQ= -github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0/go.mod h1:kB00Ak8Dgn1uZlZHLc/WsUta58Jc+n/ZhCetcPkh42Q= +github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0 h1:6aQs+TF3KULMarpzbKu8DhFOF9D2UBCaAN5ZtbK53nQ= +github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0/go.mod h1:gb/QiZH0QDXLSQ9PskyJ2oTflB7tsP4AYc8y+FppvB0= github.com/dchest/siphash v1.2.1 h1:4cLinnzVJDKxTCl9B01807Yiy+W7ZzVHj/KIroQRvT4= github.com/dchest/siphash v1.2.1/go.mod h1:q+IRvb2gOSrUnYoPqHiyHXS0FOBBOdl6tONBlVnOnt4= - h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88= -/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= +github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88= +github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/willscott/goturn v0.0.0-20170802220503-19f41278d0c9/go.mod h1:PfwRjodCaQXOsHnh2DeVaXqCFCIrbn5WLj1+A5bQkD4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= diff --git a/transports/obfs2/v2/obfs2.go b/transports/obfs2/v2/obfs2.go index b57a779..2acc079 100644 --- a/transports/obfs2/v2/obfs2.go +++ b/transports/obfs2/v2/obfs2.go @@ -36,14 +36,16 @@ import ( "crypto/sha256" "encoding/binary" "fmt" + "log" + "io" "net" "time" - "golang.org/x/net/proxy" - "github.com/OperatorFoundation/obfs4/common/csrand" - "github.com/OperatorFoundation/shapeshifter-ipc" + "github.com/OperatorFoundation/shapeshifter-ipc/v2" + + "golang.org/x/net/proxy" ) const ( @@ -81,6 +83,7 @@ func (transport OptimizerTransport) Dial() (net.Conn, error) { transportConn, err := newObfs2ClientConn(conn) if err != nil { _ = dialConn.Close() + log.Fatalf("dial connection failed") return nil, err } @@ -90,6 +93,7 @@ func (transport OptimizerTransport) Dial() (net.Conn, error) { // Transport is the obfs2 implementation of the base.Transport interface. type Transport struct { dialer proxy.Dialer + } //New initializes obfs2 for Optimizer diff --git a/transports/obfs2/v2/obfs2_test.go b/transports/obfs2/v2/obfs2_test.go index 5205992..c118e07 100644 --- a/transports/obfs2/v2/obfs2_test.go +++ b/transports/obfs2/v2/obfs2_test.go @@ -32,7 +32,6 @@ package obfs2 import ( - "github.com/kataras/golog" "golang.org/x/net/proxy" "os" "testing" @@ -98,8 +97,7 @@ func TestObfs2WithDialer(t *testing.T) { } func TestObfs2OptimizerTransportWithDialer(t *testing.T) { - var log = golog.MustGetLogger("obfs2") - config := New("127.0.0.1:1237", proxy.Direct, log) + config := New("127.0.0.1:1237", proxy.Direct) //create client buffer clientBuffer := make([]byte, 4) //call dial on client and check error diff --git a/transports/obfs4/v2/go.mod b/transports/obfs4/v2/go.mod index 68baf42..1548034 100644 --- a/transports/obfs4/v2/go.mod +++ b/transports/obfs4/v2/go.mod @@ -4,7 +4,7 @@ go 1.12 require ( github.com/OperatorFoundation/obfs4 v1.0.0 - github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0 + github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0 golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d golang.org/x/net v0.0.0-20200226121028-0de0cce0169b ) diff --git a/transports/obfs4/v2/go.sum b/transports/obfs4/v2/go.sum index 8a6f976..76c4cd7 100644 --- a/transports/obfs4/v2/go.sum +++ b/transports/obfs4/v2/go.sum @@ -5,8 +5,12 @@ github.com/OperatorFoundation/obfs4 v1.0.0 h1:OcfdNMzv69fKQrLTkTSwpaBkHyBZMLjigA github.com/OperatorFoundation/obfs4 v1.0.0/go.mod h1:6apgxOLYwyvbpzujpFHWu6Jlc+mjn1aFK7WvNijIVWc= github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0 h1:zDYt6FDJwDSX4woVFVK2EMt7fkxU5L5qDNLUjQwA+BQ= github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0/go.mod h1:kB00Ak8Dgn1uZlZHLc/WsUta58Jc+n/ZhCetcPkh42Q= +github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0 h1:6aQs+TF3KULMarpzbKu8DhFOF9D2UBCaAN5ZtbK53nQ= +github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0/go.mod h1:gb/QiZH0QDXLSQ9PskyJ2oTflB7tsP4AYc8y+FppvB0= github.com/dchest/siphash v1.2.1 h1:4cLinnzVJDKxTCl9B01807Yiy+W7ZzVHj/KIroQRvT4= github.com/dchest/siphash v1.2.1/go.mod h1:q+IRvb2gOSrUnYoPqHiyHXS0FOBBOdl6tONBlVnOnt4= +github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88= +github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/willscott/goturn v0.0.0-20170802220503-19f41278d0c9/go.mod h1:PfwRjodCaQXOsHnh2DeVaXqCFCIrbn5WLj1+A5bQkD4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d h1:1ZiEyfaQIg3Qh0EoqpwAakHVhecoE5wlSg5GjnafJGw= diff --git a/transports/obfs4/v2/obfs4.go b/transports/obfs4/v2/obfs4.go index ecb0aeb..45afec5 100644 --- a/transports/obfs4/v2/obfs4.go +++ b/transports/obfs4/v2/obfs4.go @@ -1,29 +1,29 @@ /* - * Copyright (c) 2014, Yawning Angel - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ +* Copyright (c) 2014, Yawning Angel +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* +* * Redistributions of source code must retain the above copyright notice, +* this list of conditions and the following disclaimer. +* +* * Redistributions in binary form must reproduce the above copyright notice, +* this list of conditions and the following disclaimer in the documentation +* and/or other materials provided with the distribution. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +* POSSIBILITY OF SUCH DAMAGE. +*/ // Package obfs4 provides an implementation of the Tor Project's obfs4 // obfuscation protocol. @@ -39,7 +39,7 @@ import ( "github.com/OperatorFoundation/obfs4/common/ntor" "github.com/OperatorFoundation/obfs4/common/probdist" "github.com/OperatorFoundation/obfs4/common/replayfilter" - "github.com/OperatorFoundation/shapeshifter-ipc" + "github.com/OperatorFoundation/shapeshifter-ipc/v2" "github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2/framing" "golang.org/x/net/proxy" "math/rand" @@ -89,7 +89,7 @@ type Transport struct { //ServerFactory contains arguments for server side type ServerFactory struct { - args *pt.Args + args map[string]string nodeID *ntor.NodeID identityKey *ntor.Keypair @@ -112,8 +112,8 @@ type ClientArgs struct { //NewObfs4Server initializes the obfs4 server side func NewObfs4Server(stateDir string) (*Transport, error) { - args := make(pt.Args) - st, err := serverStateFromArgs(stateDir, &args) + args := make(map[string]string) + st, err := serverStateFromArgs(stateDir, args) if err != nil { return nil, err } @@ -129,10 +129,10 @@ func NewObfs4Server(stateDir string) (*Transport, error) { } // Store the arguments that should appear in our descriptor for the clients. - ptArgs := pt.Args{} - ptArgs.Add(certArg, st.cert.String()) + ptArgs := make(map[string]string) + ptArgs[certArg] = st.cert.String() log.Infof("certstring %s", certArg) - ptArgs.Add(iatArg, strconv.Itoa(st.iatMode)) + ptArgs[iatArg] = strconv.Itoa(st.iatMode) // Initialize the replay filter. filter, err := replayfilter.New(replayTTL) @@ -147,7 +147,7 @@ func NewObfs4Server(stateDir string) (*Transport, error) { } rng := rand.New(hashDrbg) - sf := &ServerFactory{&ptArgs, st.nodeID, st.identityKey, st.drbgSeed, iatSeed, st.iatMode, filter, rng.Intn(maxCloseDelayBytes), rng.Intn(maxCloseDelay)} + sf := &ServerFactory{ptArgs, st.nodeID, st.identityKey, st.drbgSeed, iatSeed, st.iatMode, filter, rng.Intn(maxCloseDelayBytes), rng.Intn(maxCloseDelay)} return &Transport{dialer: nil, serverFactory: sf, clientArgs: nil}, nil } diff --git a/transports/obfs4/v2/statefile.go b/transports/obfs4/v2/statefile.go index f0707de..c1f8e03 100644 --- a/transports/obfs4/v2/statefile.go +++ b/transports/obfs4/v2/statefile.go @@ -40,7 +40,6 @@ import ( "github.com/OperatorFoundation/obfs4/common/csrand" "github.com/OperatorFoundation/obfs4/common/drbg" "github.com/OperatorFoundation/obfs4/common/ntor" - "github.com/OperatorFoundation/shapeshifter-ipc" ) const ( @@ -113,14 +112,14 @@ func (st *obfs4ServerState) clientString() string { return fmt.Sprintf("%s=%s %s=%d", certArg, st.cert, iatArg, st.iatMode) } -func serverStateFromArgs(stateDir string, args *pt.Args) (*obfs4ServerState, error) { +func serverStateFromArgs(stateDir string, args map[string]string) (*obfs4ServerState, error) { var js jsonServerState var nodeIDOk, privKeyOk, seedOk bool - js.NodeID, nodeIDOk = args.Get(nodeIDArg) - js.PrivateKey, privKeyOk = args.Get(privateKeyArg) - js.DrbgSeed, seedOk = args.Get(seedArg) - iatStr, iatOk := args.Get(iatArg) + js.NodeID, nodeIDOk = args[nodeIDArg] + js.PrivateKey, privKeyOk = args[privateKeyArg] + js.DrbgSeed, seedOk = args[seedArg] + iatStr, iatOk := args[iatArg] // Either a private key, node id, and seed are ALL specified, or // they should be loaded from the state file. diff --git a/transports/shadow/v2/go.sum b/transports/shadow/v2/go.sum index 41a91f8..e71d517 100644 --- a/transports/shadow/v2/go.sum +++ b/transports/shadow/v2/go.sum @@ -1,5 +1,7 @@ github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da h1:KjTM2ks9d14ZYCvmHS9iAKVt9AyzRSqNU1qabPih5BY= github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da/go.mod h1:eHEWzANqSiWQsof+nXEI9bUVUyV6F53Fp89EuCh2EAA= +github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88= +github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/shadowsocks/go-shadowsocks2 v0.0.11 h1:dXloqEhYnZV40jblWTK8kWeC0Eb+dgql4S0tj99e8j0= github.com/shadowsocks/go-shadowsocks2 v0.0.11/go.mod h1:R+KWaoIwRRhnpw6XV+dZil0XHi64Hc1D7hXUyXTjUzQ= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= diff --git a/transports/shadow/v2/shadow.go b/transports/shadow/v2/shadow.go index c1bbb05..7e94b3e 100644 --- a/transports/shadow/v2/shadow.go +++ b/transports/shadow/v2/shadow.go @@ -26,10 +26,9 @@ package shadow import ( + shadowsocks "github.com/shadowsocks/go-shadowsocks2/core" "log" "net" - - shadowsocks "github.com/shadowsocks/go-shadowsocks2/core" ) //Config contains the necessary command like arguments to run shadow @@ -59,6 +58,7 @@ func NewTransport(password string, cipherName string, address string) Transport Password: password, CipherName: cipherName, Address: address, + } } @@ -97,7 +97,7 @@ func (config Config) Dial(address string) (net.Conn, error) { func (transport *Transport) Dial() (net.Conn, error) { cipher, err := shadowsocks.PickCipher(transport.CipherName, nil, transport.Password) if err != nil { - log.Fatal("Failed generating ciphers:", err) + log.Fatalf("Failed generating ciphers: %s", err) } return shadowsocks.Dial("tcp", transport.Address, cipher) diff --git a/transports/shadow/v2/shadow_test.go b/transports/shadow/v2/shadow_test.go index fb05dd1..f780093 100644 --- a/transports/shadow/v2/shadow_test.go +++ b/transports/shadow/v2/shadow_test.go @@ -94,3 +94,34 @@ func TestShadow(t *testing.T) { return } } + +func TestShadowTransport(t *testing.T) { + //create a server + transport := NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1236") + + //create client buffer + clientBuffer := make([]byte, 4) + //call dial on client and check error + clientConn, dialErr := transport.Dial() + if dialErr != nil { + fmt.Println("clientConn Dial error") + t.Fail() + return + } + + //write data from clientConn for server to read + _, clientWriteErr := clientConn.Write([]byte(data)) + if clientWriteErr != nil { + fmt.Println("client write error") + t.Fail() + return + } + + //read on client side + _, clientReadErr := clientConn.Read(clientBuffer) + if clientReadErr != nil { + fmt.Println("client read error") + t.Fail() + return + } +} From 43daf357babeb062b9cef885c33893a20be19d17 Mon Sep 17 00:00:00 2001 From: Bluesaxorcist Date: Mon, 10 Aug 2020 13:16:23 -0500 Subject: [PATCH 29/33] merging process --- transports/Dust/v3/Dust.go | 75 ++------- transports/Dust/v3/Dust_test.go | 85 +--------- transports/Dust/v3/LICENSE.md | 59 ++++--- transports/Dust/v3/go.mod | 3 +- transports/Dust/v3/go.sum | 5 - transports/Optimizer/v3/LICENSE | 6 +- transports/Optimizer/v3/Optimizer.go | 80 +++++---- transports/Optimizer/v3/Optimizer_test.go | 72 +++----- transports/Optimizer/v3/go.mod | 11 +- transports/Optimizer/v3/go.sum | 36 ++-- transports/Replicant/v3/LICENSE | 6 +- transports/Replicant/v3/Optimizer.go | 59 ++----- .../Replicant/v3/ReplicantClientConfig.json | 2 +- .../Replicant/v3/ReplicantClientConfig1.json | 2 +- .../Replicant/v3/ReplicantServerConfig.json | 2 +- .../Replicant/v3/ReplicantServerConfig1.json | 2 +- transports/Replicant/v3/config.go | 26 +-- transports/Replicant/v3/go.mod | 3 +- transports/Replicant/v3/go.sum | 4 - transports/Replicant/v3/persistence.go | 4 +- transports/Replicant/v3/persistence_test.go | 4 +- transports/Replicant/v3/polish/silver.go | 2 - transports/Replicant/v3/pt21.go | 114 ++++++++++--- transports/Replicant/v3/replicant.go | 4 +- transports/Replicant/v3/replicant_test.go | 149 +---------------- transports/meeklite/v3/LICENSE | 55 ------ transports/meeklite/v3/go.mod | 4 +- transports/meeklite/v3/go.sum | 16 +- transports/meeklite/v3/meeklite.go | 68 ++++---- transports/meeklite/v3/meeklite_test.go | 57 +------ transports/meekserver/v3/LICENSE | 55 ------ transports/meekserver/v3/certificate.go | 31 +--- transports/meekserver/v3/go.mod | 4 +- transports/meekserver/v3/go.sum | 7 +- transports/meekserver/v3/meek-server.go | 43 +---- transports/meekserver/v3/meekserver_test.go | 30 +--- transports/meekserver/v3/pt21.go | 147 ++-------------- transports/meekserver/v3/useraddr.go | 27 --- transports/obfs2/v3/LICENSE | 55 ------ transports/obfs2/v3/go.mod | 3 +- transports/obfs2/v3/go.sum | 9 +- transports/obfs2/v3/obfs2.go | 36 ++-- transports/obfs2/v3/obfs2_test.go | 11 +- transports/obfs4/v3/LICENSE | 55 ------ transports/obfs4/v3/go.mod | 3 +- transports/obfs4/v3/go.sum | 8 +- transports/obfs4/v3/handshake_ntor.go | 2 +- transports/obfs4/v3/obfs4.go | 158 +++++------------- transports/obfs4/v3/obfs4_test.go | 33 +--- transports/obfs4/v3/packet.go | 2 +- transports/obfs4/v3/test_utils.go | 129 +------------- transports/shadow/v3/LICENSE | 6 +- transports/shadow/v3/go.mod | 3 +- transports/shadow/v3/go.sum | 6 +- transports/shadow/v3/shadow.go | 51 ++---- transports/shadow/v3/shadow_test.go | 19 +-- 56 files changed, 457 insertions(+), 1491 deletions(-) delete mode 100644 transports/meekserver/v3/LICENSE delete mode 100644 transports/obfs2/v3/LICENSE delete mode 100644 transports/obfs4/v3/LICENSE diff --git a/transports/Dust/v3/Dust.go b/transports/Dust/v3/Dust.go index cb0f905..66c9eeb 100644 --- a/transports/Dust/v3/Dust.go +++ b/transports/Dust/v3/Dust.go @@ -1,32 +1,15 @@ package Dust /* - MIT License + * Copyright (c) 2019, Operator Foundation + * + */ - Copyright (c) 2020 Operator Foundation - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ +// Package Dust provides a PT 2.1 Go API wrapper around the Dust transport import ( "fmt" - "github.com/kataras/golog" + "github.com/OperatorFoundation/obfs4/common/log" "golang.org/x/net/proxy" "net" "time" @@ -38,7 +21,6 @@ import ( type dustClient struct { serverPubkey *Dust.ServerPublic dialer proxy.Dialer - Address string `json:"address"` } type dustServer struct { @@ -46,16 +28,16 @@ type dustServer struct { dialer proxy.Dialer } -func NewDustClient(serverPublic string, dialer proxy.Dialer, address string) *dustClient { +func NewDustClient(serverPublic string, dialer proxy.Dialer) *dustClient { unparsed := make(map[string]string) - unparsed["p"] = serverPublic + unparsed["p"]=serverPublic spub, err := Dust.ParseServerPublic(unparsed) if err != nil { return nil } - return &dustClient{serverPubkey: spub, dialer: dialer, Address: address} + return &dustClient{serverPubkey: spub, dialer: dialer} } type dustTransportListener struct { @@ -68,25 +50,13 @@ type Transport struct { ServerPublic string Address string Dialer proxy.Dialer - ServerConfig *dustServer } type Config struct { ServerPublic string `json:"server-public"` - Address string `json:"address"` -} - -func New(serverPublic string, address string, dialer proxy.Dialer, serverConfig *dustServer) Transport { - return Transport{ - ServerPublic: serverPublic, - Address: address, - Dialer: dialer, - ServerConfig: serverConfig, - } } - func (transport Transport) Dial() (net.Conn, error) { - dustTransport := NewDustClient(transport.ServerPublic, transport.Dialer, transport.Address) + dustTransport := NewDustClient(transport.ServerPublic, transport.Dialer) conn, err := dustTransport.Dial(transport.Address) if err != nil { return nil, err @@ -94,23 +64,6 @@ func (transport Transport) Dial() (net.Conn, error) { return conn, nil } } - -func (transport Transport) Listen() (net.Listener, error) { - addr, resolveErr := pt.ResolveAddr(transport.Address) - if resolveErr != nil { - fmt.Println(resolveErr.Error()) - return nil, resolveErr - } - - ln, err := net.ListenTCP("tcp", addr) - if err != nil { - fmt.Println(err.Error()) - return nil, err - } - - return newDustTransportListener(ln, transport.ServerConfig), nil -} - //end optimizer code func newDustTransportListener(listener *net.TCPListener, transport *dustServer) *dustTransportListener { @@ -128,7 +81,7 @@ func (transport *dustClient) Dial(address string) (net.Conn, error) { if err != nil { closeErr := conn.Close() if closeErr != nil { - golog.Error("could not close") + log.Errorf("could not close") } return conn, dialErr } @@ -137,20 +90,20 @@ func (transport *dustClient) Dial(address string) (net.Conn, error) { } // Create listener for incoming transport connection -func (transport *dustServer) Listen(address string) (net.Listener, error) { +func (transport *dustServer) Listen(address string) net.Listener { addr, resolveErr := pt.ResolveAddr(address) if resolveErr != nil { fmt.Println(resolveErr.Error()) - return nil, resolveErr + return nil } ln, err := net.ListenTCP("tcp", addr) if err != nil { fmt.Println(err.Error()) - return nil, err + return nil } - return newDustTransportListener(ln, transport), nil + return newDustTransportListener(ln, transport) } func (listener *dustTransportListener) Addr() net.Addr { diff --git a/transports/Dust/v3/Dust_test.go b/transports/Dust/v3/Dust_test.go index 71fe8d5..2aaacc5 100644 --- a/transports/Dust/v3/Dust_test.go +++ b/transports/Dust/v3/Dust_test.go @@ -7,32 +7,27 @@ package Dust // Package Dust provides a PT 2.1 Go API wrapper around the Dust transport + import ( - "github.com/kataras/golog" - "golang.org/x/net/proxy" - "os" "testing" ) const data = "test" func TestDust(t *testing.T) { - - MakeLog() //create a server serverConfig := dustServer{ serverPrivkey: nil, dialer: nil, } - clientConfig := dustClient{ serverPubkey: nil, dialer: nil, } //call listen on the server - serverListener, listenErr := serverConfig.Listen("127.0.0.1:1234") - if listenErr != nil { + serverListener := serverConfig.Listen("127.0.0.1:1234") + if serverListener == nil { t.Fail() return } @@ -87,77 +82,3 @@ func TestDust(t *testing.T) { return } } - -func TestDustV3(t *testing.T) { - - MakeLog() - - //create a server - serverConfig := dustServer{ - serverPrivkey: nil, - dialer: nil, - } - - transport := New("", "127.0.0.1:1234", proxy.Direct, &serverConfig) - //call listen on the server - serverListener, listenErr := transport.Listen() - if listenErr != nil { - t.Fail() - return - } - - //Create Server connection and format it for concurrency - go func() { - //create server buffer - serverBuffer := make([]byte, 4) - - //create serverConn - serverConn, acceptErr := serverListener.Accept() - if acceptErr != nil { - t.Fail() - return - } - - //read on server side - _, serverReadErr := serverConn.Read(serverBuffer) - if serverReadErr != nil { - t.Fail() - return - } - - //write data from serverConn for client to read - _, serverWriteErr := serverConn.Write([]byte(data)) - if serverWriteErr != nil { - t.Fail() - return - } - }() - - //create client buffer - clientBuffer := make([]byte, 4) - //call dial on client and check error - clientConn, dialErr := transport.Dial() - if dialErr != nil { - t.Fail() - return - } - - //write data from clientConn for server to read - _, clientWriteErr := clientConn.Write([]byte(data)) - if clientWriteErr != nil { - t.Fail() - return - } - - //read on client side - _, clientReadErr := clientConn.Read(clientBuffer) - if clientReadErr != nil { - t.Fail() - return - } -} - -func MakeLog() { - golog.SetLevel("debug") - golog.SetOutput(os.Stderr) -} \ No newline at end of file diff --git a/transports/Dust/v3/LICENSE.md b/transports/Dust/v3/LICENSE.md index 97e8749..f98047a 100644 --- a/transports/Dust/v3/LICENSE.md +++ b/transports/Dust/v3/LICENSE.md @@ -1,19 +1,40 @@ -Copyright (c) 2020 Operator Foundation - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +# Licenses for software included in this directory + +## Main Dust packages and first-party support packages + +The directories 'v2' and 'sillyHex' compose the main Dust packages for Go. The directories 'buf', 'huffman', 'model1', 'prim1', and 'proc' compose the first-party support packages. These are all subject to the following terms: + +* Copyright © 2015 Drake Wilson <drake@dasyatidae.com> + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +## Skein + +The directory 'skein' contains a modified version of Dmitry Chestnykh's Skein-512 code. It is subject to the following terms: + +* Copyright © 2012 Dmitry Chestnykh <dmitry@codingrobots.com> +* Copyright © 2015 Drake Wilson <drake@dasyatidae.com> +* All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +## Dist + +The directory 'dist' contains a local copy of the random distribution code from gonum. + +(TODO: copy appropriate file for this here) + + diff --git a/transports/Dust/v3/go.mod b/transports/Dust/v3/go.mod index b3c6090..2a6a0aa 100644 --- a/transports/Dust/v3/go.mod +++ b/transports/Dust/v3/go.mod @@ -1,4 +1,4 @@ -module github.com/OperatorFoundation/shapeshifter-transports/transports/Dust/v3 +module github.com/OperatorFoundation/shapeshifter-transports/transports/Dust/v2 go 1.12 @@ -7,6 +7,5 @@ require ( github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0 github.com/blanu/Dust v1.0.1 // indirect github.com/blanu/Dust/go/v2/interface v1.0.1 - github.com/kataras/golog v0.0.18 golang.org/x/net v0.0.0-20200226121028-0de0cce0169b ) diff --git a/transports/Dust/v3/go.sum b/transports/Dust/v3/go.sum index 799dbcf..dd89648 100644 --- a/transports/Dust/v3/go.sum +++ b/transports/Dust/v3/go.sum @@ -11,10 +11,6 @@ github.com/blanu/Dust v1.0.1/go.mod h1:jLFQI2Ufz4kBnGiTzh8O9+/p4U/9MLbouXkaympnT github.com/blanu/Dust/go/v2/interface v1.0.1 h1:lIQrNXljx8vgTTwB+gObrkA6jBhokmgH/uHp1OxbqxE= github.com/blanu/Dust/go/v2/interface v1.0.1/go.mod h1:0NnpBd5fkRrG2I/pf6bcUaL5jpp84LeShsQzn4gCOCw= github.com/dchest/siphash v1.2.1/go.mod h1:q+IRvb2gOSrUnYoPqHiyHXS0FOBBOdl6tONBlVnOnt4= -github.com/kataras/golog v0.0.18 h1:Td7hcKN25yzqB/0SO5iohOsMk5Mq5V9kDtM5apaJLY0= -github.com/kataras/golog v0.0.18/go.mod h1:jRYl7dFYqP8aQj9VkwdBUXYZSfUktm+YYg1arJILfyw= -github.com/kataras/pio v0.0.8 h1:6pX6nHJk7DAV3x1dEimibQF2CmJLlo0jWVmM9yE9KY8= -github.com/kataras/pio v0.0.8/go.mod h1:NFfMp2kVP1rmV4N6gH6qgWpuoDKlrOeYi3VrAIWCGsE= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/willscott/goturn v0.0.0-20170802220503-19f41278d0c9/go.mod h1:PfwRjodCaQXOsHnh2DeVaXqCFCIrbn5WLj1+A5bQkD4= @@ -26,6 +22,5 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20200226121028-0de0cce0169b h1:0mm1VjtFUOIlE1SbDlwjYaDxZVDP2S5ou6y0gSgXHu8= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/transports/Optimizer/v3/LICENSE b/transports/Optimizer/v3/LICENSE index 97e8749..dfad7b5 100644 --- a/transports/Optimizer/v3/LICENSE +++ b/transports/Optimizer/v3/LICENSE @@ -1,3 +1,5 @@ +MIT License + Copyright (c) 2020 Operator Foundation Permission is hereby granted, free of charge, to any person obtaining a copy @@ -12,8 +14,8 @@ copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +SOFTWARE. diff --git a/transports/Optimizer/v3/Optimizer.go b/transports/Optimizer/v3/Optimizer.go index f9daefb..49d06cf 100644 --- a/transports/Optimizer/v3/Optimizer.go +++ b/transports/Optimizer/v3/Optimizer.go @@ -33,23 +33,19 @@ import ( const timeoutInSeconds = 60 -//TransportDialer is a program that transforms network traffic -type TransportDialer interface { +//Transport is a program that transforms network traffic +type Transport interface { Dial() (net.Conn, error) } -type TransportListener interface { - Listen() (net.Listener, error) -} - //Client contains the two parameters needed to use Optimizer. type Client struct { - Transports []TransportDialer + Transports []Transport Strategy Strategy } //NewOptimizerClient is the initializer -func NewOptimizerClient(Transports []TransportDialer, Strategy Strategy) *Client { +func NewOptimizerClient(Transports []Transport, Strategy Strategy) *Client { return &Client{Transports, Strategy} } @@ -77,63 +73,63 @@ func (OptT *Client) Dial() (net.Conn, error) { //Strategy is the method used to choose a transport type Strategy interface { - Choose() TransportDialer - Report(transport TransportDialer, success bool, durationElapsed float64) + Choose() Transport + Report(transport Transport, success bool, durationElapsed float64) } //FirstStrategy returns the first strategy in the array type FirstStrategy struct { - transports []TransportDialer + transports []Transport } //NewFirstStrategy initializes FirstStrategy -func NewFirstStrategy(transports []TransportDialer) Strategy { +func NewFirstStrategy(transports []Transport) Strategy { return &FirstStrategy{transports} } //Choose selects a transport in the array -func (strategy *FirstStrategy) Choose() TransportDialer { +func (strategy *FirstStrategy) Choose() Transport { return strategy.transports[0] } //Report returns if the transport was successful and how long the connection took -func (strategy *FirstStrategy) Report(TransportDialer, bool, float64) { +func (strategy *FirstStrategy) Report(Transport, bool, float64) { } //NewRandomStrategy initializes RandomStrategy -func NewRandomStrategy(transports []TransportDialer) Strategy { +func NewRandomStrategy(transports []Transport) Strategy { return &RandomStrategy{transports} } //RandomStrategy returns a transport at random type RandomStrategy struct { - transports []TransportDialer + transports []Transport } //Choose selects a transport in the array -func (strategy *RandomStrategy) Choose() TransportDialer { +func (strategy *RandomStrategy) Choose() Transport { return strategy.transports[0] } //Report returns if the transport was successful and how long the connection took -func (strategy *RandomStrategy) Report(TransportDialer, bool, float64) { +func (strategy *RandomStrategy) Report(Transport, bool, float64) { } //NewRotateStrategy initializes RotateStrategy -func NewRotateStrategy(transports []TransportDialer) Strategy { +func NewRotateStrategy(transports []Transport) Strategy { return &RotateStrategy{transports, 1} } //RotateStrategy cycles through the list of transports, using a different one each time type RotateStrategy struct { - transports []TransportDialer + transports []Transport index int } //Choose selects a transport in the array -func (strategy *RotateStrategy) Choose() TransportDialer { +func (strategy *RotateStrategy) Choose() Transport { transport := strategy.transports[strategy.index] strategy.index++ if strategy.index >= len(strategy.transports) { @@ -143,7 +139,7 @@ func (strategy *RotateStrategy) Choose() TransportDialer { } //Report returns if the transport was successful and how long the connection took -func (strategy *RotateStrategy) Report(TransportDialer, bool, float64) { +func (strategy *RotateStrategy) Report(Transport, bool, float64) { } @@ -151,19 +147,19 @@ func (strategy *RotateStrategy) Report(TransportDialer, bool, float64) { //choose the best option type TrackStrategy struct { index int - trackMap map[TransportDialer]int - transport []TransportDialer + trackMap map[Transport]int + transport []Transport } //NewTrackStrategy initializes TrackStrategy -func NewTrackStrategy(transport []TransportDialer) Strategy { - track := TrackStrategy{0, map[TransportDialer]int{}, transport} - track.trackMap = make(map[TransportDialer]int) +func NewTrackStrategy(transport []Transport) Strategy { + track := TrackStrategy{0, map[Transport]int{}, transport} + track.trackMap = make(map[Transport]int) return &track } //Choose selects a transport in the array -func (strategy *TrackStrategy) Choose() TransportDialer { +func (strategy *TrackStrategy) Choose() Transport { transport := strategy.transport[strategy.index] score := strategy.findScore(strategy.transport) startIndex := strategy.index @@ -181,7 +177,7 @@ func (strategy *TrackStrategy) Choose() TransportDialer { } //findScore is used to find the score given to each transport based on performance -func (strategy *TrackStrategy) findScore(transports []TransportDialer) int { +func (strategy *TrackStrategy) findScore(transports []Transport) int { transport := transports[strategy.index] score, ok := strategy.trackMap[transport] if ok { @@ -192,7 +188,7 @@ func (strategy *TrackStrategy) findScore(transports []TransportDialer) int { } //incrementIndex is used to cycle through the transport index -func (strategy *TrackStrategy) incrementIndex(transports []TransportDialer) { +func (strategy *TrackStrategy) incrementIndex(transports []Transport) { strategy.index++ if strategy.index >= len(transports) { strategy.index = 0 @@ -200,7 +196,7 @@ func (strategy *TrackStrategy) incrementIndex(transports []TransportDialer) { } //Report returns if the transport was successful and how long the connection took -func (strategy *TrackStrategy) Report(transport TransportDialer, success bool, _ float64) { +func (strategy *TrackStrategy) Report(transport Transport, success bool, _ float64) { if success { strategy.trackMap[transport] = 1 } else { @@ -211,19 +207,19 @@ func (strategy *TrackStrategy) Report(transport TransportDialer, success bool, _ //minimizeDialDuration is used to find the transport with the fastest response time type minimizeDialDuration struct { index int - trackMap map[TransportDialer]float64 - transports []TransportDialer + trackMap map[Transport]float64 + transports []Transport } //NewMinimizeDialDuration initializes minimizeDialDuration -func NewMinimizeDialDuration(transport []TransportDialer) Strategy { - duration := minimizeDialDuration{0, map[TransportDialer]float64{}, transport} - duration.trackMap = make(map[TransportDialer]float64) +func NewMinimizeDialDuration(transport []Transport) Strategy { + duration := minimizeDialDuration{0, map[Transport]float64{}, transport} + duration.trackMap = make(map[Transport]float64) return &duration } //Choose selects a transport in the array -func (strategy *minimizeDialDuration) Choose() TransportDialer { +func (strategy *minimizeDialDuration) Choose() Transport { transport := strategy.transports[strategy.index] score := strategy.findScore(strategy.transports) startIndex := strategy.index @@ -247,7 +243,7 @@ func (strategy *minimizeDialDuration) Choose() TransportDialer { } //incrementIndex is used to cycle through the transport index -func (strategy *minimizeDialDuration) incrementIndex(transports []TransportDialer) { +func (strategy *minimizeDialDuration) incrementIndex(transports []Transport) { strategy.index++ if strategy.index >= len(transports) { strategy.index = 0 @@ -255,7 +251,7 @@ func (strategy *minimizeDialDuration) incrementIndex(transports []TransportDiale } //findScore is used to find the score given to each transport based on performance -func (strategy *minimizeDialDuration) findScore(transports []TransportDialer) float64 { +func (strategy *minimizeDialDuration) findScore(transports []Transport) float64 { transport := transports[strategy.index] score, ok := strategy.trackMap[transport] if ok { @@ -266,7 +262,7 @@ func (strategy *minimizeDialDuration) findScore(transports []TransportDialer) fl } //Report returns if the transport was successful and how long the connection took -func (strategy *minimizeDialDuration) Report(transport TransportDialer, success bool, durationElapsed float64) { +func (strategy *minimizeDialDuration) Report(transport Transport, success bool, durationElapsed float64) { if success { if durationElapsed < 60 { strategy.trackMap[transport] = durationElapsed @@ -279,9 +275,9 @@ func (strategy *minimizeDialDuration) Report(transport TransportDialer, success } //minDuration assigns a value to the response time -func (strategy *minimizeDialDuration) minDuration() TransportDialer { +func (strategy *minimizeDialDuration) minDuration() Transport { min := 61.0 - var transport TransportDialer = nil + var transport Transport = nil for key, value := range strategy.trackMap { if value < min { min = value diff --git a/transports/Optimizer/v3/Optimizer_test.go b/transports/Optimizer/v3/Optimizer_test.go index 600590b..2d13bc3 100644 --- a/transports/Optimizer/v3/Optimizer_test.go +++ b/transports/Optimizer/v3/Optimizer_test.go @@ -1,11 +1,11 @@ package optimizer import ( - "github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3" - "github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3" - "github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3" - "github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3" - "github.com/kataras/golog" + "github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v2" + "github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v2" + "github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2" + "github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v2" + "golang.org/x/net/proxy" "io/ioutil" "net" @@ -21,11 +21,8 @@ import ( const data = "test" func TestMain(m *testing.M) { - config := shadow.NewServerConfig("1234", "CHACHA20-IETF-POLY1305") - listener, listenErr := config.Listen("127.0.0.1:1235") - if listenErr != nil { - return - } + config := shadow.NewConfig("1234", "CHACHA20-IETF-POLY1305") + listener := config.Listen("127.0.0.1:1235") go acceptConnections(listener) _ = obfs4.RunLocalObfs4Server("test") @@ -45,13 +42,12 @@ func acceptConnections(listener net.Listener) { } func TestMeekliteDial(t *testing.T) { - MakeLog() unparsedURL := "https://d2zfqthxsdq309.cloudfront.net/" URL, parseErr := url.Parse(unparsedURL) if parseErr != nil { t.Fail() } - meekliteTransport := meeklite.Transport{URL: URL, Front: "a0.awsstatic.com"} + meekliteTransport := meeklite.Transport{URL: URL, Front: "a0.awsstatic.com", Address: "127.0.0.1:1235" } _, err := meekliteTransport.Dial() if err != nil { t.Fail() @@ -59,14 +55,13 @@ func TestMeekliteDial(t *testing.T) { } func TestOptimizerMeekliteDial(t *testing.T) { - MakeLog() unparsedURL := "https://d2zfqthxsdq309.cloudfront.net/" URL, parseErr := url.Parse(unparsedURL) if parseErr != nil { t.Fail() } - meekliteTransport := meeklite.Transport{URL: URL, Front: "a0.awsstatic.com"} - transports := []TransportDialer{meekliteTransport} + meekliteTransport := meeklite.Transport{URL: URL, Front: "a0.awsstatic.com", Address: "127.0.0.1:1235" } + transports := []Transport{meekliteTransport} strategy := NewFirstStrategy(transports) optimizerTransport := NewOptimizerClient(transports, strategy) _, err := optimizerTransport.Dial() @@ -76,7 +71,6 @@ func TestOptimizerMeekliteDial(t *testing.T) { } func TestShadowDial(t *testing.T) { - MakeLog() shadowTransport := shadow.Transport{Password: "1234", CipherName: "CHACHA20-IETF-POLY1305", Address: "127.0.0.1:1235"} _, err := shadowTransport.Dial() if err != nil { @@ -85,9 +79,8 @@ func TestShadowDial(t *testing.T) { } func TestOptimizerShadowDial(t *testing.T) { - MakeLog() shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235") - transports := []TransportDialer{&shadowTransport} + transports := []Transport{&shadowTransport} strategy := NewFirstStrategy(transports) optimizerTransport := NewOptimizerClient(transports, strategy) _, err := optimizerTransport.Dial() @@ -97,9 +90,8 @@ func TestOptimizerShadowDial(t *testing.T) { } func TestOptimizerObfs2Dial(t *testing.T) { - MakeLog() obfs2Transport := obfs2.New("127.0.0.1:1237", proxy.Direct) - transports := []TransportDialer{obfs2Transport} + transports := []Transport{obfs2Transport} strategy := NewFirstStrategy(transports) optimizerTransport := NewOptimizerClient(transports, strategy) _, err := optimizerTransport.Dial() @@ -109,7 +101,6 @@ func TestOptimizerObfs2Dial(t *testing.T) { } func TestObfs4Transport_Dial(t *testing.T) { - MakeLog() obfs4Transport, transportErr := obfs4.RunObfs4Client() if transportErr != nil { t.Fail() @@ -122,19 +113,18 @@ func TestObfs4Transport_Dial(t *testing.T) { } func TestOptimizerObfs4Transport_Dial(t *testing.T) { - MakeLog() dialer := proxy.Direct certstring, certError := getObfs4CertString() if certError != nil { t.Fail() return } - obfs4Transport := obfs4.TransportClient{ + obfs4Transport := obfs4.OptimizerTransport{ CertString: *certstring, IatMode: 0, Address: "127.0.0.1:1234", Dialer: dialer} - transports := []TransportDialer{obfs4Transport} + transports := []Transport{obfs4Transport} strategy := NewFirstStrategy(transports) optimizerTransport := NewOptimizerClient(transports, strategy) _, err := optimizerTransport.Dial() @@ -144,20 +134,19 @@ func TestOptimizerObfs4Transport_Dial(t *testing.T) { } func TestOptimizerTransportFirstDial(t *testing.T) { - MakeLog() dialer := proxy.Direct certstring, certError := getObfs4CertString() if certError != nil { t.Fail() return } - obfs4Transport := obfs4.TransportClient{ + obfs4Transport := obfs4.OptimizerTransport{ CertString: *certstring, IatMode: 0, Address: "127.0.0.1:1234", Dialer: dialer} shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235") - transports := []TransportDialer{obfs4Transport, &shadowTransport} + transports := []Transport{obfs4Transport, &shadowTransport} strategy := NewFirstStrategy(transports) optimizerTransport := NewOptimizerClient(transports, strategy) for i := 1; i <= 3; i++ { @@ -169,21 +158,20 @@ func TestOptimizerTransportFirstDial(t *testing.T) { } func TestOptimizerTransportRandomDial(t *testing.T) { - MakeLog() dialer := proxy.Direct certstring, certError := getObfs4CertString() if certError != nil { t.Fail() return } - obfs4Transport := obfs4.TransportClient{ + obfs4Transport := obfs4.OptimizerTransport{ CertString: *certstring, IatMode: 0, Address: "127.0.0.1:1234", Dialer: dialer, } shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235") - transports := []TransportDialer{obfs4Transport, &shadowTransport} + transports := []Transport{obfs4Transport, &shadowTransport} strategy := NewRandomStrategy(transports) optimizerTransport := NewOptimizerClient(transports, strategy) @@ -196,21 +184,20 @@ func TestOptimizerTransportRandomDial(t *testing.T) { } func TestOptimizerTransportRotateDial(t *testing.T) { - MakeLog() dialer := proxy.Direct certstring, certError := getObfs4CertString() if certError != nil { t.Fail() return } - obfs4Transport := obfs4.TransportClient{ + obfs4Transport := obfs4.OptimizerTransport{ CertString: *certstring, IatMode: 0, Address: "127.0.0.1:1234", Dialer: dialer, } shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235") - transports := []TransportDialer{obfs4Transport, &shadowTransport} + transports := []Transport{obfs4Transport, &shadowTransport} strategy := NewRotateStrategy(transports) optimizerTransport := NewOptimizerClient(transports, strategy) @@ -223,21 +210,20 @@ func TestOptimizerTransportRotateDial(t *testing.T) { } func TestOptimizerTransportTrackDial(t *testing.T) { - MakeLog() dialer := proxy.Direct certstring, certError := getObfs4CertString() if certError != nil { t.Fail() return } - obfs4Transport := obfs4.TransportClient{ + obfs4Transport := obfs4.OptimizerTransport{ CertString: *certstring, IatMode: 0, Address: "127.0.0.1:1234", Dialer: dialer, } shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235") - transports := []TransportDialer{obfs4Transport, &shadowTransport} + transports := []Transport{obfs4Transport, &shadowTransport} strategy := NewTrackStrategy(transports) optimizerTransport := NewOptimizerClient(transports, strategy) @@ -250,21 +236,20 @@ func TestOptimizerTransportTrackDial(t *testing.T) { } func TestOptimizerTransportMinimizeDialDurationDial(t *testing.T) { - MakeLog() dialer := proxy.Direct certstring, certError := getObfs4CertString() if certError != nil { t.Fail() return } - obfs4Transport := obfs4.TransportClient{ + obfs4Transport := obfs4.OptimizerTransport{ CertString: *certstring, IatMode: 0, Address: "127.0.0.1:1234", Dialer: dialer, } shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235") - transports := []TransportDialer{obfs4Transport, &shadowTransport} + transports := []Transport{obfs4Transport, &shadowTransport} strategy := NewMinimizeDialDuration(transports) optimizerTransport := NewOptimizerClient(transports, strategy) @@ -310,8 +295,8 @@ func RunLocalObfs2Server() { config := obfs2.NewObfs2Transport() //call listen on the server - serverListener, listenErr := config.Listen("127.0.0.1:1237") - if listenErr != nil { + serverListener := config.Listen("127.0.0.1:1237") + if serverListener == nil { return } @@ -340,9 +325,4 @@ func RunLocalObfs2Server() { } } }() -} - -func MakeLog() { - golog.SetLevel("debug") - golog.SetOutput(os.Stderr) } \ No newline at end of file diff --git a/transports/Optimizer/v3/go.mod b/transports/Optimizer/v3/go.mod index 1ec247f..7f791ae 100644 --- a/transports/Optimizer/v3/go.mod +++ b/transports/Optimizer/v3/go.mod @@ -1,12 +1,11 @@ -module github.com/OperatorFoundation/shapeshifter-transports/transports/Optimizer/v3 +module github.com/OperatorFoundation/shapeshifter-transports/transports/Optimizer/v2 go 1.12 require ( - github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3 v3.0.11 - github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 v3.0.11 - github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 v3.0.11 - github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 v3.0.11 - github.com/kataras/golog v0.0.18 + github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v2 v2.2.5 + github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v2 v2.2.5 + github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2 v2.2.5 + github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v2 v2.2.5 golang.org/x/net v0.0.0-20200226121028-0de0cce0169b ) diff --git a/transports/Optimizer/v3/go.sum b/transports/Optimizer/v3/go.sum index f3f9cb8..7927a9a 100644 --- a/transports/Optimizer/v3/go.sum +++ b/transports/Optimizer/v3/go.sum @@ -5,34 +5,24 @@ github.com/OperatorFoundation/obfs4 v1.0.0 h1:OcfdNMzv69fKQrLTkTSwpaBkHyBZMLjigA github.com/OperatorFoundation/obfs4 v1.0.0/go.mod h1:6apgxOLYwyvbpzujpFHWu6Jlc+mjn1aFK7WvNijIVWc= github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0 h1:6aQs+TF3KULMarpzbKu8DhFOF9D2UBCaAN5ZtbK53nQ= github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0/go.mod h1:gb/QiZH0QDXLSQ9PskyJ2oTflB7tsP4AYc8y+FppvB0= -github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3 v3.0.6 h1:CzFbaRDdcg1xXxIa+N20StrDN8P0hGfoBOv+Idfepn4= -github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3 v3.0.6/go.mod h1:gW1GFU+PS/+snW7IK7gcObExPKCzsvIL1z2g9N/5ubM= -github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3 v3.0.10 h1:D2CK7Vbr7eh7Z+2npal98SaXfqQvhWFptyskmnh3+cQ= -github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3 v3.0.10/go.mod h1:wQZC/2AdEDj3fnuI0Bu0dL1kvUeaE7MvoyeLlLu2nfQ= -github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 v3.0.6 h1:xmos+1ED0y2UbqtEXGxtcxIqTDGPuw0te5Obqlspj9s= -github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 v3.0.6/go.mod h1:i8hkRv+UCu0YbOll8NqoDzDBsRR6XgMa1bykKsTUxTg= -github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 v3.0.10 h1:hKOpe/wHRjIdv10ZWarm3hebce6BtfMpxsr9ZRS+ei0= -github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 v3.0.10/go.mod h1:nnE7S0srPoXZDatJ7sTWhClwo/3vyMXykSDPHAdi2xo= -github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 v3.0.6 h1:/aEcDgGu3VA+gndxMv02LvfbZ6rg0lUYYnPkTlbgaSM= -github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 v3.0.6/go.mod h1:jdYrSKfsppvvtY/WHSL2mN2FdFNiQ7S/XzQxrty0+2I= -github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 v3.0.10 h1:ATbRmWxRg7AHAGgU54DPrVpiy7zteqhCQYXc1T/U0Po= -github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 v3.0.10/go.mod h1:k1ga949kVeIGplqIb1lBE8Qi957Om/bz/GDMymQr+kA= -github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 v3.0.6 h1:nqdVkCLaotgyabOWXf+sVLrGDQTRt8HqAAT/EZwysLM= -github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 v3.0.6/go.mod h1:EQS0MxXaaSQO2IoAwVyXsgx7RBWL6Yy+gMiEn2YJRbo= -github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 v3.0.10 h1:rRRsTQycB1WeVGZSbgfTn0R9woiCi1RpyFEYoRU8uLo= -github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 v3.0.10/go.mod h1:eI5kZwV2A9NBKB3UgzjY1ThIsV2sSUETBmjGbPncaf0= +github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v2 v2.2.5 h1:EqRoJz0kdLmnxpaOv6PbXRJohdbIvio6FkYkyWs2U0w= +github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v2 v2.2.5/go.mod h1:DEfaE6lfJKEG5CkCRks4rXTMi1xYwbYR0sa+JKsgsr0= +github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v2 v2.2.5 h1:AcAPnmUoi9qsK5vOQUvJIM7+YXtaLDhfOiBz8EA9bGM= +github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v2 v2.2.5/go.mod h1:W9OJqDkmHbSB86NOlGqECLDtSvr9MoVVlYrvjFqBMG0= +github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2 v2.2.5 h1:NudLXkarpDevMLpW/s081LHDwTmKURMCHZ67ZNSXWBc= +github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2 v2.2.5/go.mod h1:WbvdPacTr1IvoVsd9fYk4sDaWoxxCZIQDks9jRveRC0= +github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v2 v2.2.5 h1:DsKNTTXO/rjm/y8wG/0wUZ3KSFx+OqU1UuYzIHN0m0Q= +github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v2 v2.2.5/go.mod h1:GN8ahnEHVGcPbR0raxdpWekjgElppspPNAAOpmNxQxU= github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da h1:KjTM2ks9d14ZYCvmHS9iAKVt9AyzRSqNU1qabPih5BY= github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da/go.mod h1:eHEWzANqSiWQsof+nXEI9bUVUyV6F53Fp89EuCh2EAA= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dchest/siphash v1.2.1 h1:4cLinnzVJDKxTCl9B01807Yiy+W7ZzVHj/KIroQRvT4= github.com/dchest/siphash v1.2.1/go.mod h1:q+IRvb2gOSrUnYoPqHiyHXS0FOBBOdl6tONBlVnOnt4= -github.com/kataras/golog v0.0.18 h1:Td7hcKN25yzqB/0SO5iohOsMk5Mq5V9kDtM5apaJLY0= -github.com/kataras/golog v0.0.18/go.mod h1:jRYl7dFYqP8aQj9VkwdBUXYZSfUktm+YYg1arJILfyw= -github.com/kataras/pio v0.0.8 h1:6pX6nHJk7DAV3x1dEimibQF2CmJLlo0jWVmM9yE9KY8= -github.com/kataras/pio v0.0.8/go.mod h1:NFfMp2kVP1rmV4N6gH6qgWpuoDKlrOeYi3VrAIWCGsE= -github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88= -github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/shadowsocks/go-shadowsocks2 v0.0.11 h1:dXloqEhYnZV40jblWTK8kWeC0Eb+dgql4S0tj99e8j0= github.com/shadowsocks/go-shadowsocks2 v0.0.11/go.mod h1:R+KWaoIwRRhnpw6XV+dZil0XHi64Hc1D7hXUyXTjUzQ= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/willscott/goturn v0.0.0-20170802220503-19f41278d0c9/go.mod h1:PfwRjodCaQXOsHnh2DeVaXqCFCIrbn5WLj1+A5bQkD4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d h1:1ZiEyfaQIg3Qh0EoqpwAakHVhecoE5wlSg5GjnafJGw= @@ -45,3 +35,5 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/transports/Replicant/v3/LICENSE b/transports/Replicant/v3/LICENSE index 97e8749..dfad7b5 100644 --- a/transports/Replicant/v3/LICENSE +++ b/transports/Replicant/v3/LICENSE @@ -1,3 +1,5 @@ +MIT License + Copyright (c) 2020 Operator Foundation Permission is hereby granted, free of charge, to any person obtaining a copy @@ -12,8 +14,8 @@ copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +SOFTWARE. diff --git a/transports/Replicant/v3/Optimizer.go b/transports/Replicant/v3/Optimizer.go index c51db1d..9d1fd2e 100644 --- a/transports/Replicant/v3/Optimizer.go +++ b/transports/Replicant/v3/Optimizer.go @@ -25,41 +25,19 @@ package replicant import ( - pt "github.com/OperatorFoundation/shapeshifter-ipc/v2" "golang.org/x/net/proxy" "net" ) // This makes Replicant compliant with Optimizer -type TransportClient struct { +type Transport struct { Config ClientConfig Address string Dialer proxy.Dialer } -type TransportServer struct { - Config ServerConfig - Address string - Dialer proxy.Dialer -} - -func NewClient(config ClientConfig, dialer proxy.Dialer) TransportClient { - return TransportClient{ - Config: config, - Address: config.Address, - Dialer: dialer, - } -} - -func NewServer(config ServerConfig, address string, dialer proxy.Dialer) TransportServer { - return TransportServer{ - Config: config, - Address: address, - Dialer: dialer, - } -} - -func (transport TransportClient) Dial() (net.Conn, error) { +// TODO: the dial we call currently does not return an error +func (transport Transport) Dial() (net.Conn, error) { conn, dialErr := transport.Dialer.Dial("tcp", transport.Address) if dialErr != nil { return nil, dialErr @@ -73,28 +51,15 @@ func (transport TransportClient) Dial() (net.Conn, error) { } return transportConn, nil -} - -func (transport TransportServer) Listen() (net.Listener, error) { - addr, resolveErr := pt.ResolveAddr(transport.Address) - if resolveErr != nil { - return nil, resolveErr - } - - ln, err := net.ListenTCP("tcp", addr) - if err != nil { - return nil, err - } - return newReplicantTransportListener(ln, transport.Config), nil + //replicantTransport := New(transport.Config, transport.Dialer) + //conn := replicantTransport.Dial(transport.Address) + //conn, err:= replicantTransport.Dial(transport.Address), errors.New("connection failed") + //if err != nil { + // return nil, err + //} else { + // return conn, nil + //} + //return conn, nil } -//replicantTransport := New(transport.Config, transport.Dialer) -//conn := replicantTransport.Dial(transport.Address) -//conn, err:= replicantTransport.Dial(transport.Address), errors.New("connection failed") -//if err != nil { -// return nil, err -//} else { -// return conn, nil -//} -//return conn, nil diff --git a/transports/Replicant/v3/ReplicantClientConfig.json b/transports/Replicant/v3/ReplicantClientConfig.json index b710236..88064b9 100644 --- a/transports/Replicant/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29tL09wZXJhdG9yRm91bmRhdGlvbi9tb25vbGl0aC1nby9tb25vbGl0aC5GaXhlZEJ5dGVUeXBl/50DAQENRml4ZWRCeXRlVHlwZQH/ngABAQEEQnl0ZQEGAAAAB/+eAwETAAAAAQAAAgEAAW1naXRodWIuY29tL09wZXJhdG9yRm91bmRhdGlvbi9zaGFwZXNoaWZ0ZXItdHJhbnNwb3J0cy90cmFuc3BvcnRzL1JlcGxpY2FudC92Mi9wb2xpc2guU2lsdmVyUG9saXNoQ2xpZW50Q29uZmln/4cDAQEYU2lsdmVyUG9saXNoQ2xpZW50Q29uZmlnAf+IAAECAQ9TZXJ2ZXJQdWJsaWNLZXkBCgABCUNodW5rU2l6ZQEEAAAATP+ISAFBBJqOsx5IKNry1YBR1K1y34dtEycAYY4Qv/hI/Bq7Dh2j2qAlR4rNi23lrT5SXIvN998Zt2od7M3fCYjj4PYq8j8B/gnuAAA="} \ No newline at end of file diff --git a/transports/Replicant/v3/ReplicantClientConfig1.json b/transports/Replicant/v3/ReplicantClientConfig1.json index f7c451a..241945d 100644 --- a/transports/Replicant/v3/ReplicantClientConfig1.json +++ b/transports/Replicant/v3/ReplicantClientConfig1.json @@ -1 +1 @@ -{"config":"P/+BAwEBDENsaWVudENvbmZpZwH/ggABAwEJVG9uZWJ1cnN0ARAAAQZQb2xpc2gBEAABB0FkZHJlc3MBDAAAAP+8/4IBZmdpdGh1Yi5jb20vT3BlcmF0b3JGb3VuZGF0aW9uL3NoYXBlc2hpZnRlci10cmFuc3BvcnRzL3RyYW5zcG9ydHMvUmVwbGljYW50L3YzL3RvbmVidXJzdC5Nb25vdG9uZUNvbmZpZ/+NAwEBDk1vbm90b25lQ29uZmlnAf+OAAEDAQxBZGRTZXF1ZW5jZXMB/5AAAQ9SZW1vdmVTZXF1ZW5jZXMB/5IAAQpTcGVha0ZpcnN0AQIAAAAq/48DAQEISW5zdGFuY2UB/5AAAQIBBERlc2MB/5IAAQRBcmdzAf+WAAAAJP+RAwEBC0Rl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Cbypy4U2c1DhK948xtC/hxJnDmS8lf7tH7SZg7B/C1mY4oQGmb3vGr4AVzYd2Oq8YJmdfyhQow98UYvXGuwH+CYYAAA=="} \ No newline at end of file diff --git a/transports/Replicant/v3/ReplicantServerConfig.json b/transports/Replicant/v3/ReplicantServerConfig.json index efee501..5c2911a 100644 --- a/transports/Replicant/v3/ReplicantServerConfig.json +++ b/transports/Replicant/v3/ReplicantServerConfig.json @@ -1 +1 @@ -{"Replicant":{"config":"M/+JAwEBDFNlcnZlckNvbmZpZwH/igABAgEJVG9uZWJ1cnN0ARAAAQZQb2xpc2gBEAAAAP+8/4oBZmdpdGh1Yi5jb20vT3BlcmF0b3JGb3VuZGF0aW9uL3NoYXBlc2hpZnRlci10cmFuc3BvcnRzL3RyYW5zcG9ydHMvUmVwbGljYW50L3YzL3RvbmVidXJzdC5Nb25vdG9uZUNvbmZpZ/+NAwEBDk1vbm90b25lQ29uZmlnAf+OAAEDAQxBZGRTZXF1ZW5jZXMB/5AAAQ9SZW1vdmVTZXF1ZW5jZXMB/5IAAQpTcGVha0ZpcnN0AQIAAAAq/48DAQEISW5zdGFuY2UB/5AAAQIBBERlc2MB/5IAAQRBcmdzAf+WAAAAJP+RAwEBC0Rlc2NyaXB0aW9uAf+SAAEBAQVQYXJ0cwH/lAAAACH/kwIBARNbXW1vbm9saXRoLk1vbm9saXRoAf+UAAEQAAAo/5UDAQEEQXJncwH/lgABAgEGVmFsdWVzAf+YAAEFSW5kZXgBBAAAABz/lwIBAQ5bXWludGVyZmFjZSB7fQH/mAABEAAA/gHI/45iAgEBPGdpdGh1Yi5jb20vT3BlcmF0b3JGb3VuZGF0aW9uL21vbm9saXRoLWdvL21vbm9saXRoLkJ5dGVzUGFydP+ZAwEBCUJ5dGVzUGFydAH/mgABAQEFSXRlbXMB/5wAAAAh/5sCAQETW11tb25vbGl0aC5CeXRlVHlwZQH/nAABEAAAdP+aZwEBQGdpdGh1Yi5jb20vT3BlcmF0b3JGb3VuZGF0aW9uL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AEFSW5kZXgBBAAAABz/lwIBAQ5bXWludGVyZmFjZSB7fQH/mAABEAAA/gHI/45iAgEBPGdpdGh1Yi5jb20vT3BlcmF0b3JGb3VuZGF0aW9uL21vbm9saXRoLWdvL21vbm9saXRoLkJ5dGVzUGFydP+ZAwEBCUJ5dGVzUGFydAH/mgABAQEFSXRlbXMB/5wAAAAh/5sCAQETW11tb25vbGl0aC5CeXRlVHlwZQH/nAABEAAAdP+aZwEBQGdpdGh1Yi5jb20vT3BlcmF0b3JGb3VuZGF0aW9uL21vbm9saXRoLWdvL21vbm9saXRoLkZpeGVkQnl0ZVR5cGX/nQMBAQ1GaXhlZEJ5dGVUeXBlAf+eAAEBAQRCeXRlAQYAAAAH/54DARMAAAAAAW1naXRodWIuY29tL09wZXJhdG9yRm91bmRhdGlvbi9zaGFwZXNoaWZ0ZXItdHJhbnNwb3J0cy90cmFuc3BvcnRzL1JlcGxpY2FudC92Mi9wb2xpc2guU2lsdmVyUG9saXNoU2VydmVyQ29uZmln/4sDAQEYU2lsdmVyUG9saXNoU2VydmVyQ29uZmlnAf+MAAEDAQ9TZXJ2ZXJQdWJsaWNLZXkBCgABEFNlcnZlclByaXZhdGVLZXkBCgABCUNodW5rU2l6ZQEEAAAAbv+MagFBBJqOsx5IKNry1YBR1K1y34dtEycAYY4Qv/hI/Bq7Dh2j2qAlR4rNi23lrT5SXIvN998Zt2od7M3fCYjj4PYq8j8BIHxZFobfzLX+4u1fQjbi9spnGxHP0/EVUoctnw1+IQ/iAf4J7gAA"}} \ No newline at end of file diff --git a/transports/Replicant/v3/ReplicantServerConfig1.json b/transports/Replicant/v3/ReplicantServerConfig1.json index 157a724..91663d4 100644 --- a/transports/Replicant/v3/ReplicantServerConfig1.json +++ b/transports/Replicant/v3/ReplicantServerConfig1.json @@ -1 +1 @@ -{"Replicant":{"config":"M/+JAwEBDFNlcnZlckNvbmZpZwH/igABAgEJVG9uZWJ1cnN0ARAAAQZQb2xpc2gBEAAAAP+8/4oBZmdpd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eXBl/6AHAQQREhMUAEtnaXRodWIuY29tL09wZXJhdG9yRm91bmRhdGlvbi9tb25vbGl0aC1nby9tb25vbGl0aC5SYW5kb21FbnVtZXJhdGVkQnl0ZVR5cGX/oAcBBBESExQAAAAAAW1naXRodWIuY29tL09wZXJhdG9yRm91bmRhdGlvbi9zaGFwZXNoaWZ0ZXItdHJhbnNwb3J0cy90cmFuc3BvcnRzL1JlcGxpY2FudC92Mi9wb2xpc2guU2lsdmVyUG9saXNoU2VydmVyQ29uZmln/4sDAQEYU2lsdmVyUG9saXNoU2VydmVyQ29uZmlnAf+MAAEDAQ9TZXJ2ZXJQdWJsaWNLZXkBCgABEFNlcnZlclByaXZhdGVLZXkBCgABCUNodW5rU2l6ZQEEAAAAbv+MagFBBFEnAm8qcuFNnNQ4SvePMbQv4cSZw5kvJX+7R+0mYOwfwtZmOKEBpm97xq+AFc2HdjqvGCZnX8oUKMPfFGL1xrsBIMTmz1uvAyqL6ZlayWybrfOfD5OC3Ho6VFCT8WA7rxz7Af4JhgAA"}} \ No newline at end of file diff --git a/transports/Replicant/v3/config.go b/transports/Replicant/v3/config.go index 579a3a6..8643d36 100644 --- a/transports/Replicant/v3/config.go +++ b/transports/Replicant/v3/config.go @@ -26,14 +26,13 @@ package replicant import ( "encoding/json" - "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v3/polish" - "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v3/toneburst" + "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v2/polish" + "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v2/toneburst" ) type ClientConfig struct { Toneburst toneburst.Config Polish polish.ClientConfig - Address string } type ServerConfig struct { @@ -41,19 +40,16 @@ type ServerConfig struct { Polish polish.ServerConfig } -type ClientJSONConfig struct { - Config string `json:"config"` -} +func (config ServerConfig) Marshal() (string, error) { -type ServerJSONInnerConfig struct { - Config string `json:"config"` -} + type ServerJSONInnerConfig struct { + Config string `json:"config"` + } -type ServerJSONOuterConfig struct { - Replicant ServerJSONInnerConfig -} + type ServerJSONOuterConfig struct { + Replicant ServerJSONInnerConfig + } -func (config ServerConfig) Marshal() (string, error) { configString, configStringError := config.Encode() if configStringError != nil { return "", configStringError @@ -72,6 +68,10 @@ func (config ServerConfig) Marshal() (string, error) { func (config ClientConfig) Marshal() (string, error) { + type ClientJSONConfig struct { + Config string `json:"config"` + } + configString, configStringError := config.Encode() if configStringError != nil { return "", configStringError diff --git a/transports/Replicant/v3/go.mod b/transports/Replicant/v3/go.mod index 063ac28..4ee9392 100644 --- a/transports/Replicant/v3/go.mod +++ b/transports/Replicant/v3/go.mod @@ -1,11 +1,10 @@ -module github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v3 +module github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v2 go 1.12 require ( github.com/OperatorFoundation/monolith-go/monolith v1.0.4 github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0 - github.com/kataras/golog v0.0.18 github.com/opentracing/opentracing-go v1.1.0 golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 golang.org/x/net v0.0.0-20200202094626-16171245cfb2 diff --git a/transports/Replicant/v3/go.sum b/transports/Replicant/v3/go.sum index 8d20f0d..fa3bd56 100644 --- a/transports/Replicant/v3/go.sum +++ b/transports/Replicant/v3/go.sum @@ -4,10 +4,6 @@ github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0 h1:6aQs+TF3KULMarpzbKu8 github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0/go.mod h1:gb/QiZH0QDXLSQ9PskyJ2oTflB7tsP4AYc8y+FppvB0= github.com/deckarep/golang-set v1.7.1 h1:SCQV0S6gTtp6itiFrTqI+pfmJ4LN85S1YzhDf9rTHJQ= github.com/deckarep/golang-set v1.7.1/go.mod h1:93vsz/8Wt4joVM7c2AVqh+YRMiUSc14yDtF28KmMOgQ= -github.com/kataras/golog v0.0.18 h1:Td7hcKN25yzqB/0SO5iohOsMk5Mq5V9kDtM5apaJLY0= -github.com/kataras/golog v0.0.18/go.mod h1:jRYl7dFYqP8aQj9VkwdBUXYZSfUktm+YYg1arJILfyw= -github.com/kataras/pio v0.0.8 h1:6pX6nHJk7DAV3x1dEimibQF2CmJLlo0jWVmM9yE9KY8= -github.com/kataras/pio v0.0.8/go.mod h1:NFfMp2kVP1rmV4N6gH6qgWpuoDKlrOeYi3VrAIWCGsE= github.com/opentracing/opentracing-go v1.1.0 h1:pWlfV3Bxv7k65HYwkikxat0+s3pV4bsqf19k25Ur8rU= github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= diff --git a/transports/Replicant/v3/persistence.go b/transports/Replicant/v3/persistence.go index 9f87825..24f08f2 100644 --- a/transports/Replicant/v3/persistence.go +++ b/transports/Replicant/v3/persistence.go @@ -29,8 +29,8 @@ import ( "encoding/base64" "encoding/gob" "github.com/OperatorFoundation/monolith-go/monolith" - "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v3/polish" - "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v3/toneburst" + "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v2/polish" + "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v2/toneburst" ) func InitializeGobRegistry() { diff --git a/transports/Replicant/v3/persistence_test.go b/transports/Replicant/v3/persistence_test.go index 6216e8c..3d3cec9 100644 --- a/transports/Replicant/v3/persistence_test.go +++ b/transports/Replicant/v3/persistence_test.go @@ -2,8 +2,8 @@ package replicant import ( "encoding/json" - "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v3/polish" - "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v3/toneburst" + "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v2/polish" + "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v2/toneburst" "io/ioutil" "testing" ) diff --git a/transports/Replicant/v3/polish/silver.go b/transports/Replicant/v3/polish/silver.go index 62b300f..8ea5639 100644 --- a/transports/Replicant/v3/polish/silver.go +++ b/transports/Replicant/v3/polish/silver.go @@ -175,8 +175,6 @@ func NewSilverClient(config SilverPolishClientConfig) (Connection, error) { } func X963KDF(sharedKeySeed []byte, ephemeralPublicKey []byte) []byte { - - //FIXME: Is this a correct X963 KDF length := 32 output := make([]byte, 0) outlen := 0 diff --git a/transports/Replicant/v3/pt21.go b/transports/Replicant/v3/pt21.go index 3e98423..66c296b 100644 --- a/transports/Replicant/v3/pt21.go +++ b/transports/Replicant/v3/pt21.go @@ -31,10 +31,10 @@ import ( ) // Create outgoing transport connection -func (config ClientConfig) Dial(address string) (net.Conn, error) { +func (config ClientConfig) Dial(address string) net.Conn { conn, dialErr := net.Dial("tcp", address) if dialErr != nil { - return nil, dialErr + return nil } transportConn, err := NewClientConnection(conn, config) @@ -42,25 +42,25 @@ func (config ClientConfig) Dial(address string) (net.Conn, error) { if conn != nil { _ = conn.Close() } - return nil, err + return nil } - return transportConn, nil + return transportConn } // Create listener for incoming transport connection -func (config ServerConfig) Listen(address string) (net.Listener, error) { +func (config ServerConfig) Listen(address string) net.Listener { addr, resolveErr := pt.ResolveAddr(address) if resolveErr != nil { - return nil, resolveErr + return nil } ln, err := net.ListenTCP("tcp", addr) if err != nil { - return nil, err + return nil } - return newReplicantTransportListener(ln, config), nil + return newReplicantTransportListener(ln, config) } func (listener *replicantTransportListener) Addr() net.Addr { @@ -77,7 +77,6 @@ func (listener *replicantTransportListener) Accept() (net.Conn, error) { } config := listener.config - return NewServerConnection(conn, config) } @@ -88,13 +87,79 @@ func (listener *replicantTransportListener) Close() error { } func (sconn *Connection) Read(b []byte) (int, error) { + if sconn.state.polish != nil { - polished := make([]byte, sconn.state.polish.GetChunkSize()) + + if len(b) == 0 { + return 0, nil + } + + if sconn.receiveBuffer.Len() > 0 { + if len(b) <= sconn.receiveBuffer.Len() { + // Read the decrypted data into the provided slice "b" + readLen, readError := sconn.receiveBuffer.Read(b) + if readError != nil { + return 0, readError + } + + // We've delivered all unpolished data from the buffer, let's clear it out + // Read just moves the offset but leaves the data in place, we need to reset the buffer + if sconn.receiveBuffer.Len() == 0 { + sconn.receiveBuffer.Reset() + } + + return readLen, nil + } else { + result := make([]byte, len(b)) + + // Read the decrypted data into the provided slice "b" + readLen, readError := sconn.receiveBuffer.Read(result) + sconn.receiveBuffer.Reset() + if readError != nil { + return 0, readError + } + + stillNeeded := result[readLen:] + snReadLen, snReadError := sconn.Read(stillNeeded) + if snReadError != nil { + return 0, snReadError + } + + // Keep reading until we get the full requested length, or an error + for snReadLen < len(stillNeeded) { + // Keep reading, we didn't get enough data + stillNeeded = stillNeeded[snReadLen:] + snReadLen, snReadError = sconn.Read(stillNeeded) + if snReadError != nil { + return 0, snReadError + } + } + + copy(b, result) + return len(result), nil + } + } + + // Make sure to discard stale data by overwriting b with zeros + zeros := make([]byte, len(b)) + copy(b, zeros) + + chunkSize := sconn.state.polish.GetChunkSize() + polished := make([]byte, chunkSize) // Read encrypted data from the connection and put it into our polished slice - _, err := sconn.conn.Read(polished) - if err != nil { - return 0, err + connReadLen, connReadError := sconn.conn.Read(polished) + if connReadError != nil { + return 0, connReadError + } + + for connReadLen < chunkSize { + // Keep reading, we didn't get enough data + partialPolish := polished[connReadLen:] + connReadLen, connReadError = sconn.conn.Read(partialPolish) + if connReadError != nil { + return 0, connReadError + } } // Decrypt the data @@ -103,18 +168,23 @@ func (sconn *Connection) Read(b []byte) (int, error) { return 0, unpolishError } - // Empty the buffer and write the decrypted data to it - sconn.receiveBuffer.Reset() - sconn.receiveBuffer.Write(unpolished) + if len(unpolished) <= len(b) { + copy(b, unpolished) + return len(unpolished), nil + } else { + // This will copy only up to the length of b from unpolished to b + copy(b, unpolished) + + remainingUnpolished := unpolished[len(b):] - // Read the decrypted data into the provided slice "b" - _, readError := sconn.receiveBuffer.Read(b) - if readError != nil { - return 0, readError + // Empty the buffer and write the decrypted data to it + sconn.receiveBuffer.Reset() + sconn.receiveBuffer.Write(remainingUnpolished) + + // Return b, and leave the remaining unpolished in the buffer + return len(b), nil } - sconn.receiveBuffer.Reset() - return len(b), nil } else { // Read from the connection directly into the provided slice "b" return sconn.conn.Read(b) diff --git a/transports/Replicant/v3/replicant.go b/transports/Replicant/v3/replicant.go index bb8c59f..a778a56 100644 --- a/transports/Replicant/v3/replicant.go +++ b/transports/Replicant/v3/replicant.go @@ -30,8 +30,8 @@ import ( "fmt" "net" - "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v3/polish" - "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v3/toneburst" + "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v2/polish" + "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v2/toneburst" ) type ConnectionState struct { diff --git a/transports/Replicant/v3/replicant_test.go b/transports/Replicant/v3/replicant_test.go index 50ba459..7985c07 100644 --- a/transports/Replicant/v3/replicant_test.go +++ b/transports/Replicant/v3/replicant_test.go @@ -3,10 +3,8 @@ package replicant import ( "bytes" "github.com/OperatorFoundation/monolith-go/monolith" - "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v3/polish" - "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v3/toneburst" - "github.com/kataras/golog" - "golang.org/x/net/proxy" + "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v2/polish" + "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v2/toneburst" "io/ioutil" "math/rand" "os" @@ -17,7 +15,7 @@ import ( func TestMain(m *testing.M) { runReplicantServer() - runReplicantFactoryServer() + os.Exit(m.Run()) } @@ -74,7 +72,7 @@ func TestNilsMonotone(t *testing.T) { replicantConnection(clientConfig, serverConfig, t) } -func TestMarshalSilverRandomEnumeratedConfigs(t *testing.T) { +func MarshalSilverRandomEnumeratedConfigs(t *testing.T) { clientConfig, serverConfig := createSilverMonotoneConfigsRandomEnumeratedItems() clientConfigJsonString, clientConfigJsonError := clientConfig.Marshal() @@ -136,13 +134,6 @@ func TestMonotoneRandomEnumerated(t *testing.T) { replicantConnection(clientConfig, serverConfig, t) } -//TODO this test looks identical to the test above apart from naming -func TestFactoryMonotoneRandomEnumerated(t *testing.T) { - clientConfig := createMonotoneClientConfigRandomEnumeratedItems() - serverConfig := createMonotoneServerConfigRandomEnumeratedItems() - replicantFactoryConnection(clientConfig, serverConfig, t) -} - func TestSilver(t *testing.T) { clientConfig, serverConfig := createSilverConfigs() replicantConnection(*clientConfig, *serverConfig, t) @@ -157,50 +148,7 @@ func runReplicantServer() { } go func() { - listener, _ := serverConfig.Listen(addr) - serverStarted <- true - - lConn, lConnError := listener.Accept() - if lConnError != nil { - return - } - - lBuffer := make([]byte, 4) - _, lReadError := lConn.Read(lBuffer) - if lReadError != nil { - return - } - - // Send a response back to person contacting us. - _, lWriteError := lConn.Write([]byte("Message received.")) - if lWriteError != nil { - return - } - }() - - serverFinishedStarting := <-serverStarted - if !serverFinishedStarting { - return - } -} - -func runReplicantFactoryServer() { - MakeLog() - serverStarted := make(chan bool) - addr := "127.0.0.1:3001" - - serverConfig := ServerConfig{ - Toneburst: nil, - Polish: nil, - } - - server := NewServer(serverConfig, addr, proxy.Direct) - - go func() { - listener, listenError := server.Listen() - if listenError != nil { - return - } + listener := serverConfig.Listen(addr) serverStarted <- true lConn, lConnError := listener.Accept() @@ -223,7 +171,7 @@ func runReplicantFactoryServer() { serverFinishedStarting := <-serverStarted if !serverFinishedStarting { - return + return } } @@ -246,7 +194,7 @@ func replicantConnection(clientConfig ClientConfig, serverConfig ServerConfig, t addr += portString go func() { - listener, _ := serverConfig.Listen(addr) + listener := serverConfig.Listen(addr) serverStarted <- true lConn, lConnError := listener.Accept() @@ -278,82 +226,8 @@ func replicantConnection(clientConfig ClientConfig, serverConfig ServerConfig, t return } - cConn, connErr := clientConfig.Dial(addr) - if connErr != nil { - t.Fail() - return - } - - writeBytes := []byte{0x0A, 0x11, 0xB0, 0xB1} - _, cWriteError := cConn.Write(writeBytes) - if cWriteError != nil { - t.Fail() - return - } - - readBuffer := make([]byte, 17) - _, cReadError := cConn.Read(readBuffer) - if cReadError != nil { - t.Fail() - return - } - - _ = cConn.Close() - - return -} - -func replicantFactoryConnection(clientConfig ClientConfig, serverConfig ServerConfig, t *testing.T) { - serverStarted := make(chan bool) - MakeLog() - // Get a random port - rand.Seed(time.Now().UnixNano()) - min := 1025 - max := 65535 - portNumber := min + rand.Intn(max-min+1) - portString := strconv.Itoa(portNumber) - addr := "127.0.0.1:" - addr += portString - - go func() { - server := NewServer(serverConfig, addr, proxy.Direct) - listener, listenError := server.Listen() - if listenError != nil { - return - } - serverStarted <- true - - lConn, lConnError := listener.Accept() - if lConnError != nil { - t.Fail() - return - } - - lBuffer := make([]byte, 4) - _, lReadError := lConn.Read(lBuffer) - if lReadError != nil { - t.Fail() - return - } - - // Send a response back to person contacting us. - _, lWriteError := lConn.Write([]byte("Message received.")) - if lWriteError != nil { - t.Fail() - return - } - - _ = listener.Close() - }() - - serverFinishedStarting := <-serverStarted - if !serverFinishedStarting { - t.Fail() - return - } - client := NewClient(clientConfig, proxy.Direct) - cConn, connErr := client.Dial() - if connErr != nil { + cConn := clientConfig.Dial(addr) + if cConn == nil { t.Fail() return } @@ -1093,8 +967,3 @@ func createSampleConfigs() (*ClientConfig, *ServerConfig) { return &clientConfig, &serverConfig } - -func MakeLog() { - golog.SetLevel("debug") - golog.SetOutput(os.Stderr) -} \ No newline at end of file diff --git a/transports/meeklite/v3/LICENSE b/transports/meeklite/v3/LICENSE index 6b89f8c..e69de29 100644 --- a/transports/meeklite/v3/LICENSE +++ b/transports/meeklite/v3/LICENSE @@ -1,55 +0,0 @@ -Copyright (c) 2014, Yawning Angel -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. - -============================================================================== - -Copyright (c) 2012 The Go Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - diff --git a/transports/meeklite/v3/go.mod b/transports/meeklite/v3/go.mod index 9fccd7f..377b94d 100644 --- a/transports/meeklite/v3/go.mod +++ b/transports/meeklite/v3/go.mod @@ -1,8 +1,8 @@ -module github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3 +module github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v2 go 1.12 require ( - github.com/kataras/golog v0.0.18 + github.com/stretchr/testify v1.5.1 golang.org/x/net v0.0.0-20200202094626-16171245cfb2 ) diff --git a/transports/meeklite/v3/go.sum b/transports/meeklite/v3/go.sum index 93924bc..fe647ab 100644 --- a/transports/meeklite/v3/go.sum +++ b/transports/meeklite/v3/go.sum @@ -1,10 +1,16 @@ -github.com/kataras/golog v0.0.18 h1:Td7hcKN25yzqB/0SO5iohOsMk5Mq5V9kDtM5apaJLY0= -github.com/kataras/golog v0.0.18/go.mod h1:jRYl7dFYqP8aQj9VkwdBUXYZSfUktm+YYg1arJILfyw= -github.com/kataras/pio v0.0.8 h1:6pX6nHJk7DAV3x1dEimibQF2CmJLlo0jWVmM9yE9KY8= -github.com/kataras/pio v0.0.8/go.mod h1:NFfMp2kVP1rmV4N6gH6qgWpuoDKlrOeYi3VrAIWCGsE= +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/net v0.0.0-20200202094626-16171245cfb2 h1:CCH4IOTTfewWjGOlSp+zGcjutRKlBEZQ6wTn8ozI/nI= golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/transports/meeklite/v3/meeklite.go b/transports/meeklite/v3/meeklite.go index d70b971..21d4002 100644 --- a/transports/meeklite/v3/meeklite.go +++ b/transports/meeklite/v3/meeklite.go @@ -95,19 +95,19 @@ func (transport *MeekTransport) NetworkDialer() proxy.Dialer { } // Dial creates outgoing transport connection -func (transport *MeekTransport) Dial() (net.Conn, error) { +func (transport *MeekTransport) Dial() net.Conn { // FIXME - should use dialer transportConn, err := newMeekClientConn(transport.clientArgs) if err != nil { - return nil, err + return nil } - return transportConn, nil + return transportConn } // Listen for the meek transport does not have a corresponding server, only a client -func (transport *MeekTransport) Listen() (net.Listener, error) { - return nil, nil +func (transport *MeekTransport) Listen() net.Listener { + return nil } // End methods that implement the base.Transport interface @@ -123,31 +123,23 @@ func (ca *meekClientArgs) Network() string { //Transport contains parameters used in Optimizer type Transport struct { - URL *gourl.URL - Front string - Dialer proxy.Dialer -} - -//Config puts the parameters in a json compatible format -type Config struct { URL *gourl.URL `json:"url"` Front string `json:"front"` - Address string `json:"address"` + Address string + Dialer proxy.Dialer } -func NewMeekFactoryTransportWithFront(url *gourl.URL, front string, dialer proxy.Dialer) *Transport { - return &Transport{url, front, dialer} +//Config puts the parameters in a json compatible format +type Config struct { + URL *gourl.URL `json:"url"` + Front string `json:"front"` } // Dial creates outgoing transport connection func (transport Transport) Dial() (net.Conn, error) { meekTransport := NewMeekTransportWithFront(transport.URL.String(), transport.Front, transport.Dialer) - conn, dialErr := meekTransport.Dial() - if dialErr != nil { - return nil, errors.New("failed to dial") - } else { - return conn, nil - } + conn := meekTransport.Dial() + return conn, nil } func (ca *meekClientArgs) String() string { @@ -238,23 +230,23 @@ func (transportConn *meekConn) Read(p []byte) (n int, err error) { return } select { - case <-time.After(20 * time.Second): - return 0, nil - // Wait for the worker to enqueue more incoming data. - case b, ok := <-transportConn.workerRdChan: - if !ok { - // Close() was called and the worker's shutting down. - return 0, io.ErrClosedPipe - } + case <-time.After(20*time.Second): + return 0, nil + // Wait for the worker to enqueue more incoming data. + case b, ok := <-transportConn.workerRdChan: + if !ok { + // Close() was called and the worker's shutting down. + return 0, io.ErrClosedPipe + } - // Ew, an extra copy, but who am I kidding, it's meek. - buf := bytes.NewBuffer(b) - n, err = buf.Read(p) - if buf.Len() > 0 { - // If there's data pending, stash the buffer so the next - // Read() call will use it to fulfill the Read(). - transportConn.rdBuf = buf - } + // Ew, an extra copy, but who am I kidding, it's meek. + buf := bytes.NewBuffer(b) + n, err = buf.Read(p) + if buf.Len() > 0 { + // If there's data pending, stash the buffer so the next + // Read() call will use it to fulfill the Read(). + transportConn.rdBuf = buf + } } return } @@ -364,7 +356,7 @@ func (transportConn *meekConn) roundTrip(sndBuf []byte) (recvBuf []byte, err err if resp.StatusCode == http.StatusInternalServerError { return } - time.Sleep(retryDelay) + time.Sleep(retryDelay) } else { _ = resp.Body.Close() diff --git a/transports/meeklite/v3/meeklite_test.go b/transports/meeklite/v3/meeklite_test.go index 92c42d3..b26d710 100644 --- a/transports/meeklite/v3/meeklite_test.go +++ b/transports/meeklite/v3/meeklite_test.go @@ -34,25 +34,21 @@ package meeklite import ( - "github.com/kataras/golog" "golang.org/x/net/proxy" - gourl "net/url" - "os" "testing" ) const data = "test" func TestMeeklite(t *testing.T) { - MakeLog() //create a server config := NewMeekTransportWithFront("https://transport-canary-meek.appspot.com/", "www.google.com", proxy.Direct) //create client buffer clientBuffer := make([]byte, 4) //call dial on client and check error - clientConn, connErr := config.Dial() - if connErr != nil { + clientConn := config.Dial() + if clientConn == nil { t.Fail() return } @@ -79,52 +75,3 @@ func TestMeeklite(t *testing.T) { return } } - -func TestFactoryMeeklite(t *testing.T) { - MakeLog() - //create a server - urlString := "https://transport-canary-meek.appspot.com/" - Url, err := gourl.Parse(urlString) - if err != nil { - t.Fail() - return - } - - config := NewMeekFactoryTransportWithFront(Url, "www.google.com", proxy.Direct) - - //create client buffer - clientBuffer := make([]byte, 4) - //call dial on client and check error - clientConn, connErr := config.Dial() - if connErr != nil { - t.Fail() - return - } - - //write data from clientConn for server to read - writeBytes, clientWriteErr := clientConn.Write([]byte(data)) - if clientWriteErr != nil { - t.Fail() - return - } - if writeBytes <= 0 { - t.Fail() - return - } - - //read on client side - readBytes, clientReadErr := clientConn.Read(clientBuffer) - if clientReadErr != nil { - t.Fail() - return - } - if readBytes <= 0 { - t.Fail() - return - } -} - -func MakeLog() { - golog.SetLevel("debug") - golog.SetOutput(os.Stderr) -} \ No newline at end of file diff --git a/transports/meekserver/v3/LICENSE b/transports/meekserver/v3/LICENSE deleted file mode 100644 index 6b89f8c..0000000 --- a/transports/meekserver/v3/LICENSE +++ /dev/null @@ -1,55 +0,0 @@ -Copyright (c) 2014, Yawning Angel -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. - -============================================================================== - -Copyright (c) 2012 The Go Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - diff --git a/transports/meekserver/v3/certificate.go b/transports/meekserver/v3/certificate.go index 9f9edf7..4daccf0 100644 --- a/transports/meekserver/v3/certificate.go +++ b/transports/meekserver/v3/certificate.go @@ -1,30 +1,3 @@ -/* - * Copyright (c) 2014, Yawning Angel - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - // certificate.go - Certificate management for meek-server. // +build go1.6 @@ -33,7 +6,7 @@ package meekserver import ( "crypto/tls" - "github.com/kataras/golog" + "log" "os" "sync" "time" @@ -126,7 +99,7 @@ func (ctx *certContext) GetCertificate(*tls.ClientHelloInfo) (*tls.Certificate, now := time.Now() if now.After(ctx.lastWarnAt.Add(certLoadErrorRateLimit)) { ctx.lastWarnAt = now - golog.Infof("failed to reload certificate: %v", err) + log.Printf("failed to reload certificate: %v", err) } } diff --git a/transports/meekserver/v3/go.mod b/transports/meekserver/v3/go.mod index afc636b..3ac5d1d 100644 --- a/transports/meekserver/v3/go.mod +++ b/transports/meekserver/v3/go.mod @@ -1,10 +1,10 @@ -module github.com/OperatorFoundation/shapeshifter-transports/transports/meekserver/v3 +module github.com/OperatorFoundation/shapeshifter-transports/transports/meekserver/v2 go 1.12 require ( + git.torproject.org/pluggable-transports/goptlib.git v1.1.0 github.com/deckarep/golang-set v1.7.1 - github.com/kataras/golog v0.0.18 github.com/mufti1/interconv v0.0.0-20190313040840-d7c72925c656 golang.org/x/crypto v0.0.0-20200214034016-1d94cc7ab1c6 golang.org/x/net v0.0.0-20200202094626-16171245cfb2 diff --git a/transports/meekserver/v3/go.sum b/transports/meekserver/v3/go.sum index 891e062..3bd92d5 100644 --- a/transports/meekserver/v3/go.sum +++ b/transports/meekserver/v3/go.sum @@ -1,9 +1,7 @@ +git.torproject.org/pluggable-transports/goptlib.git v1.1.0 h1:LMQAA8pAho+QtYrrVNimJQiINNEwcwuuD99vezD/PAo= +git.torproject.org/pluggable-transports/goptlib.git v1.1.0/go.mod h1:YT4XMSkuEXbtqlydr9+OxqFAyspUv0Gr9qhM3B++o/Q= github.com/deckarep/golang-set v1.7.1 h1:SCQV0S6gTtp6itiFrTqI+pfmJ4LN85S1YzhDf9rTHJQ= github.com/deckarep/golang-set v1.7.1/go.mod h1:93vsz/8Wt4joVM7c2AVqh+YRMiUSc14yDtF28KmMOgQ= -github.com/kataras/golog v0.0.18 h1:Td7hcKN25yzqB/0SO5iohOsMk5Mq5V9kDtM5apaJLY0= -github.com/kataras/golog v0.0.18/go.mod h1:jRYl7dFYqP8aQj9VkwdBUXYZSfUktm+YYg1arJILfyw= -github.com/kataras/pio v0.0.8 h1:6pX6nHJk7DAV3x1dEimibQF2CmJLlo0jWVmM9yE9KY8= -github.com/kataras/pio v0.0.8/go.mod h1:NFfMp2kVP1rmV4N6gH6qgWpuoDKlrOeYi3VrAIWCGsE= github.com/mufti1/interconv v0.0.0-20190313040840-d7c72925c656 h1:p+IdebEeB9SAEH9IOJVF6oZ535bwvWqUdqWxG1UWeko= github.com/mufti1/interconv v0.0.0-20190313040840-d7c72925c656/go.mod h1:+db4NNs1NvceiftEzz0ymfu3zKLkynYukafc7llNoMs= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= @@ -13,7 +11,6 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20200202094626-16171245cfb2 h1:CCH4IOTTfewWjGOlSp+zGcjutRKlBEZQ6wTn8ozI/nI= golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/transports/meekserver/v3/meek-server.go b/transports/meekserver/v3/meek-server.go index a74bbdf..dbd64b0 100644 --- a/transports/meekserver/v3/meek-server.go +++ b/transports/meekserver/v3/meek-server.go @@ -1,30 +1,3 @@ -/* - * Copyright (c) 2014, Yawning Angel - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - // Package meekserver is the server transport plugin for the meek pluggable transport. // It acts as an HTTP server, keeps track of session ids, and forwards received // data to a local OR port. @@ -49,8 +22,8 @@ package meekserver import ( "crypto/tls" "fmt" - "github.com/kataras/golog" "io" + "log" "net" "net/http" "path" @@ -189,7 +162,7 @@ func (a scrubbedAddr) String() string { return "[scrubbed]" } -// Replace the Addr in a net.OpError with "[scrubbed]" for golog. +// Replace the Addr in a net.OpError with "[scrubbed]" for logging. func scrubError(err error) error { if operr, ok := err.(*net.OpError); ok { // net.OpError contains Op, Net, Addr, and a subsidiary Err. The @@ -246,14 +219,14 @@ func (state *State) Post(w http.ResponseWriter, req *http.Request) { session, err := state.GetSession(sessionID) if err != nil { - golog.Error(err) + log.Print(err) httpInternalServerError(w) return } err = transact(session, w, req) if err != nil { - golog.Error(err) + log.Print(err) state.CloseSession(sessionID) return } @@ -345,10 +318,10 @@ func initServer(addr *net.TCPAddr, func startServer(addr *net.TCPAddr) (*http.Server, *State, error) { return initServer(addr, nil, func(server *http.Server, errChan chan<- error) { - golog.Errorf("listening with plain HTTP on %s", addr) + log.Printf("listening with plain HTTP on %s", addr) err := server.ListenAndServe() if err != nil { - golog.Errorf("Error in ListenAndServe: %s", err) + log.Printf("Error in ListenAndServe: %s", err) } errChan <- err }) @@ -356,10 +329,10 @@ func startServer(addr *net.TCPAddr) (*http.Server, *State, error) { func startServerTLS(addr *net.TCPAddr, getCertificate func(*tls.ClientHelloInfo) (*tls.Certificate, error)) (*http.Server, *State, error) { return initServer(addr, getCertificate, func(server *http.Server, errChan chan<- error) { - golog.Errorf("listening with HTTPS on %s", addr) + log.Printf("listening with HTTPS on %s", addr) err := server.ListenAndServeTLS("", "") if err != nil { - golog.Errorf("Error in ListenAndServeTLS: %s", err) + log.Printf("Error in ListenAndServeTLS: %s", err) } errChan <- err }) diff --git a/transports/meekserver/v3/meekserver_test.go b/transports/meekserver/v3/meekserver_test.go index 4d19edd..0f7788f 100644 --- a/transports/meekserver/v3/meekserver_test.go +++ b/transports/meekserver/v3/meekserver_test.go @@ -1,8 +1,6 @@ package meekserver import ( - "github.com/kataras/golog" - "os" "testing" ) @@ -14,7 +12,8 @@ import ( // t.Fail() // } //} -func TestMeekServerListen(t *testing.T) { + +func TestMeekServerListen2(t *testing.T) { acmeEmail := "brandon@operatorfoundation.org" keyFileName := "operatorrss.com" meekserverTransport := NewMeekTransportServer(false, acmeEmail, keyFileName, "state") @@ -22,30 +21,9 @@ func TestMeekServerListen(t *testing.T) { t.Fail() return } - _, listenErr := meekserverTransport.Listen("127.0.0.1:8080") - if listenErr != nil { - t.Fail() - return - } -} - -func TestMeekServerFactoryListen(t *testing.T) { -MakeLog() - acmeEmail := "brandon@operatorfoundation.org" - acmeHostNames := "operatorrss.com" - meekserverTransport, newError := New(false, acmeHostNames, acmeEmail,"127.0.0.1:8080", "state") - if newError != nil { - t.Fail() - return - } - _, listenErr := meekserverTransport.Listen() - if listenErr != nil { + listener := meekserverTransport.Listen("127.0.0.1:8080") + if listener == nil { t.Fail() return } -} - -func MakeLog() { - golog.SetLevel("debug") - golog.SetOutput(os.Stderr) } \ No newline at end of file diff --git a/transports/meekserver/v3/pt21.go b/transports/meekserver/v3/pt21.go index 6e67333..63c12b7 100644 --- a/transports/meekserver/v3/pt21.go +++ b/transports/meekserver/v3/pt21.go @@ -24,33 +24,6 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ -/* - * Copyright (c) 2014, Yawning Angel - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - // Package meekserver provides an implementation of the Meek circumvention // protocol. Only a client implementation is provided, and no effort is @@ -61,9 +34,9 @@ package meekserver import ( "errors" - "github.com/kataras/golog" interconv "github.com/mufti1/interconv/package" "golang.org/x/crypto/acme/autocert" + "log" "net" "net/http" "strings" @@ -78,12 +51,6 @@ type MeekServer struct { CertManager *autocert.Manager } -type Transport struct { - DisableTLS bool - CertManager *autocert.Manager - Address string -} - //Config contains arguments formatted for a json file type Config struct { AcmeEmail string `json:"acme-email"` @@ -106,50 +73,6 @@ type fakeConn struct { writeBuffer []byte } -func New(disableTLS bool, acmeHostnamesCommas string, acmeEmail string, address string, stateDir string) (*Transport, error) { - var certManager *autocert.Manager - if disableTLS { - if acmeEmail != "" || acmeHostnamesCommas != "" { - return nil, errors.New("acmeEmail and acmeHostnames must be empty when disableTLS is enabled") - } - return nil, errors.New("disableTLS mode is not yet supported") - } else { - if acmeEmail == "" || acmeHostnamesCommas == "" { - return nil, errors.New("acmeEmail and acmeHostnames must be empty when disableTLS is disabled") - } - if acmeHostnamesCommas != "" { - acmeHostnames := strings.Split(acmeHostnamesCommas, ",") - golog.Infof("ACME hostnames: %q", acmeHostnames) - - // The ACME HTTP-01 responder only works when it is running on - // port 80. - // https://github.com/ietf-wg-acme/acme/blob/master/draft-ietf-acme-acme.md#http-challenge - - var cache autocert.Cache - cacheDir, err := getCertificateCacheDir(stateDir) - if err == nil { - golog.Infof("caching ACME certificates in directory %q", cacheDir) - cache = autocert.DirCache(cacheDir) - } else { - golog.Infof("disabling ACME certificate cache: %s", err) - } - - certManager = &autocert.Manager{ - Prompt: autocert.AcceptTOS, - HostPolicy: autocert.HostWhitelist(acmeHostnames...), - Email: acmeEmail, - Cache: cache, - } - return &Transport{ - DisableTLS: disableTLS, - CertManager: certManager, - Address: address, - }, nil - } else { - return nil, errors.New("must set acmeEmail") - } - } -} func (listener meekListener) Accept() (net.Conn, error) { state := listener.state state.lock.Lock() @@ -183,13 +106,13 @@ func (listener meekListener) Addr() net.Addr { } func (conn meekServerConn) Read(b []byte) (n int, err error) { - if len(conn.session.Or.readBuffer) == 0 { + if len(conn.session.Or.readBuffer) == 0 || len(b) == 0 { return 0, nil + } else { + copyLength := copy(b, conn.session.Or.readBuffer) + conn.session.Or.readBuffer = conn.session.Or.readBuffer[copyLength:] + return copyLength, nil } - copy(b, conn.session.Or.readBuffer) - conn.session.Or.readBuffer = conn.session.Or.readBuffer[:0] - - return len(b), nil } func (conn meekServerConn) Write(b []byte) (n int, err error) { @@ -236,7 +159,7 @@ func NewMeekTransportServer(disableTLS bool, acmeEmail string, acmeHostnamesComm } if acmeHostnamesCommas != "" { acmeHostnames := strings.Split(acmeHostnamesCommas, ",") - golog.Infof("ACME hostnames: %q", acmeHostnames) + log.Printf("ACME hostnames: %q", acmeHostnames) // The ACME HTTP-01 responder only works when it is running on // port 80. @@ -245,10 +168,10 @@ func NewMeekTransportServer(disableTLS bool, acmeEmail string, acmeHostnamesComm var cache autocert.Cache cacheDir, err := getCertificateCacheDir(stateDir) if err == nil { - golog.Infof("caching ACME certificates in directory %q", cacheDir) + log.Printf("caching ACME certificates in directory %q", cacheDir) cache = autocert.DirCache(cacheDir) } else { - golog.Infof("disabling ACME certificate cache: %s", err) + log.Printf("disabling ACME certificate cache: %s", err) } certManager = &autocert.Manager{ @@ -265,49 +188,13 @@ func NewMeekTransportServer(disableTLS bool, acmeEmail string, acmeHostnamesComm // Methods that implement the base.Transport interface // Listen on the meek transport does not have a corresponding server, only a client -func (transport *MeekServer) Listen(address string) (net.Listener, error) { +func (transport *MeekServer) Listen(address string) net.Listener { var ln net.Listener var state *State var err error addr, resolverr := net.ResolveTCPAddr("tcp", address) if resolverr != nil { - return ln, resolverr - } - acmeAddr := net.TCPAddr{ - IP: addr.IP, - Port: 80, - Zone: "", - } - acmeAddr.Port = 80 - golog.Infof("starting HTTP-01 ACME listener on %s", acmeAddr.String()) - lnHTTP01, err := net.ListenTCP("tcp", &acmeAddr) - if err != nil { - golog.Infof("error opening HTTP-01 ACME listener: %s", err) - return nil, err - } - go func() { - golog.Fatal(http.Serve(lnHTTP01, transport.CertManager.HTTPHandler(nil))) - }() - var server *http.Server - if transport.DisableTLS { - server, state, err = startServer(addr) - } else { - server, state, err = startServerTLS(addr, transport.CertManager.GetCertificate) - } - if err != nil { - - return nil, err - } - return meekListener{server, state}, nil -} - -func (transport *Transport) Listen() (net.Listener, error) { - var ln net.Listener - var state *State - var err error - addr, resolverr := net.ResolveTCPAddr("tcp", transport.Address) - if resolverr != nil { - return ln, resolverr + return ln } acmeAddr := net.TCPAddr{ IP: addr.IP, @@ -315,14 +202,14 @@ func (transport *Transport) Listen() (net.Listener, error) { Zone: "", } acmeAddr.Port = 80 - golog.Infof("starting HTTP-01 ACME listener on %s", acmeAddr.String()) + log.Printf("starting HTTP-01 ACME listener on %s", acmeAddr.String()) lnHTTP01, err := net.ListenTCP("tcp", &acmeAddr) if err != nil { - golog.Infof("error opening HTTP-01 ACME listener: %s", err) - return nil, err + log.Printf("error opening HTTP-01 ACME listener: %s", err) + return nil } go func() { - golog.Fatal(http.Serve(lnHTTP01, transport.CertManager.HTTPHandler(nil))) + log.Fatal(http.Serve(lnHTTP01, transport.CertManager.HTTPHandler(nil))) }() var server *http.Server if transport.DisableTLS { @@ -332,7 +219,7 @@ func (transport *Transport) Listen() (net.Listener, error) { } if err != nil { - return nil, err + return nil } - return meekListener{server, state}, nil + return meekListener{server, state} } diff --git a/transports/meekserver/v3/useraddr.go b/transports/meekserver/v3/useraddr.go index a2ff086..599ca6f 100644 --- a/transports/meekserver/v3/useraddr.go +++ b/transports/meekserver/v3/useraddr.go @@ -1,30 +1,3 @@ -/* - * Copyright (c) 2014, Yawning Angel - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - package meekserver import ( diff --git a/transports/obfs2/v3/LICENSE b/transports/obfs2/v3/LICENSE deleted file mode 100644 index 6b89f8c..0000000 --- a/transports/obfs2/v3/LICENSE +++ /dev/null @@ -1,55 +0,0 @@ -Copyright (c) 2014, Yawning Angel -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. - -============================================================================== - -Copyright (c) 2012 The Go Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - diff --git a/transports/obfs2/v3/go.mod b/transports/obfs2/v3/go.mod index c9ed2e6..acfdfab 100644 --- a/transports/obfs2/v3/go.mod +++ b/transports/obfs2/v3/go.mod @@ -1,10 +1,9 @@ -module github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 +module github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v2 go 1.12 require ( github.com/OperatorFoundation/obfs4 v1.0.0 github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0 - github.com/kataras/golog v0.0.18 golang.org/x/net v0.0.0-20200226121028-0de0cce0169b ) diff --git a/transports/obfs2/v3/go.sum b/transports/obfs2/v3/go.sum index 9e479db..139977a 100644 --- a/transports/obfs2/v3/go.sum +++ b/transports/obfs2/v3/go.sum @@ -7,16 +7,17 @@ github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0 h1:6aQs+TF3KULMarpzbKu8 github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0/go.mod h1:gb/QiZH0QDXLSQ9PskyJ2oTflB7tsP4AYc8y+FppvB0= github.com/dchest/siphash v1.2.1 h1:4cLinnzVJDKxTCl9B01807Yiy+W7ZzVHj/KIroQRvT4= github.com/dchest/siphash v1.2.1/go.mod h1:q+IRvb2gOSrUnYoPqHiyHXS0FOBBOdl6tONBlVnOnt4= -github.com/kataras/golog v0.0.18 h1:Td7hcKN25yzqB/0SO5iohOsMk5Mq5V9kDtM5apaJLY0= -github.com/kataras/golog v0.0.18/go.mod h1:jRYl7dFYqP8aQj9VkwdBUXYZSfUktm+YYg1arJILfyw= -github.com/kataras/pio v0.0.8 h1:6pX6nHJk7DAV3x1dEimibQF2CmJLlo0jWVmM9yE9KY8= -github.com/kataras/pio v0.0.8/go.mod h1:NFfMp2kVP1rmV4N6gH6qgWpuoDKlrOeYi3VrAIWCGsE= +github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88= +github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/willscott/goturn v0.0.0-20170802220503-19f41278d0c9/go.mod h1:PfwRjodCaQXOsHnh2DeVaXqCFCIrbn5WLj1+A5bQkD4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d h1:1ZiEyfaQIg3Qh0EoqpwAakHVhecoE5wlSg5GjnafJGw= golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b h1:0mm1VjtFUOIlE1SbDlwjYaDxZVDP2S5ou6y0gSgXHu8= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= diff --git a/transports/obfs2/v3/obfs2.go b/transports/obfs2/v3/obfs2.go index 1052bae..2acc079 100644 --- a/transports/obfs2/v3/obfs2.go +++ b/transports/obfs2/v3/obfs2.go @@ -36,14 +36,16 @@ import ( "crypto/sha256" "encoding/binary" "fmt" + "log" + "io" "net" "time" - "golang.org/x/net/proxy" - "github.com/OperatorFoundation/obfs4/common/csrand" "github.com/OperatorFoundation/shapeshifter-ipc/v2" + + "golang.org/x/net/proxy" ) const ( @@ -67,10 +69,6 @@ type OptimizerTransport struct { Dialer proxy.Dialer } -type Config struct { - Address string `json:"address"` -} - //Dial connects to a specified address. //this dial function is made to be Optimizer compatible func (transport OptimizerTransport) Dial() (net.Conn, error) { @@ -85,31 +83,17 @@ func (transport OptimizerTransport) Dial() (net.Conn, error) { transportConn, err := newObfs2ClientConn(conn) if err != nil { _ = dialConn.Close() + log.Fatalf("dial connection failed") return nil, err } return transportConn, nil } -func (transport OptimizerTransport) Listen() (net.Listener, error) { - addr, resolveErr := pt.ResolveAddr(transport.Address) - if resolveErr != nil { - fmt.Println(resolveErr.Error()) - return nil, resolveErr - } - - ln, err := net.ListenTCP("tcp", addr) - if err != nil { - fmt.Println(err.Error()) - return nil, err - } - - return newObfs2TransportListener(ln), nil -} - // Transport is the obfs2 implementation of the base.Transport interface. type Transport struct { dialer proxy.Dialer + } //New initializes obfs2 for Optimizer @@ -166,20 +150,20 @@ func (transport *Transport) Dial(address string) (net.Conn, error) { } // Listen creates listener for incoming transport connection -func (transport *Transport) Listen(address string) (net.Listener, error) { +func (transport *Transport) Listen(address string) net.Listener { addr, resolveErr := pt.ResolveAddr(address) if resolveErr != nil { fmt.Println(resolveErr.Error()) - return nil, resolveErr + return nil } ln, err := net.ListenTCP("tcp", addr) if err != nil { fmt.Println(err.Error()) - return nil, err + return nil } - return newObfs2TransportListener(ln), nil + return newObfs2TransportListener(ln) } // Methods that implement the net.Conn interface diff --git a/transports/obfs2/v3/obfs2_test.go b/transports/obfs2/v3/obfs2_test.go index b4e070b..c118e07 100644 --- a/transports/obfs2/v3/obfs2_test.go +++ b/transports/obfs2/v3/obfs2_test.go @@ -32,7 +32,6 @@ package obfs2 import ( - "github.com/kataras/golog" "golang.org/x/net/proxy" "os" "testing" @@ -98,7 +97,6 @@ func TestObfs2WithDialer(t *testing.T) { } func TestObfs2OptimizerTransportWithDialer(t *testing.T) { -MakeLog() config := New("127.0.0.1:1237", proxy.Direct) //create client buffer clientBuffer := make([]byte, 4) @@ -129,8 +127,8 @@ func RunLocalObfs2Server() { config := NewObfs2Transport() //call listen on the server - serverListener, listenErr := config.Listen("127.0.0.1:1237") - if listenErr != nil { + serverListener := config.Listen("127.0.0.1:1237") + if serverListener == nil { return } @@ -159,9 +157,4 @@ func RunLocalObfs2Server() { } } }() -} - -func MakeLog() { - golog.SetLevel("debug") - golog.SetOutput(os.Stderr) } \ No newline at end of file diff --git a/transports/obfs4/v3/LICENSE b/transports/obfs4/v3/LICENSE deleted file mode 100644 index 6b89f8c..0000000 --- a/transports/obfs4/v3/LICENSE +++ /dev/null @@ -1,55 +0,0 @@ -Copyright (c) 2014, Yawning Angel -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. - -============================================================================== - -Copyright (c) 2012 The Go Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - diff --git a/transports/obfs4/v3/go.mod b/transports/obfs4/v3/go.mod index 12d8731..1548034 100644 --- a/transports/obfs4/v3/go.mod +++ b/transports/obfs4/v3/go.mod @@ -1,11 +1,10 @@ -module github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 +module github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2 go 1.12 require ( github.com/OperatorFoundation/obfs4 v1.0.0 github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0 - github.com/kataras/golog v0.0.18 golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d golang.org/x/net v0.0.0-20200226121028-0de0cce0169b ) diff --git a/transports/obfs4/v3/go.sum b/transports/obfs4/v3/go.sum index f1673f2..76c4cd7 100644 --- a/transports/obfs4/v3/go.sum +++ b/transports/obfs4/v3/go.sum @@ -3,14 +3,14 @@ github.com/OperatorFoundation/ed25519 v0.0.0-20200225224545-b22b4bd3ddef h1:1xEt github.com/OperatorFoundation/ed25519 v0.0.0-20200225224545-b22b4bd3ddef/go.mod h1:gQNGvsyT4Zmps9H/yzCqdc+RQzt8ZxCndRNtGTYnBzQ= github.com/OperatorFoundation/obfs4 v1.0.0 h1:OcfdNMzv69fKQrLTkTSwpaBkHyBZMLjigA5M3txZpAg= github.com/OperatorFoundation/obfs4 v1.0.0/go.mod h1:6apgxOLYwyvbpzujpFHWu6Jlc+mjn1aFK7WvNijIVWc= +github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0 h1:zDYt6FDJwDSX4woVFVK2EMt7fkxU5L5qDNLUjQwA+BQ= +github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0/go.mod h1:kB00Ak8Dgn1uZlZHLc/WsUta58Jc+n/ZhCetcPkh42Q= github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0 h1:6aQs+TF3KULMarpzbKu8DhFOF9D2UBCaAN5ZtbK53nQ= github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0/go.mod h1:gb/QiZH0QDXLSQ9PskyJ2oTflB7tsP4AYc8y+FppvB0= github.com/dchest/siphash v1.2.1 h1:4cLinnzVJDKxTCl9B01807Yiy+W7ZzVHj/KIroQRvT4= github.com/dchest/siphash v1.2.1/go.mod h1:q+IRvb2gOSrUnYoPqHiyHXS0FOBBOdl6tONBlVnOnt4= -github.com/kataras/golog v0.0.18 h1:Td7hcKN25yzqB/0SO5iohOsMk5Mq5V9kDtM5apaJLY0= -github.com/kataras/golog v0.0.18/go.mod h1:jRYl7dFYqP8aQj9VkwdBUXYZSfUktm+YYg1arJILfyw= -github.com/kataras/pio v0.0.8 h1:6pX6nHJk7DAV3x1dEimibQF2CmJLlo0jWVmM9yE9KY8= -github.com/kataras/pio v0.0.8/go.mod h1:NFfMp2kVP1rmV4N6gH6qgWpuoDKlrOeYi3VrAIWCGsE= +github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88= +github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/willscott/goturn v0.0.0-20170802220503-19f41278d0c9/go.mod h1:PfwRjodCaQXOsHnh2DeVaXqCFCIrbn5WLj1+A5bQkD4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d h1:1ZiEyfaQIg3Qh0EoqpwAakHVhecoE5wlSg5GjnafJGw= diff --git a/transports/obfs4/v3/handshake_ntor.go b/transports/obfs4/v3/handshake_ntor.go index 6e7e9ac..6ff9624 100644 --- a/transports/obfs4/v3/handshake_ntor.go +++ b/transports/obfs4/v3/handshake_ntor.go @@ -41,7 +41,7 @@ import ( "github.com/OperatorFoundation/obfs4/common/csrand" "github.com/OperatorFoundation/obfs4/common/ntor" "github.com/OperatorFoundation/obfs4/common/replayfilter" - "github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3/framing" + "github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2/framing" ) const ( diff --git a/transports/obfs4/v3/obfs4.go b/transports/obfs4/v3/obfs4.go index e87a169..45afec5 100644 --- a/transports/obfs4/v3/obfs4.go +++ b/transports/obfs4/v3/obfs4.go @@ -1,29 +1,29 @@ /* - * Copyright (c) 2014, Yawning Angel - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ +* Copyright (c) 2014, Yawning Angel +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* +* * Redistributions of source code must retain the above copyright notice, +* this list of conditions and the following disclaimer. +* +* * Redistributions in binary form must reproduce the above copyright notice, +* this list of conditions and the following disclaimer in the documentation +* and/or other materials provided with the distribution. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +* POSSIBILITY OF SUCH DAMAGE. +*/ // Package obfs4 provides an implementation of the Tor Project's obfs4 // obfuscation protocol. @@ -35,12 +35,12 @@ import ( "flag" "fmt" "github.com/OperatorFoundation/obfs4/common/drbg" + "github.com/OperatorFoundation/obfs4/common/log" "github.com/OperatorFoundation/obfs4/common/ntor" "github.com/OperatorFoundation/obfs4/common/probdist" "github.com/OperatorFoundation/obfs4/common/replayfilter" "github.com/OperatorFoundation/shapeshifter-ipc/v2" - "github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3/framing" - "github.com/kataras/golog" + "github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2/framing" "golang.org/x/net/proxy" "math/rand" "net" @@ -131,7 +131,7 @@ func NewObfs4Server(stateDir string) (*Transport, error) { // Store the arguments that should appear in our descriptor for the clients. ptArgs := make(map[string]string) ptArgs[certArg] = st.cert.String() - golog.Infof("certstring %s", certArg) + log.Infof("certstring %s", certArg) ptArgs[iatArg] = strconv.Itoa(st.iatMode) // Initialize the replay filter. @@ -175,7 +175,7 @@ func NewObfs4Client(certString string, iatMode int, dialer proxy.Dialer) (*Trans if dialer == nil { return &Transport{dialer: proxy.Direct, serverFactory: nil, clientArgs: &ClientArgs{nodeID, publicKey, sessionKey, iatMode}}, nil } - return &Transport{dialer: dialer, serverFactory: nil, clientArgs: &ClientArgs{nodeID, publicKey, sessionKey, iatMode}}, nil + return &Transport{dialer: dialer, serverFactory: nil, clientArgs: &ClientArgs{nodeID, publicKey, sessionKey, iatMode}}, nil } @@ -192,7 +192,7 @@ func (transport *Transport) Dial(address string) (net.Conn, error) { if err != nil { closeErr := dialConn.Close() if closeErr != nil { - golog.Errorf("could not close") + log.Errorf("could not close") } return nil, err } @@ -200,87 +200,23 @@ func (transport *Transport) Dial(address string) (net.Conn, error) { return transportConn, nil } -//TransportClient contains parameters to be used in Optimizer -type TransportClient struct { + +//OptimizerTransport contains parameters to be used in Optimizer +type OptimizerTransport struct { CertString string IatMode int - Address string `json:"address"` + Address string Dialer proxy.Dialer } -type TransportServer struct { - ServerFactory *ServerFactory - Address string -} - //Config contains arguments formatted for a json file type Config struct { CertString string `json:"cert"` IatMode string `json:"iat-mode"` - Address string `json:"address"` -} - -func NewClient(certString string, iatMode int, address string, dialer proxy.Dialer) (TransportClient, error) { - return TransportClient{CertString: certString, IatMode: iatMode, Address: address, Dialer: dialer}, nil -} - -func NewServer(stateDir string, address string) (*TransportServer, error) { - sf, sFError := NewObfs4ServerFactory(stateDir) - - if sFError != nil { - return nil, sFError - } - transport := &TransportServer{ - ServerFactory: sf, - Address: address, - } - return transport, nil -} - -//NewObfs4Server initializes the obfs4 server side -func NewObfs4ServerFactory(stateDir string) (*ServerFactory, error) { - args := make(map[string]string) - st, err := serverStateFromArgs(stateDir, args) - if err != nil { - return nil, err - } - - var iatSeed *drbg.Seed - if st.iatMode != iatNone { - iatSeedSrc := sha256.Sum256(st.drbgSeed.Bytes()[:]) - var err error - iatSeed, err = drbg.SeedFromBytes(iatSeedSrc[:]) - if err != nil { - return nil, err - } - } - - // Store the arguments that should appear in our descriptor for the clients. - ptArgs := make(map[string]string) - ptArgs[certArg] = st.cert.String() - golog.Infof("certstring %s", certArg) - ptArgs[iatArg] = strconv.Itoa(st.iatMode) - - // Initialize the replay filter. - filter, err := replayfilter.New(replayTTL) - if err != nil { - return nil, err - } - - // Initialize the close thresholds for failed connections. - hashDrbg, err := drbg.NewHashDrbg(st.drbgSeed) - if err != nil { - return nil, err - } - rng := rand.New(hashDrbg) - - sf := &ServerFactory{ptArgs, st.nodeID, st.identityKey, st.drbgSeed, iatSeed, st.iatMode, filter, rng.Intn(maxCloseDelayBytes), rng.Intn(maxCloseDelay)} - - return sf, nil } // Dial creates outgoing transport connection -func (transport TransportClient) Dial() (net.Conn, error) { +func (transport OptimizerTransport) Dial() (net.Conn, error) { Obfs4Transport, err := NewObfs4Client(transport.CertString, transport.IatMode, transport.Dialer) if err != nil { return nil, err @@ -293,36 +229,20 @@ func (transport TransportClient) Dial() (net.Conn, error) { } // Listen creates listener for incoming transport connection -func (transport *Transport) Listen(address string) (net.Listener, error) { +func (transport *Transport) Listen(address string) net.Listener { addr, resolveErr := pt.ResolveAddr(address) if resolveErr != nil { fmt.Println(resolveErr.Error()) - return nil, resolveErr + return nil } ln, err := net.ListenTCP("tcp", addr) if err != nil { fmt.Println(err.Error()) - return nil, err - } - - return newObfs4TransportListener(transport.serverFactory, ln), nil -} - -func (transport *TransportServer) Listen() (net.Listener, error) { - addr, resolveErr := pt.ResolveAddr(transport.Address) - if resolveErr != nil { - golog.Error(resolveErr.Error()) - return nil, resolveErr - } - - ln, err := net.ListenTCP("tcp", addr) - if err != nil { - golog.Error(err.Error()) - return nil, err + return nil } - return newObfs4TransportListener(transport.ServerFactory, ln), nil + return newObfs4TransportListener(transport.serverFactory, ln) } // Close closes the transport listener. diff --git a/transports/obfs4/v3/obfs4_test.go b/transports/obfs4/v3/obfs4_test.go index 2a63d1b..9f2beec 100644 --- a/transports/obfs4/v3/obfs4_test.go +++ b/transports/obfs4/v3/obfs4_test.go @@ -39,7 +39,7 @@ const data = "test" func TestMain(m *testing.M) { _ = RunLocalObfs4Server("test") - _ = RunLocalObfs4ServerFactory("test") + os.Exit(m.Run()) } @@ -73,34 +73,3 @@ func TestObfs4(t *testing.T) { return } } - -func TestObfs4Factory(t *testing.T) { - print(runtime.GOOS) - clientConfig, launchErr := RunObfs4ClientFactory() - if launchErr != nil { - t.Fail() - return - } - //create client buffer - clientBuffer := make([]byte, 4) - //call dial on client and check error - clientConn, dialErr := clientConfig.Dial() - if dialErr != nil { - t.Fail() - return - } - - //write data from clientConn for server to read - _, clientWriteErr := clientConn.Write([]byte(data)) - if clientWriteErr != nil { - t.Fail() - return - } - - //read on client side - _, clientReadErr := clientConn.Read(clientBuffer) - if clientReadErr != nil { - t.Fail() - return - } -} \ No newline at end of file diff --git a/transports/obfs4/v3/packet.go b/transports/obfs4/v3/packet.go index 441c113..c6a0562 100644 --- a/transports/obfs4/v3/packet.go +++ b/transports/obfs4/v3/packet.go @@ -34,7 +34,7 @@ import ( "io" "github.com/OperatorFoundation/obfs4/common/drbg" - "github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3/framing" + "github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2/framing" ) const ( diff --git a/transports/obfs4/v3/test_utils.go b/transports/obfs4/v3/test_utils.go index b0aded0..ce8484f 100644 --- a/transports/obfs4/v3/test_utils.go +++ b/transports/obfs4/v3/test_utils.go @@ -1,32 +1,6 @@ -/* - MIT License - - Copyright (c) 2020 Operator Foundation - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ - package obfs4 import ( - "github.com/kataras/golog" - "golang.org/x/net/proxy" "io/ioutil" "os" "os/user" @@ -51,7 +25,7 @@ func RunLocalObfs4Server(data string) bool { } directoryErr := os.Mkdir(fPath, 0775) if directoryErr != nil { - if !os.IsExist(directoryErr) { + if !os.IsExist(directoryErr){ return false } } @@ -60,67 +34,8 @@ func RunLocalObfs4Server(data string) bool { return false } //call listen on the server - serverListener, listenErr := serverConfig.Listen("127.0.0.1:1234") - if listenErr != nil { - return false - } - //Create Server connection and format it for concurrency - go func() { - //create server buffer - serverBuffer := make([]byte, 4) - - for { - //create serverConn - serverConn, acceptErr := serverListener.Accept() - if acceptErr != nil { - return - } - - go func() { - //read on server side - _, serverReadErr := serverConn.Read(serverBuffer) - if serverReadErr != nil { - return - } - - //write data from serverConn for client to read - _, serverWriteErr := serverConn.Write([]byte(data)) - if serverWriteErr != nil { - return - } - }() - } - }() - return true -} - -func RunLocalObfs4ServerFactory(data string) bool { - //create a server - MakeLog() - usr, userError := user.Current() - if userError != nil { - return false - } - home := usr.HomeDir - var fPath string - if runtime.GOOS == "darwin" { - fPath = path.Join(home, "shapeshifter-transports/stateDir") - } else { - fPath = path.Join(home, "gopath/src/github.com/OperatorFoundation/shapeshifter-transports/stateDir") - } - directoryErr := os.Mkdir(fPath, 0775) - if directoryErr != nil { - if !os.IsExist(directoryErr) { - return false - } - } - serverConfig, confError := NewServer(fPath, "127.0.0.1:2234") - if confError != nil { - return false - } - //call listen on the server - serverListener, listenErr := serverConfig.Listen() - if listenErr != nil { + serverListener := serverConfig.Listen("127.0.0.1:1234") + if serverListener == nil { return false } //Create Server connection and format it for concurrency @@ -184,41 +99,3 @@ func RunObfs4Client() (*Transport, error) { clientConfig, confError := NewObfs4Client(certstring, 0, nil) return clientConfig, confError } - -//RunObfs4Client runs the client side in the background for the test -func RunObfs4ClientFactory() (*TransportClient, error) { - MakeLog() - usr, userError := user.Current() - if userError != nil { - return nil, userError - } - home := usr.HomeDir - var fPath string - if runtime.GOOS == "darwin" { - fPath = path.Join(home, "shapeshifter-transports/stateDir/obfs4_bridgeline.txt") - } else { - fPath = path.Join(home, "gopath/src/github.com/OperatorFoundation/shapeshifter-transports/stateDir/obfs4_bridgeline.txt") - } - bytes, fileError := ioutil.ReadFile(fPath) - if fileError != nil { - return nil, fileError - } - //print(bytes) - byteString := string(bytes) - //print(byteString) - lines := strings.Split(byteString, "\n") - //print(lines) - bridgeLine := lines[len(lines)-2] - //println(bridgeLine) - bridgeParts1 := strings.Split(bridgeLine, " ") - bridgePart := bridgeParts1[5] - certstring := bridgePart[5:] - //println(certstring) - clientConfig, confError := NewClient(certstring, 0, "127.0.0.1:2234", proxy.Direct) - return &clientConfig, confError -} - -func MakeLog() { - golog.SetLevel("debug") - golog.SetOutput(os.Stderr) -} diff --git a/transports/shadow/v3/LICENSE b/transports/shadow/v3/LICENSE index 97e8749..dfad7b5 100644 --- a/transports/shadow/v3/LICENSE +++ b/transports/shadow/v3/LICENSE @@ -1,3 +1,5 @@ +MIT License + Copyright (c) 2020 Operator Foundation Permission is hereby granted, free of charge, to any person obtaining a copy @@ -12,8 +14,8 @@ copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +SOFTWARE. diff --git a/transports/shadow/v3/go.mod b/transports/shadow/v3/go.mod index 6363ad1..361d52b 100644 --- a/transports/shadow/v3/go.mod +++ b/transports/shadow/v3/go.mod @@ -1,10 +1,9 @@ -module github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 +module github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v2 go 1.12 require ( github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da // indirect - github.com/kataras/golog v0.0.18 github.com/shadowsocks/go-shadowsocks2 v0.0.11 golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 // indirect ) diff --git a/transports/shadow/v3/go.sum b/transports/shadow/v3/go.sum index 8b0b225..e71d517 100644 --- a/transports/shadow/v3/go.sum +++ b/transports/shadow/v3/go.sum @@ -1,9 +1,7 @@ github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da h1:KjTM2ks9d14ZYCvmHS9iAKVt9AyzRSqNU1qabPih5BY= github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da/go.mod h1:eHEWzANqSiWQsof+nXEI9bUVUyV6F53Fp89EuCh2EAA= -github.com/kataras/golog v0.0.18 h1:Td7hcKN25yzqB/0SO5iohOsMk5Mq5V9kDtM5apaJLY0= -github.com/kataras/golog v0.0.18/go.mod h1:jRYl7dFYqP8aQj9VkwdBUXYZSfUktm+YYg1arJILfyw= -github.com/kataras/pio v0.0.8 h1:6pX6nHJk7DAV3x1dEimibQF2CmJLlo0jWVmM9yE9KY8= -github.com/kataras/pio v0.0.8/go.mod h1:NFfMp2kVP1rmV4N6gH6qgWpuoDKlrOeYi3VrAIWCGsE= +github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88= +github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/shadowsocks/go-shadowsocks2 v0.0.11 h1:dXloqEhYnZV40jblWTK8kWeC0Eb+dgql4S0tj99e8j0= github.com/shadowsocks/go-shadowsocks2 v0.0.11/go.mod h1:R+KWaoIwRRhnpw6XV+dZil0XHi64Hc1D7hXUyXTjUzQ= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= diff --git a/transports/shadow/v3/shadow.go b/transports/shadow/v3/shadow.go index 84e5df9..7e94b3e 100644 --- a/transports/shadow/v3/shadow.go +++ b/transports/shadow/v3/shadow.go @@ -26,20 +26,13 @@ package shadow import ( - "github.com/kataras/golog" shadowsocks "github.com/shadowsocks/go-shadowsocks2/core" "log" "net" ) //Config contains the necessary command like arguments to run shadow -type ClientConfig struct { - Password string `json:"password"` - CipherName string `json:"cipherName"` - Address string `json:"address"` -} - -type ServerConfig struct { +type Config struct { Password string `json:"password"` CipherName string `json:"cipherName"` } @@ -52,16 +45,8 @@ type Transport struct { } //NewConfig is used to create a config for testing -func NewClientConfig(password string, cipherName string, address string) ClientConfig { - return ClientConfig{ - Password: password, - CipherName: cipherName, - Address: address, - } -} - -func NewServerConfig(password string, cipherName string) ServerConfig { - return ServerConfig{ +func NewConfig(password string, cipherName string) Config { + return Config{ Password: password, CipherName: cipherName, } @@ -73,27 +58,28 @@ func NewTransport(password string, cipherName string, address string) Transport Password: password, CipherName: cipherName, Address: address, + } } //Listen checks for a working connection -func (config ServerConfig) Listen(address string) (net.Listener, error) { +func (config Config) Listen(address string) net.Listener { cipher, err := shadowsocks.PickCipher(config.CipherName, nil, config.Password) if err != nil { - golog.Errorf("Failed generating ciphers:", err) - return nil, err + log.Fatal("Failed generating ciphers:", err) + return nil } listener, listenerErr := shadowsocks.Listen("tcp", address, cipher) if listenerErr != nil { log.Fatal("Failed to start listener:", listenerErr) - return nil, listenerErr + return nil } - return listener, nil + return listener } //Dial connects to the address on the named network -func (config ClientConfig) Dial(address string) (net.Conn, error) { +func (config Config) Dial(address string) (net.Conn, error) { cipher, err := shadowsocks.PickCipher(config.CipherName, nil, config.Password) if err != nil { log.Fatal("Failed generating ciphers:", err) @@ -111,23 +97,8 @@ func (config ClientConfig) Dial(address string) (net.Conn, error) { func (transport *Transport) Dial() (net.Conn, error) { cipher, err := shadowsocks.PickCipher(transport.CipherName, nil, transport.Password) if err != nil { - log.Fatal("Failed generating ciphers:", err) + log.Fatalf("Failed generating ciphers: %s", err) } return shadowsocks.Dial("tcp", transport.Address, cipher) } - -func (transport *Transport) Listen() (net.Listener, error) { - cipher, err := shadowsocks.PickCipher(transport.CipherName, nil, transport.Password) - if err != nil { - log.Fatal("Failed generating ciphers:", err) - return nil, err - } - - listener, listenerErr := shadowsocks.Listen("tcp", transport.Address, cipher) - if listenerErr != nil { - log.Fatal("Failed to start listener:", listenerErr) - return nil, listenerErr - } - return listener, nil -} diff --git a/transports/shadow/v3/shadow_test.go b/transports/shadow/v3/shadow_test.go index b4e3b3b..f780093 100644 --- a/transports/shadow/v3/shadow_test.go +++ b/transports/shadow/v3/shadow_test.go @@ -26,7 +26,6 @@ package shadow import ( "fmt" - "github.com/kataras/golog" "net" "os" "testing" @@ -35,11 +34,8 @@ import ( const data = "test" func TestMain(m *testing.M) { - config := NewServerConfig("1234", "CHACHA20-IETF-POLY1305") - listener, listenErr := config.Listen("127.0.0.1:1236") - if listenErr != nil { - return - } + config := NewConfig("1234", "CHACHA20-IETF-POLY1305") + listener := config.Listen("127.0.0.1:1236") go acceptConnections(listener) os.Exit(m.Run()) @@ -70,7 +66,7 @@ func acceptConnections(listener net.Listener) { func TestShadow(t *testing.T) { //create a server - config := NewClientConfig("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1236") + config := NewConfig("1234", "CHACHA20-IETF-POLY1305") //create client buffer clientBuffer := make([]byte, 4) @@ -98,9 +94,9 @@ func TestShadow(t *testing.T) { return } } -func TestShadowFactory(t *testing.T) { + +func TestShadowTransport(t *testing.T) { //create a server - MakeLog() transport := NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1236") //create client buffer @@ -129,8 +125,3 @@ func TestShadowFactory(t *testing.T) { return } } - -func MakeLog() { - golog.SetLevel("debug") - golog.SetOutput(os.Stderr) -} \ No newline at end of file From 8d6f7a274c01eaabe38f5e1bde9ad880c4163251 Mon Sep 17 00:00:00 2001 From: Bluesaxorcist Date: Mon, 10 Aug 2020 13:18:05 -0500 Subject: [PATCH 30/33] added stray file --- .../Replicant/v3/toneburst/monotone_test.go | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 transports/Replicant/v3/toneburst/monotone_test.go diff --git a/transports/Replicant/v3/toneburst/monotone_test.go b/transports/Replicant/v3/toneburst/monotone_test.go new file mode 100644 index 0000000..dfce8ec --- /dev/null +++ b/transports/Replicant/v3/toneburst/monotone_test.go @@ -0,0 +1,63 @@ +package toneburst + +//func TestMonotone_Perform(t *testing.T) { +// thing1 := monolith.FixedByteType{Byte: 0xB0} +// thing2 := monolith.FixedByteType{Byte: 0xB1} +// items := []monolith.Monolith{thing1, thing2} +// part := monolith.BytesPart{Items: items} +// parts := []monolith.Monolith{part} +// description := monolith.Description{Parts:parts} +// +// removeSequences := []monolith.Description{description} +// +// addInstance := monolith.Instance{ +// Desc: description, +// Args: make([]interface{}, 0), +// } +// addSequences := []monolith.Instance{addInstance} +// println("Add Sequences count: ", len(addSequences)) +// +// monotoneConfig := MonotoneConfig{ +// AddSequences: addSequences, +// RemoveSequences: removeSequences, +// SpeakFirst: true, +// } +// +// println("Add Sequences count: ", len(monotoneConfig.AddSequences)) +// monotoneInstance := NewMonotone(monotoneConfig) +// go monotoneServer(monotoneInstance) +// +// clientConn, dialError := net.Dial("tcp", "127.0.0.1:2121") +// if dialError != nil { +// println("Dial error: ") +// println(dialError.Error()) +// t.Fail() +// } +// +// performError := monotoneInstance.Perform(clientConn) +// if performError!= nil { +// println("Error on perform: ") +// println(performError.Error()) +// t.Fail() +// } +//} +// +//func monotoneServer(monotoneInstance *Monotone) { +// l, serverErr := net.Listen("tcp", "0.0.0.0:2121") +// if serverErr != nil { +// println(serverErr.Error()) +// return +// } +// +// serverConn, acceptError := l.Accept() +// if acceptError != nil { +// println(acceptError.Error()) +// return +// } +// +// serverPerformError := monotoneInstance.Perform(serverConn) +// if serverPerformError!= nil { +// println("Error on perform: ", serverPerformError) +// return +// } +//} From 49b9c6b6d59dea4ce321dddd9ab5b792e8516e44 Mon Sep 17 00:00:00 2001 From: Bluesaxorcist Date: Mon, 10 Aug 2020 13:23:07 -0500 Subject: [PATCH 31/33] Revert "added stray file" This reverts commit 8d6f7a274c01eaabe38f5e1bde9ad880c4163251. --- .../Replicant/v3/toneburst/monotone_test.go | 63 ------------------- 1 file changed, 63 deletions(-) delete mode 100644 transports/Replicant/v3/toneburst/monotone_test.go diff --git a/transports/Replicant/v3/toneburst/monotone_test.go b/transports/Replicant/v3/toneburst/monotone_test.go deleted file mode 100644 index dfce8ec..0000000 --- a/transports/Replicant/v3/toneburst/monotone_test.go +++ /dev/null @@ -1,63 +0,0 @@ -package toneburst - -//func TestMonotone_Perform(t *testing.T) { -// thing1 := monolith.FixedByteType{Byte: 0xB0} -// thing2 := monolith.FixedByteType{Byte: 0xB1} -// items := []monolith.Monolith{thing1, thing2} -// part := monolith.BytesPart{Items: items} -// parts := []monolith.Monolith{part} -// description := monolith.Description{Parts:parts} -// -// removeSequences := []monolith.Description{description} -// -// addInstance := monolith.Instance{ -// Desc: description, -// Args: make([]interface{}, 0), -// } -// addSequences := []monolith.Instance{addInstance} -// println("Add Sequences count: ", len(addSequences)) -// -// monotoneConfig := MonotoneConfig{ -// AddSequences: addSequences, -// RemoveSequences: removeSequences, -// SpeakFirst: true, -// } -// -// println("Add Sequences count: ", len(monotoneConfig.AddSequences)) -// monotoneInstance := NewMonotone(monotoneConfig) -// go monotoneServer(monotoneInstance) -// -// clientConn, dialError := net.Dial("tcp", "127.0.0.1:2121") -// if dialError != nil { -// println("Dial error: ") -// println(dialError.Error()) -// t.Fail() -// } -// -// performError := monotoneInstance.Perform(clientConn) -// if performError!= nil { -// println("Error on perform: ") -// println(performError.Error()) -// t.Fail() -// } -//} -// -//func monotoneServer(monotoneInstance *Monotone) { -// l, serverErr := net.Listen("tcp", "0.0.0.0:2121") -// if serverErr != nil { -// println(serverErr.Error()) -// return -// } -// -// serverConn, acceptError := l.Accept() -// if acceptError != nil { -// println(acceptError.Error()) -// return -// } -// -// serverPerformError := monotoneInstance.Perform(serverConn) -// if serverPerformError!= nil { -// println("Error on perform: ", serverPerformError) -// return -// } -//} From e0ce613752bd27c845784a00efa8987c766d9401 Mon Sep 17 00:00:00 2001 From: Bluesaxorcist Date: Mon, 10 Aug 2020 13:27:01 -0500 Subject: [PATCH 32/33] Revert "merging process" This reverts commit 43daf357babeb062b9cef885c33893a20be19d17. --- transports/Dust/v3/Dust.go | 75 +++++++-- transports/Dust/v3/Dust_test.go | 85 +++++++++- transports/Dust/v3/LICENSE.md | 59 +++---- transports/Dust/v3/go.mod | 3 +- transports/Dust/v3/go.sum | 5 + transports/Optimizer/v3/LICENSE | 6 +- transports/Optimizer/v3/Optimizer.go | 80 ++++----- transports/Optimizer/v3/Optimizer_test.go | 72 +++++--- transports/Optimizer/v3/go.mod | 11 +- transports/Optimizer/v3/go.sum | 36 ++-- transports/Replicant/v3/LICENSE | 6 +- transports/Replicant/v3/Optimizer.go | 59 +++++-- .../Replicant/v3/ReplicantClientConfig.json | 2 +- .../Replicant/v3/ReplicantClientConfig1.json | 2 +- .../Replicant/v3/ReplicantServerConfig.json | 2 +- .../Replicant/v3/ReplicantServerConfig1.json | 2 +- transports/Replicant/v3/config.go | 26 +-- transports/Replicant/v3/go.mod | 3 +- transports/Replicant/v3/go.sum | 4 + transports/Replicant/v3/persistence.go | 4 +- transports/Replicant/v3/persistence_test.go | 4 +- transports/Replicant/v3/polish/silver.go | 2 + transports/Replicant/v3/pt21.go | 114 +++---------- transports/Replicant/v3/replicant.go | 4 +- transports/Replicant/v3/replicant_test.go | 149 ++++++++++++++++- transports/meeklite/v3/LICENSE | 55 ++++++ transports/meeklite/v3/go.mod | 4 +- transports/meeklite/v3/go.sum | 16 +- transports/meeklite/v3/meeklite.go | 68 ++++---- transports/meeklite/v3/meeklite_test.go | 57 ++++++- transports/meekserver/v3/LICENSE | 55 ++++++ transports/meekserver/v3/certificate.go | 31 +++- transports/meekserver/v3/go.mod | 4 +- transports/meekserver/v3/go.sum | 7 +- transports/meekserver/v3/meek-server.go | 43 ++++- transports/meekserver/v3/meekserver_test.go | 30 +++- transports/meekserver/v3/pt21.go | 147 ++++++++++++++-- transports/meekserver/v3/useraddr.go | 27 +++ transports/obfs2/v3/LICENSE | 55 ++++++ transports/obfs2/v3/go.mod | 3 +- transports/obfs2/v3/go.sum | 9 +- transports/obfs2/v3/obfs2.go | 36 ++-- transports/obfs2/v3/obfs2_test.go | 11 +- transports/obfs4/v3/LICENSE | 55 ++++++ transports/obfs4/v3/go.mod | 3 +- transports/obfs4/v3/go.sum | 8 +- transports/obfs4/v3/handshake_ntor.go | 2 +- transports/obfs4/v3/obfs4.go | 158 +++++++++++++----- transports/obfs4/v3/obfs4_test.go | 33 +++- transports/obfs4/v3/packet.go | 2 +- transports/obfs4/v3/test_utils.go | 129 +++++++++++++- transports/shadow/v3/LICENSE | 6 +- transports/shadow/v3/go.mod | 3 +- transports/shadow/v3/go.sum | 6 +- transports/shadow/v3/shadow.go | 51 ++++-- transports/shadow/v3/shadow_test.go | 19 ++- 56 files changed, 1491 insertions(+), 457 deletions(-) create mode 100644 transports/meekserver/v3/LICENSE create mode 100644 transports/obfs2/v3/LICENSE create mode 100644 transports/obfs4/v3/LICENSE diff --git a/transports/Dust/v3/Dust.go b/transports/Dust/v3/Dust.go index 66c9eeb..cb0f905 100644 --- a/transports/Dust/v3/Dust.go +++ b/transports/Dust/v3/Dust.go @@ -1,15 +1,32 @@ package Dust /* - * Copyright (c) 2019, Operator Foundation - * - */ + MIT License -// Package Dust provides a PT 2.1 Go API wrapper around the Dust transport + Copyright (c) 2020 Operator Foundation + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ import ( "fmt" - "github.com/OperatorFoundation/obfs4/common/log" + "github.com/kataras/golog" "golang.org/x/net/proxy" "net" "time" @@ -21,6 +38,7 @@ import ( type dustClient struct { serverPubkey *Dust.ServerPublic dialer proxy.Dialer + Address string `json:"address"` } type dustServer struct { @@ -28,16 +46,16 @@ type dustServer struct { dialer proxy.Dialer } -func NewDustClient(serverPublic string, dialer proxy.Dialer) *dustClient { +func NewDustClient(serverPublic string, dialer proxy.Dialer, address string) *dustClient { unparsed := make(map[string]string) - unparsed["p"]=serverPublic + unparsed["p"] = serverPublic spub, err := Dust.ParseServerPublic(unparsed) if err != nil { return nil } - return &dustClient{serverPubkey: spub, dialer: dialer} + return &dustClient{serverPubkey: spub, dialer: dialer, Address: address} } type dustTransportListener struct { @@ -50,13 +68,25 @@ type Transport struct { ServerPublic string Address string Dialer proxy.Dialer + ServerConfig *dustServer } type Config struct { ServerPublic string `json:"server-public"` + Address string `json:"address"` +} + +func New(serverPublic string, address string, dialer proxy.Dialer, serverConfig *dustServer) Transport { + return Transport{ + ServerPublic: serverPublic, + Address: address, + Dialer: dialer, + ServerConfig: serverConfig, + } } + func (transport Transport) Dial() (net.Conn, error) { - dustTransport := NewDustClient(transport.ServerPublic, transport.Dialer) + dustTransport := NewDustClient(transport.ServerPublic, transport.Dialer, transport.Address) conn, err := dustTransport.Dial(transport.Address) if err != nil { return nil, err @@ -64,6 +94,23 @@ func (transport Transport) Dial() (net.Conn, error) { return conn, nil } } + +func (transport Transport) Listen() (net.Listener, error) { + addr, resolveErr := pt.ResolveAddr(transport.Address) + if resolveErr != nil { + fmt.Println(resolveErr.Error()) + return nil, resolveErr + } + + ln, err := net.ListenTCP("tcp", addr) + if err != nil { + fmt.Println(err.Error()) + return nil, err + } + + return newDustTransportListener(ln, transport.ServerConfig), nil +} + //end optimizer code func newDustTransportListener(listener *net.TCPListener, transport *dustServer) *dustTransportListener { @@ -81,7 +128,7 @@ func (transport *dustClient) Dial(address string) (net.Conn, error) { if err != nil { closeErr := conn.Close() if closeErr != nil { - log.Errorf("could not close") + golog.Error("could not close") } return conn, dialErr } @@ -90,20 +137,20 @@ func (transport *dustClient) Dial(address string) (net.Conn, error) { } // Create listener for incoming transport connection -func (transport *dustServer) Listen(address string) net.Listener { +func (transport *dustServer) Listen(address string) (net.Listener, error) { addr, resolveErr := pt.ResolveAddr(address) if resolveErr != nil { fmt.Println(resolveErr.Error()) - return nil + return nil, resolveErr } ln, err := net.ListenTCP("tcp", addr) if err != nil { fmt.Println(err.Error()) - return nil + return nil, err } - return newDustTransportListener(ln, transport) + return newDustTransportListener(ln, transport), nil } func (listener *dustTransportListener) Addr() net.Addr { diff --git a/transports/Dust/v3/Dust_test.go b/transports/Dust/v3/Dust_test.go index 2aaacc5..71fe8d5 100644 --- a/transports/Dust/v3/Dust_test.go +++ b/transports/Dust/v3/Dust_test.go @@ -7,27 +7,32 @@ package Dust // Package Dust provides a PT 2.1 Go API wrapper around the Dust transport - import ( + "github.com/kataras/golog" + "golang.org/x/net/proxy" + "os" "testing" ) const data = "test" func TestDust(t *testing.T) { + + MakeLog() //create a server serverConfig := dustServer{ serverPrivkey: nil, dialer: nil, } + clientConfig := dustClient{ serverPubkey: nil, dialer: nil, } //call listen on the server - serverListener := serverConfig.Listen("127.0.0.1:1234") - if serverListener == nil { + serverListener, listenErr := serverConfig.Listen("127.0.0.1:1234") + if listenErr != nil { t.Fail() return } @@ -82,3 +87,77 @@ func TestDust(t *testing.T) { return } } + +func TestDustV3(t *testing.T) { + + MakeLog() + + //create a server + serverConfig := dustServer{ + serverPrivkey: nil, + dialer: nil, + } + + transport := New("", "127.0.0.1:1234", proxy.Direct, &serverConfig) + //call listen on the server + serverListener, listenErr := transport.Listen() + if listenErr != nil { + t.Fail() + return + } + + //Create Server connection and format it for concurrency + go func() { + //create server buffer + serverBuffer := make([]byte, 4) + + //create serverConn + serverConn, acceptErr := serverListener.Accept() + if acceptErr != nil { + t.Fail() + return + } + + //read on server side + _, serverReadErr := serverConn.Read(serverBuffer) + if serverReadErr != nil { + t.Fail() + return + } + + //write data from serverConn for client to read + _, serverWriteErr := serverConn.Write([]byte(data)) + if serverWriteErr != nil { + t.Fail() + return + } + }() + + //create client buffer + clientBuffer := make([]byte, 4) + //call dial on client and check error + clientConn, dialErr := transport.Dial() + if dialErr != nil { + t.Fail() + return + } + + //write data from clientConn for server to read + _, clientWriteErr := clientConn.Write([]byte(data)) + if clientWriteErr != nil { + t.Fail() + return + } + + //read on client side + _, clientReadErr := clientConn.Read(clientBuffer) + if clientReadErr != nil { + t.Fail() + return + } +} + +func MakeLog() { + golog.SetLevel("debug") + golog.SetOutput(os.Stderr) +} \ No newline at end of file diff --git a/transports/Dust/v3/LICENSE.md b/transports/Dust/v3/LICENSE.md index f98047a..97e8749 100644 --- a/transports/Dust/v3/LICENSE.md +++ b/transports/Dust/v3/LICENSE.md @@ -1,40 +1,19 @@ -# Licenses for software included in this directory - -## Main Dust packages and first-party support packages - -The directories 'v2' and 'sillyHex' compose the main Dust packages for Go. The directories 'buf', 'huffman', 'model1', 'prim1', and 'proc' compose the first-party support packages. These are all subject to the following terms: - -* Copyright © 2015 Drake Wilson <drake@dasyatidae.com> - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -## Skein - -The directory 'skein' contains a modified version of Dmitry Chestnykh's Skein-512 code. It is subject to the following terms: - -* Copyright © 2012 Dmitry Chestnykh <dmitry@codingrobots.com> -* Copyright © 2015 Drake Wilson <drake@dasyatidae.com> -* All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - -* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -## Dist - -The directory 'dist' contains a local copy of the random distribution code from gonum. - -(TODO: copy appropriate file for this here) - - +Copyright (c) 2020 Operator Foundation + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/transports/Dust/v3/go.mod b/transports/Dust/v3/go.mod index 2a6a0aa..b3c6090 100644 --- a/transports/Dust/v3/go.mod +++ b/transports/Dust/v3/go.mod @@ -1,4 +1,4 @@ -module github.com/OperatorFoundation/shapeshifter-transports/transports/Dust/v2 +module github.com/OperatorFoundation/shapeshifter-transports/transports/Dust/v3 go 1.12 @@ -7,5 +7,6 @@ require ( github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0 github.com/blanu/Dust v1.0.1 // indirect github.com/blanu/Dust/go/v2/interface v1.0.1 + github.com/kataras/golog v0.0.18 golang.org/x/net v0.0.0-20200226121028-0de0cce0169b ) diff --git a/transports/Dust/v3/go.sum b/transports/Dust/v3/go.sum index dd89648..799dbcf 100644 --- a/transports/Dust/v3/go.sum +++ b/transports/Dust/v3/go.sum @@ -11,6 +11,10 @@ github.com/blanu/Dust v1.0.1/go.mod h1:jLFQI2Ufz4kBnGiTzh8O9+/p4U/9MLbouXkaympnT github.com/blanu/Dust/go/v2/interface v1.0.1 h1:lIQrNXljx8vgTTwB+gObrkA6jBhokmgH/uHp1OxbqxE= github.com/blanu/Dust/go/v2/interface v1.0.1/go.mod h1:0NnpBd5fkRrG2I/pf6bcUaL5jpp84LeShsQzn4gCOCw= github.com/dchest/siphash v1.2.1/go.mod h1:q+IRvb2gOSrUnYoPqHiyHXS0FOBBOdl6tONBlVnOnt4= +github.com/kataras/golog v0.0.18 h1:Td7hcKN25yzqB/0SO5iohOsMk5Mq5V9kDtM5apaJLY0= +github.com/kataras/golog v0.0.18/go.mod h1:jRYl7dFYqP8aQj9VkwdBUXYZSfUktm+YYg1arJILfyw= +github.com/kataras/pio v0.0.8 h1:6pX6nHJk7DAV3x1dEimibQF2CmJLlo0jWVmM9yE9KY8= +github.com/kataras/pio v0.0.8/go.mod h1:NFfMp2kVP1rmV4N6gH6qgWpuoDKlrOeYi3VrAIWCGsE= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/willscott/goturn v0.0.0-20170802220503-19f41278d0c9/go.mod h1:PfwRjodCaQXOsHnh2DeVaXqCFCIrbn5WLj1+A5bQkD4= @@ -22,5 +26,6 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20200226121028-0de0cce0169b h1:0mm1VjtFUOIlE1SbDlwjYaDxZVDP2S5ou6y0gSgXHu8= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/transports/Optimizer/v3/LICENSE b/transports/Optimizer/v3/LICENSE index dfad7b5..97e8749 100644 --- a/transports/Optimizer/v3/LICENSE +++ b/transports/Optimizer/v3/LICENSE @@ -1,5 +1,3 @@ -MIT License - Copyright (c) 2020 Operator Foundation Permission is hereby granted, free of charge, to any person obtaining a copy @@ -14,8 +12,8 @@ copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +SOFTWARE. \ No newline at end of file diff --git a/transports/Optimizer/v3/Optimizer.go b/transports/Optimizer/v3/Optimizer.go index 49d06cf..f9daefb 100644 --- a/transports/Optimizer/v3/Optimizer.go +++ b/transports/Optimizer/v3/Optimizer.go @@ -33,19 +33,23 @@ import ( const timeoutInSeconds = 60 -//Transport is a program that transforms network traffic -type Transport interface { +//TransportDialer is a program that transforms network traffic +type TransportDialer interface { Dial() (net.Conn, error) } +type TransportListener interface { + Listen() (net.Listener, error) +} + //Client contains the two parameters needed to use Optimizer. type Client struct { - Transports []Transport + Transports []TransportDialer Strategy Strategy } //NewOptimizerClient is the initializer -func NewOptimizerClient(Transports []Transport, Strategy Strategy) *Client { +func NewOptimizerClient(Transports []TransportDialer, Strategy Strategy) *Client { return &Client{Transports, Strategy} } @@ -73,63 +77,63 @@ func (OptT *Client) Dial() (net.Conn, error) { //Strategy is the method used to choose a transport type Strategy interface { - Choose() Transport - Report(transport Transport, success bool, durationElapsed float64) + Choose() TransportDialer + Report(transport TransportDialer, success bool, durationElapsed float64) } //FirstStrategy returns the first strategy in the array type FirstStrategy struct { - transports []Transport + transports []TransportDialer } //NewFirstStrategy initializes FirstStrategy -func NewFirstStrategy(transports []Transport) Strategy { +func NewFirstStrategy(transports []TransportDialer) Strategy { return &FirstStrategy{transports} } //Choose selects a transport in the array -func (strategy *FirstStrategy) Choose() Transport { +func (strategy *FirstStrategy) Choose() TransportDialer { return strategy.transports[0] } //Report returns if the transport was successful and how long the connection took -func (strategy *FirstStrategy) Report(Transport, bool, float64) { +func (strategy *FirstStrategy) Report(TransportDialer, bool, float64) { } //NewRandomStrategy initializes RandomStrategy -func NewRandomStrategy(transports []Transport) Strategy { +func NewRandomStrategy(transports []TransportDialer) Strategy { return &RandomStrategy{transports} } //RandomStrategy returns a transport at random type RandomStrategy struct { - transports []Transport + transports []TransportDialer } //Choose selects a transport in the array -func (strategy *RandomStrategy) Choose() Transport { +func (strategy *RandomStrategy) Choose() TransportDialer { return strategy.transports[0] } //Report returns if the transport was successful and how long the connection took -func (strategy *RandomStrategy) Report(Transport, bool, float64) { +func (strategy *RandomStrategy) Report(TransportDialer, bool, float64) { } //NewRotateStrategy initializes RotateStrategy -func NewRotateStrategy(transports []Transport) Strategy { +func NewRotateStrategy(transports []TransportDialer) Strategy { return &RotateStrategy{transports, 1} } //RotateStrategy cycles through the list of transports, using a different one each time type RotateStrategy struct { - transports []Transport + transports []TransportDialer index int } //Choose selects a transport in the array -func (strategy *RotateStrategy) Choose() Transport { +func (strategy *RotateStrategy) Choose() TransportDialer { transport := strategy.transports[strategy.index] strategy.index++ if strategy.index >= len(strategy.transports) { @@ -139,7 +143,7 @@ func (strategy *RotateStrategy) Choose() Transport { } //Report returns if the transport was successful and how long the connection took -func (strategy *RotateStrategy) Report(Transport, bool, float64) { +func (strategy *RotateStrategy) Report(TransportDialer, bool, float64) { } @@ -147,19 +151,19 @@ func (strategy *RotateStrategy) Report(Transport, bool, float64) { //choose the best option type TrackStrategy struct { index int - trackMap map[Transport]int - transport []Transport + trackMap map[TransportDialer]int + transport []TransportDialer } //NewTrackStrategy initializes TrackStrategy -func NewTrackStrategy(transport []Transport) Strategy { - track := TrackStrategy{0, map[Transport]int{}, transport} - track.trackMap = make(map[Transport]int) +func NewTrackStrategy(transport []TransportDialer) Strategy { + track := TrackStrategy{0, map[TransportDialer]int{}, transport} + track.trackMap = make(map[TransportDialer]int) return &track } //Choose selects a transport in the array -func (strategy *TrackStrategy) Choose() Transport { +func (strategy *TrackStrategy) Choose() TransportDialer { transport := strategy.transport[strategy.index] score := strategy.findScore(strategy.transport) startIndex := strategy.index @@ -177,7 +181,7 @@ func (strategy *TrackStrategy) Choose() Transport { } //findScore is used to find the score given to each transport based on performance -func (strategy *TrackStrategy) findScore(transports []Transport) int { +func (strategy *TrackStrategy) findScore(transports []TransportDialer) int { transport := transports[strategy.index] score, ok := strategy.trackMap[transport] if ok { @@ -188,7 +192,7 @@ func (strategy *TrackStrategy) findScore(transports []Transport) int { } //incrementIndex is used to cycle through the transport index -func (strategy *TrackStrategy) incrementIndex(transports []Transport) { +func (strategy *TrackStrategy) incrementIndex(transports []TransportDialer) { strategy.index++ if strategy.index >= len(transports) { strategy.index = 0 @@ -196,7 +200,7 @@ func (strategy *TrackStrategy) incrementIndex(transports []Transport) { } //Report returns if the transport was successful and how long the connection took -func (strategy *TrackStrategy) Report(transport Transport, success bool, _ float64) { +func (strategy *TrackStrategy) Report(transport TransportDialer, success bool, _ float64) { if success { strategy.trackMap[transport] = 1 } else { @@ -207,19 +211,19 @@ func (strategy *TrackStrategy) Report(transport Transport, success bool, _ float //minimizeDialDuration is used to find the transport with the fastest response time type minimizeDialDuration struct { index int - trackMap map[Transport]float64 - transports []Transport + trackMap map[TransportDialer]float64 + transports []TransportDialer } //NewMinimizeDialDuration initializes minimizeDialDuration -func NewMinimizeDialDuration(transport []Transport) Strategy { - duration := minimizeDialDuration{0, map[Transport]float64{}, transport} - duration.trackMap = make(map[Transport]float64) +func NewMinimizeDialDuration(transport []TransportDialer) Strategy { + duration := minimizeDialDuration{0, map[TransportDialer]float64{}, transport} + duration.trackMap = make(map[TransportDialer]float64) return &duration } //Choose selects a transport in the array -func (strategy *minimizeDialDuration) Choose() Transport { +func (strategy *minimizeDialDuration) Choose() TransportDialer { transport := strategy.transports[strategy.index] score := strategy.findScore(strategy.transports) startIndex := strategy.index @@ -243,7 +247,7 @@ func (strategy *minimizeDialDuration) Choose() Transport { } //incrementIndex is used to cycle through the transport index -func (strategy *minimizeDialDuration) incrementIndex(transports []Transport) { +func (strategy *minimizeDialDuration) incrementIndex(transports []TransportDialer) { strategy.index++ if strategy.index >= len(transports) { strategy.index = 0 @@ -251,7 +255,7 @@ func (strategy *minimizeDialDuration) incrementIndex(transports []Transport) { } //findScore is used to find the score given to each transport based on performance -func (strategy *minimizeDialDuration) findScore(transports []Transport) float64 { +func (strategy *minimizeDialDuration) findScore(transports []TransportDialer) float64 { transport := transports[strategy.index] score, ok := strategy.trackMap[transport] if ok { @@ -262,7 +266,7 @@ func (strategy *minimizeDialDuration) findScore(transports []Transport) float64 } //Report returns if the transport was successful and how long the connection took -func (strategy *minimizeDialDuration) Report(transport Transport, success bool, durationElapsed float64) { +func (strategy *minimizeDialDuration) Report(transport TransportDialer, success bool, durationElapsed float64) { if success { if durationElapsed < 60 { strategy.trackMap[transport] = durationElapsed @@ -275,9 +279,9 @@ func (strategy *minimizeDialDuration) Report(transport Transport, success bool, } //minDuration assigns a value to the response time -func (strategy *minimizeDialDuration) minDuration() Transport { +func (strategy *minimizeDialDuration) minDuration() TransportDialer { min := 61.0 - var transport Transport = nil + var transport TransportDialer = nil for key, value := range strategy.trackMap { if value < min { min = value diff --git a/transports/Optimizer/v3/Optimizer_test.go b/transports/Optimizer/v3/Optimizer_test.go index 2d13bc3..600590b 100644 --- a/transports/Optimizer/v3/Optimizer_test.go +++ b/transports/Optimizer/v3/Optimizer_test.go @@ -1,11 +1,11 @@ package optimizer import ( - "github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v2" - "github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v2" - "github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2" - "github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v2" - + "github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3" + "github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3" + "github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3" + "github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3" + "github.com/kataras/golog" "golang.org/x/net/proxy" "io/ioutil" "net" @@ -21,8 +21,11 @@ import ( const data = "test" func TestMain(m *testing.M) { - config := shadow.NewConfig("1234", "CHACHA20-IETF-POLY1305") - listener := config.Listen("127.0.0.1:1235") + config := shadow.NewServerConfig("1234", "CHACHA20-IETF-POLY1305") + listener, listenErr := config.Listen("127.0.0.1:1235") + if listenErr != nil { + return + } go acceptConnections(listener) _ = obfs4.RunLocalObfs4Server("test") @@ -42,12 +45,13 @@ func acceptConnections(listener net.Listener) { } func TestMeekliteDial(t *testing.T) { + MakeLog() unparsedURL := "https://d2zfqthxsdq309.cloudfront.net/" URL, parseErr := url.Parse(unparsedURL) if parseErr != nil { t.Fail() } - meekliteTransport := meeklite.Transport{URL: URL, Front: "a0.awsstatic.com", Address: "127.0.0.1:1235" } + meekliteTransport := meeklite.Transport{URL: URL, Front: "a0.awsstatic.com"} _, err := meekliteTransport.Dial() if err != nil { t.Fail() @@ -55,13 +59,14 @@ func TestMeekliteDial(t *testing.T) { } func TestOptimizerMeekliteDial(t *testing.T) { + MakeLog() unparsedURL := "https://d2zfqthxsdq309.cloudfront.net/" URL, parseErr := url.Parse(unparsedURL) if parseErr != nil { t.Fail() } - meekliteTransport := meeklite.Transport{URL: URL, Front: "a0.awsstatic.com", Address: "127.0.0.1:1235" } - transports := []Transport{meekliteTransport} + meekliteTransport := meeklite.Transport{URL: URL, Front: "a0.awsstatic.com"} + transports := []TransportDialer{meekliteTransport} strategy := NewFirstStrategy(transports) optimizerTransport := NewOptimizerClient(transports, strategy) _, err := optimizerTransport.Dial() @@ -71,6 +76,7 @@ func TestOptimizerMeekliteDial(t *testing.T) { } func TestShadowDial(t *testing.T) { + MakeLog() shadowTransport := shadow.Transport{Password: "1234", CipherName: "CHACHA20-IETF-POLY1305", Address: "127.0.0.1:1235"} _, err := shadowTransport.Dial() if err != nil { @@ -79,8 +85,9 @@ func TestShadowDial(t *testing.T) { } func TestOptimizerShadowDial(t *testing.T) { + MakeLog() shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235") - transports := []Transport{&shadowTransport} + transports := []TransportDialer{&shadowTransport} strategy := NewFirstStrategy(transports) optimizerTransport := NewOptimizerClient(transports, strategy) _, err := optimizerTransport.Dial() @@ -90,8 +97,9 @@ func TestOptimizerShadowDial(t *testing.T) { } func TestOptimizerObfs2Dial(t *testing.T) { + MakeLog() obfs2Transport := obfs2.New("127.0.0.1:1237", proxy.Direct) - transports := []Transport{obfs2Transport} + transports := []TransportDialer{obfs2Transport} strategy := NewFirstStrategy(transports) optimizerTransport := NewOptimizerClient(transports, strategy) _, err := optimizerTransport.Dial() @@ -101,6 +109,7 @@ func TestOptimizerObfs2Dial(t *testing.T) { } func TestObfs4Transport_Dial(t *testing.T) { + MakeLog() obfs4Transport, transportErr := obfs4.RunObfs4Client() if transportErr != nil { t.Fail() @@ -113,18 +122,19 @@ func TestObfs4Transport_Dial(t *testing.T) { } func TestOptimizerObfs4Transport_Dial(t *testing.T) { + MakeLog() dialer := proxy.Direct certstring, certError := getObfs4CertString() if certError != nil { t.Fail() return } - obfs4Transport := obfs4.OptimizerTransport{ + obfs4Transport := obfs4.TransportClient{ CertString: *certstring, IatMode: 0, Address: "127.0.0.1:1234", Dialer: dialer} - transports := []Transport{obfs4Transport} + transports := []TransportDialer{obfs4Transport} strategy := NewFirstStrategy(transports) optimizerTransport := NewOptimizerClient(transports, strategy) _, err := optimizerTransport.Dial() @@ -134,19 +144,20 @@ func TestOptimizerObfs4Transport_Dial(t *testing.T) { } func TestOptimizerTransportFirstDial(t *testing.T) { + MakeLog() dialer := proxy.Direct certstring, certError := getObfs4CertString() if certError != nil { t.Fail() return } - obfs4Transport := obfs4.OptimizerTransport{ + obfs4Transport := obfs4.TransportClient{ CertString: *certstring, IatMode: 0, Address: "127.0.0.1:1234", Dialer: dialer} shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235") - transports := []Transport{obfs4Transport, &shadowTransport} + transports := []TransportDialer{obfs4Transport, &shadowTransport} strategy := NewFirstStrategy(transports) optimizerTransport := NewOptimizerClient(transports, strategy) for i := 1; i <= 3; i++ { @@ -158,20 +169,21 @@ func TestOptimizerTransportFirstDial(t *testing.T) { } func TestOptimizerTransportRandomDial(t *testing.T) { + MakeLog() dialer := proxy.Direct certstring, certError := getObfs4CertString() if certError != nil { t.Fail() return } - obfs4Transport := obfs4.OptimizerTransport{ + obfs4Transport := obfs4.TransportClient{ CertString: *certstring, IatMode: 0, Address: "127.0.0.1:1234", Dialer: dialer, } shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235") - transports := []Transport{obfs4Transport, &shadowTransport} + transports := []TransportDialer{obfs4Transport, &shadowTransport} strategy := NewRandomStrategy(transports) optimizerTransport := NewOptimizerClient(transports, strategy) @@ -184,20 +196,21 @@ func TestOptimizerTransportRandomDial(t *testing.T) { } func TestOptimizerTransportRotateDial(t *testing.T) { + MakeLog() dialer := proxy.Direct certstring, certError := getObfs4CertString() if certError != nil { t.Fail() return } - obfs4Transport := obfs4.OptimizerTransport{ + obfs4Transport := obfs4.TransportClient{ CertString: *certstring, IatMode: 0, Address: "127.0.0.1:1234", Dialer: dialer, } shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235") - transports := []Transport{obfs4Transport, &shadowTransport} + transports := []TransportDialer{obfs4Transport, &shadowTransport} strategy := NewRotateStrategy(transports) optimizerTransport := NewOptimizerClient(transports, strategy) @@ -210,20 +223,21 @@ func TestOptimizerTransportRotateDial(t *testing.T) { } func TestOptimizerTransportTrackDial(t *testing.T) { + MakeLog() dialer := proxy.Direct certstring, certError := getObfs4CertString() if certError != nil { t.Fail() return } - obfs4Transport := obfs4.OptimizerTransport{ + obfs4Transport := obfs4.TransportClient{ CertString: *certstring, IatMode: 0, Address: "127.0.0.1:1234", Dialer: dialer, } shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235") - transports := []Transport{obfs4Transport, &shadowTransport} + transports := []TransportDialer{obfs4Transport, &shadowTransport} strategy := NewTrackStrategy(transports) optimizerTransport := NewOptimizerClient(transports, strategy) @@ -236,20 +250,21 @@ func TestOptimizerTransportTrackDial(t *testing.T) { } func TestOptimizerTransportMinimizeDialDurationDial(t *testing.T) { + MakeLog() dialer := proxy.Direct certstring, certError := getObfs4CertString() if certError != nil { t.Fail() return } - obfs4Transport := obfs4.OptimizerTransport{ + obfs4Transport := obfs4.TransportClient{ CertString: *certstring, IatMode: 0, Address: "127.0.0.1:1234", Dialer: dialer, } shadowTransport := shadow.NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1235") - transports := []Transport{obfs4Transport, &shadowTransport} + transports := []TransportDialer{obfs4Transport, &shadowTransport} strategy := NewMinimizeDialDuration(transports) optimizerTransport := NewOptimizerClient(transports, strategy) @@ -295,8 +310,8 @@ func RunLocalObfs2Server() { config := obfs2.NewObfs2Transport() //call listen on the server - serverListener := config.Listen("127.0.0.1:1237") - if serverListener == nil { + serverListener, listenErr := config.Listen("127.0.0.1:1237") + if listenErr != nil { return } @@ -325,4 +340,9 @@ func RunLocalObfs2Server() { } } }() +} + +func MakeLog() { + golog.SetLevel("debug") + golog.SetOutput(os.Stderr) } \ No newline at end of file diff --git a/transports/Optimizer/v3/go.mod b/transports/Optimizer/v3/go.mod index 7f791ae..1ec247f 100644 --- a/transports/Optimizer/v3/go.mod +++ b/transports/Optimizer/v3/go.mod @@ -1,11 +1,12 @@ -module github.com/OperatorFoundation/shapeshifter-transports/transports/Optimizer/v2 +module github.com/OperatorFoundation/shapeshifter-transports/transports/Optimizer/v3 go 1.12 require ( - github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v2 v2.2.5 - github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v2 v2.2.5 - github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2 v2.2.5 - github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v2 v2.2.5 + github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3 v3.0.11 + github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 v3.0.11 + github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 v3.0.11 + github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 v3.0.11 + github.com/kataras/golog v0.0.18 golang.org/x/net v0.0.0-20200226121028-0de0cce0169b ) diff --git a/transports/Optimizer/v3/go.sum b/transports/Optimizer/v3/go.sum index 7927a9a..f3f9cb8 100644 --- a/transports/Optimizer/v3/go.sum +++ b/transports/Optimizer/v3/go.sum @@ -5,24 +5,34 @@ github.com/OperatorFoundation/obfs4 v1.0.0 h1:OcfdNMzv69fKQrLTkTSwpaBkHyBZMLjigA github.com/OperatorFoundation/obfs4 v1.0.0/go.mod h1:6apgxOLYwyvbpzujpFHWu6Jlc+mjn1aFK7WvNijIVWc= github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0 h1:6aQs+TF3KULMarpzbKu8DhFOF9D2UBCaAN5ZtbK53nQ= github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0/go.mod h1:gb/QiZH0QDXLSQ9PskyJ2oTflB7tsP4AYc8y+FppvB0= -github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v2 v2.2.5 h1:EqRoJz0kdLmnxpaOv6PbXRJohdbIvio6FkYkyWs2U0w= -github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v2 v2.2.5/go.mod h1:DEfaE6lfJKEG5CkCRks4rXTMi1xYwbYR0sa+JKsgsr0= -github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v2 v2.2.5 h1:AcAPnmUoi9qsK5vOQUvJIM7+YXtaLDhfOiBz8EA9bGM= -github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v2 v2.2.5/go.mod h1:W9OJqDkmHbSB86NOlGqECLDtSvr9MoVVlYrvjFqBMG0= -github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2 v2.2.5 h1:NudLXkarpDevMLpW/s081LHDwTmKURMCHZ67ZNSXWBc= -github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2 v2.2.5/go.mod h1:WbvdPacTr1IvoVsd9fYk4sDaWoxxCZIQDks9jRveRC0= -github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v2 v2.2.5 h1:DsKNTTXO/rjm/y8wG/0wUZ3KSFx+OqU1UuYzIHN0m0Q= -github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v2 v2.2.5/go.mod h1:GN8ahnEHVGcPbR0raxdpWekjgElppspPNAAOpmNxQxU= +github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3 v3.0.6 h1:CzFbaRDdcg1xXxIa+N20StrDN8P0hGfoBOv+Idfepn4= +github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3 v3.0.6/go.mod h1:gW1GFU+PS/+snW7IK7gcObExPKCzsvIL1z2g9N/5ubM= +github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3 v3.0.10 h1:D2CK7Vbr7eh7Z+2npal98SaXfqQvhWFptyskmnh3+cQ= +github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3 v3.0.10/go.mod h1:wQZC/2AdEDj3fnuI0Bu0dL1kvUeaE7MvoyeLlLu2nfQ= +github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 v3.0.6 h1:xmos+1ED0y2UbqtEXGxtcxIqTDGPuw0te5Obqlspj9s= +github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 v3.0.6/go.mod h1:i8hkRv+UCu0YbOll8NqoDzDBsRR6XgMa1bykKsTUxTg= +github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 v3.0.10 h1:hKOpe/wHRjIdv10ZWarm3hebce6BtfMpxsr9ZRS+ei0= +github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 v3.0.10/go.mod h1:nnE7S0srPoXZDatJ7sTWhClwo/3vyMXykSDPHAdi2xo= +github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 v3.0.6 h1:/aEcDgGu3VA+gndxMv02LvfbZ6rg0lUYYnPkTlbgaSM= +github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 v3.0.6/go.mod h1:jdYrSKfsppvvtY/WHSL2mN2FdFNiQ7S/XzQxrty0+2I= +github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 v3.0.10 h1:ATbRmWxRg7AHAGgU54DPrVpiy7zteqhCQYXc1T/U0Po= +github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 v3.0.10/go.mod h1:k1ga949kVeIGplqIb1lBE8Qi957Om/bz/GDMymQr+kA= +github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 v3.0.6 h1:nqdVkCLaotgyabOWXf+sVLrGDQTRt8HqAAT/EZwysLM= +github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 v3.0.6/go.mod h1:EQS0MxXaaSQO2IoAwVyXsgx7RBWL6Yy+gMiEn2YJRbo= +github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 v3.0.10 h1:rRRsTQycB1WeVGZSbgfTn0R9woiCi1RpyFEYoRU8uLo= +github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 v3.0.10/go.mod h1:eI5kZwV2A9NBKB3UgzjY1ThIsV2sSUETBmjGbPncaf0= github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da h1:KjTM2ks9d14ZYCvmHS9iAKVt9AyzRSqNU1qabPih5BY= github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da/go.mod h1:eHEWzANqSiWQsof+nXEI9bUVUyV6F53Fp89EuCh2EAA= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dchest/siphash v1.2.1 h1:4cLinnzVJDKxTCl9B01807Yiy+W7ZzVHj/KIroQRvT4= github.com/dchest/siphash v1.2.1/go.mod h1:q+IRvb2gOSrUnYoPqHiyHXS0FOBBOdl6tONBlVnOnt4= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/kataras/golog v0.0.18 h1:Td7hcKN25yzqB/0SO5iohOsMk5Mq5V9kDtM5apaJLY0= +github.com/kataras/golog v0.0.18/go.mod h1:jRYl7dFYqP8aQj9VkwdBUXYZSfUktm+YYg1arJILfyw= +github.com/kataras/pio v0.0.8 h1:6pX6nHJk7DAV3x1dEimibQF2CmJLlo0jWVmM9yE9KY8= +github.com/kataras/pio v0.0.8/go.mod h1:NFfMp2kVP1rmV4N6gH6qgWpuoDKlrOeYi3VrAIWCGsE= +github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88= +github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/shadowsocks/go-shadowsocks2 v0.0.11 h1:dXloqEhYnZV40jblWTK8kWeC0Eb+dgql4S0tj99e8j0= github.com/shadowsocks/go-shadowsocks2 v0.0.11/go.mod h1:R+KWaoIwRRhnpw6XV+dZil0XHi64Hc1D7hXUyXTjUzQ= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/willscott/goturn v0.0.0-20170802220503-19f41278d0c9/go.mod h1:PfwRjodCaQXOsHnh2DeVaXqCFCIrbn5WLj1+A5bQkD4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d h1:1ZiEyfaQIg3Qh0EoqpwAakHVhecoE5wlSg5GjnafJGw= @@ -35,5 +45,3 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/transports/Replicant/v3/LICENSE b/transports/Replicant/v3/LICENSE index dfad7b5..97e8749 100644 --- a/transports/Replicant/v3/LICENSE +++ b/transports/Replicant/v3/LICENSE @@ -1,5 +1,3 @@ -MIT License - Copyright (c) 2020 Operator Foundation Permission is hereby granted, free of charge, to any person obtaining a copy @@ -14,8 +12,8 @@ copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +SOFTWARE. \ No newline at end of file diff --git a/transports/Replicant/v3/Optimizer.go b/transports/Replicant/v3/Optimizer.go index 9d1fd2e..c51db1d 100644 --- a/transports/Replicant/v3/Optimizer.go +++ b/transports/Replicant/v3/Optimizer.go @@ -25,19 +25,41 @@ package replicant import ( + pt "github.com/OperatorFoundation/shapeshifter-ipc/v2" "golang.org/x/net/proxy" "net" ) // This makes Replicant compliant with Optimizer -type Transport struct { +type TransportClient struct { Config ClientConfig Address string Dialer proxy.Dialer } -// TODO: the dial we call currently does not return an error -func (transport Transport) Dial() (net.Conn, error) { +type TransportServer struct { + Config ServerConfig + Address string + Dialer proxy.Dialer +} + +func NewClient(config ClientConfig, dialer proxy.Dialer) TransportClient { + return TransportClient{ + Config: config, + Address: config.Address, + Dialer: dialer, + } +} + +func NewServer(config ServerConfig, address string, dialer proxy.Dialer) TransportServer { + return TransportServer{ + Config: config, + Address: address, + Dialer: dialer, + } +} + +func (transport TransportClient) Dial() (net.Conn, error) { conn, dialErr := transport.Dialer.Dial("tcp", transport.Address) if dialErr != nil { return nil, dialErr @@ -51,15 +73,28 @@ func (transport Transport) Dial() (net.Conn, error) { } return transportConn, nil +} + +func (transport TransportServer) Listen() (net.Listener, error) { + addr, resolveErr := pt.ResolveAddr(transport.Address) + if resolveErr != nil { + return nil, resolveErr + } + + ln, err := net.ListenTCP("tcp", addr) + if err != nil { + return nil, err + } - //replicantTransport := New(transport.Config, transport.Dialer) - //conn := replicantTransport.Dial(transport.Address) - //conn, err:= replicantTransport.Dial(transport.Address), errors.New("connection failed") - //if err != nil { - // return nil, err - //} else { - // return conn, nil - //} - //return conn, nil + return newReplicantTransportListener(ln, transport.Config), nil } +//replicantTransport := New(transport.Config, transport.Dialer) +//conn := replicantTransport.Dial(transport.Address) +//conn, err:= replicantTransport.Dial(transport.Address), errors.New("connection failed") +//if err != nil { +// return nil, err +//} else { +// return conn, nil +//} +//return conn, nil diff --git a/transports/Replicant/v3/ReplicantClientConfig.json b/transports/Replicant/v3/ReplicantClientConfig.json index 88064b9..b710236 100644 --- a/transports/Replicant/v3/ReplicantClientConfig.json +++ b/transports/Replicant/v3/ReplicantClientConfig.json @@ -1 +1 @@ -{"config":"M/+BAwEBDENsaWVudENvbmZpZwH/ggABAgEJVG9uZWJ1cnN0ARAAAQZQb2xpc2gBEAAAAP+8/4IBZmdpdGh1Yi5jb20vT3BlcmF0b3JGb3VuZGF0aW9uL3NoYXBlc2hpZnRlci10cmFuc3BvcnRzL3RyYW5zcG9ydHMvUmVwbGljYW50L3YyL3RvbmVidXJzdC5Nb25vdG9uZUNvbmZpZ/+NAwEBDk1vbm90b25lQ29uZmlnAf+OAAEDAQxBZGRTZXF1ZW5jZXMB/5AAAQ9SZW1vdmVTZXF1ZW5jZXMB/5IAAQpTcGVha0ZpcnN0AQIAAAAq/48DAQEISW5zdGFuY2UB/5AAAQIBBERlc2MB/5IAAQRBcmdzAf+WAAAAJP+RAwEBC0Rlc2NyaXB0aW9uAf+SAAEBAQVQYXJ0cwH/lAAAACH/kwIBARNbXW1vbm9saXRoLk1vbm9saXRoAf+UAAEQAAAo/5UDAQEEQXJncwH/lgABAgEGVmFsdWVzAf+YAAEFSW5kZXgBBAAAABz/lwIBAQ5bXWludGVyZmFjZSB7fQH/mAABEAAA/gG5/45jAQEBATxnaXRodWIuY29tL09wZXJhdG9yRm91bmRhdGlvbi9tb25vbGl0aC1nby9tb25vbGl0aC5CeXRlc1BhcnT/mQMBAQlCeXRlc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ARNbXW1vbm9saXRoLk1vbm9saXRoAf+UAAEQAAAo/5UDAQEEQXJncwH/lgABAgEGVmFsdWVzAf+YAAEFSW5kZXgBBAAAABz/lwIBAQ5bXWludGVyZmFjZSB7fQH/mAABEAAA/gG5/45jAQEBATxnaXRodWIuY29tL09wZXJhdG9yRm91bmRhdGlvbi9tb25vbGl0aC1nby9tb25vbGl0aC5CeXRlc1BhcnT/mQMBAQlCeXRlc1BhcnQB/5oAAQEBBUl0ZW1zAf+cAAAAIf+bAgEBE1tdbW9ub2xpdGguQnl0ZVR5cGUB/5wAARAAAHn/mmcBAUBnaXRodWIuY29tL09wZXJhdG9yRm91bmRhdGlvbi9tb25vbGl0aC1nby9tb25vbGl0aC5GaXhlZEJ5dGVUeXBl/50DAQENRml4ZWRCeXRlVHlwZQH/ngABAQEEQnl0ZQEGAAAAB/+eAwETAAAAAQAAAgEAAW1naXRodWIuY29tL09wZXJhdG9yRm91bmRhdGlvbi9zaGFwZXNoaWZ0ZXItdHJhbnNwb3J0cy90cmFuc3BvcnRzL1JlcGxpY2FudC92My9wb2xpc2guU2lsdmVyUG9saXNoQ2xpZW50Q29uZmln/4cDAQEYU2lsdmVyUG9saXNoQ2xpZW50Q29uZmlnAf+IAAECAQ9TZXJ2ZXJQdWJsaWNLZXkBCgABCUNodW5rU2l6ZQEEAAAATP+ISAFBBLd8zoUelx+g4T0o6OU6EZrDFXIEgD7seIX+0bIoFQbFw35nkA+/gLTvfifR7p1kTFXd060zD+099p2oqSV6OaMB/glaAAA="} \ No newline at end of file diff --git a/transports/Replicant/v3/ReplicantClientConfig1.json b/transports/Replicant/v3/ReplicantClientConfig1.json index 241945d..f7c451a 100644 --- a/transports/Replicant/v3/ReplicantClientConfig1.json +++ b/transports/Replicant/v3/ReplicantClientConfig1.json @@ -1 +1 @@ -{"config":"M/+BAwEBDENsaWVudENvbmZpZwH/ggABAgEJVG9uZWJ1cnN0ARAAAQZQb2xpc2gBEAAAAP+8/4IBZmdpdGh1Yi5jb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Gl0aC1nby9tb25vbGl0aC5SYW5kb21FbnVtZXJhdGVkQnl0ZVR5cGX/oAcBBBESExQAAAABAQABbWdpdGh1Yi5jb20vT3BlcmF0b3JGb3VuZGF0aW9uL3NoYXBlc2hpZnRlci10cmFuc3BvcnRzL3RyYW5zcG9ydHMvUmVwbGljYW50L3YzL3BvbGlzaC5TaWx2ZXJQb2xpc2hDbGllbnRDb25maWf/hwMBARhTaWx2ZXJQb2xpc2hDbGllbnRDb25maWcB/4gAAQIBD1NlcnZlclB1YmxpY0tleQEKAAEJQ2h1bmtTaXplAQQAAABM/4hIAUEEPy7UR8K4ws8wBa9BqC31wmpjgPEPUkogCxrL1/9FouyyVG6bs7LTkFcjlK1e16ySbrqrOiDw9Ph2mF/kacL57gH+Cp4AAA=="} \ No newline at end of file diff --git a/transports/Replicant/v3/ReplicantServerConfig.json b/transports/Replicant/v3/ReplicantServerConfig.json index 5c2911a..efee501 100644 --- a/transports/Replicant/v3/ReplicantServerConfig.json +++ b/transports/Replicant/v3/ReplicantServerConfig.json @@ -1 +1 @@ -{"Replicant":{"config":"M/+JAwEBDFNlcnZlckNvbmZpZwH/igABAgEJVG9uZWJ1cnN0ARAAAQZQb2xpc2gBEAAAAP+8/4oBZmdpdGh1Yi5jb20vT3BlcmF0b3JGb3VuZGF0aW9uL3NoYXBlc2hpZnRlci10cmFuc3BvcnRzL3RyYW5zcG9ydHMvUmVwbGljYW50L3YyL3RvbmVidXJzdC5Nb25vdG9uZUNvbmZpZ/+NAwEBDk1vbm90b25lQ29uZmlnAf+OAAEDAQxBZGRTZXF1ZW5jZXMB/5AAAQ9SZW1vdmVTZXF1ZW5jZXMB/5IAAQpTcGVha0ZpcnN0AQIAAAAq/48DAQEISW5zdGFuY2UB/5AAAQIBBERlc2MB/5IAAQRBcmdzAf+WAAAAJP+RAwEBC0Rlc2NyaXB0aW9uAf+SAAEBAQVQYXJ0cwH/lAAAACH/kwIBARNbXW1vbm9saXRoLk1vbm9saXRoAf+UAAEQAA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TFXd060zD+099p2oqSV6OaMBIPq/E8xDxstEZNB05fQ2J5zpkEoNbfr8vjhobT6cmFVcAf4JWgAA"}} \ No newline at end of file diff --git a/transports/Replicant/v3/ReplicantServerConfig1.json b/transports/Replicant/v3/ReplicantServerConfig1.json index 91663d4..157a724 100644 --- a/transports/Replicant/v3/ReplicantServerConfig1.json +++ b/transports/Replicant/v3/ReplicantServerConfig1.json @@ -1 +1 @@ -{"Replicant":{"config":"M/+JAwEBDFNlcnZlckNvbmZpZwH/igABAgEJVG9uZWJ1cnN0ARAAAQZQb2xpc2gBEAAAAP+8/4oBZmdpdGh1Yi5jb20vT3BlcmF0b3JGb3VuZGF0aW9uL3NoYXBlc2hpZnRlci10cmFuc3BvcnRzL3RyYW5zcG9ydHMvUmVwbGljYW50L3YyL3RvbmVidXJzdC5Nb25vdG9uZUNvbmZpZ/+NAwEBDk1vbm90b25lQ29uZmlnAf+OAAEDAQxBZGRTZXF1ZW5jZXMB/5AAAQ9SZW1vdmVTZXF1ZW5jZXMB/5IAAQpTcGVha0ZpcnN0AQIAAAAq/48DAQEISW5zdGFuY2UB/5AAAQIBBERlc2MB/5IAAQRBcmdzAf+WAAAAJP+RAwEBC0Rlc2NyaXB0aW9uAf+SAAEBAQVQYXJ0cwH/lAAAACH/kwIBARNbXW1vbm9saXRoLk1vbm9saXRoAf+UAAEQAAAo/5UDAQEEQXJncwH/lgABAgEGVmFsdWVzAf+YAAEFSW5kZXgBBAAAABz/lwIBAQ5bXWludGVyZmFjZSB7fQH/mAABEAAA/gUc/45jAQEBAjxnaXRodWIuY29tL09wZXJhdG9yRm91bmRhdGlvbi9tb25vbGl0aC1nby9tb25vbGl0aC5CeXRlc1BhcnT/mQMBAQlCeXRlc1BhcnQB/5oAAQEBBUl0ZW1zAf+cAAAAIf+bAgEBE1tdbW9ub2xpdGguQnl0ZVR5cGUB/5wAARAAAP4Dxf+a/4YBAktnaXRodWIuY29tL09wZXJhdG9yRm91bmRhdGlvbi9tb25vbGl0aC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guUmFuZG9tRW51bWVyYXRlZEJ5dGVUeXBl/6AHAQQREhMUAEtnaXRodWIuY29tL09wZXJhdG9yRm91bmRhdGlvbi9tb25vbGl0aC1nby9tb25vbGl0aC5SYW5kb21FbnVtZXJhdGVkQnl0ZVR5cGX/oAcBBBESExQAADxnaXRodWIuY29tL09wZXJhdG9yRm91bmRhdGlvbi9tb25vbGl0aC1nby9tb25vbGl0aC5CeXRlc1BhcnT/mv+vAQJLZ2l0aHViLmNvbS9PcGVyYXRvckZvdW5kYXRpb24vbW9ub2xpdGgtZ28vbW9ub2xpdGguUmFuZG9tRW51bWVyYXRlZEJ5dGVUeXBl/6AHAQQREhMUAEtnaXRodWIuY29tL09wZXJhdG9yRm91bmRhdGlvbi9tb25vbGl0aC1nby9tb25vbGl0aC5SYW5kb21FbnVtZXJhdGVkQnl0ZVR5cGX/oAcBBBESExQAAAAAAW1naXRodWIuY29tL09wZXJhdG9yRm91bmRhdGlvbi9zaGFwZXNoaWZ0ZXItdHJhbnNwb3J0cy90cmFuc3BvcnRzL1JlcGxpY2FudC92My9wb2xpc2guU2lsdmVyUG9saXNoU2VydmVyQ29uZmln/4sDAQEYU2lsdmVyUG9saXNoU2VydmVyQ29uZmlnAf+MAAEDAQ9TZXJ2ZXJQdWJsaWNLZXkBCgABEFNlcnZlclByaXZhdGVLZXkBCgABCUNodW5rU2l6ZQEEAAAAbv+MagFBBD8u1EfCuMLPMAWvQagt9cJqY4DxD1JKIAsay9f/RaLsslRum7Oy05BXI5StXteskm66qzog8PT4dphf5GnC+e4BIIBLchU1rtGnBcGXOPR/nMbz9PcfevBPsm+0/EDZODkpAf4KngAA"}} \ No newline at end of file diff --git a/transports/Replicant/v3/config.go b/transports/Replicant/v3/config.go index 8643d36..579a3a6 100644 --- a/transports/Replicant/v3/config.go +++ b/transports/Replicant/v3/config.go @@ -26,13 +26,14 @@ package replicant import ( "encoding/json" - "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v2/polish" - "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v2/toneburst" + "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v3/polish" + "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v3/toneburst" ) type ClientConfig struct { Toneburst toneburst.Config Polish polish.ClientConfig + Address string } type ServerConfig struct { @@ -40,16 +41,19 @@ type ServerConfig struct { Polish polish.ServerConfig } -func (config ServerConfig) Marshal() (string, error) { +type ClientJSONConfig struct { + Config string `json:"config"` +} - type ServerJSONInnerConfig struct { - Config string `json:"config"` - } +type ServerJSONInnerConfig struct { + Config string `json:"config"` +} - type ServerJSONOuterConfig struct { - Replicant ServerJSONInnerConfig - } +type ServerJSONOuterConfig struct { + Replicant ServerJSONInnerConfig +} +func (config ServerConfig) Marshal() (string, error) { configString, configStringError := config.Encode() if configStringError != nil { return "", configStringError @@ -68,10 +72,6 @@ func (config ServerConfig) Marshal() (string, error) { func (config ClientConfig) Marshal() (string, error) { - type ClientJSONConfig struct { - Config string `json:"config"` - } - configString, configStringError := config.Encode() if configStringError != nil { return "", configStringError diff --git a/transports/Replicant/v3/go.mod b/transports/Replicant/v3/go.mod index 4ee9392..063ac28 100644 --- a/transports/Replicant/v3/go.mod +++ b/transports/Replicant/v3/go.mod @@ -1,10 +1,11 @@ -module github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v2 +module github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v3 go 1.12 require ( github.com/OperatorFoundation/monolith-go/monolith v1.0.4 github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0 + github.com/kataras/golog v0.0.18 github.com/opentracing/opentracing-go v1.1.0 golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 golang.org/x/net v0.0.0-20200202094626-16171245cfb2 diff --git a/transports/Replicant/v3/go.sum b/transports/Replicant/v3/go.sum index fa3bd56..8d20f0d 100644 --- a/transports/Replicant/v3/go.sum +++ b/transports/Replicant/v3/go.sum @@ -4,6 +4,10 @@ github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0 h1:6aQs+TF3KULMarpzbKu8 github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0/go.mod h1:gb/QiZH0QDXLSQ9PskyJ2oTflB7tsP4AYc8y+FppvB0= github.com/deckarep/golang-set v1.7.1 h1:SCQV0S6gTtp6itiFrTqI+pfmJ4LN85S1YzhDf9rTHJQ= github.com/deckarep/golang-set v1.7.1/go.mod h1:93vsz/8Wt4joVM7c2AVqh+YRMiUSc14yDtF28KmMOgQ= +github.com/kataras/golog v0.0.18 h1:Td7hcKN25yzqB/0SO5iohOsMk5Mq5V9kDtM5apaJLY0= +github.com/kataras/golog v0.0.18/go.mod h1:jRYl7dFYqP8aQj9VkwdBUXYZSfUktm+YYg1arJILfyw= +github.com/kataras/pio v0.0.8 h1:6pX6nHJk7DAV3x1dEimibQF2CmJLlo0jWVmM9yE9KY8= +github.com/kataras/pio v0.0.8/go.mod h1:NFfMp2kVP1rmV4N6gH6qgWpuoDKlrOeYi3VrAIWCGsE= github.com/opentracing/opentracing-go v1.1.0 h1:pWlfV3Bxv7k65HYwkikxat0+s3pV4bsqf19k25Ur8rU= github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= diff --git a/transports/Replicant/v3/persistence.go b/transports/Replicant/v3/persistence.go index 24f08f2..9f87825 100644 --- a/transports/Replicant/v3/persistence.go +++ b/transports/Replicant/v3/persistence.go @@ -29,8 +29,8 @@ import ( "encoding/base64" "encoding/gob" "github.com/OperatorFoundation/monolith-go/monolith" - "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v2/polish" - "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v2/toneburst" + "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v3/polish" + "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v3/toneburst" ) func InitializeGobRegistry() { diff --git a/transports/Replicant/v3/persistence_test.go b/transports/Replicant/v3/persistence_test.go index 3d3cec9..6216e8c 100644 --- a/transports/Replicant/v3/persistence_test.go +++ b/transports/Replicant/v3/persistence_test.go @@ -2,8 +2,8 @@ package replicant import ( "encoding/json" - "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v2/polish" - "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v2/toneburst" + "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v3/polish" + "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v3/toneburst" "io/ioutil" "testing" ) diff --git a/transports/Replicant/v3/polish/silver.go b/transports/Replicant/v3/polish/silver.go index 8ea5639..62b300f 100644 --- a/transports/Replicant/v3/polish/silver.go +++ b/transports/Replicant/v3/polish/silver.go @@ -175,6 +175,8 @@ func NewSilverClient(config SilverPolishClientConfig) (Connection, error) { } func X963KDF(sharedKeySeed []byte, ephemeralPublicKey []byte) []byte { + + //FIXME: Is this a correct X963 KDF length := 32 output := make([]byte, 0) outlen := 0 diff --git a/transports/Replicant/v3/pt21.go b/transports/Replicant/v3/pt21.go index 66c296b..3e98423 100644 --- a/transports/Replicant/v3/pt21.go +++ b/transports/Replicant/v3/pt21.go @@ -31,10 +31,10 @@ import ( ) // Create outgoing transport connection -func (config ClientConfig) Dial(address string) net.Conn { +func (config ClientConfig) Dial(address string) (net.Conn, error) { conn, dialErr := net.Dial("tcp", address) if dialErr != nil { - return nil + return nil, dialErr } transportConn, err := NewClientConnection(conn, config) @@ -42,25 +42,25 @@ func (config ClientConfig) Dial(address string) net.Conn { if conn != nil { _ = conn.Close() } - return nil + return nil, err } - return transportConn + return transportConn, nil } // Create listener for incoming transport connection -func (config ServerConfig) Listen(address string) net.Listener { +func (config ServerConfig) Listen(address string) (net.Listener, error) { addr, resolveErr := pt.ResolveAddr(address) if resolveErr != nil { - return nil + return nil, resolveErr } ln, err := net.ListenTCP("tcp", addr) if err != nil { - return nil + return nil, err } - return newReplicantTransportListener(ln, config) + return newReplicantTransportListener(ln, config), nil } func (listener *replicantTransportListener) Addr() net.Addr { @@ -77,6 +77,7 @@ func (listener *replicantTransportListener) Accept() (net.Conn, error) { } config := listener.config + return NewServerConnection(conn, config) } @@ -87,79 +88,13 @@ func (listener *replicantTransportListener) Close() error { } func (sconn *Connection) Read(b []byte) (int, error) { - if sconn.state.polish != nil { - - if len(b) == 0 { - return 0, nil - } - - if sconn.receiveBuffer.Len() > 0 { - if len(b) <= sconn.receiveBuffer.Len() { - // Read the decrypted data into the provided slice "b" - readLen, readError := sconn.receiveBuffer.Read(b) - if readError != nil { - return 0, readError - } - - // We've delivered all unpolished data from the buffer, let's clear it out - // Read just moves the offset but leaves the data in place, we need to reset the buffer - if sconn.receiveBuffer.Len() == 0 { - sconn.receiveBuffer.Reset() - } - - return readLen, nil - } else { - result := make([]byte, len(b)) - - // Read the decrypted data into the provided slice "b" - readLen, readError := sconn.receiveBuffer.Read(result) - sconn.receiveBuffer.Reset() - if readError != nil { - return 0, readError - } - - stillNeeded := result[readLen:] - snReadLen, snReadError := sconn.Read(stillNeeded) - if snReadError != nil { - return 0, snReadError - } - - // Keep reading until we get the full requested length, or an error - for snReadLen < len(stillNeeded) { - // Keep reading, we didn't get enough data - stillNeeded = stillNeeded[snReadLen:] - snReadLen, snReadError = sconn.Read(stillNeeded) - if snReadError != nil { - return 0, snReadError - } - } - - copy(b, result) - return len(result), nil - } - } - - // Make sure to discard stale data by overwriting b with zeros - zeros := make([]byte, len(b)) - copy(b, zeros) - - chunkSize := sconn.state.polish.GetChunkSize() - polished := make([]byte, chunkSize) + polished := make([]byte, sconn.state.polish.GetChunkSize()) // Read encrypted data from the connection and put it into our polished slice - connReadLen, connReadError := sconn.conn.Read(polished) - if connReadError != nil { - return 0, connReadError - } - - for connReadLen < chunkSize { - // Keep reading, we didn't get enough data - partialPolish := polished[connReadLen:] - connReadLen, connReadError = sconn.conn.Read(partialPolish) - if connReadError != nil { - return 0, connReadError - } + _, err := sconn.conn.Read(polished) + if err != nil { + return 0, err } // Decrypt the data @@ -168,23 +103,18 @@ func (sconn *Connection) Read(b []byte) (int, error) { return 0, unpolishError } - if len(unpolished) <= len(b) { - copy(b, unpolished) - return len(unpolished), nil - } else { - // This will copy only up to the length of b from unpolished to b - copy(b, unpolished) - - remainingUnpolished := unpolished[len(b):] + // Empty the buffer and write the decrypted data to it + sconn.receiveBuffer.Reset() + sconn.receiveBuffer.Write(unpolished) - // Empty the buffer and write the decrypted data to it - sconn.receiveBuffer.Reset() - sconn.receiveBuffer.Write(remainingUnpolished) - - // Return b, and leave the remaining unpolished in the buffer - return len(b), nil + // Read the decrypted data into the provided slice "b" + _, readError := sconn.receiveBuffer.Read(b) + if readError != nil { + return 0, readError } + sconn.receiveBuffer.Reset() + return len(b), nil } else { // Read from the connection directly into the provided slice "b" return sconn.conn.Read(b) diff --git a/transports/Replicant/v3/replicant.go b/transports/Replicant/v3/replicant.go index a778a56..bb8c59f 100644 --- a/transports/Replicant/v3/replicant.go +++ b/transports/Replicant/v3/replicant.go @@ -30,8 +30,8 @@ import ( "fmt" "net" - "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v2/polish" - "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v2/toneburst" + "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v3/polish" + "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v3/toneburst" ) type ConnectionState struct { diff --git a/transports/Replicant/v3/replicant_test.go b/transports/Replicant/v3/replicant_test.go index 7985c07..50ba459 100644 --- a/transports/Replicant/v3/replicant_test.go +++ b/transports/Replicant/v3/replicant_test.go @@ -3,8 +3,10 @@ package replicant import ( "bytes" "github.com/OperatorFoundation/monolith-go/monolith" - "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v2/polish" - "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v2/toneburst" + "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v3/polish" + "github.com/OperatorFoundation/shapeshifter-transports/transports/Replicant/v3/toneburst" + "github.com/kataras/golog" + "golang.org/x/net/proxy" "io/ioutil" "math/rand" "os" @@ -15,7 +17,7 @@ import ( func TestMain(m *testing.M) { runReplicantServer() - + runReplicantFactoryServer() os.Exit(m.Run()) } @@ -72,7 +74,7 @@ func TestNilsMonotone(t *testing.T) { replicantConnection(clientConfig, serverConfig, t) } -func MarshalSilverRandomEnumeratedConfigs(t *testing.T) { +func TestMarshalSilverRandomEnumeratedConfigs(t *testing.T) { clientConfig, serverConfig := createSilverMonotoneConfigsRandomEnumeratedItems() clientConfigJsonString, clientConfigJsonError := clientConfig.Marshal() @@ -134,6 +136,13 @@ func TestMonotoneRandomEnumerated(t *testing.T) { replicantConnection(clientConfig, serverConfig, t) } +//TODO this test looks identical to the test above apart from naming +func TestFactoryMonotoneRandomEnumerated(t *testing.T) { + clientConfig := createMonotoneClientConfigRandomEnumeratedItems() + serverConfig := createMonotoneServerConfigRandomEnumeratedItems() + replicantFactoryConnection(clientConfig, serverConfig, t) +} + func TestSilver(t *testing.T) { clientConfig, serverConfig := createSilverConfigs() replicantConnection(*clientConfig, *serverConfig, t) @@ -148,7 +157,7 @@ func runReplicantServer() { } go func() { - listener := serverConfig.Listen(addr) + listener, _ := serverConfig.Listen(addr) serverStarted <- true lConn, lConnError := listener.Accept() @@ -171,7 +180,50 @@ func runReplicantServer() { serverFinishedStarting := <-serverStarted if !serverFinishedStarting { - return + return + } +} + +func runReplicantFactoryServer() { + MakeLog() + serverStarted := make(chan bool) + addr := "127.0.0.1:3001" + + serverConfig := ServerConfig{ + Toneburst: nil, + Polish: nil, + } + + server := NewServer(serverConfig, addr, proxy.Direct) + + go func() { + listener, listenError := server.Listen() + if listenError != nil { + return + } + serverStarted <- true + + lConn, lConnError := listener.Accept() + if lConnError != nil { + return + } + + lBuffer := make([]byte, 4) + _, lReadError := lConn.Read(lBuffer) + if lReadError != nil { + return + } + + // Send a response back to person contacting us. + _, lWriteError := lConn.Write([]byte("Message received.")) + if lWriteError != nil { + return + } + }() + + serverFinishedStarting := <-serverStarted + if !serverFinishedStarting { + return } } @@ -194,7 +246,7 @@ func replicantConnection(clientConfig ClientConfig, serverConfig ServerConfig, t addr += portString go func() { - listener := serverConfig.Listen(addr) + listener, _ := serverConfig.Listen(addr) serverStarted <- true lConn, lConnError := listener.Accept() @@ -226,8 +278,82 @@ func replicantConnection(clientConfig ClientConfig, serverConfig ServerConfig, t return } - cConn := clientConfig.Dial(addr) - if cConn == nil { + cConn, connErr := clientConfig.Dial(addr) + if connErr != nil { + t.Fail() + return + } + + writeBytes := []byte{0x0A, 0x11, 0xB0, 0xB1} + _, cWriteError := cConn.Write(writeBytes) + if cWriteError != nil { + t.Fail() + return + } + + readBuffer := make([]byte, 17) + _, cReadError := cConn.Read(readBuffer) + if cReadError != nil { + t.Fail() + return + } + + _ = cConn.Close() + + return +} + +func replicantFactoryConnection(clientConfig ClientConfig, serverConfig ServerConfig, t *testing.T) { + serverStarted := make(chan bool) + MakeLog() + // Get a random port + rand.Seed(time.Now().UnixNano()) + min := 1025 + max := 65535 + portNumber := min + rand.Intn(max-min+1) + portString := strconv.Itoa(portNumber) + addr := "127.0.0.1:" + addr += portString + + go func() { + server := NewServer(serverConfig, addr, proxy.Direct) + listener, listenError := server.Listen() + if listenError != nil { + return + } + serverStarted <- true + + lConn, lConnError := listener.Accept() + if lConnError != nil { + t.Fail() + return + } + + lBuffer := make([]byte, 4) + _, lReadError := lConn.Read(lBuffer) + if lReadError != nil { + t.Fail() + return + } + + // Send a response back to person contacting us. + _, lWriteError := lConn.Write([]byte("Message received.")) + if lWriteError != nil { + t.Fail() + return + } + + _ = listener.Close() + }() + + serverFinishedStarting := <-serverStarted + if !serverFinishedStarting { + t.Fail() + return + } + client := NewClient(clientConfig, proxy.Direct) + cConn, connErr := client.Dial() + if connErr != nil { t.Fail() return } @@ -967,3 +1093,8 @@ func createSampleConfigs() (*ClientConfig, *ServerConfig) { return &clientConfig, &serverConfig } + +func MakeLog() { + golog.SetLevel("debug") + golog.SetOutput(os.Stderr) +} \ No newline at end of file diff --git a/transports/meeklite/v3/LICENSE b/transports/meeklite/v3/LICENSE index e69de29..6b89f8c 100644 --- a/transports/meeklite/v3/LICENSE +++ b/transports/meeklite/v3/LICENSE @@ -0,0 +1,55 @@ +Copyright (c) 2014, Yawning Angel +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +============================================================================== + +Copyright (c) 2012 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + diff --git a/transports/meeklite/v3/go.mod b/transports/meeklite/v3/go.mod index 377b94d..9fccd7f 100644 --- a/transports/meeklite/v3/go.mod +++ b/transports/meeklite/v3/go.mod @@ -1,8 +1,8 @@ -module github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v2 +module github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3 go 1.12 require ( - github.com/stretchr/testify v1.5.1 + github.com/kataras/golog v0.0.18 golang.org/x/net v0.0.0-20200202094626-16171245cfb2 ) diff --git a/transports/meeklite/v3/go.sum b/transports/meeklite/v3/go.sum index fe647ab..93924bc 100644 --- a/transports/meeklite/v3/go.sum +++ b/transports/meeklite/v3/go.sum @@ -1,16 +1,10 @@ -github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/kataras/golog v0.0.18 h1:Td7hcKN25yzqB/0SO5iohOsMk5Mq5V9kDtM5apaJLY0= +github.com/kataras/golog v0.0.18/go.mod h1:jRYl7dFYqP8aQj9VkwdBUXYZSfUktm+YYg1arJILfyw= +github.com/kataras/pio v0.0.8 h1:6pX6nHJk7DAV3x1dEimibQF2CmJLlo0jWVmM9yE9KY8= +github.com/kataras/pio v0.0.8/go.mod h1:NFfMp2kVP1rmV4N6gH6qgWpuoDKlrOeYi3VrAIWCGsE= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/net v0.0.0-20200202094626-16171245cfb2 h1:CCH4IOTTfewWjGOlSp+zGcjutRKlBEZQ6wTn8ozI/nI= golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/transports/meeklite/v3/meeklite.go b/transports/meeklite/v3/meeklite.go index 21d4002..d70b971 100644 --- a/transports/meeklite/v3/meeklite.go +++ b/transports/meeklite/v3/meeklite.go @@ -95,19 +95,19 @@ func (transport *MeekTransport) NetworkDialer() proxy.Dialer { } // Dial creates outgoing transport connection -func (transport *MeekTransport) Dial() net.Conn { +func (transport *MeekTransport) Dial() (net.Conn, error) { // FIXME - should use dialer transportConn, err := newMeekClientConn(transport.clientArgs) if err != nil { - return nil + return nil, err } - return transportConn + return transportConn, nil } // Listen for the meek transport does not have a corresponding server, only a client -func (transport *MeekTransport) Listen() net.Listener { - return nil +func (transport *MeekTransport) Listen() (net.Listener, error) { + return nil, nil } // End methods that implement the base.Transport interface @@ -123,23 +123,31 @@ func (ca *meekClientArgs) Network() string { //Transport contains parameters used in Optimizer type Transport struct { - URL *gourl.URL `json:"url"` - Front string `json:"front"` - Address string - Dialer proxy.Dialer + URL *gourl.URL + Front string + Dialer proxy.Dialer } //Config puts the parameters in a json compatible format type Config struct { - URL *gourl.URL `json:"url"` - Front string `json:"front"` + URL *gourl.URL `json:"url"` + Front string `json:"front"` + Address string `json:"address"` +} + +func NewMeekFactoryTransportWithFront(url *gourl.URL, front string, dialer proxy.Dialer) *Transport { + return &Transport{url, front, dialer} } // Dial creates outgoing transport connection func (transport Transport) Dial() (net.Conn, error) { meekTransport := NewMeekTransportWithFront(transport.URL.String(), transport.Front, transport.Dialer) - conn := meekTransport.Dial() - return conn, nil + conn, dialErr := meekTransport.Dial() + if dialErr != nil { + return nil, errors.New("failed to dial") + } else { + return conn, nil + } } func (ca *meekClientArgs) String() string { @@ -230,23 +238,23 @@ func (transportConn *meekConn) Read(p []byte) (n int, err error) { return } select { - case <-time.After(20*time.Second): - return 0, nil - // Wait for the worker to enqueue more incoming data. - case b, ok := <-transportConn.workerRdChan: - if !ok { - // Close() was called and the worker's shutting down. - return 0, io.ErrClosedPipe - } + case <-time.After(20 * time.Second): + return 0, nil + // Wait for the worker to enqueue more incoming data. + case b, ok := <-transportConn.workerRdChan: + if !ok { + // Close() was called and the worker's shutting down. + return 0, io.ErrClosedPipe + } - // Ew, an extra copy, but who am I kidding, it's meek. - buf := bytes.NewBuffer(b) - n, err = buf.Read(p) - if buf.Len() > 0 { - // If there's data pending, stash the buffer so the next - // Read() call will use it to fulfill the Read(). - transportConn.rdBuf = buf - } + // Ew, an extra copy, but who am I kidding, it's meek. + buf := bytes.NewBuffer(b) + n, err = buf.Read(p) + if buf.Len() > 0 { + // If there's data pending, stash the buffer so the next + // Read() call will use it to fulfill the Read(). + transportConn.rdBuf = buf + } } return } @@ -356,7 +364,7 @@ func (transportConn *meekConn) roundTrip(sndBuf []byte) (recvBuf []byte, err err if resp.StatusCode == http.StatusInternalServerError { return } - time.Sleep(retryDelay) + time.Sleep(retryDelay) } else { _ = resp.Body.Close() diff --git a/transports/meeklite/v3/meeklite_test.go b/transports/meeklite/v3/meeklite_test.go index b26d710..92c42d3 100644 --- a/transports/meeklite/v3/meeklite_test.go +++ b/transports/meeklite/v3/meeklite_test.go @@ -34,21 +34,25 @@ package meeklite import ( + "github.com/kataras/golog" "golang.org/x/net/proxy" + gourl "net/url" + "os" "testing" ) const data = "test" func TestMeeklite(t *testing.T) { + MakeLog() //create a server config := NewMeekTransportWithFront("https://transport-canary-meek.appspot.com/", "www.google.com", proxy.Direct) //create client buffer clientBuffer := make([]byte, 4) //call dial on client and check error - clientConn := config.Dial() - if clientConn == nil { + clientConn, connErr := config.Dial() + if connErr != nil { t.Fail() return } @@ -75,3 +79,52 @@ func TestMeeklite(t *testing.T) { return } } + +func TestFactoryMeeklite(t *testing.T) { + MakeLog() + //create a server + urlString := "https://transport-canary-meek.appspot.com/" + Url, err := gourl.Parse(urlString) + if err != nil { + t.Fail() + return + } + + config := NewMeekFactoryTransportWithFront(Url, "www.google.com", proxy.Direct) + + //create client buffer + clientBuffer := make([]byte, 4) + //call dial on client and check error + clientConn, connErr := config.Dial() + if connErr != nil { + t.Fail() + return + } + + //write data from clientConn for server to read + writeBytes, clientWriteErr := clientConn.Write([]byte(data)) + if clientWriteErr != nil { + t.Fail() + return + } + if writeBytes <= 0 { + t.Fail() + return + } + + //read on client side + readBytes, clientReadErr := clientConn.Read(clientBuffer) + if clientReadErr != nil { + t.Fail() + return + } + if readBytes <= 0 { + t.Fail() + return + } +} + +func MakeLog() { + golog.SetLevel("debug") + golog.SetOutput(os.Stderr) +} \ No newline at end of file diff --git a/transports/meekserver/v3/LICENSE b/transports/meekserver/v3/LICENSE new file mode 100644 index 0000000..6b89f8c --- /dev/null +++ b/transports/meekserver/v3/LICENSE @@ -0,0 +1,55 @@ +Copyright (c) 2014, Yawning Angel +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +============================================================================== + +Copyright (c) 2012 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + diff --git a/transports/meekserver/v3/certificate.go b/transports/meekserver/v3/certificate.go index 4daccf0..9f9edf7 100644 --- a/transports/meekserver/v3/certificate.go +++ b/transports/meekserver/v3/certificate.go @@ -1,3 +1,30 @@ +/* + * Copyright (c) 2014, Yawning Angel + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + // certificate.go - Certificate management for meek-server. // +build go1.6 @@ -6,7 +33,7 @@ package meekserver import ( "crypto/tls" - "log" + "github.com/kataras/golog" "os" "sync" "time" @@ -99,7 +126,7 @@ func (ctx *certContext) GetCertificate(*tls.ClientHelloInfo) (*tls.Certificate, now := time.Now() if now.After(ctx.lastWarnAt.Add(certLoadErrorRateLimit)) { ctx.lastWarnAt = now - log.Printf("failed to reload certificate: %v", err) + golog.Infof("failed to reload certificate: %v", err) } } diff --git a/transports/meekserver/v3/go.mod b/transports/meekserver/v3/go.mod index 3ac5d1d..afc636b 100644 --- a/transports/meekserver/v3/go.mod +++ b/transports/meekserver/v3/go.mod @@ -1,10 +1,10 @@ -module github.com/OperatorFoundation/shapeshifter-transports/transports/meekserver/v2 +module github.com/OperatorFoundation/shapeshifter-transports/transports/meekserver/v3 go 1.12 require ( - git.torproject.org/pluggable-transports/goptlib.git v1.1.0 github.com/deckarep/golang-set v1.7.1 + github.com/kataras/golog v0.0.18 github.com/mufti1/interconv v0.0.0-20190313040840-d7c72925c656 golang.org/x/crypto v0.0.0-20200214034016-1d94cc7ab1c6 golang.org/x/net v0.0.0-20200202094626-16171245cfb2 diff --git a/transports/meekserver/v3/go.sum b/transports/meekserver/v3/go.sum index 3bd92d5..891e062 100644 --- a/transports/meekserver/v3/go.sum +++ b/transports/meekserver/v3/go.sum @@ -1,7 +1,9 @@ -git.torproject.org/pluggable-transports/goptlib.git v1.1.0 h1:LMQAA8pAho+QtYrrVNimJQiINNEwcwuuD99vezD/PAo= -git.torproject.org/pluggable-transports/goptlib.git v1.1.0/go.mod h1:YT4XMSkuEXbtqlydr9+OxqFAyspUv0Gr9qhM3B++o/Q= github.com/deckarep/golang-set v1.7.1 h1:SCQV0S6gTtp6itiFrTqI+pfmJ4LN85S1YzhDf9rTHJQ= github.com/deckarep/golang-set v1.7.1/go.mod h1:93vsz/8Wt4joVM7c2AVqh+YRMiUSc14yDtF28KmMOgQ= +github.com/kataras/golog v0.0.18 h1:Td7hcKN25yzqB/0SO5iohOsMk5Mq5V9kDtM5apaJLY0= +github.com/kataras/golog v0.0.18/go.mod h1:jRYl7dFYqP8aQj9VkwdBUXYZSfUktm+YYg1arJILfyw= +github.com/kataras/pio v0.0.8 h1:6pX6nHJk7DAV3x1dEimibQF2CmJLlo0jWVmM9yE9KY8= +github.com/kataras/pio v0.0.8/go.mod h1:NFfMp2kVP1rmV4N6gH6qgWpuoDKlrOeYi3VrAIWCGsE= github.com/mufti1/interconv v0.0.0-20190313040840-d7c72925c656 h1:p+IdebEeB9SAEH9IOJVF6oZ535bwvWqUdqWxG1UWeko= github.com/mufti1/interconv v0.0.0-20190313040840-d7c72925c656/go.mod h1:+db4NNs1NvceiftEzz0ymfu3zKLkynYukafc7llNoMs= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= @@ -11,6 +13,7 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20200202094626-16171245cfb2 h1:CCH4IOTTfewWjGOlSp+zGcjutRKlBEZQ6wTn8ozI/nI= golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/transports/meekserver/v3/meek-server.go b/transports/meekserver/v3/meek-server.go index dbd64b0..a74bbdf 100644 --- a/transports/meekserver/v3/meek-server.go +++ b/transports/meekserver/v3/meek-server.go @@ -1,3 +1,30 @@ +/* + * Copyright (c) 2014, Yawning Angel + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + // Package meekserver is the server transport plugin for the meek pluggable transport. // It acts as an HTTP server, keeps track of session ids, and forwards received // data to a local OR port. @@ -22,8 +49,8 @@ package meekserver import ( "crypto/tls" "fmt" + "github.com/kataras/golog" "io" - "log" "net" "net/http" "path" @@ -162,7 +189,7 @@ func (a scrubbedAddr) String() string { return "[scrubbed]" } -// Replace the Addr in a net.OpError with "[scrubbed]" for logging. +// Replace the Addr in a net.OpError with "[scrubbed]" for golog. func scrubError(err error) error { if operr, ok := err.(*net.OpError); ok { // net.OpError contains Op, Net, Addr, and a subsidiary Err. The @@ -219,14 +246,14 @@ func (state *State) Post(w http.ResponseWriter, req *http.Request) { session, err := state.GetSession(sessionID) if err != nil { - log.Print(err) + golog.Error(err) httpInternalServerError(w) return } err = transact(session, w, req) if err != nil { - log.Print(err) + golog.Error(err) state.CloseSession(sessionID) return } @@ -318,10 +345,10 @@ func initServer(addr *net.TCPAddr, func startServer(addr *net.TCPAddr) (*http.Server, *State, error) { return initServer(addr, nil, func(server *http.Server, errChan chan<- error) { - log.Printf("listening with plain HTTP on %s", addr) + golog.Errorf("listening with plain HTTP on %s", addr) err := server.ListenAndServe() if err != nil { - log.Printf("Error in ListenAndServe: %s", err) + golog.Errorf("Error in ListenAndServe: %s", err) } errChan <- err }) @@ -329,10 +356,10 @@ func startServer(addr *net.TCPAddr) (*http.Server, *State, error) { func startServerTLS(addr *net.TCPAddr, getCertificate func(*tls.ClientHelloInfo) (*tls.Certificate, error)) (*http.Server, *State, error) { return initServer(addr, getCertificate, func(server *http.Server, errChan chan<- error) { - log.Printf("listening with HTTPS on %s", addr) + golog.Errorf("listening with HTTPS on %s", addr) err := server.ListenAndServeTLS("", "") if err != nil { - log.Printf("Error in ListenAndServeTLS: %s", err) + golog.Errorf("Error in ListenAndServeTLS: %s", err) } errChan <- err }) diff --git a/transports/meekserver/v3/meekserver_test.go b/transports/meekserver/v3/meekserver_test.go index 0f7788f..4d19edd 100644 --- a/transports/meekserver/v3/meekserver_test.go +++ b/transports/meekserver/v3/meekserver_test.go @@ -1,6 +1,8 @@ package meekserver import ( + "github.com/kataras/golog" + "os" "testing" ) @@ -12,8 +14,7 @@ import ( // t.Fail() // } //} - -func TestMeekServerListen2(t *testing.T) { +func TestMeekServerListen(t *testing.T) { acmeEmail := "brandon@operatorfoundation.org" keyFileName := "operatorrss.com" meekserverTransport := NewMeekTransportServer(false, acmeEmail, keyFileName, "state") @@ -21,9 +22,30 @@ func TestMeekServerListen2(t *testing.T) { t.Fail() return } - listener := meekserverTransport.Listen("127.0.0.1:8080") - if listener == nil { + _, listenErr := meekserverTransport.Listen("127.0.0.1:8080") + if listenErr != nil { + t.Fail() + return + } +} + +func TestMeekServerFactoryListen(t *testing.T) { +MakeLog() + acmeEmail := "brandon@operatorfoundation.org" + acmeHostNames := "operatorrss.com" + meekserverTransport, newError := New(false, acmeHostNames, acmeEmail,"127.0.0.1:8080", "state") + if newError != nil { + t.Fail() + return + } + _, listenErr := meekserverTransport.Listen() + if listenErr != nil { t.Fail() return } +} + +func MakeLog() { + golog.SetLevel("debug") + golog.SetOutput(os.Stderr) } \ No newline at end of file diff --git a/transports/meekserver/v3/pt21.go b/transports/meekserver/v3/pt21.go index 63c12b7..6e67333 100644 --- a/transports/meekserver/v3/pt21.go +++ b/transports/meekserver/v3/pt21.go @@ -24,6 +24,33 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ +/* + * Copyright (c) 2014, Yawning Angel + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + // Package meekserver provides an implementation of the Meek circumvention // protocol. Only a client implementation is provided, and no effort is @@ -34,9 +61,9 @@ package meekserver import ( "errors" + "github.com/kataras/golog" interconv "github.com/mufti1/interconv/package" "golang.org/x/crypto/acme/autocert" - "log" "net" "net/http" "strings" @@ -51,6 +78,12 @@ type MeekServer struct { CertManager *autocert.Manager } +type Transport struct { + DisableTLS bool + CertManager *autocert.Manager + Address string +} + //Config contains arguments formatted for a json file type Config struct { AcmeEmail string `json:"acme-email"` @@ -73,6 +106,50 @@ type fakeConn struct { writeBuffer []byte } +func New(disableTLS bool, acmeHostnamesCommas string, acmeEmail string, address string, stateDir string) (*Transport, error) { + var certManager *autocert.Manager + if disableTLS { + if acmeEmail != "" || acmeHostnamesCommas != "" { + return nil, errors.New("acmeEmail and acmeHostnames must be empty when disableTLS is enabled") + } + return nil, errors.New("disableTLS mode is not yet supported") + } else { + if acmeEmail == "" || acmeHostnamesCommas == "" { + return nil, errors.New("acmeEmail and acmeHostnames must be empty when disableTLS is disabled") + } + if acmeHostnamesCommas != "" { + acmeHostnames := strings.Split(acmeHostnamesCommas, ",") + golog.Infof("ACME hostnames: %q", acmeHostnames) + + // The ACME HTTP-01 responder only works when it is running on + // port 80. + // https://github.com/ietf-wg-acme/acme/blob/master/draft-ietf-acme-acme.md#http-challenge + + var cache autocert.Cache + cacheDir, err := getCertificateCacheDir(stateDir) + if err == nil { + golog.Infof("caching ACME certificates in directory %q", cacheDir) + cache = autocert.DirCache(cacheDir) + } else { + golog.Infof("disabling ACME certificate cache: %s", err) + } + + certManager = &autocert.Manager{ + Prompt: autocert.AcceptTOS, + HostPolicy: autocert.HostWhitelist(acmeHostnames...), + Email: acmeEmail, + Cache: cache, + } + return &Transport{ + DisableTLS: disableTLS, + CertManager: certManager, + Address: address, + }, nil + } else { + return nil, errors.New("must set acmeEmail") + } + } +} func (listener meekListener) Accept() (net.Conn, error) { state := listener.state state.lock.Lock() @@ -106,13 +183,13 @@ func (listener meekListener) Addr() net.Addr { } func (conn meekServerConn) Read(b []byte) (n int, err error) { - if len(conn.session.Or.readBuffer) == 0 || len(b) == 0 { + if len(conn.session.Or.readBuffer) == 0 { return 0, nil - } else { - copyLength := copy(b, conn.session.Or.readBuffer) - conn.session.Or.readBuffer = conn.session.Or.readBuffer[copyLength:] - return copyLength, nil } + copy(b, conn.session.Or.readBuffer) + conn.session.Or.readBuffer = conn.session.Or.readBuffer[:0] + + return len(b), nil } func (conn meekServerConn) Write(b []byte) (n int, err error) { @@ -159,7 +236,7 @@ func NewMeekTransportServer(disableTLS bool, acmeEmail string, acmeHostnamesComm } if acmeHostnamesCommas != "" { acmeHostnames := strings.Split(acmeHostnamesCommas, ",") - log.Printf("ACME hostnames: %q", acmeHostnames) + golog.Infof("ACME hostnames: %q", acmeHostnames) // The ACME HTTP-01 responder only works when it is running on // port 80. @@ -168,10 +245,10 @@ func NewMeekTransportServer(disableTLS bool, acmeEmail string, acmeHostnamesComm var cache autocert.Cache cacheDir, err := getCertificateCacheDir(stateDir) if err == nil { - log.Printf("caching ACME certificates in directory %q", cacheDir) + golog.Infof("caching ACME certificates in directory %q", cacheDir) cache = autocert.DirCache(cacheDir) } else { - log.Printf("disabling ACME certificate cache: %s", err) + golog.Infof("disabling ACME certificate cache: %s", err) } certManager = &autocert.Manager{ @@ -188,13 +265,49 @@ func NewMeekTransportServer(disableTLS bool, acmeEmail string, acmeHostnamesComm // Methods that implement the base.Transport interface // Listen on the meek transport does not have a corresponding server, only a client -func (transport *MeekServer) Listen(address string) net.Listener { +func (transport *MeekServer) Listen(address string) (net.Listener, error) { var ln net.Listener var state *State var err error addr, resolverr := net.ResolveTCPAddr("tcp", address) if resolverr != nil { - return ln + return ln, resolverr + } + acmeAddr := net.TCPAddr{ + IP: addr.IP, + Port: 80, + Zone: "", + } + acmeAddr.Port = 80 + golog.Infof("starting HTTP-01 ACME listener on %s", acmeAddr.String()) + lnHTTP01, err := net.ListenTCP("tcp", &acmeAddr) + if err != nil { + golog.Infof("error opening HTTP-01 ACME listener: %s", err) + return nil, err + } + go func() { + golog.Fatal(http.Serve(lnHTTP01, transport.CertManager.HTTPHandler(nil))) + }() + var server *http.Server + if transport.DisableTLS { + server, state, err = startServer(addr) + } else { + server, state, err = startServerTLS(addr, transport.CertManager.GetCertificate) + } + if err != nil { + + return nil, err + } + return meekListener{server, state}, nil +} + +func (transport *Transport) Listen() (net.Listener, error) { + var ln net.Listener + var state *State + var err error + addr, resolverr := net.ResolveTCPAddr("tcp", transport.Address) + if resolverr != nil { + return ln, resolverr } acmeAddr := net.TCPAddr{ IP: addr.IP, @@ -202,14 +315,14 @@ func (transport *MeekServer) Listen(address string) net.Listener { Zone: "", } acmeAddr.Port = 80 - log.Printf("starting HTTP-01 ACME listener on %s", acmeAddr.String()) + golog.Infof("starting HTTP-01 ACME listener on %s", acmeAddr.String()) lnHTTP01, err := net.ListenTCP("tcp", &acmeAddr) if err != nil { - log.Printf("error opening HTTP-01 ACME listener: %s", err) - return nil + golog.Infof("error opening HTTP-01 ACME listener: %s", err) + return nil, err } go func() { - log.Fatal(http.Serve(lnHTTP01, transport.CertManager.HTTPHandler(nil))) + golog.Fatal(http.Serve(lnHTTP01, transport.CertManager.HTTPHandler(nil))) }() var server *http.Server if transport.DisableTLS { @@ -219,7 +332,7 @@ func (transport *MeekServer) Listen(address string) net.Listener { } if err != nil { - return nil + return nil, err } - return meekListener{server, state} + return meekListener{server, state}, nil } diff --git a/transports/meekserver/v3/useraddr.go b/transports/meekserver/v3/useraddr.go index 599ca6f..a2ff086 100644 --- a/transports/meekserver/v3/useraddr.go +++ b/transports/meekserver/v3/useraddr.go @@ -1,3 +1,30 @@ +/* + * Copyright (c) 2014, Yawning Angel + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + package meekserver import ( diff --git a/transports/obfs2/v3/LICENSE b/transports/obfs2/v3/LICENSE new file mode 100644 index 0000000..6b89f8c --- /dev/null +++ b/transports/obfs2/v3/LICENSE @@ -0,0 +1,55 @@ +Copyright (c) 2014, Yawning Angel +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +============================================================================== + +Copyright (c) 2012 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + diff --git a/transports/obfs2/v3/go.mod b/transports/obfs2/v3/go.mod index acfdfab..c9ed2e6 100644 --- a/transports/obfs2/v3/go.mod +++ b/transports/obfs2/v3/go.mod @@ -1,9 +1,10 @@ -module github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v2 +module github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 go 1.12 require ( github.com/OperatorFoundation/obfs4 v1.0.0 github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0 + github.com/kataras/golog v0.0.18 golang.org/x/net v0.0.0-20200226121028-0de0cce0169b ) diff --git a/transports/obfs2/v3/go.sum b/transports/obfs2/v3/go.sum index 139977a..9e479db 100644 --- a/transports/obfs2/v3/go.sum +++ b/transports/obfs2/v3/go.sum @@ -7,17 +7,16 @@ github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0 h1:6aQs+TF3KULMarpzbKu8 github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0/go.mod h1:gb/QiZH0QDXLSQ9PskyJ2oTflB7tsP4AYc8y+FppvB0= github.com/dchest/siphash v1.2.1 h1:4cLinnzVJDKxTCl9B01807Yiy+W7ZzVHj/KIroQRvT4= github.com/dchest/siphash v1.2.1/go.mod h1:q+IRvb2gOSrUnYoPqHiyHXS0FOBBOdl6tONBlVnOnt4= -github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88= -github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= +github.com/kataras/golog v0.0.18 h1:Td7hcKN25yzqB/0SO5iohOsMk5Mq5V9kDtM5apaJLY0= +github.com/kataras/golog v0.0.18/go.mod h1:jRYl7dFYqP8aQj9VkwdBUXYZSfUktm+YYg1arJILfyw= +github.com/kataras/pio v0.0.8 h1:6pX6nHJk7DAV3x1dEimibQF2CmJLlo0jWVmM9yE9KY8= +github.com/kataras/pio v0.0.8/go.mod h1:NFfMp2kVP1rmV4N6gH6qgWpuoDKlrOeYi3VrAIWCGsE= github.com/willscott/goturn v0.0.0-20170802220503-19f41278d0c9/go.mod h1:PfwRjodCaQXOsHnh2DeVaXqCFCIrbn5WLj1+A5bQkD4= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d h1:1ZiEyfaQIg3Qh0EoqpwAakHVhecoE5wlSg5GjnafJGw= golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b h1:0mm1VjtFUOIlE1SbDlwjYaDxZVDP2S5ou6y0gSgXHu8= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= diff --git a/transports/obfs2/v3/obfs2.go b/transports/obfs2/v3/obfs2.go index 2acc079..1052bae 100644 --- a/transports/obfs2/v3/obfs2.go +++ b/transports/obfs2/v3/obfs2.go @@ -36,16 +36,14 @@ import ( "crypto/sha256" "encoding/binary" "fmt" - "log" - "io" "net" "time" + "golang.org/x/net/proxy" + "github.com/OperatorFoundation/obfs4/common/csrand" "github.com/OperatorFoundation/shapeshifter-ipc/v2" - - "golang.org/x/net/proxy" ) const ( @@ -69,6 +67,10 @@ type OptimizerTransport struct { Dialer proxy.Dialer } +type Config struct { + Address string `json:"address"` +} + //Dial connects to a specified address. //this dial function is made to be Optimizer compatible func (transport OptimizerTransport) Dial() (net.Conn, error) { @@ -83,17 +85,31 @@ func (transport OptimizerTransport) Dial() (net.Conn, error) { transportConn, err := newObfs2ClientConn(conn) if err != nil { _ = dialConn.Close() - log.Fatalf("dial connection failed") return nil, err } return transportConn, nil } +func (transport OptimizerTransport) Listen() (net.Listener, error) { + addr, resolveErr := pt.ResolveAddr(transport.Address) + if resolveErr != nil { + fmt.Println(resolveErr.Error()) + return nil, resolveErr + } + + ln, err := net.ListenTCP("tcp", addr) + if err != nil { + fmt.Println(err.Error()) + return nil, err + } + + return newObfs2TransportListener(ln), nil +} + // Transport is the obfs2 implementation of the base.Transport interface. type Transport struct { dialer proxy.Dialer - } //New initializes obfs2 for Optimizer @@ -150,20 +166,20 @@ func (transport *Transport) Dial(address string) (net.Conn, error) { } // Listen creates listener for incoming transport connection -func (transport *Transport) Listen(address string) net.Listener { +func (transport *Transport) Listen(address string) (net.Listener, error) { addr, resolveErr := pt.ResolveAddr(address) if resolveErr != nil { fmt.Println(resolveErr.Error()) - return nil + return nil, resolveErr } ln, err := net.ListenTCP("tcp", addr) if err != nil { fmt.Println(err.Error()) - return nil + return nil, err } - return newObfs2TransportListener(ln) + return newObfs2TransportListener(ln), nil } // Methods that implement the net.Conn interface diff --git a/transports/obfs2/v3/obfs2_test.go b/transports/obfs2/v3/obfs2_test.go index c118e07..b4e070b 100644 --- a/transports/obfs2/v3/obfs2_test.go +++ b/transports/obfs2/v3/obfs2_test.go @@ -32,6 +32,7 @@ package obfs2 import ( + "github.com/kataras/golog" "golang.org/x/net/proxy" "os" "testing" @@ -97,6 +98,7 @@ func TestObfs2WithDialer(t *testing.T) { } func TestObfs2OptimizerTransportWithDialer(t *testing.T) { +MakeLog() config := New("127.0.0.1:1237", proxy.Direct) //create client buffer clientBuffer := make([]byte, 4) @@ -127,8 +129,8 @@ func RunLocalObfs2Server() { config := NewObfs2Transport() //call listen on the server - serverListener := config.Listen("127.0.0.1:1237") - if serverListener == nil { + serverListener, listenErr := config.Listen("127.0.0.1:1237") + if listenErr != nil { return } @@ -157,4 +159,9 @@ func RunLocalObfs2Server() { } } }() +} + +func MakeLog() { + golog.SetLevel("debug") + golog.SetOutput(os.Stderr) } \ No newline at end of file diff --git a/transports/obfs4/v3/LICENSE b/transports/obfs4/v3/LICENSE new file mode 100644 index 0000000..6b89f8c --- /dev/null +++ b/transports/obfs4/v3/LICENSE @@ -0,0 +1,55 @@ +Copyright (c) 2014, Yawning Angel +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +============================================================================== + +Copyright (c) 2012 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + diff --git a/transports/obfs4/v3/go.mod b/transports/obfs4/v3/go.mod index 1548034..12d8731 100644 --- a/transports/obfs4/v3/go.mod +++ b/transports/obfs4/v3/go.mod @@ -1,10 +1,11 @@ -module github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2 +module github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 go 1.12 require ( github.com/OperatorFoundation/obfs4 v1.0.0 github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0 + github.com/kataras/golog v0.0.18 golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d golang.org/x/net v0.0.0-20200226121028-0de0cce0169b ) diff --git a/transports/obfs4/v3/go.sum b/transports/obfs4/v3/go.sum index 76c4cd7..f1673f2 100644 --- a/transports/obfs4/v3/go.sum +++ b/transports/obfs4/v3/go.sum @@ -3,14 +3,14 @@ github.com/OperatorFoundation/ed25519 v0.0.0-20200225224545-b22b4bd3ddef h1:1xEt github.com/OperatorFoundation/ed25519 v0.0.0-20200225224545-b22b4bd3ddef/go.mod h1:gQNGvsyT4Zmps9H/yzCqdc+RQzt8ZxCndRNtGTYnBzQ= github.com/OperatorFoundation/obfs4 v1.0.0 h1:OcfdNMzv69fKQrLTkTSwpaBkHyBZMLjigA5M3txZpAg= github.com/OperatorFoundation/obfs4 v1.0.0/go.mod h1:6apgxOLYwyvbpzujpFHWu6Jlc+mjn1aFK7WvNijIVWc= -github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0 h1:zDYt6FDJwDSX4woVFVK2EMt7fkxU5L5qDNLUjQwA+BQ= -github.com/OperatorFoundation/shapeshifter-ipc v0.0.0-20170814234159-11746ba927e0/go.mod h1:kB00Ak8Dgn1uZlZHLc/WsUta58Jc+n/ZhCetcPkh42Q= github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0 h1:6aQs+TF3KULMarpzbKu8DhFOF9D2UBCaAN5ZtbK53nQ= github.com/OperatorFoundation/shapeshifter-ipc/v2 v2.0.0/go.mod h1:gb/QiZH0QDXLSQ9PskyJ2oTflB7tsP4AYc8y+FppvB0= github.com/dchest/siphash v1.2.1 h1:4cLinnzVJDKxTCl9B01807Yiy+W7ZzVHj/KIroQRvT4= github.com/dchest/siphash v1.2.1/go.mod h1:q+IRvb2gOSrUnYoPqHiyHXS0FOBBOdl6tONBlVnOnt4= -github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88= -github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= +github.com/kataras/golog v0.0.18 h1:Td7hcKN25yzqB/0SO5iohOsMk5Mq5V9kDtM5apaJLY0= +github.com/kataras/golog v0.0.18/go.mod h1:jRYl7dFYqP8aQj9VkwdBUXYZSfUktm+YYg1arJILfyw= +github.com/kataras/pio v0.0.8 h1:6pX6nHJk7DAV3x1dEimibQF2CmJLlo0jWVmM9yE9KY8= +github.com/kataras/pio v0.0.8/go.mod h1:NFfMp2kVP1rmV4N6gH6qgWpuoDKlrOeYi3VrAIWCGsE= github.com/willscott/goturn v0.0.0-20170802220503-19f41278d0c9/go.mod h1:PfwRjodCaQXOsHnh2DeVaXqCFCIrbn5WLj1+A5bQkD4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d h1:1ZiEyfaQIg3Qh0EoqpwAakHVhecoE5wlSg5GjnafJGw= diff --git a/transports/obfs4/v3/handshake_ntor.go b/transports/obfs4/v3/handshake_ntor.go index 6ff9624..6e7e9ac 100644 --- a/transports/obfs4/v3/handshake_ntor.go +++ b/transports/obfs4/v3/handshake_ntor.go @@ -41,7 +41,7 @@ import ( "github.com/OperatorFoundation/obfs4/common/csrand" "github.com/OperatorFoundation/obfs4/common/ntor" "github.com/OperatorFoundation/obfs4/common/replayfilter" - "github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2/framing" + "github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3/framing" ) const ( diff --git a/transports/obfs4/v3/obfs4.go b/transports/obfs4/v3/obfs4.go index 45afec5..e87a169 100644 --- a/transports/obfs4/v3/obfs4.go +++ b/transports/obfs4/v3/obfs4.go @@ -1,29 +1,29 @@ /* -* Copyright (c) 2014, Yawning Angel -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* -* * Redistributions of source code must retain the above copyright notice, -* this list of conditions and the following disclaimer. -* -* * Redistributions in binary form must reproduce the above copyright notice, -* this list of conditions and the following disclaimer in the documentation -* and/or other materials provided with the distribution. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -* POSSIBILITY OF SUCH DAMAGE. -*/ + * Copyright (c) 2014, Yawning Angel + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ // Package obfs4 provides an implementation of the Tor Project's obfs4 // obfuscation protocol. @@ -35,12 +35,12 @@ import ( "flag" "fmt" "github.com/OperatorFoundation/obfs4/common/drbg" - "github.com/OperatorFoundation/obfs4/common/log" "github.com/OperatorFoundation/obfs4/common/ntor" "github.com/OperatorFoundation/obfs4/common/probdist" "github.com/OperatorFoundation/obfs4/common/replayfilter" "github.com/OperatorFoundation/shapeshifter-ipc/v2" - "github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2/framing" + "github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3/framing" + "github.com/kataras/golog" "golang.org/x/net/proxy" "math/rand" "net" @@ -131,7 +131,7 @@ func NewObfs4Server(stateDir string) (*Transport, error) { // Store the arguments that should appear in our descriptor for the clients. ptArgs := make(map[string]string) ptArgs[certArg] = st.cert.String() - log.Infof("certstring %s", certArg) + golog.Infof("certstring %s", certArg) ptArgs[iatArg] = strconv.Itoa(st.iatMode) // Initialize the replay filter. @@ -175,7 +175,7 @@ func NewObfs4Client(certString string, iatMode int, dialer proxy.Dialer) (*Trans if dialer == nil { return &Transport{dialer: proxy.Direct, serverFactory: nil, clientArgs: &ClientArgs{nodeID, publicKey, sessionKey, iatMode}}, nil } - return &Transport{dialer: dialer, serverFactory: nil, clientArgs: &ClientArgs{nodeID, publicKey, sessionKey, iatMode}}, nil + return &Transport{dialer: dialer, serverFactory: nil, clientArgs: &ClientArgs{nodeID, publicKey, sessionKey, iatMode}}, nil } @@ -192,7 +192,7 @@ func (transport *Transport) Dial(address string) (net.Conn, error) { if err != nil { closeErr := dialConn.Close() if closeErr != nil { - log.Errorf("could not close") + golog.Errorf("could not close") } return nil, err } @@ -200,23 +200,87 @@ func (transport *Transport) Dial(address string) (net.Conn, error) { return transportConn, nil } - -//OptimizerTransport contains parameters to be used in Optimizer -type OptimizerTransport struct { +//TransportClient contains parameters to be used in Optimizer +type TransportClient struct { CertString string IatMode int - Address string + Address string `json:"address"` Dialer proxy.Dialer } +type TransportServer struct { + ServerFactory *ServerFactory + Address string +} + //Config contains arguments formatted for a json file type Config struct { CertString string `json:"cert"` IatMode string `json:"iat-mode"` + Address string `json:"address"` +} + +func NewClient(certString string, iatMode int, address string, dialer proxy.Dialer) (TransportClient, error) { + return TransportClient{CertString: certString, IatMode: iatMode, Address: address, Dialer: dialer}, nil +} + +func NewServer(stateDir string, address string) (*TransportServer, error) { + sf, sFError := NewObfs4ServerFactory(stateDir) + + if sFError != nil { + return nil, sFError + } + transport := &TransportServer{ + ServerFactory: sf, + Address: address, + } + return transport, nil +} + +//NewObfs4Server initializes the obfs4 server side +func NewObfs4ServerFactory(stateDir string) (*ServerFactory, error) { + args := make(map[string]string) + st, err := serverStateFromArgs(stateDir, args) + if err != nil { + return nil, err + } + + var iatSeed *drbg.Seed + if st.iatMode != iatNone { + iatSeedSrc := sha256.Sum256(st.drbgSeed.Bytes()[:]) + var err error + iatSeed, err = drbg.SeedFromBytes(iatSeedSrc[:]) + if err != nil { + return nil, err + } + } + + // Store the arguments that should appear in our descriptor for the clients. + ptArgs := make(map[string]string) + ptArgs[certArg] = st.cert.String() + golog.Infof("certstring %s", certArg) + ptArgs[iatArg] = strconv.Itoa(st.iatMode) + + // Initialize the replay filter. + filter, err := replayfilter.New(replayTTL) + if err != nil { + return nil, err + } + + // Initialize the close thresholds for failed connections. + hashDrbg, err := drbg.NewHashDrbg(st.drbgSeed) + if err != nil { + return nil, err + } + rng := rand.New(hashDrbg) + + sf := &ServerFactory{ptArgs, st.nodeID, st.identityKey, st.drbgSeed, iatSeed, st.iatMode, filter, rng.Intn(maxCloseDelayBytes), rng.Intn(maxCloseDelay)} + + return sf, nil } // Dial creates outgoing transport connection -func (transport OptimizerTransport) Dial() (net.Conn, error) { +func (transport TransportClient) Dial() (net.Conn, error) { Obfs4Transport, err := NewObfs4Client(transport.CertString, transport.IatMode, transport.Dialer) if err != nil { return nil, err @@ -229,20 +293,36 @@ func (transport OptimizerTransport) Dial() (net.Conn, error) { } // Listen creates listener for incoming transport connection -func (transport *Transport) Listen(address string) net.Listener { +func (transport *Transport) Listen(address string) (net.Listener, error) { addr, resolveErr := pt.ResolveAddr(address) if resolveErr != nil { fmt.Println(resolveErr.Error()) - return nil + return nil, resolveErr } ln, err := net.ListenTCP("tcp", addr) if err != nil { fmt.Println(err.Error()) - return nil + return nil, err + } + + return newObfs4TransportListener(transport.serverFactory, ln), nil +} + +func (transport *TransportServer) Listen() (net.Listener, error) { + addr, resolveErr := pt.ResolveAddr(transport.Address) + if resolveErr != nil { + golog.Error(resolveErr.Error()) + return nil, resolveErr + } + + ln, err := net.ListenTCP("tcp", addr) + if err != nil { + golog.Error(err.Error()) + return nil, err } - return newObfs4TransportListener(transport.serverFactory, ln) + return newObfs4TransportListener(transport.ServerFactory, ln), nil } // Close closes the transport listener. diff --git a/transports/obfs4/v3/obfs4_test.go b/transports/obfs4/v3/obfs4_test.go index 9f2beec..2a63d1b 100644 --- a/transports/obfs4/v3/obfs4_test.go +++ b/transports/obfs4/v3/obfs4_test.go @@ -39,7 +39,7 @@ const data = "test" func TestMain(m *testing.M) { _ = RunLocalObfs4Server("test") - + _ = RunLocalObfs4ServerFactory("test") os.Exit(m.Run()) } @@ -73,3 +73,34 @@ func TestObfs4(t *testing.T) { return } } + +func TestObfs4Factory(t *testing.T) { + print(runtime.GOOS) + clientConfig, launchErr := RunObfs4ClientFactory() + if launchErr != nil { + t.Fail() + return + } + //create client buffer + clientBuffer := make([]byte, 4) + //call dial on client and check error + clientConn, dialErr := clientConfig.Dial() + if dialErr != nil { + t.Fail() + return + } + + //write data from clientConn for server to read + _, clientWriteErr := clientConn.Write([]byte(data)) + if clientWriteErr != nil { + t.Fail() + return + } + + //read on client side + _, clientReadErr := clientConn.Read(clientBuffer) + if clientReadErr != nil { + t.Fail() + return + } +} \ No newline at end of file diff --git a/transports/obfs4/v3/packet.go b/transports/obfs4/v3/packet.go index c6a0562..441c113 100644 --- a/transports/obfs4/v3/packet.go +++ b/transports/obfs4/v3/packet.go @@ -34,7 +34,7 @@ import ( "io" "github.com/OperatorFoundation/obfs4/common/drbg" - "github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v2/framing" + "github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3/framing" ) const ( diff --git a/transports/obfs4/v3/test_utils.go b/transports/obfs4/v3/test_utils.go index ce8484f..b0aded0 100644 --- a/transports/obfs4/v3/test_utils.go +++ b/transports/obfs4/v3/test_utils.go @@ -1,6 +1,32 @@ +/* + MIT License + + Copyright (c) 2020 Operator Foundation + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ + package obfs4 import ( + "github.com/kataras/golog" + "golang.org/x/net/proxy" "io/ioutil" "os" "os/user" @@ -25,7 +51,7 @@ func RunLocalObfs4Server(data string) bool { } directoryErr := os.Mkdir(fPath, 0775) if directoryErr != nil { - if !os.IsExist(directoryErr){ + if !os.IsExist(directoryErr) { return false } } @@ -34,8 +60,67 @@ func RunLocalObfs4Server(data string) bool { return false } //call listen on the server - serverListener := serverConfig.Listen("127.0.0.1:1234") - if serverListener == nil { + serverListener, listenErr := serverConfig.Listen("127.0.0.1:1234") + if listenErr != nil { + return false + } + //Create Server connection and format it for concurrency + go func() { + //create server buffer + serverBuffer := make([]byte, 4) + + for { + //create serverConn + serverConn, acceptErr := serverListener.Accept() + if acceptErr != nil { + return + } + + go func() { + //read on server side + _, serverReadErr := serverConn.Read(serverBuffer) + if serverReadErr != nil { + return + } + + //write data from serverConn for client to read + _, serverWriteErr := serverConn.Write([]byte(data)) + if serverWriteErr != nil { + return + } + }() + } + }() + return true +} + +func RunLocalObfs4ServerFactory(data string) bool { + //create a server + MakeLog() + usr, userError := user.Current() + if userError != nil { + return false + } + home := usr.HomeDir + var fPath string + if runtime.GOOS == "darwin" { + fPath = path.Join(home, "shapeshifter-transports/stateDir") + } else { + fPath = path.Join(home, "gopath/src/github.com/OperatorFoundation/shapeshifter-transports/stateDir") + } + directoryErr := os.Mkdir(fPath, 0775) + if directoryErr != nil { + if !os.IsExist(directoryErr) { + return false + } + } + serverConfig, confError := NewServer(fPath, "127.0.0.1:2234") + if confError != nil { + return false + } + //call listen on the server + serverListener, listenErr := serverConfig.Listen() + if listenErr != nil { return false } //Create Server connection and format it for concurrency @@ -99,3 +184,41 @@ func RunObfs4Client() (*Transport, error) { clientConfig, confError := NewObfs4Client(certstring, 0, nil) return clientConfig, confError } + +//RunObfs4Client runs the client side in the background for the test +func RunObfs4ClientFactory() (*TransportClient, error) { + MakeLog() + usr, userError := user.Current() + if userError != nil { + return nil, userError + } + home := usr.HomeDir + var fPath string + if runtime.GOOS == "darwin" { + fPath = path.Join(home, "shapeshifter-transports/stateDir/obfs4_bridgeline.txt") + } else { + fPath = path.Join(home, "gopath/src/github.com/OperatorFoundation/shapeshifter-transports/stateDir/obfs4_bridgeline.txt") + } + bytes, fileError := ioutil.ReadFile(fPath) + if fileError != nil { + return nil, fileError + } + //print(bytes) + byteString := string(bytes) + //print(byteString) + lines := strings.Split(byteString, "\n") + //print(lines) + bridgeLine := lines[len(lines)-2] + //println(bridgeLine) + bridgeParts1 := strings.Split(bridgeLine, " ") + bridgePart := bridgeParts1[5] + certstring := bridgePart[5:] + //println(certstring) + clientConfig, confError := NewClient(certstring, 0, "127.0.0.1:2234", proxy.Direct) + return &clientConfig, confError +} + +func MakeLog() { + golog.SetLevel("debug") + golog.SetOutput(os.Stderr) +} diff --git a/transports/shadow/v3/LICENSE b/transports/shadow/v3/LICENSE index dfad7b5..97e8749 100644 --- a/transports/shadow/v3/LICENSE +++ b/transports/shadow/v3/LICENSE @@ -1,5 +1,3 @@ -MIT License - Copyright (c) 2020 Operator Foundation Permission is hereby granted, free of charge, to any person obtaining a copy @@ -14,8 +12,8 @@ copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +SOFTWARE. \ No newline at end of file diff --git a/transports/shadow/v3/go.mod b/transports/shadow/v3/go.mod index 361d52b..6363ad1 100644 --- a/transports/shadow/v3/go.mod +++ b/transports/shadow/v3/go.mod @@ -1,9 +1,10 @@ -module github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v2 +module github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 go 1.12 require ( github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da // indirect + github.com/kataras/golog v0.0.18 github.com/shadowsocks/go-shadowsocks2 v0.0.11 golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 // indirect ) diff --git a/transports/shadow/v3/go.sum b/transports/shadow/v3/go.sum index e71d517..8b0b225 100644 --- a/transports/shadow/v3/go.sum +++ b/transports/shadow/v3/go.sum @@ -1,7 +1,9 @@ github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da h1:KjTM2ks9d14ZYCvmHS9iAKVt9AyzRSqNU1qabPih5BY= github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da/go.mod h1:eHEWzANqSiWQsof+nXEI9bUVUyV6F53Fp89EuCh2EAA= -github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 h1:lDH9UUVJtmYCjyT0CI4q8xvlXPxeZ0gYCVvWbmPlp88= -github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= +github.com/kataras/golog v0.0.18 h1:Td7hcKN25yzqB/0SO5iohOsMk5Mq5V9kDtM5apaJLY0= +github.com/kataras/golog v0.0.18/go.mod h1:jRYl7dFYqP8aQj9VkwdBUXYZSfUktm+YYg1arJILfyw= +github.com/kataras/pio v0.0.8 h1:6pX6nHJk7DAV3x1dEimibQF2CmJLlo0jWVmM9yE9KY8= +github.com/kataras/pio v0.0.8/go.mod h1:NFfMp2kVP1rmV4N6gH6qgWpuoDKlrOeYi3VrAIWCGsE= github.com/shadowsocks/go-shadowsocks2 v0.0.11 h1:dXloqEhYnZV40jblWTK8kWeC0Eb+dgql4S0tj99e8j0= github.com/shadowsocks/go-shadowsocks2 v0.0.11/go.mod h1:R+KWaoIwRRhnpw6XV+dZil0XHi64Hc1D7hXUyXTjUzQ= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= diff --git a/transports/shadow/v3/shadow.go b/transports/shadow/v3/shadow.go index 7e94b3e..84e5df9 100644 --- a/transports/shadow/v3/shadow.go +++ b/transports/shadow/v3/shadow.go @@ -26,13 +26,20 @@ package shadow import ( + "github.com/kataras/golog" shadowsocks "github.com/shadowsocks/go-shadowsocks2/core" "log" "net" ) //Config contains the necessary command like arguments to run shadow -type Config struct { +type ClientConfig struct { + Password string `json:"password"` + CipherName string `json:"cipherName"` + Address string `json:"address"` +} + +type ServerConfig struct { Password string `json:"password"` CipherName string `json:"cipherName"` } @@ -45,8 +52,16 @@ type Transport struct { } //NewConfig is used to create a config for testing -func NewConfig(password string, cipherName string) Config { - return Config{ +func NewClientConfig(password string, cipherName string, address string) ClientConfig { + return ClientConfig{ + Password: password, + CipherName: cipherName, + Address: address, + } +} + +func NewServerConfig(password string, cipherName string) ServerConfig { + return ServerConfig{ Password: password, CipherName: cipherName, } @@ -58,28 +73,27 @@ func NewTransport(password string, cipherName string, address string) Transport Password: password, CipherName: cipherName, Address: address, - } } //Listen checks for a working connection -func (config Config) Listen(address string) net.Listener { +func (config ServerConfig) Listen(address string) (net.Listener, error) { cipher, err := shadowsocks.PickCipher(config.CipherName, nil, config.Password) if err != nil { - log.Fatal("Failed generating ciphers:", err) - return nil + golog.Errorf("Failed generating ciphers:", err) + return nil, err } listener, listenerErr := shadowsocks.Listen("tcp", address, cipher) if listenerErr != nil { log.Fatal("Failed to start listener:", listenerErr) - return nil + return nil, listenerErr } - return listener + return listener, nil } //Dial connects to the address on the named network -func (config Config) Dial(address string) (net.Conn, error) { +func (config ClientConfig) Dial(address string) (net.Conn, error) { cipher, err := shadowsocks.PickCipher(config.CipherName, nil, config.Password) if err != nil { log.Fatal("Failed generating ciphers:", err) @@ -97,8 +111,23 @@ func (config Config) Dial(address string) (net.Conn, error) { func (transport *Transport) Dial() (net.Conn, error) { cipher, err := shadowsocks.PickCipher(transport.CipherName, nil, transport.Password) if err != nil { - log.Fatalf("Failed generating ciphers: %s", err) + log.Fatal("Failed generating ciphers:", err) } return shadowsocks.Dial("tcp", transport.Address, cipher) } + +func (transport *Transport) Listen() (net.Listener, error) { + cipher, err := shadowsocks.PickCipher(transport.CipherName, nil, transport.Password) + if err != nil { + log.Fatal("Failed generating ciphers:", err) + return nil, err + } + + listener, listenerErr := shadowsocks.Listen("tcp", transport.Address, cipher) + if listenerErr != nil { + log.Fatal("Failed to start listener:", listenerErr) + return nil, listenerErr + } + return listener, nil +} diff --git a/transports/shadow/v3/shadow_test.go b/transports/shadow/v3/shadow_test.go index f780093..b4e3b3b 100644 --- a/transports/shadow/v3/shadow_test.go +++ b/transports/shadow/v3/shadow_test.go @@ -26,6 +26,7 @@ package shadow import ( "fmt" + "github.com/kataras/golog" "net" "os" "testing" @@ -34,8 +35,11 @@ import ( const data = "test" func TestMain(m *testing.M) { - config := NewConfig("1234", "CHACHA20-IETF-POLY1305") - listener := config.Listen("127.0.0.1:1236") + config := NewServerConfig("1234", "CHACHA20-IETF-POLY1305") + listener, listenErr := config.Listen("127.0.0.1:1236") + if listenErr != nil { + return + } go acceptConnections(listener) os.Exit(m.Run()) @@ -66,7 +70,7 @@ func acceptConnections(listener net.Listener) { func TestShadow(t *testing.T) { //create a server - config := NewConfig("1234", "CHACHA20-IETF-POLY1305") + config := NewClientConfig("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1236") //create client buffer clientBuffer := make([]byte, 4) @@ -94,9 +98,9 @@ func TestShadow(t *testing.T) { return } } - -func TestShadowTransport(t *testing.T) { +func TestShadowFactory(t *testing.T) { //create a server + MakeLog() transport := NewTransport("1234", "CHACHA20-IETF-POLY1305", "127.0.0.1:1236") //create client buffer @@ -125,3 +129,8 @@ func TestShadowTransport(t *testing.T) { return } } + +func MakeLog() { + golog.SetLevel("debug") + golog.SetOutput(os.Stderr) +} \ No newline at end of file From af33fee12de00a43172caf1b5cc95eeb3ab1a86d Mon Sep 17 00:00:00 2001 From: Bluesaxorcist Date: Mon, 10 Aug 2020 13:42:20 -0500 Subject: [PATCH 33/33] updated go.sum --- transports/Optimizer/v3/go.sum | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/transports/Optimizer/v3/go.sum b/transports/Optimizer/v3/go.sum index f3f9cb8..d5b0f68 100644 --- a/transports/Optimizer/v3/go.sum +++ b/transports/Optimizer/v3/go.sum @@ -9,18 +9,26 @@ github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3 v3. github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3 v3.0.6/go.mod h1:gW1GFU+PS/+snW7IK7gcObExPKCzsvIL1z2g9N/5ubM= github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3 v3.0.10 h1:D2CK7Vbr7eh7Z+2npal98SaXfqQvhWFptyskmnh3+cQ= github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3 v3.0.10/go.mod h1:wQZC/2AdEDj3fnuI0Bu0dL1kvUeaE7MvoyeLlLu2nfQ= +github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3 v3.0.11 h1:wZS0LVcP5+TJNJTlV73ys6A+lgM3B+P9iH+3bKcXt40= +github.com/OperatorFoundation/shapeshifter-transports/transports/meeklite/v3 v3.0.11/go.mod h1:wQZC/2AdEDj3fnuI0Bu0dL1kvUeaE7MvoyeLlLu2nfQ= github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 v3.0.6 h1:xmos+1ED0y2UbqtEXGxtcxIqTDGPuw0te5Obqlspj9s= github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 v3.0.6/go.mod h1:i8hkRv+UCu0YbOll8NqoDzDBsRR6XgMa1bykKsTUxTg= github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 v3.0.10 h1:hKOpe/wHRjIdv10ZWarm3hebce6BtfMpxsr9ZRS+ei0= github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 v3.0.10/go.mod h1:nnE7S0srPoXZDatJ7sTWhClwo/3vyMXykSDPHAdi2xo= +github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 v3.0.11 h1:Y12MCe3C6c7CeWnZjZc3Xn17uUXLoxnD3L1Guj+2n34= +github.com/OperatorFoundation/shapeshifter-transports/transports/obfs2/v3 v3.0.11/go.mod h1:nnE7S0srPoXZDatJ7sTWhClwo/3vyMXykSDPHAdi2xo= github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 v3.0.6 h1:/aEcDgGu3VA+gndxMv02LvfbZ6rg0lUYYnPkTlbgaSM= github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 v3.0.6/go.mod h1:jdYrSKfsppvvtY/WHSL2mN2FdFNiQ7S/XzQxrty0+2I= github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 v3.0.10 h1:ATbRmWxRg7AHAGgU54DPrVpiy7zteqhCQYXc1T/U0Po= github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 v3.0.10/go.mod h1:k1ga949kVeIGplqIb1lBE8Qi957Om/bz/GDMymQr+kA= +github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 v3.0.11 h1:SkbSYVapVSi/KSdLHZPSSO176p26CHNKFv7hZ1t1dK0= +github.com/OperatorFoundation/shapeshifter-transports/transports/obfs4/v3 v3.0.11/go.mod h1:k1ga949kVeIGplqIb1lBE8Qi957Om/bz/GDMymQr+kA= github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 v3.0.6 h1:nqdVkCLaotgyabOWXf+sVLrGDQTRt8HqAAT/EZwysLM= github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 v3.0.6/go.mod h1:EQS0MxXaaSQO2IoAwVyXsgx7RBWL6Yy+gMiEn2YJRbo= github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 v3.0.10 h1:rRRsTQycB1WeVGZSbgfTn0R9woiCi1RpyFEYoRU8uLo= github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 v3.0.10/go.mod h1:eI5kZwV2A9NBKB3UgzjY1ThIsV2sSUETBmjGbPncaf0= +github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 v3.0.11 h1:eQDjLsEgy7IgHdaKU10Hq9EPa8pT9ytu9jL3z1VshAs= +github.com/OperatorFoundation/shapeshifter-transports/transports/shadow/v3 v3.0.11/go.mod h1:eI5kZwV2A9NBKB3UgzjY1ThIsV2sSUETBmjGbPncaf0= github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da h1:KjTM2ks9d14ZYCvmHS9iAKVt9AyzRSqNU1qabPih5BY= github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da/go.mod h1:eHEWzANqSiWQsof+nXEI9bUVUyV6F53Fp89EuCh2EAA= github.com/dchest/siphash v1.2.1 h1:4cLinnzVJDKxTCl9B01807Yiy+W7ZzVHj/KIroQRvT4=