summaryrefslogtreecommitdiff
path: root/transports/scramblesuit/base.go
diff options
context:
space:
mode:
Diffstat (limited to 'transports/scramblesuit/base.go')
-rw-r--r--transports/scramblesuit/base.go14
1 files changed, 12 insertions, 2 deletions
diff --git a/transports/scramblesuit/base.go b/transports/scramblesuit/base.go
index 711c046..223d085 100644
--- a/transports/scramblesuit/base.go
+++ b/transports/scramblesuit/base.go
@@ -76,12 +76,22 @@ func (cf *ssClientFactory) ParseArgs(args *pt.Args) (interface{}, error) {
return newClientArgs(args)
}
-func (cf *ssClientFactory) WrapConn(conn net.Conn, args interface{}) (net.Conn, error) {
+func (cf *ssClientFactory) Dial(network, addr string, dialFn base.DialFunc, args interface{}) (net.Conn, error) {
+ // Validate args before opening outgoing connection.
ca, ok := args.(*ssClientArgs)
if !ok {
return nil, fmt.Errorf("invalid argument type for args")
}
- return newScrambleSuitClientConn(conn, cf.ticketStore, ca)
+
+ conn, err := dialFn(network, addr)
+ if err != nil {
+ return nil, err
+ }
+ if conn, err = newScrambleSuitClientConn(conn, cf.ticketStore, ca); err != nil {
+ conn.Close()
+ return nil, err
+ }
+ return conn, nil
}
var _ base.ClientFactory = (*ssClientFactory)(nil)