kinnay / NintendoClients

Python package to communicate with Switch, Wii U and 3DS servers
MIT License
537 stars 63 forks source link

Server usage examples #124

Open BurAndBY opened 5 months ago

BurAndBY commented 5 months ago

I found this package very useful, however there are no examples on how to use things like nintendo.nex.matchmaking. MatchMakingServer. Are there any examples (other than the SMB35 repo) for those server classes?

jonbarrow commented 5 months ago

This repo has an example server found in the examples folder

https://github.com/kinnay/NintendoClients/blob/master/examples/custom/server.py

You would use the other protocol classes the same way. As for the actual logic behind them, that's an implementation detail and really up to you how you implement it. Also some NEX versions have slightly different requirements especially with matchmaking, so your implementation would also vary by game

We've had instances like this several times over at Pretendo, where one game may expect a matchmaking notification and another may not (as an example)

kinnay commented 5 months ago

@jonbarrow is right. No other examples unfortunately. If you have a specific question about the match making protocol, feel free to ask and we can try to help.

BurAndBY commented 5 months ago

This repo has an example server found in the examples folder

https://github.com/kinnay/NintendoClients/blob/master/examples/custom/server.py

You would use the other protocol classes the same way. As for the actual logic behind them, that's an implementation detail and really up to you how you implement it. Also some NEX versions have slightly different requirements especially with matchmaking, so your implementation would also vary by game

We've had instances like this several times over at Pretendo, where one game may expect a matchmaking notification and another may not (as an example)

This is very useful, thanks! I was looking at the matchmaking_mk8d code to try serve it, since it has the full server code and as far as I understand I need to run the servers mk8d uses

BurAndBY commented 5 months ago

@jonbarrow is right. No other examples unfortunately. If you have a specific question about the match making protocol, feel free to ask and we can try to help.

This example is good enough and it tells what parts are coded specifically for SMB35 and which ones are the base code needed

jonbarrow commented 5 months ago

This is very useful, thanks! I was looking at the matchmaking_mk8d code to try serve it, since it has the full server code and as far as I understand I need to run the servers mk8d uses

It has the skeleton of the protocol but you'll still need to implement all the actual functionality by hand. You'll also probably need to run your own account server, unless there's some other way to force the game to connect? I haven't looked much into the Switch's architecture myself yet, to be honest. I assume it gets the NEX servers location from the account server much like the WiiU/3DS do

BurAndBY commented 5 months ago

This is very useful, thanks! I was looking at the matchmaking_mk8d code to try serve it, since it has the full server code and as far as I understand I need to run the servers mk8d uses

It has the skeleton of the protocol but you'll still need to implement all the actual functionality by hand. You'll also probably need to run your own account server, unless there's some other way to force the game to connect? I haven't looked much into the Switch's architecture myself yet, to be honest. I assume it gets the NEX servers location from the account server much like the WiiU/3DS do

Oh, that makes a lot of sense, thanks!

kinnay commented 5 months ago

You'll also probably need to run your own account server, unless there's some other way to force the game to connect? I haven't looked much into the Switch's architecture myself yet, to be honest. I assume it gets the NEX servers location from the account server much like the WiiU/3DS do

No, the Switch finds the game servers by DNS lookup. The easiest way to connect with a custom server is to write an IPS patch that replaces the game server URL. This is what I did with SMB35 as well.

jonbarrow commented 5 months ago

No, the Switch finds the game servers by DNS lookup. The easiest way to connect with a custom server is to write an IPS patch that replaces the game server URL. This is what I did with SMB35 as well.

That's right, my bad. I remember that from your wiki now, ignore me

BurAndBY commented 5 months ago

You'll also probably need to run your own account server, unless there's some other way to force the game to connect? I haven't looked much into the Switch's architecture myself yet, to be honest. I assume it gets the NEX servers location from the account server much like the WiiU/3DS do

No, the Switch finds the game servers by DNS lookup. The easiest way to connect with a custom server is to write an IPS patch that replaces the game server URL. This is what I did with SMB35 as well.

And what about the dauth/nso check switch does on connection, how to bypass that? I presume a patch too?

kinnay commented 5 months ago

Yes. It depends on the game, but you probably want to look for the following functions:

BurAndBY commented 5 months ago

And does F-Zero 99 use libeagle too? It seems so, but it's not mentioned in the wiki.

kinnay commented 5 months ago

Yes it does, I just checked and updated the wiki. Its version string is 2.5.5, so the protocol is probably the same as in SMB 35 and Pac-Man 99.

BurAndBY commented 5 months ago

Yes it does, I just checked and updated the wiki. Its version string is 2.5.5, so the protocol is probably the same as in SMB 35 and Pac-Man 99.

Great to know, thanks!

damartcode commented 2 months ago

You'll also probably need to run your own account server, unless there's some other way to force the game to connect? I haven't looked much into the Switch's architecture myself yet, to be honest. I assume it gets the NEX servers location from the account server much like the WiiU/3DS do

No, the Switch finds the game servers by DNS lookup. The easiest way to connect with a custom server is to write an IPS patch that replaces the game server URL. This is what I did with SMB35 as well.

And what about the dauth/nso check switch does on connection, how to bypass that? I presume a patch too?

I have a question on this. Instead of the patch for the game server url, couldn't you disable certificate check and custom DNS to point into your game/authentication server?.

Same logic could go on dauth/nso checks?, I could run my own dauth/nso servers with certificate check and custom DNS, correct?

kinnay commented 2 months ago

Correct. Here's a repo that disables certificate checks: https://github.com/misson20000/exefs_patches.

damartcode commented 1 month ago

Kinnay, would you appreciate implementations for the dauth/nso servers in the repo?

kinnay commented 1 month ago

Not here, but I have a server implementation elsewhere: https://github.com/nintendo-playground/.

It currently implements dauth and aauth up to system version 14.1.2.