commit 2ea3f77a7824a9638a2ada53dc87f94d65ff7776
Author: David Fifield <[email protected]>
Date:   Sun Nov 3 17:11:26 2013 -0800

    Make dummy-client a bit more like dummy-server.
---
 src/pt/examples/dummy-client/dummy-client.go |   22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/src/pt/examples/dummy-client/dummy-client.go 
b/src/pt/examples/dummy-client/dummy-client.go
index 7b69104..3cf7b45 100644
--- a/src/pt/examples/dummy-client/dummy-client.go
+++ b/src/pt/examples/dummy-client/dummy-client.go
@@ -19,6 +19,8 @@ import (
 import "git.torproject.org/pluggable-transports/websocket.git/src/pt"
 import "git.torproject.org/pluggable-transports/websocket.git/src/pt/socks"
 
+var ptInfo pt.ClientInfo
+
 // When a connection handler starts, +1 is written to this channel; when it
 // ends, -1 is written.
 var handlerChan = make(chan int)
@@ -87,12 +89,18 @@ func startListener(addr string) (net.Listener, error) {
 }
 
 func main() {
-       pt.ClientSetup([]string{"dummy"})
-       ln, err := startListener("127.0.0.1:0")
-       if err != nil {
-               pt.CmethodError("dummy", err.Error())
+       ptInfo = pt.ClientSetup([]string{"dummy"})
+
+       listeners := make([]net.Listener, 0)
+       for _, methodName := range ptInfo.MethodNames {
+               ln, err := startListener("127.0.0.1:0")
+               if err != nil {
+                       pt.CmethodError(methodName, err.Error())
+                       continue
+               }
+               pt.Cmethod(methodName, "socks4", ln.Addr())
+               listeners = append(listeners, ln)
        }
-       pt.Cmethod("dummy", "socks4", ln.Addr())
        pt.CmethodsDone()
 
        var numHandlers int = 0
@@ -109,7 +117,9 @@ func main() {
                case sig = <-sigChan:
                }
        }
-       ln.Close()
+       for _, ln := range listeners {
+               ln.Close()
+       }
 
        if sig == syscall.SIGTERM {
                return



_______________________________________________
tor-commits mailing list
[email protected]
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits

Reply via email to