diff options
author | Yawning Angel <yawning@torproject.org> | 2015-10-29 14:09:34 +0000 |
---|---|---|
committer | Yawning Angel <yawning@torproject.org> | 2015-10-29 14:09:34 +0000 |
commit | e52258edac55d82ff153755493d770bfbbc9a346 (patch) | |
tree | 324136fb4500944cd8c8790e4bca2f06fb96cef8 /transports/obfs2 | |
parent | 69ffcc39c63f4a9a192082da71eea6b06a1e75d7 (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 'transports/obfs2')
-rw-r--r-- | transports/obfs2/obfs2.go | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/transports/obfs2/obfs2.go b/transports/obfs2/obfs2.go index bc2532b..a926141 100644 --- a/transports/obfs2/obfs2.go +++ b/transports/obfs2/obfs2.go @@ -108,8 +108,16 @@ func (cf *obfs2ClientFactory) ParseArgs(args *pt.Args) (interface{}, error) { return nil, validateArgs(args) } -func (cf *obfs2ClientFactory) WrapConn(conn net.Conn, args interface{}) (net.Conn, error) { - return newObfs2ClientConn(conn) +func (cf *obfs2ClientFactory) Dial(network, addr string, dialFn base.DialFunc, args interface{}) (net.Conn, error) { + conn, err := dialFn(network, addr) + if err != nil { + return nil, err + } + if conn, err = newObfs2ClientConn(conn); err != nil { + conn.Close() + return nil, err + } + return conn, nil } type obfs2ServerFactory struct { |