Esempio n. 1
0
 def get(self, node_uuid=None):
     if not node_uuid:
         node = Node.get_by(uuid=Node.me().uuid)
     else:
         node = Node.get_by(uuid=node_uuid)
     if not node:
         raise tornado.web.HTTPError(404)
     self.write({'node': node.to_dict()})
Esempio n. 2
0
 def get(self, node_uuid=None):
     if not node_uuid:
         node = Node.get_by(uuid=Node.me().uuid)
     else:
         node = Node.get_by(uuid=node_uuid)
     if not node:
         raise tornado.web.HTTPError(404)
     self.write({'node': node.to_dict()})
Esempio n. 3
0
 def test_register_node(self):
     data = {'uuid': "a-unique-id", 'port': 8001}
     eq_(Node.get_by(uuid=data['uuid']), None)
     self.http_client.fetch(HTTPRequest(
         self.get_url('/nodes'), 'POST', body=json.dumps(data)), self.stop)
     response = self.wait()
     eq_(response.code, 200)
     ok_(Node.get_by(uuid=data['uuid']))
Esempio n. 4
0
 def __init__(self, source=None, source_port=None, destination=None,
         destination_port=None, hops=0, *args, **kwargs):
     source = source or Node.me()
     source_port = source_port or settings.RTMP_PORT
     destination = destination or Node.me()
     super(Ticket, self).__init__(source=source, source_port=source_port,
             destination=destination, destination_port=destination_port,
             hops=hops, *args, **kwargs)
Esempio n. 5
0
 def test_register_node(self):
     data = {'uuid': "a-unique-id", 'port': 8001}
     eq_(Node.get_by(uuid=data['uuid']), None)
     self.http_client.fetch(
         HTTPRequest(self.get_url('/nodes'), 'POST', body=json.dumps(data)),
         self.stop)
     response = self.wait()
     eq_(response.code, 200)
     ok_(Node.get_by(uuid=data['uuid']))
Esempio n. 6
0
 def test_get_nodes(self):
     [NodeFactory() for _ in range(3)]
     response = self.fetch('/nodes')
     eq_(response.code, 200)
     result = json.loads(response.body)
     ok_('nodes' in result)
     for node in result['nodes']:
         ok_(Node.get_by(uuid=node['uuid']))
Esempio n. 7
0
 def test_get_nodes(self):
     [NodeFactory() for _ in range(3)]
     response = self.fetch('/nodes')
     eq_(response.code, 200)
     result = json.loads(response.body)
     ok_('nodes' in result)
     for node in result['nodes']:
         ok_(Node.get_by(uuid=node['uuid']))
Esempio n. 8
0
 def __init__(self,
              source=None,
              source_port=None,
              destination=None,
              destination_port=None,
              hops=0,
              *args,
              **kwargs):
     source = source or Node.me()
     source_port = source_port or settings.RTMP_PORT
     destination = destination or Node.me()
     super(Ticket, self).__init__(source=source,
                                  source_port=source_port,
                                  destination=destination,
                                  destination_port=destination_port,
                                  hops=hops,
                                  *args,
                                  **kwargs)
Esempio n. 9
0
    def delete(self, node_uuid=None):
        """Remove the requesting node from the list of known nodes,
        unregistering the from the network.
        """

        if not node_uuid or node_uuid == Node.me().uuid:
            log.info("Shutting down because of request from %s",
                    self.request.remote_ip)
            tornado.ioloop.IOLoop.instance().stop()
            return

        node = Node.get_by(uuid=node_uuid)
        if node:
            closest_supernode = Node.closest_supernode()
            if closest_supernode and node != closest_supernode:
                log.info("Notifying closest supernode %s that %s was deleted",
                        closest_supernode, node)
                NodesAPI(closest_supernode.absolute_url()).unregister(node)
            if node == Node.me().primary_supernode and self.application.node:
                self.application.node.bootstrap()
            node.delete()
Esempio n. 10
0
    def delete(self, node_uuid=None):
        """Remove the requesting node from the list of known nodes,
        unregistering the from the network.
        """

        if not node_uuid or node_uuid == Node.me().uuid:
            log.info("Shutting down because of request from %s",
                     self.request.remote_ip)
            tornado.ioloop.IOLoop.instance().stop()
            return

        node = Node.get_by(uuid=node_uuid)
        if node:
            closest_supernode = Node.closest_supernode()
            if closest_supernode and node != closest_supernode:
                log.info("Notifying closest supernode %s that %s was deleted",
                         closest_supernode, node)
                NodesAPI(closest_supernode.absolute_url()).unregister(node)
            if node == Node.me().primary_supernode and self.application.node:
                self.application.node.bootstrap()
            node.delete()
Esempio n. 11
0
    def queue_tunnel_creation(self):
        """Since Astral is a "pull" system, the person receiving a forwarded
        stream from us based on this ticket (the destination) is in charge of
        connecting to us - we don't explicitly send anything to them.

        This will queue the node up to create a tunnel from the source's RTMP
        server to a port on the local node. If we created this ticket for
        ourselves, we will just connect to it from the browser. If it was
        created in response to a request from another node (i.e. the destination
        is not us), we don't create any extra tunnels. A tunnel will already
        exist in that case to bring the stream from somewhere else to here.
        """
        if self.confirmed and self.destination == Node.me():
            TUNNEL_QUEUE.put(self)
Esempio n. 12
0
    def queue_tunnel_creation(self):
        """Since Astral is a "pull" system, the person receiving a forwarded
        stream from us based on this ticket (the destination) is in charge of
        connecting to us - we don't explicitly send anything to them.

        This will queue the node up to create a tunnel from the source's RTMP
        server to a port on the local node. If we created this ticket for
        ourselves, we will just connect to it from the browser. If it was
        created in response to a request from another node (i.e. the destination
        is not us), we don't create any extra tunnels. A tunnel will already
        exist in that case to bring the stream from somewhere else to here.
        """
        if self.confirmed and self.destination == Node.me():
            TUNNEL_QUEUE.put(self)