def handle_accept(self): """ Process new connections (sf-client or trigger) -- asyncore callback. """ client, addr = self.accept() # Determine who connected and if they look valid. This is done # first to siphon off the 'trigger' handler. It also blocks. magic = sync_read(client, 2) if is_trigger(magic): InjectTrigger(sf_inject=self, socket=client) elif is_sfclient(magic): InjectUpstream(sf_inject=self, socket=client) client.send(SFCLIENT_MAGIC) else: warn(InvalidVersionWarning()) client.close()
def handle_connect(self): ver = sync_read(self.socket, 2) if not is_sfclient(ver): raise ValueError, "bridged SF has invalid version"