Commit graph

322 commits

Author SHA1 Message Date
Daniel López Guimaraes
6fe235745c
fix(globals/authentication): Check for token alignment with block size 2025-03-15 22:11:10 +00:00
Daniel López Guimaraes
62f0414475
fix(globals/authentication): Fix typo on invalid token type error 2025-03-15 22:10:34 +00:00
Daniel López Guimaraes
8976a663d5
feat: Implement token validation on TicketGranting and SecureConnection
Add callback function `ValidateLoginData` on the `ticket-granting` and
`secure-connection` common protocols to allow validation of the given
login data on the `LoginEx` or `RegisterEx` methods. Alongside that, add
a toggle on the `secure-connection` common protocol for enabling or
disabling the insecure `Register` method, like the one for `Login` on
`ticket-granting`.

Also implement the Pretendo token validation inside the globals section,
so that both common protocols can use them. The common protocols include
an option to use the Pretendo token validation `SetPretendoValidation`
on that protocol, but custom handling can be added by setting the
callback function to a custom one.

And finally, replace the error handling on the protocols to set any
errors that aren't related to invalid arguments on `%retval%`. This is
accurate as per previous research, since this is where errors like
maintenace or validation failures get populated.

By default, both of the insecure methods are disabled. That means that
current game servers that use the insecure `Register` method will have
to enable them using `EnableInsecureRegister`. Server implementers
**MUST NOT** enable both of the insecure methods at the same time.

The new `SetPretendoValidation` function expects an AES key as an
argument. This matches with the AES key that is stored on the server
list from the account server, after being hex-decoded. Servers are
expected to set the AES key from an environment variable and validate
that the input provided is valid (the key must be decoded using
`hex.DecodeString` before being provided to the validation fucntion).
2025-03-15 18:24:40 +00:00
Daniel López Guimaraes
db917c2172
Merge pull request #49 from PretendoNetwork/notification-data 2025-02-24 23:44:39 +00:00
Daniel López Guimaraes
52d289e761
fix(matchmake-extension): Fix notification string length check
Kid Icarus: Uprising sends strings with byte length longer than 156, so
assume this should count runes instead.
2025-02-24 23:34:32 +00:00
Daniel López Guimaraes
9005d07605
fix(matchmake-extension): Fix OnAfter typo on notification data methods 2025-02-24 22:30:05 +00:00
Daniel López Guimaraes
0fe4724b02 fix(matchmake-extension): Send notification data to connected friends
Removes warnings for connections not being found when it isn't relevant.
2025-02-13 15:22:04 +00:00
Daniel López Guimaraes
ffaba6e616 fix(matchmake-extension): Fix incorrect SQL query for notifications
Also improve and fix the NotificationData methods.
2025-02-13 15:22:04 +00:00
Daniel López Guimaraes
1450b7ffcc feat(matchmake-extension): Implement NotificationData methods
The NotificationData methods are used by games to send notifications to
friends about user activity, among others. These notifications are
created or updated using `UpdateNotificationData`, which the server will
register and send to the connected friends (as seen on Mario Tennis Open).

The lifetime of these notifications is the same as the connection of the
user who sends them. That is, when a user sends a notification and then
disconnects, the notifications will be discarded.

