commit 203776bc531591278b96ebead68ef472363f4fbf Author: David Fifield david@bamsoftware.com Date: Fri Mar 1 21:31:24 2013 -0800
Tolerate failures in opening listeners.
Carry on as long as we have at least one local and one remote listener. In reproduce it). --- flashproxy-client | 18 ++++++++++++++++-- 1 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/flashproxy-client b/flashproxy-client index c229a3f..e9795fa 100755 --- a/flashproxy-client +++ b/flashproxy-client @@ -1124,17 +1124,31 @@ def main(): # Remote sockets, accepting remote WebSocket connections from proxies. remote_listen = [] for addr in options.remote_addrs: - listen = listen_socket(addr) + try: + listen = listen_socket(addr) + except socket.error, e: + log(u"Failed to listen remote on %s: %s." % (addr, str(e))) + continue remote_listen.append(listen) log(u"Listening remote on %s." % format_sockaddr(listen.getsockname())) + if not remote_listen: + log(u"Failed to open any remote listeners, quitting.") + pt_cmethoderror("Failed to open any remote listeners.") # Local sockets, accepting SOCKS requests from localhost local_listen = [] for addr in options.local_addrs: - listen = listen_socket(addr) + try: + listen = listen_socket(addr) + except socket.error, e: + log(u"Failed to listen local on %s: %s." % (addr, str(e))) + continue local_listen.append(listen) log(u"Listening local on %s." % format_sockaddr(listen.getsockname())) if options.managed: pt_cmethod("websocket", listen.getsockname()) + if not local_listen: + log(u"Failed to open any local listeners, quitting.") + pt_cmethoderror("Failed to open any local listeners.") if options.managed: pt_cmethods_done()