mirror of
https://github.com/PretendoNetwork/friends.git
synced 2024-06-01 11:37:53 -04:00
Updated to latest NEX libs
This commit is contained in:
parent
1d82e2e39c
commit
2cce4a7af4
|
@ -1,58 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
friends_3ds "github.com/PretendoNetwork/friends-secure/3ds"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
friends_wiiu "github.com/PretendoNetwork/friends-secure/wiiu"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
)
|
||||
|
||||
func assignNEXProtocols() {
|
||||
secureServer := nexproto.NewSecureProtocol(globals.NEXServer)
|
||||
accountManagementServer := nexproto.NewAccountManagementProtocol(globals.NEXServer)
|
||||
friendsWiiUServer := nexproto.NewFriendsWiiUProtocol(globals.NEXServer)
|
||||
friends3DSServer := nexproto.NewFriends3DSProtocol(globals.NEXServer)
|
||||
|
||||
// Account Management protocol handles
|
||||
accountManagementServer.NintendoCreateAccount(nintendoCreateAccount)
|
||||
|
||||
// Secure protocol handles
|
||||
secureServer.Register(register)
|
||||
secureServer.RegisterEx(registerEx)
|
||||
|
||||
// Friends (WiiU) protocol handles
|
||||
friendsWiiUServer.UpdateAndGetAllInformation(friends_wiiu.UpdateAndGetAllInformation)
|
||||
friendsWiiUServer.AddFriendRequest(friends_wiiu.AddFriendRequest)
|
||||
friendsWiiUServer.RemoveFriend(friends_wiiu.RemoveFriend)
|
||||
friendsWiiUServer.CancelFriendRequest(friends_wiiu.CancelFriendRequest)
|
||||
friendsWiiUServer.AcceptFriendRequest(friends_wiiu.AcceptFriendRequest)
|
||||
friendsWiiUServer.DeleteFriendRequest(friends_wiiu.DeleteFriendRequest)
|
||||
friendsWiiUServer.DenyFriendRequest(friends_wiiu.DenyFriendRequest)
|
||||
friendsWiiUServer.MarkFriendRequestsAsReceived(friends_wiiu.MarkFriendRequestsAsReceived)
|
||||
friendsWiiUServer.AddBlackList(friends_wiiu.AddBlacklist)
|
||||
friendsWiiUServer.RemoveBlackList(friends_wiiu.RemoveBlacklist)
|
||||
friendsWiiUServer.UpdatePresence(friends_wiiu.UpdatePresence)
|
||||
friendsWiiUServer.UpdateComment(friends_wiiu.UpdateComment)
|
||||
friendsWiiUServer.UpdatePreference(friends_wiiu.UpdatePreference)
|
||||
friendsWiiUServer.GetBasicInfo(friends_wiiu.GetBasicInfo)
|
||||
friendsWiiUServer.DeletePersistentNotification(friends_wiiu.DeletePersistentNotification)
|
||||
friendsWiiUServer.CheckSettingStatus(friends_wiiu.CheckSettingStatus)
|
||||
friendsWiiUServer.GetRequestBlockSettings(friends_wiiu.GetRequestBlockSettings)
|
||||
|
||||
// Friends (3DS) protocol handles
|
||||
friends3DSServer.UpdateProfile(friends_3ds.UpdateProfile)
|
||||
friends3DSServer.UpdateMii(friends_3ds.UpdateMii)
|
||||
friends3DSServer.UpdatePreference(friends_3ds.UpdatePreference)
|
||||
friends3DSServer.SyncFriend(friends_3ds.SyncFriend)
|
||||
friends3DSServer.UpdatePresence(friends_3ds.UpdatePresence)
|
||||
friends3DSServer.UpdateFavoriteGameKey(friends_3ds.UpdateFavoriteGameKey)
|
||||
friends3DSServer.UpdateComment(friends_3ds.UpdateComment)
|
||||
friends3DSServer.AddFriendByPrincipalID(friends_3ds.AddFriendshipByPrincipalID)
|
||||
friends3DSServer.GetFriendPersistentInfo(friends_3ds.GetFriendPersistentInfo)
|
||||
friends3DSServer.GetFriendMii(friends_3ds.GetFriendMii)
|
||||
friends3DSServer.GetFriendPresence(friends_3ds.GetFriendPresence)
|
||||
friends3DSServer.RemoveFriendByPrincipalID(friends_3ds.RemoveFriendByPrincipalID)
|
||||
friends3DSServer.RemoveFriendByLocalFriendCode(friends_3ds.RemoveFriendByLocalFriendCode)
|
||||
friends3DSServer.GetPrincipalIDByLocalFriendCode(friends_3ds.GetPrincipalIDByLocalFriendCode)
|
||||
friends3DSServer.GetAllFriends(friends_3ds.GetAllFriends)
|
||||
}
|
|
@ -7,12 +7,12 @@ import (
|
|||
"github.com/PretendoNetwork/friends-secure/database"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
"github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends/3ds"
|
||||
)
|
||||
|
||||
// Get a friend's mii
|
||||
func GetFriendMiis(pids []uint32) []*nexproto.FriendMii {
|
||||
friendMiis := make([]*nexproto.FriendMii, 0)
|
||||
func GetFriendMiis(pids []uint32) []*friends_3ds.FriendMii {
|
||||
friendMiis := make([]*friends_3ds.FriendMii, 0)
|
||||
|
||||
rows, err := database.Postgres.Query(`
|
||||
SELECT pid, mii_name, mii_data FROM "3ds".user_data WHERE pid IN ($1)`, database.PIDArrayToString(pids))
|
||||
|
@ -30,13 +30,13 @@ func GetFriendMiis(pids []uint32) []*nexproto.FriendMii {
|
|||
for rows.Next() {
|
||||
var pid uint32
|
||||
|
||||
mii := nexproto.NewMii()
|
||||
mii := friends_3ds.NewMii()
|
||||
mii.Unknown2 = false
|
||||
mii.Unknown3 = 0
|
||||
|
||||
rows.Scan(&pid, &mii.Name, &mii.MiiData)
|
||||
|
||||
friendMii := nexproto.NewFriendMii()
|
||||
friendMii := friends_3ds.NewFriendMii()
|
||||
friendMii.PID = pid
|
||||
friendMii.Mii = mii
|
||||
friendMii.ModifiedAt = changedTime
|
||||
|
|
|
@ -7,12 +7,12 @@ import (
|
|||
"github.com/PretendoNetwork/friends-secure/database"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
"github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends/3ds"
|
||||
)
|
||||
|
||||
// Get a friend's persistent information
|
||||
func GetFriendPersistentInfos(user1_pid uint32, pids []uint32) []*nexproto.FriendPersistentInfo {
|
||||
persistentInfos := make([]*nexproto.FriendPersistentInfo, 0)
|
||||
func GetFriendPersistentInfos(user1_pid uint32, pids []uint32) []*friends_3ds.FriendPersistentInfo {
|
||||
persistentInfos := make([]*friends_3ds.FriendPersistentInfo, 0)
|
||||
|
||||
rows, err := database.Postgres.Query(`
|
||||
SELECT pid, region, area, language, favorite_title, favorite_title_version, comment, comment_changed, last_online FROM "3ds".user_data WHERE pid IN ($1)`, database.PIDArrayToString(pids))
|
||||
|
@ -25,9 +25,9 @@ func GetFriendPersistentInfos(user1_pid uint32, pids []uint32) []*nexproto.Frien
|
|||
}
|
||||
|
||||
for rows.Next() {
|
||||
persistentInfo := nexproto.NewFriendPersistentInfo()
|
||||
persistentInfo := friends_3ds.NewFriendPersistentInfo()
|
||||
|
||||
gameKey := nexproto.NewGameKey()
|
||||
gameKey := friends_3ds.NewGameKey()
|
||||
|
||||
var lastOnlineTime uint64
|
||||
var msgUpdateTime uint64
|
||||
|
|
|
@ -5,12 +5,12 @@ import (
|
|||
|
||||
"github.com/PretendoNetwork/friends-secure/database"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends/3ds"
|
||||
)
|
||||
|
||||
// Get all of a user's friend relationships
|
||||
func GetUserFriends(pid uint32) []*nexproto.FriendRelationship {
|
||||
friendRelationships := make([]*nexproto.FriendRelationship, 0)
|
||||
func GetUserFriends(pid uint32) []*friends_3ds.FriendRelationship {
|
||||
friendRelationships := make([]*friends_3ds.FriendRelationship, 0)
|
||||
|
||||
rows, err := database.Postgres.Query(`
|
||||
SELECT user2_pid, type FROM "3ds".friendships WHERE user1_pid=$1 AND type=1 LIMIT 100`, pid)
|
||||
|
@ -19,7 +19,7 @@ func GetUserFriends(pid uint32) []*nexproto.FriendRelationship {
|
|||
}
|
||||
|
||||
for rows.Next() {
|
||||
relationship := nexproto.NewFriendRelationship()
|
||||
relationship := friends_3ds.NewFriendRelationship()
|
||||
relationship.LFC = 0
|
||||
rows.Scan(&relationship.PID, &relationship.RelationshipType)
|
||||
|
||||
|
|
|
@ -6,12 +6,12 @@ import (
|
|||
"github.com/PretendoNetwork/friends-secure/database"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
"github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends/3ds"
|
||||
)
|
||||
|
||||
// Save a friend relationship for a user
|
||||
func SaveFriendship(senderPID uint32, recipientPID uint32) *nexproto.FriendRelationship {
|
||||
friendRelationship := nexproto.NewFriendRelationship()
|
||||
func SaveFriendship(senderPID uint32, recipientPID uint32) *friends_3ds.FriendRelationship {
|
||||
friendRelationship := friends_3ds.NewFriendRelationship()
|
||||
friendRelationship.PID = recipientPID
|
||||
friendRelationship.LFC = 0
|
||||
friendRelationship.RelationshipType = 0 // Incomplete
|
||||
|
|
|
@ -3,11 +3,11 @@ package database_3ds
|
|||
import (
|
||||
"github.com/PretendoNetwork/friends-secure/database"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends/3ds"
|
||||
)
|
||||
|
||||
// Update a user's favorite game
|
||||
func UpdateUserFavoriteGame(pid uint32, gameKey *nexproto.GameKey) {
|
||||
func UpdateUserFavoriteGame(pid uint32, gameKey *friends_3ds.GameKey) {
|
||||
_, err := database.Postgres.Exec(`
|
||||
INSERT INTO "3ds".user_data (pid, favorite_title, favorite_title_version)
|
||||
VALUES ($1, $2, $3)
|
||||
|
|
|
@ -4,11 +4,11 @@ import (
|
|||
"github.com/PretendoNetwork/friends-secure/database"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
"github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends/3ds"
|
||||
)
|
||||
|
||||
// Update a user's mii
|
||||
func UpdateUserMii(pid uint32, mii *nexproto.Mii) {
|
||||
func UpdateUserMii(pid uint32, mii *friends_3ds.Mii) {
|
||||
_, err := database.Postgres.Exec(`
|
||||
INSERT INTO "3ds".user_data (pid, mii_name, mii_data, mii_changed)
|
||||
VALUES ($1, $2, $3, $4)
|
||||
|
|
|
@ -3,11 +3,11 @@ package database_3ds
|
|||
import (
|
||||
"github.com/PretendoNetwork/friends-secure/database"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends/3ds"
|
||||
)
|
||||
|
||||
// Update a user's profile
|
||||
func UpdateUserProfile(pid uint32, profileData *nexproto.MyProfile) {
|
||||
func UpdateUserProfile(pid uint32, profileData *friends_3ds.MyProfile) {
|
||||
_, err := database.Postgres.Exec(`
|
||||
INSERT INTO "3ds".user_data (pid, region, area, language)
|
||||
VALUES ($1, $2, $3, $4)
|
||||
|
|
|
@ -6,11 +6,11 @@ import (
|
|||
"github.com/PretendoNetwork/friends-secure/database"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
"github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
"github.com/gocql/gocql"
|
||||
)
|
||||
|
||||
func AcceptFriendRequestAndReturnFriendInfo(friendRequestID uint64) *nexproto.FriendInfo {
|
||||
func AcceptFriendRequestAndReturnFriendInfo(friendRequestID uint64) *friends_wiiu.FriendInfo {
|
||||
var senderPID uint32
|
||||
var recipientPID uint32
|
||||
|
||||
|
@ -54,7 +54,7 @@ func AcceptFriendRequestAndReturnFriendInfo(friendRequestID uint64) *nexproto.Fr
|
|||
|
||||
SetFriendRequestAccepted(friendRequestID)
|
||||
|
||||
friendInfo := nexproto.NewFriendInfo()
|
||||
friendInfo := friends_wiiu.NewFriendInfo()
|
||||
connectedUser := globals.ConnectedUsers[senderPID]
|
||||
var lastOnline *nex.DateTime
|
||||
|
||||
|
@ -68,15 +68,15 @@ func AcceptFriendRequestAndReturnFriendInfo(friendRequestID uint64) *nexproto.Fr
|
|||
} else {
|
||||
// Offline
|
||||
|
||||
friendInfo.NNAInfo = nexproto.NewNNAInfo()
|
||||
friendInfo.NNAInfo = friends_wiiu.NewNNAInfo()
|
||||
friendInfo.NNAInfo.PrincipalBasicInfo = GetUserInfoByPID(senderPID)
|
||||
friendInfo.NNAInfo.Unknown1 = 0
|
||||
friendInfo.NNAInfo.Unknown2 = 0
|
||||
|
||||
friendInfo.Presence = nexproto.NewNintendoPresenceV2()
|
||||
friendInfo.Presence = friends_wiiu.NewNintendoPresenceV2()
|
||||
friendInfo.Presence.ChangedFlags = 0
|
||||
friendInfo.Presence.Online = false
|
||||
friendInfo.Presence.GameKey = nexproto.NewGameKey()
|
||||
friendInfo.Presence.GameKey = friends_wiiu.NewGameKey()
|
||||
friendInfo.Presence.GameKey.TitleID = 0
|
||||
friendInfo.Presence.GameKey.TitleVersion = 0
|
||||
friendInfo.Presence.Unknown1 = 0
|
||||
|
|
|
@ -4,12 +4,12 @@ import (
|
|||
"github.com/PretendoNetwork/friends-secure/database"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
"github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
)
|
||||
|
||||
// Get a users blacklist
|
||||
func GetUserBlockList(pid uint32) []*nexproto.BlacklistedPrincipal {
|
||||
blockList := make([]*nexproto.BlacklistedPrincipal, 0)
|
||||
func GetUserBlockList(pid uint32) []*friends_wiiu.BlacklistedPrincipal {
|
||||
blockList := make([]*friends_wiiu.BlacklistedPrincipal, 0)
|
||||
|
||||
rows, err := database.Postgres.Query(`SELECT blocked_pid, title_id, title_version, date FROM wiiu.blocks WHERE blocker_pid=$1`, pid)
|
||||
if err != nil {
|
||||
|
@ -24,11 +24,11 @@ func GetUserBlockList(pid uint32) []*nexproto.BlacklistedPrincipal {
|
|||
var date *nex.DateTime
|
||||
rows.Scan(&pid, &titleId, &titleVersion, &date)
|
||||
|
||||
blacklistPrincipal := nexproto.NewBlacklistedPrincipal()
|
||||
blacklistPrincipal := friends_wiiu.NewBlacklistedPrincipal()
|
||||
|
||||
blacklistPrincipal.PrincipalBasicInfo = GetUserInfoByPID(pid)
|
||||
|
||||
blacklistPrincipal.GameKey = nexproto.NewGameKey()
|
||||
blacklistPrincipal.GameKey = friends_wiiu.NewGameKey()
|
||||
blacklistPrincipal.GameKey.TitleID = titleId
|
||||
blacklistPrincipal.GameKey.TitleVersion = titleVersion
|
||||
blacklistPrincipal.BlackListedSince = date
|
||||
|
|
|
@ -6,12 +6,12 @@ import (
|
|||
"github.com/PretendoNetwork/friends-secure/database"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
"github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
)
|
||||
|
||||
// Get a users comment
|
||||
func GetUserComment(pid uint32) *nexproto.Comment {
|
||||
comment := nexproto.NewComment()
|
||||
func GetUserComment(pid uint32) *friends_wiiu.Comment {
|
||||
comment := friends_wiiu.NewComment()
|
||||
comment.Unknown = 0
|
||||
|
||||
var changed uint64 = 0
|
||||
|
|
|
@ -7,13 +7,13 @@ import (
|
|||
"github.com/PretendoNetwork/friends-secure/database"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
"github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
"github.com/gocql/gocql"
|
||||
)
|
||||
|
||||
// Get a users friend list
|
||||
func GetUserFriendList(pid uint32) []*nexproto.FriendInfo {
|
||||
friendList := make([]*nexproto.FriendInfo, 0)
|
||||
func GetUserFriendList(pid uint32) []*friends_wiiu.FriendInfo {
|
||||
friendList := make([]*friends_wiiu.FriendInfo, 0)
|
||||
|
||||
rows, err := database.Postgres.Query(`SELECT user2_pid, date FROM wiiu.friendships WHERE user1_pid=$1 AND active=true LIMIT 100`, pid)
|
||||
if err != nil {
|
||||
|
@ -26,7 +26,7 @@ func GetUserFriendList(pid uint32) []*nexproto.FriendInfo {
|
|||
var date uint64
|
||||
rows.Scan(&friendPID, &date)
|
||||
|
||||
friendInfo := nexproto.NewFriendInfo()
|
||||
friendInfo := friends_wiiu.NewFriendInfo()
|
||||
connectedUser := globals.ConnectedUsers[friendPID]
|
||||
var lastOnline *nex.DateTime
|
||||
|
||||
|
@ -52,15 +52,15 @@ func GetUserFriendList(pid uint32) []*nexproto.FriendInfo {
|
|||
} else {
|
||||
// Offline
|
||||
|
||||
friendInfo.NNAInfo = nexproto.NewNNAInfo()
|
||||
friendInfo.NNAInfo = friends_wiiu.NewNNAInfo()
|
||||
friendInfo.NNAInfo.PrincipalBasicInfo = GetUserInfoByPID(friendPID)
|
||||
friendInfo.NNAInfo.Unknown1 = 0
|
||||
friendInfo.NNAInfo.Unknown2 = 0
|
||||
|
||||
friendInfo.Presence = nexproto.NewNintendoPresenceV2()
|
||||
friendInfo.Presence = friends_wiiu.NewNintendoPresenceV2()
|
||||
friendInfo.Presence.ChangedFlags = 0
|
||||
friendInfo.Presence.Online = false
|
||||
friendInfo.Presence.GameKey = nexproto.NewGameKey()
|
||||
friendInfo.Presence.GameKey = friends_wiiu.NewGameKey()
|
||||
friendInfo.Presence.GameKey.TitleID = 0
|
||||
friendInfo.Presence.GameKey.TitleVersion = 0
|
||||
friendInfo.Presence.Unknown1 = 0
|
||||
|
|
|
@ -4,12 +4,12 @@ import (
|
|||
"github.com/PretendoNetwork/friends-secure/database"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
"github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
)
|
||||
|
||||
// Get a users received friend requests
|
||||
func GetUserFriendRequestsIn(pid uint32) []*nexproto.FriendRequest {
|
||||
friendRequestsIn := make([]*nexproto.FriendRequest, 0)
|
||||
func GetUserFriendRequestsIn(pid uint32) []*friends_wiiu.FriendRequest {
|
||||
friendRequestsIn := make([]*friends_wiiu.FriendRequest, 0)
|
||||
|
||||
rows, err := database.Postgres.Query(`SELECT id, sender_pid, sent_on, expires_on, message, received FROM wiiu.friend_requests WHERE recipient_pid=$1 AND accepted=false AND denied=false`, pid)
|
||||
if err != nil {
|
||||
|
@ -26,18 +26,18 @@ func GetUserFriendRequestsIn(pid uint32) []*nexproto.FriendRequest {
|
|||
var received bool
|
||||
rows.Scan(&id, &senderPID, &sentOn, &expiresOn, &message, &received)
|
||||
|
||||
friendRequest := nexproto.NewFriendRequest()
|
||||
friendRequest := friends_wiiu.NewFriendRequest()
|
||||
|
||||
friendRequest.PrincipalInfo = GetUserInfoByPID(senderPID)
|
||||
|
||||
friendRequest.Message = nexproto.NewFriendRequestMessage()
|
||||
friendRequest.Message = friends_wiiu.NewFriendRequestMessage()
|
||||
friendRequest.Message.FriendRequestID = id
|
||||
friendRequest.Message.Received = received
|
||||
friendRequest.Message.Unknown2 = 1
|
||||
friendRequest.Message.Message = message
|
||||
friendRequest.Message.Unknown3 = 0
|
||||
friendRequest.Message.Unknown4 = ""
|
||||
friendRequest.Message.GameKey = nexproto.NewGameKey()
|
||||
friendRequest.Message.GameKey = friends_wiiu.NewGameKey()
|
||||
friendRequest.Message.GameKey.TitleID = 0
|
||||
friendRequest.Message.GameKey.TitleVersion = 0
|
||||
friendRequest.Message.Unknown5 = nex.NewDateTime(134222053376) // idk what this value means but its always this
|
||||
|
|
|
@ -4,12 +4,12 @@ import (
|
|||
"github.com/PretendoNetwork/friends-secure/database"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
"github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
)
|
||||
|
||||
// Get a users sent friend requests
|
||||
func GetUserFriendRequestsOut(pid uint32) []*nexproto.FriendRequest {
|
||||
friendRequestsOut := make([]*nexproto.FriendRequest, 0)
|
||||
func GetUserFriendRequestsOut(pid uint32) []*friends_wiiu.FriendRequest {
|
||||
friendRequestsOut := make([]*friends_wiiu.FriendRequest, 0)
|
||||
|
||||
rows, err := database.Postgres.Query(`SELECT id, recipient_pid, sent_on, expires_on, message, received FROM wiiu.friend_requests WHERE sender_pid=$1 AND accepted=false`, pid)
|
||||
if err != nil {
|
||||
|
@ -26,18 +26,18 @@ func GetUserFriendRequestsOut(pid uint32) []*nexproto.FriendRequest {
|
|||
var received bool
|
||||
rows.Scan(&id, &recipientPID, &sentOn, &expiresOn, &message, &received)
|
||||
|
||||
friendRequest := nexproto.NewFriendRequest()
|
||||
friendRequest := friends_wiiu.NewFriendRequest()
|
||||
|
||||
friendRequest.PrincipalInfo = GetUserInfoByPID(recipientPID)
|
||||
|
||||
friendRequest.Message = nexproto.NewFriendRequestMessage()
|
||||
friendRequest.Message = friends_wiiu.NewFriendRequestMessage()
|
||||
friendRequest.Message.FriendRequestID = id
|
||||
friendRequest.Message.Received = received
|
||||
friendRequest.Message.Unknown2 = 1
|
||||
friendRequest.Message.Message = message
|
||||
friendRequest.Message.Unknown3 = 0
|
||||
friendRequest.Message.Unknown4 = ""
|
||||
friendRequest.Message.GameKey = nexproto.NewGameKey()
|
||||
friendRequest.Message.GameKey = friends_wiiu.NewGameKey()
|
||||
friendRequest.Message.GameKey.TitleID = 0
|
||||
friendRequest.Message.GameKey.TitleVersion = 0
|
||||
friendRequest.Message.Unknown5 = nex.NewDateTime(134222053376) // idk what this value means but its always this
|
||||
|
|
|
@ -7,13 +7,13 @@ import (
|
|||
"github.com/PretendoNetwork/friends-secure/database"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
"github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
)
|
||||
|
||||
func GetUserInfoByPID(pid uint32) *nexproto.PrincipalBasicInfo {
|
||||
func GetUserInfoByPID(pid uint32) *friends_wiiu.PrincipalBasicInfo {
|
||||
var result bson.M
|
||||
|
||||
err := database.MongoCollection.FindOne(context.TODO(), bson.D{{Key: "pid", Value: pid}}, options.FindOne()).Decode(&result)
|
||||
|
@ -26,10 +26,10 @@ func GetUserInfoByPID(pid uint32) *nexproto.PrincipalBasicInfo {
|
|||
globals.Logger.Critical(err.Error())
|
||||
}
|
||||
|
||||
info := nexproto.NewPrincipalBasicInfo()
|
||||
info := friends_wiiu.NewPrincipalBasicInfo()
|
||||
info.PID = pid
|
||||
info.NNID = result["username"].(string)
|
||||
info.Mii = nexproto.NewMiiV2()
|
||||
info.Mii = friends_wiiu.NewMiiV2()
|
||||
info.Unknown = 2
|
||||
|
||||
encodedMiiData := result["mii"].(bson.M)["data"].(string)
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package database_wiiu
|
||||
|
||||
import nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
import friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
|
||||
// Get notifications for a user
|
||||
func GetUserNotifications(pid uint32) []*nexproto.PersistentNotification {
|
||||
return make([]*nexproto.PersistentNotification, 0)
|
||||
func GetUserNotifications(pid uint32) []*friends_wiiu.PersistentNotification {
|
||||
return make([]*friends_wiiu.PersistentNotification, 0)
|
||||
}
|
||||
|
|
|
@ -5,11 +5,11 @@ import (
|
|||
|
||||
"github.com/PretendoNetwork/friends-secure/database"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
)
|
||||
|
||||
func GetUserPrincipalPreference(pid uint32) *nexproto.PrincipalPreference {
|
||||
preference := nexproto.NewPrincipalPreference()
|
||||
func GetUserPrincipalPreference(pid uint32) *friends_wiiu.PrincipalPreference {
|
||||
preference := friends_wiiu.NewPrincipalPreference()
|
||||
|
||||
err := database.Postgres.QueryRow(`SELECT show_online, show_current_game, block_friend_requests FROM wiiu.user_data WHERE pid=$1`, pid).Scan(&preference.ShowOnlinePresence, &preference.ShowCurrentTitle, &preference.BlockFriendRequests)
|
||||
if err != nil {
|
||||
|
|
|
@ -3,10 +3,10 @@ package database_wiiu
|
|||
import (
|
||||
"github.com/PretendoNetwork/friends-secure/database"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
)
|
||||
|
||||
func UpdateUserPrincipalPreference(pid uint32, principalPreference *nexproto.PrincipalPreference) {
|
||||
func UpdateUserPrincipalPreference(pid uint32, principalPreference *friends_wiiu.PrincipalPreference) {
|
||||
_, err := database.Postgres.Exec(`
|
||||
INSERT INTO wiiu.user_data (pid, show_online, show_current_game, block_friend_requests)
|
||||
VALUES ($1, $2, $3, $4)
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
)
|
||||
|
||||
// FriendUser represents a user connected to the friends server
|
||||
// Contains data relating only to friends
|
||||
type FriendUser struct {
|
||||
NNID string
|
||||
PID uint32
|
||||
Comment *nexproto.Comment
|
||||
FriendRequestsOut []*nexproto.FriendRequest
|
||||
FriendRequestsIn []*nexproto.FriendRequest
|
||||
BlockedUsers []*nexproto.BlacklistedPrincipal
|
||||
LastOnline *nex.DateTime
|
||||
ActiveTitle *nexproto.GameKey
|
||||
Notifications []*nexproto.PersistentNotification
|
||||
}
|
||||
|
||||
func (friendUser *FriendUser) FromPID(pid uint32) {
|
||||
|
||||
}
|
||||
|
||||
func NewFriendUser() *FriendUser {
|
||||
return &FriendUser{}
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
package globals
|
||||
|
||||
import (
|
||||
"github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
)
|
||||
|
||||
type ConnectedUser struct {
|
||||
PID uint32
|
||||
Platform Platform
|
||||
Client *nex.Client
|
||||
NNAInfo *nexproto.NNAInfo
|
||||
Presence *nexproto.NintendoPresence
|
||||
PresenceV2 *nexproto.NintendoPresenceV2
|
||||
}
|
||||
|
||||
func NewConnectedUser() *ConnectedUser {
|
||||
return &ConnectedUser{}
|
||||
}
|
|
@ -1,17 +1,16 @@
|
|||
package globals
|
||||
|
||||
import (
|
||||
"crypto/rsa"
|
||||
|
||||
"github.com/PretendoNetwork/friends-secure/types"
|
||||
"github.com/PretendoNetwork/nex-go"
|
||||
"github.com/PretendoNetwork/plogger-go"
|
||||
)
|
||||
|
||||
var Logger = plogger.NewLogger()
|
||||
var NEXServer *nex.Server
|
||||
var ConnectedUsers map[uint32]*ConnectedUser
|
||||
|
||||
type Platform int
|
||||
|
||||
const (
|
||||
WUP Platform = iota
|
||||
CTR
|
||||
)
|
||||
var ConnectedUsers map[uint32]*types.ConnectedUser
|
||||
var RSAPrivateKeyBytes []byte
|
||||
var RSAPrivateKey *rsa.PrivateKey
|
||||
var HMACSecret []byte
|
||||
|
|
38
go.mod
38
go.mod
|
@ -4,16 +4,16 @@ go 1.18
|
|||
|
||||
require (
|
||||
github.com/PretendoNetwork/grpc-go v0.0.0-20220820112405-4798a22a13f3
|
||||
github.com/PretendoNetwork/nex-go v1.0.14
|
||||
github.com/PretendoNetwork/nex-protocols-go v1.0.19
|
||||
github.com/PretendoNetwork/nex-go v1.0.16
|
||||
github.com/PretendoNetwork/nex-protocols-go v1.0.20
|
||||
github.com/PretendoNetwork/plogger-go v1.0.2
|
||||
github.com/gocql/gocql v1.2.1
|
||||
github.com/golang/protobuf v1.5.2
|
||||
github.com/joho/godotenv v1.4.0
|
||||
github.com/gocql/gocql v1.3.2
|
||||
github.com/golang/protobuf v1.5.3
|
||||
github.com/joho/godotenv v1.5.1
|
||||
github.com/lib/pq v1.10.7
|
||||
go.mongodb.org/mongo-driver v1.10.2
|
||||
golang.org/x/exp v0.0.0-20230213192124-5e25df0256eb
|
||||
google.golang.org/grpc v1.49.0
|
||||
go.mongodb.org/mongo-driver v1.11.4
|
||||
golang.org/x/exp v0.0.0-20230321023759-10a507213a29
|
||||
google.golang.org/grpc v1.54.0
|
||||
)
|
||||
|
||||
require (
|
||||
|
@ -21,24 +21,24 @@ require (
|
|||
github.com/golang/snappy v0.0.4 // indirect
|
||||
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed // indirect
|
||||
github.com/jwalton/go-supportscolor v1.1.0 // indirect
|
||||
github.com/klauspost/compress v1.15.9 // indirect
|
||||
github.com/klauspost/compress v1.16.4 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.18 // indirect
|
||||
github.com/montanaflynn/stats v0.6.6 // indirect
|
||||
github.com/montanaflynn/stats v0.7.0 // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/stretchr/testify v1.7.0 // indirect
|
||||
github.com/superwhiskers/crunch/v3 v3.5.7 // indirect
|
||||
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
|
||||
github.com/xdg-go/scram v1.1.1 // indirect
|
||||
github.com/xdg-go/stringprep v1.0.3 // indirect
|
||||
github.com/xdg-go/scram v1.1.2 // indirect
|
||||
github.com/xdg-go/stringprep v1.0.4 // indirect
|
||||
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a // indirect
|
||||
golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 // indirect
|
||||
golang.org/x/net v0.0.0-20220909164309-bea034e7d591 // indirect
|
||||
golang.org/x/sync v0.0.0-20220907140024-f12130a52804 // indirect
|
||||
golang.org/x/crypto v0.8.0 // indirect
|
||||
golang.org/x/net v0.9.0 // indirect
|
||||
golang.org/x/sync v0.1.0 // indirect
|
||||
golang.org/x/sys v0.7.0 // indirect
|
||||
golang.org/x/term v0.6.0 // indirect
|
||||
golang.org/x/text v0.3.7 // indirect
|
||||
google.golang.org/genproto v0.0.0-20220909194730-69f6226f97e5 // indirect
|
||||
google.golang.org/protobuf v1.28.1 // indirect
|
||||
golang.org/x/term v0.7.0 // indirect
|
||||
golang.org/x/text v0.9.0 // indirect
|
||||
google.golang.org/genproto v0.0.0-20230403163135-c38d8f061ccd // indirect
|
||||
google.golang.org/protobuf v1.30.0 // indirect
|
||||
gopkg.in/inf.v0 v0.9.1 // indirect
|
||||
)
|
||||
|
|
91
go.sum
91
go.sum
|
@ -1,9 +1,9 @@
|
|||
github.com/PretendoNetwork/grpc-go v0.0.0-20220820112405-4798a22a13f3 h1:rXQLOWgjXYrmdBCMiZzoSWoe4VPxPCYbveyf0pCagKU=
|
||||
github.com/PretendoNetwork/grpc-go v0.0.0-20220820112405-4798a22a13f3/go.mod h1:iONEVRP4H4OEkfzSWfAWf0Fvh9upLBv21bq2R2iy8Jk=
|
||||
github.com/PretendoNetwork/nex-go v1.0.14 h1:K5E9lh6vjtJ1nMeYOUk/iS7aYtORS0bbbmrNhIQ2AgI=
|
||||
github.com/PretendoNetwork/nex-go v1.0.14/go.mod h1:Bx2ONeSefnbJyE0IDIwGopxrjRrnszOV/uQv74Cx+m0=
|
||||
github.com/PretendoNetwork/nex-protocols-go v1.0.19 h1:SfD/8tIcuqeqZH/ySGxc+kd9EAyvMvH7+gSjG4nCKfc=
|
||||
github.com/PretendoNetwork/nex-protocols-go v1.0.19/go.mod h1:wsa+sNxQj3+THXS2K+R8Ulg4VkCcEBmsg0SRnLnYrjw=
|
||||
github.com/PretendoNetwork/nex-go v1.0.16 h1:g2lJW8G+WOS6/8qsgQ0+jLlzemjJ60tQtLqloLTjElo=
|
||||
github.com/PretendoNetwork/nex-go v1.0.16/go.mod h1:Bx2ONeSefnbJyE0IDIwGopxrjRrnszOV/uQv74Cx+m0=
|
||||
github.com/PretendoNetwork/nex-protocols-go v1.0.20 h1:vUoYHFvVWWx9Bm9/2JiN1siW03tFxtD4NY9w/WfC878=
|
||||
github.com/PretendoNetwork/nex-protocols-go v1.0.20/go.mod h1:Bt7hI7hJ+8r6UU5LSs+3xx4xzsvMVeEUkAW8Cg3lGjQ=
|
||||
github.com/PretendoNetwork/plogger-go v1.0.2 h1:vWKEnEmJJzYwqLxLyiSsAvCrZV6qnnu/a0GQOjIfzY0=
|
||||
github.com/PretendoNetwork/plogger-go v1.0.2/go.mod h1:7kD6M4vPq1JL4LTuPg6kuB1OvUBOwQOtAvTaUwMbwvU=
|
||||
github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932 h1:mXoPYz/Ul5HYEDvkta6I8/rnYM5gSdSV2tJ6XbZuEtY=
|
||||
|
@ -15,27 +15,27 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
|
|||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs=
|
||||
github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw=
|
||||
github.com/gocql/gocql v1.2.1 h1:G/STxUzD6pGvRHzG0Fi7S04SXejMKBbRZb7pwre1edU=
|
||||
github.com/gocql/gocql v1.2.1/go.mod h1:3gM2c4D3AnkISwBxGnMMsS8Oy4y2lhbPRsH4xnJrHG8=
|
||||
github.com/gocql/gocql v1.3.2 h1:ox3T+R7VFibHSIGxRkuUi1uIvAv8jBHCWxc+9aFQ/LA=
|
||||
github.com/gocql/gocql v1.3.2/go.mod h1:3gM2c4D3AnkISwBxGnMMsS8Oy4y2lhbPRsH4xnJrHG8=
|
||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
|
||||
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
|
||||
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
|
||||
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
|
||||
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
||||
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed h1:5upAirOpQc1Q53c0bnx2ufif5kANL7bfZWcc6VJWJd8=
|
||||
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed/go.mod h1:tMWxXQ9wFIaZeTI9F+hmhFiGpFmhOHzyShyFUhRm0H4=
|
||||
github.com/joho/godotenv v1.4.0 h1:3l4+N6zfMWnkbPEXKng2o2/MR5mSwTrBih4ZEkkz1lg=
|
||||
github.com/joho/godotenv v1.4.0/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
||||
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
|
||||
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
||||
github.com/jwalton/go-supportscolor v1.1.0 h1:HsXFJdMPjRUAx8cIW6g30hVSFYaxh9yRQwEWgkAR7lQ=
|
||||
github.com/jwalton/go-supportscolor v1.1.0/go.mod h1:hFVUAZV2cWg+WFFC4v8pT2X/S2qUUBYMioBD9AINXGs=
|
||||
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
|
||||
github.com/klauspost/compress v1.15.9 h1:wKRjX6JRtDdrE9qwa4b/Cip7ACOshUI4smpCQanqjSY=
|
||||
github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU=
|
||||
github.com/klauspost/compress v1.16.4 h1:91KN02FnsOYhuunwU4ssRe8lc2JosWmizWa91B5v1PU=
|
||||
github.com/klauspost/compress v1.16.4/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
|
||||
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
|
@ -49,8 +49,8 @@ github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/
|
|||
github.com/mattn/go-isatty v0.0.18 h1:DOKFKCQ7FNG2L1rbrmstDN4QVRdS89Nkh85u68Uwp98=
|
||||
github.com/mattn/go-isatty v0.0.18/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc=
|
||||
github.com/montanaflynn/stats v0.6.6 h1:Duep6KMIDpY4Yo11iFsvyqJDyfzLF9+sndUKT+v64GQ=
|
||||
github.com/montanaflynn/stats v0.6.6/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow=
|
||||
github.com/montanaflynn/stats v0.7.0 h1:r3y12KyNxj/Sb/iOE46ws+3mS1+MZca1wlHQFPsY/JU=
|
||||
github.com/montanaflynn/stats v0.7.0/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
|
@ -66,57 +66,76 @@ github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4=
|
|||
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
|
||||
github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c=
|
||||
github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
|
||||
github.com/xdg-go/scram v1.1.1 h1:VOMT+81stJgXW3CpHyqHN3AXDYIMsx56mEFrB37Mb/E=
|
||||
github.com/xdg-go/scram v1.1.1/go.mod h1:RaEWvsqvNKKvBPvcKeFjrG2cJqOkHTiyTpzz23ni57g=
|
||||
github.com/xdg-go/stringprep v1.0.3 h1:kdwGpVNwPFtjs98xCGkHjQtGKh86rDcRZN17QEMCOIs=
|
||||
github.com/xdg-go/scram v1.1.2 h1:FHX5I5B4i4hKRVRBCFRxq1iQRej7WO3hhBuJf+UUySY=
|
||||
github.com/xdg-go/scram v1.1.2/go.mod h1:RT/sEzTbU5y00aCK8UOx6R7YryM0iF1N2MOmC3kKLN4=
|
||||
github.com/xdg-go/stringprep v1.0.3/go.mod h1:W3f5j4i+9rC0kuIEJL0ky1VpHXQU3ocBgklLGvcBnW8=
|
||||
github.com/xdg-go/stringprep v1.0.4 h1:XLI/Ng3O1Atzq0oBs3TWm+5ZVgkq2aqdlvP9JtoZ6c8=
|
||||
github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gijq1dTyGkM=
|
||||
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA=
|
||||
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a h1:fZHgsYlfvtyqToslyjUt3VOPF4J7aK/3MPcK7xp3PDk=
|
||||
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a/go.mod h1:ul22v+Nro/R083muKhosV54bj5niojjWZvU8xrevuH4=
|
||||
go.mongodb.org/mongo-driver v1.10.2 h1:4Wk3cnqOrQCn0P92L3/mmurMxzdvWWs5J9jinAVKD+k=
|
||||
go.mongodb.org/mongo-driver v1.10.2/go.mod h1:z4XpeoU6w+9Vht+jAFyLgVrD+jGSQQe0+CBWFHNiHt8=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
go.mongodb.org/mongo-driver v1.11.4 h1:4ayjakA013OdpGyL2K3ZqylTac/rMjrJOMZ1EHizXas=
|
||||
go.mongodb.org/mongo-driver v1.11.4/go.mod h1:PTSz5yu21bkT/wXpkS7WR5f0ddqw5quethTUn9WM+2g=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 h1:Y/gsMcFOcR+6S6f3YeMKl5g+dZMEWqcz5Czj/GWYbkM=
|
||||
golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/exp v0.0.0-20230213192124-5e25df0256eb h1:PaBZQdo+iSDyHT053FjUCgZQ/9uqVwPOcl7KSWhKn6w=
|
||||
golang.org/x/exp v0.0.0-20230213192124-5e25df0256eb/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
|
||||
golang.org/x/crypto v0.8.0 h1:pd9TJtTueMTVQXzk8E2XESSMQDj/U7OUu0PqJqPXQjQ=
|
||||
golang.org/x/crypto v0.8.0/go.mod h1:mRqEX+O9/h5TFCrQhkgjo2yKi0yYA+9ecGkdQoHrywE=
|
||||
golang.org/x/exp v0.0.0-20230321023759-10a507213a29 h1:ooxPy7fPvB4kwsA2h+iBNHkAbp/4JxTSwCmvdjEYmug=
|
||||
golang.org/x/exp v0.0.0-20230321023759-10a507213a29/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20220909164309-bea034e7d591 h1:D0B/7al0LLrVC8aWF4+oxpv/m8bc7ViFfVS8/gXGdqI=
|
||||
golang.org/x/net v0.0.0-20220909164309-bea034e7d591/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM=
|
||||
golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220907140024-f12130a52804 h1:0SH2R3f1b1VmIMG7BXbEZCBUu2dKmHschSmjqGUrW8A=
|
||||
golang.org/x/sync v0.0.0-20220907140024-f12130a52804/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
|
||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU=
|
||||
golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.6.0 h1:clScbb1cHjoCkyRbWwBEUZ5H/tIFu5TAXIqaZD0Gcjw=
|
||||
golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.7.0 h1:BEvjmm5fURWqcfbSKTdpkDXYBrUS1c0m8agp14W48vQ=
|
||||
golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
|
||||
golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE=
|
||||
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/genproto v0.0.0-20220909194730-69f6226f97e5 h1:ngtP8S8JkBWfJACT9cmj5eTkS9tIWPQI5leBz/7Bq/c=
|
||||
google.golang.org/genproto v0.0.0-20220909194730-69f6226f97e5/go.mod h1:0Nb8Qy+Sk5eDzHnzlStwW3itdNaWoZA5XeSG+R3JHSo=
|
||||
google.golang.org/grpc v1.49.0 h1:WTLtQzmQori5FUH25Pq4WT22oCsv8USpQ+F6rqtsmxw=
|
||||
google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI=
|
||||
google.golang.org/genproto v0.0.0-20230403163135-c38d8f061ccd h1:sLpv7bNL1AsX3fdnWh9WVh7ejIzXdOc1RRHGeAmeStU=
|
||||
google.golang.org/genproto v0.0.0-20230403163135-c38d8f061ccd/go.mod h1:UUQDJDOlWu4KYeJZffbWgBkS1YFobzKbLVfK69pe0Ak=
|
||||
google.golang.org/grpc v1.54.0 h1:EhTqbhiYeixwWQtAEZAxmV9MGqcjEU2mFx52xCzNyag=
|
||||
google.golang.org/grpc v1.54.0/go.mod h1:PUSEXI6iWghWaB6lXM4knEgpJNu2qUcKfDtNci3EC2g=
|
||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w=
|
||||
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||
google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng=
|
||||
google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package grpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
@ -8,7 +8,7 @@ import (
|
|||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
pb "github.com/PretendoNetwork/grpc-go/friends"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
nintendo_notifications "github.com/PretendoNetwork/nex-protocols-go/nintendo-notifications"
|
||||
empty "github.com/golang/protobuf/ptypes/empty"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
@ -23,9 +23,9 @@ func (s *gRPCFriendsServer) SendUserNotificationWiiU(ctx context.Context, in *pb
|
|||
|
||||
if connectedUser != nil {
|
||||
rmcRequest := nex.NewRMCRequest()
|
||||
rmcRequest.SetProtocolID(nexproto.NintendoNotificationsProtocolID)
|
||||
rmcRequest.SetProtocolID(nintendo_notifications.ProtocolID)
|
||||
rmcRequest.SetCallID(3810693103)
|
||||
rmcRequest.SetMethodID(nexproto.NintendoNotificationsMethodProcessNintendoNotificationEvent2)
|
||||
rmcRequest.SetMethodID(nintendo_notifications.MethodProcessNintendoNotificationEvent2)
|
||||
rmcRequest.SetParameters(in.GetNotificationData())
|
||||
|
||||
rmcRequestBytes := rmcRequest.Bytes()
|
||||
|
@ -47,7 +47,7 @@ func (s *gRPCFriendsServer) SendUserNotificationWiiU(ctx context.Context, in *pb
|
|||
return &empty.Empty{}, nil
|
||||
}
|
||||
|
||||
func startGRPCServer() {
|
||||
func StartGRPCServer() {
|
||||
listener, err := net.Listen("tcp", ":50051")
|
||||
if err != nil {
|
||||
log.Fatalf("failed to listen: %v", err)
|
32
init.go
32
init.go
|
@ -1,55 +1,35 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"crypto/rsa"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
|
||||
"github.com/PretendoNetwork/friends-secure/database"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
"github.com/PretendoNetwork/friends-secure/types"
|
||||
"github.com/PretendoNetwork/friends-secure/utility"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
)
|
||||
|
||||
/*
|
||||
type Config struct {
|
||||
Mongo struct {
|
||||
}
|
||||
Cassandra struct{}
|
||||
}
|
||||
*/
|
||||
|
||||
type nexToken struct {
|
||||
SystemType uint8
|
||||
TokenType uint8
|
||||
UserPID uint32
|
||||
AccessLevel uint8
|
||||
TitleID uint64
|
||||
ExpireTime uint64
|
||||
}
|
||||
|
||||
var rsaPrivateKeyBytes []byte
|
||||
var rsaPrivateKey *rsa.PrivateKey
|
||||
var hmacSecret []byte
|
||||
|
||||
func init() {
|
||||
globals.ConnectedUsers = make(map[uint32]*globals.ConnectedUser)
|
||||
globals.ConnectedUsers = make(map[uint32]*types.ConnectedUser)
|
||||
// Setup RSA private key for token parsing
|
||||
var err error
|
||||
|
||||
rsaPrivateKeyBytes, err = ioutil.ReadFile("private.pem")
|
||||
globals.RSAPrivateKeyBytes, err = ioutil.ReadFile("private.pem")
|
||||
if err != nil {
|
||||
// TODO: Handle error
|
||||
globals.Logger.Critical(err.Error())
|
||||
}
|
||||
|
||||
rsaPrivateKey, err = parseRsaPrivateKey(rsaPrivateKeyBytes)
|
||||
globals.RSAPrivateKey, err = utility.ParseRsaPrivateKey(globals.RSAPrivateKeyBytes)
|
||||
if err != nil {
|
||||
// TODO: Handle error
|
||||
globals.Logger.Critical(err.Error())
|
||||
}
|
||||
|
||||
hmacSecret, err = ioutil.ReadFile("secret.key")
|
||||
globals.HMACSecret, err = ioutil.ReadFile("secret.key")
|
||||
if err != nil {
|
||||
// TODO: Handle error
|
||||
globals.Logger.Critical(err.Error())
|
||||
|
|
7
main.go
7
main.go
|
@ -2,6 +2,9 @@ package main
|
|||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"github.com/PretendoNetwork/friends-secure/grpc"
|
||||
"github.com/PretendoNetwork/friends-secure/nex"
|
||||
)
|
||||
|
||||
var wg sync.WaitGroup
|
||||
|
@ -9,8 +12,8 @@ var wg sync.WaitGroup
|
|||
func main() {
|
||||
wg.Add(2)
|
||||
|
||||
go startGRPCServer()
|
||||
go startNEXServer()
|
||||
go grpc.StartGRPCServer()
|
||||
go nex.StartNEXServer()
|
||||
|
||||
wg.Wait()
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package nex_account_management
|
||||
|
||||
import (
|
||||
"crypto/hmac"
|
||||
|
@ -9,11 +9,12 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
"github.com/PretendoNetwork/friends-secure/utility"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
account_management "github.com/PretendoNetwork/nex-protocols-go/account-management"
|
||||
)
|
||||
|
||||
func nintendoCreateAccount(err error, client *nex.Client, callID uint32, strPrincipalName string, strKey string, uiGroups uint32, strEmail string, oAuthData *nex.DataHolder) {
|
||||
func NintendoCreateAccount(err error, client *nex.Client, callID uint32, strPrincipalName string, strKey string, uiGroups uint32, strEmail string, oAuthData *nex.DataHolder) {
|
||||
if err != nil {
|
||||
// TODO: Handle error
|
||||
globals.Logger.Critical(err.Error())
|
||||
|
@ -24,11 +25,11 @@ func nintendoCreateAccount(err error, client *nex.Client, callID uint32, strPrin
|
|||
oAuthDataType := oAuthData.TypeName()
|
||||
|
||||
if oAuthDataType == "NintendoCreateAccountData" { // Wii U
|
||||
nintendoCreateAccountData := oAuthData.ObjectData().(*nexproto.NintendoCreateAccountData)
|
||||
nintendoCreateAccountData := oAuthData.ObjectData().(*account_management.NintendoCreateAccountData)
|
||||
|
||||
tokenBase64 = nintendoCreateAccountData.Token
|
||||
} else if oAuthDataType == "AccountExtraInfo" { // 3DS
|
||||
accountExtraInfo := oAuthData.ObjectData().(*nexproto.AccountExtraInfo)
|
||||
accountExtraInfo := oAuthData.ObjectData().(*account_management.AccountExtraInfo)
|
||||
|
||||
tokenBase64 = accountExtraInfo.NEXToken
|
||||
tokenBase64 = strings.Replace(tokenBase64, ".", "+", -1)
|
||||
|
@ -38,7 +39,7 @@ func nintendoCreateAccount(err error, client *nex.Client, callID uint32, strPrin
|
|||
|
||||
encryptedToken, _ := base64.StdEncoding.DecodeString(tokenBase64)
|
||||
|
||||
decryptedToken, err := decryptToken(encryptedToken)
|
||||
decryptedToken, err := utility.DecryptToken(encryptedToken)
|
||||
if err != nil {
|
||||
// TODO: Handle error
|
||||
globals.Logger.Critical(err.Error())
|
||||
|
@ -61,8 +62,8 @@ func nintendoCreateAccount(err error, client *nex.Client, callID uint32, strPrin
|
|||
|
||||
rmcResponseBody := rmcResponseStream.Bytes()
|
||||
|
||||
rmcResponse := nex.NewRMCResponse(nexproto.AccountManagementProtocolID, callID)
|
||||
rmcResponse.SetSuccess(nexproto.AccountManagementMethodNintendoCreateAccount, rmcResponseBody)
|
||||
rmcResponse := nex.NewRMCResponse(account_management.ProtocolID, callID)
|
||||
rmcResponse.SetSuccess(account_management.MethodNintendoCreateAccount, rmcResponseBody)
|
||||
|
||||
rmcResponseBytes := rmcResponse.Bytes()
|
||||
|
|
@ -1,7 +1,8 @@
|
|||
package main
|
||||
package nex
|
||||
|
||||
import (
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
"github.com/PretendoNetwork/friends-secure/types"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
)
|
||||
|
||||
|
@ -46,7 +47,7 @@ func connect(packet *nex.PacketV0) {
|
|||
|
||||
packet.Sender().SetPID(userPID)
|
||||
|
||||
connectedUser := globals.NewConnectedUser()
|
||||
connectedUser := types.NewConnectedUser()
|
||||
connectedUser.PID = packet.Sender().PID()
|
||||
connectedUser.Client = packet.Sender()
|
||||
globals.ConnectedUsers[userPID] = connectedUser
|
|
@ -1,11 +1,11 @@
|
|||
package friends_3ds
|
||||
package nex_friends_3ds
|
||||
|
||||
import (
|
||||
database_3ds "github.com/PretendoNetwork/friends-secure/database/3ds"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
notifications_3ds "github.com/PretendoNetwork/friends-secure/notifications/3ds"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends/3ds"
|
||||
)
|
||||
|
||||
func AddFriendshipByPrincipalID(err error, client *nex.Client, callID uint32, lfc uint64, pid uint32) {
|
||||
|
@ -22,8 +22,8 @@ func AddFriendshipByPrincipalID(err error, client *nex.Client, callID uint32, lf
|
|||
|
||||
rmcResponseBody := rmcResponseStream.Bytes()
|
||||
|
||||
rmcResponse := nex.NewRMCResponse(nexproto.Friends3DSProtocolID, callID)
|
||||
rmcResponse.SetSuccess(nexproto.Friends3DSMethodAddFriendByPrincipalID, rmcResponseBody)
|
||||
rmcResponse := nex.NewRMCResponse(friends_3ds.ProtocolID, callID)
|
||||
rmcResponse.SetSuccess(friends_3ds.MethodAddFriendByPrincipalID, rmcResponseBody)
|
||||
|
||||
rmcResponseBytes := rmcResponse.Bytes()
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
package friends_3ds
|
||||
package nex_friends_3ds
|
||||
|
||||
import (
|
||||
database_3ds "github.com/PretendoNetwork/friends-secure/database/3ds"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends/3ds"
|
||||
)
|
||||
|
||||
func GetAllFriends(err error, client *nex.Client, callID uint32) {
|
||||
|
@ -16,8 +16,8 @@ func GetAllFriends(err error, client *nex.Client, callID uint32) {
|
|||
|
||||
rmcResponseBody := rmcResponseStream.Bytes()
|
||||
|
||||
rmcResponse := nex.NewRMCResponse(nexproto.Friends3DSProtocolID, callID)
|
||||
rmcResponse.SetSuccess(nexproto.Friends3DSMethodGetAllFriends, rmcResponseBody)
|
||||
rmcResponse := nex.NewRMCResponse(friends_3ds.ProtocolID, callID)
|
||||
rmcResponse.SetSuccess(friends_3ds.MethodGetAllFriends, rmcResponseBody)
|
||||
|
||||
rmcResponseBytes := rmcResponse.Bytes()
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
package friends_3ds
|
||||
package nex_friends_3ds
|
||||
|
||||
import (
|
||||
database_3ds "github.com/PretendoNetwork/friends-secure/database/3ds"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends/3ds"
|
||||
)
|
||||
|
||||
func GetFriendMii(err error, client *nex.Client, callID uint32, pids []uint32) {
|
||||
|
@ -16,8 +16,8 @@ func GetFriendMii(err error, client *nex.Client, callID uint32, pids []uint32) {
|
|||
|
||||
rmcResponseBody := rmcResponseStream.Bytes()
|
||||
|
||||
rmcResponse := nex.NewRMCResponse(nexproto.Friends3DSProtocolID, callID)
|
||||
rmcResponse.SetSuccess(nexproto.Friends3DSMethodGetFriendMii, rmcResponseBody)
|
||||
rmcResponse := nex.NewRMCResponse(friends_3ds.ProtocolID, callID)
|
||||
rmcResponse.SetSuccess(friends_3ds.MethodGetFriendMii, rmcResponseBody)
|
||||
|
||||
rmcResponseBytes := rmcResponse.Bytes()
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
package friends_3ds
|
||||
package nex_friends_3ds
|
||||
|
||||
import (
|
||||
database_3ds "github.com/PretendoNetwork/friends-secure/database/3ds"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends/3ds"
|
||||
)
|
||||
|
||||
func GetFriendPersistentInfo(err error, client *nex.Client, callID uint32, pids []uint32) {
|
||||
|
@ -16,8 +16,8 @@ func GetFriendPersistentInfo(err error, client *nex.Client, callID uint32, pids
|
|||
|
||||
rmcResponseBody := rmcResponseStream.Bytes()
|
||||
|
||||
rmcResponse := nex.NewRMCResponse(nexproto.Friends3DSProtocolID, callID)
|
||||
rmcResponse.SetSuccess(nexproto.Friends3DSMethodGetFriendPersistentInfo, rmcResponseBody)
|
||||
rmcResponse := nex.NewRMCResponse(friends_3ds.ProtocolID, callID)
|
||||
rmcResponse.SetSuccess(friends_3ds.MethodGetFriendPersistentInfo, rmcResponseBody)
|
||||
|
||||
rmcResponseBytes := rmcResponse.Bytes()
|
||||
|
|
@ -1,19 +1,19 @@
|
|||
package friends_3ds
|
||||
package nex_friends_3ds
|
||||
|
||||
import (
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends/3ds"
|
||||
)
|
||||
|
||||
func GetFriendPresence(err error, client *nex.Client, callID uint32, pids []uint32) {
|
||||
presenceList := make([]*nexproto.FriendPresence, 0)
|
||||
presenceList := make([]*friends_3ds.FriendPresence, 0)
|
||||
|
||||
for i := 0; i < len(pids); i++ {
|
||||
connectedUser := globals.ConnectedUsers[pids[i]]
|
||||
|
||||
if connectedUser != nil && connectedUser.Presence != nil {
|
||||
friendPresence := nexproto.NewFriendPresence()
|
||||
friendPresence := friends_3ds.NewFriendPresence()
|
||||
friendPresence.PID = pids[i]
|
||||
friendPresence.Presence = globals.ConnectedUsers[pids[i]].Presence
|
||||
|
||||
|
@ -27,8 +27,8 @@ func GetFriendPresence(err error, client *nex.Client, callID uint32, pids []uint
|
|||
|
||||
rmcResponseBody := rmcResponseStream.Bytes()
|
||||
|
||||
rmcResponse := nex.NewRMCResponse(nexproto.Friends3DSProtocolID, callID)
|
||||
rmcResponse.SetSuccess(nexproto.Friends3DSMethodGetFriendPresence, rmcResponseBody)
|
||||
rmcResponse := nex.NewRMCResponse(friends_3ds.ProtocolID, callID)
|
||||
rmcResponse.SetSuccess(friends_3ds.MethodGetFriendPresence, rmcResponseBody)
|
||||
|
||||
rmcResponseBytes := rmcResponse.Bytes()
|
||||
|
|
@ -1,15 +1,15 @@
|
|||
package friends_3ds
|
||||
package nex_friends_3ds
|
||||
|
||||
import (
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends/3ds"
|
||||
)
|
||||
|
||||
func GetPrincipalIDByLocalFriendCode(err error, client *nex.Client, callID uint32, lfc uint64, lfcList []uint64) {
|
||||
// Respond with unimplemented, waiting for gRPC to retrieve PID from account server
|
||||
|
||||
rmcResponse := nex.NewRMCResponse(nexproto.Friends3DSProtocolID, callID)
|
||||
rmcResponse := nex.NewRMCResponse(friends_3ds.ProtocolID, callID)
|
||||
rmcResponse.SetError(nex.Errors.Core.NotImplemented)
|
||||
|
||||
rmcResponseBytes := rmcResponse.Bytes()
|
|
@ -1,15 +1,15 @@
|
|||
package friends_3ds
|
||||
package nex_friends_3ds
|
||||
|
||||
import (
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends/3ds"
|
||||
)
|
||||
|
||||
func RemoveFriendByLocalFriendCode(err error, client *nex.Client, callID uint32, friendLFC uint64) {
|
||||
// Respond with unimplemented, waiting for gRPC to retrieve PID from account server
|
||||
|
||||
rmcResponse := nex.NewRMCResponse(nexproto.Friends3DSProtocolID, callID)
|
||||
rmcResponse := nex.NewRMCResponse(friends_3ds.ProtocolID, callID)
|
||||
rmcResponse.SetError(nex.Errors.Core.NotImplemented)
|
||||
|
||||
rmcResponseBytes := rmcResponse.Bytes()
|
|
@ -1,19 +1,19 @@
|
|||
package friends_3ds
|
||||
package nex_friends_3ds
|
||||
|
||||
import (
|
||||
database_3ds "github.com/PretendoNetwork/friends-secure/database/3ds"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
notifications_3ds "github.com/PretendoNetwork/friends-secure/notifications/3ds"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends/3ds"
|
||||
)
|
||||
|
||||
func RemoveFriendByPrincipalID(err error, client *nex.Client, callID uint32, pid uint32) {
|
||||
go notifications_3ds.SendUserWentOffline(client, pid)
|
||||
database_3ds.RemoveFriendship(client.PID(), pid)
|
||||
|
||||
rmcResponse := nex.NewRMCResponse(nexproto.Friends3DSProtocolID, callID)
|
||||
rmcResponse.SetSuccess(nexproto.Friends3DSMethodRemoveFriendByPrincipalID, nil)
|
||||
rmcResponse := nex.NewRMCResponse(friends_3ds.ProtocolID, callID)
|
||||
rmcResponse.SetSuccess(friends_3ds.MethodRemoveFriendByPrincipalID, nil)
|
||||
|
||||
rmcResponseBytes := rmcResponse.Bytes()
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
package friends_3ds
|
||||
package nex_friends_3ds
|
||||
|
||||
import (
|
||||
database_3ds "github.com/PretendoNetwork/friends-secure/database/3ds"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
notifications_3ds "github.com/PretendoNetwork/friends-secure/notifications/3ds"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends/3ds"
|
||||
"golang.org/x/exp/slices"
|
||||
)
|
||||
|
||||
|
@ -38,8 +38,8 @@ func SyncFriend(err error, client *nex.Client, callID uint32, lfc uint64, pids [
|
|||
|
||||
rmcResponseBody := rmcResponseStream.Bytes()
|
||||
|
||||
rmcResponse := nex.NewRMCResponse(nexproto.Friends3DSProtocolID, callID)
|
||||
rmcResponse.SetSuccess(nexproto.Friends3DSMethodSyncFriend, rmcResponseBody)
|
||||
rmcResponse := nex.NewRMCResponse(friends_3ds.ProtocolID, callID)
|
||||
rmcResponse.SetSuccess(friends_3ds.MethodSyncFriend, rmcResponseBody)
|
||||
|
||||
rmcResponseBytes := rmcResponse.Bytes()
|
||||
|
||||
|
@ -57,7 +57,7 @@ func SyncFriend(err error, client *nex.Client, callID uint32, lfc uint64, pids [
|
|||
globals.NEXServer.Send(responsePacket)
|
||||
}
|
||||
|
||||
func isPIDInRelationships(relationships []*nexproto.FriendRelationship, pid uint32) bool {
|
||||
func isPIDInRelationships(relationships []*friends_3ds.FriendRelationship, pid uint32) bool {
|
||||
for i := range relationships {
|
||||
if relationships[i].PID == pid {
|
||||
return true
|
|
@ -1,19 +1,19 @@
|
|||
package friends_3ds
|
||||
package nex_friends_3ds
|
||||
|
||||
import (
|
||||
database_3ds "github.com/PretendoNetwork/friends-secure/database/3ds"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
notifications_3ds "github.com/PretendoNetwork/friends-secure/notifications/3ds"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends/3ds"
|
||||
)
|
||||
|
||||
func UpdateComment(err error, client *nex.Client, callID uint32, comment string) {
|
||||
go notifications_3ds.SendCommentUpdate(client, comment)
|
||||
database_3ds.UpdateUserComment(client.PID(), comment)
|
||||
|
||||
rmcResponse := nex.NewRMCResponse(nexproto.Friends3DSProtocolID, callID)
|
||||
rmcResponse.SetSuccess(nexproto.Friends3DSMethodUpdateComment, nil)
|
||||
rmcResponse := nex.NewRMCResponse(friends_3ds.ProtocolID, callID)
|
||||
rmcResponse.SetSuccess(friends_3ds.MethodUpdateComment, nil)
|
||||
|
||||
rmcResponseBytes := rmcResponse.Bytes()
|
||||
|
|
@ -1,19 +1,19 @@
|
|||
package friends_3ds
|
||||
package nex_friends_3ds
|
||||
|
||||
import (
|
||||
database_3ds "github.com/PretendoNetwork/friends-secure/database/3ds"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
notifications_3ds "github.com/PretendoNetwork/friends-secure/notifications/3ds"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends/3ds"
|
||||
)
|
||||
|
||||
func UpdateFavoriteGameKey(err error, client *nex.Client, callID uint32, gameKey *nexproto.GameKey) {
|
||||
func UpdateFavoriteGameKey(err error, client *nex.Client, callID uint32, gameKey *friends_3ds.GameKey) {
|
||||
go notifications_3ds.SendFavoriteUpdate(client, gameKey)
|
||||
database_3ds.UpdateUserFavoriteGame(client.PID(), gameKey)
|
||||
|
||||
rmcResponse := nex.NewRMCResponse(nexproto.Friends3DSProtocolID, callID)
|
||||
rmcResponse.SetSuccess(nexproto.Friends3DSMethodUpdateFavoriteGameKey, nil)
|
||||
rmcResponse := nex.NewRMCResponse(friends_3ds.ProtocolID, callID)
|
||||
rmcResponse.SetSuccess(friends_3ds.MethodUpdateFavoriteGameKey, nil)
|
||||
|
||||
rmcResponseBytes := rmcResponse.Bytes()
|
||||
|
|
@ -1,19 +1,19 @@
|
|||
package friends_3ds
|
||||
package nex_friends_3ds
|
||||
|
||||
import (
|
||||
database_3ds "github.com/PretendoNetwork/friends-secure/database/3ds"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
notifications_3ds "github.com/PretendoNetwork/friends-secure/notifications/3ds"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends/3ds"
|
||||
)
|
||||
|
||||
func UpdateMii(err error, client *nex.Client, callID uint32, mii *nexproto.Mii) {
|
||||
func UpdateMii(err error, client *nex.Client, callID uint32, mii *friends_3ds.Mii) {
|
||||
go notifications_3ds.SendMiiUpdateNotification(client)
|
||||
database_3ds.UpdateUserMii(client.PID(), mii)
|
||||
|
||||
rmcResponse := nex.NewRMCResponse(nexproto.Friends3DSProtocolID, callID)
|
||||
rmcResponse.SetSuccess(nexproto.Friends3DSMethodUpdateMii, nil)
|
||||
rmcResponse := nex.NewRMCResponse(friends_3ds.ProtocolID, callID)
|
||||
rmcResponse.SetSuccess(friends_3ds.MethodUpdateMii, nil)
|
||||
|
||||
rmcResponseBytes := rmcResponse.Bytes()
|
||||
|
|
@ -1,17 +1,17 @@
|
|||
package friends_3ds
|
||||
package nex_friends_3ds
|
||||
|
||||
import (
|
||||
database_3ds "github.com/PretendoNetwork/friends-secure/database/3ds"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
notifications_3ds "github.com/PretendoNetwork/friends-secure/notifications/3ds"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends/3ds"
|
||||
)
|
||||
|
||||
func UpdatePreference(err error, client *nex.Client, callID uint32, showOnline bool, showCurrentGame bool, showPlayedGame bool) {
|
||||
if !showCurrentGame {
|
||||
emptyPresence := nexproto.NewNintendoPresence()
|
||||
emptyPresence.GameKey = nexproto.NewGameKey()
|
||||
emptyPresence := friends_3ds.NewNintendoPresence()
|
||||
emptyPresence.GameKey = friends_3ds.NewGameKey()
|
||||
emptyPresence.ChangedFlags = 0xFFFFFFFF // All flags
|
||||
notifications_3ds.SendPresenceUpdate(client, emptyPresence)
|
||||
}
|
||||
|
@ -21,8 +21,8 @@ func UpdatePreference(err error, client *nex.Client, callID uint32, showOnline b
|
|||
|
||||
database_3ds.UpdateUserPreferences(client.PID(), showOnline, showCurrentGame)
|
||||
|
||||
rmcResponse := nex.NewRMCResponse(nexproto.Friends3DSProtocolID, callID)
|
||||
rmcResponse.SetSuccess(nexproto.Friends3DSMethodUpdatePreference, nil)
|
||||
rmcResponse := nex.NewRMCResponse(friends_3ds.ProtocolID, callID)
|
||||
rmcResponse.SetSuccess(friends_3ds.MethodUpdatePreference, nil)
|
||||
|
||||
rmcResponseBytes := rmcResponse.Bytes()
|
||||
|
|
@ -1,27 +1,27 @@
|
|||
package friends_3ds
|
||||
package nex_friends_3ds
|
||||
|
||||
import (
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
notifications_3ds "github.com/PretendoNetwork/friends-secure/notifications/3ds"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends/3ds"
|
||||
)
|
||||
|
||||
func UpdatePresence(err error, client *nex.Client, callID uint32, presence *nexproto.NintendoPresence, showGame bool) {
|
||||
func UpdatePresence(err error, client *nex.Client, callID uint32, presence *friends_3ds.NintendoPresence, showGame bool) {
|
||||
currentPresence := presence
|
||||
|
||||
// Send an entirely empty status, with every flag set to update
|
||||
if !showGame {
|
||||
currentPresence = nexproto.NewNintendoPresence()
|
||||
currentPresence.GameKey = nexproto.NewGameKey()
|
||||
currentPresence = friends_3ds.NewNintendoPresence()
|
||||
currentPresence.GameKey = friends_3ds.NewGameKey()
|
||||
currentPresence.ChangedFlags = 0xFFFFFFFF // All flags
|
||||
}
|
||||
|
||||
go notifications_3ds.SendPresenceUpdate(client, currentPresence)
|
||||
globals.ConnectedUsers[client.PID()].Presence = currentPresence
|
||||
|
||||
rmcResponse := nex.NewRMCResponse(nexproto.Friends3DSProtocolID, callID)
|
||||
rmcResponse.SetSuccess(nexproto.Friends3DSMethodUpdatePresence, nil)
|
||||
rmcResponse := nex.NewRMCResponse(friends_3ds.ProtocolID, callID)
|
||||
rmcResponse.SetSuccess(friends_3ds.MethodUpdatePresence, nil)
|
||||
|
||||
rmcResponseBytes := rmcResponse.Bytes()
|
||||
|
|
@ -1,17 +1,17 @@
|
|||
package friends_3ds
|
||||
package nex_friends_3ds
|
||||
|
||||
import (
|
||||
database_3ds "github.com/PretendoNetwork/friends-secure/database/3ds"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends/3ds"
|
||||
)
|
||||
|
||||
func UpdateProfile(err error, client *nex.Client, callID uint32, profileData *nexproto.MyProfile) {
|
||||
func UpdateProfile(err error, client *nex.Client, callID uint32, profileData *friends_3ds.MyProfile) {
|
||||
database_3ds.UpdateUserProfile(client.PID(), profileData)
|
||||
|
||||
rmcResponse := nex.NewRMCResponse(nexproto.Friends3DSProtocolID, callID)
|
||||
rmcResponse.SetSuccess(nexproto.Friends3DSMethodUpdateProfile, nil)
|
||||
rmcResponse := nex.NewRMCResponse(friends_3ds.ProtocolID, callID)
|
||||
rmcResponse.SetSuccess(friends_3ds.MethodUpdateProfile, nil)
|
||||
|
||||
rmcResponseBytes := rmcResponse.Bytes()
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
package friends_wiiu
|
||||
package nex_friends_wiiu
|
||||
|
||||
import (
|
||||
database_wiiu "github.com/PretendoNetwork/friends-secure/database/wiiu"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
notifications_wiiu "github.com/PretendoNetwork/friends-secure/notifications/wiiu"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
)
|
||||
|
||||
func AcceptFriendRequest(err error, client *nex.Client, callID uint32, id uint64) {
|
||||
|
@ -18,7 +18,7 @@ func AcceptFriendRequest(err error, client *nex.Client, callID uint32, id uint64
|
|||
senderPID := client.PID()
|
||||
senderConnectedUser := globals.ConnectedUsers[senderPID]
|
||||
|
||||
senderFriendInfo := nexproto.NewFriendInfo()
|
||||
senderFriendInfo := friends_wiiu.NewFriendInfo()
|
||||
|
||||
senderFriendInfo.NNAInfo = senderConnectedUser.NNAInfo
|
||||
senderFriendInfo.Presence = senderConnectedUser.PresenceV2
|
||||
|
@ -37,8 +37,8 @@ func AcceptFriendRequest(err error, client *nex.Client, callID uint32, id uint64
|
|||
rmcResponseBody := rmcResponseStream.Bytes()
|
||||
|
||||
// Build response packet
|
||||
rmcResponse := nex.NewRMCResponse(nexproto.FriendsWiiUProtocolID, callID)
|
||||
rmcResponse.SetSuccess(nexproto.FriendsWiiUMethodAcceptFriendRequest, rmcResponseBody)
|
||||
rmcResponse := nex.NewRMCResponse(friends_wiiu.ProtocolID, callID)
|
||||
rmcResponse.SetSuccess(friends_wiiu.MethodAcceptFriendRequest, rmcResponseBody)
|
||||
|
||||
rmcResponseBytes := rmcResponse.Bytes()
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package friends_wiiu
|
||||
package nex_friends_wiiu
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
@ -6,10 +6,10 @@ import (
|
|||
database_wiiu "github.com/PretendoNetwork/friends-secure/database/wiiu"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
)
|
||||
|
||||
func AddBlacklist(err error, client *nex.Client, callID uint32, blacklistPrincipal *nexproto.BlacklistedPrincipal) {
|
||||
func AddBlacklist(err error, client *nex.Client, callID uint32, blacklistPrincipal *friends_wiiu.BlacklistedPrincipal) {
|
||||
currentBlacklistPrincipal := blacklistPrincipal
|
||||
|
||||
senderPID := currentBlacklistPrincipal.PrincipalBasicInfo.PID
|
||||
|
@ -22,7 +22,7 @@ func AddBlacklist(err error, client *nex.Client, callID uint32, blacklistPrincip
|
|||
userInfo := database_wiiu.GetUserInfoByPID(currentBlacklistPrincipal.PrincipalBasicInfo.PID)
|
||||
|
||||
if userInfo == nil {
|
||||
rmcResponse := nex.NewRMCResponse(nexproto.FriendsWiiUProtocolID, callID)
|
||||
rmcResponse := nex.NewRMCResponse(friends_wiiu.ProtocolID, callID)
|
||||
rmcResponse.SetError(nex.Errors.FPD.FriendNotExists) // TODO: Not sure if this is the correct error.
|
||||
|
||||
rmcResponseBytes := rmcResponse.Bytes()
|
||||
|
@ -55,8 +55,8 @@ func AddBlacklist(err error, client *nex.Client, callID uint32, blacklistPrincip
|
|||
rmcResponseBody := rmcResponseStream.Bytes()
|
||||
|
||||
// Build response packet
|
||||
rmcResponse := nex.NewRMCResponse(nexproto.FriendsWiiUProtocolID, callID)
|
||||
rmcResponse.SetSuccess(nexproto.FriendsWiiUMethodAddBlackList, rmcResponseBody)
|
||||
rmcResponse := nex.NewRMCResponse(friends_wiiu.ProtocolID, callID)
|
||||
rmcResponse.SetSuccess(friends_wiiu.MethodAddBlackList, rmcResponseBody)
|
||||
|
||||
rmcResponseBytes := rmcResponse.Bytes()
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package friends_wiiu
|
||||
package nex_friends_wiiu
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
@ -8,10 +8,10 @@ import (
|
|||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
notifications_wiiu "github.com/PretendoNetwork/friends-secure/notifications/wiiu"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
)
|
||||
|
||||
func AddFriendRequest(err error, client *nex.Client, callID uint32, pid uint32, unknown2 uint8, message string, unknown4 uint8, unknown5 string, gameKey *nexproto.GameKey, unknown6 *nex.DateTime) {
|
||||
func AddFriendRequest(err error, client *nex.Client, callID uint32, pid uint32, unknown2 uint8, message string, unknown4 uint8, unknown5 string, gameKey *friends_wiiu.GameKey, unknown6 *nex.DateTime) {
|
||||
senderPID := client.PID()
|
||||
recipientPID := pid
|
||||
|
||||
|
@ -19,7 +19,7 @@ func AddFriendRequest(err error, client *nex.Client, callID uint32, pid uint32,
|
|||
if recipient == nil {
|
||||
globals.Logger.Error(fmt.Sprintf("User %d has sent friend request to invalid PID %d", senderPID, pid))
|
||||
|
||||
rmcResponse := nex.NewRMCResponse(nexproto.FriendsWiiUProtocolID, callID)
|
||||
rmcResponse := nex.NewRMCResponse(friends_wiiu.ProtocolID, callID)
|
||||
rmcResponse.SetError(nex.Errors.FPD.InvalidPrincipalID) // TODO - Is this the right error?
|
||||
|
||||
rmcResponseBytes := rmcResponse.Bytes()
|
||||
|
@ -51,11 +51,11 @@ func AddFriendRequest(err error, client *nex.Client, callID uint32, pid uint32,
|
|||
|
||||
friendRequestID := database_wiiu.SaveFriendRequest(senderPID, recipientPID, sentTime.Value(), expireTime.Value(), message)
|
||||
|
||||
friendRequest := nexproto.NewFriendRequest()
|
||||
friendRequest := friends_wiiu.NewFriendRequest()
|
||||
|
||||
friendRequest.PrincipalInfo = database_wiiu.GetUserInfoByPID(recipientPID)
|
||||
|
||||
friendRequest.Message = nexproto.NewFriendRequestMessage()
|
||||
friendRequest.Message = friends_wiiu.NewFriendRequestMessage()
|
||||
friendRequest.Message.FriendRequestID = friendRequestID
|
||||
friendRequest.Message.Received = false
|
||||
friendRequest.Message.Unknown2 = 1 // replaying from real
|
||||
|
@ -68,13 +68,13 @@ func AddFriendRequest(err error, client *nex.Client, callID uint32, pid uint32,
|
|||
friendRequest.SentOn = sentTime
|
||||
|
||||
// Why does this exist?? Always empty??
|
||||
friendInfo := nexproto.NewFriendInfo()
|
||||
friendInfo := friends_wiiu.NewFriendInfo()
|
||||
|
||||
friendInfo.NNAInfo = nexproto.NewNNAInfo()
|
||||
friendInfo.NNAInfo.PrincipalBasicInfo = nexproto.NewPrincipalBasicInfo()
|
||||
friendInfo.NNAInfo = friends_wiiu.NewNNAInfo()
|
||||
friendInfo.NNAInfo.PrincipalBasicInfo = friends_wiiu.NewPrincipalBasicInfo()
|
||||
friendInfo.NNAInfo.PrincipalBasicInfo.PID = 0
|
||||
friendInfo.NNAInfo.PrincipalBasicInfo.NNID = ""
|
||||
friendInfo.NNAInfo.PrincipalBasicInfo.Mii = nexproto.NewMiiV2()
|
||||
friendInfo.NNAInfo.PrincipalBasicInfo.Mii = friends_wiiu.NewMiiV2()
|
||||
friendInfo.NNAInfo.PrincipalBasicInfo.Mii.Name = ""
|
||||
friendInfo.NNAInfo.PrincipalBasicInfo.Mii.Unknown1 = 0
|
||||
friendInfo.NNAInfo.PrincipalBasicInfo.Mii.Unknown2 = 0
|
||||
|
@ -84,7 +84,7 @@ func AddFriendRequest(err error, client *nex.Client, callID uint32, pid uint32,
|
|||
friendInfo.NNAInfo.Unknown1 = 0
|
||||
friendInfo.NNAInfo.Unknown2 = 0
|
||||
|
||||
friendInfo.Presence = nexproto.NewNintendoPresenceV2()
|
||||
friendInfo.Presence = friends_wiiu.NewNintendoPresenceV2()
|
||||
friendInfo.Presence.ChangedFlags = 0
|
||||
friendInfo.Presence.Online = false
|
||||
friendInfo.Presence.GameKey = gameKey // maybe this is reused?
|
||||
|
@ -101,7 +101,7 @@ func AddFriendRequest(err error, client *nex.Client, callID uint32, pid uint32,
|
|||
friendInfo.Presence.Unknown6 = 0
|
||||
friendInfo.Presence.Unknown7 = 0
|
||||
|
||||
friendInfo.Status = nexproto.NewComment()
|
||||
friendInfo.Status = friends_wiiu.NewComment()
|
||||
friendInfo.Status.Unknown = 0
|
||||
friendInfo.Status.Contents = ""
|
||||
friendInfo.Status.LastChanged = nex.NewDateTime(0)
|
||||
|
@ -114,11 +114,11 @@ func AddFriendRequest(err error, client *nex.Client, callID uint32, pid uint32,
|
|||
|
||||
if recipientClient != nil {
|
||||
|
||||
friendRequestNotificationData := nexproto.NewFriendRequest()
|
||||
friendRequestNotificationData := friends_wiiu.NewFriendRequest()
|
||||
|
||||
friendRequestNotificationData.PrincipalInfo = database_wiiu.GetUserInfoByPID(senderPID)
|
||||
|
||||
friendRequestNotificationData.Message = nexproto.NewFriendRequestMessage()
|
||||
friendRequestNotificationData.Message = friends_wiiu.NewFriendRequestMessage()
|
||||
friendRequestNotificationData.Message.FriendRequestID = friendRequestID
|
||||
friendRequestNotificationData.Message.Received = false
|
||||
friendRequestNotificationData.Message.Unknown2 = 1 // replaying from real
|
||||
|
@ -141,8 +141,8 @@ func AddFriendRequest(err error, client *nex.Client, callID uint32, pid uint32,
|
|||
rmcResponseBody := rmcResponseStream.Bytes()
|
||||
|
||||
// Build response packet
|
||||
rmcResponse := nex.NewRMCResponse(nexproto.FriendsWiiUProtocolID, callID)
|
||||
rmcResponse.SetSuccess(nexproto.FriendsWiiUMethodAddFriendRequest, rmcResponseBody)
|
||||
rmcResponse := nex.NewRMCResponse(friends_wiiu.ProtocolID, callID)
|
||||
rmcResponse.SetSuccess(friends_wiiu.MethodAddFriendRequest, rmcResponseBody)
|
||||
|
||||
rmcResponseBytes := rmcResponse.Bytes()
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
package friends_wiiu
|
||||
package nex_friends_wiiu
|
||||
|
||||
import (
|
||||
database_wiiu "github.com/PretendoNetwork/friends-secure/database/wiiu"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
notifications_wiiu "github.com/PretendoNetwork/friends-secure/notifications/wiiu"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
)
|
||||
|
||||
func CancelFriendRequest(err error, client *nex.Client, callID uint32, id uint64) {
|
||||
|
@ -17,8 +17,8 @@ func CancelFriendRequest(err error, client *nex.Client, callID uint32, id uint64
|
|||
go notifications_wiiu.SendFriendshipRemoved(connectedUser.Client, client.PID())
|
||||
}
|
||||
|
||||
rmcResponse := nex.NewRMCResponse(nexproto.FriendsWiiUProtocolID, callID)
|
||||
rmcResponse.SetSuccess(nexproto.FriendsWiiUMethodCancelFriendRequest, nil)
|
||||
rmcResponse := nex.NewRMCResponse(friends_wiiu.ProtocolID, callID)
|
||||
rmcResponse.SetSuccess(friends_wiiu.MethodCancelFriendRequest, nil)
|
||||
|
||||
rmcResponseBytes := rmcResponse.Bytes()
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
package friends_wiiu
|
||||
package nex_friends_wiiu
|
||||
|
||||
import (
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
)
|
||||
|
||||
func CheckSettingStatus(err error, client *nex.Client, callID uint32) {
|
||||
|
@ -14,8 +14,8 @@ func CheckSettingStatus(err error, client *nex.Client, callID uint32) {
|
|||
rmcResponseBody := rmcResponseStream.Bytes()
|
||||
|
||||
// Build response packet
|
||||
rmcResponse := nex.NewRMCResponse(nexproto.FriendsWiiUProtocolID, callID)
|
||||
rmcResponse.SetSuccess(nexproto.FriendsWiiUMethodCheckSettingStatus, rmcResponseBody)
|
||||
rmcResponse := nex.NewRMCResponse(friends_wiiu.ProtocolID, callID)
|
||||
rmcResponse.SetSuccess(friends_wiiu.MethodCheckSettingStatus, rmcResponseBody)
|
||||
|
||||
rmcResponseBytes := rmcResponse.Bytes()
|
||||
|
|
@ -1,17 +1,17 @@
|
|||
package friends_wiiu
|
||||
package nex_friends_wiiu
|
||||
|
||||
import (
|
||||
database_wiiu "github.com/PretendoNetwork/friends-secure/database/wiiu"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
)
|
||||
|
||||
func DeleteFriendRequest(err error, client *nex.Client, callID uint32, id uint64) {
|
||||
database_wiiu.SetFriendRequestDenied(id)
|
||||
|
||||
rmcResponse := nex.NewRMCResponse(nexproto.FriendsWiiUProtocolID, callID)
|
||||
rmcResponse.SetSuccess(nexproto.FriendsWiiUMethodDeleteFriendRequest, nil)
|
||||
rmcResponse := nex.NewRMCResponse(friends_wiiu.ProtocolID, callID)
|
||||
rmcResponse.SetSuccess(friends_wiiu.MethodDeleteFriendRequest, nil)
|
||||
|
||||
rmcResponseBytes := rmcResponse.Bytes()
|
||||
|
|
@ -1,16 +1,16 @@
|
|||
package friends_wiiu
|
||||
package nex_friends_wiiu
|
||||
|
||||
import (
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
)
|
||||
|
||||
func DeletePersistentNotification(err error, client *nex.Client, callID uint32, notifications []*nexproto.PersistentNotification) {
|
||||
func DeletePersistentNotification(err error, client *nex.Client, callID uint32, notifications []*friends_wiiu.PersistentNotification) {
|
||||
// TODO: Do something here
|
||||
|
||||
rmcResponse := nex.NewRMCResponse(nexproto.FriendsWiiUProtocolID, callID)
|
||||
rmcResponse.SetSuccess(nexproto.FriendsWiiUMethodDeletePersistentNotification, nil)
|
||||
rmcResponse := nex.NewRMCResponse(friends_wiiu.ProtocolID, callID)
|
||||
rmcResponse.SetSuccess(friends_wiiu.MethodDeletePersistentNotification, nil)
|
||||
|
||||
rmcResponseBytes := rmcResponse.Bytes()
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package friends_wiiu
|
||||
package nex_friends_wiiu
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
@ -6,7 +6,7 @@ import (
|
|||
database_wiiu "github.com/PretendoNetwork/friends-secure/database/wiiu"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
)
|
||||
|
||||
func DenyFriendRequest(err error, client *nex.Client, callID uint32, id uint64) {
|
||||
|
@ -21,10 +21,10 @@ func DenyFriendRequest(err error, client *nex.Client, callID uint32, id uint64)
|
|||
date.FromTimestamp(time.Now())
|
||||
|
||||
// Create a new blacklist principal for the client, as unlike AddBlacklist they don't send one to us.
|
||||
blacklistPrincipal := nexproto.NewBlacklistedPrincipal()
|
||||
blacklistPrincipal := friends_wiiu.NewBlacklistedPrincipal()
|
||||
|
||||
blacklistPrincipal.PrincipalBasicInfo = info
|
||||
blacklistPrincipal.GameKey = nexproto.NewGameKey()
|
||||
blacklistPrincipal.GameKey = friends_wiiu.NewGameKey()
|
||||
blacklistPrincipal.BlackListedSince = date
|
||||
|
||||
rmcResponseStream := nex.NewStreamOut(globals.NEXServer)
|
||||
|
@ -34,8 +34,8 @@ func DenyFriendRequest(err error, client *nex.Client, callID uint32, id uint64)
|
|||
rmcResponseBody := rmcResponseStream.Bytes()
|
||||
|
||||
// Build response packet
|
||||
rmcResponse := nex.NewRMCResponse(nexproto.FriendsWiiUProtocolID, callID)
|
||||
rmcResponse.SetSuccess(nexproto.FriendsWiiUMethodDenyFriendRequest, rmcResponseBody)
|
||||
rmcResponse := nex.NewRMCResponse(friends_wiiu.ProtocolID, callID)
|
||||
rmcResponse.SetSuccess(friends_wiiu.MethodDenyFriendRequest, rmcResponseBody)
|
||||
|
||||
rmcResponseBytes := rmcResponse.Bytes()
|
||||
|
|
@ -1,14 +1,14 @@
|
|||
package friends_wiiu
|
||||
package nex_friends_wiiu
|
||||
|
||||
import (
|
||||
database_wiiu "github.com/PretendoNetwork/friends-secure/database/wiiu"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
)
|
||||
|
||||
func GetBasicInfo(err error, client *nex.Client, callID uint32, pids []uint32) {
|
||||
infos := make([]*nexproto.PrincipalBasicInfo, 0)
|
||||
infos := make([]*friends_wiiu.PrincipalBasicInfo, 0)
|
||||
|
||||
for i := 0; i < len(pids); i++ {
|
||||
pid := pids[i]
|
||||
|
@ -26,8 +26,8 @@ func GetBasicInfo(err error, client *nex.Client, callID uint32, pids []uint32) {
|
|||
rmcResponseBody := rmcResponseStream.Bytes()
|
||||
|
||||
// Build response packet
|
||||
rmcResponse := nex.NewRMCResponse(nexproto.FriendsWiiUProtocolID, callID)
|
||||
rmcResponse.SetSuccess(nexproto.FriendsWiiUMethodGetBasicInfo, rmcResponseBody)
|
||||
rmcResponse := nex.NewRMCResponse(friends_wiiu.ProtocolID, callID)
|
||||
rmcResponse.SetSuccess(friends_wiiu.MethodGetBasicInfo, rmcResponseBody)
|
||||
|
||||
rmcResponseBytes := rmcResponse.Bytes()
|
||||
|
|
@ -1,21 +1,21 @@
|
|||
package friends_wiiu
|
||||
package nex_friends_wiiu
|
||||
|
||||
import (
|
||||
database_wiiu "github.com/PretendoNetwork/friends-secure/database/wiiu"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
)
|
||||
|
||||
func GetRequestBlockSettings(err error, client *nex.Client, callID uint32, pids []uint32) {
|
||||
settings := make([]*nexproto.PrincipalRequestBlockSetting, 0)
|
||||
settings := make([]*friends_wiiu.PrincipalRequestBlockSetting, 0)
|
||||
|
||||
// TODO:
|
||||
// Improve this. Use less database_wiiu.reads
|
||||
for i := 0; i < len(pids); i++ {
|
||||
requestedPID := pids[i]
|
||||
|
||||
setting := nexproto.NewPrincipalRequestBlockSetting()
|
||||
setting := friends_wiiu.NewPrincipalRequestBlockSetting()
|
||||
setting.PID = requestedPID
|
||||
setting.IsBlocked = database_wiiu.IsFriendRequestBlocked(client.PID(), requestedPID)
|
||||
|
||||
|
@ -29,8 +29,8 @@ func GetRequestBlockSettings(err error, client *nex.Client, callID uint32, pids
|
|||
rmcResponseBody := rmcResponseStream.Bytes()
|
||||
|
||||
// Build response packet
|
||||
rmcResponse := nex.NewRMCResponse(nexproto.FriendsWiiUProtocolID, callID)
|
||||
rmcResponse.SetSuccess(nexproto.FriendsWiiUMethodGetRequestBlockSettings, rmcResponseBody)
|
||||
rmcResponse := nex.NewRMCResponse(friends_wiiu.ProtocolID, callID)
|
||||
rmcResponse.SetSuccess(friends_wiiu.MethodGetRequestBlockSettings, rmcResponseBody)
|
||||
|
||||
rmcResponseBytes := rmcResponse.Bytes()
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
package friends_wiiu
|
||||
package nex_friends_wiiu
|
||||
|
||||
import (
|
||||
database_wiiu "github.com/PretendoNetwork/friends-secure/database/wiiu"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
)
|
||||
|
||||
func MarkFriendRequestsAsReceived(err error, client *nex.Client, callID uint32, ids []uint64) {
|
||||
|
@ -13,8 +13,8 @@ func MarkFriendRequestsAsReceived(err error, client *nex.Client, callID uint32,
|
|||
database_wiiu.SetFriendRequestReceived(id)
|
||||
}
|
||||
|
||||
rmcResponse := nex.NewRMCResponse(nexproto.FriendsWiiUProtocolID, callID)
|
||||
rmcResponse.SetSuccess(nexproto.FriendsWiiUMethodMarkFriendRequestsAsReceived, nil)
|
||||
rmcResponse := nex.NewRMCResponse(friends_wiiu.ProtocolID, callID)
|
||||
rmcResponse.SetSuccess(friends_wiiu.MethodMarkFriendRequestsAsReceived, nil)
|
||||
|
||||
rmcResponseBytes := rmcResponse.Bytes()
|
||||
|
|
@ -1,17 +1,17 @@
|
|||
package friends_wiiu
|
||||
package nex_friends_wiiu
|
||||
|
||||
import (
|
||||
database_wiiu "github.com/PretendoNetwork/friends-secure/database/wiiu"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
)
|
||||
|
||||
func RemoveBlacklist(err error, client *nex.Client, callID uint32, blockedPID uint32) {
|
||||
database_wiiu.UnsetUserBlocked(client.PID(), blockedPID)
|
||||
|
||||
rmcResponse := nex.NewRMCResponse(nexproto.FriendsWiiUProtocolID, callID)
|
||||
rmcResponse.SetSuccess(nexproto.FriendsWiiUMethodRemoveBlackList, nil)
|
||||
rmcResponse := nex.NewRMCResponse(friends_wiiu.ProtocolID, callID)
|
||||
rmcResponse.SetSuccess(friends_wiiu.MethodRemoveBlackList, nil)
|
||||
|
||||
rmcResponseBytes := rmcResponse.Bytes()
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
package friends_wiiu
|
||||
package nex_friends_wiiu
|
||||
|
||||
import (
|
||||
database_wiiu "github.com/PretendoNetwork/friends-secure/database/wiiu"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
notifications_wiiu "github.com/PretendoNetwork/friends-secure/notifications/wiiu"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
)
|
||||
|
||||
func RemoveFriend(err error, client *nex.Client, callID uint32, pid uint32) {
|
||||
|
@ -16,8 +16,8 @@ func RemoveFriend(err error, client *nex.Client, callID uint32, pid uint32) {
|
|||
|
||||
database_wiiu.RemoveFriendship(client.PID(), pid)
|
||||
|
||||
rmcResponse := nex.NewRMCResponse(nexproto.FriendsWiiUProtocolID, callID)
|
||||
rmcResponse.SetSuccess(nexproto.FriendsWiiUMethodRemoveFriend, nil)
|
||||
rmcResponse := nex.NewRMCResponse(friends_wiiu.ProtocolID, callID)
|
||||
rmcResponse.SetSuccess(friends_wiiu.MethodRemoveFriend, nil)
|
||||
|
||||
rmcResponseBytes := rmcResponse.Bytes()
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package friends_wiiu
|
||||
package nex_friends_wiiu
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
@ -7,10 +7,10 @@ import (
|
|||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
notifications_wiiu "github.com/PretendoNetwork/friends-secure/notifications/wiiu"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
)
|
||||
|
||||
func UpdateAndGetAllInformation(err error, client *nex.Client, callID uint32, nnaInfo *nexproto.NNAInfo, presence *nexproto.NintendoPresenceV2, birthday *nex.DateTime) {
|
||||
func UpdateAndGetAllInformation(err error, client *nex.Client, callID uint32, nnaInfo *friends_wiiu.NNAInfo, presence *friends_wiiu.NintendoPresenceV2, birthday *nex.DateTime) {
|
||||
|
||||
if err != nil {
|
||||
// TODO: Handle error
|
||||
|
@ -39,22 +39,22 @@ func UpdateAndGetAllInformation(err error, client *nex.Client, callID uint32, nn
|
|||
notifications := database_wiiu.GetUserNotifications(pid)
|
||||
|
||||
if os.Getenv("ENABLE_BELLA") == "true" {
|
||||
bella := nexproto.NewFriendInfo()
|
||||
bella := friends_wiiu.NewFriendInfo()
|
||||
|
||||
bella.NNAInfo = nexproto.NewNNAInfo()
|
||||
bella.Presence = nexproto.NewNintendoPresenceV2()
|
||||
bella.Status = nexproto.NewComment()
|
||||
bella.NNAInfo = friends_wiiu.NewNNAInfo()
|
||||
bella.Presence = friends_wiiu.NewNintendoPresenceV2()
|
||||
bella.Status = friends_wiiu.NewComment()
|
||||
bella.BecameFriend = nex.NewDateTime(0)
|
||||
bella.LastOnline = nex.NewDateTime(0)
|
||||
bella.Unknown = 0
|
||||
|
||||
bella.NNAInfo.PrincipalBasicInfo = nexproto.NewPrincipalBasicInfo()
|
||||
bella.NNAInfo.PrincipalBasicInfo = friends_wiiu.NewPrincipalBasicInfo()
|
||||
bella.NNAInfo.Unknown1 = 0
|
||||
bella.NNAInfo.Unknown2 = 0
|
||||
|
||||
bella.NNAInfo.PrincipalBasicInfo.PID = 1743126339
|
||||
bella.NNAInfo.PrincipalBasicInfo.NNID = "bells1998"
|
||||
bella.NNAInfo.PrincipalBasicInfo.Mii = nexproto.NewMiiV2()
|
||||
bella.NNAInfo.PrincipalBasicInfo.Mii = friends_wiiu.NewMiiV2()
|
||||
bella.NNAInfo.PrincipalBasicInfo.Unknown = 0
|
||||
|
||||
bella.NNAInfo.PrincipalBasicInfo.Mii.Name = "bella"
|
||||
|
@ -78,7 +78,7 @@ func UpdateAndGetAllInformation(err error, client *nex.Client, callID uint32, nn
|
|||
|
||||
bella.Presence.ChangedFlags = 0x1EE
|
||||
bella.Presence.Online = true
|
||||
bella.Presence.GameKey = nexproto.NewGameKey()
|
||||
bella.Presence.GameKey = friends_wiiu.NewGameKey()
|
||||
bella.Presence.Unknown1 = 0
|
||||
bella.Presence.Message = "Testing"
|
||||
//bella.Presence.Unknown2 = 2
|
||||
|
@ -127,8 +127,8 @@ func UpdateAndGetAllInformation(err error, client *nex.Client, callID uint32, nn
|
|||
rmcResponseBody := rmcResponseStream.Bytes()
|
||||
|
||||
// Build response packet
|
||||
rmcResponse := nex.NewRMCResponse(nexproto.FriendsWiiUProtocolID, callID)
|
||||
rmcResponse.SetSuccess(nexproto.FriendsWiiUMethodUpdateAndGetAllInformation, rmcResponseBody)
|
||||
rmcResponse := nex.NewRMCResponse(friends_wiiu.ProtocolID, callID)
|
||||
rmcResponse.SetSuccess(friends_wiiu.MethodUpdateAndGetAllInformation, rmcResponseBody)
|
||||
|
||||
rmcResponseBytes := rmcResponse.Bytes()
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
package friends_wiiu
|
||||
package nex_friends_wiiu
|
||||
|
||||
import (
|
||||
database_wiiu "github.com/PretendoNetwork/friends-secure/database/wiiu"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
)
|
||||
|
||||
func UpdateComment(err error, client *nex.Client, callID uint32, comment *nexproto.Comment) {
|
||||
func UpdateComment(err error, client *nex.Client, callID uint32, comment *friends_wiiu.Comment) {
|
||||
// TODO: Do something with this
|
||||
|
||||
changed := database_wiiu.UpdateUserComment(client.PID(), comment.Contents)
|
||||
|
@ -18,8 +18,8 @@ func UpdateComment(err error, client *nex.Client, callID uint32, comment *nexpro
|
|||
|
||||
rmcResponseBody := rmcResponseStream.Bytes()
|
||||
|
||||
rmcResponse := nex.NewRMCResponse(nexproto.FriendsWiiUProtocolID, callID)
|
||||
rmcResponse.SetSuccess(nexproto.FriendsWiiUMethodUpdateComment, rmcResponseBody)
|
||||
rmcResponse := nex.NewRMCResponse(friends_wiiu.ProtocolID, callID)
|
||||
rmcResponse.SetSuccess(friends_wiiu.MethodUpdateComment, rmcResponseBody)
|
||||
|
||||
rmcResponseBytes := rmcResponse.Bytes()
|
||||
|
|
@ -1,17 +1,17 @@
|
|||
package friends_wiiu
|
||||
package nex_friends_wiiu
|
||||
|
||||
import (
|
||||
database_wiiu "github.com/PretendoNetwork/friends-secure/database/wiiu"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
)
|
||||
|
||||
func UpdatePreference(err error, client *nex.Client, callID uint32, principalPreference *nexproto.PrincipalPreference) {
|
||||
func UpdatePreference(err error, client *nex.Client, callID uint32, principalPreference *friends_wiiu.PrincipalPreference) {
|
||||
database_wiiu.UpdateUserPrincipalPreference(client.PID(), principalPreference)
|
||||
|
||||
rmcResponse := nex.NewRMCResponse(nexproto.FriendsWiiUProtocolID, callID)
|
||||
rmcResponse.SetSuccess(nexproto.FriendsWiiUMethodUpdatePreference, nil)
|
||||
rmcResponse := nex.NewRMCResponse(friends_wiiu.ProtocolID, callID)
|
||||
rmcResponse.SetSuccess(friends_wiiu.MethodUpdatePreference, nil)
|
||||
|
||||
rmcResponseBytes := rmcResponse.Bytes()
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
package friends_wiiu
|
||||
package nex_friends_wiiu
|
||||
|
||||
import (
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
notifications_wiiu "github.com/PretendoNetwork/friends-secure/notifications/wiiu"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
)
|
||||
|
||||
func UpdatePresence(err error, client *nex.Client, callID uint32, presence *nexproto.NintendoPresenceV2) {
|
||||
func UpdatePresence(err error, client *nex.Client, callID uint32, presence *friends_wiiu.NintendoPresenceV2) {
|
||||
pid := client.PID()
|
||||
|
||||
presence.Online = true // Force online status. I have no idea why this is always false
|
||||
|
@ -16,8 +16,8 @@ func UpdatePresence(err error, client *nex.Client, callID uint32, presence *nexp
|
|||
globals.ConnectedUsers[pid].PresenceV2 = presence
|
||||
notifications_wiiu.SendPresenceUpdate(presence)
|
||||
|
||||
rmcResponse := nex.NewRMCResponse(nexproto.FriendsWiiUProtocolID, callID)
|
||||
rmcResponse.SetSuccess(nexproto.FriendsWiiUMethodUpdatePresence, nil)
|
||||
rmcResponse := nex.NewRMCResponse(friends_wiiu.ProtocolID, callID)
|
||||
rmcResponse.SetSuccess(friends_wiiu.MethodUpdatePresence, nil)
|
||||
|
||||
rmcResponseBytes := rmcResponse.Bytes()
|
||||
|
63
nex/register_nex_protocols.go
Normal file
63
nex/register_nex_protocols.go
Normal file
|
@ -0,0 +1,63 @@
|
|||
package nex
|
||||
|
||||
import (
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nex_account_management "github.com/PretendoNetwork/friends-secure/nex/account-management"
|
||||
nex_friends_3ds "github.com/PretendoNetwork/friends-secure/nex/friends-3ds"
|
||||
nex_friends_wiiu "github.com/PretendoNetwork/friends-secure/nex/friends-wiiu"
|
||||
nex_secure_connection "github.com/PretendoNetwork/friends-secure/nex/secure-connection"
|
||||
account_management "github.com/PretendoNetwork/nex-protocols-go/account-management"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends/3ds"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
secure_connection "github.com/PretendoNetwork/nex-protocols-go/secure-connection"
|
||||
)
|
||||
|
||||
func registerNEXProtocols() {
|
||||
secureConnectionProtocol := secure_connection.NewSecureConnectionProtocol(globals.NEXServer)
|
||||
accountManagementProtocol := account_management.NewAccountManagementProtocol(globals.NEXServer)
|
||||
friendsWiiUProtocol := friends_wiiu.NewFriendsWiiUProtocol(globals.NEXServer)
|
||||
friends3DSProtocol := friends_3ds.NewFriends3DSProtocol(globals.NEXServer)
|
||||
|
||||
// Account Management protocol handles
|
||||
accountManagementProtocol.NintendoCreateAccount(nex_account_management.NintendoCreateAccount)
|
||||
|
||||
// Secure protocol handles
|
||||
secureConnectionProtocol.Register(nex_secure_connection.Register)
|
||||
secureConnectionProtocol.RegisterEx(nex_secure_connection.RegisterEx)
|
||||
|
||||
// Friends (WiiU) protocol handles
|
||||
friendsWiiUProtocol.UpdateAndGetAllInformation(nex_friends_wiiu.UpdateAndGetAllInformation)
|
||||
friendsWiiUProtocol.AddFriendRequest(nex_friends_wiiu.AddFriendRequest)
|
||||
friendsWiiUProtocol.RemoveFriend(nex_friends_wiiu.RemoveFriend)
|
||||
friendsWiiUProtocol.CancelFriendRequest(nex_friends_wiiu.CancelFriendRequest)
|
||||
friendsWiiUProtocol.AcceptFriendRequest(nex_friends_wiiu.AcceptFriendRequest)
|
||||
friendsWiiUProtocol.DeleteFriendRequest(nex_friends_wiiu.DeleteFriendRequest)
|
||||
friendsWiiUProtocol.DenyFriendRequest(nex_friends_wiiu.DenyFriendRequest)
|
||||
friendsWiiUProtocol.MarkFriendRequestsAsReceived(nex_friends_wiiu.MarkFriendRequestsAsReceived)
|
||||
friendsWiiUProtocol.AddBlackList(nex_friends_wiiu.AddBlacklist)
|
||||
friendsWiiUProtocol.RemoveBlackList(nex_friends_wiiu.RemoveBlacklist)
|
||||
friendsWiiUProtocol.UpdatePresence(nex_friends_wiiu.UpdatePresence)
|
||||
friendsWiiUProtocol.UpdateComment(nex_friends_wiiu.UpdateComment)
|
||||
friendsWiiUProtocol.UpdatePreference(nex_friends_wiiu.UpdatePreference)
|
||||
friendsWiiUProtocol.GetBasicInfo(nex_friends_wiiu.GetBasicInfo)
|
||||
friendsWiiUProtocol.DeletePersistentNotification(nex_friends_wiiu.DeletePersistentNotification)
|
||||
friendsWiiUProtocol.CheckSettingStatus(nex_friends_wiiu.CheckSettingStatus)
|
||||
friendsWiiUProtocol.GetRequestBlockSettings(nex_friends_wiiu.GetRequestBlockSettings)
|
||||
|
||||
// Friends (3DS) protocol handles
|
||||
friends3DSProtocol.UpdateProfile(nex_friends_3ds.UpdateProfile)
|
||||
friends3DSProtocol.UpdateMii(nex_friends_3ds.UpdateMii)
|
||||
friends3DSProtocol.UpdatePreference(nex_friends_3ds.UpdatePreference)
|
||||
friends3DSProtocol.SyncFriend(nex_friends_3ds.SyncFriend)
|
||||
friends3DSProtocol.UpdatePresence(nex_friends_3ds.UpdatePresence)
|
||||
friends3DSProtocol.UpdateFavoriteGameKey(nex_friends_3ds.UpdateFavoriteGameKey)
|
||||
friends3DSProtocol.UpdateComment(nex_friends_3ds.UpdateComment)
|
||||
friends3DSProtocol.AddFriendByPrincipalID(nex_friends_3ds.AddFriendshipByPrincipalID)
|
||||
friends3DSProtocol.GetFriendPersistentInfo(nex_friends_3ds.GetFriendPersistentInfo)
|
||||
friends3DSProtocol.GetFriendMii(nex_friends_3ds.GetFriendMii)
|
||||
friends3DSProtocol.GetFriendPresence(nex_friends_3ds.GetFriendPresence)
|
||||
friends3DSProtocol.RemoveFriendByPrincipalID(nex_friends_3ds.RemoveFriendByPrincipalID)
|
||||
friends3DSProtocol.RemoveFriendByLocalFriendCode(nex_friends_3ds.RemoveFriendByLocalFriendCode)
|
||||
friends3DSProtocol.GetPrincipalIDByLocalFriendCode(nex_friends_3ds.GetPrincipalIDByLocalFriendCode)
|
||||
friends3DSProtocol.GetAllFriends(nex_friends_3ds.GetAllFriends)
|
||||
}
|
|
@ -1,14 +1,14 @@
|
|||
package main
|
||||
package nex_secure_connection
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
secure_connection "github.com/PretendoNetwork/nex-protocols-go/secure-connection"
|
||||
)
|
||||
|
||||
func register(err error, client *nex.Client, callID uint32, stationUrls []*nex.StationURL) {
|
||||
func Register(err error, client *nex.Client, callID uint32, stationUrls []*nex.StationURL) {
|
||||
localStation := stationUrls[0]
|
||||
|
||||
address := client.Address().IP.String()
|
||||
|
@ -28,8 +28,8 @@ func register(err error, client *nex.Client, callID uint32, stationUrls []*nex.S
|
|||
rmcResponseBody := rmcResponseStream.Bytes()
|
||||
|
||||
// Build response packet
|
||||
rmcResponse := nex.NewRMCResponse(nexproto.SecureProtocolID, callID)
|
||||
rmcResponse.SetSuccess(nexproto.SecureMethodRegister, rmcResponseBody)
|
||||
rmcResponse := nex.NewRMCResponse(secure_connection.ProtocolID, callID)
|
||||
rmcResponse.SetSuccess(secure_connection.MethodRegister, rmcResponseBody)
|
||||
|
||||
rmcResponseBytes := rmcResponse.Bytes()
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package nex_secure_connection
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
@ -7,11 +7,12 @@ import (
|
|||
database_3ds "github.com/PretendoNetwork/friends-secure/database/3ds"
|
||||
database_wiiu "github.com/PretendoNetwork/friends-secure/database/wiiu"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
"github.com/PretendoNetwork/friends-secure/types"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
secure_connection "github.com/PretendoNetwork/nex-protocols-go/secure-connection"
|
||||
)
|
||||
|
||||
func registerEx(err error, client *nex.Client, callID uint32, stationUrls []*nex.StationURL, loginData *nex.DataHolder) {
|
||||
func RegisterEx(err error, client *nex.Client, callID uint32, stationUrls []*nex.StationURL, loginData *nex.DataHolder) {
|
||||
// TODO: Validate loginData
|
||||
|
||||
pid := client.PID()
|
||||
|
@ -20,11 +21,11 @@ func registerEx(err error, client *nex.Client, callID uint32, stationUrls []*nex
|
|||
lastOnline.FromTimestamp(time.Now())
|
||||
|
||||
if loginData.TypeName() == "NintendoLoginData" {
|
||||
user.Platform = globals.WUP // Platform is Wii U
|
||||
user.Platform = types.WUP // Platform is Wii U
|
||||
|
||||
database_wiiu.UpdateUserLastOnlineTime(pid, lastOnline)
|
||||
} else if loginData.TypeName() == "AccountExtraInfo" {
|
||||
user.Platform = globals.CTR // Platform is 3DS
|
||||
user.Platform = types.CTR // Platform is 3DS
|
||||
|
||||
database_3ds.UpdateUserLastOnlineTime(pid, lastOnline)
|
||||
}
|
||||
|
@ -48,8 +49,8 @@ func registerEx(err error, client *nex.Client, callID uint32, stationUrls []*nex
|
|||
rmcResponseBody := rmcResponseStream.Bytes()
|
||||
|
||||
// Build response packet
|
||||
rmcResponse := nex.NewRMCResponse(nexproto.SecureProtocolID, callID)
|
||||
rmcResponse.SetSuccess(nexproto.SecureMethodRegisterEx, rmcResponseBody)
|
||||
rmcResponse := nex.NewRMCResponse(secure_connection.ProtocolID, callID)
|
||||
rmcResponse.SetSuccess(secure_connection.MethodRegisterEx, rmcResponseBody)
|
||||
|
||||
rmcResponseBytes := rmcResponse.Bytes()
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package nex
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
@ -10,13 +10,14 @@ import (
|
|||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
notifications_3ds "github.com/PretendoNetwork/friends-secure/notifications/3ds"
|
||||
notifications_wiiu "github.com/PretendoNetwork/friends-secure/notifications/wiiu"
|
||||
"github.com/PretendoNetwork/friends-secure/types"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
)
|
||||
|
||||
func startNEXServer() {
|
||||
func StartNEXServer() {
|
||||
globals.NEXServer = nex.NewServer()
|
||||
globals.NEXServer.SetFragmentSize(900)
|
||||
globals.NEXServer.SetPrudpVersion(0)
|
||||
globals.NEXServer.SetPRUDPVersion(0)
|
||||
globals.NEXServer.SetKerberosKeySize(16)
|
||||
globals.NEXServer.SetKerberosPassword(os.Getenv("KERBEROS_PASSWORD"))
|
||||
globals.NEXServer.SetPingTimeout(20) // Maybe too long?
|
||||
|
@ -42,10 +43,10 @@ func startNEXServer() {
|
|||
lastOnline := nex.NewDateTime(0)
|
||||
lastOnline.FromTimestamp(time.Now())
|
||||
|
||||
if platform == globals.WUP {
|
||||
if platform == types.WUP {
|
||||
database_wiiu.UpdateUserLastOnlineTime(pid, lastOnline)
|
||||
notifications_wiiu.SendUserWentOfflineGlobally(packet.Sender())
|
||||
} else if platform == globals.CTR {
|
||||
} else if platform == types.CTR {
|
||||
database_3ds.UpdateUserLastOnlineTime(pid, lastOnline)
|
||||
notifications_3ds.SendUserWentOfflineGlobally(packet.Sender())
|
||||
}
|
||||
|
@ -60,7 +61,7 @@ func startNEXServer() {
|
|||
|
||||
globals.NEXServer.On("Connect", connect)
|
||||
|
||||
assignNEXProtocols()
|
||||
registerNEXProtocols()
|
||||
|
||||
globals.NEXServer.Listen(":60001")
|
||||
}
|
|
@ -4,14 +4,14 @@ import (
|
|||
database_3ds "github.com/PretendoNetwork/friends-secure/database/3ds"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
nintendo_notifications "github.com/PretendoNetwork/nex-protocols-go/nintendo-notifications"
|
||||
)
|
||||
|
||||
func SendCommentUpdate(client *nex.Client, comment string) {
|
||||
notificationEvent := nexproto.NewNintendoNotificationEventGeneral()
|
||||
notificationEvent := nintendo_notifications.NewNintendoNotificationEventGeneral()
|
||||
notificationEvent.StrParam = comment
|
||||
|
||||
eventObject := nexproto.NewNintendoNotificationEvent()
|
||||
eventObject := nintendo_notifications.NewNintendoNotificationEvent()
|
||||
eventObject.Type = 3
|
||||
eventObject.SenderPID = client.PID()
|
||||
eventObject.DataHolder = nex.NewDataHolder()
|
||||
|
@ -22,9 +22,9 @@ func SendCommentUpdate(client *nex.Client, comment string) {
|
|||
eventObjectBytes := eventObject.Bytes(stream)
|
||||
|
||||
rmcRequest := nex.NewRMCRequest()
|
||||
rmcRequest.SetProtocolID(nexproto.NintendoNotificationsProtocolID)
|
||||
rmcRequest.SetProtocolID(nintendo_notifications.ProtocolID)
|
||||
rmcRequest.SetCallID(3810693103)
|
||||
rmcRequest.SetMethodID(nexproto.NintendoNotificationsMethodProcessNintendoNotificationEvent1)
|
||||
rmcRequest.SetMethodID(nintendo_notifications.MethodProcessNintendoNotificationEvent1)
|
||||
rmcRequest.SetParameters(eventObjectBytes)
|
||||
|
||||
rmcRequestBytes := rmcRequest.Bytes()
|
||||
|
|
|
@ -4,11 +4,12 @@ import (
|
|||
database_3ds "github.com/PretendoNetwork/friends-secure/database/3ds"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends/3ds"
|
||||
nintendo_notifications "github.com/PretendoNetwork/nex-protocols-go/nintendo-notifications"
|
||||
)
|
||||
|
||||
func SendFavoriteUpdate(client *nex.Client, gameKey *nexproto.GameKey) {
|
||||
eventObject := nexproto.NewNintendoNotificationEvent()
|
||||
func SendFavoriteUpdate(client *nex.Client, gameKey *friends_3ds.GameKey) {
|
||||
eventObject := nintendo_notifications.NewNintendoNotificationEvent()
|
||||
eventObject.Type = 2
|
||||
eventObject.SenderPID = client.PID()
|
||||
eventObject.DataHolder = nex.NewDataHolder()
|
||||
|
@ -19,9 +20,9 @@ func SendFavoriteUpdate(client *nex.Client, gameKey *nexproto.GameKey) {
|
|||
eventObjectBytes := eventObject.Bytes(stream)
|
||||
|
||||
rmcRequest := nex.NewRMCRequest()
|
||||
rmcRequest.SetProtocolID(nexproto.NintendoNotificationsProtocolID)
|
||||
rmcRequest.SetProtocolID(nintendo_notifications.ProtocolID)
|
||||
rmcRequest.SetCallID(3810693103)
|
||||
rmcRequest.SetMethodID(nexproto.NintendoNotificationsMethodProcessNintendoNotificationEvent1)
|
||||
rmcRequest.SetMethodID(nintendo_notifications.MethodProcessNintendoNotificationEvent1)
|
||||
rmcRequest.SetParameters(eventObjectBytes)
|
||||
|
||||
rmcRequestBytes := rmcRequest.Bytes()
|
||||
|
|
|
@ -3,16 +3,16 @@ package notifications_3ds
|
|||
import (
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
nintendo_notifications "github.com/PretendoNetwork/nex-protocols-go/nintendo-notifications"
|
||||
)
|
||||
|
||||
func SendFriendshipCompleted(client *nex.Client, friendPID uint32, senderPID uint32) {
|
||||
notificationEvent := nexproto.NewNintendoNotificationEventGeneral()
|
||||
notificationEvent := nintendo_notifications.NewNintendoNotificationEventGeneral()
|
||||
notificationEvent.U32Param = 0
|
||||
notificationEvent.U64Param1 = 0
|
||||
notificationEvent.U64Param2 = uint64(friendPID)
|
||||
|
||||
eventObject := nexproto.NewNintendoNotificationEvent()
|
||||
eventObject := nintendo_notifications.NewNintendoNotificationEvent()
|
||||
eventObject.Type = 7
|
||||
eventObject.SenderPID = senderPID
|
||||
eventObject.DataHolder = nex.NewDataHolder()
|
||||
|
@ -23,9 +23,9 @@ func SendFriendshipCompleted(client *nex.Client, friendPID uint32, senderPID uin
|
|||
eventObjectBytes := eventObject.Bytes(stream)
|
||||
|
||||
rmcRequest := nex.NewRMCRequest()
|
||||
rmcRequest.SetProtocolID(nexproto.NintendoNotificationsProtocolID)
|
||||
rmcRequest.SetProtocolID(nintendo_notifications.ProtocolID)
|
||||
rmcRequest.SetCallID(3810693103)
|
||||
rmcRequest.SetMethodID(nexproto.NintendoNotificationsMethodProcessNintendoNotificationEvent1)
|
||||
rmcRequest.SetMethodID(nintendo_notifications.MethodProcessNintendoNotificationEvent1)
|
||||
rmcRequest.SetParameters(eventObjectBytes)
|
||||
|
||||
rmcRequestBytes := rmcRequest.Bytes()
|
||||
|
|
|
@ -4,13 +4,13 @@ import (
|
|||
database_3ds "github.com/PretendoNetwork/friends-secure/database/3ds"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
nintendo_notifications "github.com/PretendoNetwork/nex-protocols-go/nintendo-notifications"
|
||||
)
|
||||
|
||||
func SendMiiUpdateNotification(client *nex.Client) {
|
||||
notificationEvent := nexproto.NewNintendoNotificationEventGeneral()
|
||||
notificationEvent := nintendo_notifications.NewNintendoNotificationEventGeneral()
|
||||
|
||||
eventObject := nexproto.NewNintendoNotificationEvent()
|
||||
eventObject := nintendo_notifications.NewNintendoNotificationEvent()
|
||||
eventObject.Type = 5
|
||||
eventObject.SenderPID = client.PID()
|
||||
eventObject.DataHolder = nex.NewDataHolder()
|
||||
|
@ -21,9 +21,9 @@ func SendMiiUpdateNotification(client *nex.Client) {
|
|||
eventObjectBytes := eventObject.Bytes(stream)
|
||||
|
||||
rmcRequest := nex.NewRMCRequest()
|
||||
rmcRequest.SetProtocolID(nexproto.NintendoNotificationsProtocolID)
|
||||
rmcRequest.SetProtocolID(nintendo_notifications.ProtocolID)
|
||||
rmcRequest.SetCallID(3810693103)
|
||||
rmcRequest.SetMethodID(nexproto.NintendoNotificationsMethodProcessNintendoNotificationEvent1)
|
||||
rmcRequest.SetMethodID(nintendo_notifications.MethodProcessNintendoNotificationEvent1)
|
||||
rmcRequest.SetParameters(eventObjectBytes)
|
||||
|
||||
rmcRequestBytes := rmcRequest.Bytes()
|
||||
|
|
|
@ -4,11 +4,12 @@ import (
|
|||
database_3ds "github.com/PretendoNetwork/friends-secure/database/3ds"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends/3ds"
|
||||
nintendo_notifications "github.com/PretendoNetwork/nex-protocols-go/nintendo-notifications"
|
||||
)
|
||||
|
||||
func SendPresenceUpdate(client *nex.Client, presence *nexproto.NintendoPresence) {
|
||||
eventObject := nexproto.NewNintendoNotificationEvent()
|
||||
func SendPresenceUpdate(client *nex.Client, presence *friends_3ds.NintendoPresence) {
|
||||
eventObject := nintendo_notifications.NewNintendoNotificationEvent()
|
||||
eventObject.Type = 1
|
||||
eventObject.SenderPID = client.PID()
|
||||
eventObject.DataHolder = nex.NewDataHolder()
|
||||
|
@ -19,9 +20,9 @@ func SendPresenceUpdate(client *nex.Client, presence *nexproto.NintendoPresence)
|
|||
eventObjectBytes := eventObject.Bytes(stream)
|
||||
|
||||
rmcRequest := nex.NewRMCRequest()
|
||||
rmcRequest.SetProtocolID(nexproto.NintendoNotificationsProtocolID)
|
||||
rmcRequest.SetProtocolID(nintendo_notifications.ProtocolID)
|
||||
rmcRequest.SetCallID(3810693103)
|
||||
rmcRequest.SetMethodID(nexproto.NintendoNotificationsMethodProcessNintendoNotificationEvent1)
|
||||
rmcRequest.SetMethodID(nintendo_notifications.MethodProcessNintendoNotificationEvent1)
|
||||
rmcRequest.SetParameters(eventObjectBytes)
|
||||
|
||||
rmcRequestBytes := rmcRequest.Bytes()
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
database_3ds "github.com/PretendoNetwork/friends-secure/database/3ds"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
nintendo_notifications "github.com/PretendoNetwork/nex-protocols-go/nintendo-notifications"
|
||||
)
|
||||
|
||||
func SendUserWentOfflineGlobally(client *nex.Client) {
|
||||
|
@ -16,9 +16,9 @@ func SendUserWentOfflineGlobally(client *nex.Client) {
|
|||
}
|
||||
|
||||
func SendUserWentOffline(client *nex.Client, pid uint32) {
|
||||
notificationEvent := nexproto.NewNintendoNotificationEventGeneral()
|
||||
notificationEvent := nintendo_notifications.NewNintendoNotificationEventGeneral()
|
||||
|
||||
eventObject := nexproto.NewNintendoNotificationEvent()
|
||||
eventObject := nintendo_notifications.NewNintendoNotificationEvent()
|
||||
eventObject.Type = 10
|
||||
eventObject.SenderPID = client.PID()
|
||||
eventObject.DataHolder = nex.NewDataHolder()
|
||||
|
@ -29,9 +29,9 @@ func SendUserWentOffline(client *nex.Client, pid uint32) {
|
|||
eventObjectBytes := eventObject.Bytes(stream)
|
||||
|
||||
rmcRequest := nex.NewRMCRequest()
|
||||
rmcRequest.SetProtocolID(nexproto.NintendoNotificationsProtocolID)
|
||||
rmcRequest.SetProtocolID(nintendo_notifications.ProtocolID)
|
||||
rmcRequest.SetCallID(3810693103)
|
||||
rmcRequest.SetMethodID(nexproto.NintendoNotificationsMethodProcessNintendoNotificationEvent1)
|
||||
rmcRequest.SetMethodID(nintendo_notifications.MethodProcessNintendoNotificationEvent1)
|
||||
rmcRequest.SetParameters(eventObjectBytes)
|
||||
|
||||
rmcRequestBytes := rmcRequest.Bytes()
|
||||
|
|
|
@ -3,11 +3,12 @@ package notifications_wiiu
|
|||
import (
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
nintendo_notifications "github.com/PretendoNetwork/nex-protocols-go/nintendo-notifications"
|
||||
)
|
||||
|
||||
func SendFriendRequest(client *nex.Client, friendRequestNotificationData *nexproto.FriendRequest) {
|
||||
eventObject := nexproto.NewNintendoNotificationEvent()
|
||||
func SendFriendRequest(client *nex.Client, friendRequestNotificationData *friends_wiiu.FriendRequest) {
|
||||
eventObject := nintendo_notifications.NewNintendoNotificationEvent()
|
||||
eventObject.Type = 27
|
||||
eventObject.SenderPID = friendRequestNotificationData.PrincipalInfo.PID
|
||||
eventObject.DataHolder = nex.NewDataHolder()
|
||||
|
@ -18,9 +19,9 @@ func SendFriendRequest(client *nex.Client, friendRequestNotificationData *nexpro
|
|||
eventObjectBytes := eventObject.Bytes(stream)
|
||||
|
||||
rmcRequest := nex.NewRMCRequest()
|
||||
rmcRequest.SetProtocolID(nexproto.NintendoNotificationsProtocolID)
|
||||
rmcRequest.SetProtocolID(nintendo_notifications.ProtocolID)
|
||||
rmcRequest.SetCallID(3810693103)
|
||||
rmcRequest.SetMethodID(nexproto.NintendoNotificationsMethodProcessNintendoNotificationEvent2)
|
||||
rmcRequest.SetMethodID(nintendo_notifications.MethodProcessNintendoNotificationEvent2)
|
||||
rmcRequest.SetParameters(eventObjectBytes)
|
||||
|
||||
rmcRequestBytes := rmcRequest.Bytes()
|
||||
|
|
|
@ -3,11 +3,12 @@ package notifications_wiiu
|
|||
import (
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
nintendo_notifications "github.com/PretendoNetwork/nex-protocols-go/nintendo-notifications"
|
||||
)
|
||||
|
||||
func SendFriendRequestAccepted(client *nex.Client, friendInfo *nexproto.FriendInfo) {
|
||||
eventObject := nexproto.NewNintendoNotificationEvent()
|
||||
func SendFriendRequestAccepted(client *nex.Client, friendInfo *friends_wiiu.FriendInfo) {
|
||||
eventObject := nintendo_notifications.NewNintendoNotificationEvent()
|
||||
eventObject.Type = 30
|
||||
eventObject.SenderPID = friendInfo.NNAInfo.PrincipalBasicInfo.PID
|
||||
eventObject.DataHolder = nex.NewDataHolder()
|
||||
|
@ -18,9 +19,9 @@ func SendFriendRequestAccepted(client *nex.Client, friendInfo *nexproto.FriendIn
|
|||
eventObjectBytes := eventObject.Bytes(stream)
|
||||
|
||||
rmcRequest := nex.NewRMCRequest()
|
||||
rmcRequest.SetProtocolID(nexproto.NintendoNotificationsProtocolID)
|
||||
rmcRequest.SetProtocolID(nintendo_notifications.ProtocolID)
|
||||
rmcRequest.SetCallID(3810693103)
|
||||
rmcRequest.SetMethodID(nexproto.NintendoNotificationsMethodProcessNintendoNotificationEvent1)
|
||||
rmcRequest.SetMethodID(nintendo_notifications.MethodProcessNintendoNotificationEvent1)
|
||||
rmcRequest.SetParameters(eventObjectBytes)
|
||||
|
||||
rmcRequestBytes := rmcRequest.Bytes()
|
||||
|
|
|
@ -3,13 +3,13 @@ package notifications_wiiu
|
|||
import (
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
nintendo_notifications "github.com/PretendoNetwork/nex-protocols-go/nintendo-notifications"
|
||||
)
|
||||
|
||||
func SendFriendshipRemoved(client *nex.Client, senderPID uint32) {
|
||||
nintendoNotificationEventGeneral := nexproto.NewNintendoNotificationEventGeneral()
|
||||
nintendoNotificationEventGeneral := nintendo_notifications.NewNintendoNotificationEventGeneral()
|
||||
|
||||
eventObject := nexproto.NewNintendoNotificationEvent()
|
||||
eventObject := nintendo_notifications.NewNintendoNotificationEvent()
|
||||
eventObject.Type = 26
|
||||
eventObject.SenderPID = senderPID
|
||||
eventObject.DataHolder = nex.NewDataHolder()
|
||||
|
@ -20,9 +20,9 @@ func SendFriendshipRemoved(client *nex.Client, senderPID uint32) {
|
|||
stream.WriteStructure(eventObject)
|
||||
|
||||
rmcRequest := nex.NewRMCRequest()
|
||||
rmcRequest.SetProtocolID(nexproto.NintendoNotificationsProtocolID)
|
||||
rmcRequest.SetProtocolID(nintendo_notifications.ProtocolID)
|
||||
rmcRequest.SetCallID(3810693103)
|
||||
rmcRequest.SetMethodID(nexproto.NintendoNotificationsMethodProcessNintendoNotificationEvent1)
|
||||
rmcRequest.SetMethodID(nintendo_notifications.MethodProcessNintendoNotificationEvent1)
|
||||
rmcRequest.SetParameters(stream.Bytes())
|
||||
|
||||
rmcRequestBytes := rmcRequest.Bytes()
|
||||
|
|
|
@ -6,11 +6,12 @@ import (
|
|||
database_wiiu "github.com/PretendoNetwork/friends-secure/database/wiiu"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
nintendo_notifications "github.com/PretendoNetwork/nex-protocols-go/nintendo-notifications"
|
||||
)
|
||||
|
||||
func SendPresenceUpdate(presence *nexproto.NintendoPresenceV2) {
|
||||
eventObject := nexproto.NewNintendoNotificationEvent()
|
||||
func SendPresenceUpdate(presence *friends_wiiu.NintendoPresenceV2) {
|
||||
eventObject := nintendo_notifications.NewNintendoNotificationEvent()
|
||||
eventObject.Type = 24
|
||||
eventObject.SenderPID = presence.PID
|
||||
eventObject.DataHolder = nex.NewDataHolder()
|
||||
|
@ -21,9 +22,9 @@ func SendPresenceUpdate(presence *nexproto.NintendoPresenceV2) {
|
|||
eventObjectBytes := eventObject.Bytes(stream)
|
||||
|
||||
rmcRequest := nex.NewRMCRequest()
|
||||
rmcRequest.SetProtocolID(nexproto.NintendoNotificationsProtocolID)
|
||||
rmcRequest.SetProtocolID(nintendo_notifications.ProtocolID)
|
||||
rmcRequest.SetCallID(3810693103)
|
||||
rmcRequest.SetMethodID(nexproto.NintendoNotificationsMethodProcessNintendoNotificationEvent2)
|
||||
rmcRequest.SetMethodID(nintendo_notifications.MethodProcessNintendoNotificationEvent2)
|
||||
rmcRequest.SetParameters(eventObjectBytes)
|
||||
|
||||
rmcRequestBytes := rmcRequest.Bytes()
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
database_wiiu "github.com/PretendoNetwork/friends-secure/database/wiiu"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nexproto "github.com/PretendoNetwork/nex-protocols-go"
|
||||
nintendo_notifications "github.com/PretendoNetwork/nex-protocols-go/nintendo-notifications"
|
||||
)
|
||||
|
||||
func SendUserWentOfflineGlobally(client *nex.Client) {
|
||||
|
@ -21,14 +21,14 @@ func SendUserWentOffline(client *nex.Client, pid uint32) {
|
|||
lastOnline := nex.NewDateTime(0)
|
||||
lastOnline.FromTimestamp(time.Now())
|
||||
|
||||
nintendoNotificationEventGeneral := nexproto.NewNintendoNotificationEventGeneral()
|
||||
nintendoNotificationEventGeneral := nintendo_notifications.NewNintendoNotificationEventGeneral()
|
||||
|
||||
nintendoNotificationEventGeneral.U32Param = 0
|
||||
nintendoNotificationEventGeneral.U64Param1 = 0
|
||||
nintendoNotificationEventGeneral.U64Param2 = lastOnline.Value()
|
||||
nintendoNotificationEventGeneral.StrParam = ""
|
||||
|
||||
eventObject := nexproto.NewNintendoNotificationEvent()
|
||||
eventObject := nintendo_notifications.NewNintendoNotificationEvent()
|
||||
eventObject.Type = 10
|
||||
eventObject.SenderPID = client.PID()
|
||||
eventObject.DataHolder = nex.NewDataHolder()
|
||||
|
@ -39,9 +39,9 @@ func SendUserWentOffline(client *nex.Client, pid uint32) {
|
|||
stream.WriteStructure(eventObject)
|
||||
|
||||
rmcRequest := nex.NewRMCRequest()
|
||||
rmcRequest.SetProtocolID(nexproto.NintendoNotificationsProtocolID)
|
||||
rmcRequest.SetProtocolID(nintendo_notifications.ProtocolID)
|
||||
rmcRequest.SetCallID(3810693103)
|
||||
rmcRequest.SetMethodID(nexproto.NintendoNotificationsMethodProcessNintendoNotificationEvent1)
|
||||
rmcRequest.SetMethodID(nintendo_notifications.MethodProcessNintendoNotificationEvent1)
|
||||
rmcRequest.SetParameters(stream.Bytes())
|
||||
|
||||
rmcRequestBytes := rmcRequest.Bytes()
|
||||
|
|
20
types/connected_user.go
Normal file
20
types/connected_user.go
Normal file
|
@ -0,0 +1,20 @@
|
|||
package types
|
||||
|
||||
import (
|
||||
"github.com/PretendoNetwork/nex-go"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends/3ds"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
)
|
||||
|
||||
type ConnectedUser struct {
|
||||
PID uint32
|
||||
Platform Platform
|
||||
Client *nex.Client
|
||||
NNAInfo *friends_wiiu.NNAInfo
|
||||
Presence *friends_3ds.NintendoPresence
|
||||
PresenceV2 *friends_wiiu.NintendoPresenceV2
|
||||
}
|
||||
|
||||
func NewConnectedUser() *ConnectedUser {
|
||||
return &ConnectedUser{}
|
||||
}
|
28
types/friend_user.go
Normal file
28
types/friend_user.go
Normal file
|
@ -0,0 +1,28 @@
|
|||
package types
|
||||
|
||||
import (
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
)
|
||||
|
||||
// FriendUser represents a user connected to the friends server
|
||||
// Contains data relating only to friends
|
||||
type FriendUser struct {
|
||||
NNID string
|
||||
PID uint32
|
||||
Comment *friends_wiiu.Comment
|
||||
FriendRequestsOut []*friends_wiiu.FriendRequest
|
||||
FriendRequestsIn []*friends_wiiu.FriendRequest
|
||||
BlockedUsers []*friends_wiiu.BlacklistedPrincipal
|
||||
LastOnline *nex.DateTime
|
||||
ActiveTitle *friends_wiiu.GameKey
|
||||
Notifications []*friends_wiiu.PersistentNotification
|
||||
}
|
||||
|
||||
func (friendUser *FriendUser) FromPID(pid uint32) {
|
||||
|
||||
}
|
||||
|
||||
func NewFriendUser() *FriendUser {
|
||||
return &FriendUser{}
|
||||
}
|
10
types/nex_token.go
Normal file
10
types/nex_token.go
Normal file
|
@ -0,0 +1,10 @@
|
|||
package types
|
||||
|
||||
type NEXToken struct {
|
||||
SystemType uint8
|
||||
TokenType uint8
|
||||
UserPID uint32
|
||||
AccessLevel uint8
|
||||
TitleID uint64
|
||||
ExpireTime uint64
|
||||
}
|
8
types/platform.go
Normal file
8
types/platform.go
Normal file
|
@ -0,0 +1,8 @@
|
|||
package types
|
||||
|
||||
type Platform int
|
||||
|
||||
const (
|
||||
WUP Platform = iota
|
||||
CTR
|
||||
)
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package utility
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
@ -13,9 +13,12 @@ import (
|
|||
"encoding/binary"
|
||||
"encoding/pem"
|
||||
"errors"
|
||||
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
"github.com/PretendoNetwork/friends-secure/types"
|
||||
)
|
||||
|
||||
func decryptToken(encryptedToken []byte) (*nexToken, error) {
|
||||
func DecryptToken(encryptedToken []byte) (*types.NEXToken, error) {
|
||||
// Split the encoded token into it's parts
|
||||
cryptoConfig := encryptedToken[:0x82]
|
||||
signature := encryptedToken[0x82:0x96]
|
||||
|
@ -32,7 +35,7 @@ func decryptToken(encryptedToken []byte) (*nexToken, error) {
|
|||
iv = append(iv, encryptedAESKey[point2:point2+8]...)
|
||||
|
||||
// Decrypt the AES key
|
||||
decryptedAESKey, err := rsa.DecryptOAEP(sha256.New(), rand.Reader, rsaPrivateKey, encryptedAESKey, nil)
|
||||
decryptedAESKey, err := rsa.DecryptOAEP(sha256.New(), rand.Reader, globals.RSAPrivateKey, encryptedAESKey, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -50,13 +53,13 @@ func decryptToken(encryptedToken []byte) (*nexToken, error) {
|
|||
decryptedBody = decryptedBody[:0x17] // Remove AES padding
|
||||
|
||||
// Verify the token body
|
||||
err = verifySignature(decryptedBody, signature, hmacSecret)
|
||||
err = verifySignature(decryptedBody, signature, globals.HMACSecret)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Unpack the token body to struct
|
||||
token := &nexToken{}
|
||||
token := &types.NEXToken{}
|
||||
tokenReader := bytes.NewBuffer(decryptedBody)
|
||||
|
||||
err = binary.Read(tokenReader, binary.LittleEndian, token)
|
||||
|
@ -81,7 +84,7 @@ func verifySignature(body []byte, expectedSignature []byte, secret []byte) error
|
|||
return nil
|
||||
}
|
||||
|
||||
func parseRsaPrivateKey(keyBytes []byte) (*rsa.PrivateKey, error) {
|
||||
func ParseRsaPrivateKey(keyBytes []byte) (*rsa.PrivateKey, error) {
|
||||
block, _ := pem.Decode(keyBytes)
|
||||
if block == nil {
|
||||
return nil, errors.New("Failed to parse RSA key")
|
Loading…
Reference in a new issue