Skip to content

Commit

Permalink
Merge branch 'v3' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
CryptoSax committed Aug 10, 2020
2 parents adbb0ca + af33fee commit fd23297
Show file tree
Hide file tree
Showing 81 changed files with 10,266 additions and 15 deletions.
16 changes: 8 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

4 changes: 2 additions & 2 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down
10 changes: 5 additions & 5 deletions doc/obfs4proxy.1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
10 changes: 10 additions & 0 deletions runAllTests.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
cd transports

#cd transports/Dust/v2; go test -v
#cd transports/meeklite/v2; go test -v
#cd transports/meekserver/v2; go test -v
Expand All @@ -7,4 +8,13 @@ cd ../../obfs4/v2; go build; go test -v
cd ../../Optimizer/v2; go build; go test -v
cd ../../Replicant/v2; go build; go test -v
cd ../../shadow/v2; go build; 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 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


232 changes: 232 additions & 0 deletions transports/Dust/v3/Dust.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
package Dust

/*
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"
"github.com/kataras/golog"
"golang.org/x/net/proxy"
"net"
"time"

"github.com/OperatorFoundation/shapeshifter-ipc/v2"
"github.com/blanu/Dust/go/v2/interface"
)

type dustClient struct {
serverPubkey *Dust.ServerPublic
dialer proxy.Dialer
Address string `json:"address"`
}

type dustServer struct {
serverPrivkey *Dust.ServerPrivate
dialer proxy.Dialer
}

func NewDustClient(serverPublic string, dialer proxy.Dialer, address string) *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, Address: address}
}

type dustTransportListener struct {
listener *net.TCPListener
transport *dustServer
}

//begin optimizer code
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)
conn, err := dustTransport.Dial(transport.Address)
if err != nil {
return nil, err
} else {
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 {
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 {
golog.Error("could not close")
}
return conn, dialErr
}

return transportConn, err
}

// Create listener for incoming transport connection
func (transport *dustServer) Listen(address string) (net.Listener, error) {
addr, resolveErr := pt.ResolveAddr(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), nil
}

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)
Loading

0 comments on commit fd23297

Please sign in to comment.