47 g_throttle[g_throttle.index (address)][1] = tt |
47 g_throttle[g_throttle.index (address)][1] = tt |
48 except ValueError: |
48 except ValueError: |
49 # not in list |
49 # not in list |
50 g_throttle.append ([address, tt]) |
50 g_throttle.append ([address, tt]) |
51 |
51 |
52 Irc.broadcast ('Throttling %s:%s for 30 seconds' % address) |
52 Irc.broadcast ('Throttling %s for 30 seconds' % address) |
53 |
53 |
54 def handle_rest_http (data, address): |
54 def handle_rest_http (data, address): |
55 global g_credentials |
55 global g_credentials |
56 displayaddress = address |
56 displayaddress = address |
57 authrex = re.compile (r'^authorization: Basic (.+)$') |
57 authrex = re.compile (r'^authorization: Basic (.+)$') |
110 httpdata = '' |
110 httpdata = '' |
111 writebuffer = '' |
111 writebuffer = '' |
112 address = None |
112 address = None |
113 |
113 |
114 def __init__ (self, conn, address): |
114 def __init__ (self, conn, address): |
115 asyncore.dispatcher.__init__ (self, conn, address) |
115 asyncore.dispatcher.__init__ (self, conn) |
116 self.socket = ssl.wrap_socket (conn, server_side=True, keyfile='key.pem', |
116 self.socket = ssl.wrap_socket (conn, server_side=True, keyfile='key.pem', |
117 certfile='cert.pem', do_handshake_on_connect=False) |
117 certfile='cert.pem', do_handshake_on_connect=False) |
118 self.socket.setblocking (0) |
118 self.socket.settimeout (3) |
119 self.address = address |
119 self.address = address |
120 print 'Initialized connection handler for %s' % type (address) |
|
121 |
120 |
122 while True: |
121 while True: |
123 try: |
122 try: |
124 self.socket.do_handshake() |
123 self.socket.do_handshake() |
125 break |
124 break |