Beispiel #1
0
    def handle_facility_get_request(self, request: Node) -> Node:
        """
        Handle a facility request. The only method of note is the 'get' request,
        which expects to return a bunch of information about the arcade this
        cabinet is in, as well as some settings for URLs and the name of the cab.
        """
        machine = self.data.local.machine.get_machine(self.config['machine']['pcbid'])

        root = Node.void('facility')
        root.set_attribute('expire', '600')
        location = Node.void('location')
        location.add_child(Node.string('id', ID.format_machine_id(machine.id)))
        location.add_child(Node.string('country', 'US'))
        location.add_child(Node.string('region', '.'))
        location.add_child(Node.string('name', machine.name))
        location.add_child(Node.u8('type', 0))

        line = Node.void('line')
        line.add_child(Node.string('id', '.'))
        line.add_child(Node.u8('class', 0))

        portfw = Node.void('portfw')
        portfw.add_child(Node.ipv4('globalip', self.config['client']['address']))
        portfw.add_child(Node.u16('globalport', machine.port))
        portfw.add_child(Node.u16('privateport', machine.port))

        public = Node.void('public')
        public.add_child(Node.u8('flag', 1))
        public.add_child(Node.string('name', '.'))
        public.add_child(Node.string('latitude', '0'))
        public.add_child(Node.string('longitude', '0'))

        share = Node.void('share')
        eacoin = Node.void('eacoin')
        eacoin.add_child(Node.s32('notchamount', 3000))
        eacoin.add_child(Node.s32('notchcount', 3))
        eacoin.add_child(Node.s32('supplylimit', 10000))

        eapass = Node.void('eapass')
        eapass.add_child(Node.u16('valid', 365))

        url = Node.void('url')
        url.add_child(Node.string('eapass', self.config['server']['uri'] or 'www.ea-pass.konami.net'))
        url.add_child(Node.string('arcadefan', self.config['server']['uri'] or 'www.konami.jp/am'))
        url.add_child(Node.string('konaminetdx', self.config['server']['uri'] or 'http://am.573.jp'))
        url.add_child(Node.string('konamiid', self.config['server']['uri'] or 'https://id.konami.net'))
        url.add_child(Node.string('eagate', self.config['server']['uri'] or 'http://eagate.573.jp'))

        share.add_child(eacoin)
        share.add_child(url)
        share.add_child(eapass)
        root.add_child(location)
        root.add_child(line)
        root.add_child(portfw)
        root.add_child(public)
        root.add_child(share)
        return root
Beispiel #2
0
 def test_format_machine_id(self) -> None:
     self.assertEqual(ID.format_machine_id(123), 'US-123')
     self.assertEqual(ID.parse_machine_id('US-123'), 123)
     self.assertEqual(ID.parse_machine_id('bla'), None)
     self.assertEqual(ID.parse_machine_id('US-blah'), None)