kinnay / NintendoClients

Python package to communicate with Switch, Wii U and 3DS servers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Hang during call to device_token

TheGreatRambler opened this issue · comments

During a call to dauth.device_token(keys) my code hangs at exactly this line. This code used to work a few weeks ago and I've updated the system and checked my keys file, but it inexplicably hangs here, not an error.

dauth = DAuthClient(keys)
dauth.set_certificate(cert, pkey)
dauth.set_system_version(SYSTEM_VERSION)
response = await dauth.device_token(dauth.BAAS)
device_token = response["device_auth_token"]

That's weird. Are you sure that the line number is correct?

image

This line can never hang, because it only looks up a value in a dict.

I updated the required anyio version a few days ago (7443f4d), so make sure that you have the latest release of anyio.

Anynet is at the most recent release and NintendoClients is at current master, yet this is my output:

Generate device token
INFO:anynet.http:Performing HTTP request: POST /v7/challenge
INFO:anynet.http:Received HTTP response: 200

It just doesn't go any further. I'm checking all my dependencies and they seem fine too, I don't get it.

EDIT: That line number is correct, yeah. Putting a print statement before the return and a print statement after the line that that function is called in the class only has the first print statement work.

Interesting. It's trying to access master_key_0c though the maximum master key I have is master_key_0b. Is it possible key generation for system version 1300 should be 12 instead of 13? These are completely fresh keys

KEY_GENERATION = {
	900:  10,
	901:  10,
	910:  11,
	920:  11,
	1000: 11,
	1001: 11,
	1002: 11,
	1003: 11,
	1004: 11,
	1010: 11,
	1011: 11,
	1020: 11,
	1100: 11,
	1101: 11,
	1200: 11,
	1201: 11,
	1202: 11,
	1203: 11,
	1210: 11,
	1300: 13
}

Yep, changing KEY_GENERATION[1300] to 12 instead of 13 fixed everything.

That is not the right way to fix this. You should redump your keys to get master_key_0c.

I still think it's weird that it hangs instead of showing a traceback. On my computer I get a traceback if I remove master_key_0c from my keys file:

Traceback (most recent call last):
  File "test.py", line 58, in <module>
    anyio.run(main)
  ...
  File "test.py", line 37, in main
    response = await dauth.device_token(dauth.BAAS)
  File "/home/yannik/files/projects/nintendo/nintendo/dauth.py", line 212, in device_token
    req.plainform["mac"] = self.calculate_mac(string, data)
  File "/home/yannik/files/projects/nintendo/nintendo/dauth.py", line 251, in calculate_mac
    master_key = self.get_master_key()
  File "/home/yannik/files/projects/nintendo/nintendo/dauth.py", line 243, in get_master_key
    return self.keyset[keyname]
  File "/home/yannik/files/projects/nintendo/nintendo/switch.py", line 38, in __getitem__
    return self.keys[key]
KeyError: 'master_key_0c'

Maybe your IDE is swallowing the exception somehow.

These are completely fresh keys

When I dumped my keys on 13.0.0 with the latest Lockpick_RCM (1.9.6) I did get master_key_0c. I don't know why your maximum master key is master_key_0b.

Ah it's possible my Lockpick_RCM version is pretty old, I'll check. And yeah it should absolutely not result in a hang, I think some other async code I'm using is messing with things.

Unrelated but I'd like you to know a lot of people have really benefited from your library, thank you for making it https://twitter.com/tgr_code/status/1449981590709293061?s=20