summaryrefslogtreecommitdiff
path: root/obfs4proxy
diff options
context:
space:
mode:
authorYawning Angel <yawning@torproject.org>2015-10-29 14:09:34 +0000
committerYawning Angel <yawning@torproject.org>2015-10-29 14:09:34 +0000
commite52258edac55d82ff153755493d770bfbbc9a346 (patch)
tree324136fb4500944cd8c8790e4bca2f06fb96cef8 /obfs4proxy
parent69ffcc39c63f4a9a192082da71eea6b06a1e75d7 (diff)
Make establishing outgoing connections the transport's responsibility.
ClientFactories now have a Dial() method instead of a WrapConn() method, so that it is possible to write something like meek-client using the obfs4proxy framework. This breaks the external interface if anyone is using obfs4proxy as a library, but the new way of doing things is a trivial modification, to a single routine that shouldn't have been very large to begin with.
Diffstat (limited to 'obfs4proxy')
-rw-r--r--obfs4proxy/obfs4proxy.go13
1 files changed, 2 insertions, 11 deletions
diff --git a/obfs4proxy/obfs4proxy.go b/obfs4proxy/obfs4proxy.go
index a817583..5c23ba2 100644
--- a/obfs4proxy/obfs4proxy.go
+++ b/obfs4proxy/obfs4proxy.go
@@ -155,22 +155,13 @@ func clientHandler(f base.ClientFactory, conn net.Conn, proxyURI *url.URL) {
}
dialFn = dialer.Dial
}
- remoteConn, err := dialFn("tcp", socksReq.Target) // XXX: Allow UDP?
+ remote, err := f.Dial("tcp", socksReq.Target, dialFn, args)
if err != nil {
log.Errorf("%s(%s) - outgoing connection failed: %s", name, addrStr, log.ElideError(err))
socksReq.Reply(socks5.ErrorToReplyCode(err))
return
}
- defer remoteConn.Close()
-
- // Instantiate the client transport method, handshake, and start pushing
- // bytes back and forth.
- remote, err := f.WrapConn(remoteConn, args)
- if err != nil {
- log.Errorf("%s(%s) - handshake failed: %s", name, addrStr, log.ElideError(err))
- socksReq.Reply(socks5.ReplyGeneralFailure)
- return
- }
+ defer remote.Close()
err = socksReq.Reply(socks5.ReplySucceeded)
if err != nil {
log.Errorf("%s(%s) - SOCKS reply failed: %s", name, addrStr, log.ElideError(err))