mirror of
https://github.com/PretendoNetwork/friends.git
synced 2026-04-25 23:37:46 -05:00
rewrite: Migrate to v2 libraries and small bug fixes
This commit is contained in:
parent
b5d34d8db4
commit
4d299a3612
27
README.md
27
README.md
|
|
@ -84,16 +84,17 @@ All configuration options are handled via environment variables
|
|||
|
||||
`.env` files are supported
|
||||
|
||||
| Name | Description | Required |
|
||||
|-----------------------------------------|------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------|
|
||||
| `PN_FRIENDS_CONFIG_DATABASE_URI` | Fully qualified URI to your Postgres server (Example `postgres://username:password@localhost/friends?sslmode=disable`) | Yes |
|
||||
| `PN_FRIENDS_CONFIG_KERBEROS_PASSWORD` | Password used as part of the internal server data in Kerberos tickets | No (Default password `password` will be used) |
|
||||
| `PN_FRIENDS_CONFIG_AES_KEY` | AES key used in tokens provided by the account server | Yes |
|
||||
| `PN_FRIENDS_CONFIG_GRPC_API_KEY` | API key for your GRPC server | No (Assumed to be an open gRPC API) |
|
||||
| `PN_FRIENDS_GRPC_SERVER_PORT` | Port for the GRPC server | Yes |
|
||||
| `PN_FRIENDS_AUTHENTICATION_SERVER_PORT` | Port for the authentication server | Yes |
|
||||
| `PN_FRIENDS_SECURE_SERVER_HOST` | Host name for the secure server (should point to the same address as the authentication server) | Yes |
|
||||
| `PN_FRIENDS_SECURE_SERVER_PORT` | Port for the secure server | Yes |
|
||||
| `PN_FRIENDS_ACCOUNT_GRPC_HOST` | Host name for your account server gRPC service | Yes |
|
||||
| `PN_FRIENDS_ACCOUNT_GRPC_PORT` | Port for your account server gRPC service | Yes |
|
||||
| `PN_FRIENDS_ACCOUNT_GRPC_API_KEY` | API key for your account server gRPC service | No (Assumed to be an open gRPC API) |
|
||||
| Name | Description | Required |
|
||||
|---------------------------------------------|------------------------------------------------------------------------------------------------------------------------|-------------------------------------|
|
||||
| `PN_FRIENDS_CONFIG_DATABASE_URI` | Fully qualified URI to your Postgres server (Example `postgres://username:password@localhost/friends?sslmode=disable`) | Yes |
|
||||
| `PN_FRIENDS_CONFIG_AUTHENTICATION_PASSWORD` | The password of the authentication server user account. | Yes |
|
||||
| `PN_FRIENDS_CONFIG_SECURE_PASSWORD` | The password of the secure server user account. Used as part of the internal server data in Kerberos tickets | Yes |
|
||||
| `PN_FRIENDS_CONFIG_AES_KEY` | AES key used in tokens provided by the account server | Yes |
|
||||
| `PN_FRIENDS_CONFIG_GRPC_API_KEY` | API key for your GRPC server | No (Assumed to be an open gRPC API) |
|
||||
| `PN_FRIENDS_GRPC_SERVER_PORT` | Port for the GRPC server | Yes |
|
||||
| `PN_FRIENDS_AUTHENTICATION_SERVER_PORT` | Port for the authentication server | Yes |
|
||||
| `PN_FRIENDS_SECURE_SERVER_HOST` | Host name for the secure server (should point to the same address as the authentication server) | Yes |
|
||||
| `PN_FRIENDS_SECURE_SERVER_PORT` | Port for the secure server | Yes |
|
||||
| `PN_FRIENDS_ACCOUNT_GRPC_HOST` | Host name for your account server gRPC service | Yes |
|
||||
| `PN_FRIENDS_ACCOUNT_GRPC_PORT` | Port for your account server gRPC service | Yes |
|
||||
| `PN_FRIENDS_ACCOUNT_GRPC_API_KEY` | API key for your account server gRPC service | No (Assumed to be an open gRPC API) |
|
||||
|
|
|
|||
|
|
@ -2,14 +2,15 @@ package database_3ds
|
|||
|
||||
import (
|
||||
"github.com/PretendoNetwork/friends/database"
|
||||
"github.com/PretendoNetwork/nex-go"
|
||||
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/friends-3ds/types"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds/types"
|
||||
"github.com/lib/pq"
|
||||
)
|
||||
|
||||
// GetFriendMiis returns the Mii of all friends
|
||||
func GetFriendMiis(pids []uint32) ([]*friends_3ds_types.FriendMii, error) {
|
||||
friendMiis := make([]*friends_3ds_types.FriendMii, 0)
|
||||
func GetFriendMiis(pids []uint32) (*types.List[*friends_3ds_types.FriendMii], error) {
|
||||
friendMiis := types.NewList[*friends_3ds_types.FriendMii]()
|
||||
friendMiis.Type = friends_3ds_types.NewFriendMii()
|
||||
|
||||
rows, err := database.Postgres.Query(`
|
||||
SELECT pid, mii_name, mii_data FROM "3ds".user_data WHERE pid=ANY($1::int[])`, pq.Array(pids))
|
||||
|
|
@ -17,23 +18,30 @@ func GetFriendMiis(pids []uint32) ([]*friends_3ds_types.FriendMii, error) {
|
|||
return friendMiis, err
|
||||
}
|
||||
|
||||
changedTime := nex.NewDateTime(0).Now()
|
||||
changedTime := types.NewDateTime(0).Now()
|
||||
|
||||
for rows.Next() {
|
||||
var pid uint32
|
||||
var miiName string
|
||||
var miiData []byte
|
||||
|
||||
err := rows.Scan(&pid, &miiName, &miiData)
|
||||
if err != nil {
|
||||
return friendMiis, err
|
||||
}
|
||||
|
||||
mii := friends_3ds_types.NewMii()
|
||||
mii.Unknown2 = false
|
||||
mii.Unknown3 = 0
|
||||
|
||||
rows.Scan(&pid, &mii.Name, &mii.MiiData)
|
||||
mii.Name = types.NewString(miiName)
|
||||
mii.Unknown2 = types.NewPrimitiveBool(false)
|
||||
mii.Unknown3 = types.NewPrimitiveU8(0)
|
||||
mii.MiiData = types.NewBuffer(miiData)
|
||||
|
||||
friendMii := friends_3ds_types.NewFriendMii()
|
||||
friendMii.PID = nex.NewPID(pid)
|
||||
friendMii.PID = types.NewPID(uint64(pid))
|
||||
friendMii.Mii = mii
|
||||
friendMii.ModifiedAt = changedTime
|
||||
|
||||
friendMiis = append(friendMiis, friendMii)
|
||||
friendMiis.Append(friendMii)
|
||||
}
|
||||
|
||||
return friendMiis, nil
|
||||
|
|
|
|||
|
|
@ -2,14 +2,15 @@ package database_3ds
|
|||
|
||||
import (
|
||||
"github.com/PretendoNetwork/friends/database"
|
||||
"github.com/PretendoNetwork/nex-go"
|
||||
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/friends-3ds/types"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds/types"
|
||||
"github.com/lib/pq"
|
||||
)
|
||||
|
||||
// GetFriendPersistentInfos returns the persistent information of all friends
|
||||
func GetFriendPersistentInfos(user1_pid uint32, pids []uint32) ([]*friends_3ds_types.FriendPersistentInfo, error) {
|
||||
persistentInfos := make([]*friends_3ds_types.FriendPersistentInfo, 0)
|
||||
func GetFriendPersistentInfos(user1_pid uint32, pids []uint32) (*types.List[*friends_3ds_types.FriendPersistentInfo], error) {
|
||||
persistentInfos := types.NewList[*friends_3ds_types.FriendPersistentInfo]()
|
||||
persistentInfos.Type = friends_3ds_types.NewFriendPersistentInfo()
|
||||
|
||||
rows, err := database.Postgres.Query(`
|
||||
SELECT pid, region, area, language, favorite_title, favorite_title_version, comment, comment_changed, last_online, mii_changed FROM "3ds".user_data WHERE pid=ANY($1::int[])`, pq.Array(pids))
|
||||
|
|
@ -23,22 +24,48 @@ func GetFriendPersistentInfos(user1_pid uint32, pids []uint32) ([]*friends_3ds_t
|
|||
gameKey := friends_3ds_types.NewGameKey()
|
||||
|
||||
var pid uint32
|
||||
var region uint8
|
||||
var area uint8
|
||||
var language uint8
|
||||
var titleID uint64
|
||||
var titleVersion uint16
|
||||
var message string
|
||||
var lastOnlineTime uint64
|
||||
var msgUpdateTime uint64
|
||||
var miiModifiedAtTime uint64
|
||||
|
||||
rows.Scan(
|
||||
&pid, &persistentInfo.Region, &persistentInfo.Area, &persistentInfo.Language,
|
||||
&gameKey.TitleID, &gameKey.TitleVersion, &persistentInfo.Message, &msgUpdateTime, &lastOnlineTime, &miiModifiedAtTime)
|
||||
err := rows.Scan(
|
||||
&pid,
|
||||
®ion,
|
||||
&area,
|
||||
&language,
|
||||
&titleID,
|
||||
&titleVersion,
|
||||
&message,
|
||||
&msgUpdateTime,
|
||||
&lastOnlineTime,
|
||||
&miiModifiedAtTime,
|
||||
)
|
||||
if err != nil {
|
||||
return persistentInfos, err
|
||||
}
|
||||
|
||||
persistentInfo.PID = nex.NewPID(pid)
|
||||
persistentInfo.MessageUpdatedAt = nex.NewDateTime(msgUpdateTime)
|
||||
persistentInfo.MiiModifiedAt = nex.NewDateTime(miiModifiedAtTime)
|
||||
persistentInfo.LastOnline = nex.NewDateTime(lastOnlineTime)
|
||||
gameKey.TitleID = types.NewPrimitiveU64(titleID)
|
||||
gameKey.TitleVersion = types.NewPrimitiveU16(titleVersion)
|
||||
|
||||
persistentInfo.PID = types.NewPID(uint64(pid))
|
||||
persistentInfo.Region = types.NewPrimitiveU8(region)
|
||||
persistentInfo.Country = types.NewPrimitiveU8(0) // TODO - What is this?
|
||||
persistentInfo.Area = types.NewPrimitiveU8(area)
|
||||
persistentInfo.Language = types.NewPrimitiveU8(language)
|
||||
persistentInfo.Platform = types.NewPrimitiveU8(2) // * Always 3DS
|
||||
persistentInfo.GameKey = gameKey
|
||||
persistentInfo.Platform = 2 // Always 3DS
|
||||
persistentInfo.Message = types.NewString(message)
|
||||
persistentInfo.MessageUpdatedAt = types.NewDateTime(msgUpdateTime)
|
||||
persistentInfo.MiiModifiedAt = types.NewDateTime(miiModifiedAtTime)
|
||||
persistentInfo.LastOnline = types.NewDateTime(lastOnlineTime)
|
||||
|
||||
persistentInfos = append(persistentInfos, persistentInfo)
|
||||
persistentInfos.Append(persistentInfo)
|
||||
}
|
||||
|
||||
return persistentInfos, nil
|
||||
|
|
|
|||
|
|
@ -4,13 +4,14 @@ import (
|
|||
"database/sql"
|
||||
|
||||
"github.com/PretendoNetwork/friends/database"
|
||||
"github.com/PretendoNetwork/nex-go"
|
||||
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/friends-3ds/types"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds/types"
|
||||
)
|
||||
|
||||
// GetUserFriends returns all friend relationships of a user
|
||||
func GetUserFriends(pid uint32) ([]*friends_3ds_types.FriendRelationship, error) {
|
||||
friendRelationships := make([]*friends_3ds_types.FriendRelationship, 0)
|
||||
func GetUserFriends(pid uint32) (*types.List[*friends_3ds_types.FriendRelationship], error) {
|
||||
friendRelationships := types.NewList[*friends_3ds_types.FriendRelationship]()
|
||||
friendRelationships.Type = friends_3ds_types.NewFriendRelationship()
|
||||
|
||||
rows, err := database.Postgres.Query(`
|
||||
SELECT user2_pid, type FROM "3ds".friendships WHERE user1_pid=$1 AND type=1 LIMIT 100`, pid)
|
||||
|
|
@ -24,15 +25,20 @@ func GetUserFriends(pid uint32) ([]*friends_3ds_types.FriendRelationship, error)
|
|||
|
||||
for rows.Next() {
|
||||
var pid uint32
|
||||
var relationshipType uint8
|
||||
|
||||
err := rows.Scan(&pid, &relationshipType)
|
||||
if err != nil {
|
||||
return friendRelationships, err
|
||||
}
|
||||
|
||||
relationship := friends_3ds_types.NewFriendRelationship()
|
||||
relationship.LFC = 0
|
||||
|
||||
rows.Scan(&pid, &relationship.RelationshipType)
|
||||
relationship.LFC = types.NewPrimitiveU64(0)
|
||||
relationship.PID = types.NewPID(uint64(pid))
|
||||
relationship.RelationshipType = types.NewPrimitiveU8(relationshipType)
|
||||
|
||||
relationship.PID = nex.NewPID(pid)
|
||||
|
||||
friendRelationships = append(friendRelationships, relationship)
|
||||
friendRelationships.Append(relationship)
|
||||
}
|
||||
|
||||
return friendRelationships, nil
|
||||
|
|
|
|||
|
|
@ -2,16 +2,16 @@ package database_3ds
|
|||
|
||||
import (
|
||||
"github.com/PretendoNetwork/friends/database"
|
||||
"github.com/PretendoNetwork/nex-go"
|
||||
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/friends-3ds/types"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds/types"
|
||||
)
|
||||
|
||||
// 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 = nex.NewPID(recipientPID)
|
||||
friendRelationship.LFC = 0
|
||||
friendRelationship.RelationshipType = 0 // * Incomplete
|
||||
friendRelationship.PID = types.NewPID(uint64(recipientPID))
|
||||
friendRelationship.LFC = types.NewPrimitiveU64(0)
|
||||
friendRelationship.RelationshipType = types.NewPrimitiveU8(0) // * Incomplete
|
||||
|
||||
// * Ensure that we inputted a valid user.
|
||||
var found bool
|
||||
|
|
@ -20,7 +20,7 @@ func SaveFriendship(senderPID uint32, recipientPID uint32) (*friends_3ds_types.F
|
|||
return nil, err
|
||||
}
|
||||
if !found {
|
||||
friendRelationship.RelationshipType = 2 // * Non-existent
|
||||
friendRelationship.RelationshipType = types.NewPrimitiveU8(2) // * Non-existent
|
||||
return friendRelationship, nil
|
||||
}
|
||||
|
||||
|
|
@ -42,7 +42,7 @@ func SaveFriendship(senderPID uint32, recipientPID uint32) (*friends_3ds_types.F
|
|||
return friendRelationship, nil
|
||||
}
|
||||
|
||||
acceptedTime := nex.NewDateTime(0).Now().Value()
|
||||
acceptedTime := types.NewDateTime(0).Now().Value()
|
||||
|
||||
// * We need to have two relationships for both sides as friend relationships are not one single object.
|
||||
_, err = database.Postgres.Exec(`
|
||||
|
|
@ -67,6 +67,7 @@ func SaveFriendship(senderPID uint32, recipientPID uint32) (*friends_3ds_types.F
|
|||
return nil, err
|
||||
}
|
||||
|
||||
friendRelationship.RelationshipType = 1 // * Complete
|
||||
friendRelationship.RelationshipType = types.NewPrimitiveU8(1) // * Complete
|
||||
|
||||
return friendRelationship, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,12 +2,12 @@ package database_3ds
|
|||
|
||||
import (
|
||||
"github.com/PretendoNetwork/friends/database"
|
||||
"github.com/PretendoNetwork/nex-go"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
)
|
||||
|
||||
// UpdateUserComment updates a user's comment
|
||||
func UpdateUserComment(pid uint32, message string) error {
|
||||
changed := nex.NewDateTime(0).Now().Value()
|
||||
changed := types.NewDateTime(0).Now().Value()
|
||||
|
||||
_, err := database.Postgres.Exec(`
|
||||
INSERT INTO "3ds".user_data (pid, comment, comment_changed)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package database_3ds
|
|||
|
||||
import (
|
||||
"github.com/PretendoNetwork/friends/database"
|
||||
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/friends-3ds/types"
|
||||
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds/types"
|
||||
)
|
||||
|
||||
// UpdateUserFavoriteGame updates a user's favorite game
|
||||
|
|
@ -13,7 +13,7 @@ func UpdateUserFavoriteGame(pid uint32, gameKey *friends_3ds_types.GameKey) erro
|
|||
ON CONFLICT (pid)
|
||||
DO UPDATE SET
|
||||
favorite_title = $2,
|
||||
favorite_title_version = $3`, pid, gameKey.TitleID, gameKey.TitleVersion)
|
||||
favorite_title_version = $3`, pid, gameKey.TitleID.Value, gameKey.TitleVersion.Value)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@ import (
|
|||
"database/sql"
|
||||
|
||||
"github.com/PretendoNetwork/friends/database"
|
||||
"github.com/PretendoNetwork/nex-go"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
)
|
||||
|
||||
// UpdateUserLastOnlineTime updates a user's last online time
|
||||
func UpdateUserLastOnlineTime(pid uint32, lastOnline *nex.DateTime) error {
|
||||
func UpdateUserLastOnlineTime(pid uint32, lastOnline *types.DateTime) error {
|
||||
var showOnline bool
|
||||
|
||||
err := database.Postgres.QueryRow(`SELECT show_online FROM "3ds".user_data WHERE pid=$1`, pid).Scan(&showOnline)
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ package database_3ds
|
|||
|
||||
import (
|
||||
"github.com/PretendoNetwork/friends/database"
|
||||
"github.com/PretendoNetwork/nex-go"
|
||||
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/friends-3ds/types"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds/types"
|
||||
)
|
||||
|
||||
// UpdateUserMii updates a user's mii
|
||||
|
|
@ -15,7 +15,7 @@ func UpdateUserMii(pid uint32, mii *friends_3ds_types.Mii) error {
|
|||
DO UPDATE SET
|
||||
mii_name = $2,
|
||||
mii_data = $3,
|
||||
mii_changed = $4`, pid, mii.Name, mii.MiiData, nex.NewDateTime(0).Now().Value())
|
||||
mii_changed = $4`, pid, mii.Name.Value, mii.MiiData.Value, types.NewDateTime(0).Now().Value())
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package database_3ds
|
|||
|
||||
import (
|
||||
"github.com/PretendoNetwork/friends/database"
|
||||
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/friends-3ds/types"
|
||||
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds/types"
|
||||
)
|
||||
|
||||
// UpdateUserProfile updates a user's profile
|
||||
|
|
@ -14,7 +14,7 @@ func UpdateUserProfile(pid uint32, profileData *friends_3ds_types.MyProfile) err
|
|||
DO UPDATE SET
|
||||
region = $2,
|
||||
area = $3,
|
||||
language = $4`, pid, profileData.Region, profileData.Area, profileData.Language)
|
||||
language = $4`, pid, profileData.Region.Value, profileData.Area.Value, profileData.Language.Value)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ import (
|
|||
"github.com/PretendoNetwork/friends/database"
|
||||
"github.com/PretendoNetwork/friends/globals"
|
||||
"github.com/PretendoNetwork/friends/utility"
|
||||
"github.com/PretendoNetwork/nex-go"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu/types"
|
||||
)
|
||||
|
||||
// AcceptFriendRequestAndReturnFriendInfo accepts the given friend reuqest and returns the friend's information
|
||||
|
|
@ -24,7 +24,7 @@ func AcceptFriendRequestAndReturnFriendInfo(friendRequestID uint64) (*friends_wi
|
|||
}
|
||||
}
|
||||
|
||||
acceptedTime := nex.NewDateTime(0).Now()
|
||||
acceptedTime := types.NewDateTime(0).Now()
|
||||
|
||||
// * Friendships are two-way relationships, not just one link between 2 entities
|
||||
// * "A" has friend "B" and "B" has friend "A", so store both relationships
|
||||
|
|
@ -60,14 +60,14 @@ func AcceptFriendRequestAndReturnFriendInfo(friendRequestID uint64) (*friends_wi
|
|||
|
||||
friendInfo := friends_wiiu_types.NewFriendInfo()
|
||||
connectedUser := globals.ConnectedUsers[senderPID]
|
||||
var lastOnline *nex.DateTime
|
||||
var lastOnline *types.DateTime
|
||||
|
||||
if connectedUser != nil {
|
||||
// * Online
|
||||
friendInfo.NNAInfo = connectedUser.NNAInfo
|
||||
friendInfo.Presence = connectedUser.PresenceV2
|
||||
|
||||
lastOnline = nex.NewDateTime(0).Now()
|
||||
lastOnline = types.NewDateTime(0).Now()
|
||||
} else {
|
||||
// * Offline
|
||||
userInfo, err := utility.GetUserInfoByPID(senderPID)
|
||||
|
|
@ -78,27 +78,27 @@ func AcceptFriendRequestAndReturnFriendInfo(friendRequestID uint64) (*friends_wi
|
|||
friendInfo.NNAInfo = friends_wiiu_types.NewNNAInfo()
|
||||
|
||||
friendInfo.NNAInfo.PrincipalBasicInfo = userInfo
|
||||
friendInfo.NNAInfo.Unknown1 = 0
|
||||
friendInfo.NNAInfo.Unknown2 = 0
|
||||
friendInfo.NNAInfo.Unknown1 = types.NewPrimitiveU8(0)
|
||||
friendInfo.NNAInfo.Unknown2 = types.NewPrimitiveU8(0)
|
||||
|
||||
friendInfo.Presence = friends_wiiu_types.NewNintendoPresenceV2()
|
||||
friendInfo.Presence.ChangedFlags = 0
|
||||
friendInfo.Presence.Online = false
|
||||
friendInfo.Presence.ChangedFlags = types.NewPrimitiveU32(0)
|
||||
friendInfo.Presence.Online = types.NewPrimitiveBool(false)
|
||||
friendInfo.Presence.GameKey = friends_wiiu_types.NewGameKey()
|
||||
friendInfo.Presence.GameKey.TitleID = 0
|
||||
friendInfo.Presence.GameKey.TitleVersion = 0
|
||||
friendInfo.Presence.Unknown1 = 0
|
||||
friendInfo.Presence.Message = ""
|
||||
friendInfo.Presence.Unknown2 = 0
|
||||
friendInfo.Presence.Unknown3 = 0
|
||||
friendInfo.Presence.GameServerID = 0
|
||||
friendInfo.Presence.Unknown4 = 0
|
||||
friendInfo.Presence.PID = nex.NewPID(senderPID)
|
||||
friendInfo.Presence.GatheringID = 0
|
||||
friendInfo.Presence.ApplicationData = make([]byte, 0)
|
||||
friendInfo.Presence.Unknown5 = 0
|
||||
friendInfo.Presence.Unknown6 = 0
|
||||
friendInfo.Presence.Unknown7 = 0
|
||||
friendInfo.Presence.GameKey.TitleID = types.NewPrimitiveU64(0)
|
||||
friendInfo.Presence.GameKey.TitleVersion = types.NewPrimitiveU16(0)
|
||||
friendInfo.Presence.Unknown1 = types.NewPrimitiveU8(0)
|
||||
friendInfo.Presence.Message = types.NewString("")
|
||||
friendInfo.Presence.Unknown2 = types.NewPrimitiveU32(0)
|
||||
friendInfo.Presence.Unknown3 = types.NewPrimitiveU8(0)
|
||||
friendInfo.Presence.GameServerID = types.NewPrimitiveU32(0)
|
||||
friendInfo.Presence.Unknown4 = types.NewPrimitiveU32(0)
|
||||
friendInfo.Presence.PID = types.NewPID(uint64(senderPID))
|
||||
friendInfo.Presence.GatheringID = types.NewPrimitiveU32(0)
|
||||
friendInfo.Presence.ApplicationData = types.NewBuffer([]byte{})
|
||||
friendInfo.Presence.Unknown5 = types.NewPrimitiveU8(0)
|
||||
friendInfo.Presence.Unknown6 = types.NewPrimitiveU8(0)
|
||||
friendInfo.Presence.Unknown7 = types.NewPrimitiveU8(0)
|
||||
|
||||
var lastOnlineTime uint64
|
||||
err = database.Postgres.QueryRow(`SELECT last_online FROM wiiu.user_data WHERE pid=$1`, senderPID).Scan(&lastOnlineTime)
|
||||
|
|
@ -110,7 +110,7 @@ func AcceptFriendRequestAndReturnFriendInfo(friendRequestID uint64) (*friends_wi
|
|||
}
|
||||
}
|
||||
|
||||
lastOnline = nex.NewDateTime(lastOnlineTime) // TODO - Change this
|
||||
lastOnline = types.NewDateTime(lastOnlineTime) // TODO - Change this
|
||||
}
|
||||
|
||||
status, err := GetUserComment(senderPID)
|
||||
|
|
@ -121,7 +121,7 @@ func AcceptFriendRequestAndReturnFriendInfo(friendRequestID uint64) (*friends_wi
|
|||
friendInfo.Status = status
|
||||
friendInfo.BecameFriend = acceptedTime
|
||||
friendInfo.LastOnline = lastOnline // TODO - Change this
|
||||
friendInfo.Unknown = 0
|
||||
friendInfo.Unknown = types.NewPrimitiveU64(0)
|
||||
|
||||
return friendInfo, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,13 +5,14 @@ import (
|
|||
|
||||
"github.com/PretendoNetwork/friends/database"
|
||||
"github.com/PretendoNetwork/friends/utility"
|
||||
"github.com/PretendoNetwork/nex-go"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu/types"
|
||||
)
|
||||
|
||||
// GetUserBlockList returns a user's blacklist
|
||||
func GetUserBlockList(pid uint32) ([]*friends_wiiu_types.BlacklistedPrincipal, error) {
|
||||
blockList := make([]*friends_wiiu_types.BlacklistedPrincipal, 0)
|
||||
func GetUserBlockList(pid uint32) (*types.List[*friends_wiiu_types.BlacklistedPrincipal], error) {
|
||||
blockList := types.NewList[*friends_wiiu_types.BlacklistedPrincipal]()
|
||||
blockList.Type = friends_wiiu_types.NewBlacklistedPrincipal()
|
||||
|
||||
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,10 +25,14 @@ func GetUserBlockList(pid uint32) ([]*friends_wiiu_types.BlacklistedPrincipal, e
|
|||
|
||||
for rows.Next() {
|
||||
var pid uint32
|
||||
var titleId uint64
|
||||
var titleID uint64
|
||||
var titleVersion uint16
|
||||
var date *nex.DateTime
|
||||
rows.Scan(&pid, &titleId, &titleVersion, &date)
|
||||
var date uint64
|
||||
|
||||
err := rows.Scan(&pid, &titleID, &titleVersion, &date)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
userInfo, err := utility.GetUserInfoByPID(pid)
|
||||
if err != nil {
|
||||
|
|
@ -39,11 +44,11 @@ func GetUserBlockList(pid uint32) ([]*friends_wiiu_types.BlacklistedPrincipal, e
|
|||
blacklistPrincipal.PrincipalBasicInfo = userInfo
|
||||
|
||||
blacklistPrincipal.GameKey = friends_wiiu_types.NewGameKey()
|
||||
blacklistPrincipal.GameKey.TitleID = titleId
|
||||
blacklistPrincipal.GameKey.TitleVersion = titleVersion
|
||||
blacklistPrincipal.BlackListedSince = date
|
||||
blacklistPrincipal.GameKey.TitleID = types.NewPrimitiveU64(titleID)
|
||||
blacklistPrincipal.GameKey.TitleVersion = types.NewPrimitiveU16(titleVersion)
|
||||
blacklistPrincipal.BlackListedSince = types.NewDateTime(date)
|
||||
|
||||
blockList = append(blockList, blacklistPrincipal)
|
||||
blockList.Append(blacklistPrincipal)
|
||||
}
|
||||
|
||||
return blockList, nil
|
||||
|
|
|
|||
|
|
@ -4,18 +4,19 @@ import (
|
|||
"database/sql"
|
||||
|
||||
"github.com/PretendoNetwork/friends/database"
|
||||
"github.com/PretendoNetwork/nex-go"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu/types"
|
||||
)
|
||||
|
||||
// GetUserComment returns a user's comment
|
||||
func GetUserComment(pid uint32) (*friends_wiiu_types.Comment, error) {
|
||||
comment := friends_wiiu_types.NewComment()
|
||||
comment.Unknown = 0
|
||||
comment.Unknown = types.NewPrimitiveU8(0)
|
||||
|
||||
var contents string
|
||||
var changed uint64 = 0
|
||||
|
||||
err := database.Postgres.QueryRow(`SELECT comment, comment_changed FROM wiiu.user_data WHERE pid=$1`, pid).Scan(&comment.Contents, &changed)
|
||||
err := database.Postgres.QueryRow(`SELECT comment, comment_changed FROM wiiu.user_data WHERE pid=$1`, pid).Scan(&contents, &changed)
|
||||
if err != nil {
|
||||
if err == sql.ErrNoRows {
|
||||
return nil, database.ErrPIDNotFound
|
||||
|
|
@ -24,7 +25,8 @@ func GetUserComment(pid uint32) (*friends_wiiu_types.Comment, error) {
|
|||
}
|
||||
}
|
||||
|
||||
comment.LastChanged = nex.NewDateTime(changed)
|
||||
comment.Contents = types.NewString(contents)
|
||||
comment.LastChanged = types.NewDateTime(changed)
|
||||
|
||||
return comment, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,13 +7,14 @@ import (
|
|||
"github.com/PretendoNetwork/friends/database"
|
||||
"github.com/PretendoNetwork/friends/globals"
|
||||
"github.com/PretendoNetwork/friends/utility"
|
||||
"github.com/PretendoNetwork/nex-go"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu/types"
|
||||
)
|
||||
|
||||
// GetUserFriendList returns a user's friend list
|
||||
func GetUserFriendList(pid uint32) ([]*friends_wiiu_types.FriendInfo, error) {
|
||||
friendList := make([]*friends_wiiu_types.FriendInfo, 0)
|
||||
func GetUserFriendList(pid uint32) (*types.List[*friends_wiiu_types.FriendInfo], error) {
|
||||
friendList := types.NewList[*friends_wiiu_types.FriendInfo]()
|
||||
friendList.Type = friends_wiiu_types.NewFriendInfo()
|
||||
|
||||
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 {
|
||||
|
|
@ -27,11 +28,15 @@ func GetUserFriendList(pid uint32) ([]*friends_wiiu_types.FriendInfo, error) {
|
|||
for rows.Next() {
|
||||
var friendPID uint32
|
||||
var date uint64
|
||||
rows.Scan(&friendPID, &date)
|
||||
|
||||
err := rows.Scan(&friendPID, &date)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
friendInfo := friends_wiiu_types.NewFriendInfo()
|
||||
connectedUser := globals.ConnectedUsers[friendPID]
|
||||
var lastOnline *nex.DateTime
|
||||
var lastOnline *types.DateTime
|
||||
|
||||
if connectedUser != nil {
|
||||
// * Online
|
||||
|
|
@ -39,7 +44,7 @@ func GetUserFriendList(pid uint32) ([]*friends_wiiu_types.FriendInfo, error) {
|
|||
friendInfo.Presence = connectedUser.PresenceV2
|
||||
|
||||
if friendInfo.NNAInfo == nil || friendInfo.NNAInfo.PrincipalBasicInfo == nil {
|
||||
// TODO: Fix this
|
||||
// TODO - Fix this
|
||||
globals.Logger.Error(fmt.Sprintf("User %d has friend %d with bad presence data", pid, friendPID))
|
||||
if friendInfo.NNAInfo == nil {
|
||||
globals.Logger.Error(fmt.Sprintf("%d friendInfo.NNAInfo is nil", friendPID))
|
||||
|
|
@ -50,7 +55,7 @@ func GetUserFriendList(pid uint32) ([]*friends_wiiu_types.FriendInfo, error) {
|
|||
continue
|
||||
}
|
||||
|
||||
lastOnline = nex.NewDateTime(0).Now()
|
||||
lastOnline = types.NewDateTime(0).Now()
|
||||
} else {
|
||||
// * Offline
|
||||
|
||||
|
|
@ -62,27 +67,27 @@ func GetUserFriendList(pid uint32) ([]*friends_wiiu_types.FriendInfo, error) {
|
|||
friendInfo.NNAInfo = friends_wiiu_types.NewNNAInfo()
|
||||
|
||||
friendInfo.NNAInfo.PrincipalBasicInfo = userInfo
|
||||
friendInfo.NNAInfo.Unknown1 = 0
|
||||
friendInfo.NNAInfo.Unknown2 = 0
|
||||
friendInfo.NNAInfo.Unknown1 = types.NewPrimitiveU8(0)
|
||||
friendInfo.NNAInfo.Unknown2 = types.NewPrimitiveU8(0)
|
||||
|
||||
friendInfo.Presence = friends_wiiu_types.NewNintendoPresenceV2()
|
||||
friendInfo.Presence.ChangedFlags = 0
|
||||
friendInfo.Presence.Online = false
|
||||
friendInfo.Presence.ChangedFlags = types.NewPrimitiveU32(0)
|
||||
friendInfo.Presence.Online = types.NewPrimitiveBool(false)
|
||||
friendInfo.Presence.GameKey = friends_wiiu_types.NewGameKey()
|
||||
friendInfo.Presence.GameKey.TitleID = 0
|
||||
friendInfo.Presence.GameKey.TitleVersion = 0
|
||||
friendInfo.Presence.Unknown1 = 0
|
||||
friendInfo.Presence.Message = ""
|
||||
friendInfo.Presence.Unknown2 = 0
|
||||
friendInfo.Presence.Unknown3 = 0
|
||||
friendInfo.Presence.GameServerID = 0
|
||||
friendInfo.Presence.Unknown4 = 0
|
||||
friendInfo.Presence.PID = nex.NewPID[uint32](0)
|
||||
friendInfo.Presence.GatheringID = 0
|
||||
friendInfo.Presence.ApplicationData = []byte{0x00}
|
||||
friendInfo.Presence.Unknown5 = 0
|
||||
friendInfo.Presence.Unknown6 = 0
|
||||
friendInfo.Presence.Unknown7 = 0
|
||||
friendInfo.Presence.GameKey.TitleID = types.NewPrimitiveU64(0)
|
||||
friendInfo.Presence.GameKey.TitleVersion = types.NewPrimitiveU16(0)
|
||||
friendInfo.Presence.Unknown1 = types.NewPrimitiveU8(0)
|
||||
friendInfo.Presence.Message = types.NewString("")
|
||||
friendInfo.Presence.Unknown2 = types.NewPrimitiveU32(0)
|
||||
friendInfo.Presence.Unknown3 = types.NewPrimitiveU8(0)
|
||||
friendInfo.Presence.GameServerID = types.NewPrimitiveU32(0)
|
||||
friendInfo.Presence.Unknown4 = types.NewPrimitiveU32(0)
|
||||
friendInfo.Presence.PID = types.NewPID(0)
|
||||
friendInfo.Presence.GatheringID = types.NewPrimitiveU32(0)
|
||||
friendInfo.Presence.ApplicationData = types.NewBuffer([]byte{})
|
||||
friendInfo.Presence.Unknown5 = types.NewPrimitiveU8(0)
|
||||
friendInfo.Presence.Unknown6 = types.NewPrimitiveU8(0)
|
||||
friendInfo.Presence.Unknown7 = types.NewPrimitiveU8(0)
|
||||
|
||||
var lastOnlineTime uint64
|
||||
err = database.Postgres.QueryRow(`SELECT last_online FROM wiiu.user_data WHERE pid=$1`, friendPID).Scan(&lastOnlineTime)
|
||||
|
|
@ -90,7 +95,7 @@ func GetUserFriendList(pid uint32) ([]*friends_wiiu_types.FriendInfo, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
lastOnline = nex.NewDateTime(lastOnlineTime) // TODO - Change this
|
||||
lastOnline = types.NewDateTime(lastOnlineTime) // TODO - Change this
|
||||
}
|
||||
|
||||
status, err := GetUserComment(friendPID)
|
||||
|
|
@ -100,11 +105,11 @@ func GetUserFriendList(pid uint32) ([]*friends_wiiu_types.FriendInfo, error) {
|
|||
|
||||
friendInfo.Status = status
|
||||
|
||||
friendInfo.BecameFriend = nex.NewDateTime(date)
|
||||
friendInfo.BecameFriend = types.NewDateTime(date)
|
||||
friendInfo.LastOnline = lastOnline
|
||||
friendInfo.Unknown = 0
|
||||
friendInfo.Unknown = types.NewPrimitiveU64(0)
|
||||
|
||||
friendList = append(friendList, friendInfo)
|
||||
friendList.Append(friendInfo)
|
||||
}
|
||||
|
||||
return friendList, nil
|
||||
|
|
|
|||
|
|
@ -22,7 +22,11 @@ func GetUserFriendPIDs(pid uint32) ([]uint32, error) {
|
|||
|
||||
for rows.Next() {
|
||||
var pid uint32
|
||||
rows.Scan(&pid)
|
||||
|
||||
err := rows.Scan(&pid)
|
||||
if err != nil {
|
||||
return pids, err
|
||||
}
|
||||
|
||||
pids = append(pids, pid)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,20 +6,21 @@ import (
|
|||
|
||||
"github.com/PretendoNetwork/friends/database"
|
||||
"github.com/PretendoNetwork/friends/utility"
|
||||
"github.com/PretendoNetwork/nex-go"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu/types"
|
||||
)
|
||||
|
||||
// GetUserFriendRequestsIn returns the friend requests received by a user
|
||||
func GetUserFriendRequestsIn(pid uint32) ([]*friends_wiiu_types.FriendRequest, error) {
|
||||
friendRequestsIn := make([]*friends_wiiu_types.FriendRequest, 0)
|
||||
func GetUserFriendRequestsIn(pid uint32) (*types.List[*friends_wiiu_types.FriendRequest], error) {
|
||||
friendRequests := types.NewList[*friends_wiiu_types.FriendRequest]()
|
||||
friendRequests.Type = friends_wiiu_types.NewFriendRequest()
|
||||
|
||||
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 {
|
||||
if err == sql.ErrNoRows {
|
||||
return friendRequestsIn, database.ErrEmptyList
|
||||
return friendRequests, database.ErrEmptyList
|
||||
} else {
|
||||
return friendRequestsIn, err
|
||||
return friendRequests, err
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -30,7 +31,11 @@ func GetUserFriendRequestsIn(pid uint32) ([]*friends_wiiu_types.FriendRequest, e
|
|||
var expiresOn uint64
|
||||
var message string
|
||||
var received bool
|
||||
rows.Scan(&id, &senderPID, &sentOn, &expiresOn, &message, &received)
|
||||
|
||||
err := rows.Scan(&id, &senderPID, &sentOn, &expiresOn, &message, &received)
|
||||
if err != nil {
|
||||
return friendRequests, err
|
||||
}
|
||||
|
||||
userInfo, err := utility.GetUserInfoByPID(senderPID)
|
||||
if err != nil {
|
||||
|
|
@ -41,24 +46,24 @@ func GetUserFriendRequestsIn(pid uint32) ([]*friends_wiiu_types.FriendRequest, e
|
|||
|
||||
friendRequest.PrincipalInfo = userInfo
|
||||
friendRequest.Message = friends_wiiu_types.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.FriendRequestID = types.NewPrimitiveU64(id)
|
||||
friendRequest.Message.Received = types.NewPrimitiveBool(received)
|
||||
friendRequest.Message.Unknown2 = types.NewPrimitiveU8(1)
|
||||
friendRequest.Message.Message = types.NewString(message)
|
||||
friendRequest.Message.Unknown3 = types.NewPrimitiveU8(0)
|
||||
friendRequest.Message.Unknown4 = types.NewString("")
|
||||
friendRequest.Message.GameKey = friends_wiiu_types.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
|
||||
friendRequest.Message.ExpiresOn = nex.NewDateTime(expiresOn)
|
||||
friendRequest.SentOn = nex.NewDateTime(sentOn)
|
||||
friendRequest.Message.GameKey.TitleID = types.NewPrimitiveU64(0)
|
||||
friendRequest.Message.GameKey.TitleVersion = types.NewPrimitiveU16(0)
|
||||
friendRequest.Message.Unknown5 = types.NewDateTime(134222053376) // * idk what this value means but its always this
|
||||
friendRequest.Message.ExpiresOn = types.NewDateTime(expiresOn)
|
||||
friendRequest.SentOn = types.NewDateTime(sentOn)
|
||||
|
||||
// * Filter out expired requests
|
||||
if friendRequest.Message.ExpiresOn.Standard().After(time.Now()) {
|
||||
friendRequestsIn = append(friendRequestsIn, friendRequest)
|
||||
friendRequests.Append(friendRequest)
|
||||
}
|
||||
}
|
||||
|
||||
return friendRequestsIn, nil
|
||||
return friendRequests, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,20 +5,21 @@ import (
|
|||
|
||||
"github.com/PretendoNetwork/friends/database"
|
||||
"github.com/PretendoNetwork/friends/utility"
|
||||
"github.com/PretendoNetwork/nex-go"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu/types"
|
||||
)
|
||||
|
||||
// GetUserFriendRequestsOut returns the friend requests sent by a user
|
||||
func GetUserFriendRequestsOut(pid uint32) ([]*friends_wiiu_types.FriendRequest, error) {
|
||||
friendRequestsOut := make([]*friends_wiiu_types.FriendRequest, 0)
|
||||
func GetUserFriendRequestsOut(pid uint32) (*types.List[*friends_wiiu_types.FriendRequest], error) {
|
||||
friendRequests := types.NewList[*friends_wiiu_types.FriendRequest]()
|
||||
friendRequests.Type = friends_wiiu_types.NewFriendRequest()
|
||||
|
||||
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 {
|
||||
if err == sql.ErrNoRows {
|
||||
return friendRequestsOut, database.ErrEmptyList
|
||||
return friendRequests, database.ErrEmptyList
|
||||
} else {
|
||||
return friendRequestsOut, err
|
||||
return friendRequests, err
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -29,7 +30,11 @@ func GetUserFriendRequestsOut(pid uint32) ([]*friends_wiiu_types.FriendRequest,
|
|||
var expiresOn uint64
|
||||
var message string
|
||||
var received bool
|
||||
rows.Scan(&id, &recipientPID, &sentOn, &expiresOn, &message, &received)
|
||||
|
||||
err := rows.Scan(&id, &recipientPID, &sentOn, &expiresOn, &message, &received)
|
||||
if err != nil {
|
||||
return friendRequests, err
|
||||
}
|
||||
|
||||
userInfo, err := utility.GetUserInfoByPID(recipientPID)
|
||||
if err != nil {
|
||||
|
|
@ -40,21 +45,21 @@ func GetUserFriendRequestsOut(pid uint32) ([]*friends_wiiu_types.FriendRequest,
|
|||
|
||||
friendRequest.PrincipalInfo = userInfo
|
||||
friendRequest.Message = friends_wiiu_types.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.FriendRequestID = types.NewPrimitiveU64(id)
|
||||
friendRequest.Message.Received = types.NewPrimitiveBool(received)
|
||||
friendRequest.Message.Unknown2 = types.NewPrimitiveU8(1)
|
||||
friendRequest.Message.Message = types.NewString(message)
|
||||
friendRequest.Message.Unknown3 = types.NewPrimitiveU8(0)
|
||||
friendRequest.Message.Unknown4 = types.NewString("")
|
||||
friendRequest.Message.GameKey = friends_wiiu_types.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
|
||||
friendRequest.Message.ExpiresOn = nex.NewDateTime(expiresOn)
|
||||
friendRequest.SentOn = nex.NewDateTime(sentOn)
|
||||
friendRequest.Message.GameKey.TitleID = types.NewPrimitiveU64(0)
|
||||
friendRequest.Message.GameKey.TitleVersion = types.NewPrimitiveU16(0)
|
||||
friendRequest.Message.Unknown5 = types.NewDateTime(134222053376) // * idk what this value means but its always this
|
||||
friendRequest.Message.ExpiresOn = types.NewDateTime(expiresOn)
|
||||
friendRequest.SentOn = types.NewDateTime(sentOn)
|
||||
|
||||
friendRequestsOut = append(friendRequestsOut, friendRequest)
|
||||
friendRequests.Append(friendRequest)
|
||||
}
|
||||
|
||||
return friendRequestsOut, nil
|
||||
return friendRequests, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,15 @@
|
|||
package database_wiiu
|
||||
|
||||
import friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
|
||||
import (
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu/types"
|
||||
)
|
||||
|
||||
// GetUserNotifications returns notifications for a user
|
||||
func GetUserNotifications(pid uint32) []*friends_wiiu_types.PersistentNotification {
|
||||
return make([]*friends_wiiu_types.PersistentNotification, 0)
|
||||
func GetUserNotifications(pid uint32) *types.List[*friends_wiiu_types.PersistentNotification] {
|
||||
// TODO - Do this
|
||||
notifications := types.NewList[*friends_wiiu_types.PersistentNotification]()
|
||||
notifications.Type = friends_wiiu_types.NewPersistentNotification()
|
||||
|
||||
return notifications
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,14 +4,23 @@ import (
|
|||
"database/sql"
|
||||
|
||||
"github.com/PretendoNetwork/friends/database"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu/types"
|
||||
)
|
||||
|
||||
// GetUserPrincipalPreference returns the user preferences
|
||||
func GetUserPrincipalPreference(pid uint32) (*friends_wiiu_types.PrincipalPreference, error) {
|
||||
preference := friends_wiiu_types.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)
|
||||
var showOnlinePresence bool
|
||||
var showCurrentTitle bool
|
||||
var blockFriendRequests bool
|
||||
|
||||
err := database.Postgres.QueryRow(`SELECT show_online, show_current_game, block_friend_requests FROM wiiu.user_data WHERE pid=$1`, pid).Scan(
|
||||
&showOnlinePresence,
|
||||
&showCurrentTitle,
|
||||
&blockFriendRequests,
|
||||
)
|
||||
if err != nil {
|
||||
if err == sql.ErrNoRows {
|
||||
return nil, database.ErrPIDNotFound
|
||||
|
|
@ -20,5 +29,9 @@ func GetUserPrincipalPreference(pid uint32) (*friends_wiiu_types.PrincipalPrefer
|
|||
}
|
||||
}
|
||||
|
||||
preference.ShowOnlinePresence = types.NewPrimitiveBool(showOnlinePresence)
|
||||
preference.ShowCurrentTitle = types.NewPrimitiveBool(showCurrentTitle)
|
||||
preference.BlockFriendRequests = types.NewPrimitiveBool(blockFriendRequests)
|
||||
|
||||
return preference, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import (
|
|||
// IsFriendRequestBlocked determines if a requester PID has blocked a requested PID
|
||||
func IsFriendRequestBlocked(requesterPID uint32, requestedPID uint32) (bool, error) {
|
||||
var found bool
|
||||
|
||||
err := database.Postgres.QueryRow(`SELECT COUNT(*) FROM wiiu.blocks WHERE blocker_pid=$1 AND blocked_pid=$2 LIMIT 1`, requesterPID, requestedPID).Scan(&found)
|
||||
if err != nil {
|
||||
return false, err
|
||||
|
|
|
|||
|
|
@ -2,12 +2,12 @@ package database_wiiu
|
|||
|
||||
import (
|
||||
"github.com/PretendoNetwork/friends/database"
|
||||
"github.com/PretendoNetwork/nex-go"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
)
|
||||
|
||||
// SetUserBlocked marks a blocked PID as blocked on a blocker PID block list
|
||||
func SetUserBlocked(blockerPID uint32, blockedPID uint32, titleId uint64, titleVersion uint16) error {
|
||||
date := nex.NewDateTime(0).Now()
|
||||
date := types.NewDateTime(0).Now()
|
||||
|
||||
_, err := database.Postgres.Exec(`
|
||||
INSERT INTO wiiu.blocks (blocker_pid, blocked_pid, title_id, title_version, date)
|
||||
|
|
|
|||
|
|
@ -2,12 +2,12 @@ package database_wiiu
|
|||
|
||||
import (
|
||||
"github.com/PretendoNetwork/friends/database"
|
||||
"github.com/PretendoNetwork/nex-go"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
)
|
||||
|
||||
// UpdateUserComment updates a user's comment
|
||||
func UpdateUserComment(pid uint32, message string) (uint64, error) {
|
||||
changed := nex.NewDateTime(0).Now().Value()
|
||||
changed := types.NewDateTime(0).Now().Value()
|
||||
|
||||
_, err := database.Postgres.Exec(`
|
||||
INSERT INTO wiiu.user_data (pid, comment, comment_changed)
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@ package database_wiiu
|
|||
|
||||
import (
|
||||
"github.com/PretendoNetwork/friends/database"
|
||||
"github.com/PretendoNetwork/nex-go"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
)
|
||||
|
||||
// UpdateUserLastOnlineTime updates a user's last online time
|
||||
func UpdateUserLastOnlineTime(pid uint32, lastOnline *nex.DateTime) error {
|
||||
func UpdateUserLastOnlineTime(pid uint32, lastOnline *types.DateTime) error {
|
||||
_, err := database.Postgres.Exec(`
|
||||
INSERT INTO wiiu.user_data (pid, last_online)
|
||||
VALUES ($1, $2)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package database_wiiu
|
|||
|
||||
import (
|
||||
"github.com/PretendoNetwork/friends/database"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu/types"
|
||||
)
|
||||
|
||||
// UpdateUserPrincipalPreference updates the user preferences
|
||||
|
|
@ -14,7 +14,7 @@ func UpdateUserPrincipalPreference(pid uint32, principalPreference *friends_wiiu
|
|||
DO UPDATE SET
|
||||
show_online = $2,
|
||||
show_current_game = $3,
|
||||
block_friend_requests = $4`, pid, principalPreference.ShowOnlinePresence, principalPreference.ShowCurrentTitle, principalPreference.BlockFriendRequests)
|
||||
block_friend_requests = $4`, pid, principalPreference.ShowOnlinePresence.Value, principalPreference.ShowCurrentTitle.Value, principalPreference.BlockFriendRequests.Value)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
|||
34
globals/account_details_by_pid.go
Normal file
34
globals/account_details_by_pid.go
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
package globals
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
pb "github.com/PretendoNetwork/grpc-go/account"
|
||||
"github.com/PretendoNetwork/nex-go/v2"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
"google.golang.org/grpc/metadata"
|
||||
)
|
||||
|
||||
func AccountDetailsByPID(pid *types.PID) (*nex.Account, *nex.Error) {
|
||||
if pid.Equals(AuthenticationEndpoint.ServerAccount.PID) {
|
||||
return AuthenticationEndpoint.ServerAccount, nil
|
||||
}
|
||||
|
||||
if pid.Equals(SecureEndpoint.ServerAccount.PID) {
|
||||
return SecureEndpoint.ServerAccount, nil
|
||||
}
|
||||
|
||||
ctx := metadata.NewOutgoingContext(context.Background(), GRPCAccountCommonMetadata)
|
||||
|
||||
response, err := GRPCAccountClient.GetNEXPassword(ctx, &pb.GetNEXPasswordRequest{Pid: pid.LegacyValue()})
|
||||
if err != nil {
|
||||
Logger.Error(err.Error())
|
||||
return nil, nex.NewError(nex.ResultCodes.RendezVous.InvalidPID, "Invalid PID")
|
||||
}
|
||||
|
||||
username := strconv.Itoa(int(pid.Value()))
|
||||
account := nex.NewAccount(pid, username, response.Password)
|
||||
|
||||
return account, nil
|
||||
}
|
||||
46
globals/account_details_by_username.go
Normal file
46
globals/account_details_by_username.go
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
package globals
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
pb "github.com/PretendoNetwork/grpc-go/account"
|
||||
"github.com/PretendoNetwork/nex-go/v2"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
"google.golang.org/grpc/metadata"
|
||||
)
|
||||
|
||||
func AccountDetailsByUsername(username string) (*nex.Account, *nex.Error) {
|
||||
if username == AuthenticationEndpoint.ServerAccount.Username {
|
||||
return AuthenticationEndpoint.ServerAccount, nil
|
||||
}
|
||||
|
||||
if username == SecureEndpoint.ServerAccount.Username {
|
||||
return SecureEndpoint.ServerAccount, nil
|
||||
}
|
||||
|
||||
// TODO - This is fine for our needs, but not for servers which use non-PID usernames?
|
||||
pid, err := strconv.Atoi(username)
|
||||
if err != nil {
|
||||
fmt.Println(1)
|
||||
fmt.Println(err)
|
||||
return nil, nex.NewError(nex.ResultCodes.RendezVous.InvalidUsername, "Invalid username")
|
||||
}
|
||||
|
||||
// * Trying to use AccountDetailsByPID here led to weird nil checks?
|
||||
// * Would always return an error even when it shouldn't.
|
||||
// TODO - Look into this more
|
||||
|
||||
ctx := metadata.NewOutgoingContext(context.Background(), GRPCAccountCommonMetadata)
|
||||
|
||||
response, err := GRPCAccountClient.GetNEXPassword(ctx, &pb.GetNEXPasswordRequest{Pid: uint32(pid)})
|
||||
if err != nil {
|
||||
Logger.Error(err.Error())
|
||||
return nil, nex.NewError(nex.ResultCodes.RendezVous.InvalidPID, "Invalid PID")
|
||||
}
|
||||
|
||||
account := nex.NewAccount(types.NewPID(uint64(pid)), username, response.Password)
|
||||
|
||||
return account, nil
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@ package globals
|
|||
import (
|
||||
"github.com/PretendoNetwork/friends/types"
|
||||
pb "github.com/PretendoNetwork/grpc-go/account"
|
||||
"github.com/PretendoNetwork/nex-go"
|
||||
"github.com/PretendoNetwork/nex-go/v2"
|
||||
"github.com/PretendoNetwork/plogger-go"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/metadata"
|
||||
|
|
@ -12,7 +12,9 @@ import (
|
|||
var Logger *plogger.Logger
|
||||
var KerberosPassword = "password" // * Default password
|
||||
var AuthenticationServer *nex.PRUDPServer
|
||||
var AuthenticationEndpoint *nex.PRUDPEndPoint
|
||||
var SecureServer *nex.PRUDPServer
|
||||
var SecureEndpoint *nex.PRUDPEndPoint
|
||||
var ConnectedUsers map[uint32]*types.ConnectedUser
|
||||
var AESKey []byte
|
||||
var GRPCAccountClientConnection *grpc.ClientConn
|
||||
|
|
|
|||
|
|
@ -1,21 +0,0 @@
|
|||
package globals
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
pb "github.com/PretendoNetwork/grpc-go/account"
|
||||
"github.com/PretendoNetwork/nex-go"
|
||||
"google.golang.org/grpc/metadata"
|
||||
)
|
||||
|
||||
func PasswordFromPID(pid *nex.PID) (string, uint32) {
|
||||
ctx := metadata.NewOutgoingContext(context.Background(), GRPCAccountCommonMetadata)
|
||||
|
||||
response, err := GRPCAccountClient.GetNEXPassword(ctx, &pb.GetNEXPasswordRequest{Pid: pid.LegacyValue()})
|
||||
if err != nil {
|
||||
Logger.Error(err.Error())
|
||||
return "", nex.Errors.RendezVous.InvalidUsername
|
||||
}
|
||||
|
||||
return response.Password, 0
|
||||
}
|
||||
36
go.mod
36
go.mod
|
|
@ -1,31 +1,37 @@
|
|||
module github.com/PretendoNetwork/friends
|
||||
|
||||
go 1.18
|
||||
go 1.21
|
||||
|
||||
require (
|
||||
github.com/PretendoNetwork/grpc-go v1.0.2
|
||||
github.com/PretendoNetwork/nex-go v1.0.41
|
||||
github.com/PretendoNetwork/nex-protocols-common-go v1.0.28
|
||||
github.com/PretendoNetwork/nex-protocols-go v1.0.55
|
||||
github.com/PretendoNetwork/nex-go/v2 v2.0.1
|
||||
github.com/PretendoNetwork/nex-protocols-common-go/v2 v2.0.1
|
||||
github.com/PretendoNetwork/nex-protocols-go v1.0.58
|
||||
github.com/PretendoNetwork/nex-protocols-go/v2 v2.0.1
|
||||
github.com/PretendoNetwork/plogger-go v1.0.4
|
||||
github.com/golang/protobuf v1.5.3
|
||||
github.com/golang/protobuf v1.5.4
|
||||
github.com/joho/godotenv v1.5.1
|
||||
github.com/lib/pq v1.10.9
|
||||
golang.org/x/exp v0.0.0-20231006140011-7918f672742d
|
||||
google.golang.org/grpc v1.58.3
|
||||
google.golang.org/grpc v1.63.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/fatih/color v1.15.0 // indirect
|
||||
github.com/PretendoNetwork/nex-go v1.0.41 // indirect
|
||||
github.com/dolthub/maphash v0.1.0 // indirect
|
||||
github.com/fatih/color v1.16.0 // indirect
|
||||
github.com/jwalton/go-supportscolor v1.2.0 // indirect
|
||||
github.com/klauspost/compress v1.17.5 // indirect
|
||||
github.com/lxzan/gws v1.8.0 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/rasky/go-lzo v0.0.0-20200203143853-96a758eda86e // indirect
|
||||
github.com/superwhiskers/crunch/v3 v3.5.7 // indirect
|
||||
golang.org/x/mod v0.13.0 // indirect
|
||||
golang.org/x/net v0.17.0 // indirect
|
||||
golang.org/x/sys v0.13.0 // indirect
|
||||
golang.org/x/term v0.13.0 // indirect
|
||||
golang.org/x/text v0.13.0 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20231030173426-d783a09b4405 // indirect
|
||||
google.golang.org/protobuf v1.31.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20240404231335-c0f41cb1a7a0 // indirect
|
||||
golang.org/x/mod v0.17.0 // indirect
|
||||
golang.org/x/net v0.24.0 // indirect
|
||||
golang.org/x/sys v0.19.0 // indirect
|
||||
golang.org/x/term v0.19.0 // indirect
|
||||
golang.org/x/text v0.14.0 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda // indirect
|
||||
google.golang.org/protobuf v1.33.0 // indirect
|
||||
)
|
||||
|
|
|
|||
80
go.sum
80
go.sum
|
|
@ -2,55 +2,71 @@ github.com/PretendoNetwork/grpc-go v1.0.2 h1:9TvKmX7dCOANyoHEra1MMYqS1N/RGav66TR
|
|||
github.com/PretendoNetwork/grpc-go v1.0.2/go.mod h1:XZjEsij9lL7HJBNkH6JPbBIkUSq/1rjflvjGdv+DAj0=
|
||||
github.com/PretendoNetwork/nex-go v1.0.41 h1:TcBb1Bpe2KAB+AXaGX1K9NVQBRtZJIoy4yCvRde2xbI=
|
||||
github.com/PretendoNetwork/nex-go v1.0.41/go.mod h1:QwHEa165DeVd0xIuthrgc3j6NWXT8lyPSG6t5kC/Shk=
|
||||
github.com/PretendoNetwork/nex-protocols-common-go v1.0.28 h1:ErkWga7Uzn4WoDU8Q/Sy+geHy0fF0G/5wFnL5i6hngI=
|
||||
github.com/PretendoNetwork/nex-protocols-common-go v1.0.28/go.mod h1:4jYhLg+Cb2qhJHyyA+f2OwCrmc98zuTO3JPWK22mIKw=
|
||||
github.com/PretendoNetwork/nex-protocols-go v1.0.55 h1:8QMeCNO2eZO4m7CRT/nv2WWm+gDh/REKR5jKTYQaaCs=
|
||||
github.com/PretendoNetwork/nex-protocols-go v1.0.55/go.mod h1:136762CMIcAsTZDrt4W7gDE4ppiBuc9zN2QFOHESjS8=
|
||||
github.com/PretendoNetwork/nex-go/v2 v2.0.1 h1:7UEwulBtWD+HIbwB0uaRjBK1EXFLfSnv0t5+WyQYV0s=
|
||||
github.com/PretendoNetwork/nex-go/v2 v2.0.1/go.mod h1:EZNyRVr0WpPLHZQqZZvarQ8/tXsEyVqLr6zy/hKCAV4=
|
||||
github.com/PretendoNetwork/nex-protocols-common-go/v2 v2.0.1 h1:e8NNIfAnIeOqXraScvnbsyvw9S+lXq38NXp9JpPn9+4=
|
||||
github.com/PretendoNetwork/nex-protocols-common-go/v2 v2.0.1/go.mod h1:YEnnM1XDVGf34885MdHcRwZR/g9Qvjn3qkXlGlgiGPk=
|
||||
github.com/PretendoNetwork/nex-protocols-go v1.0.58 h1:W8pZ2LOlJm/mo/UOJjkLWNVHs0jQmkoa8qoI5A1WVyY=
|
||||
github.com/PretendoNetwork/nex-protocols-go v1.0.58/go.mod h1:136762CMIcAsTZDrt4W7gDE4ppiBuc9zN2QFOHESjS8=
|
||||
github.com/PretendoNetwork/nex-protocols-go/v2 v2.0.1 h1:BqrHYF2JeYfB/JUmhU3pWR1qUJEEqUDM4pigXzi95Ik=
|
||||
github.com/PretendoNetwork/nex-protocols-go/v2 v2.0.1/go.mod h1:TAzlc/gOu6E5Ct2NoTpN+Ea9Gpjh38dTsGqfs0pfZ4w=
|
||||
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/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs=
|
||||
github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw=
|
||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||
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/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
||||
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/dolthub/maphash v0.1.0 h1:bsQ7JsF4FkkWyrP3oCnFJgrCUAFbFf3kOl4L/QxPDyQ=
|
||||
github.com/dolthub/maphash v0.1.0/go.mod h1:gkg4Ch4CdCDu5h6PMriVLawB7koZ+5ijb9puGMV50a4=
|
||||
github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM=
|
||||
github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE=
|
||||
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
|
||||
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
|
||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
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.2.0 h1:g6Ha4u7Vm3LIsQ5wmeBpS4gazu0UP1DRDE8y6bre4H8=
|
||||
github.com/jwalton/go-supportscolor v1.2.0/go.mod h1:hFVUAZV2cWg+WFFC4v8pT2X/S2qUUBYMioBD9AINXGs=
|
||||
github.com/klauspost/compress v1.17.5 h1:d4vBd+7CHydUqpFBgUEKkSdtSugf9YFmSkvUYPquI5E=
|
||||
github.com/klauspost/compress v1.17.5/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM=
|
||||
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
|
||||
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
||||
github.com/lxzan/gws v1.8.0 h1:SqRuU6PUez/BA6CHB9BufV6n+gCnRtWHUntjLcaHA44=
|
||||
github.com/lxzan/gws v1.8.0/go.mod h1:FcGeRMB7HwGuTvMLR24ku0Zx0p6RXqeKASeMc4VYgi4=
|
||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
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/rasky/go-lzo v0.0.0-20200203143853-96a758eda86e h1:dCWirM5F3wMY+cmRda/B1BiPsFtmzXqV9b0hLWtVBMs=
|
||||
github.com/rasky/go-lzo v0.0.0-20200203143853-96a758eda86e/go.mod h1:9leZcVcItj6m9/CfHY5Em/iBrCz7js8LcRQGTKEEv2M=
|
||||
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/superwhiskers/crunch/v3 v3.5.7 h1:N9RLxaR65C36i26BUIpzPXGy2f6pQ7wisu2bawbKNqg=
|
||||
github.com/superwhiskers/crunch/v3 v3.5.7/go.mod h1:4ub2EKgF1MAhTjoOCTU4b9uLMsAweHEa89aRrfAypXA=
|
||||
golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI=
|
||||
golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo=
|
||||
golang.org/x/mod v0.13.0 h1:I/DsJXRlw/8l/0c24sM9yb0T4z9liZTduXvdAWYiysY=
|
||||
golang.org/x/mod v0.13.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
|
||||
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
|
||||
golang.org/x/exp v0.0.0-20240404231335-c0f41cb1a7a0 h1:985EYyeCOxTpcgOTJpflJUwOeEz0CQOdPt73OzpE9F8=
|
||||
golang.org/x/exp v0.0.0-20240404231335-c0f41cb1a7a0/go.mod h1:/lliqkxwWAhPjf5oSOIJup2XcqJaw8RGS6k3TGEc7GI=
|
||||
golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA=
|
||||
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||
golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w=
|
||||
golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
|
||||
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-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
|
||||
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
|
||||
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek=
|
||||
golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U=
|
||||
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
|
||||
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20231030173426-d783a09b4405 h1:AB/lmRny7e2pLhFEYIbl5qkDAUt2h0ZRO4wGPhZf+ik=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20231030173426-d783a09b4405/go.mod h1:67X1fPuzjcrkymZzZV1vvkFeTn2Rvc6lYF9MYFGCcwE=
|
||||
google.golang.org/grpc v1.58.3 h1:BjnpXut1btbtgN/6sp+brB2Kbm2LjNXnidYujAVbSoQ=
|
||||
google.golang.org/grpc v1.58.3/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0=
|
||||
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.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
|
||||
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||
golang.org/x/term v0.19.0 h1:+ThwsDv+tYfnJFhF4L8jITxu1tdTWRTZpdsWgEgjL6Q=
|
||||
golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk=
|
||||
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda h1:LI5DOvAxUPMv/50agcLLoo+AdWc1irS9Rzz4vPuD1V4=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY=
|
||||
google.golang.org/grpc v1.63.0 h1:WjKe+dnvABXyPJMD7KDNLxtoGk5tgk+YFWN6cBWjZE8=
|
||||
google.golang.org/grpc v1.63.0/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA=
|
||||
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
|
||||
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import (
|
|||
database_wiiu "github.com/PretendoNetwork/friends/database/wiiu"
|
||||
"github.com/PretendoNetwork/friends/globals"
|
||||
pb "github.com/PretendoNetwork/grpc-go/friends"
|
||||
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds/types"
|
||||
)
|
||||
|
||||
func (s *gRPCFriendsServer) GetUserFriendPIDs(ctx context.Context, in *pb.GetUserFriendPIDsRequest) (*pb.GetUserFriendPIDsResponse, error) {
|
||||
|
|
@ -37,11 +38,15 @@ func (s *gRPCFriendsServer) GetUserFriendPIDs(ctx context.Context, in *pb.GetUse
|
|||
return nil, status.Errorf(codes.Internal, "internal server error")
|
||||
}
|
||||
|
||||
for _, relationship := range relationships {
|
||||
// * Only add complete relationships to the list
|
||||
if relationship.RelationshipType == 1 {
|
||||
pids = append(pids, relationship.PID.LegacyValue())
|
||||
}
|
||||
if relationships != nil {
|
||||
relationships.Each(func(i int, relationship *friends_3ds_types.FriendRelationship) bool {
|
||||
// * Only add complete relationships to the list
|
||||
if relationship.RelationshipType.Value == 1 {
|
||||
pids = append(pids, relationship.PID.LegacyValue())
|
||||
}
|
||||
|
||||
return false
|
||||
})
|
||||
}
|
||||
|
||||
return &pb.GetUserFriendPIDsResponse{
|
||||
|
|
|
|||
|
|
@ -10,29 +10,33 @@ import (
|
|||
database_wiiu "github.com/PretendoNetwork/friends/database/wiiu"
|
||||
"github.com/PretendoNetwork/friends/globals"
|
||||
pb "github.com/PretendoNetwork/grpc-go/friends"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu/types"
|
||||
)
|
||||
|
||||
func (s *gRPCFriendsServer) GetUserFriendRequestsIncoming(ctx context.Context, in *pb.GetUserFriendRequestsIncomingRequest) (*pb.GetUserFriendRequestsIncomingResponse, error) {
|
||||
|
||||
friendRequestsIn, err := database_wiiu.GetUserFriendRequestsIn(in.GetPid())
|
||||
if err != nil && err != database.ErrEmptyList {
|
||||
globals.Logger.Critical(err.Error())
|
||||
return nil, status.Errorf(codes.Internal, "internal server error")
|
||||
}
|
||||
|
||||
friendRequests := make([]*pb.FriendRequest, 0, len(friendRequestsIn))
|
||||
friendRequests := make([]*pb.FriendRequest, 0, friendRequestsIn.Length())
|
||||
|
||||
for i := 0; i < len(friendRequestsIn); i++ {
|
||||
friendRequest := &pb.FriendRequest{
|
||||
Id: friendRequestsIn[i].Message.FriendRequestID,
|
||||
Sender: friendRequestsIn[i].PrincipalInfo.PID.LegacyValue(),
|
||||
Recipient: in.GetPid(),
|
||||
Sent: uint64(friendRequestsIn[i].SentOn.Standard().Unix()),
|
||||
Expires: uint64(friendRequestsIn[i].Message.ExpiresOn.Standard().Unix()),
|
||||
Message: friendRequestsIn[i].Message.Message,
|
||||
}
|
||||
if friendRequestsIn != nil {
|
||||
friendRequestsIn.Each(func(i int, friendRequestIn *friends_wiiu_types.FriendRequest) bool {
|
||||
friendRequest := &pb.FriendRequest{
|
||||
Id: friendRequestIn.Message.FriendRequestID.Value,
|
||||
Sender: friendRequestIn.PrincipalInfo.PID.LegacyValue(),
|
||||
Recipient: in.GetPid(),
|
||||
Sent: uint64(friendRequestIn.SentOn.Standard().Unix()),
|
||||
Expires: uint64(friendRequestIn.Message.ExpiresOn.Standard().Unix()),
|
||||
Message: friendRequestIn.Message.Message.Value,
|
||||
}
|
||||
|
||||
friendRequests = append(friendRequests, friendRequest)
|
||||
friendRequests = append(friendRequests, friendRequest)
|
||||
|
||||
return false
|
||||
})
|
||||
}
|
||||
|
||||
return &pb.GetUserFriendRequestsIncomingResponse{
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import (
|
|||
database_wiiu "github.com/PretendoNetwork/friends/database/wiiu"
|
||||
"github.com/PretendoNetwork/friends/globals"
|
||||
pb "github.com/PretendoNetwork/grpc-go/friends"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
)
|
||||
|
||||
func (s *gRPCFriendsServer) SendUserFriendRequest(ctx context.Context, in *pb.SendUserFriendRequestRequest) (*pb.SendUserFriendRequestResponse, error) {
|
||||
|
|
@ -20,8 +20,8 @@ func (s *gRPCFriendsServer) SendUserFriendRequest(ctx context.Context, in *pb.Se
|
|||
currentTimestamp := time.Now()
|
||||
expireTimestamp := currentTimestamp.Add(time.Hour * 24 * 29)
|
||||
|
||||
sentTime := nex.NewDateTime(0)
|
||||
expireTime := nex.NewDateTime(0)
|
||||
sentTime := types.NewDateTime(0)
|
||||
expireTime := types.NewDateTime(0)
|
||||
|
||||
sentTime.FromTimestamp(currentTimestamp)
|
||||
expireTime.FromTimestamp(expireTimestamp)
|
||||
|
|
|
|||
|
|
@ -5,8 +5,9 @@ import (
|
|||
|
||||
"github.com/PretendoNetwork/friends/globals"
|
||||
pb "github.com/PretendoNetwork/grpc-go/friends"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nintendo_notifications "github.com/PretendoNetwork/nex-protocols-go/nintendo-notifications"
|
||||
nex "github.com/PretendoNetwork/nex-go/v2"
|
||||
"github.com/PretendoNetwork/nex-go/v2/constants"
|
||||
nintendo_notifications "github.com/PretendoNetwork/nex-protocols-go/v2/nintendo-notifications"
|
||||
empty "github.com/golang/protobuf/ptypes/empty"
|
||||
)
|
||||
|
||||
|
|
@ -15,7 +16,7 @@ func (s *gRPCFriendsServer) SendUserNotificationWiiU(ctx context.Context, in *pb
|
|||
connectedUser := globals.ConnectedUsers[in.GetPid()]
|
||||
|
||||
if connectedUser != nil {
|
||||
rmcRequest := nex.NewRMCRequest(globals.SecureServer)
|
||||
rmcRequest := nex.NewRMCRequest(globals.SecureEndpoint)
|
||||
rmcRequest.ProtocolID = nintendo_notifications.ProtocolID
|
||||
rmcRequest.CallID = 3810693103
|
||||
rmcRequest.MethodID = nintendo_notifications.MethodProcessNintendoNotificationEvent2
|
||||
|
|
@ -23,15 +24,15 @@ func (s *gRPCFriendsServer) SendUserNotificationWiiU(ctx context.Context, in *pb
|
|||
|
||||
rmcRequestBytes := rmcRequest.Bytes()
|
||||
|
||||
requestPacket, _ := nex.NewPRUDPPacketV0(connectedUser.Client, nil)
|
||||
requestPacket, _ := nex.NewPRUDPPacketV0(globals.SecureEndpoint.Server, connectedUser.Connection, nil)
|
||||
|
||||
requestPacket.SetType(nex.DataPacket)
|
||||
requestPacket.AddFlag(nex.FlagNeedsAck)
|
||||
requestPacket.AddFlag(nex.FlagReliable)
|
||||
requestPacket.SetSourceStreamType(connectedUser.Client.DestinationStreamType)
|
||||
requestPacket.SetSourcePort(connectedUser.Client.DestinationPort)
|
||||
requestPacket.SetDestinationStreamType(connectedUser.Client.SourceStreamType)
|
||||
requestPacket.SetDestinationPort(connectedUser.Client.SourcePort)
|
||||
requestPacket.SetType(constants.DataPacket)
|
||||
requestPacket.AddFlag(constants.PacketFlagNeedsAck)
|
||||
requestPacket.AddFlag(constants.PacketFlagReliable)
|
||||
requestPacket.SetSourceVirtualPortStreamType(connectedUser.Connection.StreamType)
|
||||
requestPacket.SetSourceVirtualPortStreamID(globals.SecureEndpoint.StreamID)
|
||||
requestPacket.SetDestinationVirtualPortStreamType(connectedUser.Connection.StreamType)
|
||||
requestPacket.SetDestinationVirtualPortStreamID(connectedUser.Connection.StreamID)
|
||||
requestPacket.SetPayload(rmcRequestBytes)
|
||||
|
||||
globals.SecureServer.Send(requestPacket)
|
||||
|
|
|
|||
17
init.go
17
init.go
|
|
@ -10,8 +10,8 @@ import (
|
|||
"github.com/PretendoNetwork/friends/database"
|
||||
"github.com/PretendoNetwork/friends/globals"
|
||||
"github.com/PretendoNetwork/friends/types"
|
||||
"github.com/PretendoNetwork/plogger-go"
|
||||
pb "github.com/PretendoNetwork/grpc-go/account"
|
||||
"github.com/PretendoNetwork/plogger-go"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
"google.golang.org/grpc/metadata"
|
||||
|
|
@ -31,7 +31,8 @@ func init() {
|
|||
}
|
||||
|
||||
postgresURI := os.Getenv("PN_FRIENDS_CONFIG_DATABASE_URI")
|
||||
kerberosPassword := os.Getenv("PN_FRIENDS_CONFIG_KERBEROS_PASSWORD")
|
||||
authenticationServerPassword := os.Getenv("PN_FRIENDS_CONFIG_AUTHENTICATION_PASSWORD")
|
||||
secureServerPassword := os.Getenv("PN_FRIENDS_CONFIG_SECURE_PASSWORD")
|
||||
aesKey := os.Getenv("PN_FRIENDS_CONFIG_AES_KEY")
|
||||
grpcAPIKey := os.Getenv("PN_FRIENDS_CONFIG_GRPC_API_KEY")
|
||||
grpcServerPort := os.Getenv("PN_FRIENDS_GRPC_SERVER_PORT")
|
||||
|
|
@ -47,10 +48,14 @@ func init() {
|
|||
os.Exit(0)
|
||||
}
|
||||
|
||||
if strings.TrimSpace(kerberosPassword) == "" {
|
||||
globals.Logger.Warningf("PN_FRIENDS_CONFIG_KERBEROS_PASSWORD environment variable not set. Using default password: %q", globals.KerberosPassword)
|
||||
} else {
|
||||
globals.KerberosPassword = kerberosPassword
|
||||
if strings.TrimSpace(authenticationServerPassword) == "" {
|
||||
globals.Logger.Error("PN_FRIENDS_CONFIG_AUTHENTICATION_PASSWORD environment variable not set")
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
if strings.TrimSpace(secureServerPassword) == "" {
|
||||
globals.Logger.Error("PN_FRIENDS_CONFIG_SECURE_PASSWORD environment variable not set")
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
if strings.TrimSpace(aesKey) == "" {
|
||||
|
|
|
|||
|
|
@ -10,75 +10,76 @@ import (
|
|||
|
||||
"github.com/PretendoNetwork/friends/globals"
|
||||
"github.com/PretendoNetwork/friends/utility"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
account_management "github.com/PretendoNetwork/nex-protocols-go/account-management"
|
||||
account_management_types "github.com/PretendoNetwork/nex-protocols-go/account-management/types"
|
||||
nex "github.com/PretendoNetwork/nex-go/v2"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
account_management "github.com/PretendoNetwork/nex-protocols-go/v2/account-management"
|
||||
account_management_types "github.com/PretendoNetwork/nex-protocols-go/v2/account-management/types"
|
||||
)
|
||||
|
||||
func NintendoCreateAccount(err error, packet nex.PacketInterface, callID uint32, strPrincipalName string, strKey string, uiGroups uint32, strEmail string, oAuthData *nex.DataHolder) (*nex.RMCMessage, uint32) {
|
||||
func NintendoCreateAccount(err error, packet nex.PacketInterface, callID uint32, strPrincipalName *types.String, strKey *types.String, uiGroups *types.PrimitiveU32, strEmail *types.String, oAuthData *types.AnyDataHolder) (*nex.RMCMessage, *nex.Error) {
|
||||
if err != nil {
|
||||
globals.Logger.Error(err.Error())
|
||||
return nil, nex.Errors.Core.InvalidArgument
|
||||
return nil, nex.NewError(nex.ResultCodes.Core.InvalidArgument, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
var tokenBase64 string
|
||||
|
||||
oAuthDataType := oAuthData.TypeName()
|
||||
oAuthDataType := oAuthData.TypeName.Value
|
||||
|
||||
switch oAuthDataType {
|
||||
case "NintendoCreateAccountData": // * Wii U
|
||||
nintendoCreateAccountData := oAuthData.ObjectData().(*account_management_types.NintendoCreateAccountData)
|
||||
nintendoCreateAccountData := oAuthData.ObjectData.Copy().(*account_management_types.NintendoCreateAccountData)
|
||||
|
||||
tokenBase64 = nintendoCreateAccountData.Token
|
||||
tokenBase64 = nintendoCreateAccountData.Token.Value
|
||||
case "AccountExtraInfo": // * 3DS
|
||||
accountExtraInfo := oAuthData.ObjectData().(*account_management_types.AccountExtraInfo)
|
||||
accountExtraInfo := oAuthData.ObjectData.Copy().(*account_management_types.AccountExtraInfo)
|
||||
|
||||
tokenBase64 = accountExtraInfo.NEXToken
|
||||
tokenBase64 = accountExtraInfo.NEXToken.Value
|
||||
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 nil, nex.Errors.Authentication.TokenParseError
|
||||
return nil, nex.NewError(nex.ResultCodes.Authentication.TokenParseError, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
encryptedToken, err := base64.StdEncoding.DecodeString(tokenBase64)
|
||||
if err != nil {
|
||||
globals.Logger.Error(err.Error())
|
||||
return nil, nex.Errors.Authentication.TokenParseError
|
||||
return nil, nex.NewError(nex.ResultCodes.Authentication.TokenParseError, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
decryptedToken, err := utility.DecryptToken(encryptedToken)
|
||||
if err != nil {
|
||||
globals.Logger.Error(err.Error())
|
||||
return nil, nex.Errors.Authentication.TokenParseError
|
||||
return nil, nex.NewError(nex.ResultCodes.Authentication.TokenParseError, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
pid := decryptedToken.UserPID
|
||||
pid := types.NewPID(uint64(decryptedToken.UserPID))
|
||||
|
||||
pidByteArray := make([]byte, 4)
|
||||
binary.LittleEndian.PutUint32(pidByteArray, pid)
|
||||
binary.LittleEndian.PutUint32(pidByteArray, pid.LegacyValue())
|
||||
|
||||
mac := hmac.New(md5.New, []byte(strKey))
|
||||
mac := hmac.New(md5.New, []byte(strKey.Value))
|
||||
_, err = mac.Write(pidByteArray)
|
||||
if err != nil {
|
||||
globals.Logger.Error(err.Error())
|
||||
return nil, nex.Errors.Authentication.Unknown
|
||||
return nil, nex.NewError(nex.ResultCodes.Authentication.Unknown, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
pidHmac := hex.EncodeToString(mac.Sum(nil))
|
||||
pidHmac := types.NewString(hex.EncodeToString(mac.Sum(nil)))
|
||||
|
||||
rmcResponseStream := nex.NewStreamOut(globals.SecureServer)
|
||||
rmcResponseStream := nex.NewByteStreamOut(globals.SecureEndpoint.LibraryVersions(), globals.SecureEndpoint.ByteStreamSettings())
|
||||
|
||||
rmcResponseStream.WriteUInt32LE(pid)
|
||||
rmcResponseStream.WriteString(pidHmac)
|
||||
pid.WriteTo(rmcResponseStream)
|
||||
pidHmac.WriteTo(rmcResponseStream)
|
||||
|
||||
rmcResponseBody := rmcResponseStream.Bytes()
|
||||
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureServer, rmcResponseBody)
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureEndpoint, rmcResponseBody)
|
||||
rmcResponse.ProtocolID = account_management.ProtocolID
|
||||
rmcResponse.MethodID = account_management.MethodNintendoCreateAccount
|
||||
rmcResponse.CallID = callID
|
||||
|
||||
return rmcResponse, 0
|
||||
return rmcResponse, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,20 +6,23 @@ import (
|
|||
"strconv"
|
||||
|
||||
"github.com/PretendoNetwork/friends/globals"
|
||||
"github.com/PretendoNetwork/nex-go"
|
||||
"github.com/PretendoNetwork/nex-go/v2"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
)
|
||||
|
||||
var serverBuildString string
|
||||
|
||||
func StartAuthenticationServer() {
|
||||
globals.AuthenticationServer = nex.NewPRUDPServer()
|
||||
globals.AuthenticationServer.SetFragmentSize(962)
|
||||
globals.AuthenticationServer.SetDefaultLibraryVersion(nex.NewLibraryVersion(1, 1, 0))
|
||||
globals.AuthenticationServer.SetKerberosPassword([]byte(globals.KerberosPassword))
|
||||
globals.AuthenticationServer.SetKerberosKeySize(16)
|
||||
globals.AuthenticationServer.SetAccessKey("ridfebb9")
|
||||
port, _ := strconv.Atoi(os.Getenv("PN_FRIENDS_AUTHENTICATION_SERVER_PORT"))
|
||||
|
||||
globals.AuthenticationServer.OnData(func(packet nex.PacketInterface) {
|
||||
globals.AuthenticationServer = nex.NewPRUDPServer()
|
||||
globals.AuthenticationEndpoint = nex.NewPRUDPEndPoint(1)
|
||||
|
||||
globals.AuthenticationEndpoint.AccountDetailsByPID = globals.AccountDetailsByPID
|
||||
globals.AuthenticationEndpoint.AccountDetailsByUsername = globals.AccountDetailsByUsername
|
||||
globals.AuthenticationEndpoint.ServerAccount = nex.NewAccount(types.NewPID(1), "Quazal Authentication", os.Getenv("PN_FRIENDS_CONFIG_AUTHENTICATION_PASSWORD"))
|
||||
|
||||
globals.AuthenticationEndpoint.OnData(func(packet nex.PacketInterface) {
|
||||
request := packet.RMCMessage()
|
||||
|
||||
fmt.Println("==Friends - Auth==")
|
||||
|
|
@ -30,6 +33,10 @@ func StartAuthenticationServer() {
|
|||
|
||||
registerCommonAuthenticationServerProtocols()
|
||||
|
||||
port, _ := strconv.Atoi(os.Getenv("PN_FRIENDS_AUTHENTICATION_SERVER_PORT"))
|
||||
globals.AuthenticationServer.SetFragmentSize(962)
|
||||
globals.AuthenticationServer.LibraryVersions.SetDefault(nex.NewLibraryVersion(1, 1, 0))
|
||||
globals.AuthenticationServer.SessionKeyLength = 16
|
||||
globals.AuthenticationServer.AccessKey = "ridfebb9"
|
||||
globals.AuthenticationServer.BindPRUDPEndPoint(globals.AuthenticationEndpoint)
|
||||
globals.AuthenticationServer.Listen(port)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,39 +4,40 @@ import (
|
|||
database_3ds "github.com/PretendoNetwork/friends/database/3ds"
|
||||
"github.com/PretendoNetwork/friends/globals"
|
||||
notifications_3ds "github.com/PretendoNetwork/friends/notifications/3ds"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends-3ds"
|
||||
nex "github.com/PretendoNetwork/nex-go/v2"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds"
|
||||
)
|
||||
|
||||
func AddFriendshipByPrincipalID(err error, packet nex.PacketInterface, callID uint32, lfc uint64, pid *nex.PID) (*nex.RMCMessage, uint32) {
|
||||
func AddFriendByPrincipalID(err error, packet nex.PacketInterface, callID uint32, lfc *types.PrimitiveU64, pid *types.PID) (*nex.RMCMessage, *nex.Error) {
|
||||
if err != nil {
|
||||
globals.Logger.Error(err.Error())
|
||||
return nil, nex.Errors.FPD.InvalidArgument
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.InvalidArgument, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
client := packet.Sender().(*nex.PRUDPClient)
|
||||
connection := packet.Sender().(*nex.PRUDPConnection)
|
||||
|
||||
friendRelationship, err := database_3ds.SaveFriendship(client.PID().LegacyValue(), pid.LegacyValue())
|
||||
friendRelationship, err := database_3ds.SaveFriendship(connection.PID().LegacyValue(), pid.LegacyValue())
|
||||
if err != nil {
|
||||
globals.Logger.Critical(err.Error())
|
||||
return nil, nex.Errors.FPD.Unknown
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
connectedUser := globals.ConnectedUsers[pid.LegacyValue()]
|
||||
if connectedUser != nil {
|
||||
go notifications_3ds.SendFriendshipCompleted(connectedUser.Client, pid.LegacyValue(), client.PID())
|
||||
go notifications_3ds.SendFriendshipCompleted(connectedUser.Connection, pid.LegacyValue(), connection.PID())
|
||||
}
|
||||
|
||||
rmcResponseStream := nex.NewStreamOut(globals.SecureServer)
|
||||
rmcResponseStream := nex.NewByteStreamOut(globals.SecureEndpoint.LibraryVersions(), globals.SecureEndpoint.ByteStreamSettings())
|
||||
|
||||
rmcResponseStream.WriteStructure(friendRelationship)
|
||||
friendRelationship.WriteTo(rmcResponseStream)
|
||||
|
||||
rmcResponseBody := rmcResponseStream.Bytes()
|
||||
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureServer, rmcResponseBody)
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureEndpoint, rmcResponseBody)
|
||||
rmcResponse.ProtocolID = friends_3ds.ProtocolID
|
||||
rmcResponse.MethodID = friends_3ds.MethodAddFriendByPrincipalID
|
||||
rmcResponse.CallID = callID
|
||||
|
||||
return rmcResponse, 0
|
||||
return rmcResponse, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,34 +5,34 @@ import (
|
|||
|
||||
database_3ds "github.com/PretendoNetwork/friends/database/3ds"
|
||||
"github.com/PretendoNetwork/friends/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends-3ds"
|
||||
nex "github.com/PretendoNetwork/nex-go/v2"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds"
|
||||
)
|
||||
|
||||
func GetAllFriends(err error, packet nex.PacketInterface, callID uint32) (*nex.RMCMessage, uint32) {
|
||||
func GetAllFriends(err error, packet nex.PacketInterface, callID uint32) (*nex.RMCMessage, *nex.Error) {
|
||||
if err != nil {
|
||||
globals.Logger.Error(err.Error())
|
||||
return nil, nex.Errors.FPD.Unknown
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
client := packet.Sender().(*nex.PRUDPClient)
|
||||
connection := packet.Sender().(*nex.PRUDPConnection)
|
||||
|
||||
friendRelationships, err := database_3ds.GetUserFriends(client.PID().LegacyValue())
|
||||
friendRelationships, err := database_3ds.GetUserFriends(connection.PID().LegacyValue())
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
globals.Logger.Critical(err.Error())
|
||||
return nil, nex.Errors.FPD.Unknown
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
rmcResponseStream := nex.NewStreamOut(globals.SecureServer)
|
||||
rmcResponseStream := nex.NewByteStreamOut(globals.SecureEndpoint.LibraryVersions(), globals.SecureEndpoint.ByteStreamSettings())
|
||||
|
||||
nex.StreamWriteListStructure(rmcResponseStream, friendRelationships)
|
||||
friendRelationships.WriteTo(rmcResponseStream)
|
||||
|
||||
rmcResponseBody := rmcResponseStream.Bytes()
|
||||
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureServer, rmcResponseBody)
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureEndpoint, rmcResponseBody)
|
||||
rmcResponse.ProtocolID = friends_3ds.ProtocolID
|
||||
rmcResponse.MethodID = friends_3ds.MethodGetAllFriends
|
||||
rmcResponse.CallID = callID
|
||||
|
||||
return rmcResponse, 0
|
||||
return rmcResponse, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,39 +5,42 @@ import (
|
|||
|
||||
database_3ds "github.com/PretendoNetwork/friends/database/3ds"
|
||||
"github.com/PretendoNetwork/friends/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends-3ds"
|
||||
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/friends-3ds/types"
|
||||
nex "github.com/PretendoNetwork/nex-go/v2"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds"
|
||||
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds/types"
|
||||
)
|
||||
|
||||
func GetFriendMii(err error, packet nex.PacketInterface, callID uint32, friends []*friends_3ds_types.FriendInfo) (*nex.RMCMessage, uint32) {
|
||||
func GetFriendMii(err error, packet nex.PacketInterface, callID uint32, friends *types.List[*friends_3ds_types.FriendInfo]) (*nex.RMCMessage, *nex.Error) {
|
||||
if err != nil {
|
||||
globals.Logger.Error(err.Error())
|
||||
return nil, nex.Errors.FPD.InvalidArgument
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.InvalidArgument, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
pids := make([]uint32, 0, len(friends))
|
||||
pids := make([]uint32, 0, friends.Length())
|
||||
|
||||
for _, friend := range friends {
|
||||
friends.Each(func(i int, friend *friends_3ds_types.FriendInfo) bool {
|
||||
pids = append(pids, friend.PID.LegacyValue())
|
||||
}
|
||||
|
||||
return false
|
||||
})
|
||||
|
||||
miiList, err := database_3ds.GetFriendMiis(pids)
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
globals.Logger.Critical(err.Error())
|
||||
return nil, nex.Errors.FPD.Unknown
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
rmcResponseStream := nex.NewStreamOut(globals.SecureServer)
|
||||
rmcResponseStream := nex.NewByteStreamOut(globals.SecureEndpoint.LibraryVersions(), globals.SecureEndpoint.ByteStreamSettings())
|
||||
|
||||
nex.StreamWriteListStructure(rmcResponseStream, miiList)
|
||||
miiList.WriteTo(rmcResponseStream)
|
||||
|
||||
rmcResponseBody := rmcResponseStream.Bytes()
|
||||
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureServer, rmcResponseBody)
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureEndpoint, rmcResponseBody)
|
||||
rmcResponse.ProtocolID = friends_3ds.ProtocolID
|
||||
rmcResponse.MethodID = friends_3ds.MethodGetFriendMii
|
||||
rmcResponse.CallID = callID
|
||||
|
||||
return rmcResponse, 0
|
||||
return rmcResponse, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,40 +5,43 @@ import (
|
|||
|
||||
database_3ds "github.com/PretendoNetwork/friends/database/3ds"
|
||||
"github.com/PretendoNetwork/friends/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends-3ds"
|
||||
nex "github.com/PretendoNetwork/nex-go/v2"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds"
|
||||
)
|
||||
|
||||
func GetFriendPersistentInfo(err error, packet nex.PacketInterface, callID uint32, pids []*nex.PID) (*nex.RMCMessage, uint32) {
|
||||
func GetFriendPersistentInfo(err error, packet nex.PacketInterface, callID uint32, pidList *types.List[*types.PID]) (*nex.RMCMessage, *nex.Error) {
|
||||
if err != nil {
|
||||
globals.Logger.Error(err.Error())
|
||||
return nil, nex.Errors.FPD.Unknown
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
client := packet.Sender().(*nex.PRUDPClient)
|
||||
connection := packet.Sender().(*nex.PRUDPConnection)
|
||||
|
||||
friendPIDs := make([]uint32, len(pids))
|
||||
friendPIDs := make([]uint32, pidList.Length())
|
||||
|
||||
for _, pid := range pids {
|
||||
pidList.Each(func(i int, pid *types.PID) bool {
|
||||
friendPIDs = append(friendPIDs, pid.LegacyValue())
|
||||
}
|
||||
|
||||
infoList, err := database_3ds.GetFriendPersistentInfos(client.PID().LegacyValue(), friendPIDs)
|
||||
return false
|
||||
})
|
||||
|
||||
infoList, err := database_3ds.GetFriendPersistentInfos(connection.PID().LegacyValue(), friendPIDs)
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
globals.Logger.Critical(err.Error())
|
||||
return nil, nex.Errors.FPD.Unknown
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
rmcResponseStream := nex.NewStreamOut(globals.SecureServer)
|
||||
rmcResponseStream := nex.NewByteStreamOut(globals.SecureEndpoint.LibraryVersions(), globals.SecureEndpoint.ByteStreamSettings())
|
||||
|
||||
nex.StreamWriteListStructure(rmcResponseStream, infoList)
|
||||
infoList.WriteTo(rmcResponseStream)
|
||||
|
||||
rmcResponseBody := rmcResponseStream.Bytes()
|
||||
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureServer, rmcResponseBody)
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureEndpoint, rmcResponseBody)
|
||||
rmcResponse.ProtocolID = friends_3ds.ProtocolID
|
||||
rmcResponse.MethodID = friends_3ds.MethodGetFriendPersistentInfo
|
||||
rmcResponse.CallID = callID
|
||||
|
||||
return rmcResponse, 0
|
||||
return rmcResponse, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,41 +2,45 @@ package nex_friends_3ds
|
|||
|
||||
import (
|
||||
"github.com/PretendoNetwork/friends/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends-3ds"
|
||||
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/friends-3ds/types"
|
||||
nex "github.com/PretendoNetwork/nex-go/v2"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds"
|
||||
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds/types"
|
||||
)
|
||||
|
||||
func GetFriendPresence(err error, packet nex.PacketInterface, callID uint32, pids []*nex.PID) (*nex.RMCMessage, uint32) {
|
||||
func GetFriendPresence(err error, packet nex.PacketInterface, callID uint32, pidList *types.List[*types.PID]) (*nex.RMCMessage, *nex.Error) {
|
||||
if err != nil {
|
||||
globals.Logger.Error(err.Error())
|
||||
return nil, nex.Errors.FPD.Unknown
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
presenceList := make([]*friends_3ds_types.FriendPresence, 0)
|
||||
presenceList := types.NewList[*friends_3ds_types.FriendPresence]()
|
||||
presenceList.Type = friends_3ds_types.NewFriendPresence()
|
||||
|
||||
for i := 0; i < len(pids); i++ {
|
||||
connectedUser := globals.ConnectedUsers[pids[i].LegacyValue()]
|
||||
pidList.Each(func(i int, pid *types.PID) bool {
|
||||
connectedUser := globals.ConnectedUsers[pid.LegacyValue()]
|
||||
|
||||
if connectedUser != nil && connectedUser.Presence != nil {
|
||||
friendPresence := friends_3ds_types.NewFriendPresence()
|
||||
friendPresence.PID = pids[i]
|
||||
friendPresence.Presence = globals.ConnectedUsers[pids[i].LegacyValue()].Presence
|
||||
friendPresence.PID = pid.Copy().(*types.PID)
|
||||
friendPresence.Presence = globals.ConnectedUsers[pid.LegacyValue()].Presence
|
||||
|
||||
presenceList = append(presenceList, friendPresence)
|
||||
presenceList.Append(friendPresence)
|
||||
}
|
||||
}
|
||||
|
||||
rmcResponseStream := nex.NewStreamOut(globals.SecureServer)
|
||||
return false
|
||||
})
|
||||
|
||||
nex.StreamWriteListStructure(rmcResponseStream, presenceList)
|
||||
rmcResponseStream := nex.NewByteStreamOut(globals.SecureEndpoint.LibraryVersions(), globals.SecureEndpoint.ByteStreamSettings())
|
||||
|
||||
presenceList.WriteTo(rmcResponseStream)
|
||||
|
||||
rmcResponseBody := rmcResponseStream.Bytes()
|
||||
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureServer, rmcResponseBody)
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureEndpoint, rmcResponseBody)
|
||||
rmcResponse.ProtocolID = friends_3ds.ProtocolID
|
||||
rmcResponse.MethodID = friends_3ds.MethodGetFriendPresence
|
||||
rmcResponse.CallID = callID
|
||||
|
||||
return rmcResponse, 0
|
||||
return rmcResponse, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,19 +2,20 @@ package nex_friends_3ds
|
|||
|
||||
import (
|
||||
// "github.com/PretendoNetwork/friends/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
// friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends-3ds"
|
||||
nex "github.com/PretendoNetwork/nex-go/v2"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
// friends_3ds "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds"
|
||||
)
|
||||
|
||||
func GetPrincipalIDByLocalFriendCode(err error, packet nex.PacketInterface, callID uint32, lfc uint64, lfcList []uint64) (*nex.RMCMessage, uint32) {
|
||||
func GetPrincipalIDByLocalFriendCode(err error, packet nex.PacketInterface, callID uint32, lfc *types.PrimitiveU64, lfcList *types.List[*types.PrimitiveU64]) (*nex.RMCMessage, *nex.Error) {
|
||||
// Respond with unimplemented, waiting for gRPC to retrieve PID from account server
|
||||
|
||||
// rmcResponse := nex.NewRMCResponse(friends_3ds.ProtocolID, callID)
|
||||
// rmcResponse.SetError(nex.Errors.Core.NotImplemented)
|
||||
// rmcResponse.SetError(nex.ResultCodes.Core.NotImplemented)
|
||||
|
||||
// rmcResponseBytes := rmcResponse.Bytes()
|
||||
|
||||
// responsePacket, _ := nex.NewPRUDPPacketV0(client, nil)
|
||||
// responsePacket, _ := nex.NewPRUDPPacketV0(connection, nil)
|
||||
|
||||
//
|
||||
// responsePacket.SetSource(0xA1)
|
||||
|
|
@ -27,5 +28,5 @@ func GetPrincipalIDByLocalFriendCode(err error, packet nex.PacketInterface, call
|
|||
|
||||
// globals.SecureServer.Send(responsePacket)
|
||||
|
||||
return nil, nex.Errors.Core.NotImplemented
|
||||
return nil, nex.NewError(nex.ResultCodes.Core.NotImplemented, "") // TODO - Add error message
|
||||
}
|
||||
|
|
@ -2,19 +2,20 @@ package nex_friends_3ds
|
|||
|
||||
import (
|
||||
// "github.com/PretendoNetwork/friends/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
// friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends-3ds"
|
||||
nex "github.com/PretendoNetwork/nex-go/v2"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
// friends_3ds "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds"
|
||||
)
|
||||
|
||||
func RemoveFriendByLocalFriendCode(err error, packet nex.PacketInterface, callID uint32, friendLFC uint64) (*nex.RMCMessage, uint32) {
|
||||
func RemoveFriendByLocalFriendCode(err error, packet nex.PacketInterface, callID uint32, lfc *types.PrimitiveU64) (*nex.RMCMessage, *nex.Error) {
|
||||
// Respond with unimplemented, waiting for gRPC to retrieve PID from account server
|
||||
|
||||
// rmcResponse := nex.NewRMCResponse(friends_3ds.ProtocolID, callID)
|
||||
// rmcResponse.SetError(nex.Errors.Core.NotImplemented)
|
||||
// rmcResponse.SetError(nex.ResultCodes.Core.NotImplemented)
|
||||
|
||||
// rmcResponseBytes := rmcResponse.Bytes()
|
||||
|
||||
// responsePacket, _ := nex.NewPRUDPPacketV0(client, nil)
|
||||
// responsePacket, _ := nex.NewPRUDPPacketV0(connection, nil)
|
||||
|
||||
//
|
||||
// responsePacket.SetSource(0xA1)
|
||||
|
|
@ -27,5 +28,5 @@ func RemoveFriendByLocalFriendCode(err error, packet nex.PacketInterface, callID
|
|||
|
||||
// globals.SecureServer.Send(responsePacket)
|
||||
|
||||
return nil, nex.Errors.Core.NotImplemented
|
||||
return nil, nex.NewError(nex.ResultCodes.Core.NotImplemented, "") // TODO - Add error message
|
||||
}
|
||||
|
|
@ -5,36 +5,37 @@ import (
|
|||
database_3ds "github.com/PretendoNetwork/friends/database/3ds"
|
||||
"github.com/PretendoNetwork/friends/globals"
|
||||
notifications_3ds "github.com/PretendoNetwork/friends/notifications/3ds"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends-3ds"
|
||||
nex "github.com/PretendoNetwork/nex-go/v2"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds"
|
||||
)
|
||||
|
||||
func RemoveFriendByPrincipalID(err error, packet nex.PacketInterface, callID uint32, pid *nex.PID) (*nex.RMCMessage, uint32) {
|
||||
func RemoveFriendByPrincipalID(err error, packet nex.PacketInterface, callID uint32, pid *types.PID) (*nex.RMCMessage, *nex.Error) {
|
||||
if err != nil {
|
||||
globals.Logger.Error(err.Error())
|
||||
return nil, nex.Errors.FPD.InvalidArgument
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.InvalidArgument, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
client := packet.Sender().(*nex.PRUDPClient)
|
||||
connection := packet.Sender().(*nex.PRUDPConnection)
|
||||
|
||||
err = database_3ds.RemoveFriendship(client.PID().LegacyValue(), pid.LegacyValue())
|
||||
err = database_3ds.RemoveFriendship(connection.PID().LegacyValue(), pid.LegacyValue())
|
||||
if err != nil {
|
||||
if err == database.ErrFriendshipNotFound {
|
||||
// * Official servers don't actually check this, but
|
||||
// * we'll do it ourselves
|
||||
return nil, nex.Errors.FPD.NotFriend
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.NotFriend, "") // TODO - Add error message
|
||||
} else {
|
||||
globals.Logger.Critical(err.Error())
|
||||
return nil, nex.Errors.FPD.Unknown
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message
|
||||
}
|
||||
}
|
||||
|
||||
go notifications_3ds.SendUserWentOffline(client, pid)
|
||||
go notifications_3ds.SendUserWentOffline(connection, pid)
|
||||
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureServer, nil)
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureEndpoint, nil)
|
||||
rmcResponse.ProtocolID = friends_3ds.ProtocolID
|
||||
rmcResponse.MethodID = friends_3ds.MethodRemoveFriendByPrincipalID
|
||||
rmcResponse.CallID = callID
|
||||
|
||||
return rmcResponse, 0
|
||||
return rmcResponse, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,73 +7,90 @@ import (
|
|||
database_3ds "github.com/PretendoNetwork/friends/database/3ds"
|
||||
"github.com/PretendoNetwork/friends/globals"
|
||||
notifications_3ds "github.com/PretendoNetwork/friends/notifications/3ds"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends-3ds"
|
||||
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/friends-3ds/types"
|
||||
nex "github.com/PretendoNetwork/nex-go/v2"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds"
|
||||
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds/types"
|
||||
)
|
||||
|
||||
func SyncFriend(err error, packet nex.PacketInterface, callID uint32, lfc uint64, pids []*nex.PID, lfcList []uint64) (*nex.RMCMessage, uint32) {
|
||||
func SyncFriend(err error, packet nex.PacketInterface, callID uint32, lfc *types.PrimitiveU64, pids *types.List[*types.PID], lfcList *types.List[*types.PrimitiveU64]) (*nex.RMCMessage, *nex.Error) {
|
||||
if err != nil {
|
||||
globals.Logger.Error(err.Error())
|
||||
return nil, nex.Errors.FPD.InvalidArgument
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.InvalidArgument, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
client := packet.Sender().(*nex.PRUDPClient)
|
||||
connection := packet.Sender().(*nex.PRUDPConnection)
|
||||
|
||||
friendRelationships, err := database_3ds.GetUserFriends(client.PID().LegacyValue())
|
||||
friendRelationships, err := database_3ds.GetUserFriends(connection.PID().LegacyValue())
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
globals.Logger.Critical(err.Error())
|
||||
return nil, nex.Errors.FPD.Unknown
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
for i := 0; i < len(friendRelationships); i++ {
|
||||
if friendRelationships.Each(func(i int, relationship *friends_3ds_types.FriendRelationship) bool {
|
||||
var hasPID bool
|
||||
for _, pidInput := range pids {
|
||||
if pidInput.Equals(friendRelationships[i].PID) {
|
||||
pids.Each(func(i int, pid *types.PID) bool {
|
||||
if pid.Equals(relationship.PID) {
|
||||
hasPID = true
|
||||
break
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
})
|
||||
|
||||
if !hasPID {
|
||||
err := database_3ds.RemoveFriendship(client.PID().LegacyValue(), friendRelationships[i].PID.LegacyValue())
|
||||
err := database_3ds.RemoveFriendship(connection.PID().LegacyValue(), relationship.PID.LegacyValue())
|
||||
if err != nil && err != database.ErrFriendshipNotFound {
|
||||
globals.Logger.Critical(err.Error())
|
||||
return nil, nex.Errors.FPD.Unknown
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}) {
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
for i := 0; i < len(pids); i++ {
|
||||
if !isPIDInRelationships(friendRelationships, pids[i].LegacyValue()) {
|
||||
friendRelationship, err := database_3ds.SaveFriendship(client.PID().LegacyValue(), pids[i].LegacyValue())
|
||||
relationships := friendRelationships.Slice()
|
||||
|
||||
if pids.Each(func(i int, pid *types.PID) bool {
|
||||
if !isPIDInRelationships(relationships, pid.LegacyValue()) {
|
||||
relationship, err := database_3ds.SaveFriendship(connection.PID().LegacyValue(), pid.LegacyValue())
|
||||
if err != nil {
|
||||
globals.Logger.Critical(err.Error())
|
||||
return nil, nex.Errors.FPD.Unknown
|
||||
return true
|
||||
}
|
||||
|
||||
friendRelationships = append(friendRelationships, friendRelationship)
|
||||
relationships = append(relationships, relationship)
|
||||
|
||||
// Alert the other side, in case they weren't able to get our presence data
|
||||
connectedUser := globals.ConnectedUsers[pids[i].LegacyValue()]
|
||||
// * Alert the other side, in case they weren't able to get our presence data
|
||||
connectedUser := globals.ConnectedUsers[pid.LegacyValue()]
|
||||
if connectedUser != nil {
|
||||
go notifications_3ds.SendFriendshipCompleted(connectedUser.Client, pids[i].LegacyValue(), client.PID())
|
||||
go notifications_3ds.SendFriendshipCompleted(connectedUser.Connection, pid.LegacyValue(), connection.PID())
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}) {
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
rmcResponseStream := nex.NewStreamOut(globals.SecureServer)
|
||||
syncedRelationships := types.NewList[*friends_3ds_types.FriendRelationship]()
|
||||
syncedRelationships.Type = friends_3ds_types.NewFriendRelationship()
|
||||
syncedRelationships.SetFromData(relationships)
|
||||
|
||||
nex.StreamWriteListStructure(rmcResponseStream, friendRelationships)
|
||||
rmcResponseStream := nex.NewByteStreamOut(globals.SecureEndpoint.LibraryVersions(), globals.SecureEndpoint.ByteStreamSettings())
|
||||
|
||||
syncedRelationships.WriteTo(rmcResponseStream)
|
||||
|
||||
rmcResponseBody := rmcResponseStream.Bytes()
|
||||
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureServer, rmcResponseBody)
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureEndpoint, rmcResponseBody)
|
||||
rmcResponse.ProtocolID = friends_3ds.ProtocolID
|
||||
rmcResponse.MethodID = friends_3ds.MethodSyncFriend
|
||||
rmcResponse.CallID = callID
|
||||
|
||||
return rmcResponse, 0
|
||||
return rmcResponse, nil
|
||||
}
|
||||
|
||||
func isPIDInRelationships(relationships []*friends_3ds_types.FriendRelationship, pid uint32) bool {
|
||||
|
|
|
|||
|
|
@ -1,33 +1,35 @@
|
|||
package nex_friends_3ds
|
||||
|
||||
import (
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
|
||||
database_3ds "github.com/PretendoNetwork/friends/database/3ds"
|
||||
"github.com/PretendoNetwork/friends/globals"
|
||||
notifications_3ds "github.com/PretendoNetwork/friends/notifications/3ds"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends-3ds"
|
||||
nex "github.com/PretendoNetwork/nex-go/v2"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds"
|
||||
)
|
||||
|
||||
func UpdateComment(err error, packet nex.PacketInterface, callID uint32, comment string) (*nex.RMCMessage, uint32) {
|
||||
func UpdateComment(err error, packet nex.PacketInterface, callID uint32, comment *types.String) (*nex.RMCMessage, *nex.Error) {
|
||||
if err != nil {
|
||||
globals.Logger.Error(err.Error())
|
||||
return nil, nex.Errors.FPD.InvalidArgument
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.InvalidArgument, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
client := packet.Sender().(*nex.PRUDPClient)
|
||||
connection := packet.Sender().(*nex.PRUDPConnection)
|
||||
|
||||
err = database_3ds.UpdateUserComment(client.PID().LegacyValue(), comment)
|
||||
err = database_3ds.UpdateUserComment(connection.PID().LegacyValue(), comment.Value)
|
||||
if err != nil {
|
||||
globals.Logger.Critical(err.Error())
|
||||
return nil, nex.Errors.FPD.Unknown
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
go notifications_3ds.SendCommentUpdate(client, comment)
|
||||
go notifications_3ds.SendCommentUpdate(connection, comment.Value)
|
||||
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureServer, nil)
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureEndpoint, nil)
|
||||
rmcResponse.ProtocolID = friends_3ds.ProtocolID
|
||||
rmcResponse.MethodID = friends_3ds.MethodUpdateComment
|
||||
rmcResponse.CallID = callID
|
||||
|
||||
return rmcResponse, 0
|
||||
return rmcResponse, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,31 +4,31 @@ import (
|
|||
database_3ds "github.com/PretendoNetwork/friends/database/3ds"
|
||||
"github.com/PretendoNetwork/friends/globals"
|
||||
notifications_3ds "github.com/PretendoNetwork/friends/notifications/3ds"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends-3ds"
|
||||
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/friends-3ds/types"
|
||||
nex "github.com/PretendoNetwork/nex-go/v2"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds"
|
||||
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds/types"
|
||||
)
|
||||
|
||||
func UpdateFavoriteGameKey(err error, packet nex.PacketInterface, callID uint32, gameKey *friends_3ds_types.GameKey) (*nex.RMCMessage, uint32) {
|
||||
func UpdateFavoriteGameKey(err error, packet nex.PacketInterface, callID uint32, gameKey *friends_3ds_types.GameKey) (*nex.RMCMessage, *nex.Error) {
|
||||
if err != nil {
|
||||
globals.Logger.Error(err.Error())
|
||||
return nil, nex.Errors.FPD.InvalidArgument
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.InvalidArgument, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
client := packet.Sender().(*nex.PRUDPClient)
|
||||
connection := packet.Sender().(*nex.PRUDPConnection)
|
||||
|
||||
err = database_3ds.UpdateUserFavoriteGame(client.PID().LegacyValue(), gameKey)
|
||||
err = database_3ds.UpdateUserFavoriteGame(connection.PID().LegacyValue(), gameKey)
|
||||
if err != nil {
|
||||
globals.Logger.Critical(err.Error())
|
||||
return nil, nex.Errors.FPD.Unknown
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
go notifications_3ds.SendFavoriteUpdate(client, gameKey)
|
||||
go notifications_3ds.SendFavoriteUpdate(connection, gameKey)
|
||||
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureServer, nil)
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureEndpoint, nil)
|
||||
rmcResponse.ProtocolID = friends_3ds.ProtocolID
|
||||
rmcResponse.MethodID = friends_3ds.MethodUpdateFavoriteGameKey
|
||||
rmcResponse.CallID = callID
|
||||
|
||||
return rmcResponse, 0
|
||||
return rmcResponse, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,31 +4,31 @@ import (
|
|||
database_3ds "github.com/PretendoNetwork/friends/database/3ds"
|
||||
"github.com/PretendoNetwork/friends/globals"
|
||||
notifications_3ds "github.com/PretendoNetwork/friends/notifications/3ds"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends-3ds"
|
||||
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/friends-3ds/types"
|
||||
nex "github.com/PretendoNetwork/nex-go/v2"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds"
|
||||
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds/types"
|
||||
)
|
||||
|
||||
func UpdateMii(err error, packet nex.PacketInterface, callID uint32, mii *friends_3ds_types.Mii) (*nex.RMCMessage, uint32) {
|
||||
func UpdateMii(err error, packet nex.PacketInterface, callID uint32, mii *friends_3ds_types.Mii) (*nex.RMCMessage, *nex.Error) {
|
||||
if err != nil {
|
||||
globals.Logger.Error(err.Error())
|
||||
return nil, nex.Errors.FPD.InvalidArgument
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.InvalidArgument, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
client := packet.Sender().(*nex.PRUDPClient)
|
||||
connection := packet.Sender().(*nex.PRUDPConnection)
|
||||
|
||||
err = database_3ds.UpdateUserMii(client.PID().LegacyValue(), mii)
|
||||
err = database_3ds.UpdateUserMii(connection.PID().LegacyValue(), mii)
|
||||
if err != nil {
|
||||
globals.Logger.Critical(err.Error())
|
||||
return nil, nex.Errors.FPD.Unknown
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
go notifications_3ds.SendMiiUpdateNotification(client)
|
||||
go notifications_3ds.SendMiiUpdateNotification(connection)
|
||||
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureServer, nil)
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureEndpoint, nil)
|
||||
rmcResponse.ProtocolID = friends_3ds.ProtocolID
|
||||
rmcResponse.MethodID = friends_3ds.MethodUpdateMii
|
||||
rmcResponse.CallID = callID
|
||||
|
||||
return rmcResponse, 0
|
||||
return rmcResponse, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,39 +4,41 @@ import (
|
|||
database_3ds "github.com/PretendoNetwork/friends/database/3ds"
|
||||
"github.com/PretendoNetwork/friends/globals"
|
||||
notifications_3ds "github.com/PretendoNetwork/friends/notifications/3ds"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends-3ds"
|
||||
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/friends-3ds/types"
|
||||
nex "github.com/PretendoNetwork/nex-go/v2"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds"
|
||||
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds/types"
|
||||
)
|
||||
|
||||
func UpdatePreference(err error, packet nex.PacketInterface, callID uint32, showOnline bool, showCurrentGame bool, showPlayedGame bool) (*nex.RMCMessage, uint32) {
|
||||
func UpdatePreference(err error, packet nex.PacketInterface, callID uint32, publicMode *types.PrimitiveBool, showGame *types.PrimitiveBool, showPlayedGame *types.PrimitiveBool) (*nex.RMCMessage, *nex.Error) {
|
||||
if err != nil {
|
||||
globals.Logger.Error(err.Error())
|
||||
return nil, nex.Errors.FPD.InvalidArgument
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.InvalidArgument, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
client := packet.Sender().(*nex.PRUDPClient)
|
||||
connection := packet.Sender().(*nex.PRUDPConnection)
|
||||
|
||||
err = database_3ds.UpdateUserPreferences(client.PID().LegacyValue(), showOnline, showCurrentGame)
|
||||
err = database_3ds.UpdateUserPreferences(connection.PID().LegacyValue(), publicMode.Value, showGame.Value)
|
||||
if err != nil {
|
||||
globals.Logger.Critical(err.Error())
|
||||
return nil, nex.Errors.FPD.Unknown
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
if !showCurrentGame {
|
||||
if !showGame.Value {
|
||||
emptyPresence := friends_3ds_types.NewNintendoPresence()
|
||||
emptyPresence.GameKey = friends_3ds_types.NewGameKey()
|
||||
emptyPresence.ChangedFlags = 0xFFFFFFFF // All flags
|
||||
notifications_3ds.SendPresenceUpdate(client, emptyPresence)
|
||||
}
|
||||
if !showOnline {
|
||||
notifications_3ds.SendUserWentOfflineGlobally(client)
|
||||
emptyPresence.ChangedFlags = types.NewPrimitiveU32(0xFFFFFFFF) // * All flags
|
||||
notifications_3ds.SendPresenceUpdate(connection, emptyPresence)
|
||||
}
|
||||
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureServer, nil)
|
||||
if !publicMode.Value {
|
||||
notifications_3ds.SendUserWentOfflineGlobally(connection)
|
||||
}
|
||||
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureEndpoint, nil)
|
||||
rmcResponse.ProtocolID = friends_3ds.ProtocolID
|
||||
rmcResponse.MethodID = friends_3ds.MethodUpdatePreference
|
||||
rmcResponse.CallID = callID
|
||||
|
||||
return rmcResponse, 0
|
||||
return rmcResponse, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,49 +3,50 @@ package nex_friends_3ds
|
|||
import (
|
||||
"github.com/PretendoNetwork/friends/globals"
|
||||
notifications_3ds "github.com/PretendoNetwork/friends/notifications/3ds"
|
||||
"github.com/PretendoNetwork/friends/types"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends-3ds"
|
||||
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/friends-3ds/types"
|
||||
friends_types "github.com/PretendoNetwork/friends/types"
|
||||
nex "github.com/PretendoNetwork/nex-go/v2"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds"
|
||||
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds/types"
|
||||
)
|
||||
|
||||
func UpdatePresence(err error, packet nex.PacketInterface, callID uint32, presence *friends_3ds_types.NintendoPresence, showGame bool) (*nex.RMCMessage, uint32) {
|
||||
func UpdatePresence(err error, packet nex.PacketInterface, callID uint32, presence *friends_3ds_types.NintendoPresence, showGame *types.PrimitiveBool) (*nex.RMCMessage, *nex.Error) {
|
||||
if err != nil {
|
||||
globals.Logger.Error(err.Error())
|
||||
return nil, nex.Errors.FPD.InvalidArgument
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.InvalidArgument, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
client := packet.Sender().(*nex.PRUDPClient)
|
||||
connection := packet.Sender().(*nex.PRUDPConnection)
|
||||
|
||||
currentPresence := presence
|
||||
|
||||
// Send an entirely empty status, with every flag set to update
|
||||
if !showGame {
|
||||
if !showGame.Value {
|
||||
currentPresence = friends_3ds_types.NewNintendoPresence()
|
||||
currentPresence.GameKey = friends_3ds_types.NewGameKey()
|
||||
currentPresence.ChangedFlags = 0xFFFFFFFF // All flags
|
||||
currentPresence.ChangedFlags = types.NewPrimitiveU32(0xFFFFFFFF) // * All flags
|
||||
}
|
||||
|
||||
go notifications_3ds.SendPresenceUpdate(client, currentPresence)
|
||||
go notifications_3ds.SendPresenceUpdate(connection, currentPresence)
|
||||
|
||||
pid := client.PID().LegacyValue()
|
||||
pid := connection.PID().LegacyValue()
|
||||
|
||||
if globals.ConnectedUsers[pid] == nil {
|
||||
// TODO - Figure out why this is getting removed
|
||||
connectedUser := types.NewConnectedUser()
|
||||
connectedUser := friends_types.NewConnectedUser()
|
||||
connectedUser.PID = pid
|
||||
connectedUser.Platform = types.CTR
|
||||
connectedUser.Client = client
|
||||
connectedUser.Platform = friends_types.CTR
|
||||
connectedUser.Connection = connection
|
||||
|
||||
globals.ConnectedUsers[pid] = connectedUser
|
||||
}
|
||||
|
||||
globals.ConnectedUsers[pid].Presence = currentPresence
|
||||
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureServer, nil)
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureEndpoint, nil)
|
||||
rmcResponse.ProtocolID = friends_3ds.ProtocolID
|
||||
rmcResponse.MethodID = friends_3ds.MethodUpdatePresence
|
||||
rmcResponse.CallID = callID
|
||||
|
||||
return rmcResponse, 0
|
||||
return rmcResponse, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,29 +3,29 @@ package nex_friends_3ds
|
|||
import (
|
||||
database_3ds "github.com/PretendoNetwork/friends/database/3ds"
|
||||
"github.com/PretendoNetwork/friends/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends-3ds"
|
||||
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/friends-3ds/types"
|
||||
nex "github.com/PretendoNetwork/nex-go/v2"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds"
|
||||
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds/types"
|
||||
)
|
||||
|
||||
func UpdateProfile(err error, packet nex.PacketInterface, callID uint32, profileData *friends_3ds_types.MyProfile) (*nex.RMCMessage, uint32) {
|
||||
func UpdateProfile(err error, packet nex.PacketInterface, callID uint32, profileData *friends_3ds_types.MyProfile) (*nex.RMCMessage, *nex.Error) {
|
||||
if err != nil {
|
||||
globals.Logger.Error(err.Error())
|
||||
return nil, nex.Errors.FPD.InvalidArgument
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.InvalidArgument, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
client := packet.Sender().(*nex.PRUDPClient)
|
||||
connection := packet.Sender().(*nex.PRUDPConnection)
|
||||
|
||||
err = database_3ds.UpdateUserProfile(client.PID().LegacyValue(), profileData)
|
||||
err = database_3ds.UpdateUserProfile(connection.PID().LegacyValue(), profileData)
|
||||
if err != nil {
|
||||
globals.Logger.Critical(err.Error())
|
||||
return nil, nex.Errors.FPD.Unknown
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureServer, nil)
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureEndpoint, nil)
|
||||
rmcResponse.ProtocolID = friends_3ds.ProtocolID
|
||||
rmcResponse.MethodID = friends_3ds.MethodUpdateProfile
|
||||
rmcResponse.CallID = callID
|
||||
|
||||
return rmcResponse, 0
|
||||
return rmcResponse, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,26 +5,27 @@ import (
|
|||
database_wiiu "github.com/PretendoNetwork/friends/database/wiiu"
|
||||
"github.com/PretendoNetwork/friends/globals"
|
||||
notifications_wiiu "github.com/PretendoNetwork/friends/notifications/wiiu"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
|
||||
nex "github.com/PretendoNetwork/nex-go/v2"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu/types"
|
||||
)
|
||||
|
||||
func AcceptFriendRequest(err error, packet nex.PacketInterface, callID uint32, id uint64) (*nex.RMCMessage, uint32) {
|
||||
func AcceptFriendRequest(err error, packet nex.PacketInterface, callID uint32, id *types.PrimitiveU64) (*nex.RMCMessage, *nex.Error) {
|
||||
if err != nil {
|
||||
globals.Logger.Error(err.Error())
|
||||
return nil, nex.Errors.FPD.InvalidArgument
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.InvalidArgument, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
client := packet.Sender().(*nex.PRUDPClient)
|
||||
connection := packet.Sender().(*nex.PRUDPConnection)
|
||||
|
||||
friendInfo, err := database_wiiu.AcceptFriendRequestAndReturnFriendInfo(id)
|
||||
friendInfo, err := database_wiiu.AcceptFriendRequestAndReturnFriendInfo(id.Value)
|
||||
if err != nil {
|
||||
if err == database.ErrFriendRequestNotFound {
|
||||
return nil, nex.Errors.FPD.InvalidMessageID
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.InvalidMessageID, "") // TODO - Add error message
|
||||
} else {
|
||||
globals.Logger.Critical(err.Error())
|
||||
return nil, nex.Errors.FPD.Unknown
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -32,7 +33,7 @@ func AcceptFriendRequest(err error, packet nex.PacketInterface, callID uint32, i
|
|||
connectedUser := globals.ConnectedUsers[friendPID]
|
||||
|
||||
if connectedUser != nil {
|
||||
senderPID := client.PID().LegacyValue()
|
||||
senderPID := connection.PID().LegacyValue()
|
||||
senderConnectedUser := globals.ConnectedUsers[senderPID]
|
||||
|
||||
senderFriendInfo := friends_wiiu_types.NewFriendInfo()
|
||||
|
|
@ -43,28 +44,28 @@ func AcceptFriendRequest(err error, packet nex.PacketInterface, callID uint32, i
|
|||
if err != nil {
|
||||
globals.Logger.Critical(err.Error())
|
||||
senderFriendInfo.Status = friends_wiiu_types.NewComment()
|
||||
senderFriendInfo.Status.LastChanged = nex.NewDateTime(0)
|
||||
senderFriendInfo.Status.LastChanged = types.NewDateTime(0)
|
||||
} else {
|
||||
senderFriendInfo.Status = status
|
||||
}
|
||||
|
||||
senderFriendInfo.BecameFriend = friendInfo.BecameFriend
|
||||
senderFriendInfo.LastOnline = friendInfo.LastOnline // TODO - Change this
|
||||
senderFriendInfo.Unknown = 0
|
||||
senderFriendInfo.Unknown = types.NewPrimitiveU64(0)
|
||||
|
||||
go notifications_wiiu.SendFriendRequestAccepted(connectedUser.Client, senderFriendInfo)
|
||||
go notifications_wiiu.SendFriendRequestAccepted(connectedUser.Connection, senderFriendInfo)
|
||||
}
|
||||
|
||||
rmcResponseStream := nex.NewStreamOut(globals.SecureServer)
|
||||
rmcResponseStream := nex.NewByteStreamOut(globals.SecureEndpoint.LibraryVersions(), globals.SecureEndpoint.ByteStreamSettings())
|
||||
|
||||
rmcResponseStream.WriteStructure(friendInfo)
|
||||
friendInfo.WriteTo(rmcResponseStream)
|
||||
|
||||
rmcResponseBody := rmcResponseStream.Bytes()
|
||||
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureServer, rmcResponseBody)
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureEndpoint, rmcResponseBody)
|
||||
rmcResponse.ProtocolID = friends_wiiu.ProtocolID
|
||||
rmcResponse.MethodID = friends_wiiu.MethodAcceptFriendRequest
|
||||
rmcResponse.CallID = callID
|
||||
|
||||
return rmcResponse, 0
|
||||
return rmcResponse, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,18 +5,19 @@ import (
|
|||
database_wiiu "github.com/PretendoNetwork/friends/database/wiiu"
|
||||
"github.com/PretendoNetwork/friends/globals"
|
||||
"github.com/PretendoNetwork/friends/utility"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
|
||||
nex "github.com/PretendoNetwork/nex-go/v2"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu/types"
|
||||
)
|
||||
|
||||
func AddBlacklist(err error, packet nex.PacketInterface, callID uint32, blacklistPrincipal *friends_wiiu_types.BlacklistedPrincipal) (*nex.RMCMessage, uint32) {
|
||||
func AddBlackList(err error, packet nex.PacketInterface, callID uint32, blacklistPrincipal *friends_wiiu_types.BlacklistedPrincipal) (*nex.RMCMessage, *nex.Error) {
|
||||
if err != nil {
|
||||
globals.Logger.Error(err.Error())
|
||||
return nil, nex.Errors.FPD.InvalidArgument
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.InvalidArgument, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
client := packet.Sender().(*nex.PRUDPClient)
|
||||
connection := packet.Sender().(*nex.PRUDPConnection)
|
||||
|
||||
currentBlacklistPrincipal := blacklistPrincipal
|
||||
|
||||
|
|
@ -27,32 +28,33 @@ func AddBlacklist(err error, packet nex.PacketInterface, callID uint32, blacklis
|
|||
userInfo, err := utility.GetUserInfoByPID(currentBlacklistPrincipal.PrincipalBasicInfo.PID.LegacyValue())
|
||||
if err != nil {
|
||||
if err == database.ErrPIDNotFound {
|
||||
return nil, nex.Errors.FPD.InvalidPrincipalID // TODO - Not sure if this is the correct error.
|
||||
// TODO - Not sure if this is the correct error.
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.InvalidPrincipalID, "") // TODO - Add error message
|
||||
} else {
|
||||
globals.Logger.Critical(err.Error())
|
||||
return nil, nex.Errors.FPD.Unknown
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message
|
||||
}
|
||||
}
|
||||
|
||||
currentBlacklistPrincipal.PrincipalBasicInfo = userInfo
|
||||
currentBlacklistPrincipal.BlackListedSince = nex.NewDateTime(0).Now()
|
||||
currentBlacklistPrincipal.BlackListedSince = types.NewDateTime(0).Now()
|
||||
|
||||
err = database_wiiu.SetUserBlocked(client.PID().LegacyValue(), senderPID.LegacyValue(), titleID, titleVersion)
|
||||
err = database_wiiu.SetUserBlocked(connection.PID().LegacyValue(), senderPID.LegacyValue(), titleID.Value, titleVersion.Value)
|
||||
if err != nil {
|
||||
globals.Logger.Critical(err.Error())
|
||||
return nil, nex.Errors.FPD.Unknown
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
rmcResponseStream := nex.NewStreamOut(globals.SecureServer)
|
||||
rmcResponseStream := nex.NewByteStreamOut(globals.SecureEndpoint.LibraryVersions(), globals.SecureEndpoint.ByteStreamSettings())
|
||||
|
||||
rmcResponseStream.WriteStructure(blacklistPrincipal)
|
||||
blacklistPrincipal.WriteTo(rmcResponseStream)
|
||||
|
||||
rmcResponseBody := rmcResponseStream.Bytes()
|
||||
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureServer, rmcResponseBody)
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureEndpoint, rmcResponseBody)
|
||||
rmcResponse.ProtocolID = friends_wiiu.ProtocolID
|
||||
rmcResponse.MethodID = friends_wiiu.MethodAddBlackList
|
||||
rmcResponse.CallID = callID
|
||||
|
||||
return rmcResponse, 0
|
||||
return rmcResponse, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,52 +8,54 @@ import (
|
|||
"github.com/PretendoNetwork/friends/globals"
|
||||
notifications_wiiu "github.com/PretendoNetwork/friends/notifications/wiiu"
|
||||
"github.com/PretendoNetwork/friends/utility"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
|
||||
nex "github.com/PretendoNetwork/nex-go/v2"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu/types"
|
||||
)
|
||||
|
||||
func AddFriendRequest(err error, packet nex.PacketInterface, callID uint32, pid *nex.PID, unknown2 uint8, message string, unknown4 uint8, unknown5 string, gameKey *friends_wiiu_types.GameKey, unknown6 *nex.DateTime) (*nex.RMCMessage, uint32) {
|
||||
func AddFriendRequest(err error, packet nex.PacketInterface, callID uint32, pid *types.PID, unknown2 *types.PrimitiveU8, message *types.String, unknown4 *types.PrimitiveU8, unknown5 *types.String, gameKey *friends_wiiu_types.GameKey, unknown6 *types.DateTime) (*nex.RMCMessage, *nex.Error) {
|
||||
if err != nil {
|
||||
globals.Logger.Error(err.Error())
|
||||
return nil, nex.Errors.FPD.InvalidArgument
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.InvalidArgument, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
client := packet.Sender().(*nex.PRUDPClient)
|
||||
connection := packet.Sender().(*nex.PRUDPConnection)
|
||||
|
||||
senderPID := client.PID().LegacyValue()
|
||||
senderPID := connection.PID().LegacyValue()
|
||||
recipientPID := pid.LegacyValue()
|
||||
|
||||
senderPrincipalInfo, err := utility.GetUserInfoByPID(senderPID)
|
||||
if err != nil {
|
||||
globals.Logger.Critical(err.Error())
|
||||
return nil, nex.Errors.FPD.Unknown
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
recipientPrincipalInfo, err := utility.GetUserInfoByPID(recipientPID)
|
||||
if err != nil {
|
||||
if err == database.ErrPIDNotFound {
|
||||
// TODO - Not sure if this is the correct error.
|
||||
globals.Logger.Errorf("User %d has sent friend request to invalid PID %d", senderPID, pid)
|
||||
return nil, nex.Errors.FPD.InvalidPrincipalID // TODO - Not sure if this is the correct error.
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.InvalidPrincipalID, "") // TODO - Add error message
|
||||
} else {
|
||||
globals.Logger.Critical(err.Error())
|
||||
return nil, nex.Errors.FPD.Unknown
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message
|
||||
}
|
||||
}
|
||||
|
||||
currentTimestamp := time.Now()
|
||||
expireTimestamp := currentTimestamp.Add(time.Hour * 24 * 29)
|
||||
|
||||
sentTime := nex.NewDateTime(0)
|
||||
expireTime := nex.NewDateTime(0)
|
||||
sentTime := types.NewDateTime(0)
|
||||
expireTime := types.NewDateTime(0)
|
||||
|
||||
sentTime.FromTimestamp(currentTimestamp)
|
||||
expireTime.FromTimestamp(expireTimestamp)
|
||||
|
||||
friendRequestID, err := database_wiiu.SaveFriendRequest(senderPID, recipientPID, sentTime.Value(), expireTime.Value(), message)
|
||||
friendRequestID, err := database_wiiu.SaveFriendRequest(senderPID, recipientPID, sentTime.Value(), expireTime.Value(), message.Value)
|
||||
if err != nil {
|
||||
globals.Logger.Critical(err.Error())
|
||||
return nil, nex.Errors.FPD.Unknown
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
friendRequest := friends_wiiu_types.NewFriendRequest()
|
||||
|
|
@ -61,15 +63,15 @@ func AddFriendRequest(err error, packet nex.PacketInterface, callID uint32, pid
|
|||
friendRequest.PrincipalInfo = recipientPrincipalInfo
|
||||
|
||||
friendRequest.Message = friends_wiiu_types.NewFriendRequestMessage()
|
||||
friendRequest.Message.FriendRequestID = friendRequestID
|
||||
friendRequest.Message.Received = false
|
||||
friendRequest.Message.Unknown2 = 1 // * Replaying from official server
|
||||
friendRequest.Message.FriendRequestID = types.NewPrimitiveU64(friendRequestID)
|
||||
friendRequest.Message.Received = types.NewPrimitiveBool(false)
|
||||
friendRequest.Message.Unknown2 = types.NewPrimitiveU8(1) // * Replaying from official server
|
||||
friendRequest.Message.Message = message
|
||||
friendRequest.Message.Unknown3 = 0 // * Replaying from official server
|
||||
friendRequest.Message.Unknown4 = "" // * Replaying from official server
|
||||
friendRequest.Message.GameKey = gameKey // * Maybe this is reused?
|
||||
friendRequest.Message.Unknown5 = unknown6 // * Maybe this is reused?
|
||||
friendRequest.Message.ExpiresOn = expireTime // * No idea why this is set as the sent time
|
||||
friendRequest.Message.Unknown3 = types.NewPrimitiveU8(0) // * Replaying from official server
|
||||
friendRequest.Message.Unknown4 = types.NewString("") // * Replaying from official server
|
||||
friendRequest.Message.GameKey = gameKey // * Maybe this is reused?
|
||||
friendRequest.Message.Unknown5 = unknown6 // * Maybe this is reused?
|
||||
friendRequest.Message.ExpiresOn = expireTime // * No idea why this is set as the sent time
|
||||
friendRequest.SentOn = sentTime
|
||||
|
||||
// * Why does this exist?? Always empty??
|
||||
|
|
@ -77,43 +79,43 @@ func AddFriendRequest(err error, packet nex.PacketInterface, callID uint32, pid
|
|||
|
||||
friendInfo.NNAInfo = friends_wiiu_types.NewNNAInfo()
|
||||
friendInfo.NNAInfo.PrincipalBasicInfo = friends_wiiu_types.NewPrincipalBasicInfo()
|
||||
friendInfo.NNAInfo.PrincipalBasicInfo.PID = nex.NewPID[uint32](0)
|
||||
friendInfo.NNAInfo.PrincipalBasicInfo.NNID = ""
|
||||
friendInfo.NNAInfo.PrincipalBasicInfo.PID = types.NewPID(0)
|
||||
friendInfo.NNAInfo.PrincipalBasicInfo.NNID = types.NewString("")
|
||||
friendInfo.NNAInfo.PrincipalBasicInfo.Mii = friends_wiiu_types.NewMiiV2()
|
||||
friendInfo.NNAInfo.PrincipalBasicInfo.Mii.Name = ""
|
||||
friendInfo.NNAInfo.PrincipalBasicInfo.Mii.Unknown1 = 0
|
||||
friendInfo.NNAInfo.PrincipalBasicInfo.Mii.Unknown2 = 0
|
||||
friendInfo.NNAInfo.PrincipalBasicInfo.Mii.MiiData = []byte{}
|
||||
friendInfo.NNAInfo.PrincipalBasicInfo.Mii.Datetime = nex.NewDateTime(0)
|
||||
friendInfo.NNAInfo.PrincipalBasicInfo.Unknown = 0
|
||||
friendInfo.NNAInfo.Unknown1 = 0
|
||||
friendInfo.NNAInfo.Unknown2 = 0
|
||||
friendInfo.NNAInfo.PrincipalBasicInfo.Mii.Name = types.NewString("")
|
||||
friendInfo.NNAInfo.PrincipalBasicInfo.Mii.Unknown1 = types.NewPrimitiveU8(0)
|
||||
friendInfo.NNAInfo.PrincipalBasicInfo.Mii.Unknown2 = types.NewPrimitiveU8(0)
|
||||
friendInfo.NNAInfo.PrincipalBasicInfo.Mii.MiiData = types.NewBuffer([]byte{})
|
||||
friendInfo.NNAInfo.PrincipalBasicInfo.Mii.Datetime = types.NewDateTime(0)
|
||||
friendInfo.NNAInfo.PrincipalBasicInfo.Unknown = types.NewPrimitiveU8(0)
|
||||
friendInfo.NNAInfo.Unknown1 = types.NewPrimitiveU8(0)
|
||||
friendInfo.NNAInfo.Unknown2 = types.NewPrimitiveU8(0)
|
||||
|
||||
friendInfo.Presence = friends_wiiu_types.NewNintendoPresenceV2()
|
||||
friendInfo.Presence.ChangedFlags = 0
|
||||
friendInfo.Presence.Online = false
|
||||
friendInfo.Presence.ChangedFlags = types.NewPrimitiveU32(0)
|
||||
friendInfo.Presence.Online = types.NewPrimitiveBool(false)
|
||||
friendInfo.Presence.GameKey = gameKey // * Maybe this is reused?
|
||||
friendInfo.Presence.Unknown1 = 0
|
||||
friendInfo.Presence.Message = ""
|
||||
friendInfo.Presence.Unknown2 = 0
|
||||
friendInfo.Presence.Unknown3 = 0
|
||||
friendInfo.Presence.GameServerID = 0
|
||||
friendInfo.Presence.Unknown4 = 0
|
||||
friendInfo.Presence.PID = nex.NewPID[uint32](0)
|
||||
friendInfo.Presence.GatheringID = 0
|
||||
friendInfo.Presence.ApplicationData = []byte{0x00}
|
||||
friendInfo.Presence.Unknown5 = 0
|
||||
friendInfo.Presence.Unknown6 = 0
|
||||
friendInfo.Presence.Unknown7 = 0
|
||||
friendInfo.Presence.Unknown1 = types.NewPrimitiveU8(0)
|
||||
friendInfo.Presence.Message = types.NewString("")
|
||||
friendInfo.Presence.Unknown2 = types.NewPrimitiveU32(0)
|
||||
friendInfo.Presence.Unknown3 = types.NewPrimitiveU8(0)
|
||||
friendInfo.Presence.GameServerID = types.NewPrimitiveU32(0)
|
||||
friendInfo.Presence.Unknown4 = types.NewPrimitiveU32(0)
|
||||
friendInfo.Presence.PID = types.NewPID(0)
|
||||
friendInfo.Presence.GatheringID = types.NewPrimitiveU32(0)
|
||||
friendInfo.Presence.ApplicationData = types.NewBuffer([]byte{0x00})
|
||||
friendInfo.Presence.Unknown5 = types.NewPrimitiveU8(0)
|
||||
friendInfo.Presence.Unknown6 = types.NewPrimitiveU8(0)
|
||||
friendInfo.Presence.Unknown7 = types.NewPrimitiveU8(0)
|
||||
|
||||
friendInfo.Status = friends_wiiu_types.NewComment()
|
||||
friendInfo.Status.Unknown = 0
|
||||
friendInfo.Status.Contents = ""
|
||||
friendInfo.Status.LastChanged = nex.NewDateTime(0)
|
||||
friendInfo.Status.Unknown = types.NewPrimitiveU8(0)
|
||||
friendInfo.Status.Contents = types.NewString("")
|
||||
friendInfo.Status.LastChanged = types.NewDateTime(0)
|
||||
|
||||
friendInfo.BecameFriend = nex.NewDateTime(0)
|
||||
friendInfo.LastOnline = nex.NewDateTime(0)
|
||||
friendInfo.Unknown = 0
|
||||
friendInfo.BecameFriend = types.NewDateTime(0)
|
||||
friendInfo.LastOnline = types.NewDateTime(0)
|
||||
friendInfo.Unknown = types.NewPrimitiveU64(0)
|
||||
|
||||
recipientClient := globals.ConnectedUsers[recipientPID]
|
||||
|
||||
|
|
@ -122,31 +124,31 @@ func AddFriendRequest(err error, packet nex.PacketInterface, callID uint32, pid
|
|||
|
||||
friendRequestNotificationData.PrincipalInfo = senderPrincipalInfo
|
||||
friendRequestNotificationData.Message = friends_wiiu_types.NewFriendRequestMessage()
|
||||
friendRequestNotificationData.Message.FriendRequestID = friendRequestID
|
||||
friendRequestNotificationData.Message.Received = false
|
||||
friendRequestNotificationData.Message.Unknown2 = 1 // * Replaying from official server
|
||||
friendRequestNotificationData.Message.FriendRequestID = types.NewPrimitiveU64(friendRequestID)
|
||||
friendRequestNotificationData.Message.Received = types.NewPrimitiveBool(false)
|
||||
friendRequestNotificationData.Message.Unknown2 = types.NewPrimitiveU8(1) // * Replaying from official server
|
||||
friendRequestNotificationData.Message.Message = message
|
||||
friendRequestNotificationData.Message.Unknown3 = 0 // * Replaying from server server
|
||||
friendRequestNotificationData.Message.Unknown4 = "" // * Replaying from server server
|
||||
friendRequestNotificationData.Message.GameKey = gameKey // * Maybe this is reused?
|
||||
friendRequestNotificationData.Message.Unknown5 = unknown6 // * Maybe this is reused?
|
||||
friendRequestNotificationData.Message.ExpiresOn = expireTime // * No idea why this is set as the sent time
|
||||
friendRequestNotificationData.Message.Unknown3 = types.NewPrimitiveU8(0) // * Replaying from server server
|
||||
friendRequestNotificationData.Message.Unknown4 = types.NewString("") // * Replaying from server server
|
||||
friendRequestNotificationData.Message.GameKey = gameKey // * Maybe this is reused?
|
||||
friendRequestNotificationData.Message.Unknown5 = unknown6 // * Maybe this is reused?
|
||||
friendRequestNotificationData.Message.ExpiresOn = expireTime // * No idea why this is set as the sent time
|
||||
friendRequestNotificationData.SentOn = sentTime
|
||||
|
||||
go notifications_wiiu.SendFriendRequest(recipientClient.Client, friendRequestNotificationData)
|
||||
go notifications_wiiu.SendFriendRequest(recipientClient.Connection, friendRequestNotificationData)
|
||||
}
|
||||
|
||||
rmcResponseStream := nex.NewStreamOut(globals.SecureServer)
|
||||
rmcResponseStream := nex.NewByteStreamOut(globals.SecureEndpoint.LibraryVersions(), globals.SecureEndpoint.ByteStreamSettings())
|
||||
|
||||
rmcResponseStream.WriteStructure(friendRequest)
|
||||
rmcResponseStream.WriteStructure(friendInfo)
|
||||
friendRequest.WriteTo(rmcResponseStream)
|
||||
friendInfo.WriteTo(rmcResponseStream)
|
||||
|
||||
rmcResponseBody := rmcResponseStream.Bytes()
|
||||
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureServer, rmcResponseBody)
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureEndpoint, rmcResponseBody)
|
||||
rmcResponse.ProtocolID = friends_wiiu.ProtocolID
|
||||
rmcResponse.MethodID = friends_wiiu.MethodAddFriendRequest
|
||||
rmcResponse.CallID = callID
|
||||
|
||||
return rmcResponse, 0
|
||||
return rmcResponse, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,38 +5,39 @@ import (
|
|||
database_wiiu "github.com/PretendoNetwork/friends/database/wiiu"
|
||||
"github.com/PretendoNetwork/friends/globals"
|
||||
notifications_wiiu "github.com/PretendoNetwork/friends/notifications/wiiu"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu"
|
||||
nex "github.com/PretendoNetwork/nex-go/v2"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu"
|
||||
)
|
||||
|
||||
func CancelFriendRequest(err error, packet nex.PacketInterface, callID uint32, id uint64) (*nex.RMCMessage, uint32) {
|
||||
func CancelFriendRequest(err error, packet nex.PacketInterface, callID uint32, id *types.PrimitiveU64) (*nex.RMCMessage, *nex.Error) {
|
||||
if err != nil {
|
||||
globals.Logger.Error(err.Error())
|
||||
return nil, nex.Errors.FPD.InvalidArgument
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.InvalidArgument, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
client := packet.Sender().(*nex.PRUDPClient)
|
||||
connection := packet.Sender().(*nex.PRUDPConnection)
|
||||
|
||||
pid, err := database_wiiu.DeleteFriendRequestAndReturnFriendPID(id)
|
||||
pid, err := database_wiiu.DeleteFriendRequestAndReturnFriendPID(id.Value)
|
||||
if err != nil {
|
||||
if err == database.ErrFriendRequestNotFound {
|
||||
return nil, nex.Errors.FPD.InvalidMessageID
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.InvalidMessageID, "") // TODO - Add error message
|
||||
} else {
|
||||
globals.Logger.Critical(err.Error())
|
||||
return nil, nex.Errors.FPD.Unknown
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message
|
||||
}
|
||||
}
|
||||
|
||||
connectedUser := globals.ConnectedUsers[pid]
|
||||
if connectedUser != nil {
|
||||
// * This may send the friend removed notification, but they are the same.
|
||||
go notifications_wiiu.SendFriendshipRemoved(connectedUser.Client, client.PID())
|
||||
go notifications_wiiu.SendFriendshipRemoved(connectedUser.Connection, connection.PID())
|
||||
}
|
||||
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureServer, nil)
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureEndpoint, nil)
|
||||
rmcResponse.ProtocolID = friends_wiiu.ProtocolID
|
||||
rmcResponse.MethodID = friends_wiiu.MethodCancelFriendRequest
|
||||
rmcResponse.CallID = callID
|
||||
|
||||
return rmcResponse, 0
|
||||
return rmcResponse, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,26 +2,29 @@ package nex_friends_wiiu
|
|||
|
||||
import (
|
||||
"github.com/PretendoNetwork/friends/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu"
|
||||
nex "github.com/PretendoNetwork/nex-go/v2"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu"
|
||||
)
|
||||
|
||||
func CheckSettingStatus(err error, packet nex.PacketInterface, callID uint32) (*nex.RMCMessage, uint32) {
|
||||
func CheckSettingStatus(err error, packet nex.PacketInterface, callID uint32) (*nex.RMCMessage, *nex.Error) {
|
||||
if err != nil {
|
||||
globals.Logger.Error(err.Error())
|
||||
return nil, nex.Errors.FPD.Unknown
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
rmcResponseStream := nex.NewStreamOut(globals.SecureServer)
|
||||
status := types.NewPrimitiveU8(0xFF) // TODO - What is this??
|
||||
|
||||
rmcResponseStream.WriteUInt8(0xFF)
|
||||
rmcResponseStream := nex.NewByteStreamOut(globals.SecureEndpoint.LibraryVersions(), globals.SecureEndpoint.ByteStreamSettings())
|
||||
|
||||
status.WriteTo(rmcResponseStream)
|
||||
|
||||
rmcResponseBody := rmcResponseStream.Bytes()
|
||||
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureServer, rmcResponseBody)
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureEndpoint, rmcResponseBody)
|
||||
rmcResponse.ProtocolID = friends_wiiu.ProtocolID
|
||||
rmcResponse.MethodID = friends_wiiu.MethodCheckSettingStatus
|
||||
rmcResponse.CallID = callID
|
||||
|
||||
return rmcResponse, 0
|
||||
return rmcResponse, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,30 +4,31 @@ import (
|
|||
"github.com/PretendoNetwork/friends/database"
|
||||
database_wiiu "github.com/PretendoNetwork/friends/database/wiiu"
|
||||
"github.com/PretendoNetwork/friends/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu"
|
||||
nex "github.com/PretendoNetwork/nex-go/v2"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu"
|
||||
)
|
||||
|
||||
func DeleteFriendRequest(err error, packet nex.PacketInterface, callID uint32, id uint64) (*nex.RMCMessage, uint32) {
|
||||
func DeleteFriendRequest(err error, packet nex.PacketInterface, callID uint32, id *types.PrimitiveU64) (*nex.RMCMessage, *nex.Error) {
|
||||
if err != nil {
|
||||
globals.Logger.Error(err.Error())
|
||||
return nil, nex.Errors.FPD.InvalidArgument
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.InvalidArgument, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
err = database_wiiu.SetFriendRequestDenied(id)
|
||||
err = database_wiiu.SetFriendRequestDenied(id.Value)
|
||||
if err != nil {
|
||||
if err == database.ErrFriendRequestNotFound {
|
||||
return nil, nex.Errors.FPD.InvalidMessageID
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.InvalidMessageID, "") // TODO - Add error message
|
||||
} else {
|
||||
globals.Logger.Critical(err.Error())
|
||||
return nil, nex.Errors.FPD.Unknown
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message
|
||||
}
|
||||
}
|
||||
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureServer, nil)
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureEndpoint, nil)
|
||||
rmcResponse.ProtocolID = friends_wiiu.ProtocolID
|
||||
rmcResponse.MethodID = friends_wiiu.MethodDeleteFriendRequest
|
||||
rmcResponse.CallID = callID
|
||||
|
||||
return rmcResponse, 0
|
||||
return rmcResponse, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,23 +2,24 @@ package nex_friends_wiiu
|
|||
|
||||
import (
|
||||
"github.com/PretendoNetwork/friends/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
|
||||
nex "github.com/PretendoNetwork/nex-go/v2"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu/types"
|
||||
)
|
||||
|
||||
func DeletePersistentNotification(err error, packet nex.PacketInterface, callID uint32, notifications []*friends_wiiu_types.PersistentNotification) (*nex.RMCMessage, uint32) {
|
||||
func DeletePersistentNotification(err error, packet nex.PacketInterface, callID uint32, notifications *types.List[*friends_wiiu_types.PersistentNotification]) (*nex.RMCMessage, *nex.Error) {
|
||||
if err != nil {
|
||||
globals.Logger.Error(err.Error())
|
||||
return nil, nex.Errors.FPD.InvalidArgument
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.InvalidArgument, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
// TODO - Do something here
|
||||
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureServer, nil)
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureEndpoint, nil)
|
||||
rmcResponse.ProtocolID = friends_wiiu.ProtocolID
|
||||
rmcResponse.MethodID = friends_wiiu.MethodDeletePersistentNotification
|
||||
rmcResponse.CallID = callID
|
||||
|
||||
return rmcResponse, 0
|
||||
return rmcResponse, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,67 +7,68 @@ import (
|
|||
database_wiiu "github.com/PretendoNetwork/friends/database/wiiu"
|
||||
"github.com/PretendoNetwork/friends/globals"
|
||||
"github.com/PretendoNetwork/friends/utility"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
|
||||
nex "github.com/PretendoNetwork/nex-go/v2"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu/types"
|
||||
)
|
||||
|
||||
func DenyFriendRequest(err error, packet nex.PacketInterface, callID uint32, id uint64) (*nex.RMCMessage, uint32) {
|
||||
func DenyFriendRequest(err error, packet nex.PacketInterface, callID uint32, id *types.PrimitiveU64) (*nex.RMCMessage, *nex.Error) {
|
||||
if err != nil {
|
||||
globals.Logger.Error(err.Error())
|
||||
return nil, nex.Errors.FPD.InvalidArgument
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.InvalidArgument, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
client := packet.Sender().(*nex.PRUDPClient)
|
||||
connection := packet.Sender().(*nex.PRUDPConnection)
|
||||
|
||||
err = database_wiiu.SetFriendRequestDenied(id)
|
||||
err = database_wiiu.SetFriendRequestDenied(id.Value)
|
||||
if err != nil {
|
||||
globals.Logger.Critical(err.Error())
|
||||
return nil, nex.Errors.FPD.Unknown
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
senderPID, _, err := database_wiiu.GetPIDsByFriendRequestID(id)
|
||||
senderPID, _, err := database_wiiu.GetPIDsByFriendRequestID(id.Value)
|
||||
if err != nil {
|
||||
if err == database.ErrFriendRequestNotFound {
|
||||
return nil, nex.Errors.FPD.InvalidMessageID
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.InvalidMessageID, "") // TODO - Add error message
|
||||
} else {
|
||||
globals.Logger.Critical(err.Error())
|
||||
return nil, nex.Errors.FPD.Unknown
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message
|
||||
}
|
||||
}
|
||||
|
||||
err = database_wiiu.SetUserBlocked(client.PID().LegacyValue(), senderPID, 0, 0)
|
||||
err = database_wiiu.SetUserBlocked(connection.PID().LegacyValue(), senderPID, 0, 0)
|
||||
if err != nil {
|
||||
globals.Logger.Critical(err.Error())
|
||||
return nil, nex.Errors.FPD.Unknown
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
info, err := utility.GetUserInfoByPID(senderPID)
|
||||
if err != nil {
|
||||
globals.Logger.Critical(err.Error())
|
||||
return nil, nex.Errors.FPD.Unknown
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
date := nex.NewDateTime(0)
|
||||
date := types.NewDateTime(0)
|
||||
date.FromTimestamp(time.Now())
|
||||
|
||||
// Create a new blacklist principal for the client, as unlike AddBlacklist they don't send one to us.
|
||||
// Create a new blacklist principal for the connection, as unlike AddBlacklist they don't send one to us.
|
||||
blacklistPrincipal := friends_wiiu_types.NewBlacklistedPrincipal()
|
||||
|
||||
blacklistPrincipal.PrincipalBasicInfo = info
|
||||
blacklistPrincipal.GameKey = friends_wiiu_types.NewGameKey()
|
||||
blacklistPrincipal.BlackListedSince = date
|
||||
|
||||
rmcResponseStream := nex.NewStreamOut(globals.SecureServer)
|
||||
rmcResponseStream := nex.NewByteStreamOut(globals.SecureEndpoint.LibraryVersions(), globals.SecureEndpoint.ByteStreamSettings())
|
||||
|
||||
rmcResponseStream.WriteStructure(blacklistPrincipal)
|
||||
blacklistPrincipal.WriteTo(rmcResponseStream)
|
||||
|
||||
rmcResponseBody := rmcResponseStream.Bytes()
|
||||
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureServer, rmcResponseBody)
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureEndpoint, rmcResponseBody)
|
||||
rmcResponse.ProtocolID = friends_wiiu.ProtocolID
|
||||
rmcResponse.MethodID = friends_wiiu.MethodDenyFriendRequest
|
||||
rmcResponse.CallID = callID
|
||||
|
||||
return rmcResponse, 0
|
||||
return rmcResponse, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,43 +3,47 @@ package nex_friends_wiiu
|
|||
import (
|
||||
"github.com/PretendoNetwork/friends/globals"
|
||||
"github.com/PretendoNetwork/friends/utility"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
|
||||
nex "github.com/PretendoNetwork/nex-go/v2"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu/types"
|
||||
)
|
||||
|
||||
func GetBasicInfo(err error, packet nex.PacketInterface, callID uint32, pids []*nex.PID) (*nex.RMCMessage, uint32) {
|
||||
func GetBasicInfo(err error, packet nex.PacketInterface, callID uint32, pids *types.List[*types.PID]) (*nex.RMCMessage, *nex.Error) {
|
||||
if err != nil {
|
||||
globals.Logger.Error(err.Error())
|
||||
return nil, nex.Errors.FPD.InvalidArgument
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.InvalidArgument, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
infos := make([]*friends_wiiu_types.PrincipalBasicInfo, 0)
|
||||
|
||||
for i := 0; i < len(pids); i++ {
|
||||
pid := pids[i]
|
||||
infos := types.NewList[*friends_wiiu_types.PrincipalBasicInfo]()
|
||||
infos.Type = friends_wiiu_types.NewPrincipalBasicInfo()
|
||||
|
||||
if pids.Each(func(i int, pid *types.PID) bool {
|
||||
info, err := utility.GetUserInfoByPID(pid.LegacyValue())
|
||||
if err != nil {
|
||||
globals.Logger.Critical(err.Error())
|
||||
return nil, nex.Errors.FPD.Unknown
|
||||
return true
|
||||
}
|
||||
|
||||
if info.PID.LegacyValue() != 0 {
|
||||
infos = append(infos, info)
|
||||
infos.Append(info)
|
||||
}
|
||||
|
||||
return false
|
||||
}) {
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
rmcResponseStream := nex.NewStreamOut(globals.SecureServer)
|
||||
rmcResponseStream := nex.NewByteStreamOut(globals.SecureEndpoint.LibraryVersions(), globals.SecureEndpoint.ByteStreamSettings())
|
||||
|
||||
nex.StreamWriteListStructure(rmcResponseStream, infos)
|
||||
infos.WriteTo(rmcResponseStream)
|
||||
|
||||
rmcResponseBody := rmcResponseStream.Bytes()
|
||||
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureServer, rmcResponseBody)
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureEndpoint, rmcResponseBody)
|
||||
rmcResponse.ProtocolID = friends_wiiu.ProtocolID
|
||||
rmcResponse.MethodID = friends_wiiu.MethodGetBasicInfo
|
||||
rmcResponse.CallID = callID
|
||||
|
||||
return rmcResponse, 0
|
||||
return rmcResponse, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,49 +3,53 @@ package nex_friends_wiiu
|
|||
import (
|
||||
database_wiiu "github.com/PretendoNetwork/friends/database/wiiu"
|
||||
"github.com/PretendoNetwork/friends/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
|
||||
nex "github.com/PretendoNetwork/nex-go/v2"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu/types"
|
||||
)
|
||||
|
||||
func GetRequestBlockSettings(err error, packet nex.PacketInterface, callID uint32, pids []uint32) (*nex.RMCMessage, uint32) {
|
||||
func GetRequestBlockSettings(err error, packet nex.PacketInterface, callID uint32, pids *types.List[*types.PrimitiveU32]) (*nex.RMCMessage, *nex.Error) {
|
||||
if err != nil {
|
||||
globals.Logger.Error(err.Error())
|
||||
return nil, nex.Errors.FPD.InvalidArgument
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.InvalidArgument, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
client := packet.Sender().(*nex.PRUDPClient)
|
||||
connection := packet.Sender().(*nex.PRUDPConnection)
|
||||
|
||||
settings := make([]*friends_wiiu_types.PrincipalRequestBlockSetting, 0)
|
||||
|
||||
// TODO:
|
||||
// Improve this. Use less database_wiiu.reads
|
||||
for i := 0; i < len(pids); i++ {
|
||||
requestedPID := pids[i]
|
||||
settings := types.NewList[*friends_wiiu_types.PrincipalRequestBlockSetting]()
|
||||
settings.Type = friends_wiiu_types.NewPrincipalRequestBlockSetting()
|
||||
|
||||
// TODO - Improve this. Use less database_wiiu reads
|
||||
if pids.Each(func(i int, pid *types.PrimitiveU32) bool {
|
||||
setting := friends_wiiu_types.NewPrincipalRequestBlockSetting()
|
||||
setting.PID = requestedPID
|
||||
isBlocked, err := database_wiiu.IsFriendRequestBlocked(client.PID().LegacyValue(), requestedPID)
|
||||
setting.PID = pid
|
||||
|
||||
isBlocked, err := database_wiiu.IsFriendRequestBlocked(connection.PID().LegacyValue(), pid.Value)
|
||||
if err != nil {
|
||||
globals.Logger.Critical(err.Error())
|
||||
return nil, nex.Errors.Core.Unknown
|
||||
return true
|
||||
}
|
||||
|
||||
setting.IsBlocked = isBlocked
|
||||
setting.IsBlocked = types.NewPrimitiveBool(isBlocked)
|
||||
|
||||
settings = append(settings, setting)
|
||||
settings.Append(setting)
|
||||
|
||||
return false
|
||||
}) {
|
||||
return nil, nex.NewError(nex.ResultCodes.Core.Unknown, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
rmcResponseStream := nex.NewStreamOut(globals.SecureServer)
|
||||
rmcResponseStream := nex.NewByteStreamOut(globals.SecureEndpoint.LibraryVersions(), globals.SecureEndpoint.ByteStreamSettings())
|
||||
|
||||
nex.StreamWriteListStructure(rmcResponseStream, settings)
|
||||
settings.WriteTo(rmcResponseStream)
|
||||
|
||||
rmcResponseBody := rmcResponseStream.Bytes()
|
||||
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureServer, rmcResponseBody)
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureEndpoint, rmcResponseBody)
|
||||
rmcResponse.ProtocolID = friends_wiiu.ProtocolID
|
||||
rmcResponse.MethodID = friends_wiiu.MethodGetRequestBlockSettings
|
||||
rmcResponse.CallID = callID
|
||||
|
||||
return rmcResponse, 0
|
||||
return rmcResponse, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,29 +3,33 @@ package nex_friends_wiiu
|
|||
import (
|
||||
database_wiiu "github.com/PretendoNetwork/friends/database/wiiu"
|
||||
"github.com/PretendoNetwork/friends/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu"
|
||||
nex "github.com/PretendoNetwork/nex-go/v2"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu"
|
||||
)
|
||||
|
||||
func MarkFriendRequestsAsReceived(err error, packet nex.PacketInterface, callID uint32, ids []uint64) (*nex.RMCMessage, uint32) {
|
||||
func MarkFriendRequestsAsReceived(err error, packet nex.PacketInterface, callID uint32, ids *types.List[*types.PrimitiveU64]) (*nex.RMCMessage, *nex.Error) {
|
||||
if err != nil {
|
||||
globals.Logger.Error(err.Error())
|
||||
return nil, nex.Errors.FPD.InvalidArgument
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.InvalidArgument, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
for i := 0; i < len(ids); i++ {
|
||||
id := ids[i]
|
||||
err = database_wiiu.SetFriendRequestReceived(id)
|
||||
if ids.Each(func(i int, id *types.PrimitiveU64) bool {
|
||||
err = database_wiiu.SetFriendRequestReceived(id.Value)
|
||||
if err != nil {
|
||||
globals.Logger.Critical(err.Error())
|
||||
return nil, nex.Errors.FPD.Unknown
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}) {
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureServer, nil)
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureEndpoint, nil)
|
||||
rmcResponse.ProtocolID = friends_wiiu.ProtocolID
|
||||
rmcResponse.MethodID = friends_wiiu.MethodMarkFriendRequestsAsReceived
|
||||
rmcResponse.CallID = callID
|
||||
|
||||
return rmcResponse, 0
|
||||
return rmcResponse, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,32 +4,33 @@ import (
|
|||
"github.com/PretendoNetwork/friends/database"
|
||||
database_wiiu "github.com/PretendoNetwork/friends/database/wiiu"
|
||||
"github.com/PretendoNetwork/friends/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu"
|
||||
nex "github.com/PretendoNetwork/nex-go/v2"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu"
|
||||
)
|
||||
|
||||
func RemoveBlacklist(err error, packet nex.PacketInterface, callID uint32, blockedPID *nex.PID) (*nex.RMCMessage, uint32) {
|
||||
func RemoveBlackList(err error, packet nex.PacketInterface, callID uint32, blockedPID *types.PID) (*nex.RMCMessage, *nex.Error) {
|
||||
if err != nil {
|
||||
globals.Logger.Error(err.Error())
|
||||
return nil, nex.Errors.FPD.InvalidArgument
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.InvalidArgument, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
client := packet.Sender().(*nex.PRUDPClient)
|
||||
connection := packet.Sender().(*nex.PRUDPConnection)
|
||||
|
||||
err = database_wiiu.UnsetUserBlocked(client.PID().LegacyValue(), blockedPID.LegacyValue())
|
||||
err = database_wiiu.UnsetUserBlocked(connection.PID().LegacyValue(), blockedPID.LegacyValue())
|
||||
if err != nil {
|
||||
if err == database.ErrPIDNotFound {
|
||||
return nil, nex.Errors.FPD.NotInMyBlacklist
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.NotInMyBlacklist, "") // TODO - Add error message
|
||||
} else {
|
||||
globals.Logger.Critical(err.Error())
|
||||
return nil, nex.Errors.FPD.Unknown
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message
|
||||
}
|
||||
}
|
||||
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureServer, nil)
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureEndpoint, nil)
|
||||
rmcResponse.ProtocolID = friends_wiiu.ProtocolID
|
||||
rmcResponse.MethodID = friends_wiiu.MethodRemoveBlackList
|
||||
rmcResponse.CallID = callID
|
||||
|
||||
return rmcResponse, 0
|
||||
return rmcResponse, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,37 +5,38 @@ import (
|
|||
database_wiiu "github.com/PretendoNetwork/friends/database/wiiu"
|
||||
"github.com/PretendoNetwork/friends/globals"
|
||||
notifications_wiiu "github.com/PretendoNetwork/friends/notifications/wiiu"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu"
|
||||
nex "github.com/PretendoNetwork/nex-go/v2"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu"
|
||||
)
|
||||
|
||||
func RemoveFriend(err error, packet nex.PacketInterface, callID uint32, pid *nex.PID) (*nex.RMCMessage, uint32) {
|
||||
func RemoveFriend(err error, packet nex.PacketInterface, callID uint32, pid *types.PID) (*nex.RMCMessage, *nex.Error) {
|
||||
if err != nil {
|
||||
globals.Logger.Error(err.Error())
|
||||
return nil, nex.Errors.FPD.InvalidArgument
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.InvalidArgument, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
client := packet.Sender().(*nex.PRUDPClient)
|
||||
connection := packet.Sender().(*nex.PRUDPConnection)
|
||||
|
||||
err = database_wiiu.RemoveFriendship(client.PID().LegacyValue(), pid.LegacyValue())
|
||||
err = database_wiiu.RemoveFriendship(connection.PID().LegacyValue(), pid.LegacyValue())
|
||||
if err != nil {
|
||||
if err == database.ErrFriendshipNotFound {
|
||||
return nil, nex.Errors.FPD.NotInMyFriendList
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.NotInMyFriendList, "") // TODO - Add error message
|
||||
} else {
|
||||
globals.Logger.Critical(err.Error())
|
||||
return nil, nex.Errors.FPD.Unknown
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message
|
||||
}
|
||||
}
|
||||
|
||||
connectedUser := globals.ConnectedUsers[pid.LegacyValue()]
|
||||
if connectedUser != nil {
|
||||
go notifications_wiiu.SendFriendshipRemoved(connectedUser.Client, pid)
|
||||
go notifications_wiiu.SendFriendshipRemoved(connectedUser.Connection, pid)
|
||||
}
|
||||
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureServer, nil)
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureEndpoint, nil)
|
||||
rmcResponse.ProtocolID = friends_wiiu.ProtocolID
|
||||
rmcResponse.MethodID = friends_wiiu.MethodRemoveFriend
|
||||
rmcResponse.CallID = callID
|
||||
|
||||
return rmcResponse, 0
|
||||
return rmcResponse, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,36 +1,36 @@
|
|||
package nex_friends_wiiu
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/PretendoNetwork/friends/database"
|
||||
database_wiiu "github.com/PretendoNetwork/friends/database/wiiu"
|
||||
"github.com/PretendoNetwork/friends/globals"
|
||||
notifications_wiiu "github.com/PretendoNetwork/friends/notifications/wiiu"
|
||||
"github.com/PretendoNetwork/friends/types"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
|
||||
friends_types "github.com/PretendoNetwork/friends/types"
|
||||
nex "github.com/PretendoNetwork/nex-go/v2"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu/types"
|
||||
)
|
||||
|
||||
func UpdateAndGetAllInformation(err error, packet nex.PacketInterface, callID uint32, nnaInfo *friends_wiiu_types.NNAInfo, presence *friends_wiiu_types.NintendoPresenceV2, birthday *nex.DateTime) (*nex.RMCMessage, uint32) {
|
||||
func UpdateAndGetAllInformation(err error, packet nex.PacketInterface, callID uint32, nnaInfo *friends_wiiu_types.NNAInfo, presence *friends_wiiu_types.NintendoPresenceV2, birthday *types.DateTime) (*nex.RMCMessage, *nex.Error) {
|
||||
if err != nil {
|
||||
globals.Logger.Error(err.Error())
|
||||
return nil, nex.Errors.FPD.InvalidArgument
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.InvalidArgument, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
client := packet.Sender().(*nex.PRUDPClient)
|
||||
connection := packet.Sender().(*nex.PRUDPConnection)
|
||||
|
||||
// * Get user information
|
||||
pid := client.PID().LegacyValue()
|
||||
pid := connection.PID().LegacyValue()
|
||||
|
||||
if globals.ConnectedUsers[pid] == nil {
|
||||
// TODO - Figure out why this is getting removed
|
||||
connectedUser := types.NewConnectedUser()
|
||||
connectedUser := friends_types.NewConnectedUser()
|
||||
connectedUser.PID = pid
|
||||
connectedUser.Platform = types.WUP
|
||||
connectedUser.Client = client
|
||||
connectedUser.Platform = friends_types.WUP
|
||||
connectedUser.Connection = connection
|
||||
|
||||
globals.ConnectedUsers[pid] = connectedUser
|
||||
}
|
||||
|
|
@ -41,53 +41,53 @@ func UpdateAndGetAllInformation(err error, packet nex.PacketInterface, callID ui
|
|||
principalPreference, err := database_wiiu.GetUserPrincipalPreference(pid)
|
||||
if err != nil {
|
||||
if err == database.ErrPIDNotFound {
|
||||
return nil, nex.Errors.FPD.InvalidPrincipalID
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.InvalidPrincipalID, "") // TODO - Add error message
|
||||
} else {
|
||||
globals.Logger.Critical(err.Error())
|
||||
return nil, nex.Errors.FPD.Unknown
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message
|
||||
}
|
||||
}
|
||||
|
||||
comment, err := database_wiiu.GetUserComment(pid)
|
||||
if err != nil {
|
||||
if err == database.ErrPIDNotFound {
|
||||
return nil, nex.Errors.FPD.InvalidPrincipalID
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.InvalidPrincipalID, "") // TODO - Add error message
|
||||
} else {
|
||||
globals.Logger.Critical(err.Error())
|
||||
return nil, nex.Errors.FPD.Unknown
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message
|
||||
}
|
||||
}
|
||||
|
||||
friendList, err := database_wiiu.GetUserFriendList(pid)
|
||||
if err != nil && err != database.ErrEmptyList {
|
||||
globals.Logger.Critical(err.Error())
|
||||
return nil, nex.Errors.FPD.Unknown
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
friendRequestsOut, err := database_wiiu.GetUserFriendRequestsOut(pid)
|
||||
if err != nil && err != database.ErrEmptyList {
|
||||
globals.Logger.Critical(err.Error())
|
||||
return nil, nex.Errors.FPD.Unknown
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
friendRequestsIn, err := database_wiiu.GetUserFriendRequestsIn(pid)
|
||||
if err != nil && err != database.ErrEmptyList {
|
||||
globals.Logger.Critical(err.Error())
|
||||
return nil, nex.Errors.FPD.Unknown
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
blockList, err := database_wiiu.GetUserBlockList(pid)
|
||||
if err != nil && err != database.ErrBlacklistNotFound {
|
||||
globals.Logger.Critical(err.Error())
|
||||
return nil, nex.Errors.FPD.Unknown
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
notifications := database_wiiu.GetUserNotifications(pid)
|
||||
|
||||
// * Update user information
|
||||
|
||||
presence.Online = true // * Force online status. I have no idea why this is always false
|
||||
presence.PID = client.PID() // * WHY IS THIS SET TO 0 BY DEFAULT??
|
||||
presence.Online = types.NewPrimitiveBool(true) // * Force online status. I have no idea why this is always false
|
||||
presence.PID = connection.PID() // * WHY IS THIS SET TO 0 BY DEFAULT??
|
||||
|
||||
notifications_wiiu.SendPresenceUpdate(presence)
|
||||
|
||||
|
|
@ -97,23 +97,23 @@ func UpdateAndGetAllInformation(err error, packet nex.PacketInterface, callID ui
|
|||
bella.NNAInfo = friends_wiiu_types.NewNNAInfo()
|
||||
bella.Presence = friends_wiiu_types.NewNintendoPresenceV2()
|
||||
bella.Status = friends_wiiu_types.NewComment()
|
||||
bella.BecameFriend = nex.NewDateTime(0)
|
||||
bella.LastOnline = nex.NewDateTime(0)
|
||||
bella.Unknown = 0
|
||||
bella.BecameFriend = types.NewDateTime(0)
|
||||
bella.LastOnline = types.NewDateTime(0)
|
||||
bella.Unknown = types.NewPrimitiveU64(0)
|
||||
|
||||
bella.NNAInfo.PrincipalBasicInfo = friends_wiiu_types.NewPrincipalBasicInfo()
|
||||
bella.NNAInfo.Unknown1 = 0
|
||||
bella.NNAInfo.Unknown2 = 0
|
||||
bella.NNAInfo.Unknown1 = types.NewPrimitiveU8(0)
|
||||
bella.NNAInfo.Unknown2 = types.NewPrimitiveU8(0)
|
||||
|
||||
bella.NNAInfo.PrincipalBasicInfo.PID = nex.NewPID[uint32](1743126339)
|
||||
bella.NNAInfo.PrincipalBasicInfo.NNID = "bells1998"
|
||||
bella.NNAInfo.PrincipalBasicInfo.PID = types.NewPID(1743126339)
|
||||
bella.NNAInfo.PrincipalBasicInfo.NNID = types.NewString("bells1998")
|
||||
bella.NNAInfo.PrincipalBasicInfo.Mii = friends_wiiu_types.NewMiiV2()
|
||||
bella.NNAInfo.PrincipalBasicInfo.Unknown = 0
|
||||
bella.NNAInfo.PrincipalBasicInfo.Unknown = types.NewPrimitiveU8(0)
|
||||
|
||||
bella.NNAInfo.PrincipalBasicInfo.Mii.Name = "bella"
|
||||
bella.NNAInfo.PrincipalBasicInfo.Mii.Unknown1 = 0
|
||||
bella.NNAInfo.PrincipalBasicInfo.Mii.Unknown2 = 0
|
||||
bella.NNAInfo.PrincipalBasicInfo.Mii.MiiData = []byte{
|
||||
bella.NNAInfo.PrincipalBasicInfo.Mii.Name = types.NewString("bella")
|
||||
bella.NNAInfo.PrincipalBasicInfo.Mii.Unknown1 = types.NewPrimitiveU8(0)
|
||||
bella.NNAInfo.PrincipalBasicInfo.Mii.Unknown2 = types.NewPrimitiveU8(0)
|
||||
bella.NNAInfo.PrincipalBasicInfo.Mii.MiiData = types.NewBuffer([]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,
|
||||
|
|
@ -126,139 +126,61 @@ func UpdateAndGetAllInformation(err error, packet nex.PacketInterface, callID ui
|
|||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x86,
|
||||
}
|
||||
bella.NNAInfo.PrincipalBasicInfo.Mii.Datetime = nex.NewDateTime(0)
|
||||
})
|
||||
bella.NNAInfo.PrincipalBasicInfo.Mii.Datetime = types.NewDateTime(0)
|
||||
|
||||
bella.Presence.ChangedFlags = 0x1EE
|
||||
bella.Presence.Online = true
|
||||
bella.Presence.ChangedFlags = types.NewPrimitiveU32(0x1EE)
|
||||
bella.Presence.Online = types.NewPrimitiveBool(true)
|
||||
bella.Presence.GameKey = friends_wiiu_types.NewGameKey()
|
||||
bella.Presence.Unknown1 = 0
|
||||
bella.Presence.Message = "Testing"
|
||||
bella.Presence.Unknown1 = types.NewPrimitiveU8(0)
|
||||
bella.Presence.Message = types.NewString("Testing")
|
||||
//bella.Presence.Unknown2 = 2
|
||||
bella.Presence.Unknown2 = 0
|
||||
bella.Presence.Unknown2 = types.NewPrimitiveU32(0)
|
||||
//bella.Presence.Unknown3 = 2
|
||||
bella.Presence.Unknown3 = 0
|
||||
bella.Presence.Unknown3 = types.NewPrimitiveU8(0)
|
||||
//bella.Presence.GameServerID = 0x1010EB00
|
||||
bella.Presence.GameServerID = 0
|
||||
bella.Presence.GameServerID = types.NewPrimitiveU32(0)
|
||||
//bella.Presence.Unknown4 = 3
|
||||
bella.Presence.Unknown4 = 0
|
||||
bella.Presence.PID = nex.NewPID[uint32](1743126339)
|
||||
bella.Presence.Unknown4 = types.NewPrimitiveU32(0)
|
||||
bella.Presence.PID = types.NewPID(1743126339)
|
||||
//bella.Presence.GatheringID = 1743126339 // test fake ID
|
||||
bella.Presence.GatheringID = 0
|
||||
bella.Presence.GatheringID = types.NewPrimitiveU32(0)
|
||||
//bella.Presence.ApplicationData, _ = hex.DecodeString("0000200300000000000000001843ffe567000000")
|
||||
bella.Presence.ApplicationData = []byte{0x0}
|
||||
bella.Presence.Unknown5 = 0
|
||||
bella.Presence.Unknown6 = 0
|
||||
bella.Presence.Unknown7 = 0
|
||||
bella.Presence.ApplicationData = types.NewBuffer([]byte{0x0})
|
||||
bella.Presence.Unknown5 = types.NewPrimitiveU8(0)
|
||||
bella.Presence.Unknown6 = types.NewPrimitiveU8(0)
|
||||
bella.Presence.Unknown7 = types.NewPrimitiveU8(0)
|
||||
|
||||
//bella.Presence.GameKey.TitleID = 0x000500001010EC00
|
||||
bella.Presence.GameKey.TitleID = 0
|
||||
bella.Presence.GameKey.TitleID = types.NewPrimitiveU64(0)
|
||||
//bella.Presence.GameKey.TitleVersion = 64
|
||||
bella.Presence.GameKey.TitleVersion = 0
|
||||
bella.Presence.GameKey.TitleVersion = types.NewPrimitiveU16(0)
|
||||
|
||||
bella.Status.Unknown = 0
|
||||
bella.Status.Contents = "test"
|
||||
bella.Status.LastChanged = nex.NewDateTime(0)
|
||||
bella.Status.Unknown = types.NewPrimitiveU8(0)
|
||||
bella.Status.Contents = types.NewString("test")
|
||||
bella.Status.LastChanged = types.NewDateTime(0)
|
||||
|
||||
friendList = append(friendList, bella)
|
||||
friendList.Append(bella)
|
||||
}
|
||||
|
||||
// * Force 100 friends
|
||||
rmcResponseStream := nex.NewByteStreamOut(globals.SecureEndpoint.LibraryVersions(), globals.SecureEndpoint.ByteStreamSettings())
|
||||
|
||||
fmt.Println(len(friendList))
|
||||
fmt.Println(100 - len(friendList))
|
||||
|
||||
for i := 0; i < 100-len(friendList); i++ {
|
||||
var pid uint32 = 1750000000 + uint32(i)
|
||||
friend := friends_wiiu_types.NewFriendInfo()
|
||||
|
||||
friend.NNAInfo = friends_wiiu_types.NewNNAInfo()
|
||||
friend.Presence = friends_wiiu_types.NewNintendoPresenceV2()
|
||||
friend.Status = friends_wiiu_types.NewComment()
|
||||
friend.BecameFriend = nex.NewDateTime(0)
|
||||
friend.LastOnline = nex.NewDateTime(0)
|
||||
friend.Unknown = 0
|
||||
|
||||
friend.NNAInfo.PrincipalBasicInfo = friends_wiiu_types.NewPrincipalBasicInfo()
|
||||
friend.NNAInfo.Unknown1 = 0
|
||||
friend.NNAInfo.Unknown2 = 0
|
||||
|
||||
friend.NNAInfo.PrincipalBasicInfo.PID = nex.NewPID[uint32](pid)
|
||||
friend.NNAInfo.PrincipalBasicInfo.NNID = fmt.Sprint(pid)
|
||||
friend.NNAInfo.PrincipalBasicInfo.Mii = friends_wiiu_types.NewMiiV2()
|
||||
friend.NNAInfo.PrincipalBasicInfo.Unknown = 0
|
||||
|
||||
friend.NNAInfo.PrincipalBasicInfo.Mii.Name = fmt.Sprint(pid)
|
||||
friend.NNAInfo.PrincipalBasicInfo.Mii.Unknown1 = 0
|
||||
friend.NNAInfo.PrincipalBasicInfo.Mii.Unknown2 = 0
|
||||
friend.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,
|
||||
0x01, 0x40, 0x62, 0x00, 0x65, 0x00, 0x6C, 0x00,
|
||||
0x6C, 0x00, 0x61, 0x00, 0x00, 0x00, 0x45, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40,
|
||||
0x12, 0x00, 0x81, 0x01, 0x04, 0x68, 0x43, 0x18,
|
||||
0x20, 0x34, 0x46, 0x14, 0x81, 0x12, 0x17, 0x68,
|
||||
0x0D, 0x00, 0x00, 0x29, 0x03, 0x52, 0x48, 0x50,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x86,
|
||||
}
|
||||
friend.NNAInfo.PrincipalBasicInfo.Mii.Datetime = nex.NewDateTime(0)
|
||||
|
||||
friend.Presence.ChangedFlags = 0x1EE
|
||||
friend.Presence.Online = true
|
||||
friend.Presence.GameKey = friends_wiiu_types.NewGameKey()
|
||||
friend.Presence.Unknown1 = 0
|
||||
friend.Presence.Message = "Testing"
|
||||
//bella.Presence.Unknown2 = 2
|
||||
friend.Presence.Unknown2 = 0
|
||||
//bella.Presence.Unknown3 = 2
|
||||
friend.Presence.Unknown3 = 0
|
||||
//bella.Presence.GameServerID = 0x1010EB00
|
||||
friend.Presence.GameServerID = 0
|
||||
//bella.Presence.Unknown4 = 3
|
||||
friend.Presence.Unknown4 = 0
|
||||
friend.Presence.PID = nex.NewPID[uint32](pid)
|
||||
//bella.Presence.GatheringID = 1743126339 // test fake ID
|
||||
friend.Presence.GatheringID = 0
|
||||
//bella.Presence.ApplicationData, _ = hex.DecodeString("0000200300000000000000001843ffe567000000")
|
||||
friend.Presence.ApplicationData = []byte{0x0}
|
||||
friend.Presence.Unknown5 = 0
|
||||
friend.Presence.Unknown6 = 0
|
||||
friend.Presence.Unknown7 = 0
|
||||
|
||||
//bella.Presence.GameKey.TitleID = 0x000500001010EC00
|
||||
friend.Presence.GameKey.TitleID = 0
|
||||
//bella.Presence.GameKey.TitleVersion = 64
|
||||
friend.Presence.GameKey.TitleVersion = 0
|
||||
|
||||
friend.Status.Unknown = 0
|
||||
friend.Status.Contents = "test"
|
||||
friend.Status.LastChanged = nex.NewDateTime(0)
|
||||
|
||||
friendList = append(friendList, friend)
|
||||
}
|
||||
|
||||
rmcResponseStream := nex.NewStreamOut(globals.SecureServer)
|
||||
|
||||
rmcResponseStream.WriteStructure(principalPreference)
|
||||
rmcResponseStream.WriteStructure(comment)
|
||||
nex.StreamWriteListStructure(rmcResponseStream, friendList)
|
||||
nex.StreamWriteListStructure(rmcResponseStream, friendRequestsOut)
|
||||
nex.StreamWriteListStructure(rmcResponseStream, friendRequestsIn)
|
||||
nex.StreamWriteListStructure(rmcResponseStream, blockList)
|
||||
rmcResponseStream.WriteBool(false) // * Unknown
|
||||
nex.StreamWriteListStructure(rmcResponseStream, notifications)
|
||||
rmcResponseStream.WriteBool(false) // * Unknown
|
||||
principalPreference.WriteTo(rmcResponseStream)
|
||||
comment.WriteTo(rmcResponseStream)
|
||||
friendList.WriteTo(rmcResponseStream)
|
||||
friendRequestsOut.WriteTo(rmcResponseStream)
|
||||
friendRequestsIn.WriteTo(rmcResponseStream)
|
||||
blockList.WriteTo(rmcResponseStream)
|
||||
types.NewPrimitiveBool(false).WriteTo(rmcResponseStream) // * Unknown
|
||||
notifications.WriteTo(rmcResponseStream)
|
||||
types.NewPrimitiveBool(false).WriteTo(rmcResponseStream) // * Unknown
|
||||
|
||||
rmcResponseBody := rmcResponseStream.Bytes()
|
||||
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureServer, rmcResponseBody)
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureEndpoint, rmcResponseBody)
|
||||
rmcResponse.ProtocolID = friends_wiiu.ProtocolID
|
||||
rmcResponse.MethodID = friends_wiiu.MethodUpdateAndGetAllInformation
|
||||
rmcResponse.CallID = callID
|
||||
|
||||
return rmcResponse, 0
|
||||
return rmcResponse, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,35 +3,36 @@ package nex_friends_wiiu
|
|||
import (
|
||||
database_wiiu "github.com/PretendoNetwork/friends/database/wiiu"
|
||||
"github.com/PretendoNetwork/friends/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
|
||||
nex "github.com/PretendoNetwork/nex-go/v2"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu/types"
|
||||
)
|
||||
|
||||
func UpdateComment(err error, packet nex.PacketInterface, callID uint32, comment *friends_wiiu_types.Comment) (*nex.RMCMessage, uint32) {
|
||||
func UpdateComment(err error, packet nex.PacketInterface, callID uint32, comment *friends_wiiu_types.Comment) (*nex.RMCMessage, *nex.Error) {
|
||||
if err != nil {
|
||||
globals.Logger.Error(err.Error())
|
||||
return nil, nex.Errors.FPD.InvalidArgument
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.InvalidArgument, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
client := packet.Sender().(*nex.PRUDPClient)
|
||||
connection := packet.Sender().(*nex.PRUDPConnection)
|
||||
|
||||
changed, err := database_wiiu.UpdateUserComment(client.PID().LegacyValue(), comment.Contents)
|
||||
changed, err := database_wiiu.UpdateUserComment(connection.PID().LegacyValue(), comment.Contents.Value)
|
||||
if err != nil {
|
||||
globals.Logger.Critical(err.Error())
|
||||
return nil, nex.Errors.FPD.Unknown
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
rmcResponseStream := nex.NewStreamOut(globals.SecureServer)
|
||||
rmcResponseStream := nex.NewByteStreamOut(globals.SecureEndpoint.LibraryVersions(), globals.SecureEndpoint.ByteStreamSettings())
|
||||
|
||||
rmcResponseStream.WriteUInt64LE(changed)
|
||||
types.NewPrimitiveU64(changed).WriteTo(rmcResponseStream) // TODO - This is ugly
|
||||
|
||||
rmcResponseBody := rmcResponseStream.Bytes()
|
||||
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureServer, rmcResponseBody)
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureEndpoint, rmcResponseBody)
|
||||
rmcResponse.ProtocolID = friends_wiiu.ProtocolID
|
||||
rmcResponse.MethodID = friends_wiiu.MethodUpdateComment
|
||||
rmcResponse.CallID = callID
|
||||
|
||||
return rmcResponse, 0
|
||||
return rmcResponse, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,29 +3,29 @@ package nex_friends_wiiu
|
|||
import (
|
||||
database_wiiu "github.com/PretendoNetwork/friends/database/wiiu"
|
||||
"github.com/PretendoNetwork/friends/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
|
||||
nex "github.com/PretendoNetwork/nex-go/v2"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu/types"
|
||||
)
|
||||
|
||||
func UpdatePreference(err error, packet nex.PacketInterface, callID uint32, principalPreference *friends_wiiu_types.PrincipalPreference) (*nex.RMCMessage, uint32) {
|
||||
func UpdatePreference(err error, packet nex.PacketInterface, callID uint32, principalPreference *friends_wiiu_types.PrincipalPreference) (*nex.RMCMessage, *nex.Error) {
|
||||
if err != nil {
|
||||
globals.Logger.Error(err.Error())
|
||||
return nil, nex.Errors.FPD.InvalidArgument
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.InvalidArgument, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
client := packet.Sender().(*nex.PRUDPClient)
|
||||
connection := packet.Sender().(*nex.PRUDPConnection)
|
||||
|
||||
err = database_wiiu.UpdateUserPrincipalPreference(client.PID().LegacyValue(), principalPreference)
|
||||
err = database_wiiu.UpdateUserPrincipalPreference(connection.PID().LegacyValue(), principalPreference)
|
||||
if err != nil {
|
||||
globals.Logger.Critical(err.Error())
|
||||
return nil, nex.Errors.FPD.Unknown
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureServer, nil)
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureEndpoint, nil)
|
||||
rmcResponse.ProtocolID = friends_wiiu.ProtocolID
|
||||
rmcResponse.MethodID = friends_wiiu.MethodUpdatePreference
|
||||
rmcResponse.CallID = callID
|
||||
|
||||
return rmcResponse, 0
|
||||
return rmcResponse, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,31 +3,32 @@ package nex_friends_wiiu
|
|||
import (
|
||||
"github.com/PretendoNetwork/friends/globals"
|
||||
notifications_wiiu "github.com/PretendoNetwork/friends/notifications/wiiu"
|
||||
"github.com/PretendoNetwork/friends/types"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
|
||||
friends_types "github.com/PretendoNetwork/friends/types"
|
||||
nex "github.com/PretendoNetwork/nex-go/v2"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu/types"
|
||||
)
|
||||
|
||||
func UpdatePresence(err error, packet nex.PacketInterface, callID uint32, presence *friends_wiiu_types.NintendoPresenceV2) (*nex.RMCMessage, uint32) {
|
||||
func UpdatePresence(err error, packet nex.PacketInterface, callID uint32, presence *friends_wiiu_types.NintendoPresenceV2) (*nex.RMCMessage, *nex.Error) {
|
||||
if err != nil {
|
||||
globals.Logger.Error(err.Error())
|
||||
return nil, nex.Errors.FPD.InvalidArgument
|
||||
return nil, nex.NewError(nex.ResultCodes.FPD.InvalidArgument, "") // TODO - Add error message
|
||||
}
|
||||
|
||||
client := packet.Sender().(*nex.PRUDPClient)
|
||||
connection := packet.Sender().(*nex.PRUDPConnection)
|
||||
|
||||
pid := client.PID().LegacyValue()
|
||||
pid := connection.PID().LegacyValue()
|
||||
|
||||
presence.Online = true // * Force online status. I have no idea why this is always false
|
||||
presence.PID = client.PID() // * WHY IS THIS SET TO 0 BY DEFAULT??
|
||||
presence.Online = types.NewPrimitiveBool(true) // * Force online status. I have no idea why this is always false
|
||||
presence.PID = connection.PID() // * WHY IS THIS SET TO 0 BY DEFAULT??
|
||||
|
||||
if globals.ConnectedUsers[pid] == nil {
|
||||
// TODO - Figure out why this is getting removed
|
||||
connectedUser := types.NewConnectedUser()
|
||||
connectedUser := friends_types.NewConnectedUser()
|
||||
connectedUser.PID = pid
|
||||
connectedUser.Platform = types.WUP
|
||||
connectedUser.Client = client
|
||||
connectedUser.Platform = friends_types.WUP
|
||||
connectedUser.Connection = connection
|
||||
// TODO - Find a clean way to create a NNAInfo?
|
||||
|
||||
globals.ConnectedUsers[pid] = connectedUser
|
||||
|
|
@ -37,10 +38,10 @@ func UpdatePresence(err error, packet nex.PacketInterface, callID uint32, presen
|
|||
|
||||
notifications_wiiu.SendPresenceUpdate(presence)
|
||||
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureServer, nil)
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureEndpoint, nil)
|
||||
rmcResponse.ProtocolID = friends_wiiu.ProtocolID
|
||||
rmcResponse.MethodID = friends_wiiu.MethodUpdatePresence
|
||||
rmcResponse.CallID = callID
|
||||
|
||||
return rmcResponse, 0
|
||||
return rmcResponse, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,30 +5,33 @@ import (
|
|||
"strconv"
|
||||
|
||||
"github.com/PretendoNetwork/friends/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
ticket_granting "github.com/PretendoNetwork/nex-protocols-go/ticket-granting"
|
||||
common_ticket_granting "github.com/PretendoNetwork/nex-protocols-common-go/ticket-granting"
|
||||
"github.com/PretendoNetwork/nex-go/v2/constants"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
common_ticket_granting "github.com/PretendoNetwork/nex-protocols-common-go/v2/ticket-granting"
|
||||
ticket_granting "github.com/PretendoNetwork/nex-protocols-go/v2/ticket-granting"
|
||||
)
|
||||
|
||||
func registerCommonAuthenticationServerProtocols() {
|
||||
ticketGrantingProtocol := ticket_granting.NewProtocol(globals.AuthenticationServer)
|
||||
ticketGrantingProtocol := ticket_granting.NewProtocol()
|
||||
commonTicketGrantingProtocol := common_ticket_granting.NewCommonProtocol(ticketGrantingProtocol)
|
||||
|
||||
port, _ := strconv.Atoi(os.Getenv("PN_FRIENDS_SECURE_SERVER_PORT"))
|
||||
|
||||
secureStationURL := nex.NewStationURL("")
|
||||
secureStationURL.Scheme = "prudps"
|
||||
secureStationURL.Fields.Set("address", os.Getenv("PN_FRIENDS_SECURE_SERVER_HOST"))
|
||||
secureStationURL.Fields.Set("port", strconv.Itoa(port))
|
||||
secureStationURL.Fields.Set("CID", "1")
|
||||
secureStationURL.Fields.Set("PID", "2")
|
||||
secureStationURL.Fields.Set("sid", "1")
|
||||
secureStationURL.Fields.Set("stream", "10")
|
||||
secureStationURL.Fields.Set("type", "2")
|
||||
secureStationURL := types.NewStationURL("")
|
||||
secureStationURL.SetURLType(constants.StationURLPRUDPS)
|
||||
secureStationURL.SetAddress(os.Getenv("PN_FRIENDS_SECURE_SERVER_HOST"))
|
||||
secureStationURL.SetPortNumber(uint16(port))
|
||||
secureStationURL.SetConnectionID(1)
|
||||
secureStationURL.SetPrincipalID(types.NewPID(2))
|
||||
secureStationURL.SetStreamID(1)
|
||||
secureStationURL.SetStreamType(constants.StreamTypeRVSecure)
|
||||
secureStationURL.SetType(2)
|
||||
|
||||
commonTicketGrantingProtocol.SecureServerAccount = globals.SecureEndpoint.ServerAccount
|
||||
commonTicketGrantingProtocol.SessionKeyLength = 16
|
||||
commonTicketGrantingProtocol.SecureStationURL = secureStationURL
|
||||
commonTicketGrantingProtocol.BuildName = serverBuildString
|
||||
commonTicketGrantingProtocol.BuildName = types.NewString(serverBuildString)
|
||||
commonTicketGrantingProtocol.EnableInsecureLogin()
|
||||
|
||||
globals.AuthenticationServer.SetPasswordFromPIDFunction(globals.PasswordFromPID)
|
||||
globals.AuthenticationEndpoint.RegisterServiceProtocol(ticketGrantingProtocol)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,13 +3,15 @@ package nex
|
|||
import (
|
||||
"github.com/PretendoNetwork/friends/globals"
|
||||
nex_secure_connection "github.com/PretendoNetwork/friends/nex/secure-connection"
|
||||
secure_connection "github.com/PretendoNetwork/nex-protocols-go/secure-connection"
|
||||
common_secure_connection "github.com/PretendoNetwork/nex-protocols-common-go/secure-connection"
|
||||
common_secure_connection "github.com/PretendoNetwork/nex-protocols-common-go/v2/secure-connection"
|
||||
secure_connection "github.com/PretendoNetwork/nex-protocols-go/v2/secure-connection"
|
||||
)
|
||||
|
||||
func registerCommonSecureServerProtocols() {
|
||||
secureConnectionProtocol := secure_connection.NewProtocol(globals.SecureServer)
|
||||
secureConnectionProtocol := secure_connection.NewProtocol()
|
||||
common_secure_connection.NewCommonProtocol(secureConnectionProtocol)
|
||||
|
||||
secureConnectionProtocol.RegisterEx = nex_secure_connection.RegisterEx
|
||||
|
||||
globals.SecureEndpoint.RegisterServiceProtocol(secureConnectionProtocol)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,15 +5,15 @@ import (
|
|||
nex_account_management "github.com/PretendoNetwork/friends/nex/account-management"
|
||||
nex_friends_3ds "github.com/PretendoNetwork/friends/nex/friends-3ds"
|
||||
nex_friends_wiiu "github.com/PretendoNetwork/friends/nex/friends-wiiu"
|
||||
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"
|
||||
account_management "github.com/PretendoNetwork/nex-protocols-go/v2/account-management"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu"
|
||||
)
|
||||
|
||||
func registerSecureServerProtocols() {
|
||||
accountManagementProtocol := account_management.NewProtocol(globals.SecureServer)
|
||||
friendsWiiUProtocol := friends_wiiu.NewProtocol(globals.SecureServer)
|
||||
friends3DSProtocol := friends_3ds.NewProtocol(globals.SecureServer)
|
||||
accountManagementProtocol := account_management.NewProtocol()
|
||||
friendsWiiUProtocol := friends_wiiu.NewProtocol()
|
||||
friends3DSProtocol := friends_3ds.NewProtocol()
|
||||
|
||||
// * Account Management protocol handles
|
||||
accountManagementProtocol.NintendoCreateAccount = nex_account_management.NintendoCreateAccount
|
||||
|
|
@ -27,8 +27,8 @@ func registerSecureServerProtocols() {
|
|||
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.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
|
||||
|
|
@ -45,7 +45,7 @@ func registerSecureServerProtocols() {
|
|||
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.AddFriendByPrincipalID = nex_friends_3ds.AddFriendByPrincipalID
|
||||
friends3DSProtocol.GetFriendPersistentInfo = nex_friends_3ds.GetFriendPersistentInfo
|
||||
friends3DSProtocol.GetFriendMii = nex_friends_3ds.GetFriendMii
|
||||
friends3DSProtocol.GetFriendPresence = nex_friends_3ds.GetFriendPresence
|
||||
|
|
@ -53,4 +53,8 @@ func registerSecureServerProtocols() {
|
|||
friends3DSProtocol.RemoveFriendByLocalFriendCode = nex_friends_3ds.RemoveFriendByLocalFriendCode
|
||||
friends3DSProtocol.GetPrincipalIDByLocalFriendCode = nex_friends_3ds.GetPrincipalIDByLocalFriendCode
|
||||
friends3DSProtocol.GetAllFriends = nex_friends_3ds.GetAllFriends
|
||||
|
||||
globals.SecureEndpoint.RegisterServiceProtocol(accountManagementProtocol)
|
||||
globals.SecureEndpoint.RegisterServiceProtocol(friendsWiiUProtocol)
|
||||
globals.SecureEndpoint.RegisterServiceProtocol(friends3DSProtocol)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,88 +2,89 @@ package nex_secure_connection
|
|||
|
||||
import (
|
||||
"net"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
database_3ds "github.com/PretendoNetwork/friends/database/3ds"
|
||||
database_wiiu "github.com/PretendoNetwork/friends/database/wiiu"
|
||||
"github.com/PretendoNetwork/friends/globals"
|
||||
"github.com/PretendoNetwork/friends/types"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
secure_connection "github.com/PretendoNetwork/nex-protocols-go/secure-connection"
|
||||
friends_types "github.com/PretendoNetwork/friends/types"
|
||||
nex "github.com/PretendoNetwork/nex-go/v2"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
secure_connection "github.com/PretendoNetwork/nex-protocols-go/v2/secure-connection"
|
||||
)
|
||||
|
||||
func RegisterEx(err error, packet nex.PacketInterface, callID uint32, stationUrls []*nex.StationURL, loginData *nex.DataHolder) (*nex.RMCMessage, uint32) {
|
||||
func RegisterEx(err error, packet nex.PacketInterface, callID uint32, vecMyURLs *types.List[*types.StationURL], hCustomData *types.AnyDataHolder) (*nex.RMCMessage, *nex.Error) {
|
||||
if err != nil {
|
||||
globals.Logger.Error(err.Error())
|
||||
return nil, nex.Errors.Core.InvalidArgument
|
||||
return nil, nex.NewError(nex.ResultCodes.Core.InvalidArgument, "")
|
||||
}
|
||||
|
||||
client := packet.Sender().(*nex.PRUDPClient)
|
||||
connection := packet.Sender().(*nex.PRUDPConnection)
|
||||
|
||||
retval := nex.NewResultSuccess(nex.Errors.Core.Unknown)
|
||||
rmcResponseStream := nex.NewStreamOut(globals.SecureServer)
|
||||
retval := types.NewQResultSuccess(nex.ResultCodes.Core.Unknown)
|
||||
|
||||
// TODO - Validate loginData
|
||||
pid := client.PID().LegacyValue()
|
||||
pid := connection.PID().LegacyValue()
|
||||
|
||||
user := types.NewConnectedUser()
|
||||
user := friends_types.NewConnectedUser()
|
||||
user.PID = pid
|
||||
user.Client = client
|
||||
user.Connection = connection
|
||||
|
||||
lastOnline := nex.NewDateTime(0)
|
||||
lastOnline.FromTimestamp(time.Now())
|
||||
lastOnline := types.NewDateTime(0).Now()
|
||||
loginDataType := hCustomData.TypeName.Value
|
||||
|
||||
loginDataType := loginData.TypeName()
|
||||
switch loginDataType {
|
||||
case "NintendoLoginData":
|
||||
user.Platform = types.WUP // * Platform is Wii U
|
||||
user.Platform = friends_types.WUP // * Platform is Wii U
|
||||
|
||||
err = database_wiiu.UpdateUserLastOnlineTime(pid, lastOnline)
|
||||
if err != nil {
|
||||
globals.Logger.Critical(err.Error())
|
||||
retval = nex.NewResultError(nex.Errors.Authentication.Unknown)
|
||||
retval = types.NewQResultError(nex.ResultCodes.Authentication.Unknown)
|
||||
}
|
||||
case "AccountExtraInfo":
|
||||
user.Platform = types.CTR // * Platform is 3DS
|
||||
user.Platform = friends_types.CTR // * Platform is 3DS
|
||||
|
||||
err = database_3ds.UpdateUserLastOnlineTime(pid, lastOnline)
|
||||
if err != nil {
|
||||
globals.Logger.Critical(err.Error())
|
||||
retval = nex.NewResultError(nex.Errors.Authentication.Unknown)
|
||||
retval = types.NewQResultError(nex.ResultCodes.Authentication.Unknown)
|
||||
}
|
||||
default:
|
||||
globals.Logger.Errorf("Unknown loginData data type %s!", loginDataType)
|
||||
retval = nex.NewResultError(nex.Errors.Authentication.ValidationFailed)
|
||||
retval = types.NewQResultError(nex.ResultCodes.Authentication.ValidationFailed)
|
||||
}
|
||||
|
||||
pidConnectionID := types.NewPrimitiveU32(0)
|
||||
urlPublic := types.NewString("")
|
||||
|
||||
if retval.IsSuccess() {
|
||||
globals.ConnectedUsers[pid] = user
|
||||
|
||||
localStation := stationUrls[0]
|
||||
localStation, _ := vecMyURLs.Get(0)
|
||||
|
||||
address := client.Address().(*net.UDPAddr)
|
||||
address := connection.Address().(*net.UDPAddr)
|
||||
|
||||
localStation.Fields.Set("address", address.IP.String())
|
||||
localStation.Fields.Set("port", strconv.Itoa(address.Port))
|
||||
localStation.SetAddress(address.IP.String())
|
||||
localStation.SetPortNumber(uint16(address.Port))
|
||||
|
||||
localStationURL := localStation.EncodeToString()
|
||||
|
||||
rmcResponseStream.WriteResult(retval)
|
||||
rmcResponseStream.WriteUInt32LE(globals.SecureServer.ConnectionIDCounter().Next())
|
||||
rmcResponseStream.WriteString(localStationURL)
|
||||
} else {
|
||||
rmcResponseStream.WriteResult(retval)
|
||||
rmcResponseStream.WriteUInt32LE(0)
|
||||
rmcResponseStream.WriteString("prudp:/")
|
||||
pidConnectionID = types.NewPrimitiveU32(connection.ID)
|
||||
urlPublic = types.NewString(localStationURL)
|
||||
}
|
||||
|
||||
rmcResponseStream := nex.NewByteStreamOut(globals.SecureEndpoint.LibraryVersions(), globals.SecureEndpoint.ByteStreamSettings())
|
||||
|
||||
retval.WriteTo(rmcResponseStream)
|
||||
pidConnectionID.WriteTo(rmcResponseStream)
|
||||
urlPublic.WriteTo(rmcResponseStream)
|
||||
|
||||
rmcResponseBody := rmcResponseStream.Bytes()
|
||||
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureServer, rmcResponseBody)
|
||||
rmcResponse := nex.NewRMCSuccess(globals.SecureEndpoint, rmcResponseBody)
|
||||
rmcResponse.ProtocolID = secure_connection.ProtocolID
|
||||
rmcResponse.MethodID = secure_connection.MethodRegisterEx
|
||||
rmcResponse.CallID = callID
|
||||
|
||||
return rmcResponse, 0
|
||||
return rmcResponse, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,21 +11,23 @@ import (
|
|||
"github.com/PretendoNetwork/friends/globals"
|
||||
notifications_3ds "github.com/PretendoNetwork/friends/notifications/3ds"
|
||||
notifications_wiiu "github.com/PretendoNetwork/friends/notifications/wiiu"
|
||||
"github.com/PretendoNetwork/friends/types"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_types "github.com/PretendoNetwork/friends/types"
|
||||
nex "github.com/PretendoNetwork/nex-go/v2"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
_ "github.com/PretendoNetwork/nex-protocols-go"
|
||||
)
|
||||
|
||||
func StartSecureServer() {
|
||||
globals.SecureServer = nex.NewPRUDPServer()
|
||||
globals.SecureServer.SecureVirtualServerPorts = []uint8{1}
|
||||
globals.SecureServer.SetFragmentSize(962)
|
||||
globals.SecureServer.SetDefaultLibraryVersion(nex.NewLibraryVersion(1, 1, 0))
|
||||
globals.SecureServer.SetKerberosPassword([]byte(globals.KerberosPassword))
|
||||
globals.SecureServer.SetKerberosKeySize(16)
|
||||
globals.SecureServer.SetAccessKey("ridfebb9")
|
||||
port, _ := strconv.Atoi(os.Getenv("PN_FRIENDS_SECURE_SERVER_PORT"))
|
||||
|
||||
globals.SecureServer.OnData(func(packet nex.PacketInterface) {
|
||||
globals.SecureServer = nex.NewPRUDPServer()
|
||||
globals.SecureEndpoint = nex.NewPRUDPEndPoint(1)
|
||||
|
||||
globals.SecureEndpoint.AccountDetailsByPID = globals.AccountDetailsByPID
|
||||
globals.SecureEndpoint.AccountDetailsByUsername = globals.AccountDetailsByUsername
|
||||
globals.SecureEndpoint.ServerAccount = nex.NewAccount(types.NewPID(2), "Quazal Rendez-Vous", os.Getenv("PN_FRIENDS_CONFIG_SECURE_PASSWORD"))
|
||||
|
||||
globals.SecureEndpoint.OnData(func(packet nex.PacketInterface) {
|
||||
request := packet.RMCMessage()
|
||||
|
||||
fmt.Println("==Friends - Secure==")
|
||||
|
|
@ -34,31 +36,31 @@ func StartSecureServer() {
|
|||
fmt.Println("====================")
|
||||
})
|
||||
|
||||
globals.SecureServer.OnClientRemoved(func(client *nex.PRUDPClient) {
|
||||
pid := client.PID().LegacyValue()
|
||||
globals.SecureEndpoint.OnConnectionEnded(func(connection *nex.PRUDPConnection) {
|
||||
pid := connection.PID().LegacyValue()
|
||||
|
||||
if globals.ConnectedUsers[pid] == nil {
|
||||
return
|
||||
}
|
||||
|
||||
platform := globals.ConnectedUsers[pid].Platform
|
||||
lastOnline := nex.NewDateTime(0)
|
||||
lastOnline := types.NewDateTime(0)
|
||||
lastOnline.FromTimestamp(time.Now())
|
||||
|
||||
if platform == types.WUP {
|
||||
if platform == friends_types.WUP {
|
||||
err := database_wiiu.UpdateUserLastOnlineTime(pid, lastOnline)
|
||||
if err != nil {
|
||||
globals.Logger.Critical(err.Error())
|
||||
}
|
||||
|
||||
notifications_wiiu.SendUserWentOfflineGlobally(client)
|
||||
} else if platform == types.CTR {
|
||||
notifications_wiiu.SendUserWentOfflineGlobally(connection)
|
||||
} else if platform == friends_types.CTR {
|
||||
err := database_3ds.UpdateUserLastOnlineTime(pid, lastOnline)
|
||||
if err != nil {
|
||||
globals.Logger.Critical(err.Error())
|
||||
}
|
||||
|
||||
notifications_3ds.SendUserWentOfflineGlobally(client)
|
||||
notifications_3ds.SendUserWentOfflineGlobally(connection)
|
||||
}
|
||||
|
||||
delete(globals.ConnectedUsers, pid)
|
||||
|
|
@ -68,6 +70,11 @@ func StartSecureServer() {
|
|||
registerCommonSecureServerProtocols()
|
||||
registerSecureServerProtocols()
|
||||
|
||||
port, _ := strconv.Atoi(os.Getenv("PN_FRIENDS_SECURE_SERVER_PORT"))
|
||||
globals.SecureEndpoint.IsSecureEndPoint = true
|
||||
globals.SecureServer.SetFragmentSize(962)
|
||||
globals.SecureServer.LibraryVersions.SetDefault(nex.NewLibraryVersion(1, 1, 0))
|
||||
globals.SecureServer.SessionKeyLength = 16
|
||||
globals.SecureServer.AccessKey = "ridfebb9"
|
||||
globals.SecureServer.BindPRUDPEndPoint(globals.SecureEndpoint)
|
||||
globals.SecureServer.Listen(port)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,55 +5,64 @@ import (
|
|||
|
||||
database_3ds "github.com/PretendoNetwork/friends/database/3ds"
|
||||
"github.com/PretendoNetwork/friends/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nintendo_notifications "github.com/PretendoNetwork/nex-protocols-go/nintendo-notifications"
|
||||
nintendo_notifications_types "github.com/PretendoNetwork/nex-protocols-go/nintendo-notifications/types"
|
||||
nex "github.com/PretendoNetwork/nex-go/v2"
|
||||
"github.com/PretendoNetwork/nex-go/v2/constants"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds/types"
|
||||
nintendo_notifications "github.com/PretendoNetwork/nex-protocols-go/v2/nintendo-notifications"
|
||||
nintendo_notifications_types "github.com/PretendoNetwork/nex-protocols-go/v2/nintendo-notifications/types"
|
||||
)
|
||||
|
||||
func SendCommentUpdate(client *nex.PRUDPClient, comment string) {
|
||||
func SendCommentUpdate(connection *nex.PRUDPConnection, comment string) {
|
||||
notificationEvent := nintendo_notifications_types.NewNintendoNotificationEventGeneral()
|
||||
notificationEvent.StrParam = comment
|
||||
notificationEvent.StrParam = types.NewString(comment)
|
||||
|
||||
eventObject := nintendo_notifications_types.NewNintendoNotificationEvent()
|
||||
eventObject.Type = 3
|
||||
eventObject.SenderPID = client.PID()
|
||||
eventObject.DataHolder = nex.NewDataHolder()
|
||||
eventObject.DataHolder.SetTypeName("NintendoNotificationEventGeneral")
|
||||
eventObject.DataHolder.SetObjectData(notificationEvent)
|
||||
eventObject.Type = types.NewPrimitiveU32(3)
|
||||
eventObject.SenderPID = connection.PID()
|
||||
eventObject.DataHolder = types.NewAnyDataHolder()
|
||||
eventObject.DataHolder.TypeName = types.NewString("NintendoNotificationEventGeneral")
|
||||
eventObject.DataHolder.ObjectData = notificationEvent.Copy()
|
||||
|
||||
stream := nex.NewStreamOut(globals.SecureServer)
|
||||
eventObjectBytes := eventObject.Bytes(stream)
|
||||
stream := nex.NewByteStreamOut(globals.SecureEndpoint.LibraryVersions(), globals.SecureEndpoint.ByteStreamSettings())
|
||||
|
||||
rmcRequest := nex.NewRMCRequest(globals.SecureServer)
|
||||
rmcRequest.ProtocolID = nintendo_notifications.ProtocolID
|
||||
rmcRequest.CallID = 3810693103
|
||||
rmcRequest.MethodID = nintendo_notifications.MethodProcessNintendoNotificationEvent1
|
||||
rmcRequest.Parameters = eventObjectBytes
|
||||
eventObject.WriteTo(stream)
|
||||
|
||||
rmcRequestBytes := rmcRequest.Bytes()
|
||||
notificationRequest := nex.NewRMCRequest(globals.SecureEndpoint)
|
||||
notificationRequest.ProtocolID = nintendo_notifications.ProtocolID
|
||||
notificationRequest.CallID = 3810693103
|
||||
notificationRequest.MethodID = nintendo_notifications.MethodProcessNintendoNotificationEvent1
|
||||
notificationRequest.Parameters = stream.Bytes()
|
||||
|
||||
friendsList, err := database_3ds.GetUserFriends(client.PID().LegacyValue())
|
||||
notificationRequestBytes := notificationRequest.Bytes()
|
||||
|
||||
friendsList, err := database_3ds.GetUserFriends(connection.PID().LegacyValue())
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
globals.Logger.Critical(err.Error())
|
||||
}
|
||||
|
||||
for i := 0; i < len(friendsList); i++ {
|
||||
if friendsList == nil {
|
||||
return
|
||||
}
|
||||
|
||||
connectedUser := globals.ConnectedUsers[friendsList[i].PID.LegacyValue()]
|
||||
friendsList.Each(func(i int, friend *friends_3ds_types.FriendRelationship) bool {
|
||||
connectedUser := globals.ConnectedUsers[friend.PID.LegacyValue()]
|
||||
|
||||
if connectedUser != nil {
|
||||
requestPacket, _ := nex.NewPRUDPPacketV0(connectedUser.Client, nil)
|
||||
requestPacket, _ := nex.NewPRUDPPacketV0(globals.SecureEndpoint.Server, connection, nil)
|
||||
|
||||
requestPacket.SetType(nex.DataPacket)
|
||||
requestPacket.AddFlag(nex.FlagNeedsAck)
|
||||
requestPacket.AddFlag(nex.FlagReliable)
|
||||
requestPacket.SetSourceStreamType(connectedUser.Client.DestinationStreamType)
|
||||
requestPacket.SetSourcePort(connectedUser.Client.DestinationPort)
|
||||
requestPacket.SetDestinationStreamType(connectedUser.Client.SourceStreamType)
|
||||
requestPacket.SetDestinationPort(connectedUser.Client.SourcePort)
|
||||
requestPacket.SetPayload(rmcRequestBytes)
|
||||
requestPacket.SetType(constants.DataPacket)
|
||||
requestPacket.AddFlag(constants.PacketFlagNeedsAck)
|
||||
requestPacket.AddFlag(constants.PacketFlagReliable)
|
||||
requestPacket.SetSourceVirtualPortStreamType(connection.StreamType)
|
||||
requestPacket.SetSourceVirtualPortStreamID(globals.SecureEndpoint.StreamID)
|
||||
requestPacket.SetDestinationVirtualPortStreamType(connection.StreamType)
|
||||
requestPacket.SetDestinationVirtualPortStreamID(connection.StreamID)
|
||||
requestPacket.SetPayload(notificationRequestBytes)
|
||||
|
||||
globals.SecureServer.Send(requestPacket)
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,53 +5,61 @@ import (
|
|||
|
||||
database_3ds "github.com/PretendoNetwork/friends/database/3ds"
|
||||
"github.com/PretendoNetwork/friends/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/friends-3ds/types"
|
||||
nintendo_notifications "github.com/PretendoNetwork/nex-protocols-go/nintendo-notifications"
|
||||
nintendo_notifications_types "github.com/PretendoNetwork/nex-protocols-go/nintendo-notifications/types"
|
||||
nex "github.com/PretendoNetwork/nex-go/v2"
|
||||
"github.com/PretendoNetwork/nex-go/v2/constants"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds/types"
|
||||
nintendo_notifications "github.com/PretendoNetwork/nex-protocols-go/v2/nintendo-notifications"
|
||||
nintendo_notifications_types "github.com/PretendoNetwork/nex-protocols-go/v2/nintendo-notifications/types"
|
||||
)
|
||||
|
||||
func SendFavoriteUpdate(client *nex.PRUDPClient, gameKey *friends_3ds_types.GameKey) {
|
||||
func SendFavoriteUpdate(connection *nex.PRUDPConnection, gameKey *friends_3ds_types.GameKey) {
|
||||
eventObject := nintendo_notifications_types.NewNintendoNotificationEvent()
|
||||
eventObject.Type = 2
|
||||
eventObject.SenderPID = client.PID()
|
||||
eventObject.DataHolder = nex.NewDataHolder()
|
||||
eventObject.DataHolder.SetTypeName("GameKey")
|
||||
eventObject.DataHolder.SetObjectData(gameKey)
|
||||
eventObject.Type = types.NewPrimitiveU32(2)
|
||||
eventObject.SenderPID = connection.PID()
|
||||
eventObject.DataHolder = types.NewAnyDataHolder()
|
||||
eventObject.DataHolder.TypeName = types.NewString("GameKey")
|
||||
eventObject.DataHolder.ObjectData = gameKey.Copy()
|
||||
|
||||
stream := nex.NewStreamOut(globals.SecureServer)
|
||||
eventObjectBytes := eventObject.Bytes(stream)
|
||||
stream := nex.NewByteStreamOut(globals.SecureEndpoint.LibraryVersions(), globals.SecureEndpoint.ByteStreamSettings())
|
||||
|
||||
rmcRequest := nex.NewRMCRequest(globals.SecureServer)
|
||||
rmcRequest.ProtocolID = nintendo_notifications.ProtocolID
|
||||
rmcRequest.CallID = 3810693103
|
||||
rmcRequest.MethodID = nintendo_notifications.MethodProcessNintendoNotificationEvent1
|
||||
rmcRequest.Parameters = eventObjectBytes
|
||||
eventObject.WriteTo(stream)
|
||||
|
||||
rmcRequestBytes := rmcRequest.Bytes()
|
||||
notificationRequest := nex.NewRMCRequest(globals.SecureEndpoint)
|
||||
notificationRequest.ProtocolID = nintendo_notifications.ProtocolID
|
||||
notificationRequest.CallID = 3810693103
|
||||
notificationRequest.MethodID = nintendo_notifications.MethodProcessNintendoNotificationEvent1
|
||||
notificationRequest.Parameters = stream.Bytes()
|
||||
|
||||
friendsList, err := database_3ds.GetUserFriends(client.PID().LegacyValue())
|
||||
notificationRequestBytes := notificationRequest.Bytes()
|
||||
|
||||
friendsList, err := database_3ds.GetUserFriends(connection.PID().LegacyValue())
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
globals.Logger.Critical(err.Error())
|
||||
}
|
||||
|
||||
for i := 0; i < len(friendsList); i++ {
|
||||
if friendsList == nil {
|
||||
return
|
||||
}
|
||||
|
||||
connectedUser := globals.ConnectedUsers[friendsList[i].PID.LegacyValue()]
|
||||
friendsList.Each(func(i int, friend *friends_3ds_types.FriendRelationship) bool {
|
||||
connectedUser := globals.ConnectedUsers[friend.PID.LegacyValue()]
|
||||
|
||||
if connectedUser != nil {
|
||||
requestPacket, _ := nex.NewPRUDPPacketV0(connectedUser.Client, nil)
|
||||
requestPacket, _ := nex.NewPRUDPPacketV0(globals.SecureEndpoint.Server, connection, nil)
|
||||
|
||||
requestPacket.SetType(nex.DataPacket)
|
||||
requestPacket.AddFlag(nex.FlagNeedsAck)
|
||||
requestPacket.AddFlag(nex.FlagReliable)
|
||||
requestPacket.SetSourceStreamType(connectedUser.Client.DestinationStreamType)
|
||||
requestPacket.SetSourcePort(connectedUser.Client.DestinationPort)
|
||||
requestPacket.SetDestinationStreamType(connectedUser.Client.SourceStreamType)
|
||||
requestPacket.SetDestinationPort(connectedUser.Client.SourcePort)
|
||||
requestPacket.SetPayload(rmcRequestBytes)
|
||||
requestPacket.SetType(constants.DataPacket)
|
||||
requestPacket.AddFlag(constants.PacketFlagNeedsAck)
|
||||
requestPacket.AddFlag(constants.PacketFlagReliable)
|
||||
requestPacket.SetSourceVirtualPortStreamType(connection.StreamType)
|
||||
requestPacket.SetSourceVirtualPortStreamID(globals.SecureEndpoint.StreamID)
|
||||
requestPacket.SetDestinationVirtualPortStreamType(connection.StreamType)
|
||||
requestPacket.SetDestinationVirtualPortStreamID(connection.StreamID)
|
||||
requestPacket.SetPayload(notificationRequestBytes)
|
||||
|
||||
globals.SecureServer.Send(requestPacket)
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,45 +2,48 @@ package notifications_3ds
|
|||
|
||||
import (
|
||||
"github.com/PretendoNetwork/friends/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nintendo_notifications "github.com/PretendoNetwork/nex-protocols-go/nintendo-notifications"
|
||||
nintendo_notifications_types "github.com/PretendoNetwork/nex-protocols-go/nintendo-notifications/types"
|
||||
nex "github.com/PretendoNetwork/nex-go/v2"
|
||||
"github.com/PretendoNetwork/nex-go/v2/constants"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
nintendo_notifications "github.com/PretendoNetwork/nex-protocols-go/v2/nintendo-notifications"
|
||||
nintendo_notifications_types "github.com/PretendoNetwork/nex-protocols-go/v2/nintendo-notifications/types"
|
||||
)
|
||||
|
||||
func SendFriendshipCompleted(client *nex.PRUDPClient, friendPID uint32, senderPID *nex.PID) {
|
||||
func SendFriendshipCompleted(connection *nex.PRUDPConnection, friendPID uint32, senderPID *types.PID) {
|
||||
notificationEvent := nintendo_notifications_types.NewNintendoNotificationEventGeneral()
|
||||
notificationEvent.U32Param = 0
|
||||
notificationEvent.U64Param1 = 0
|
||||
notificationEvent.U64Param2 = uint64(friendPID)
|
||||
notificationEvent.U32Param = types.NewPrimitiveU32(0)
|
||||
notificationEvent.U64Param1 = types.NewPrimitiveU64(0)
|
||||
notificationEvent.U64Param2 = types.NewPrimitiveU64(uint64(friendPID))
|
||||
|
||||
eventObject := nintendo_notifications_types.NewNintendoNotificationEvent()
|
||||
eventObject.Type = 7
|
||||
eventObject.SenderPID = senderPID
|
||||
eventObject.DataHolder = nex.NewDataHolder()
|
||||
eventObject.DataHolder.SetTypeName("NintendoNotificationEventGeneral")
|
||||
eventObject.DataHolder.SetObjectData(notificationEvent)
|
||||
eventObject.Type = types.NewPrimitiveU32(7)
|
||||
eventObject.SenderPID = connection.PID()
|
||||
eventObject.DataHolder = types.NewAnyDataHolder()
|
||||
eventObject.DataHolder.TypeName = types.NewString("NintendoNotificationEventGeneral")
|
||||
eventObject.DataHolder.ObjectData = notificationEvent.Copy()
|
||||
|
||||
stream := nex.NewStreamOut(globals.SecureServer)
|
||||
eventObjectBytes := eventObject.Bytes(stream)
|
||||
stream := nex.NewByteStreamOut(globals.SecureEndpoint.LibraryVersions(), globals.SecureEndpoint.ByteStreamSettings())
|
||||
|
||||
rmcRequest := nex.NewRMCRequest(globals.SecureServer)
|
||||
rmcRequest.ProtocolID = nintendo_notifications.ProtocolID
|
||||
rmcRequest.CallID = 3810693103
|
||||
rmcRequest.MethodID = nintendo_notifications.MethodProcessNintendoNotificationEvent1
|
||||
rmcRequest.Parameters = eventObjectBytes
|
||||
eventObject.WriteTo(stream)
|
||||
|
||||
rmcRequestBytes := rmcRequest.Bytes()
|
||||
notificationRequest := nex.NewRMCRequest(globals.SecureEndpoint)
|
||||
notificationRequest.ProtocolID = nintendo_notifications.ProtocolID
|
||||
notificationRequest.CallID = 3810693103
|
||||
notificationRequest.MethodID = nintendo_notifications.MethodProcessNintendoNotificationEvent1
|
||||
notificationRequest.Parameters = stream.Bytes()
|
||||
|
||||
requestPacket, _ := nex.NewPRUDPPacketV0(client, nil)
|
||||
notificationRequestBytes := notificationRequest.Bytes()
|
||||
|
||||
requestPacket.SetType(nex.DataPacket)
|
||||
requestPacket.AddFlag(nex.FlagNeedsAck)
|
||||
requestPacket.AddFlag(nex.FlagReliable)
|
||||
requestPacket.SetSourceStreamType(client.DestinationStreamType)
|
||||
requestPacket.SetSourcePort(client.DestinationPort)
|
||||
requestPacket.SetDestinationStreamType(client.SourceStreamType)
|
||||
requestPacket.SetDestinationPort(client.SourcePort)
|
||||
requestPacket.SetPayload(rmcRequestBytes)
|
||||
requestPacket, _ := nex.NewPRUDPPacketV0(globals.SecureEndpoint.Server, connection, nil)
|
||||
|
||||
requestPacket.SetType(constants.DataPacket)
|
||||
requestPacket.AddFlag(constants.PacketFlagNeedsAck)
|
||||
requestPacket.AddFlag(constants.PacketFlagReliable)
|
||||
requestPacket.SetSourceVirtualPortStreamType(connection.StreamType)
|
||||
requestPacket.SetSourceVirtualPortStreamID(globals.SecureEndpoint.StreamID)
|
||||
requestPacket.SetDestinationVirtualPortStreamType(connection.StreamType)
|
||||
requestPacket.SetDestinationVirtualPortStreamID(connection.StreamID)
|
||||
requestPacket.SetPayload(notificationRequestBytes)
|
||||
|
||||
globals.SecureServer.Send(requestPacket)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,54 +5,63 @@ import (
|
|||
|
||||
database_3ds "github.com/PretendoNetwork/friends/database/3ds"
|
||||
"github.com/PretendoNetwork/friends/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nintendo_notifications "github.com/PretendoNetwork/nex-protocols-go/nintendo-notifications"
|
||||
nintendo_notifications_types "github.com/PretendoNetwork/nex-protocols-go/nintendo-notifications/types"
|
||||
nex "github.com/PretendoNetwork/nex-go/v2"
|
||||
"github.com/PretendoNetwork/nex-go/v2/constants"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds/types"
|
||||
nintendo_notifications "github.com/PretendoNetwork/nex-protocols-go/v2/nintendo-notifications"
|
||||
nintendo_notifications_types "github.com/PretendoNetwork/nex-protocols-go/v2/nintendo-notifications/types"
|
||||
)
|
||||
|
||||
func SendMiiUpdateNotification(client *nex.PRUDPClient) {
|
||||
func SendMiiUpdateNotification(connection *nex.PRUDPConnection) {
|
||||
notificationEvent := nintendo_notifications_types.NewNintendoNotificationEventGeneral()
|
||||
|
||||
eventObject := nintendo_notifications_types.NewNintendoNotificationEvent()
|
||||
eventObject.Type = 5
|
||||
eventObject.SenderPID = client.PID()
|
||||
eventObject.DataHolder = nex.NewDataHolder()
|
||||
eventObject.DataHolder.SetTypeName("NintendoNotificationEventGeneral")
|
||||
eventObject.DataHolder.SetObjectData(notificationEvent)
|
||||
eventObject.Type = types.NewPrimitiveU32(5)
|
||||
eventObject.SenderPID = connection.PID()
|
||||
eventObject.DataHolder = types.NewAnyDataHolder()
|
||||
eventObject.DataHolder.TypeName = types.NewString("NintendoNotificationEventGeneral")
|
||||
eventObject.DataHolder.ObjectData = notificationEvent.Copy()
|
||||
|
||||
stream := nex.NewStreamOut(globals.SecureServer)
|
||||
eventObjectBytes := eventObject.Bytes(stream)
|
||||
stream := nex.NewByteStreamOut(globals.SecureEndpoint.LibraryVersions(), globals.SecureEndpoint.ByteStreamSettings())
|
||||
|
||||
rmcRequest := nex.NewRMCRequest(globals.SecureServer)
|
||||
rmcRequest.ProtocolID = nintendo_notifications.ProtocolID
|
||||
rmcRequest.CallID = 3810693103
|
||||
rmcRequest.MethodID = nintendo_notifications.MethodProcessNintendoNotificationEvent1
|
||||
rmcRequest.Parameters = eventObjectBytes
|
||||
eventObject.WriteTo(stream)
|
||||
|
||||
rmcRequestBytes := rmcRequest.Bytes()
|
||||
notificationRequest := nex.NewRMCRequest(globals.SecureEndpoint)
|
||||
notificationRequest.ProtocolID = nintendo_notifications.ProtocolID
|
||||
notificationRequest.CallID = 3810693103
|
||||
notificationRequest.MethodID = nintendo_notifications.MethodProcessNintendoNotificationEvent1
|
||||
notificationRequest.Parameters = stream.Bytes()
|
||||
|
||||
friendsList, err := database_3ds.GetUserFriends(client.PID().LegacyValue())
|
||||
notificationRequestBytes := notificationRequest.Bytes()
|
||||
|
||||
friendsList, err := database_3ds.GetUserFriends(connection.PID().LegacyValue())
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
globals.Logger.Critical(err.Error())
|
||||
}
|
||||
|
||||
for i := 0; i < len(friendsList); i++ {
|
||||
if friendsList == nil {
|
||||
return
|
||||
}
|
||||
|
||||
connectedUser := globals.ConnectedUsers[friendsList[i].PID.LegacyValue()]
|
||||
friendsList.Each(func(i int, friend *friends_3ds_types.FriendRelationship) bool {
|
||||
connectedUser := globals.ConnectedUsers[friend.PID.LegacyValue()]
|
||||
|
||||
if connectedUser != nil {
|
||||
requestPacket, _ := nex.NewPRUDPPacketV0(connectedUser.Client, nil)
|
||||
requestPacket, _ := nex.NewPRUDPPacketV0(globals.SecureEndpoint.Server, connection, nil)
|
||||
|
||||
requestPacket.SetType(nex.DataPacket)
|
||||
requestPacket.AddFlag(nex.FlagNeedsAck)
|
||||
requestPacket.AddFlag(nex.FlagReliable)
|
||||
requestPacket.SetSourceStreamType(connectedUser.Client.DestinationStreamType)
|
||||
requestPacket.SetSourcePort(connectedUser.Client.DestinationPort)
|
||||
requestPacket.SetDestinationStreamType(connectedUser.Client.SourceStreamType)
|
||||
requestPacket.SetDestinationPort(connectedUser.Client.SourcePort)
|
||||
requestPacket.SetPayload(rmcRequestBytes)
|
||||
requestPacket.SetType(constants.DataPacket)
|
||||
requestPacket.AddFlag(constants.PacketFlagNeedsAck)
|
||||
requestPacket.AddFlag(constants.PacketFlagReliable)
|
||||
requestPacket.SetSourceVirtualPortStreamType(connection.StreamType)
|
||||
requestPacket.SetSourceVirtualPortStreamID(globals.SecureEndpoint.StreamID)
|
||||
requestPacket.SetDestinationVirtualPortStreamType(connection.StreamType)
|
||||
requestPacket.SetDestinationVirtualPortStreamID(connection.StreamID)
|
||||
requestPacket.SetPayload(notificationRequestBytes)
|
||||
|
||||
globals.SecureServer.Send(requestPacket)
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,53 +5,61 @@ import (
|
|||
|
||||
database_3ds "github.com/PretendoNetwork/friends/database/3ds"
|
||||
"github.com/PretendoNetwork/friends/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/friends-3ds/types"
|
||||
nintendo_notifications "github.com/PretendoNetwork/nex-protocols-go/nintendo-notifications"
|
||||
nintendo_notifications_types "github.com/PretendoNetwork/nex-protocols-go/nintendo-notifications/types"
|
||||
nex "github.com/PretendoNetwork/nex-go/v2"
|
||||
"github.com/PretendoNetwork/nex-go/v2/constants"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds/types"
|
||||
nintendo_notifications "github.com/PretendoNetwork/nex-protocols-go/v2/nintendo-notifications"
|
||||
nintendo_notifications_types "github.com/PretendoNetwork/nex-protocols-go/v2/nintendo-notifications/types"
|
||||
)
|
||||
|
||||
func SendPresenceUpdate(client *nex.PRUDPClient, presence *friends_3ds_types.NintendoPresence) {
|
||||
func SendPresenceUpdate(connection *nex.PRUDPConnection, presence *friends_3ds_types.NintendoPresence) {
|
||||
eventObject := nintendo_notifications_types.NewNintendoNotificationEvent()
|
||||
eventObject.Type = 1
|
||||
eventObject.SenderPID = client.PID()
|
||||
eventObject.DataHolder = nex.NewDataHolder()
|
||||
eventObject.DataHolder.SetTypeName("NintendoPresence")
|
||||
eventObject.DataHolder.SetObjectData(presence)
|
||||
eventObject.Type = types.NewPrimitiveU32(1)
|
||||
eventObject.SenderPID = connection.PID()
|
||||
eventObject.DataHolder = types.NewAnyDataHolder()
|
||||
eventObject.DataHolder.TypeName = types.NewString("NintendoPresence")
|
||||
eventObject.DataHolder.ObjectData = presence.Copy()
|
||||
|
||||
stream := nex.NewStreamOut(globals.SecureServer)
|
||||
eventObjectBytes := eventObject.Bytes(stream)
|
||||
stream := nex.NewByteStreamOut(globals.SecureEndpoint.LibraryVersions(), globals.SecureEndpoint.ByteStreamSettings())
|
||||
|
||||
rmcRequest := nex.NewRMCRequest(globals.SecureServer)
|
||||
rmcRequest.ProtocolID = nintendo_notifications.ProtocolID
|
||||
rmcRequest.CallID = 3810693103
|
||||
rmcRequest.MethodID = nintendo_notifications.MethodProcessNintendoNotificationEvent1
|
||||
rmcRequest.Parameters = eventObjectBytes
|
||||
eventObject.WriteTo(stream)
|
||||
|
||||
rmcRequestBytes := rmcRequest.Bytes()
|
||||
notificationRequest := nex.NewRMCRequest(globals.SecureEndpoint)
|
||||
notificationRequest.ProtocolID = nintendo_notifications.ProtocolID
|
||||
notificationRequest.CallID = 3810693103
|
||||
notificationRequest.MethodID = nintendo_notifications.MethodProcessNintendoNotificationEvent1
|
||||
notificationRequest.Parameters = stream.Bytes()
|
||||
|
||||
friendsList, err := database_3ds.GetUserFriends(client.PID().LegacyValue())
|
||||
notificationRequestBytes := notificationRequest.Bytes()
|
||||
|
||||
friendsList, err := database_3ds.GetUserFriends(connection.PID().LegacyValue())
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
globals.Logger.Critical(err.Error())
|
||||
}
|
||||
|
||||
for i := 0; i < len(friendsList); i++ {
|
||||
if friendsList == nil {
|
||||
return
|
||||
}
|
||||
|
||||
connectedUser := globals.ConnectedUsers[friendsList[i].PID.LegacyValue()]
|
||||
friendsList.Each(func(i int, friend *friends_3ds_types.FriendRelationship) bool {
|
||||
connectedUser := globals.ConnectedUsers[friend.PID.LegacyValue()]
|
||||
|
||||
if connectedUser != nil {
|
||||
requestPacket, _ := nex.NewPRUDPPacketV0(connectedUser.Client, nil)
|
||||
requestPacket, _ := nex.NewPRUDPPacketV0(globals.SecureEndpoint.Server, connection, nil)
|
||||
|
||||
requestPacket.SetType(nex.DataPacket)
|
||||
requestPacket.AddFlag(nex.FlagNeedsAck)
|
||||
requestPacket.AddFlag(nex.FlagReliable)
|
||||
requestPacket.SetSourceStreamType(connectedUser.Client.DestinationStreamType)
|
||||
requestPacket.SetSourcePort(connectedUser.Client.DestinationPort)
|
||||
requestPacket.SetDestinationStreamType(connectedUser.Client.SourceStreamType)
|
||||
requestPacket.SetDestinationPort(connectedUser.Client.SourcePort)
|
||||
requestPacket.SetPayload(rmcRequestBytes)
|
||||
requestPacket.SetType(constants.DataPacket)
|
||||
requestPacket.AddFlag(constants.PacketFlagNeedsAck)
|
||||
requestPacket.AddFlag(constants.PacketFlagReliable)
|
||||
requestPacket.SetSourceVirtualPortStreamType(connection.StreamType)
|
||||
requestPacket.SetSourceVirtualPortStreamID(globals.SecureEndpoint.StreamID)
|
||||
requestPacket.SetDestinationVirtualPortStreamType(connection.StreamType)
|
||||
requestPacket.SetDestinationVirtualPortStreamID(connection.StreamID)
|
||||
requestPacket.SetPayload(notificationRequestBytes)
|
||||
|
||||
globals.SecureServer.Send(requestPacket)
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,56 +5,66 @@ import (
|
|||
|
||||
database_3ds "github.com/PretendoNetwork/friends/database/3ds"
|
||||
"github.com/PretendoNetwork/friends/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nintendo_notifications "github.com/PretendoNetwork/nex-protocols-go/nintendo-notifications"
|
||||
nintendo_notifications_types "github.com/PretendoNetwork/nex-protocols-go/nintendo-notifications/types"
|
||||
nex "github.com/PretendoNetwork/nex-go/v2"
|
||||
"github.com/PretendoNetwork/nex-go/v2/constants"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds/types"
|
||||
nintendo_notifications "github.com/PretendoNetwork/nex-protocols-go/v2/nintendo-notifications"
|
||||
nintendo_notifications_types "github.com/PretendoNetwork/nex-protocols-go/v2/nintendo-notifications/types"
|
||||
)
|
||||
|
||||
func SendUserWentOfflineGlobally(client *nex.PRUDPClient) {
|
||||
friendsList, err := database_3ds.GetUserFriends(client.PID().LegacyValue())
|
||||
func SendUserWentOfflineGlobally(connection *nex.PRUDPConnection) {
|
||||
friendsList, err := database_3ds.GetUserFriends(connection.PID().LegacyValue())
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
globals.Logger.Critical(err.Error())
|
||||
}
|
||||
|
||||
for i := 0; i < len(friendsList); i++ {
|
||||
SendUserWentOffline(client, friendsList[i].PID)
|
||||
if friendsList == nil {
|
||||
return
|
||||
}
|
||||
|
||||
friendsList.Each(func(i int, friend *friends_3ds_types.FriendRelationship) bool {
|
||||
SendUserWentOffline(connection, friend.PID)
|
||||
|
||||
return false
|
||||
})
|
||||
}
|
||||
|
||||
func SendUserWentOffline(client *nex.PRUDPClient, pid *nex.PID) {
|
||||
func SendUserWentOffline(connection *nex.PRUDPConnection, pid *types.PID) {
|
||||
notificationEvent := nintendo_notifications_types.NewNintendoNotificationEventGeneral()
|
||||
|
||||
eventObject := nintendo_notifications_types.NewNintendoNotificationEvent()
|
||||
eventObject.Type = 10
|
||||
eventObject.SenderPID = client.PID()
|
||||
eventObject.DataHolder = nex.NewDataHolder()
|
||||
eventObject.DataHolder.SetTypeName("NintendoNotificationEventGeneral")
|
||||
eventObject.DataHolder.SetObjectData(notificationEvent)
|
||||
eventObject.Type = types.NewPrimitiveU32(10)
|
||||
eventObject.SenderPID = connection.PID()
|
||||
eventObject.DataHolder = types.NewAnyDataHolder()
|
||||
eventObject.DataHolder.TypeName = types.NewString("NintendoNotificationEventGeneral")
|
||||
eventObject.DataHolder.ObjectData = notificationEvent.Copy()
|
||||
|
||||
stream := nex.NewStreamOut(globals.SecureServer)
|
||||
eventObjectBytes := eventObject.Bytes(stream)
|
||||
stream := nex.NewByteStreamOut(globals.SecureEndpoint.LibraryVersions(), globals.SecureEndpoint.ByteStreamSettings())
|
||||
|
||||
rmcRequest := nex.NewRMCRequest(globals.SecureServer)
|
||||
rmcRequest.ProtocolID = nintendo_notifications.ProtocolID
|
||||
rmcRequest.CallID = 3810693103
|
||||
rmcRequest.MethodID = nintendo_notifications.MethodProcessNintendoNotificationEvent1
|
||||
rmcRequest.Parameters = eventObjectBytes
|
||||
eventObject.WriteTo(stream)
|
||||
|
||||
rmcRequestBytes := rmcRequest.Bytes()
|
||||
notificationRequest := nex.NewRMCRequest(globals.SecureEndpoint)
|
||||
notificationRequest.ProtocolID = nintendo_notifications.ProtocolID
|
||||
notificationRequest.CallID = 3810693103
|
||||
notificationRequest.MethodID = nintendo_notifications.MethodProcessNintendoNotificationEvent1
|
||||
notificationRequest.Parameters = stream.Bytes()
|
||||
|
||||
notificationRequestBytes := notificationRequest.Bytes()
|
||||
|
||||
connectedUser := globals.ConnectedUsers[pid.LegacyValue()]
|
||||
|
||||
if connectedUser != nil {
|
||||
requestPacket, _ := nex.NewPRUDPPacketV0(connectedUser.Client, nil)
|
||||
requestPacket, _ := nex.NewPRUDPPacketV0(globals.SecureEndpoint.Server, connection, nil)
|
||||
|
||||
requestPacket.SetType(nex.DataPacket)
|
||||
requestPacket.AddFlag(nex.FlagNeedsAck)
|
||||
requestPacket.AddFlag(nex.FlagReliable)
|
||||
requestPacket.SetSourceStreamType(connectedUser.Client.DestinationStreamType)
|
||||
requestPacket.SetSourcePort(connectedUser.Client.DestinationPort)
|
||||
requestPacket.SetDestinationStreamType(connectedUser.Client.SourceStreamType)
|
||||
requestPacket.SetDestinationPort(connectedUser.Client.SourcePort)
|
||||
requestPacket.SetPayload(rmcRequestBytes)
|
||||
requestPacket.SetType(constants.DataPacket)
|
||||
requestPacket.AddFlag(constants.PacketFlagNeedsAck)
|
||||
requestPacket.AddFlag(constants.PacketFlagReliable)
|
||||
requestPacket.SetSourceVirtualPortStreamType(connection.StreamType)
|
||||
requestPacket.SetSourceVirtualPortStreamID(globals.SecureEndpoint.StreamID)
|
||||
requestPacket.SetDestinationVirtualPortStreamType(connection.StreamType)
|
||||
requestPacket.SetDestinationVirtualPortStreamID(connection.StreamID)
|
||||
requestPacket.SetPayload(notificationRequestBytes)
|
||||
|
||||
globals.SecureServer.Send(requestPacket)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,41 +2,44 @@ package notifications_wiiu
|
|||
|
||||
import (
|
||||
"github.com/PretendoNetwork/friends/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
|
||||
nintendo_notifications "github.com/PretendoNetwork/nex-protocols-go/nintendo-notifications"
|
||||
nintendo_notifications_types "github.com/PretendoNetwork/nex-protocols-go/nintendo-notifications/types"
|
||||
nex "github.com/PretendoNetwork/nex-go/v2"
|
||||
"github.com/PretendoNetwork/nex-go/v2/constants"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu/types"
|
||||
nintendo_notifications "github.com/PretendoNetwork/nex-protocols-go/v2/nintendo-notifications"
|
||||
nintendo_notifications_types "github.com/PretendoNetwork/nex-protocols-go/v2/nintendo-notifications/types"
|
||||
)
|
||||
|
||||
func SendFriendRequest(client *nex.PRUDPClient, friendRequestNotificationData *friends_wiiu_types.FriendRequest) {
|
||||
func SendFriendRequest(connection *nex.PRUDPConnection, friendRequestNotificationData *friends_wiiu_types.FriendRequest) {
|
||||
eventObject := nintendo_notifications_types.NewNintendoNotificationEvent()
|
||||
eventObject.Type = 27
|
||||
eventObject.SenderPID = friendRequestNotificationData.PrincipalInfo.PID
|
||||
eventObject.DataHolder = nex.NewDataHolder()
|
||||
eventObject.DataHolder.SetTypeName("FriendRequest")
|
||||
eventObject.DataHolder.SetObjectData(friendRequestNotificationData)
|
||||
eventObject.Type = types.NewPrimitiveU32(27)
|
||||
eventObject.SenderPID = friendRequestNotificationData.PrincipalInfo.PID.Copy().(*types.PID)
|
||||
eventObject.DataHolder = types.NewAnyDataHolder()
|
||||
eventObject.DataHolder.TypeName = types.NewString("FriendRequest")
|
||||
eventObject.DataHolder.ObjectData = friendRequestNotificationData.Copy()
|
||||
|
||||
stream := nex.NewStreamOut(globals.SecureServer)
|
||||
eventObjectBytes := eventObject.Bytes(stream)
|
||||
stream := nex.NewByteStreamOut(globals.SecureEndpoint.LibraryVersions(), globals.SecureEndpoint.ByteStreamSettings())
|
||||
|
||||
rmcRequest := nex.NewRMCRequest(globals.SecureServer)
|
||||
rmcRequest.ProtocolID = nintendo_notifications.ProtocolID
|
||||
rmcRequest.CallID = 3810693103
|
||||
rmcRequest.MethodID = nintendo_notifications.MethodProcessNintendoNotificationEvent2
|
||||
rmcRequest.Parameters = eventObjectBytes
|
||||
eventObject.WriteTo(stream)
|
||||
|
||||
rmcRequestBytes := rmcRequest.Bytes()
|
||||
notificationRequest := nex.NewRMCRequest(globals.SecureEndpoint)
|
||||
notificationRequest.ProtocolID = nintendo_notifications.ProtocolID
|
||||
notificationRequest.CallID = 3810693103
|
||||
notificationRequest.MethodID = nintendo_notifications.MethodProcessNintendoNotificationEvent2
|
||||
notificationRequest.Parameters = stream.Bytes()
|
||||
|
||||
requestPacket, _ := nex.NewPRUDPPacketV0(client, nil)
|
||||
notificationRequestBytes := notificationRequest.Bytes()
|
||||
|
||||
requestPacket.SetType(nex.DataPacket)
|
||||
requestPacket.AddFlag(nex.FlagNeedsAck)
|
||||
requestPacket.AddFlag(nex.FlagReliable)
|
||||
requestPacket.SetSourceStreamType(client.DestinationStreamType)
|
||||
requestPacket.SetSourcePort(client.DestinationPort)
|
||||
requestPacket.SetDestinationStreamType(client.SourceStreamType)
|
||||
requestPacket.SetDestinationPort(client.SourcePort)
|
||||
requestPacket.SetPayload(rmcRequestBytes)
|
||||
requestPacket, _ := nex.NewPRUDPPacketV0(globals.SecureEndpoint.Server, connection, nil)
|
||||
|
||||
requestPacket.SetType(constants.DataPacket)
|
||||
requestPacket.AddFlag(constants.PacketFlagNeedsAck)
|
||||
requestPacket.AddFlag(constants.PacketFlagReliable)
|
||||
requestPacket.SetSourceVirtualPortStreamType(connection.StreamType)
|
||||
requestPacket.SetSourceVirtualPortStreamID(globals.SecureEndpoint.StreamID)
|
||||
requestPacket.SetDestinationVirtualPortStreamType(connection.StreamType)
|
||||
requestPacket.SetDestinationVirtualPortStreamID(connection.StreamID)
|
||||
requestPacket.SetPayload(notificationRequestBytes)
|
||||
|
||||
globals.SecureServer.Send(requestPacket)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,41 +2,44 @@ package notifications_wiiu
|
|||
|
||||
import (
|
||||
"github.com/PretendoNetwork/friends/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
|
||||
nintendo_notifications "github.com/PretendoNetwork/nex-protocols-go/nintendo-notifications"
|
||||
nintendo_notifications_types "github.com/PretendoNetwork/nex-protocols-go/nintendo-notifications/types"
|
||||
nex "github.com/PretendoNetwork/nex-go/v2"
|
||||
"github.com/PretendoNetwork/nex-go/v2/constants"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu/types"
|
||||
nintendo_notifications "github.com/PretendoNetwork/nex-protocols-go/v2/nintendo-notifications"
|
||||
nintendo_notifications_types "github.com/PretendoNetwork/nex-protocols-go/v2/nintendo-notifications/types"
|
||||
)
|
||||
|
||||
func SendFriendRequestAccepted(client *nex.PRUDPClient, friendInfo *friends_wiiu_types.FriendInfo) {
|
||||
func SendFriendRequestAccepted(connection *nex.PRUDPConnection, friendInfo *friends_wiiu_types.FriendInfo) {
|
||||
eventObject := nintendo_notifications_types.NewNintendoNotificationEvent()
|
||||
eventObject.Type = 30
|
||||
eventObject.SenderPID = friendInfo.NNAInfo.PrincipalBasicInfo.PID
|
||||
eventObject.DataHolder = nex.NewDataHolder()
|
||||
eventObject.DataHolder.SetTypeName("FriendInfo")
|
||||
eventObject.DataHolder.SetObjectData(friendInfo)
|
||||
eventObject.Type = types.NewPrimitiveU32(30)
|
||||
eventObject.SenderPID = friendInfo.NNAInfo.PrincipalBasicInfo.PID.Copy().(*types.PID)
|
||||
eventObject.DataHolder = types.NewAnyDataHolder()
|
||||
eventObject.DataHolder.TypeName = types.NewString("FriendInfo")
|
||||
eventObject.DataHolder.ObjectData = friendInfo.Copy()
|
||||
|
||||
stream := nex.NewStreamOut(globals.SecureServer)
|
||||
eventObjectBytes := eventObject.Bytes(stream)
|
||||
stream := nex.NewByteStreamOut(globals.SecureEndpoint.LibraryVersions(), globals.SecureEndpoint.ByteStreamSettings())
|
||||
|
||||
rmcRequest := nex.NewRMCRequest(globals.SecureServer)
|
||||
rmcRequest.ProtocolID = nintendo_notifications.ProtocolID
|
||||
rmcRequest.CallID = 3810693103
|
||||
rmcRequest.MethodID = nintendo_notifications.MethodProcessNintendoNotificationEvent1
|
||||
rmcRequest.Parameters = eventObjectBytes
|
||||
eventObject.WriteTo(stream)
|
||||
|
||||
rmcRequestBytes := rmcRequest.Bytes()
|
||||
notificationRequest := nex.NewRMCRequest(globals.SecureEndpoint)
|
||||
notificationRequest.ProtocolID = nintendo_notifications.ProtocolID
|
||||
notificationRequest.CallID = 3810693103
|
||||
notificationRequest.MethodID = nintendo_notifications.MethodProcessNintendoNotificationEvent1
|
||||
notificationRequest.Parameters = stream.Bytes()
|
||||
|
||||
requestPacket, _ := nex.NewPRUDPPacketV0(client, nil)
|
||||
notificationRequestBytes := notificationRequest.Bytes()
|
||||
|
||||
requestPacket.SetType(nex.DataPacket)
|
||||
requestPacket.AddFlag(nex.FlagNeedsAck)
|
||||
requestPacket.AddFlag(nex.FlagReliable)
|
||||
requestPacket.SetSourceStreamType(client.DestinationStreamType)
|
||||
requestPacket.SetSourcePort(client.DestinationPort)
|
||||
requestPacket.SetDestinationStreamType(client.SourceStreamType)
|
||||
requestPacket.SetDestinationPort(client.SourcePort)
|
||||
requestPacket.SetPayload(rmcRequestBytes)
|
||||
requestPacket, _ := nex.NewPRUDPPacketV0(globals.SecureEndpoint.Server, connection, nil)
|
||||
|
||||
requestPacket.SetType(constants.DataPacket)
|
||||
requestPacket.AddFlag(constants.PacketFlagNeedsAck)
|
||||
requestPacket.AddFlag(constants.PacketFlagReliable)
|
||||
requestPacket.SetSourceVirtualPortStreamType(connection.StreamType)
|
||||
requestPacket.SetSourceVirtualPortStreamID(globals.SecureEndpoint.StreamID)
|
||||
requestPacket.SetDestinationVirtualPortStreamType(connection.StreamType)
|
||||
requestPacket.SetDestinationVirtualPortStreamID(connection.StreamID)
|
||||
requestPacket.SetPayload(notificationRequestBytes)
|
||||
|
||||
globals.SecureServer.Send(requestPacket)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,42 +2,45 @@ package notifications_wiiu
|
|||
|
||||
import (
|
||||
"github.com/PretendoNetwork/friends/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nintendo_notifications "github.com/PretendoNetwork/nex-protocols-go/nintendo-notifications"
|
||||
nintendo_notifications_types "github.com/PretendoNetwork/nex-protocols-go/nintendo-notifications/types"
|
||||
nex "github.com/PretendoNetwork/nex-go/v2"
|
||||
"github.com/PretendoNetwork/nex-go/v2/constants"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
nintendo_notifications "github.com/PretendoNetwork/nex-protocols-go/v2/nintendo-notifications"
|
||||
nintendo_notifications_types "github.com/PretendoNetwork/nex-protocols-go/v2/nintendo-notifications/types"
|
||||
)
|
||||
|
||||
func SendFriendshipRemoved(client *nex.PRUDPClient, senderPID *nex.PID) {
|
||||
func SendFriendshipRemoved(connection *nex.PRUDPConnection, senderPID *types.PID) {
|
||||
nintendoNotificationEventGeneral := nintendo_notifications_types.NewNintendoNotificationEventGeneral()
|
||||
|
||||
eventObject := nintendo_notifications_types.NewNintendoNotificationEvent()
|
||||
eventObject.Type = 26
|
||||
eventObject.SenderPID = senderPID
|
||||
eventObject.DataHolder = nex.NewDataHolder()
|
||||
eventObject.DataHolder.SetTypeName("NintendoNotificationEventGeneral")
|
||||
eventObject.DataHolder.SetObjectData(nintendoNotificationEventGeneral)
|
||||
eventObject.Type = types.NewPrimitiveU32(26)
|
||||
eventObject.SenderPID = senderPID.Copy().(*types.PID)
|
||||
eventObject.DataHolder = types.NewAnyDataHolder()
|
||||
eventObject.DataHolder.TypeName = types.NewString("NintendoNotificationEventGeneral")
|
||||
eventObject.DataHolder.ObjectData = nintendoNotificationEventGeneral.Copy()
|
||||
|
||||
stream := nex.NewStreamOut(globals.SecureServer)
|
||||
stream.WriteStructure(eventObject)
|
||||
stream := nex.NewByteStreamOut(globals.SecureEndpoint.LibraryVersions(), globals.SecureEndpoint.ByteStreamSettings())
|
||||
|
||||
rmcRequest := nex.NewRMCRequest(globals.SecureServer)
|
||||
rmcRequest.ProtocolID = nintendo_notifications.ProtocolID
|
||||
rmcRequest.CallID = 3810693103
|
||||
rmcRequest.MethodID = nintendo_notifications.MethodProcessNintendoNotificationEvent1
|
||||
rmcRequest.Parameters = stream.Bytes()
|
||||
eventObject.WriteTo(stream)
|
||||
|
||||
rmcRequestBytes := rmcRequest.Bytes()
|
||||
notificationRequest := nex.NewRMCRequest(globals.SecureEndpoint)
|
||||
notificationRequest.ProtocolID = nintendo_notifications.ProtocolID
|
||||
notificationRequest.CallID = 3810693103
|
||||
notificationRequest.MethodID = nintendo_notifications.MethodProcessNintendoNotificationEvent1
|
||||
notificationRequest.Parameters = stream.Bytes()
|
||||
|
||||
requestPacket, _ := nex.NewPRUDPPacketV0(client, nil)
|
||||
notificationRequestBytes := notificationRequest.Bytes()
|
||||
|
||||
requestPacket.SetType(nex.DataPacket)
|
||||
requestPacket.AddFlag(nex.FlagNeedsAck)
|
||||
requestPacket.AddFlag(nex.FlagReliable)
|
||||
requestPacket.SetSourceStreamType(client.DestinationStreamType)
|
||||
requestPacket.SetSourcePort(client.DestinationPort)
|
||||
requestPacket.SetDestinationStreamType(client.SourceStreamType)
|
||||
requestPacket.SetDestinationPort(client.SourcePort)
|
||||
requestPacket.SetPayload(rmcRequestBytes)
|
||||
requestPacket, _ := nex.NewPRUDPPacketV0(globals.SecureEndpoint.Server, connection, nil)
|
||||
|
||||
requestPacket.SetType(constants.DataPacket)
|
||||
requestPacket.AddFlag(constants.PacketFlagNeedsAck)
|
||||
requestPacket.AddFlag(constants.PacketFlagReliable)
|
||||
requestPacket.SetSourceVirtualPortStreamType(connection.StreamType)
|
||||
requestPacket.SetSourceVirtualPortStreamID(globals.SecureEndpoint.StreamID)
|
||||
requestPacket.SetDestinationVirtualPortStreamType(connection.StreamType)
|
||||
requestPacket.SetDestinationVirtualPortStreamID(connection.StreamID)
|
||||
requestPacket.SetPayload(notificationRequestBytes)
|
||||
|
||||
globals.SecureServer.Send(requestPacket)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,74 +6,82 @@ import (
|
|||
"github.com/PretendoNetwork/friends/database"
|
||||
database_wiiu "github.com/PretendoNetwork/friends/database/wiiu"
|
||||
"github.com/PretendoNetwork/friends/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
|
||||
nintendo_notifications "github.com/PretendoNetwork/nex-protocols-go/nintendo-notifications"
|
||||
nintendo_notifications_types "github.com/PretendoNetwork/nex-protocols-go/nintendo-notifications/types"
|
||||
nex "github.com/PretendoNetwork/nex-go/v2"
|
||||
"github.com/PretendoNetwork/nex-go/v2/constants"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu/types"
|
||||
nintendo_notifications "github.com/PretendoNetwork/nex-protocols-go/v2/nintendo-notifications"
|
||||
nintendo_notifications_types "github.com/PretendoNetwork/nex-protocols-go/v2/nintendo-notifications/types"
|
||||
)
|
||||
|
||||
func SendPresenceUpdate(presence *friends_wiiu_types.NintendoPresenceV2) {
|
||||
eventObject := nintendo_notifications_types.NewNintendoNotificationEvent()
|
||||
eventObject.Type = 24
|
||||
eventObject.SenderPID = presence.PID
|
||||
eventObject.DataHolder = nex.NewDataHolder()
|
||||
eventObject.DataHolder.SetTypeName("NintendoPresenceV2")
|
||||
eventObject.DataHolder.SetObjectData(presence)
|
||||
eventObject.Type = types.NewPrimitiveU32(24)
|
||||
eventObject.SenderPID = presence.PID.Copy().(*types.PID)
|
||||
eventObject.DataHolder = types.NewAnyDataHolder()
|
||||
eventObject.DataHolder.TypeName = types.NewString("NintendoPresenceV2")
|
||||
eventObject.DataHolder.ObjectData = presence.Copy()
|
||||
|
||||
stream := nex.NewStreamOut(globals.SecureServer)
|
||||
eventObjectBytes := eventObject.Bytes(stream)
|
||||
stream := nex.NewByteStreamOut(globals.SecureEndpoint.LibraryVersions(), globals.SecureEndpoint.ByteStreamSettings())
|
||||
|
||||
rmcRequest := nex.NewRMCRequest(globals.SecureServer)
|
||||
rmcRequest.ProtocolID = nintendo_notifications.ProtocolID
|
||||
rmcRequest.CallID = 3810693103
|
||||
rmcRequest.MethodID = nintendo_notifications.MethodProcessNintendoNotificationEvent2
|
||||
rmcRequest.Parameters = eventObjectBytes
|
||||
eventObject.WriteTo(stream)
|
||||
|
||||
rmcRequestBytes := rmcRequest.Bytes()
|
||||
notificationRequest := nex.NewRMCRequest(globals.SecureEndpoint)
|
||||
notificationRequest.ProtocolID = nintendo_notifications.ProtocolID
|
||||
notificationRequest.CallID = 3810693103
|
||||
notificationRequest.MethodID = nintendo_notifications.MethodProcessNintendoNotificationEvent2
|
||||
notificationRequest.Parameters = stream.Bytes()
|
||||
|
||||
notificationRequestBytes := notificationRequest.Bytes()
|
||||
|
||||
friendList, err := database_wiiu.GetUserFriendList(presence.PID.LegacyValue())
|
||||
if err != nil && err != database.ErrEmptyList {
|
||||
globals.Logger.Critical(err.Error())
|
||||
}
|
||||
|
||||
for i := 0; i < len(friendList); i++ {
|
||||
if friendList[i] == nil || friendList[i].NNAInfo == nil || friendList[i].NNAInfo.PrincipalBasicInfo == nil {
|
||||
// TODO: Fix this
|
||||
// * Lazy
|
||||
friends := friendList.Slice()
|
||||
|
||||
for i := 0; i < len(friends); i++ {
|
||||
friend := friends[i]
|
||||
|
||||
if friend == nil || friend.NNAInfo == nil || friend.NNAInfo.PrincipalBasicInfo == nil {
|
||||
// TODO - Fix this
|
||||
pid := presence.PID
|
||||
var friendPID uint32 = 0
|
||||
|
||||
if friendList[i] != nil && friendList[i].Presence != nil {
|
||||
// TODO: Better track the bad users PID
|
||||
friendPID = friendList[i].Presence.PID.LegacyValue()
|
||||
if friend != nil && friend.Presence != nil {
|
||||
// TODO - Better track the bad users PID
|
||||
friendPID = friend.Presence.PID.LegacyValue()
|
||||
}
|
||||
|
||||
globals.Logger.Error(fmt.Sprintf("User %d has friend %d with bad presence data", pid, friendPID))
|
||||
|
||||
if friendList[i] == nil {
|
||||
if friend == nil {
|
||||
globals.Logger.Error(fmt.Sprintf("%d friendList[i] nil", friendPID))
|
||||
} else if friendList[i].NNAInfo == nil {
|
||||
} else if friend.NNAInfo == nil {
|
||||
globals.Logger.Error(fmt.Sprintf("%d friendList[i].NNAInfo is nil", friendPID))
|
||||
} else if friendList[i].NNAInfo.PrincipalBasicInfo == nil {
|
||||
} else if friend.NNAInfo.PrincipalBasicInfo == nil {
|
||||
globals.Logger.Error(fmt.Sprintf("%d friendList[i].NNAInfo.PrincipalBasicInfo is nil", friendPID))
|
||||
}
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
friendPID := friendList[i].NNAInfo.PrincipalBasicInfo.PID
|
||||
friendPID := friend.NNAInfo.PrincipalBasicInfo.PID
|
||||
connectedUser := globals.ConnectedUsers[friendPID.LegacyValue()]
|
||||
|
||||
if connectedUser != nil {
|
||||
requestPacket, _ := nex.NewPRUDPPacketV0(connectedUser.Client, nil)
|
||||
requestPacket, _ := nex.NewPRUDPPacketV0(globals.SecureEndpoint.Server, connectedUser.Connection, nil)
|
||||
|
||||
requestPacket.SetType(nex.DataPacket)
|
||||
requestPacket.AddFlag(nex.FlagNeedsAck)
|
||||
requestPacket.AddFlag(nex.FlagReliable)
|
||||
requestPacket.SetSourceStreamType(connectedUser.Client.DestinationStreamType)
|
||||
requestPacket.SetSourcePort(connectedUser.Client.DestinationPort)
|
||||
requestPacket.SetDestinationStreamType(connectedUser.Client.SourceStreamType)
|
||||
requestPacket.SetDestinationPort(connectedUser.Client.SourcePort)
|
||||
requestPacket.SetPayload(rmcRequestBytes)
|
||||
requestPacket.SetType(constants.DataPacket)
|
||||
requestPacket.AddFlag(constants.PacketFlagNeedsAck)
|
||||
requestPacket.AddFlag(constants.PacketFlagReliable)
|
||||
requestPacket.SetSourceVirtualPortStreamType(connectedUser.Connection.StreamType)
|
||||
requestPacket.SetSourceVirtualPortStreamID(globals.SecureEndpoint.StreamID)
|
||||
requestPacket.SetDestinationVirtualPortStreamType(connectedUser.Connection.StreamType)
|
||||
requestPacket.SetDestinationVirtualPortStreamID(connectedUser.Connection.StreamID)
|
||||
requestPacket.SetPayload(notificationRequestBytes)
|
||||
|
||||
globals.SecureServer.Send(requestPacket)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,63 +4,72 @@ import (
|
|||
"github.com/PretendoNetwork/friends/database"
|
||||
database_wiiu "github.com/PretendoNetwork/friends/database/wiiu"
|
||||
"github.com/PretendoNetwork/friends/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
nintendo_notifications "github.com/PretendoNetwork/nex-protocols-go/nintendo-notifications"
|
||||
nintendo_notifications_types "github.com/PretendoNetwork/nex-protocols-go/nintendo-notifications/types"
|
||||
nex "github.com/PretendoNetwork/nex-go/v2"
|
||||
"github.com/PretendoNetwork/nex-go/v2/constants"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu/types"
|
||||
nintendo_notifications "github.com/PretendoNetwork/nex-protocols-go/v2/nintendo-notifications"
|
||||
nintendo_notifications_types "github.com/PretendoNetwork/nex-protocols-go/v2/nintendo-notifications/types"
|
||||
)
|
||||
|
||||
func SendUserWentOfflineGlobally(client *nex.PRUDPClient) {
|
||||
friendsList, err := database_wiiu.GetUserFriendList(client.PID().LegacyValue())
|
||||
func SendUserWentOfflineGlobally(connection *nex.PRUDPConnection) {
|
||||
friendsList, err := database_wiiu.GetUserFriendList(connection.PID().LegacyValue())
|
||||
if err != nil && err != database.ErrEmptyList {
|
||||
globals.Logger.Critical(err.Error())
|
||||
}
|
||||
|
||||
for i := 0; i < len(friendsList); i++ {
|
||||
SendUserWentOffline(client, friendsList[i].NNAInfo.PrincipalBasicInfo.PID)
|
||||
if friendsList == nil {
|
||||
return
|
||||
}
|
||||
|
||||
friendsList.Each(func(i int, friend *friends_wiiu_types.FriendInfo) bool {
|
||||
SendUserWentOffline(connection, friend.NNAInfo.PrincipalBasicInfo.PID)
|
||||
return false
|
||||
})
|
||||
}
|
||||
|
||||
func SendUserWentOffline(client *nex.PRUDPClient, pid *nex.PID) {
|
||||
lastOnline := nex.NewDateTime(0).Now()
|
||||
func SendUserWentOffline(connection *nex.PRUDPConnection, pid *types.PID) {
|
||||
lastOnline := types.NewDateTime(0).Now()
|
||||
|
||||
nintendoNotificationEventGeneral := nintendo_notifications_types.NewNintendoNotificationEventGeneral()
|
||||
|
||||
nintendoNotificationEventGeneral.U32Param = 0
|
||||
nintendoNotificationEventGeneral.U64Param1 = 0
|
||||
nintendoNotificationEventGeneral.U64Param2 = lastOnline.Value()
|
||||
nintendoNotificationEventGeneral.StrParam = ""
|
||||
nintendoNotificationEventGeneral.U32Param = types.NewPrimitiveU32(0)
|
||||
nintendoNotificationEventGeneral.U64Param1 = types.NewPrimitiveU64(0)
|
||||
nintendoNotificationEventGeneral.U64Param2 = types.NewPrimitiveU64(lastOnline.Value())
|
||||
nintendoNotificationEventGeneral.StrParam = types.NewString("")
|
||||
|
||||
eventObject := nintendo_notifications_types.NewNintendoNotificationEvent()
|
||||
eventObject.Type = 10
|
||||
eventObject.SenderPID = client.PID()
|
||||
eventObject.DataHolder = nex.NewDataHolder()
|
||||
eventObject.DataHolder.SetTypeName("NintendoNotificationEventGeneral")
|
||||
eventObject.DataHolder.SetObjectData(nintendoNotificationEventGeneral)
|
||||
eventObject.Type = types.NewPrimitiveU32(10)
|
||||
eventObject.SenderPID = connection.PID().Copy().(*types.PID)
|
||||
eventObject.DataHolder = types.NewAnyDataHolder()
|
||||
eventObject.DataHolder.TypeName = types.NewString("NintendoNotificationEventGeneral")
|
||||
eventObject.DataHolder.ObjectData = nintendoNotificationEventGeneral.Copy()
|
||||
|
||||
stream := nex.NewStreamOut(globals.SecureServer)
|
||||
stream.WriteStructure(eventObject)
|
||||
stream := nex.NewByteStreamOut(globals.SecureEndpoint.LibraryVersions(), globals.SecureEndpoint.ByteStreamSettings())
|
||||
|
||||
rmcRequest := nex.NewRMCRequest(globals.SecureServer)
|
||||
rmcRequest.ProtocolID = nintendo_notifications.ProtocolID
|
||||
rmcRequest.CallID = 3810693103
|
||||
rmcRequest.MethodID = nintendo_notifications.MethodProcessNintendoNotificationEvent1
|
||||
rmcRequest.Parameters = stream.Bytes()
|
||||
eventObject.WriteTo(stream)
|
||||
|
||||
rmcRequestBytes := rmcRequest.Bytes()
|
||||
notificationRequest := nex.NewRMCRequest(globals.SecureEndpoint)
|
||||
notificationRequest.ProtocolID = nintendo_notifications.ProtocolID
|
||||
notificationRequest.CallID = 3810693103
|
||||
notificationRequest.MethodID = nintendo_notifications.MethodProcessNintendoNotificationEvent1
|
||||
notificationRequest.Parameters = stream.Bytes()
|
||||
|
||||
notificationRequestBytes := notificationRequest.Bytes()
|
||||
|
||||
connectedUser := globals.ConnectedUsers[pid.LegacyValue()]
|
||||
|
||||
if connectedUser != nil {
|
||||
requestPacket, _ := nex.NewPRUDPPacketV0(connectedUser.Client, nil)
|
||||
requestPacket, _ := nex.NewPRUDPPacketV0(globals.SecureEndpoint.Server, connectedUser.Connection, nil)
|
||||
|
||||
requestPacket.SetType(nex.DataPacket)
|
||||
requestPacket.AddFlag(nex.FlagNeedsAck)
|
||||
requestPacket.AddFlag(nex.FlagReliable)
|
||||
requestPacket.SetSourceStreamType(connectedUser.Client.DestinationStreamType)
|
||||
requestPacket.SetSourcePort(connectedUser.Client.DestinationPort)
|
||||
requestPacket.SetDestinationStreamType(connectedUser.Client.SourceStreamType)
|
||||
requestPacket.SetDestinationPort(connectedUser.Client.SourcePort)
|
||||
requestPacket.SetPayload(rmcRequestBytes)
|
||||
requestPacket.SetType(constants.DataPacket)
|
||||
requestPacket.AddFlag(constants.PacketFlagNeedsAck)
|
||||
requestPacket.AddFlag(constants.PacketFlagReliable)
|
||||
requestPacket.SetSourceVirtualPortStreamType(connectedUser.Connection.StreamType)
|
||||
requestPacket.SetSourceVirtualPortStreamID(globals.SecureEndpoint.StreamID)
|
||||
requestPacket.SetDestinationVirtualPortStreamType(connectedUser.Connection.StreamType)
|
||||
requestPacket.SetDestinationVirtualPortStreamID(connectedUser.Connection.StreamID)
|
||||
requestPacket.SetPayload(notificationRequestBytes)
|
||||
|
||||
globals.SecureServer.Send(requestPacket)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
package types
|
||||
|
||||
import (
|
||||
"github.com/PretendoNetwork/nex-go"
|
||||
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/friends-3ds/types"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
|
||||
"github.com/PretendoNetwork/nex-go/v2"
|
||||
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds/types"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu/types"
|
||||
)
|
||||
|
||||
type ConnectedUser struct {
|
||||
PID uint32
|
||||
Platform Platform
|
||||
Client *nex.PRUDPClient
|
||||
Connection *nex.PRUDPConnection
|
||||
NNAInfo *friends_wiiu_types.NNAInfo
|
||||
Presence *friends_3ds_types.NintendoPresence
|
||||
PresenceV2 *friends_wiiu_types.NintendoPresenceV2
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
package types
|
||||
|
||||
import (
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu/types"
|
||||
)
|
||||
|
||||
// FriendUser represents a user connected to the friends server
|
||||
|
|
@ -14,7 +14,7 @@ type FriendUser struct {
|
|||
FriendRequestsOut []*friends_wiiu_types.FriendRequest
|
||||
FriendRequestsIn []*friends_wiiu_types.FriendRequest
|
||||
BlockedUsers []*friends_wiiu_types.BlacklistedPrincipal
|
||||
LastOnline *nex.DateTime
|
||||
LastOnline *types.DateTime
|
||||
ActiveTitle *friends_wiiu_types.GameKey
|
||||
Notifications []*friends_wiiu_types.PersistentNotification
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ package utility
|
|||
import (
|
||||
"encoding/base64"
|
||||
|
||||
"github.com/PretendoNetwork/nex-go"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
|
||||
"github.com/PretendoNetwork/nex-go/v2/types"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-wiiu/types"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
|
|
@ -25,10 +25,10 @@ func GetUserInfoByPID(pid uint32) (*friends_wiiu_types.PrincipalBasicInfo, error
|
|||
|
||||
info := friends_wiiu_types.NewPrincipalBasicInfo()
|
||||
|
||||
info.PID = nex.NewPID(userData.Pid)
|
||||
info.NNID = userData.Username
|
||||
info.PID = types.NewPID(uint64(userData.Pid))
|
||||
info.NNID = types.NewString(userData.Username)
|
||||
info.Mii = friends_wiiu_types.NewMiiV2()
|
||||
info.Unknown = 2
|
||||
info.Unknown = types.NewPrimitiveU8(2)
|
||||
|
||||
encodedMiiData := userData.Mii.Data
|
||||
decodedMiiData, err := base64.StdEncoding.DecodeString(encodedMiiData)
|
||||
|
|
@ -36,11 +36,11 @@ func GetUserInfoByPID(pid uint32) (*friends_wiiu_types.PrincipalBasicInfo, error
|
|||
return nil, err
|
||||
}
|
||||
|
||||
info.Mii.Name = userData.Mii.Name
|
||||
info.Mii.Unknown1 = 0
|
||||
info.Mii.Unknown2 = 0
|
||||
info.Mii.MiiData = decodedMiiData
|
||||
info.Mii.Datetime = nex.NewDateTime(0)
|
||||
info.Mii.Name = types.NewString(userData.Mii.Name)
|
||||
info.Mii.Unknown1 = types.NewPrimitiveU8(0)
|
||||
info.Mii.Unknown2 = types.NewPrimitiveU8(0)
|
||||
info.Mii.MiiData = types.NewBuffer(decodedMiiData)
|
||||
info.Mii.Datetime = types.NewDateTime(0)
|
||||
|
||||
return info, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user