def delete(self, server_id): server = Server.get_server(id=server_id) if not server: self.send_error(404) return server.remove() self.write({ 'id': server_id, })
def post(self, server_id): data = tornado.escape.json_decode(self.request.body) interface = data['interface'] network = data['network'] local_networks = data['local_networks'] ovpn_conf = data['ovpn_conf'] server_ver = data.get('server_ver', 0) server = Server( id=server_id, interface=interface, network=network, local_networks=local_networks, ovpn_conf=ovpn_conf, server_ver=server_ver, ) server.initialize() server.start() self.write({ 'id': server.id, })
def post(self, server_id): data = tornado.escape.json_decode(self.request.body) org_id = data['org_id'] user_id = data['user_id'] server = Server.get_server(id=server_id) if not server: self.send_error(404) return self.call_buffer = server.call_buffer self.timeout = tornado.ioloop.IOLoop.current().add_timeout( time.time() + CALL_RESPONSE_TIMEOUT, self.on_timeout) self.call_id = self.call_buffer.create_call('tls_verify', [org_id, user_id], self.on_response)
def open(self, server_id): if not self.authenticate(): self.close() return self.server = Server.get_server(id=server_id) if not self.server: self.close() return self.call_buffer = self.server.call_buffer if not self.call_buffer: self.close() return self.call_buffer.wait_for_calls(self.on_new_calls)
def put(self, server_id): server = Server.get_server(id=server_id) if not server: self.send_error(404) return self.call_buffer = server.call_buffer if not self.call_buffer: self.send_error(410) return for call in tornado.escape.json_decode(self.request.body): self.call_buffer.return_call(call['id'], call['response']) self.timeout = tornado.ioloop.IOLoop.current().add_timeout( time.time() + 5, self.on_new_calls) self.call_buffer.wait_for_calls(self.on_new_calls)