[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [goptlib/master] Have ConnectOr take an Addr, not a Conn.



commit 537dbd836dc468a9e193bee0418d4b9cc8347da9
Author: David Fifield <david@xxxxxxxxxxxxxxx>
Date:   Tue Nov 26 23:50:10 2013 -0800

    Have ConnectOr take an Addr, not a Conn.
---
 examples/dummy-server/dummy-server.go |    2 +-
 pt.go                                 |   10 +++++-----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/examples/dummy-server/dummy-server.go b/examples/dummy-server/dummy-server.go
index 86176d7..0518737 100644
--- a/examples/dummy-server/dummy-server.go
+++ b/examples/dummy-server/dummy-server.go
@@ -50,7 +50,7 @@ func handleConnection(conn net.Conn) {
 		handlerChan <- -1
 	}()
 
-	or, err := pt.ConnectOr(&ptInfo, conn, "dummy")
+	or, err := pt.ConnectOr(&ptInfo, conn.RemoteAddr(), "dummy")
 	if err != nil {
 		return
 	}
diff --git a/pt.go b/pt.go
index 2caac33..c2a5d8c 100644
--- a/pt.go
+++ b/pt.go
@@ -20,7 +20,7 @@
 //
 // Sample server usage:
 // 	func handler(conn net.Conn) {
-// 		or, err := pt.ConnectOr(&ptInfo, conn, "foo")
+// 		or, err := pt.ConnectOr(&ptInfo, conn.RemoteAddr(), "foo")
 // 		if err != nil {
 // 			return
 // 		}
@@ -648,10 +648,10 @@ func extOrPortRecvCommand(s io.Reader) (cmd uint16, body []byte, err error) {
 // Send USERADDR and TRANSPORT commands followed by a DONE command. Wait for an
 // OKAY or DENY response command from the server. Returns nil if and only if
 // OKAY is received.
-func extOrPortSetup(s io.ReadWriter, conn net.Conn, methodName string) error {
+func extOrPortSetup(s io.ReadWriter, addr net.Addr, methodName string) error {
 	var err error
 
-	err = extOrPortSendUserAddr(s, conn.RemoteAddr())
+	err = extOrPortSendUserAddr(s, addr)
 	if err != nil {
 		return err
 	}
@@ -680,7 +680,7 @@ func extOrPortSetup(s io.ReadWriter, conn net.Conn, methodName string) error {
 // open *net.TCPConn. If connecting to the extended OR port, extended OR port
 // authentication à la 217-ext-orport-auth.txt is done before returning; an
 // error is returned if authentication fails.
-func ConnectOr(info *ServerInfo, conn net.Conn, methodName string) (*net.TCPConn, error) {
+func ConnectOr(info *ServerInfo, addr net.Addr, methodName string) (*net.TCPConn, error) {
 	if info.ExtendedOrAddr == nil {
 		return net.DialTCP("tcp", nil, info.OrAddr)
 	}
@@ -695,7 +695,7 @@ func ConnectOr(info *ServerInfo, conn net.Conn, methodName string) (*net.TCPConn
 		s.Close()
 		return nil, err
 	}
-	err = extOrPortSetup(s, conn, methodName)
+	err = extOrPortSetup(s, addr, methodName)
 	if err != nil {
 		s.Close()
 		return nil, err

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits