Improve error handling

Now that we can return errors to nex-protocols-go and it will handle it,
we can improve how errors are being handled in friends.

There's probably room for improvement from this, since I haven't added
error handling on some database getters due to uncertainties on whether
the error should interrupt an action or not.
This commit is contained in:
Daniel López Guimaraes 2023-08-12 23:53:21 +01:00
parent 2c1cdba561
commit 3d5e78f532
No known key found for this signature in database
GPG key ID: 6AC74DE3DEF050E0
65 changed files with 631 additions and 343 deletions

View file

@ -10,7 +10,7 @@ import (
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/friends-3ds/types"
)
// Get a friend's mii
// GetFriendMiis returns the Mii of all friends
func GetFriendMiis(pids []uint32) []*friends_3ds_types.FriendMii {
friendMiis := make([]*friends_3ds_types.FriendMii, 0)

View file

@ -10,7 +10,7 @@ import (
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/friends-3ds/types"
)
// Get a friend's persistent information
// GetFriendPersistentInfos returns the persistent information of all friends
func GetFriendPersistentInfos(user1_pid uint32, pids []uint32) []*friends_3ds_types.FriendPersistentInfo {
persistentInfos := make([]*friends_3ds_types.FriendPersistentInfo, 0)

View file

@ -8,7 +8,7 @@ import (
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/friends-3ds/types"
)
// Get all of a user's friend relationships
// GetUserFriends returns all friend relationships of a user
func GetUserFriends(pid uint32) []*friends_3ds_types.FriendRelationship {
friendRelationships := make([]*friends_3ds_types.FriendRelationship, 0)

View file

@ -2,20 +2,21 @@ package database_3ds
import (
"github.com/PretendoNetwork/friends-secure/database"
"github.com/PretendoNetwork/friends-secure/globals"
)
// Remove a user's friend relationship
func RemoveFriendship(user1_pid uint32, user2_pid uint32) {
// RemoveFriendship removes a user's friend relationship
func RemoveFriendship(user1_pid uint32, user2_pid uint32) error {
_, err := database.Postgres.Exec(`
DELETE FROM "3ds".friendships WHERE user1_pid=$1 AND user2_pid=$2`, user1_pid, user2_pid)
if err != nil {
globals.Logger.Critical(err.Error())
return err
}
_, err = database.Postgres.Exec(`
UPDATE "3ds".friendships SET type=0 WHERE user1_pid=$1 AND user2_pid=$2`, user2_pid, user1_pid)
if err != nil {
globals.Logger.Critical(err.Error())
return err
}
return nil
}

View file

@ -4,13 +4,12 @@ import (
"time"
"github.com/PretendoNetwork/friends-secure/database"
"github.com/PretendoNetwork/friends-secure/globals"
"github.com/PretendoNetwork/nex-go"
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/friends-3ds/types"
)
// Save a friend relationship for a user
func SaveFriendship(senderPID uint32, recipientPID uint32) *friends_3ds_types.FriendRelationship {
// SaveFriendship saves a friend relationship for a user
func SaveFriendship(senderPID uint32, recipientPID uint32) (*friends_3ds_types.FriendRelationship, error) {
friendRelationship := friends_3ds_types.NewFriendRelationship()
friendRelationship.PID = recipientPID
friendRelationship.LFC = 0
@ -23,18 +22,18 @@ func SaveFriendship(senderPID uint32, recipientPID uint32) *friends_3ds_types.Fr
var found bool
err := database.Postgres.QueryRow(`SELECT COUNT(*) FROM "3ds".user_data WHERE pid=$1 LIMIT 1`, recipientPID).Scan(&found)
if err != nil {
globals.Logger.Critical(err.Error())
return nil, err
}
if !found {
friendRelationship.RelationshipType = 2 // Non-existent
return friendRelationship
return friendRelationship, nil
}
// Get the other side's relationship, we need to know if we've already got one sent to us.
err = database.Postgres.QueryRow(`
SELECT COUNT(*) FROM "3ds".friendships WHERE user1_pid=$1 AND user2_pid=$2 AND type=0 LIMIT 1`, recipientPID, senderPID).Scan(&found)
if err != nil {
globals.Logger.Critical(err.Error())
return nil, err
}
if !found {
_, err = database.Postgres.Exec(`
@ -43,9 +42,9 @@ func SaveFriendship(senderPID uint32, recipientPID uint32) *friends_3ds_types.Fr
ON CONFLICT (user1_pid, user2_pid)
DO NOTHING`, senderPID, recipientPID)
if err != nil {
globals.Logger.Critical(err.Error())
return nil, err
}
return friendRelationship
return friendRelationship, nil
}
acceptedTime := nex.NewDateTime(0).Now()
@ -59,8 +58,7 @@ func SaveFriendship(senderPID uint32, recipientPID uint32) *friends_3ds_types.Fr
date = $3,
type = 1`, senderPID, recipientPID, acceptedTime)
if err != nil {
globals.Logger.Critical(err.Error())
return nil
return nil, err
}
_, err = database.Postgres.Exec(`
@ -71,10 +69,9 @@ func SaveFriendship(senderPID uint32, recipientPID uint32) *friends_3ds_types.Fr
date = $3,
type = 1`, recipientPID, senderPID, acceptedTime)
if err != nil {
globals.Logger.Critical(err.Error())
return nil
return nil, err
}
friendRelationship.RelationshipType = 1 // Complete
return friendRelationship
return friendRelationship, nil
}

View file

@ -2,12 +2,11 @@ package database_3ds
import (
"github.com/PretendoNetwork/friends-secure/database"
"github.com/PretendoNetwork/friends-secure/globals"
"github.com/PretendoNetwork/nex-go"
)
// Update a user's comment
func UpdateUserComment(pid uint32, message string) {
// UpdateUserComment updates a user's comment
func UpdateUserComment(pid uint32, message string) error {
changed := nex.NewDateTime(0).Now()
_, err := database.Postgres.Exec(`
@ -19,6 +18,8 @@ func UpdateUserComment(pid uint32, message string) {
comment_changed = $3`, pid, message, changed)
if err != nil {
globals.Logger.Critical(err.Error())
return err
}
return nil
}

View file

@ -2,12 +2,11 @@ package database_3ds
import (
"github.com/PretendoNetwork/friends-secure/database"
"github.com/PretendoNetwork/friends-secure/globals"
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/friends-3ds/types"
)
// Update a user's favorite game
func UpdateUserFavoriteGame(pid uint32, gameKey *friends_3ds_types.GameKey) {
// UpdateUserFavoriteGame updates a user's favorite game
func UpdateUserFavoriteGame(pid uint32, gameKey *friends_3ds_types.GameKey) error {
_, err := database.Postgres.Exec(`
INSERT INTO "3ds".user_data (pid, favorite_title, favorite_title_version)
VALUES ($1, $2, $3)
@ -17,6 +16,8 @@ func UpdateUserFavoriteGame(pid uint32, gameKey *friends_3ds_types.GameKey) {
favorite_title_version = $3`, pid, gameKey.TitleID, gameKey.TitleVersion)
if err != nil {
globals.Logger.Critical(err.Error())
return err
}
return nil
}

View file

@ -4,20 +4,19 @@ import (
"database/sql"
"github.com/PretendoNetwork/friends-secure/database"
"github.com/PretendoNetwork/friends-secure/globals"
"github.com/PretendoNetwork/nex-go"
)
// Update a user's last online time
func UpdateUserLastOnlineTime(pid uint32, lastOnline *nex.DateTime) {
// UpdateUserLastOnlineTime updates a user's last online time
func UpdateUserLastOnlineTime(pid uint32, lastOnline *nex.DateTime) error {
var showOnline bool
err := database.Postgres.QueryRow(`SELECT show_online FROM "3ds".user_data WHERE pid=$1`, pid).Scan(&showOnline)
if err != nil && err != sql.ErrNoRows {
globals.Logger.Critical(err.Error())
return err
}
if !showOnline {
return
return nil
}
_, err = database.Postgres.Exec(`
@ -27,6 +26,8 @@ func UpdateUserLastOnlineTime(pid uint32, lastOnline *nex.DateTime) {
DO UPDATE SET
last_online = $2`, pid, lastOnline.Value())
if err != nil {
globals.Logger.Critical(err.Error())
return err
}
return nil
}

View file

@ -2,13 +2,12 @@ package database_3ds
import (
"github.com/PretendoNetwork/friends-secure/database"
"github.com/PretendoNetwork/friends-secure/globals"
"github.com/PretendoNetwork/nex-go"
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/friends-3ds/types"
)
// Update a user's mii
func UpdateUserMii(pid uint32, mii *friends_3ds_types.Mii) {
// UpdateUserMii updates a user's mii
func UpdateUserMii(pid uint32, mii *friends_3ds_types.Mii) error {
_, err := database.Postgres.Exec(`
INSERT INTO "3ds".user_data (pid, mii_name, mii_data, mii_changed)
VALUES ($1, $2, $3, $4)
@ -19,6 +18,8 @@ func UpdateUserMii(pid uint32, mii *friends_3ds_types.Mii) {
mii_changed = $4`, pid, mii.Name, mii.MiiData, nex.NewDateTime(0).Now())
if err != nil {
globals.Logger.Critical(err.Error())
return err
}
return nil
}

View file

@ -2,11 +2,10 @@ package database_3ds
import (
"github.com/PretendoNetwork/friends-secure/database"
"github.com/PretendoNetwork/friends-secure/globals"
)
// Update a user's preferences
func UpdateUserPreferences(pid uint32, show_online bool, show_current_game bool) {
// UpdateUserPreferences updates a user's preferences
func UpdateUserPreferences(pid uint32, show_online bool, show_current_game bool) error {
_, err := database.Postgres.Exec(`
INSERT INTO "3ds".user_data (pid, show_online, show_current_game)
VALUES ($1, $2, $3)
@ -16,6 +15,8 @@ func UpdateUserPreferences(pid uint32, show_online bool, show_current_game bool)
show_current_game = $3`, pid, show_online, show_current_game)
if err != nil {
globals.Logger.Critical(err.Error())
return err
}
return nil
}

View file

@ -2,12 +2,11 @@ package database_3ds
import (
"github.com/PretendoNetwork/friends-secure/database"
"github.com/PretendoNetwork/friends-secure/globals"
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/friends-3ds/types"
)
// Update a user's profile
func UpdateUserProfile(pid uint32, profileData *friends_3ds_types.MyProfile) {
// UpdateUserProfile updates a user's profile
func UpdateUserProfile(pid uint32, profileData *friends_3ds_types.MyProfile) error {
_, err := database.Postgres.Exec(`
INSERT INTO "3ds".user_data (pid, region, area, language)
VALUES ($1, $2, $3, $4)
@ -18,6 +17,8 @@ func UpdateUserProfile(pid uint32, profileData *friends_3ds_types.MyProfile) {
language = $4`, pid, profileData.Region, profileData.Area, profileData.Language)
if err != nil {
globals.Logger.Critical(err.Error())
return err
}
return nil
}

View file

@ -7,17 +7,15 @@ import (
"github.com/PretendoNetwork/friends-secure/globals"
"github.com/PretendoNetwork/nex-go"
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
"github.com/gocql/gocql"
)
func AcceptFriendRequestAndReturnFriendInfo(friendRequestID uint64) *friends_wiiu_types.FriendInfo {
func AcceptFriendRequestAndReturnFriendInfo(friendRequestID uint64) (*friends_wiiu_types.FriendInfo, error) {
var senderPID uint32
var recipientPID uint32
err := database.Postgres.QueryRow(`SELECT sender_pid, recipient_pid FROM wiiu.friend_requests WHERE id=$1`, friendRequestID).Scan(&senderPID, &recipientPID)
if err != nil {
globals.Logger.Critical(err.Error())
return nil
return nil, err
}
acceptedTime := nex.NewDateTime(0)
@ -36,8 +34,7 @@ func AcceptFriendRequestAndReturnFriendInfo(friendRequestID uint64) *friends_wii
date = $3,
active = true`, senderPID, recipientPID, acceptedTime.Value())
if err != nil {
globals.Logger.Critical(err.Error())
return nil
return nil, err
}
_, err = database.Postgres.Exec(`
@ -48,11 +45,13 @@ func AcceptFriendRequestAndReturnFriendInfo(friendRequestID uint64) *friends_wii
date = $3,
active = true`, recipientPID, senderPID, acceptedTime.Value())
if err != nil {
globals.Logger.Critical(err.Error())
return nil
return nil, err
}
SetFriendRequestAccepted(friendRequestID)
err = SetFriendRequestAccepted(friendRequestID)
if err != nil {
return nil, err
}
friendInfo := friends_wiiu_types.NewFriendInfo()
connectedUser := globals.ConnectedUsers[senderPID]
@ -87,7 +86,7 @@ func AcceptFriendRequestAndReturnFriendInfo(friendRequestID uint64) *friends_wii
friendInfo.Presence.Unknown4 = 0
friendInfo.Presence.PID = senderPID
friendInfo.Presence.GatheringID = 0
friendInfo.Presence.ApplicationData = []byte{0x00}
friendInfo.Presence.ApplicationData = make([]byte, 0)
friendInfo.Presence.Unknown5 = 0
friendInfo.Presence.Unknown6 = 0
friendInfo.Presence.Unknown7 = 0
@ -97,11 +96,8 @@ func AcceptFriendRequestAndReturnFriendInfo(friendRequestID uint64) *friends_wii
if err != nil {
lastOnlineTime = nex.NewDateTime(0).Now()
if err == gocql.ErrNotFound {
globals.Logger.Error(err.Error())
} else {
globals.Logger.Critical(err.Error())
}
// TODO: Should we return the error here?
globals.Logger.Critical(err.Error())
}
lastOnline = nex.NewDateTime(lastOnlineTime) // TODO: Change this
@ -112,5 +108,5 @@ func AcceptFriendRequestAndReturnFriendInfo(friendRequestID uint64) *friends_wii
friendInfo.LastOnline = lastOnline // TODO: Change this
friendInfo.Unknown = 0
return friendInfo
return friendInfo, nil
}

View file

@ -2,22 +2,21 @@ package database_wiiu
import (
"github.com/PretendoNetwork/friends-secure/database"
"github.com/PretendoNetwork/friends-secure/globals"
)
func DeleteFriendRequestAndReturnFriendPID(friendRequestID uint64) uint32 {
func DeleteFriendRequestAndReturnFriendPID(friendRequestID uint64) (uint32, error) {
var recipientPID uint32
err := database.Postgres.QueryRow(`SELECT recipient_pid FROM wiiu.friend_requests WHERE id=$1`, friendRequestID).Scan(&recipientPID)
if err != nil {
globals.Logger.Critical(err.Error())
return 0, err
}
_, err = database.Postgres.Exec(`
DELETE FROM wiiu.friend_requests WHERE id=$1`, friendRequestID)
if err != nil {
globals.Logger.Critical(err.Error())
return 0, err
}
return recipientPID
return recipientPID, nil
}

View file

@ -16,17 +16,18 @@ import (
func GetUserInfoByPID(pid uint32) *friends_wiiu_types.PrincipalBasicInfo {
var result bson.M
info := friends_wiiu_types.NewPrincipalBasicInfo()
err := database.MongoCollection.FindOne(context.TODO(), bson.D{{Key: "pid", Value: pid}}, options.FindOne()).Decode(&result)
if err != nil {
if err == mongo.ErrNoDocuments {
return nil
if err != mongo.ErrNoDocuments {
globals.Logger.Critical(err.Error())
}
globals.Logger.Critical(err.Error())
return info
}
info := friends_wiiu_types.NewPrincipalBasicInfo()
info.PID = pid
info.NNID = result["username"].(string)
info.Mii = friends_wiiu_types.NewMiiV2()
@ -38,7 +39,7 @@ func GetUserInfoByPID(pid uint32) *friends_wiiu_types.PrincipalBasicInfo {
info.Mii.Name = result["mii"].(bson.M)["name"].(string)
info.Mii.Unknown1 = 0
info.Mii.Unknown2 = 0
info.Mii.Data = decodedMiiData
info.Mii.MiiData = decodedMiiData
info.Mii.Datetime = nex.NewDateTime(0)
return info

View file

@ -2,20 +2,21 @@ package database_wiiu
import (
"github.com/PretendoNetwork/friends-secure/database"
"github.com/PretendoNetwork/friends-secure/globals"
)
// Remove a user's friend relationship
func RemoveFriendship(user1_pid uint32, user2_pid uint32) {
func RemoveFriendship(user1_pid uint32, user2_pid uint32) error {
_, err := database.Postgres.Exec(`
DELETE FROM wiiu.friendships WHERE user1_pid=$1 AND user2_pid=$2`, user1_pid, user2_pid)
if err != nil {
globals.Logger.Critical(err.Error())
return err
}
_, err = database.Postgres.Exec(`
UPDATE wiiu.friendships SET active=false WHERE user1_pid=$1 AND user2_pid=$2`, user2_pid, user1_pid)
if err != nil {
globals.Logger.Critical(err.Error())
return err
}
return nil
}

View file

@ -4,10 +4,9 @@ import (
"database/sql"
"github.com/PretendoNetwork/friends-secure/database"
"github.com/PretendoNetwork/friends-secure/globals"
)
func SaveFriendRequest(senderPID uint32, recipientPID uint32, sentTime uint64, expireTime uint64, message string) uint64 {
func SaveFriendRequest(senderPID uint32, recipientPID uint32, sentTime uint64, expireTime uint64, message string) (uint64, error) {
var id uint64
friendRequestBlocked := IsFriendRequestBlocked(recipientPID, senderPID)
@ -15,15 +14,18 @@ func SaveFriendRequest(senderPID uint32, recipientPID uint32, sentTime uint64, e
// Make sure we don't already have that friend request! If we do, give them the one we already have.
err := database.Postgres.QueryRow(`SELECT id FROM wiiu.friend_requests WHERE sender_pid=$1 AND recipient_pid=$2`, senderPID, recipientPID).Scan(&id)
if err != nil && err != sql.ErrNoRows {
globals.Logger.Critical(err.Error())
return 0
return 0, err
} else if id != 0 {
// If they aren't blocked, we want to unset the denied status on the previous request we have so that it appears again.
if friendRequestBlocked {
return id
return id, nil
} else {
UnsetFriendRequestDenied(id)
return id
err = UnsetFriendRequestDenied(id)
if err != nil {
return 0, err
}
return id, nil
}
}
@ -31,9 +33,8 @@ func SaveFriendRequest(senderPID uint32, recipientPID uint32, sentTime uint64, e
INSERT INTO wiiu.friend_requests (sender_pid, recipient_pid, sent_on, expires_on, message, received, accepted, denied)
VALUES ($1, $2, $3, $4, $5, false, false, $6) RETURNING id`, senderPID, recipientPID, sentTime, expireTime, message, friendRequestBlocked).Scan(&id)
if err != nil {
globals.Logger.Critical(err.Error())
return 0
return 0, err
}
return id
return id, nil
}

View file

@ -2,13 +2,13 @@ package database_wiiu
import (
"github.com/PretendoNetwork/friends-secure/database"
"github.com/PretendoNetwork/friends-secure/globals"
)
func SetFriendRequestAccepted(friendRequestID uint64) {
func SetFriendRequestAccepted(friendRequestID uint64) error {
_, err := database.Postgres.Exec(`UPDATE wiiu.friend_requests SET accepted=true WHERE id=$1`, friendRequestID)
if err != nil {
globals.Logger.Critical(err.Error())
return err
}
return nil
}

View file

@ -2,13 +2,14 @@ package database_wiiu
import (
"github.com/PretendoNetwork/friends-secure/database"
"github.com/PretendoNetwork/friends-secure/globals"
)
func SetFriendRequestDenied(friendRequestID uint64) {
func SetFriendRequestDenied(friendRequestID uint64) error {
_, err := database.Postgres.Exec(`UPDATE wiiu.friend_requests SET denied=true WHERE id=$1`, friendRequestID)
if err != nil {
globals.Logger.Critical(err.Error())
return err
}
return nil
}

View file

@ -2,13 +2,14 @@ package database_wiiu
import (
"github.com/PretendoNetwork/friends-secure/database"
"github.com/PretendoNetwork/friends-secure/globals"
)
func SetFriendRequestReceived(friendRequestID uint64) {
func SetFriendRequestReceived(friendRequestID uint64) error {
_, err := database.Postgres.Exec(`UPDATE wiiu.friend_requests SET received=true WHERE id=$1`, friendRequestID)
if err != nil {
globals.Logger.Critical(err.Error())
return err
}
return nil
}

View file

@ -4,11 +4,10 @@ import (
"time"
"github.com/PretendoNetwork/friends-secure/database"
"github.com/PretendoNetwork/friends-secure/globals"
"github.com/PretendoNetwork/nex-go"
)
func SetUserBlocked(blockerPID uint32, blockedPID uint32, titleId uint64, titleVersion uint16) {
func SetUserBlocked(blockerPID uint32, blockedPID uint32, titleId uint64, titleVersion uint16) error {
date := nex.NewDateTime(0)
date.FromTimestamp(time.Now())
@ -19,6 +18,8 @@ func SetUserBlocked(blockerPID uint32, blockedPID uint32, titleId uint64, titleV
DO UPDATE SET
date = $5`, blockerPID, blockedPID, titleId, titleVersion, date.Value())
if err != nil {
globals.Logger.Critical(err.Error())
return err
}
return nil
}

View file

@ -2,13 +2,14 @@ package database_wiiu
import (
"github.com/PretendoNetwork/friends-secure/database"
"github.com/PretendoNetwork/friends-secure/globals"
)
func UnsetFriendRequestDenied(friendRequestID uint64) {
func UnsetFriendRequestDenied(friendRequestID uint64) error {
_, err := database.Postgres.Exec(`UPDATE wiiu.friend_requests SET denied=false WHERE id=$1`, friendRequestID)
if err != nil {
globals.Logger.Critical(err.Error())
return err
}
return nil
}

View file

@ -2,14 +2,15 @@ package database_wiiu
import (
"github.com/PretendoNetwork/friends-secure/database"
"github.com/PretendoNetwork/friends-secure/globals"
)
// Remove a block from a user
func UnsetUserBlocked(user1_pid uint32, user2_pid uint32) {
func UnsetUserBlocked(user1_pid uint32, user2_pid uint32) error {
_, err := database.Postgres.Exec(`
DELETE FROM wiiu.blocks WHERE blocker_pid=$1 AND blocked_pid=$2`, user1_pid, user2_pid)
if err != nil {
globals.Logger.Critical(err.Error())
return err
}
return nil
}

View file

@ -2,12 +2,11 @@ package database_wiiu
import (
"github.com/PretendoNetwork/friends-secure/database"
"github.com/PretendoNetwork/friends-secure/globals"
"github.com/PretendoNetwork/nex-go"
)
// Update a users comment
func UpdateUserComment(pid uint32, message string) uint64 {
func UpdateUserComment(pid uint32, message string) (uint64, error) {
changed := nex.NewDateTime(0).Now()
_, err := database.Postgres.Exec(`
@ -19,8 +18,8 @@ func UpdateUserComment(pid uint32, message string) uint64 {
comment_changed = $3`, pid, message, changed)
if err != nil {
globals.Logger.Critical(err.Error())
return 0, err
}
return changed
return changed, nil
}

View file

@ -2,11 +2,10 @@ package database_wiiu
import (
"github.com/PretendoNetwork/friends-secure/database"
"github.com/PretendoNetwork/friends-secure/globals"
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
)
func UpdateUserPrincipalPreference(pid uint32, principalPreference *friends_wiiu_types.PrincipalPreference) {
func UpdateUserPrincipalPreference(pid uint32, principalPreference *friends_wiiu_types.PrincipalPreference) error {
_, err := database.Postgres.Exec(`
INSERT INTO wiiu.user_data (pid, show_online, show_current_game, block_friend_requests)
VALUES ($1, $2, $3, $4)
@ -17,6 +16,8 @@ func UpdateUserPrincipalPreference(pid uint32, principalPreference *friends_wiiu
block_friend_requests = $4`, pid, principalPreference.ShowOnlinePresence, principalPreference.ShowCurrentTitle, principalPreference.BlockFriendRequests)
if err != nil {
globals.Logger.Critical(err.Error())
return err
}
return nil
}

10
go.mod
View file

@ -4,10 +4,10 @@ go 1.18
require (
github.com/PretendoNetwork/grpc-go v1.0.2
github.com/PretendoNetwork/nex-go v1.0.29
github.com/PretendoNetwork/nex-protocols-common-go v1.0.23
github.com/PretendoNetwork/nex-protocols-go v1.0.41
github.com/PretendoNetwork/plogger-go v1.0.3
github.com/PretendoNetwork/nex-go v1.0.35
github.com/PretendoNetwork/nex-protocols-common-go v1.0.25
github.com/PretendoNetwork/nex-protocols-go v1.0.49
github.com/PretendoNetwork/plogger-go v1.0.4
github.com/gocql/gocql v1.5.2
github.com/golang/protobuf v1.5.3
github.com/joho/godotenv v1.5.1
@ -26,8 +26,6 @@ require (
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/montanaflynn/stats v0.7.1 // 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.2 // indirect

59
go.sum
View file

@ -1,19 +1,13 @@
github.com/PretendoNetwork/grpc-go v0.0.0-20230418154649-25a94d02f01f h1:RfnZOFUIiw9rpxPo4RDkPXx7DdM8rxix3xfpbV/A2e8=
github.com/PretendoNetwork/grpc-go v0.0.0-20230418154649-25a94d02f01f/go.mod h1:XZjEsij9lL7HJBNkH6JPbBIkUSq/1rjflvjGdv+DAj0=
github.com/PretendoNetwork/grpc-go v1.0.2 h1:9TvKmX7dCOANyoHEra1MMYqS1N/RGav66TRG4SHInvo=
github.com/PretendoNetwork/grpc-go v1.0.2/go.mod h1:XZjEsij9lL7HJBNkH6JPbBIkUSq/1rjflvjGdv+DAj0=
github.com/PretendoNetwork/nex-go v1.0.28 h1:g3892srP1T7LaeY5JklMtLZ03gTxE8wpXqpPQpXpN74=
github.com/PretendoNetwork/nex-go v1.0.28/go.mod h1:tWfWhrC/DCJuS08jTk0ceOv2R1VtElvKSVv13To6miE=
github.com/PretendoNetwork/nex-go v1.0.29 h1:Mu/UGpYEt0YHgJR/l+8Ysc5rlX91NE86ab3sMSKpPWo=
github.com/PretendoNetwork/nex-go v1.0.29/go.mod h1:tWfWhrC/DCJuS08jTk0ceOv2R1VtElvKSVv13To6miE=
github.com/PretendoNetwork/nex-protocols-common-go v1.0.23 h1:5nhsCg0NtJ+Wlq4eAxLkpazsBDWOnSHLgpllW3XUeE0=
github.com/PretendoNetwork/nex-protocols-common-go v1.0.23/go.mod h1:WqdDoCdjAHg4cdnIGJCrBQUX/JQIJHbw0D5oQWZ8mfk=
github.com/PretendoNetwork/nex-protocols-go v1.0.39 h1:l0wezyS1s8WELcuiZBV726C/cYE0GHHnnks2GLP+33Q=
github.com/PretendoNetwork/nex-protocols-go v1.0.39/go.mod h1:jZSnoM2G4oc7tKXeUf2OkJ6VyfJc4nb7gR++2oNEh5A=
github.com/PretendoNetwork/nex-protocols-go v1.0.41 h1:f4AJxoIgKt5k22IcYF/SM5MazR0/34hmyflZkFt/Hug=
github.com/PretendoNetwork/nex-protocols-go v1.0.41/go.mod h1:DPRCNkz45onV4ySCRJNp2+69NQnRa+SRqeErsnjW6P4=
github.com/PretendoNetwork/plogger-go v1.0.3 h1:KEnrUfPaCn0LFweg8OrhtiDhlN3pclWpNhlmAtmgfB0=
github.com/PretendoNetwork/plogger-go v1.0.3/go.mod h1:7kD6M4vPq1JL4LTuPg6kuB1OvUBOwQOtAvTaUwMbwvU=
github.com/PretendoNetwork/nex-go v1.0.35 h1:2oZxb4YUlMgFcT2tSRETrjsrS/9Wxf3BVr45+bMvjRM=
github.com/PretendoNetwork/nex-go v1.0.35/go.mod h1:v3dYsytdk7VvZOqplKwVqQOPa9heaq2V4DOAzCwyYNE=
github.com/PretendoNetwork/nex-protocols-common-go v1.0.25 h1:mMvmzrqwwBk6iFq8mCd8jn0XcxwFrhSc3jFITpprsZs=
github.com/PretendoNetwork/nex-protocols-common-go v1.0.25/go.mod h1:yLskCITByVXqxxuBd7389wW1xOhzSw4nmPNpA86CHzk=
github.com/PretendoNetwork/nex-protocols-go v1.0.49 h1:CIAjb9H11uTLj4JT2/4eedX1NsnQbBEFAJsSSEE2zR8=
github.com/PretendoNetwork/nex-protocols-go v1.0.49/go.mod h1:ztsrVFHaJc5MDBpL1rv4PgriLsTjl3R8u5XVxJHUzCk=
github.com/PretendoNetwork/plogger-go v1.0.4 h1:PF7xHw9eDRHH+RsAP9tmAE7fG0N0p6H4iPwHKnsoXwc=
github.com/PretendoNetwork/plogger-go v1.0.4/go.mod h1:7kD6M4vPq1JL4LTuPg6kuB1OvUBOwQOtAvTaUwMbwvU=
github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932 h1:mXoPYz/Ul5HYEDvkta6I8/rnYM5gSdSV2tJ6XbZuEtY=
github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932/go.mod h1:NOuUCSz6Q9T7+igc/hlvDOUdtWKryOrtFyIVABv/p7k=
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 h1:DDGfHa7BWjL4YnC6+E63dPcxHo2sUxDIu8g3QgEJdRY=
@ -42,8 +36,6 @@ github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwA
github.com/jwalton/go-supportscolor v1.2.0 h1:g6Ha4u7Vm3LIsQ5wmeBpS4gazu0UP1DRDE8y6bre4H8=
github.com/jwalton/go-supportscolor v1.2.0/go.mod h1:hFVUAZV2cWg+WFFC4v8pT2X/S2qUUBYMioBD9AINXGs=
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
github.com/klauspost/compress v1.16.5 h1:IFV2oUNUzZaz+XyusxpLzpzS8Pt5rh0Z16For/djlyI=
github.com/klauspost/compress v1.16.5/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
github.com/klauspost/compress v1.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGCFR9I=
github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
@ -61,45 +53,29 @@ github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc=
github.com/montanaflynn/stats v0.7.1 h1:etflOAAHORrCC44V+aR6Ftzort912ZU+YLiSTuV8eaE=
github.com/montanaflynn/stats v0.7.1/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=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/superwhiskers/crunch/v3 v3.5.7 h1:N9RLxaR65C36i26BUIpzPXGy2f6pQ7wisu2bawbKNqg=
github.com/superwhiskers/crunch/v3 v3.5.7/go.mod h1:4ub2EKgF1MAhTjoOCTU4b9uLMsAweHEa89aRrfAypXA=
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/go.mod h1:RaEWvsqvNKKvBPvcKeFjrG2cJqOkHTiyTpzz23ni57g=
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=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
go.mongodb.org/mongo-driver v1.11.7 h1:LIwYxASDLGUg/8wOhgOOZhX8tQa/9tgZPgzZoVqJvcs=
go.mongodb.org/mongo-driver v1.11.7/go.mod h1:G9TgswdsWjX4tmDA5zfs2+6AEPpYJwqblyjsfuh8oXY=
go.mongodb.org/mongo-driver v1.12.0 h1:aPx33jmn/rQuJXPQLZQ8NtfPQG8CaqgLThFtqRb0PiE=
go.mongodb.org/mongo-driver v1.12.0/go.mod h1:AZkxhPnFJUoH7kZlFkVKucV20K387miPfm7oimrSmK0=
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.9.0 h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g=
golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0=
golang.org/x/crypto v0.11.0 h1:6Ewdq3tDic1mg5xRO4milcWCfMVQhI4NkqWWvqejpuA=
golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio=
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 h1:k/i9J1pBpvlfR+9QsetwPyERsqu1GIbi967PQMq3Ivc=
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w=
golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1 h1:MGwJjxBy0HJshjDNfLsYO8xppfqWlA5ZT9OhtUUhTNw=
golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
@ -108,15 +84,10 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL
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-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50=
golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA=
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-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI=
golang.org/x/sync v0.2.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@ -142,8 +113,6 @@ golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
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.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.10.0 h1:UpjohKhiEgNc0CSauXmwYftY1+LlaC75SJwh0SgCX58=
golang.org/x/text v0.10.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4=
golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
@ -151,25 +120,13 @@ golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtn
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/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc h1:XSJ8Vk1SWuNr8S18z1NZSziL0CPIXLCCMDOEFtHBOFc=
google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc/go.mod h1:66JfowdXAEgad5O9NnYcsNPLCPZJD++2L9X0PCMODrA=
google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 h1:bVf09lpb+OJbByTj913DRJioFFAjf/ZGxEz7MajTp2U=
google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98/go.mod h1:TUfxEVdsvPg18p6AslUXFoLdpED4oBnGwyqk3dV1XzM=
google.golang.org/grpc v1.55.0 h1:3Oj82/tFSCeUrRTg/5E/7d/W5A1tj6Ky1ABAuZuv5ag=
google.golang.org/grpc v1.55.0/go.mod h1:iYEXKGkEBhg1PjZQvoYEVPTDkHo1/bjTnfwTeGONTY8=
google.golang.org/grpc v1.56.2 h1:fVRFRnXvU+x6C4IlHZewvJOVHoOv1TUuQyoRsYnB4bI=
google.golang.org/grpc v1.56.2/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s=
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.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng=
google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
google.golang.org/protobuf v1.31.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=
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

View file

@ -2,6 +2,10 @@ package grpc
import (
"context"
"database/sql"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
database_wiiu "github.com/PretendoNetwork/friends-secure/database/wiiu"
pb "github.com/PretendoNetwork/grpc-go/friends"
@ -9,7 +13,12 @@ import (
func (s *gRPCFriendsServer) AcceptFriendRequest(ctx context.Context, in *pb.AcceptFriendRequestRequest) (*pb.AcceptFriendRequestResponse, error) {
friendInfo := database_wiiu.AcceptFriendRequestAndReturnFriendInfo(in.GetFriendRequestId())
friendInfo, err := database_wiiu.AcceptFriendRequestAndReturnFriendInfo(in.GetFriendRequestId())
if err == sql.ErrNoRows {
return &pb.AcceptFriendRequestResponse{
Success: false,
}, status.Errorf(codes.NotFound, "friend request not found")
}
return &pb.AcceptFriendRequestResponse{
Success: friendInfo != nil,

View file

@ -8,10 +8,9 @@ import (
)
func (s *gRPCFriendsServer) DenyFriendRequest(ctx context.Context, in *pb.DenyFriendRequestRequest) (*pb.DenyFriendRequestResponse, error) {
// TODO - Make this return an error
database_wiiu.SetFriendRequestDenied(in.GetFriendRequestId())
err := database_wiiu.SetFriendRequestDenied(in.GetFriendRequestId())
return &pb.DenyFriendRequestResponse{
Success: true,
Success: err == nil,
}, nil
}

View file

@ -24,9 +24,9 @@ func (s *gRPCFriendsServer) SendUserFriendRequest(ctx context.Context, in *pb.Se
message := in.GetMessage()
id := database_wiiu.SaveFriendRequest(sender, recipient, sentTime.Value(), expireTime.Value(), message)
id, _ := database_wiiu.SaveFriendRequest(sender, recipient, sentTime.Value(), expireTime.Value(), message)
return &pb.SendUserFriendRequestResponse{
Success: id == 0,
Success: id != 0,
}, nil
}

View file

@ -15,58 +15,70 @@ import (
account_management_types "github.com/PretendoNetwork/nex-protocols-go/account-management/types"
)
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) uint32 {
if err != nil {
// TODO: Handle error
globals.Logger.Critical(err.Error())
globals.Logger.Error(err.Error())
return nex.Errors.Core.InvalidArgument
}
rmcResponse := nex.NewRMCResponse(account_management.ProtocolID, callID)
var tokenBase64 string
oAuthDataType := oAuthData.TypeName()
if oAuthDataType == "NintendoCreateAccountData" { // Wii U
switch oAuthDataType {
case "NintendoCreateAccountData": // Wii U
nintendoCreateAccountData := oAuthData.ObjectData().(*account_management_types.NintendoCreateAccountData)
tokenBase64 = nintendoCreateAccountData.Token
} else if oAuthDataType == "AccountExtraInfo" { // 3DS
case "AccountExtraInfo": // 3DS
accountExtraInfo := oAuthData.ObjectData().(*account_management_types.AccountExtraInfo)
tokenBase64 = accountExtraInfo.NEXToken
tokenBase64 = strings.Replace(tokenBase64, ".", "+", -1)
tokenBase64 = strings.Replace(tokenBase64, "-", "/", -1)
tokenBase64 = strings.Replace(tokenBase64, "*", "=", -1)
default:
globals.Logger.Errorf("Invalid oAuthData data type %s!", oAuthDataType)
return nex.Errors.Authentication.TokenParseError
}
encryptedToken, _ := base64.StdEncoding.DecodeString(tokenBase64)
encryptedToken, err := base64.StdEncoding.DecodeString(tokenBase64)
if err != nil {
globals.Logger.Error(err.Error())
return nex.Errors.Authentication.TokenParseError
}
decryptedToken, err := utility.DecryptToken(encryptedToken)
if err != nil {
globals.Logger.Error(err.Error())
rmcResponse.SetError(nex.Errors.Authentication.TokenParseError)
} else {
pid := decryptedToken.UserPID
pidByteArray := make([]byte, 4)
binary.LittleEndian.PutUint32(pidByteArray, pid)
mac := hmac.New(md5.New, []byte(strKey))
mac.Write(pidByteArray)
pidHmac := hex.EncodeToString(mac.Sum(nil))
rmcResponseStream := nex.NewStreamOut(globals.SecureServer)
rmcResponseStream.WriteUInt32LE(pid)
rmcResponseStream.WriteString(pidHmac)
rmcResponseBody := rmcResponseStream.Bytes()
rmcResponse.SetSuccess(account_management.MethodNintendoCreateAccount, rmcResponseBody)
return nex.Errors.Authentication.TokenParseError
}
pid := decryptedToken.UserPID
pidByteArray := make([]byte, 4)
binary.LittleEndian.PutUint32(pidByteArray, pid)
mac := hmac.New(md5.New, []byte(strKey))
_, err = mac.Write(pidByteArray)
if err != nil {
globals.Logger.Error(err.Error())
return nex.Errors.Authentication.Unknown
}
pidHmac := hex.EncodeToString(mac.Sum(nil))
rmcResponse := nex.NewRMCResponse(account_management.ProtocolID, callID)
rmcResponseStream := nex.NewStreamOut(globals.SecureServer)
rmcResponseStream.WriteUInt32LE(pid)
rmcResponseStream.WriteString(pidHmac)
rmcResponseBody := rmcResponseStream.Bytes()
rmcResponse.SetSuccess(account_management.MethodNintendoCreateAccount, rmcResponseBody)
rmcResponseBytes := rmcResponse.Bytes()
responsePacket, _ := nex.NewPacketV0(client, nil)
@ -81,4 +93,6 @@ func NintendoCreateAccount(err error, client *nex.Client, callID uint32, strPrin
responsePacket.AddFlag(nex.FlagReliable)
globals.SecureServer.Send(responsePacket)
return 0
}

View file

@ -1,54 +1,73 @@
package nex
import (
"time"
"github.com/PretendoNetwork/friends-secure/globals"
"github.com/PretendoNetwork/friends-secure/types"
nex "github.com/PretendoNetwork/nex-go"
)
func connect(packet *nex.PacketV0) {
packet.Sender().SetClientConnectionSignature(packet.ConnectionSignature())
// * We aren't making any replies here because the common Secure Protocol already does that
// *
// * We only want to check that the data given is right so that we don't register a client
// * with an invalid request
payload := packet.Payload()
stream := nex.NewStreamIn(payload, globals.SecureServer)
ticketData, _ := stream.ReadBuffer()
requestData, _ := stream.ReadBuffer()
ticketData, err := stream.ReadBuffer()
if err != nil {
return
}
requestData, err := stream.ReadBuffer()
if err != nil {
return
}
serverKey := nex.DeriveKerberosKey(2, []byte(globals.SecureServer.KerberosPassword()))
// TODO: use random key from auth server
ticketDataEncryption, _ := nex.NewKerberosEncryption(serverKey)
decryptedTicketData := ticketDataEncryption.Decrypt(ticketData)
ticketDataStream := nex.NewStreamIn(decryptedTicketData, globals.SecureServer)
ticket := nex.NewKerberosTicketInternalData()
err = ticket.Decrypt(nex.NewStreamIn(ticketData, globals.SecureServer), serverKey)
if err != nil {
return
}
_, _ = ticketDataStream.ReadUInt64LE() // expiration time
_, _ = ticketDataStream.ReadUInt32LE() // User PID
sessionKey := ticketDataStream.ReadBytesNext(16)
ticketTime := ticket.Timestamp().Standard()
serverTime := time.Now().UTC()
requestDataEncryption, _ := nex.NewKerberosEncryption(sessionKey)
decryptedRequestData := requestDataEncryption.Decrypt(requestData)
requestDataStream := nex.NewStreamIn(decryptedRequestData, globals.SecureServer)
timeLimit := ticketTime.Add(time.Minute * 2)
if serverTime.After(timeLimit) {
return
}
userPID, _ := requestDataStream.ReadUInt32LE() // User PID
sessionKey := ticket.SessionKey()
kerberos, err := nex.NewKerberosEncryption(sessionKey)
if err != nil {
return
}
_, _ = requestDataStream.ReadUInt32LE() //CID of secure server station url
responseCheck, _ := requestDataStream.ReadUInt32LE()
decryptedRequestData := kerberos.Decrypt(requestData)
checkDataStream := nex.NewStreamIn(decryptedRequestData, globals.SecureServer)
responseValueStream := nex.NewStreamOut(globals.SecureServer)
responseValueStream.WriteUInt32LE(responseCheck + 1)
userPID, err := checkDataStream.ReadUInt32LE()
if err != nil {
return
}
responseValueBufferStream := nex.NewStreamOut(globals.SecureServer)
responseValueBufferStream.WriteBuffer(responseValueStream.Bytes())
_, err = checkDataStream.ReadUInt32LE() // CID of secure server station url
if err != nil {
return
}
packet.Sender().UpdateRC4Key(sessionKey)
globals.SecureServer.AcknowledgePacket(packet, responseValueBufferStream.Bytes())
packet.Sender().SetPID(userPID)
_, err = checkDataStream.ReadUInt32LE() // Response check
if err != nil {
return
}
connectedUser := types.NewConnectedUser()
connectedUser.PID = packet.Sender().PID()
connectedUser.PID = userPID
connectedUser.Client = packet.Sender()
globals.ConnectedUsers[userPID] = connectedUser
}

View file

@ -8,8 +8,17 @@ import (
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends-3ds"
)
func AddFriendshipByPrincipalID(err error, client *nex.Client, callID uint32, lfc uint64, pid uint32) {
friendRelationship := database_3ds.SaveFriendship(client.PID(), pid)
func AddFriendshipByPrincipalID(err error, client *nex.Client, callID uint32, lfc uint64, pid uint32) uint32 {
if err != nil {
globals.Logger.Error(err.Error())
return nex.Errors.FPD.InvalidArgument
}
friendRelationship, err := database_3ds.SaveFriendship(client.PID(), pid)
if err != nil {
globals.Logger.Critical(err.Error())
return nex.Errors.FPD.Unknown
}
connectedUser := globals.ConnectedUsers[pid]
if connectedUser != nil {
@ -39,4 +48,6 @@ func AddFriendshipByPrincipalID(err error, client *nex.Client, callID uint32, lf
responsePacket.AddFlag(nex.FlagReliable)
globals.SecureServer.Send(responsePacket)
return 0
}

View file

@ -7,7 +7,12 @@ import (
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends-3ds"
)
func GetAllFriends(err error, client *nex.Client, callID uint32) {
func GetAllFriends(err error, client *nex.Client, callID uint32) uint32 {
if err != nil {
globals.Logger.Error(err.Error())
return nex.Errors.FPD.Unknown
}
friendRelationships := database_3ds.GetUserFriends(client.PID())
rmcResponseStream := nex.NewStreamOut(globals.SecureServer)
@ -33,4 +38,6 @@ func GetAllFriends(err error, client *nex.Client, callID uint32) {
responsePacket.AddFlag(nex.FlagReliable)
globals.SecureServer.Send(responsePacket)
return 0
}

View file

@ -7,7 +7,12 @@ import (
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends-3ds"
)
func GetFriendMii(err error, client *nex.Client, callID uint32, pids []uint32) {
func GetFriendMii(err error, client *nex.Client, callID uint32, pids []uint32) uint32 {
if err != nil {
globals.Logger.Error(err.Error())
return nex.Errors.FPD.InvalidArgument
}
miiList := database_3ds.GetFriendMiis(pids)
rmcResponseStream := nex.NewStreamOut(globals.SecureServer)
@ -33,4 +38,6 @@ func GetFriendMii(err error, client *nex.Client, callID uint32, pids []uint32) {
responsePacket.AddFlag(nex.FlagReliable)
globals.SecureServer.Send(responsePacket)
return 0
}

View file

@ -7,7 +7,12 @@ import (
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends-3ds"
)
func GetFriendPersistentInfo(err error, client *nex.Client, callID uint32, pids []uint32) {
func GetFriendPersistentInfo(err error, client *nex.Client, callID uint32, pids []uint32) uint32 {
if err != nil {
globals.Logger.Error(err.Error())
return nex.Errors.FPD.Unknown
}
infoList := database_3ds.GetFriendPersistentInfos(client.PID(), pids)
rmcResponseStream := nex.NewStreamOut(globals.SecureServer)
@ -33,4 +38,6 @@ func GetFriendPersistentInfo(err error, client *nex.Client, callID uint32, pids
responsePacket.AddFlag(nex.FlagReliable)
globals.SecureServer.Send(responsePacket)
return 0
}

View file

@ -7,7 +7,12 @@ import (
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/friends-3ds/types"
)
func GetFriendPresence(err error, client *nex.Client, callID uint32, pids []uint32) {
func GetFriendPresence(err error, client *nex.Client, callID uint32, pids []uint32) uint32 {
if err != nil {
globals.Logger.Error(err.Error())
return nex.Errors.FPD.Unknown
}
presenceList := make([]*friends_3ds_types.FriendPresence, 0)
for i := 0; i < len(pids); i++ {
@ -45,4 +50,6 @@ func GetFriendPresence(err error, client *nex.Client, callID uint32, pids []uint
responsePacket.AddFlag(nex.FlagReliable)
globals.SecureServer.Send(responsePacket)
return 0
}

View file

@ -6,7 +6,7 @@ import (
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends-3ds"
)
func GetPrincipalIDByLocalFriendCode(err error, client *nex.Client, callID uint32, lfc uint64, lfcList []uint64) {
func GetPrincipalIDByLocalFriendCode(err error, client *nex.Client, callID uint32, lfc uint64, lfcList []uint64) uint32 {
// Respond with unimplemented, waiting for gRPC to retrieve PID from account server
rmcResponse := nex.NewRMCResponse(friends_3ds.ProtocolID, callID)
@ -26,4 +26,6 @@ func GetPrincipalIDByLocalFriendCode(err error, client *nex.Client, callID uint3
responsePacket.AddFlag(nex.FlagReliable)
globals.SecureServer.Send(responsePacket)
return 0
}

View file

@ -6,7 +6,7 @@ import (
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends-3ds"
)
func RemoveFriendByLocalFriendCode(err error, client *nex.Client, callID uint32, friendLFC uint64) {
func RemoveFriendByLocalFriendCode(err error, client *nex.Client, callID uint32, friendLFC uint64) uint32 {
// Respond with unimplemented, waiting for gRPC to retrieve PID from account server
rmcResponse := nex.NewRMCResponse(friends_3ds.ProtocolID, callID)
@ -26,4 +26,6 @@ func RemoveFriendByLocalFriendCode(err error, client *nex.Client, callID uint32,
responsePacket.AddFlag(nex.FlagReliable)
globals.SecureServer.Send(responsePacket)
return 0
}

View file

@ -8,9 +8,19 @@ import (
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends-3ds"
)
func RemoveFriendByPrincipalID(err error, client *nex.Client, callID uint32, pid uint32) {
func RemoveFriendByPrincipalID(err error, client *nex.Client, callID uint32, pid uint32) uint32 {
if err != nil {
globals.Logger.Error(err.Error())
return nex.Errors.FPD.InvalidArgument
}
err = database_3ds.RemoveFriendship(client.PID(), pid)
if err != nil {
globals.Logger.Critical(err.Error())
return nex.Errors.FPD.Unknown
}
go notifications_3ds.SendUserWentOffline(client, pid)
database_3ds.RemoveFriendship(client.PID(), pid)
rmcResponse := nex.NewRMCResponse(friends_3ds.ProtocolID, callID)
rmcResponse.SetSuccess(friends_3ds.MethodRemoveFriendByPrincipalID, nil)
@ -29,4 +39,6 @@ func RemoveFriendByPrincipalID(err error, client *nex.Client, callID uint32, pid
responsePacket.AddFlag(nex.FlagReliable)
globals.SecureServer.Send(responsePacket)
return 0
}

View file

@ -10,18 +10,31 @@ import (
"golang.org/x/exp/slices"
)
func SyncFriend(err error, client *nex.Client, callID uint32, lfc uint64, pids []uint32, lfcList []uint64) {
func SyncFriend(err error, client *nex.Client, callID uint32, lfc uint64, pids []uint32, lfcList []uint64) uint32 {
if err != nil {
globals.Logger.Error(err.Error())
return nex.Errors.FPD.InvalidArgument
}
friendRelationships := database_3ds.GetUserFriends(client.PID())
for i := 0; i < len(friendRelationships); i++ {
if !slices.Contains(pids, friendRelationships[i].PID) {
database_3ds.RemoveFriendship(client.PID(), friendRelationships[i].PID)
err := database_3ds.RemoveFriendship(client.PID(), friendRelationships[i].PID)
if err != nil {
globals.Logger.Critical(err.Error())
return nex.Errors.FPD.Unknown
}
}
}
for i := 0; i < len(pids); i++ {
if !isPIDInRelationships(friendRelationships, pids[i]) {
friendRelationship := database_3ds.SaveFriendship(client.PID(), pids[i])
friendRelationship, err := database_3ds.SaveFriendship(client.PID(), pids[i])
if err != nil {
globals.Logger.Critical(err.Error())
return nex.Errors.FPD.Unknown
}
friendRelationships = append(friendRelationships, friendRelationship)
@ -56,6 +69,8 @@ func SyncFriend(err error, client *nex.Client, callID uint32, lfc uint64, pids [
responsePacket.AddFlag(nex.FlagReliable)
globals.SecureServer.Send(responsePacket)
return 0
}
func isPIDInRelationships(relationships []*friends_3ds_types.FriendRelationship, pid uint32) bool {

View file

@ -8,9 +8,20 @@ import (
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends-3ds"
)
func UpdateComment(err error, client *nex.Client, callID uint32, comment string) {
func UpdateComment(err error, client *nex.Client, callID uint32, comment string) uint32 {
if err != nil {
globals.Logger.Error(err.Error())
return nex.Errors.FPD.InvalidArgument
}
err = database_3ds.UpdateUserComment(client.PID(), comment)
if err != nil {
globals.Logger.Critical(err.Error())
return nex.Errors.FPD.Unknown
}
go notifications_3ds.SendCommentUpdate(client, comment)
database_3ds.UpdateUserComment(client.PID(), comment)
rmcResponse := nex.NewRMCResponse(friends_3ds.ProtocolID, callID)
rmcResponse.SetSuccess(friends_3ds.MethodUpdateComment, nil)
@ -29,4 +40,6 @@ func UpdateComment(err error, client *nex.Client, callID uint32, comment string)
responsePacket.AddFlag(nex.FlagReliable)
globals.SecureServer.Send(responsePacket)
return 0
}

View file

@ -9,9 +9,19 @@ import (
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/friends-3ds/types"
)
func UpdateFavoriteGameKey(err error, client *nex.Client, callID uint32, gameKey *friends_3ds_types.GameKey) {
func UpdateFavoriteGameKey(err error, client *nex.Client, callID uint32, gameKey *friends_3ds_types.GameKey) uint32 {
if err != nil {
globals.Logger.Error(err.Error())
return nex.Errors.FPD.InvalidArgument
}
err = database_3ds.UpdateUserFavoriteGame(client.PID(), gameKey)
if err != nil {
globals.Logger.Critical(err.Error())
return nex.Errors.FPD.Unknown
}
go notifications_3ds.SendFavoriteUpdate(client, gameKey)
database_3ds.UpdateUserFavoriteGame(client.PID(), gameKey)
rmcResponse := nex.NewRMCResponse(friends_3ds.ProtocolID, callID)
rmcResponse.SetSuccess(friends_3ds.MethodUpdateFavoriteGameKey, nil)
@ -30,4 +40,6 @@ func UpdateFavoriteGameKey(err error, client *nex.Client, callID uint32, gameKey
responsePacket.AddFlag(nex.FlagReliable)
globals.SecureServer.Send(responsePacket)
return 0
}

View file

@ -9,9 +9,19 @@ import (
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/friends-3ds/types"
)
func UpdateMii(err error, client *nex.Client, callID uint32, mii *friends_3ds_types.Mii) {
func UpdateMii(err error, client *nex.Client, callID uint32, mii *friends_3ds_types.Mii) uint32 {
if err != nil {
globals.Logger.Error(err.Error())
return nex.Errors.FPD.InvalidArgument
}
err = database_3ds.UpdateUserMii(client.PID(), mii)
if err != nil {
globals.Logger.Critical(err.Error())
return nex.Errors.FPD.Unknown
}
go notifications_3ds.SendMiiUpdateNotification(client)
database_3ds.UpdateUserMii(client.PID(), mii)
rmcResponse := nex.NewRMCResponse(friends_3ds.ProtocolID, callID)
rmcResponse.SetSuccess(friends_3ds.MethodUpdateMii, nil)
@ -30,4 +40,6 @@ func UpdateMii(err error, client *nex.Client, callID uint32, mii *friends_3ds_ty
responsePacket.AddFlag(nex.FlagReliable)
globals.SecureServer.Send(responsePacket)
return 0
}

View file

@ -9,7 +9,18 @@ import (
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/friends-3ds/types"
)
func UpdatePreference(err error, client *nex.Client, callID uint32, showOnline bool, showCurrentGame bool, showPlayedGame bool) {
func UpdatePreference(err error, client *nex.Client, callID uint32, showOnline bool, showCurrentGame bool, showPlayedGame bool) uint32 {
if err != nil {
globals.Logger.Error(err.Error())
return nex.Errors.FPD.InvalidArgument
}
err = database_3ds.UpdateUserPreferences(client.PID(), showOnline, showCurrentGame)
if err != nil {
globals.Logger.Critical(err.Error())
return nex.Errors.FPD.Unknown
}
if !showCurrentGame {
emptyPresence := friends_3ds_types.NewNintendoPresence()
emptyPresence.GameKey = friends_3ds_types.NewGameKey()
@ -20,8 +31,6 @@ func UpdatePreference(err error, client *nex.Client, callID uint32, showOnline b
notifications_3ds.SendUserWentOfflineGlobally(client)
}
database_3ds.UpdateUserPreferences(client.PID(), showOnline, showCurrentGame)
rmcResponse := nex.NewRMCResponse(friends_3ds.ProtocolID, callID)
rmcResponse.SetSuccess(friends_3ds.MethodUpdatePreference, nil)
@ -39,4 +48,6 @@ func UpdatePreference(err error, client *nex.Client, callID uint32, showOnline b
responsePacket.AddFlag(nex.FlagReliable)
globals.SecureServer.Send(responsePacket)
return 0
}

View file

@ -9,7 +9,12 @@ import (
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/friends-3ds/types"
)
func UpdatePresence(err error, client *nex.Client, callID uint32, presence *friends_3ds_types.NintendoPresence, showGame bool) {
func UpdatePresence(err error, client *nex.Client, callID uint32, presence *friends_3ds_types.NintendoPresence, showGame bool) uint32 {
if err != nil {
globals.Logger.Error(err.Error())
return nex.Errors.FPD.InvalidArgument
}
currentPresence := presence
// Send an entirely empty status, with every flag set to update
@ -52,4 +57,6 @@ func UpdatePresence(err error, client *nex.Client, callID uint32, presence *frie
responsePacket.AddFlag(nex.FlagReliable)
globals.SecureServer.Send(responsePacket)
return 0
}

View file

@ -8,8 +8,17 @@ import (
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/friends-3ds/types"
)
func UpdateProfile(err error, client *nex.Client, callID uint32, profileData *friends_3ds_types.MyProfile) {
database_3ds.UpdateUserProfile(client.PID(), profileData)
func UpdateProfile(err error, client *nex.Client, callID uint32, profileData *friends_3ds_types.MyProfile) uint32 {
if err != nil {
globals.Logger.Error(err.Error())
return nex.Errors.FPD.InvalidArgument
}
err = database_3ds.UpdateUserProfile(client.PID(), profileData)
if err != nil {
globals.Logger.Critical(err.Error())
return nex.Errors.FPD.Unknown
}
rmcResponse := nex.NewRMCResponse(friends_3ds.ProtocolID, callID)
rmcResponse.SetSuccess(friends_3ds.MethodUpdateProfile, nil)
@ -28,4 +37,6 @@ func UpdateProfile(err error, client *nex.Client, callID uint32, profileData *fr
responsePacket.AddFlag(nex.FlagReliable)
globals.SecureServer.Send(responsePacket)
return 0
}

View file

@ -1,6 +1,8 @@
package nex_friends_wiiu
import (
"database/sql"
database_wiiu "github.com/PretendoNetwork/friends-secure/database/wiiu"
"github.com/PretendoNetwork/friends-secure/globals"
notifications_wiiu "github.com/PretendoNetwork/friends-secure/notifications/wiiu"
@ -9,8 +11,21 @@ import (
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
)
func AcceptFriendRequest(err error, client *nex.Client, callID uint32, id uint64) {
friendInfo := database_wiiu.AcceptFriendRequestAndReturnFriendInfo(id)
func AcceptFriendRequest(err error, client *nex.Client, callID uint32, id uint64) uint32 {
if err != nil {
globals.Logger.Error(err.Error())
return nex.Errors.FPD.InvalidArgument
}
friendInfo, err := database_wiiu.AcceptFriendRequestAndReturnFriendInfo(id)
if err != nil {
if err == sql.ErrNoRows {
return nex.Errors.FPD.InvalidMessageID
} else {
globals.Logger.Critical(err.Error())
return nex.Errors.FPD.Unknown
}
}
friendPID := friendInfo.NNAInfo.PrincipalBasicInfo.PID
connectedUser := globals.ConnectedUsers[friendPID]
@ -55,4 +70,6 @@ func AcceptFriendRequest(err error, client *nex.Client, callID uint32, id uint64
responsePacket.AddFlag(nex.FlagReliable)
globals.SecureServer.Send(responsePacket)
return 0
}

View file

@ -10,7 +10,12 @@ import (
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
)
func AddBlacklist(err error, client *nex.Client, callID uint32, blacklistPrincipal *friends_wiiu_types.BlacklistedPrincipal) {
func AddBlacklist(err error, client *nex.Client, callID uint32, blacklistPrincipal *friends_wiiu_types.BlacklistedPrincipal) uint32 {
if err != nil {
globals.Logger.Error(err.Error())
return nex.Errors.FPD.InvalidArgument
}
currentBlacklistPrincipal := blacklistPrincipal
senderPID := currentBlacklistPrincipal.PrincipalBasicInfo.PID
@ -22,32 +27,18 @@ func AddBlacklist(err error, client *nex.Client, callID uint32, blacklistPrincip
userInfo := database_wiiu.GetUserInfoByPID(currentBlacklistPrincipal.PrincipalBasicInfo.PID)
if userInfo == nil {
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()
responsePacket, _ := nex.NewPacketV0(client, nil)
responsePacket.SetVersion(0)
responsePacket.SetSource(0xA1)
responsePacket.SetDestination(0xAF)
responsePacket.SetType(nex.DataPacket)
responsePacket.SetPayload(rmcResponseBytes)
responsePacket.AddFlag(nex.FlagNeedsAck)
responsePacket.AddFlag(nex.FlagReliable)
globals.SecureServer.Send(responsePacket)
return
if userInfo.PID == 0 {
return nex.Errors.FPD.InvalidPrincipalID // TODO: Not sure if this is the correct error.
}
currentBlacklistPrincipal.PrincipalBasicInfo = userInfo
currentBlacklistPrincipal.BlackListedSince = date
database_wiiu.SetUserBlocked(client.PID(), senderPID, titleID, titleVersion)
err = database_wiiu.SetUserBlocked(client.PID(), senderPID, titleID, titleVersion)
if err != nil {
globals.Logger.Critical(err.Error())
return nex.Errors.FPD.Unknown
}
rmcResponseStream := nex.NewStreamOut(globals.SecureServer)
@ -73,4 +64,6 @@ func AddBlacklist(err error, client *nex.Client, callID uint32, blacklistPrincip
responsePacket.AddFlag(nex.FlagReliable)
globals.SecureServer.Send(responsePacket)
return 0
}

View file

@ -1,7 +1,6 @@
package nex_friends_wiiu
import (
"fmt"
"time"
database_wiiu "github.com/PretendoNetwork/friends-secure/database/wiiu"
@ -12,33 +11,19 @@ import (
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
)
func AddFriendRequest(err error, client *nex.Client, callID uint32, pid uint32, unknown2 uint8, message string, unknown4 uint8, unknown5 string, gameKey *friends_wiiu_types.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_types.GameKey, unknown6 *nex.DateTime) uint32 {
if err != nil {
globals.Logger.Error(err.Error())
return nex.Errors.FPD.InvalidArgument
}
senderPID := client.PID()
recipientPID := pid
recipient := database_wiiu.GetUserInfoByPID(recipientPID)
if recipient == nil {
globals.Logger.Error(fmt.Sprintf("User %d has sent friend request to invalid PID %d", senderPID, pid))
rmcResponse := nex.NewRMCResponse(friends_wiiu.ProtocolID, callID)
rmcResponse.SetError(nex.Errors.FPD.InvalidPrincipalID) // TODO - Is this the right error?
rmcResponseBytes := rmcResponse.Bytes()
responsePacket, _ := nex.NewPacketV0(client, nil)
responsePacket.SetVersion(0)
responsePacket.SetSource(0xA1)
responsePacket.SetDestination(0xAF)
responsePacket.SetType(nex.DataPacket)
responsePacket.SetPayload(rmcResponseBytes)
responsePacket.AddFlag(nex.FlagNeedsAck)
responsePacket.AddFlag(nex.FlagReliable)
globals.SecureServer.Send(responsePacket)
return
if recipient.PID == 0 {
globals.Logger.Errorf("User %d has sent friend request to invalid PID %d", senderPID, pid)
return nex.Errors.FPD.InvalidPrincipalID
}
currentTimestamp := time.Now()
@ -50,7 +35,11 @@ func AddFriendRequest(err error, client *nex.Client, callID uint32, pid uint32,
sentTime.FromTimestamp(currentTimestamp)
expireTime.FromTimestamp(expireTimestamp)
friendRequestID := database_wiiu.SaveFriendRequest(senderPID, recipientPID, sentTime.Value(), expireTime.Value(), message)
friendRequestID, err := database_wiiu.SaveFriendRequest(senderPID, recipientPID, sentTime.Value(), expireTime.Value(), message)
if err != nil {
globals.Logger.Critical(err.Error())
return nex.Errors.FPD.Unknown
}
friendRequest := friends_wiiu_types.NewFriendRequest()
@ -79,7 +68,7 @@ func AddFriendRequest(err error, client *nex.Client, callID uint32, pid uint32,
friendInfo.NNAInfo.PrincipalBasicInfo.Mii.Name = ""
friendInfo.NNAInfo.PrincipalBasicInfo.Mii.Unknown1 = 0
friendInfo.NNAInfo.PrincipalBasicInfo.Mii.Unknown2 = 0
friendInfo.NNAInfo.PrincipalBasicInfo.Mii.Data = []byte{}
friendInfo.NNAInfo.PrincipalBasicInfo.Mii.MiiData = []byte{}
friendInfo.NNAInfo.PrincipalBasicInfo.Mii.Datetime = nex.NewDateTime(0)
friendInfo.NNAInfo.PrincipalBasicInfo.Unknown = 0
friendInfo.NNAInfo.Unknown1 = 0
@ -159,4 +148,6 @@ func AddFriendRequest(err error, client *nex.Client, callID uint32, pid uint32,
responsePacket.AddFlag(nex.FlagReliable)
globals.SecureServer.Send(responsePacket)
return 0
}

View file

@ -1,6 +1,8 @@
package nex_friends_wiiu
import (
"database/sql"
database_wiiu "github.com/PretendoNetwork/friends-secure/database/wiiu"
"github.com/PretendoNetwork/friends-secure/globals"
notifications_wiiu "github.com/PretendoNetwork/friends-secure/notifications/wiiu"
@ -8,8 +10,21 @@ import (
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu"
)
func CancelFriendRequest(err error, client *nex.Client, callID uint32, id uint64) {
pid := database_wiiu.DeleteFriendRequestAndReturnFriendPID(id)
func CancelFriendRequest(err error, client *nex.Client, callID uint32, id uint64) uint32 {
if err != nil {
globals.Logger.Error(err.Error())
return nex.Errors.FPD.InvalidArgument
}
pid, err := database_wiiu.DeleteFriendRequestAndReturnFriendPID(id)
if err != nil {
if err == sql.ErrNoRows {
return nex.Errors.FPD.InvalidMessageID
} else {
globals.Logger.Critical(err.Error())
return nex.Errors.FPD.Unknown
}
}
connectedUser := globals.ConnectedUsers[pid]
if connectedUser != nil {
@ -34,4 +49,6 @@ func CancelFriendRequest(err error, client *nex.Client, callID uint32, id uint64
responsePacket.AddFlag(nex.FlagReliable)
globals.SecureServer.Send(responsePacket)
return 0
}

View file

@ -6,7 +6,12 @@ import (
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu"
)
func CheckSettingStatus(err error, client *nex.Client, callID uint32) {
func CheckSettingStatus(err error, client *nex.Client, callID uint32) uint32 {
if err != nil {
globals.Logger.Error(err.Error())
return nex.Errors.FPD.Unknown
}
rmcResponseStream := nex.NewStreamOut(globals.SecureServer)
rmcResponseStream.WriteUInt8(0xFF)
@ -31,4 +36,6 @@ func CheckSettingStatus(err error, client *nex.Client, callID uint32) {
responsePacket.AddFlag(nex.FlagReliable)
globals.SecureServer.Send(responsePacket)
return 0
}

View file

@ -7,8 +7,17 @@ import (
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)
func DeleteFriendRequest(err error, client *nex.Client, callID uint32, id uint64) uint32 {
if err != nil {
globals.Logger.Error(err.Error())
return nex.Errors.FPD.InvalidArgument
}
err = database_wiiu.SetFriendRequestDenied(id)
if err != nil {
globals.Logger.Critical(err.Error())
return nex.Errors.FPD.Unknown
}
rmcResponse := nex.NewRMCResponse(friends_wiiu.ProtocolID, callID)
rmcResponse.SetSuccess(friends_wiiu.MethodDeleteFriendRequest, nil)
@ -27,4 +36,6 @@ func DeleteFriendRequest(err error, client *nex.Client, callID uint32, id uint64
responsePacket.AddFlag(nex.FlagReliable)
globals.SecureServer.Send(responsePacket)
return 0
}

View file

@ -7,7 +7,12 @@ import (
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
)
func DeletePersistentNotification(err error, client *nex.Client, callID uint32, notifications []*friends_wiiu_types.PersistentNotification) {
func DeletePersistentNotification(err error, client *nex.Client, callID uint32, notifications []*friends_wiiu_types.PersistentNotification) uint32 {
if err != nil {
globals.Logger.Error(err.Error())
return nex.Errors.FPD.InvalidArgument
}
// TODO: Do something here
rmcResponse := nex.NewRMCResponse(friends_wiiu.ProtocolID, callID)
@ -27,4 +32,6 @@ func DeletePersistentNotification(err error, client *nex.Client, callID uint32,
responsePacket.AddFlag(nex.FlagReliable)
globals.SecureServer.Send(responsePacket)
return 0
}

View file

@ -10,11 +10,24 @@ import (
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
)
func DenyFriendRequest(err error, client *nex.Client, callID uint32, id uint64) {
database_wiiu.SetFriendRequestDenied(id)
func DenyFriendRequest(err error, client *nex.Client, callID uint32, id uint64) uint32 {
if err != nil {
globals.Logger.Error(err.Error())
return nex.Errors.FPD.InvalidArgument
}
err = database_wiiu.SetFriendRequestDenied(id)
if err != nil {
globals.Logger.Critical(err.Error())
return nex.Errors.FPD.Unknown
}
senderPID, _ := database_wiiu.GetPIDsByFriendRequestID(id)
database_wiiu.SetUserBlocked(client.PID(), senderPID, 0, 0)
err = database_wiiu.SetUserBlocked(client.PID(), senderPID, 0, 0)
if err != nil {
globals.Logger.Critical(err.Error())
return nex.Errors.FPD.Unknown
}
info := database_wiiu.GetUserInfoByPID(senderPID)
@ -52,4 +65,6 @@ func DenyFriendRequest(err error, client *nex.Client, callID uint32, id uint64)
responsePacket.AddFlag(nex.FlagReliable)
globals.SecureServer.Send(responsePacket)
return 0
}

View file

@ -8,14 +8,19 @@ import (
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
)
func GetBasicInfo(err error, client *nex.Client, callID uint32, pids []uint32) {
func GetBasicInfo(err error, client *nex.Client, callID uint32, pids []uint32) uint32 {
if err != nil {
globals.Logger.Error(err.Error())
return nex.Errors.FPD.InvalidArgument
}
infos := make([]*friends_wiiu_types.PrincipalBasicInfo, 0)
for i := 0; i < len(pids); i++ {
pid := pids[i]
info := database_wiiu.GetUserInfoByPID(pid)
if info != nil {
if info.PID != 0 {
infos = append(infos, info)
}
}
@ -44,4 +49,6 @@ func GetBasicInfo(err error, client *nex.Client, callID uint32, pids []uint32) {
responsePacket.AddFlag(nex.FlagReliable)
globals.SecureServer.Send(responsePacket)
return 0
}

View file

@ -8,7 +8,12 @@ import (
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
)
func GetRequestBlockSettings(err error, client *nex.Client, callID uint32, pids []uint32) {
func GetRequestBlockSettings(err error, client *nex.Client, callID uint32, pids []uint32) uint32 {
if err != nil {
globals.Logger.Error(err.Error())
return nex.Errors.FPD.InvalidArgument
}
settings := make([]*friends_wiiu_types.PrincipalRequestBlockSetting, 0)
// TODO:
@ -47,4 +52,6 @@ func GetRequestBlockSettings(err error, client *nex.Client, callID uint32, pids
responsePacket.AddFlag(nex.FlagReliable)
globals.SecureServer.Send(responsePacket)
return 0
}

View file

@ -7,10 +7,24 @@ import (
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu"
)
func MarkFriendRequestsAsReceived(err error, client *nex.Client, callID uint32, ids []uint64) {
func MarkFriendRequestsAsReceived(err error, client *nex.Client, callID uint32, ids []uint64) uint32 {
if err != nil {
globals.Logger.Error(err.Error())
return nex.Errors.FPD.InvalidArgument
}
var markErr error
for i := 0; i < len(ids); i++ {
id := ids[i]
database_wiiu.SetFriendRequestReceived(id)
err = database_wiiu.SetFriendRequestReceived(id)
if err != nil {
globals.Logger.Critical(err.Error())
markErr = err
}
}
if markErr != nil {
return nex.Errors.FPD.Unknown
}
rmcResponse := nex.NewRMCResponse(friends_wiiu.ProtocolID, callID)
@ -30,4 +44,6 @@ func MarkFriendRequestsAsReceived(err error, client *nex.Client, callID uint32,
responsePacket.AddFlag(nex.FlagReliable)
globals.SecureServer.Send(responsePacket)
return 0
}

View file

@ -7,8 +7,17 @@ import (
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)
func RemoveBlacklist(err error, client *nex.Client, callID uint32, blockedPID uint32) uint32 {
if err != nil {
globals.Logger.Error(err.Error())
return nex.Errors.FPD.InvalidArgument
}
err = database_wiiu.UnsetUserBlocked(client.PID(), blockedPID)
if err != nil {
globals.Logger.Critical(err.Error())
return nex.Errors.FPD.Unknown
}
rmcResponse := nex.NewRMCResponse(friends_wiiu.ProtocolID, callID)
rmcResponse.SetSuccess(friends_wiiu.MethodRemoveBlackList, nil)
@ -27,4 +36,6 @@ func RemoveBlacklist(err error, client *nex.Client, callID uint32, blockedPID ui
responsePacket.AddFlag(nex.FlagReliable)
globals.SecureServer.Send(responsePacket)
return 0
}

View file

@ -8,14 +8,23 @@ import (
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu"
)
func RemoveFriend(err error, client *nex.Client, callID uint32, pid uint32) {
func RemoveFriend(err error, client *nex.Client, callID uint32, pid uint32) uint32 {
if err != nil {
globals.Logger.Error(err.Error())
return nex.Errors.FPD.InvalidArgument
}
err = database_wiiu.RemoveFriendship(client.PID(), pid)
if err != nil {
globals.Logger.Critical(err.Error())
return nex.Errors.FPD.Unknown
}
connectedUser := globals.ConnectedUsers[pid]
if connectedUser != nil {
go notifications_wiiu.SendFriendshipRemoved(connectedUser.Client, pid)
}
database_wiiu.RemoveFriendship(client.PID(), pid)
rmcResponse := nex.NewRMCResponse(friends_wiiu.ProtocolID, callID)
rmcResponse.SetSuccess(friends_wiiu.MethodRemoveFriend, nil)
@ -33,4 +42,6 @@ func RemoveFriend(err error, client *nex.Client, callID uint32, pid uint32) {
responsePacket.AddFlag(nex.FlagReliable)
globals.SecureServer.Send(responsePacket)
return 0
}

View file

@ -12,11 +12,10 @@ import (
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
)
func UpdateAndGetAllInformation(err error, client *nex.Client, callID uint32, nnaInfo *friends_wiiu_types.NNAInfo, presence *friends_wiiu_types.NintendoPresenceV2, birthday *nex.DateTime) {
func UpdateAndGetAllInformation(err error, client *nex.Client, callID uint32, nnaInfo *friends_wiiu_types.NNAInfo, presence *friends_wiiu_types.NintendoPresenceV2, birthday *nex.DateTime) uint32 {
if err != nil {
// TODO: Handle error
globals.Logger.Critical(err.Error())
globals.Logger.Error(err.Error())
return nex.Errors.FPD.InvalidArgument
}
// Update user information
@ -72,7 +71,7 @@ func UpdateAndGetAllInformation(err error, client *nex.Client, callID uint32, nn
bella.NNAInfo.PrincipalBasicInfo.Mii.Name = "bella"
bella.NNAInfo.PrincipalBasicInfo.Mii.Unknown1 = 0
bella.NNAInfo.PrincipalBasicInfo.Mii.Unknown2 = 0
bella.NNAInfo.PrincipalBasicInfo.Mii.Data = []byte{
bella.NNAInfo.PrincipalBasicInfo.Mii.MiiData = []byte{
0x03, 0x00, 0x00, 0x40, 0xE9, 0x55, 0xA2, 0x09,
0xE7, 0xC7, 0x41, 0x82, 0xD9, 0x7D, 0x0B, 0x2D,
0x03, 0xB3, 0xB8, 0x8D, 0x27, 0xD9, 0x00, 0x00,
@ -156,4 +155,6 @@ func UpdateAndGetAllInformation(err error, client *nex.Client, callID uint32, nn
responsePacket.AddFlag(nex.FlagReliable)
globals.SecureServer.Send(responsePacket)
return 0
}

View file

@ -8,10 +8,17 @@ import (
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
)
func UpdateComment(err error, client *nex.Client, callID uint32, comment *friends_wiiu_types.Comment) {
// TODO: Do something with this
func UpdateComment(err error, client *nex.Client, callID uint32, comment *friends_wiiu_types.Comment) uint32 {
if err != nil {
globals.Logger.Error(err.Error())
return nex.Errors.FPD.InvalidArgument
}
changed := database_wiiu.UpdateUserComment(client.PID(), comment.Contents)
changed, err := database_wiiu.UpdateUserComment(client.PID(), comment.Contents)
if err != nil {
globals.Logger.Critical(err.Error())
return nex.Errors.FPD.Unknown
}
rmcResponseStream := nex.NewStreamOut(globals.SecureServer)
@ -36,4 +43,6 @@ func UpdateComment(err error, client *nex.Client, callID uint32, comment *friend
responsePacket.AddFlag(nex.FlagReliable)
globals.SecureServer.Send(responsePacket)
return 0
}

View file

@ -8,8 +8,17 @@ import (
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
)
func UpdatePreference(err error, client *nex.Client, callID uint32, principalPreference *friends_wiiu_types.PrincipalPreference) {
database_wiiu.UpdateUserPrincipalPreference(client.PID(), principalPreference)
func UpdatePreference(err error, client *nex.Client, callID uint32, principalPreference *friends_wiiu_types.PrincipalPreference) uint32 {
if err != nil {
globals.Logger.Error(err.Error())
return nex.Errors.FPD.InvalidArgument
}
err = database_wiiu.UpdateUserPrincipalPreference(client.PID(), principalPreference)
if err != nil {
globals.Logger.Critical(err.Error())
return nex.Errors.FPD.Unknown
}
rmcResponse := nex.NewRMCResponse(friends_wiiu.ProtocolID, callID)
rmcResponse.SetSuccess(friends_wiiu.MethodUpdatePreference, nil)
@ -28,4 +37,6 @@ func UpdatePreference(err error, client *nex.Client, callID uint32, principalPre
responsePacket.AddFlag(nex.FlagReliable)
globals.SecureServer.Send(responsePacket)
return 0
}

View file

@ -9,7 +9,12 @@ import (
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
)
func UpdatePresence(err error, client *nex.Client, callID uint32, presence *friends_wiiu_types.NintendoPresenceV2) {
func UpdatePresence(err error, client *nex.Client, callID uint32, presence *friends_wiiu_types.NintendoPresenceV2) uint32 {
if err != nil {
globals.Logger.Error(err.Error())
return nex.Errors.FPD.InvalidArgument
}
pid := client.PID()
presence.Online = true // Force online status. I have no idea why this is always false
@ -47,4 +52,6 @@ func UpdatePresence(err error, client *nex.Client, callID uint32, presence *frie
responsePacket.AddFlag(nex.FlagReliable)
globals.SecureServer.Send(responsePacket)
return 0
}

View file

@ -11,9 +11,9 @@ import (
)
func registerSecureServerProtocols() {
accountManagementProtocol := account_management.NewAccountManagementProtocol(globals.SecureServer)
friendsWiiUProtocol := friends_wiiu.NewFriendsWiiUProtocol(globals.SecureServer)
friends3DSProtocol := friends_3ds.NewFriends3DSProtocol(globals.SecureServer)
accountManagementProtocol := account_management.NewProtocol(globals.SecureServer)
friendsWiiUProtocol := friends_wiiu.NewProtocol(globals.SecureServer)
friends3DSProtocol := friends_3ds.NewProtocol(globals.SecureServer)
// Account Management protocol handles
accountManagementProtocol.NintendoCreateAccount(nex_account_management.NintendoCreateAccount)

View file

@ -12,22 +12,31 @@ import (
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) {
// TODO: Validate loginData
func RegisterEx(err error, client *nex.Client, callID uint32, stationUrls []*nex.StationURL, loginData *nex.DataHolder) uint32 {
if err != nil {
globals.Logger.Error(err.Error())
return nex.Errors.Core.InvalidArgument
}
// TODO: Validate loginData
pid := client.PID()
user := globals.ConnectedUsers[pid]
lastOnline := nex.NewDateTime(0)
lastOnline.FromTimestamp(time.Now())
if loginData.TypeName() == "NintendoLoginData" {
loginDataType := loginData.TypeName()
switch loginDataType {
case "NintendoLoginData":
user.Platform = types.WUP // Platform is Wii U
database_wiiu.UpdateUserLastOnlineTime(pid, lastOnline)
} else if loginData.TypeName() == "AccountExtraInfo" {
case "AccountExtraInfo":
user.Platform = types.CTR // Platform is 3DS
database_3ds.UpdateUserLastOnlineTime(pid, lastOnline)
default:
globals.Logger.Errorf("Unknown loginData data type %s!", loginDataType)
return nex.Errors.Authentication.TokenParseError
}
localStation := stationUrls[0]
@ -67,4 +76,6 @@ func RegisterEx(err error, client *nex.Client, callID uint32, stationUrls []*nex
responsePacket.AddFlag(nex.FlagReliable)
globals.SecureServer.Send(responsePacket)
return 0
}