All notifications sent over `UpdateNotificationData` are logged inside
the `tracking.notification_data` table to prevent abuse. The type of
these notifications is also constrained to a range of specific values
reserved for game-specific purposes (from 101 to 108).
2025-02-13 15:22:04 +00:00
Daniel López Guimaraes
f83d9061ee
fix(ranking): Fix inlined DateTime declaration
Instead of instantiating a new DateTime we can use the one that already
exists on the result param.
2025-02-11 22:41:48 +00:00
Daniel López Guimaraes
59c7633654
fix(matchmake-extension): Remove inlined DateTime
This isn't allowed now with the update to the `FromTimestamp()` method.
2025-02-11 16:35:00 +00:00
Jonathan Barrow
63aaefe721
Merge pull request #45 from PretendoNetwork/persistent-gatherings 2025-02-11 11:11:52 -05:00
Daniel López Guimaraes
7781eb9e7b
chore: Update nex-go module 2025-02-11 16:06:57 +00:00
Daniel López Guimaraes
fa8845a22b
chore: Update go modules 2025-02-11 15:56:56 +00:00
Daniel López Guimaraes
7ba13e1abc
fix(matchmake-extension): Use DateTime.Now() to simplify code 2025-02-09 20:22:08 +00:00
Daniel López Guimaraes
2fd1f78759
fix(matchmake-extension): Handle zero values on communities properly 2025-02-09 19:48:47 +00:00
Daniel López Guimaraes
426a8a81dc
chore(matchmake-extension): Inline session and participation count 2025-02-09 10:25:41 +00:00
Daniel López Guimaraes
a01073f4e9 fix(matchmake-extension): Use persistent gathering constants
Also reduce the PersistentGathering.Password size to 32 extrapolatinf
from the UserPassword on MatchmakeSession
2025-02-09 00:04:05 +00:00
Daniel López Guimaraes
d5a4a74726 chore(matchmake-extension): Inline SQL queries with NEX types 2025-02-09 00:04:05 +00:00
Daniel López Guimaraes
35aed21585 feat: Initial support for persistent gatherings/communities
Implement methods that are needed for Mario Kart 7 communities to work.
Note that support for communities on MK7 is partial since the community
statistics don't load because legacy Ranking isn't implemented. Aside
from that, players can create communities and join others without
issues. Other games which use persistent gatherings may or may not work.

In order to support the `ParticipationCount`, we replace matchmake
session joins with a wrapper which checks if the session is attached to
a community, and if it is, it will increment the participation count of
the player in a new table named `community_participations`. The
`MatchmakeSessionCount` is handled more easily by checking the sessions
that belong to the corresponding community.

A new parameter is also added named `PersistentGatheringCreationMax`
with a default value of 4, as reported and tested on various games. This
allows game servers to change the maximum number of active persistent
gatherings that a player can create. For example, Mario Kart 7 supports
up to 8 persistent gatherings instead of the default of 4.

In Mario Kart 7 there is no limitation on the number of players that can
"join" to a community. That is because they don't really join to it but
they create matchmake sessions linked to the persistent gathering (in
fact, the `MaximumParticipants` parameter on persistent gatherings is
set to 0). Thus, the `participants` parameter is unused in communities
(at least on MK7) and we instead log community participations with a new
tracking table `tracking.participate_community`.

Some changes also had to be done in other places like participant
disconnection handling or gathering registrations in order to implement
persistent gatherings accurately.
2025-02-09 00:04:03 +00:00
Ash Logan
8084bcdf96 fix(datastore): Allow PersistenceTargets in PrepareGetObject 2025-02-01 17:47:34 +11:00
Ash Logan
2b1d5b7c9b fix(matchmaking): Allow missing attributes in "ranked" selection methods
As a temporary workaround until real Ranked matchmaking is implemented, attributes[1] is in use, but some games send '' for this. Just skip ranking in that case instead of erroring out.
2025-02-01 16:23:17 +11:00
Daniel López Guimaraes
bcc53deac2
chore: Inline SQL queries with NEX types 2025-01-24 22:36:52 +00:00
Daniel López Guimaraes
7f067a8ccd
Merge pull request #47 from PretendoNetwork/types-updates 2025-01-12 20:32:53 +00:00
Daniel López Guimaraes
f9e65db077
chore: Update go modules 2025-01-12 20:30:47 +00:00
Daniel López Guimaraes
5651e7f651
fix(matchmake-extension): Fix CleanupSearchMatchmakeSession signature
The matchmake session needs to be a pointer to cleanup the required
values.
2025-01-12 00:17:59 +00:00
Daniel López Guimaraes
21fdc4730e
refactor: Replace AnyDataHolder with AnyObjectHolder 2025-01-09 23:24:02 +00:00
Daniel López Guimaraes
d7f8b585c1
feat: Migrate to new nex-go types 2025-01-01 19:55:13 +00:00
Daniel López Guimaraes
f7a2dab7cc
Merge pull request #44 from DaniElectra/custom-search-criteria 2024-11-05 23:42:37 +00:00
Daniel López Guimaraes
9a67d7e82c
feat(matchmake-extension): Support custom search criteria
Add the ability to cleanup the search criteria on
`BrowseMatchmakeSession`.
2024-11-05 22:07:24 +00:00
Daniel López Guimaraes
9696be334e
Merge pull request #35 from PretendoNetwork/matchmaking-rewrite 2024-11-04 12:08:33 +00:00
Daniel López Guimaraes
7b42e6a794
chore: Update go modules 2024-11-04 12:05:06 +00:00
Daniel López Guimaraes
dd5156d92b
chore: Remove debug log from SendNotificationEvent 2024-11-04 12:04:12 +00:00
Daniel López Guimaraes
e853c5df55
fix(match-making): Change host when host disconnects
Assign a new host when the current host is disconnecting from a
gathering. To simplify the implementation, set the owner of the
gathering as the new host.

