commit ca61c5d4125c4991468a36ef8cf6e9fb23d820f2 Author: David Fifield david@bamsoftware.com Date: Sun Jun 12 01:00:56 2011 -0700
Restore labels on ProxyPair output.
Allow setting the label from the outside. --- ProxyPair.as | 13 +++++++++---- swfcat.as | 11 +++++++++-- 2 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/ProxyPair.as b/ProxyPair.as index ca9f092..62c6ec2 100644 --- a/ProxyPair.as +++ b/ProxyPair.as @@ -14,6 +14,9 @@ package /* An instance of a client-relay connection. */ public class ProxyPair extends EventDispatcher { + // Label for log messages. + public var name:String; + // Socket to client. private var s_c:*; private var connect_c:Function; @@ -33,13 +36,15 @@ package
public function log(msg:String):void { - ui.puts(id() + ": " + msg) + if (name) + ui.puts(name + ": " + msg) + else + ui.puts(msg) }
- // String describing this pair for output. - public function id():String + public function set_name(name:String):void { - return "<>"; + this.name = name; }
public function ProxyPair(ui:swfcat, s_c:*, connect_c:Function, s_r:*, connect_r:Function) diff --git a/swfcat.as b/swfcat.as index 6125187..d9e9bc6 100644 --- a/swfcat.as +++ b/swfcat.as @@ -265,6 +265,7 @@ package
private function make_proxy_pair(client_spec:String, relay_spec:String):ProxyPair { + var proxy_pair:ProxyPair; var addr_c:Object; var addr_r:Object; var s_c:*; @@ -278,21 +279,27 @@ package if (addr_c) { s_c = new Socket(); s_r = new Socket(); - return new ProxyPair(this, s_c, function ():void { + proxy_pair = new ProxyPair(this, s_c, function ():void { s_c.connect(addr_c.host, addr_c.port); }, s_r, function ():void { s_r.connect(addr_r.host, addr_r.port); }); + proxy_pair.set_name("<" + addr_c.host + ":" + addr_c.port + "," + + addr_r.host + ":" + addr_r.port + ">"); + return proxy_pair; }
if (client_spec.match(/^[0-9A-Fa-f]{64}$/)) { s_c = new RTMFPSocket(CIRRUS_URL, CIRRUS_KEY); s_r = new Socket(); - return new ProxyPair(this, s_c, function ():void { + proxy_pair = new ProxyPair(this, s_c, function ():void { s_c.connect(client_spec); }, s_r, function ():void { s_r.connect(addr_r.host, addr_r.port); }); + proxy_pair.set_name("<" + client_spec.substr(0, 4) + "...," + + addr_r.host + ":" + addr_r.port + ">"); + return proxy_pair; }
throw new ArgumentError("Can't parse client spec "" + client_spec + "".");
tor-commits@lists.torproject.org