From e52258edac55d82ff153755493d770bfbbc9a346 Mon Sep 17 00:00:00 2001 From: Yawning Angel Date: Thu, 29 Oct 2015 14:09:34 +0000 Subject: 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. --- transports/obfs3/obfs3.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'transports/obfs3') diff --git a/transports/obfs3/obfs3.go b/transports/obfs3/obfs3.go index d215c49..e4c3ba6 100644 --- a/transports/obfs3/obfs3.go +++ b/transports/obfs3/obfs3.go @@ -92,8 +92,16 @@ func (cf *obfs3ClientFactory) ParseArgs(args *pt.Args) (interface{}, error) { return nil, nil } -func (cf *obfs3ClientFactory) WrapConn(conn net.Conn, args interface{}) (net.Conn, error) { - return newObfs3ClientConn(conn) +func (cf *obfs3ClientFactory) 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 = newObfs3ClientConn(conn); err != nil { + conn.Close() + return nil, err + } + return conn, nil } type obfs3ServerFactory struct { -- cgit v1.2.3