Fixes Splatoon where the client doesn't transfer the host by
themselves.
2024-10-03 20:13:33 +01:00
Daniel López Guimaraes
16ed5f16db
fix(matchmake-extension): Only use attribute 1 on selection method
Otherwise the selection method is rendered useless since they are
incompatible.
2024-09-30 17:01:24 +01:00
Daniel López Guimaraes
b7042f3435
fix(matchmake-extension): Fix min/max participants search
The `min_participants` and `max_participants` are stored on
`gatherings`, not on `matchmake_sessions`.
2024-09-30 16:59:52 +01:00
Daniel López Guimaraes
80765de633
fix(matchmake-extension): Remove extra open participation check 2024-09-01 02:02:53 +01:00
Daniel López Guimaraes
0290f5c994
feat(match-making): Implement JoinMatchmakeSessionBehavior
Also include some minor fixes.
2024-09-01 01:54:36 +01:00
Daniel López Guimaraes
165afdc00d
feat(matchmake-extension): Support selection method for finding sessions
Currently we don't support ranked matchmaking properly nor the "score
based" version.
2024-09-01 01:30:26 +01:00
Daniel López Guimaraes
32a375d64e
feat(matchmake-extension): Implement GIDForParticipationCheck 2024-08-31 12:36:18 +01:00
Daniel López Guimaraes
808a786461
fix(match-making): Check if participants are allowed to change owner 2024-08-31 12:31:36 +01:00
Daniel López Guimaraes
69e3b1f342
feat(match-making): Add tracking system
Keep tracking on gathering (un)registrations, participants joining and
leaving and host and owner changes. All tracking is managed inside the
database functions except for the host and owner changes.

The `matchmaking.participants` now remains useless from this change at
the moment, so remove it for now.
2024-08-31 00:27:51 +01:00
Daniel López Guimaraes
32d393f708
Merge pull request #42 from ashquarky/matchmaking-rewrite 2024-08-25 16:16:16 +02:00
Ash Logan
ff20935c8c feat: Add extension point for CanJoinMatchmakeSession
Useful for games with custom behaviours, like Minecraft's friends-of-friends feature
and Splatoon's fests
2024-08-25 21:03:07 +10:00
Daniel López Guimaraes
9639ab6c06
Merge pull request #41 from ashquarky/matchmaking-rewrite 2024-08-10 11:54:18 +02:00
Ash Logan
6953e78d24 fix(matchmake-extension): Fix typo in JoinMatchmakeSessionWithParam
I wanted the answer, not my own question!
2024-08-10 00:14:44 +10:00
Ash Logan
dfe34baf48 fix(matchmake-extension): Unlock mutex after CreateMatchmakeSessionWithParam
Causes deadlocks if left locked
2024-08-10 00:14:15 +10:00
Daniel López Guimaraes
8caa52cbbe
feat: Add MatchmakingManager abstraction
Allows removal of matchmake_extension_database dependency inside
match-making
2024-07-03 02:08:45 +01:00
Daniel López Guimaraes
14ae73e15e chore: Update go modules 2024-07-01 20:08:51 +01:00
Daniel López Guimaraes
20f418e04f
feat(matchmake-extension): Support user and system password 2024-07-01 20:08:44 +01:00