def InitServer(bind_addr, bind_port): s = socket(AF_INET, SOCK_STREAM) s.bind((bind_addr, bind_port)) print "Listening on %s:%d..." % (bind_addr, bind_port) s.listen(1) while(1): cl, addr = s.accept() start_new_thread(AcceptConnect, (cl, addr,)) s.close()
def Run(self): if(len(self.plugins) == 0): self.plugins.append(self) try: s = socket(AF_INET, SOCK_STREAM) s.connect((out_addr, out_port)) except: s.close() self.sock.close() return tunnel_out = new_plug_in() tunnel_out.sock = s tunnel_out.send_to = 0 self.plugins.append(tunnel_out) self.description = '[CLIENT]' tunnel_out.description = '[SERVER]' tunnel_out.plugins = self.plugins tunnel_out.Run() start_new_thread(self.Recv, ())