diff options
author | Yawning Angel <yawning@schwanenlied.me> | 2014-05-25 09:14:14 +0000 |
---|---|---|
committer | Yawning Angel <yawning@schwanenlied.me> | 2014-05-25 09:14:14 +0000 |
commit | 92494597ce18e21ca8db4d0cd7ba1be3ba05e735 (patch) | |
tree | 41961f5677bfcce4c01646aaa3afdfb87d1d5e3f /obfs4.go | |
parent | b3d17c327b3d0f8cfd3ebf91e776e1f99bb81004 (diff) |
Wire in go.net/proxy, enabling SOCKS5 via TOR_PT_PROXY.
With tor patched to support 8402, obfs4 bootstraps via a SOCKSv5 proxy
now. Other schemes will bail with a PROXY-ERROR, as the go.net/proxy
package does not support them, and I have not gotten around to writing
dialers for them yet (next on my TODO list).
Part of issue #7.
Diffstat (limited to 'obfs4.go')
-rw-r--r-- | obfs4.go | 15 |
1 files changed, 13 insertions, 2 deletions
@@ -533,10 +533,21 @@ func (c *Obfs4Conn) SetWriteDeadline(t time.Time) error { return syscall.ENOTSUP } +// DialFn is a function pointer to a dial routine that matches the +// net.Dialer.Dial routine. +type DialFn func(string, string) (net.Conn, error) + // DialObfs4 connects to the remote address on the network, and handshakes with // the peer's obfs4 Node ID and Identity Public Key. nodeID and publicKey are // expected as strings containing the Base64 encoded values. func DialObfs4(network, address, nodeID, publicKey string, iatObfuscation bool) (*Obfs4Conn, error) { + + return DialObfs4DialFn(net.Dial, network, address, nodeID, publicKey, iatObfuscation) +} + +// DialObfs4DialFn connects to the remote address on the network via DialFn, +// and handshakes with the peers' obfs4 Node ID and Identity Public Key. +func DialObfs4DialFn(dialFn DialFn, network, address, nodeID, publicKey string, iatObfuscation bool) (*Obfs4Conn, error) { // Decode the node_id/public_key. pub, err := ntor.PublicKeyFromBase64(publicKey) if err != nil { @@ -553,13 +564,13 @@ func DialObfs4(network, address, nodeID, publicKey string, iatObfuscation bool) return nil, err } - // Connect to the peer. + // Generate the Obfs4Conn. c := new(Obfs4Conn) c.lenProbDist = newWDist(seed, 0, framing.MaximumSegmentLength) if iatObfuscation { c.iatProbDist = newWDist(seed, 0, maxIatDelay) } - c.conn, err = net.Dial(network, address) + c.conn, err = dialFn(network, address) if err != nil { return nil, err } |