def verify_pcb24_boot(self, loc: str) -> None: call = self.call_node() # Construct node pcb24 = Node.void('pcb24') call.add_child(pcb24) pcb24.set_attribute('method', 'boot') pcb24.add_child(Node.string('loc_id', loc)) pcb24.add_child(Node.u8('loc_type', 0)) pcb24.add_child(Node.string('loc_name', '')) pcb24.add_child(Node.string('country', 'US')) pcb24.add_child(Node.string('region', '.')) pcb24.add_child(Node.s16('pref', 51)) pcb24.add_child(Node.string('customer', '')) pcb24.add_child(Node.string('company', '')) pcb24.add_child(Node.ipv4('gip', '127.0.0.1')) pcb24.add_child(Node.u16('gp', 10011)) pcb24.add_child(Node.string('rom_number', 'M39-JB-G01')) pcb24.add_child(Node.u64('c_drive', 10028228608)) pcb24.add_child(Node.u64('d_drive', 47945170944)) pcb24.add_child(Node.u64('e_drive', 10394677248)) pcb24.add_child(Node.string('etc', '')) # Swap with server resp = self.exchange('', call) # Verify that response is correct self.assert_path(resp, "response/pcb24/@status")
def verify_game_shop(self, location: str) -> None: call = self.call_node() game = Node.void('game') call.add_child(game) game.set_attribute('method', 'sv4_shop') game.set_attribute('ver', '0') game.add_child(Node.string('locid', location)) game.add_child(Node.string('regcode', '.')) game.add_child(Node.string('locname', '')) game.add_child(Node.u8('loctype', 0)) game.add_child(Node.string('cstcode', '')) game.add_child(Node.string('cpycode', '')) game.add_child(Node.s32('latde', 0)) game.add_child(Node.s32('londe', 0)) game.add_child(Node.u8('accu', 0)) game.add_child(Node.string('linid', '.')) game.add_child(Node.u8('linclass', 0)) game.add_child(Node.ipv4('ipaddr', '0.0.0.0')) game.add_child(Node.string('hadid', '00010203040506070809')) game.add_child(Node.string('licid', '00010203040506070809')) game.add_child(Node.string('actid', self.pcbid)) game.add_child(Node.s8('appstate', 0)) game.add_child(Node.s8('c_need', 1)) game.add_child(Node.s8('c_credit', 2)) game.add_child(Node.s8('s_credit', 2)) game.add_child(Node.bool('free_p', True)) game.add_child(Node.bool('close', False)) game.add_child(Node.s32('close_t', 1380)) game.add_child(Node.u32('playc', 0)) game.add_child(Node.u32('playn', 0)) game.add_child(Node.u32('playe', 0)) game.add_child(Node.u32('test_m', 0)) game.add_child(Node.u32('service', 0)) game.add_child(Node.bool('paseli', True)) game.add_child(Node.u32('update', 0)) game.add_child(Node.string('shopname', '')) game.add_child(Node.bool('newpc', False)) game.add_child(Node.s32('s_paseli', 206)) game.add_child(Node.s32('monitor', 1)) game.add_child(Node.string('romnumber', 'KFC-JA-B01')) game.add_child(Node.string('etc', 'TaxMode:1,BasicRate:100/1,FirstFree:0')) setting = Node.void('setting') game.add_child(setting) setting.add_child(Node.s32('coin_slot', 0)) setting.add_child(Node.s32('game_start', 1)) setting.add_child(Node.string('schedule', '0,0,0,0,0,0,0')) setting.add_child(Node.string('reference', '1,1,1')) setting.add_child(Node.string('basic_rate', '100,100,100')) setting.add_child(Node.s32('tax_rate', 1)) setting.add_child(Node.string('time_service', '0,0,0')) setting.add_child(Node.string('service_value', '10,10,10')) setting.add_child(Node.string('service_limit', '10,10,10')) setting.add_child(Node.string('service_time', '07:00-11:00,07:00-11:00,07:00-11:00')) # Swap with server resp = self.exchange('', call) # Verify that response is correct self.assert_path(resp, "response/game/nxt_time")
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
def test_packet1(self) -> Node: root = Node.void('test') root.set_attribute('test', 'test string value') # Regular nodes root.add_child(Node.void('void_node')) root.add_child(Node.s8('s8_node', -1)) root.add_child(Node.u8('u8_node', 245)) root.add_child(Node.s16('s16_node', -8000)) root.add_child(Node.u16('u16_node', 65000)) root.add_child(Node.s32('s32_node', -2000000000)) root.add_child(Node.u32('u32_node', 4000000000)) root.add_child(Node.s64('s64_node', -1234567890000)) root.add_child(Node.u64('u64_node', 1234567890000)) root.add_child(Node.binary('bin_node', b'DEADBEEF')) root.add_child(Node.string('str_node', 'this is a string!')) root.add_child(Node.ipv4('ip4_node', '192.168.1.24')) root.add_child(Node.time('time_node', 1234567890)) root.add_child(Node.float('float_node', 2.5)) root.add_child(Node.fouru8('4u8_node', [0x20, 0x21, 0x22, 0x23])) root.add_child(Node.bool('bool_true_node', True)) root.add_child(Node.bool('bool_false_node', False)) # Array nodes root.add_child(Node.s8_array('s8_array_node', [-1, -2, 3, 4, -5])) root.add_child(Node.u8_array('u8_array_node', [245, 2, 0, 255, 1])) root.add_child(Node.s16_array('s16_array_node', [-8000, 8000])) root.add_child(Node.u16_array('u16_array_node', [65000, 1, 2, 65535])) root.add_child(Node.s32_array('s32_array_node', [-2000000000, -1])) root.add_child(Node.u32_array('u32_array_node', [4000000000, 0, 1, 2])) root.add_child( Node.s64_array('s64_array_node', [-1234567890000, -1, 1, 1337])) root.add_child( Node.u64_array('u64_array_node', [1234567890000, 123, 456, 7890])) root.add_child( Node.time_array('time_array_node', [1234567890, 98765432])) root.add_child( Node.float_array('float_array_node', [2.5, 0.0, 5.0, 20.5])) root.add_child( Node.bool_array('bool_array_node', [False, True, True, False])) # XML escaping escape = Node.string( 'escape_test', '\r\n<testing> & \'thing\' "thing" \r\nthing on new line\r\n ') escape.set_attribute('test', '<testing> & \'thing\' "thing" \r\n thing') root.add_child(escape) # Unicode unicode_node = Node.string('unicode', '今日は') unicode_node.set_attribute('unicode_attr', 'わたし') root.add_child(unicode_node) self.assertLoopback(root)
def test_game_packet6(self) -> Node: root = Node.void('response') facility = Node.void('facility') root.add_child(facility) location = Node.void('location') facility.add_child(location) location.add_child(Node.string('id', 'US-6')) location.add_child(Node.string('country', 'US')) location.add_child(Node.string('region', '.')) location.add_child(Node.string('name', '')) location.add_child(Node.u8('type', 0)) line = Node.void('line') facility.add_child(line) line.add_child(Node.string('id', '.')) line.add_child(Node.u8('class', 0)) portfw = Node.void('portfw') facility.add_child(portfw) portfw.add_child(Node.ipv4('globalip', '10.0.0.1')) portfw.add_child(Node.u16('globalport', 20000)) portfw.add_child(Node.u16('privateport', 20000)) public = Node.void('public') facility.add_child(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') facility.add_child(share) eacoin = Node.void('eacoin') share.add_child(eacoin) eacoin.add_child(Node.s32('notchamount', 0)) eacoin.add_child(Node.s32('notchcount', 0)) eacoin.add_child(Node.s32('supplylimit', 1000000)) url = Node.void('url') share.add_child(url) url.add_child(Node.string('eapass', 'http://some.dummy.net/')) url.add_child(Node.string('arcadefan', 'http://some.dummy.net/')) url.add_child(Node.string('konaminetdx', 'http://some.dummy.net/')) url.add_child(Node.string('konamiid', 'http://some.dummy.net/')) url.add_child(Node.string('eagate', 'http://some.dummy.net/')) self.assertLoopback(root)
def verify_game_shop(self, location: str) -> None: call = self.call_node() game = Node.void('game') call.add_child(game) game.set_attribute('method', 'shop') game.set_attribute('ver', '0') game.add_child(Node.string('locid', location)) game.add_child(Node.string('regcode', '.')) game.add_child(Node.string('locname', '')) game.add_child(Node.u8('loctype', 0)) game.add_child(Node.string('cstcode', '')) game.add_child(Node.string('cpycode', '')) game.add_child(Node.s32('latde', 0)) game.add_child(Node.s32('londe', 0)) game.add_child(Node.u8('accu', 0)) game.add_child(Node.string('linid', '.')) game.add_child(Node.u8('linclass', 0)) game.add_child(Node.ipv4('ipaddr', '0.0.0.0')) game.add_child(Node.string('hadid', '00010203040506070809')) game.add_child(Node.string('licid', '00010203040506070809')) game.add_child(Node.string('actid', self.pcbid)) game.add_child(Node.s8('appstate', 0)) game.add_child(Node.s8('c_need', 1)) game.add_child(Node.s8('c_credit', 2)) game.add_child(Node.s8('s_credit', 2)) game.add_child(Node.bool('free_p', True)) game.add_child(Node.bool('close', True)) game.add_child(Node.s32('close_t', 1380)) game.add_child(Node.u32('playc', 0)) game.add_child(Node.u32('playn', 0)) game.add_child(Node.u32('playe', 0)) game.add_child(Node.u32('test_m', 0)) game.add_child(Node.u32('service', 0)) game.add_child(Node.bool('paseli', True)) game.add_child(Node.u32('update', 0)) game.add_child(Node.string('shopname', '')) # Swap with server resp = self.exchange('', call) # Verify that response is correct self.assert_path(resp, "response/game/nxt_time")