mirror of
https://github.com/PretendoNetwork/friends.git
synced 2026-10-02 14:58:05 -05:00
Merge pull request #6 from PretendoNetwork/new-style
Merge authentication server to make a singular codebase
This commit is contained in:
7
.dockerignore
Normal file
7
.dockerignore
Normal file
@@ -0,0 +1,7 @@
|
||||
.env
|
||||
.git
|
||||
build
|
||||
log
|
||||
go.work
|
||||
*.test
|
||||
go.work.sum
|
||||
19
Dockerfile
Normal file
19
Dockerfile
Normal file
@@ -0,0 +1,19 @@
|
||||
# --- builder ---
|
||||
FROM golang:1.20.6-alpine3.17 as builder
|
||||
LABEL stage=builder
|
||||
RUN apk add git
|
||||
WORKDIR /build
|
||||
|
||||
COPY go.* ./
|
||||
RUN go mod download
|
||||
|
||||
COPY . ./
|
||||
ARG BUILD_STRING=pretendo.friends.docker
|
||||
RUN go build -ldflags "-X 'main.serverBuildString=${BUILD_STRING}'" -v -o server
|
||||
|
||||
# --- runner ---
|
||||
FROM alpine:3.17 as runner
|
||||
WORKDIR /build
|
||||
|
||||
COPY --from=builder /build/server /build/
|
||||
CMD ["/build/server"]
|
||||
@@ -7,12 +7,12 @@ import (
|
||||
"github.com/PretendoNetwork/friends-secure/database"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
"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"
|
||||
)
|
||||
|
||||
// Get a friend's mii
|
||||
func GetFriendMiis(pids []uint32) []*friends_3ds.FriendMii {
|
||||
friendMiis := make([]*friends_3ds.FriendMii, 0)
|
||||
func GetFriendMiis(pids []uint32) []*friends_3ds_types.FriendMii {
|
||||
friendMiis := make([]*friends_3ds_types.FriendMii, 0)
|
||||
|
||||
rows, err := database.Postgres.Query(`
|
||||
SELECT pid, mii_name, mii_data FROM "3ds".user_data WHERE pid IN ($1)`, database.PIDArrayToString(pids))
|
||||
@@ -30,13 +30,13 @@ func GetFriendMiis(pids []uint32) []*friends_3ds.FriendMii {
|
||||
for rows.Next() {
|
||||
var pid uint32
|
||||
|
||||
mii := friends_3ds.NewMii()
|
||||
mii := friends_3ds_types.NewMii()
|
||||
mii.Unknown2 = false
|
||||
mii.Unknown3 = 0
|
||||
|
||||
rows.Scan(&pid, &mii.Name, &mii.MiiData)
|
||||
|
||||
friendMii := friends_3ds.NewFriendMii()
|
||||
friendMii := friends_3ds_types.NewFriendMii()
|
||||
friendMii.PID = pid
|
||||
friendMii.Mii = mii
|
||||
friendMii.ModifiedAt = changedTime
|
||||
|
||||
@@ -7,12 +7,12 @@ import (
|
||||
"github.com/PretendoNetwork/friends-secure/database"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
"github.com/PretendoNetwork/nex-go"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends/3ds"
|
||||
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/friends-3ds/types"
|
||||
)
|
||||
|
||||
// Get a friend's persistent information
|
||||
func GetFriendPersistentInfos(user1_pid uint32, pids []uint32) []*friends_3ds.FriendPersistentInfo {
|
||||
persistentInfos := make([]*friends_3ds.FriendPersistentInfo, 0)
|
||||
func GetFriendPersistentInfos(user1_pid uint32, pids []uint32) []*friends_3ds_types.FriendPersistentInfo {
|
||||
persistentInfos := make([]*friends_3ds_types.FriendPersistentInfo, 0)
|
||||
|
||||
rows, err := database.Postgres.Query(`
|
||||
SELECT pid, region, area, language, favorite_title, favorite_title_version, comment, comment_changed, last_online FROM "3ds".user_data WHERE pid IN ($1)`, database.PIDArrayToString(pids))
|
||||
@@ -25,9 +25,9 @@ func GetFriendPersistentInfos(user1_pid uint32, pids []uint32) []*friends_3ds.Fr
|
||||
}
|
||||
|
||||
for rows.Next() {
|
||||
persistentInfo := friends_3ds.NewFriendPersistentInfo()
|
||||
persistentInfo := friends_3ds_types.NewFriendPersistentInfo()
|
||||
|
||||
gameKey := friends_3ds.NewGameKey()
|
||||
gameKey := friends_3ds_types.NewGameKey()
|
||||
|
||||
var lastOnlineTime uint64
|
||||
var msgUpdateTime uint64
|
||||
|
||||
@@ -5,12 +5,12 @@ import (
|
||||
|
||||
"github.com/PretendoNetwork/friends-secure/database"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends/3ds"
|
||||
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/friends-3ds/types"
|
||||
)
|
||||
|
||||
// Get all of a user's friend relationships
|
||||
func GetUserFriends(pid uint32) []*friends_3ds.FriendRelationship {
|
||||
friendRelationships := make([]*friends_3ds.FriendRelationship, 0)
|
||||
func GetUserFriends(pid uint32) []*friends_3ds_types.FriendRelationship {
|
||||
friendRelationships := make([]*friends_3ds_types.FriendRelationship, 0)
|
||||
|
||||
rows, err := database.Postgres.Query(`
|
||||
SELECT user2_pid, type FROM "3ds".friendships WHERE user1_pid=$1 AND type=1 LIMIT 100`, pid)
|
||||
@@ -19,7 +19,7 @@ func GetUserFriends(pid uint32) []*friends_3ds.FriendRelationship {
|
||||
}
|
||||
|
||||
for rows.Next() {
|
||||
relationship := friends_3ds.NewFriendRelationship()
|
||||
relationship := friends_3ds_types.NewFriendRelationship()
|
||||
relationship.LFC = 0
|
||||
rows.Scan(&relationship.PID, &relationship.RelationshipType)
|
||||
|
||||
|
||||
@@ -6,12 +6,12 @@ import (
|
||||
"github.com/PretendoNetwork/friends-secure/database"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
"github.com/PretendoNetwork/nex-go"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends/3ds"
|
||||
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/friends-3ds/types"
|
||||
)
|
||||
|
||||
// Save a friend relationship for a user
|
||||
func SaveFriendship(senderPID uint32, recipientPID uint32) *friends_3ds.FriendRelationship {
|
||||
friendRelationship := friends_3ds.NewFriendRelationship()
|
||||
func SaveFriendship(senderPID uint32, recipientPID uint32) *friends_3ds_types.FriendRelationship {
|
||||
friendRelationship := friends_3ds_types.NewFriendRelationship()
|
||||
friendRelationship.PID = recipientPID
|
||||
friendRelationship.LFC = 0
|
||||
friendRelationship.RelationshipType = 0 // Incomplete
|
||||
|
||||
@@ -3,11 +3,11 @@ package database_3ds
|
||||
import (
|
||||
"github.com/PretendoNetwork/friends-secure/database"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends/3ds"
|
||||
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/friends-3ds/types"
|
||||
)
|
||||
|
||||
// Update a user's favorite game
|
||||
func UpdateUserFavoriteGame(pid uint32, gameKey *friends_3ds.GameKey) {
|
||||
func UpdateUserFavoriteGame(pid uint32, gameKey *friends_3ds_types.GameKey) {
|
||||
_, err := database.Postgres.Exec(`
|
||||
INSERT INTO "3ds".user_data (pid, favorite_title, favorite_title_version)
|
||||
VALUES ($1, $2, $3)
|
||||
|
||||
@@ -4,11 +4,11 @@ import (
|
||||
"github.com/PretendoNetwork/friends-secure/database"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
"github.com/PretendoNetwork/nex-go"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends/3ds"
|
||||
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/friends-3ds/types"
|
||||
)
|
||||
|
||||
// Update a user's mii
|
||||
func UpdateUserMii(pid uint32, mii *friends_3ds.Mii) {
|
||||
func UpdateUserMii(pid uint32, mii *friends_3ds_types.Mii) {
|
||||
_, err := database.Postgres.Exec(`
|
||||
INSERT INTO "3ds".user_data (pid, mii_name, mii_data, mii_changed)
|
||||
VALUES ($1, $2, $3, $4)
|
||||
|
||||
@@ -3,11 +3,11 @@ package database_3ds
|
||||
import (
|
||||
"github.com/PretendoNetwork/friends-secure/database"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends/3ds"
|
||||
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/friends-3ds/types"
|
||||
)
|
||||
|
||||
// Update a user's profile
|
||||
func UpdateUserProfile(pid uint32, profileData *friends_3ds.MyProfile) {
|
||||
func UpdateUserProfile(pid uint32, profileData *friends_3ds_types.MyProfile) {
|
||||
_, err := database.Postgres.Exec(`
|
||||
INSERT INTO "3ds".user_data (pid, region, area, language)
|
||||
VALUES ($1, $2, $3, $4)
|
||||
|
||||
@@ -6,11 +6,11 @@ import (
|
||||
"github.com/PretendoNetwork/friends-secure/database"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
"github.com/PretendoNetwork/nex-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
|
||||
"github.com/gocql/gocql"
|
||||
)
|
||||
|
||||
func AcceptFriendRequestAndReturnFriendInfo(friendRequestID uint64) *friends_wiiu.FriendInfo {
|
||||
func AcceptFriendRequestAndReturnFriendInfo(friendRequestID uint64) *friends_wiiu_types.FriendInfo {
|
||||
var senderPID uint32
|
||||
var recipientPID uint32
|
||||
|
||||
@@ -54,7 +54,7 @@ func AcceptFriendRequestAndReturnFriendInfo(friendRequestID uint64) *friends_wii
|
||||
|
||||
SetFriendRequestAccepted(friendRequestID)
|
||||
|
||||
friendInfo := friends_wiiu.NewFriendInfo()
|
||||
friendInfo := friends_wiiu_types.NewFriendInfo()
|
||||
connectedUser := globals.ConnectedUsers[senderPID]
|
||||
var lastOnline *nex.DateTime
|
||||
|
||||
@@ -68,15 +68,15 @@ func AcceptFriendRequestAndReturnFriendInfo(friendRequestID uint64) *friends_wii
|
||||
} else {
|
||||
// Offline
|
||||
|
||||
friendInfo.NNAInfo = friends_wiiu.NewNNAInfo()
|
||||
friendInfo.NNAInfo = friends_wiiu_types.NewNNAInfo()
|
||||
friendInfo.NNAInfo.PrincipalBasicInfo = GetUserInfoByPID(senderPID)
|
||||
friendInfo.NNAInfo.Unknown1 = 0
|
||||
friendInfo.NNAInfo.Unknown2 = 0
|
||||
|
||||
friendInfo.Presence = friends_wiiu.NewNintendoPresenceV2()
|
||||
friendInfo.Presence = friends_wiiu_types.NewNintendoPresenceV2()
|
||||
friendInfo.Presence.ChangedFlags = 0
|
||||
friendInfo.Presence.Online = false
|
||||
friendInfo.Presence.GameKey = friends_wiiu.NewGameKey()
|
||||
friendInfo.Presence.GameKey = friends_wiiu_types.NewGameKey()
|
||||
friendInfo.Presence.GameKey.TitleID = 0
|
||||
friendInfo.Presence.GameKey.TitleVersion = 0
|
||||
friendInfo.Presence.Unknown1 = 0
|
||||
|
||||
@@ -4,12 +4,12 @@ import (
|
||||
"github.com/PretendoNetwork/friends-secure/database"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
"github.com/PretendoNetwork/nex-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
|
||||
)
|
||||
|
||||
// Get a users blacklist
|
||||
func GetUserBlockList(pid uint32) []*friends_wiiu.BlacklistedPrincipal {
|
||||
blockList := make([]*friends_wiiu.BlacklistedPrincipal, 0)
|
||||
func GetUserBlockList(pid uint32) []*friends_wiiu_types.BlacklistedPrincipal {
|
||||
blockList := make([]*friends_wiiu_types.BlacklistedPrincipal, 0)
|
||||
|
||||
rows, err := database.Postgres.Query(`SELECT blocked_pid, title_id, title_version, date FROM wiiu.blocks WHERE blocker_pid=$1`, pid)
|
||||
if err != nil {
|
||||
@@ -24,11 +24,11 @@ func GetUserBlockList(pid uint32) []*friends_wiiu.BlacklistedPrincipal {
|
||||
var date *nex.DateTime
|
||||
rows.Scan(&pid, &titleId, &titleVersion, &date)
|
||||
|
||||
blacklistPrincipal := friends_wiiu.NewBlacklistedPrincipal()
|
||||
blacklistPrincipal := friends_wiiu_types.NewBlacklistedPrincipal()
|
||||
|
||||
blacklistPrincipal.PrincipalBasicInfo = GetUserInfoByPID(pid)
|
||||
|
||||
blacklistPrincipal.GameKey = friends_wiiu.NewGameKey()
|
||||
blacklistPrincipal.GameKey = friends_wiiu_types.NewGameKey()
|
||||
blacklistPrincipal.GameKey.TitleID = titleId
|
||||
blacklistPrincipal.GameKey.TitleVersion = titleVersion
|
||||
blacklistPrincipal.BlackListedSince = date
|
||||
|
||||
@@ -6,12 +6,12 @@ import (
|
||||
"github.com/PretendoNetwork/friends-secure/database"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
"github.com/PretendoNetwork/nex-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
|
||||
)
|
||||
|
||||
// Get a users comment
|
||||
func GetUserComment(pid uint32) *friends_wiiu.Comment {
|
||||
comment := friends_wiiu.NewComment()
|
||||
func GetUserComment(pid uint32) *friends_wiiu_types.Comment {
|
||||
comment := friends_wiiu_types.NewComment()
|
||||
comment.Unknown = 0
|
||||
|
||||
var changed uint64 = 0
|
||||
|
||||
@@ -7,13 +7,13 @@ import (
|
||||
"github.com/PretendoNetwork/friends-secure/database"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
"github.com/PretendoNetwork/nex-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
|
||||
"github.com/gocql/gocql"
|
||||
)
|
||||
|
||||
// Get a users friend list
|
||||
func GetUserFriendList(pid uint32) []*friends_wiiu.FriendInfo {
|
||||
friendList := make([]*friends_wiiu.FriendInfo, 0)
|
||||
func GetUserFriendList(pid uint32) []*friends_wiiu_types.FriendInfo {
|
||||
friendList := make([]*friends_wiiu_types.FriendInfo, 0)
|
||||
|
||||
rows, err := database.Postgres.Query(`SELECT user2_pid, date FROM wiiu.friendships WHERE user1_pid=$1 AND active=true LIMIT 100`, pid)
|
||||
if err != nil {
|
||||
@@ -26,7 +26,7 @@ func GetUserFriendList(pid uint32) []*friends_wiiu.FriendInfo {
|
||||
var date uint64
|
||||
rows.Scan(&friendPID, &date)
|
||||
|
||||
friendInfo := friends_wiiu.NewFriendInfo()
|
||||
friendInfo := friends_wiiu_types.NewFriendInfo()
|
||||
connectedUser := globals.ConnectedUsers[friendPID]
|
||||
var lastOnline *nex.DateTime
|
||||
|
||||
@@ -52,15 +52,15 @@ func GetUserFriendList(pid uint32) []*friends_wiiu.FriendInfo {
|
||||
} else {
|
||||
// Offline
|
||||
|
||||
friendInfo.NNAInfo = friends_wiiu.NewNNAInfo()
|
||||
friendInfo.NNAInfo = friends_wiiu_types.NewNNAInfo()
|
||||
friendInfo.NNAInfo.PrincipalBasicInfo = GetUserInfoByPID(friendPID)
|
||||
friendInfo.NNAInfo.Unknown1 = 0
|
||||
friendInfo.NNAInfo.Unknown2 = 0
|
||||
|
||||
friendInfo.Presence = friends_wiiu.NewNintendoPresenceV2()
|
||||
friendInfo.Presence = friends_wiiu_types.NewNintendoPresenceV2()
|
||||
friendInfo.Presence.ChangedFlags = 0
|
||||
friendInfo.Presence.Online = false
|
||||
friendInfo.Presence.GameKey = friends_wiiu.NewGameKey()
|
||||
friendInfo.Presence.GameKey = friends_wiiu_types.NewGameKey()
|
||||
friendInfo.Presence.GameKey.TitleID = 0
|
||||
friendInfo.Presence.GameKey.TitleVersion = 0
|
||||
friendInfo.Presence.Unknown1 = 0
|
||||
|
||||
@@ -6,12 +6,12 @@ import (
|
||||
"github.com/PretendoNetwork/friends-secure/database"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
"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"
|
||||
)
|
||||
|
||||
// Get a users received friend requests
|
||||
func GetUserFriendRequestsIn(pid uint32) []*friends_wiiu.FriendRequest {
|
||||
friendRequestsIn := make([]*friends_wiiu.FriendRequest, 0)
|
||||
func GetUserFriendRequestsIn(pid uint32) []*friends_wiiu_types.FriendRequest {
|
||||
friendRequestsIn := make([]*friends_wiiu_types.FriendRequest, 0)
|
||||
|
||||
rows, err := database.Postgres.Query(`SELECT id, sender_pid, sent_on, expires_on, message, received FROM wiiu.friend_requests WHERE recipient_pid=$1 AND accepted=false AND denied=false`, pid)
|
||||
if err != nil {
|
||||
@@ -28,18 +28,18 @@ func GetUserFriendRequestsIn(pid uint32) []*friends_wiiu.FriendRequest {
|
||||
var received bool
|
||||
rows.Scan(&id, &senderPID, &sentOn, &expiresOn, &message, &received)
|
||||
|
||||
friendRequest := friends_wiiu.NewFriendRequest()
|
||||
friendRequest := friends_wiiu_types.NewFriendRequest()
|
||||
|
||||
friendRequest.PrincipalInfo = GetUserInfoByPID(senderPID)
|
||||
|
||||
friendRequest.Message = friends_wiiu.NewFriendRequestMessage()
|
||||
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.GameKey = friends_wiiu.NewGameKey()
|
||||
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
|
||||
|
||||
@@ -4,12 +4,12 @@ import (
|
||||
"github.com/PretendoNetwork/friends-secure/database"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
"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"
|
||||
)
|
||||
|
||||
// Get a users sent friend requests
|
||||
func GetUserFriendRequestsOut(pid uint32) []*friends_wiiu.FriendRequest {
|
||||
friendRequestsOut := make([]*friends_wiiu.FriendRequest, 0)
|
||||
func GetUserFriendRequestsOut(pid uint32) []*friends_wiiu_types.FriendRequest {
|
||||
friendRequestsOut := make([]*friends_wiiu_types.FriendRequest, 0)
|
||||
|
||||
rows, err := database.Postgres.Query(`SELECT id, recipient_pid, sent_on, expires_on, message, received FROM wiiu.friend_requests WHERE sender_pid=$1 AND accepted=false`, pid)
|
||||
if err != nil {
|
||||
@@ -26,18 +26,18 @@ func GetUserFriendRequestsOut(pid uint32) []*friends_wiiu.FriendRequest {
|
||||
var received bool
|
||||
rows.Scan(&id, &recipientPID, &sentOn, &expiresOn, &message, &received)
|
||||
|
||||
friendRequest := friends_wiiu.NewFriendRequest()
|
||||
friendRequest := friends_wiiu_types.NewFriendRequest()
|
||||
|
||||
friendRequest.PrincipalInfo = GetUserInfoByPID(recipientPID)
|
||||
|
||||
friendRequest.Message = friends_wiiu.NewFriendRequestMessage()
|
||||
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.GameKey = friends_wiiu.NewGameKey()
|
||||
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
|
||||
|
||||
@@ -7,13 +7,13 @@ import (
|
||||
"github.com/PretendoNetwork/friends-secure/database"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
"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"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
)
|
||||
|
||||
func GetUserInfoByPID(pid uint32) *friends_wiiu.PrincipalBasicInfo {
|
||||
func GetUserInfoByPID(pid uint32) *friends_wiiu_types.PrincipalBasicInfo {
|
||||
var result bson.M
|
||||
|
||||
err := database.MongoCollection.FindOne(context.TODO(), bson.D{{Key: "pid", Value: pid}}, options.FindOne()).Decode(&result)
|
||||
@@ -26,10 +26,10 @@ func GetUserInfoByPID(pid uint32) *friends_wiiu.PrincipalBasicInfo {
|
||||
globals.Logger.Critical(err.Error())
|
||||
}
|
||||
|
||||
info := friends_wiiu.NewPrincipalBasicInfo()
|
||||
info := friends_wiiu_types.NewPrincipalBasicInfo()
|
||||
info.PID = pid
|
||||
info.NNID = result["username"].(string)
|
||||
info.Mii = friends_wiiu.NewMiiV2()
|
||||
info.Mii = friends_wiiu_types.NewMiiV2()
|
||||
info.Unknown = 2
|
||||
|
||||
encodedMiiData := result["mii"].(bson.M)["data"].(string)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package database_wiiu
|
||||
|
||||
import friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
import friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
|
||||
|
||||
// Get notifications for a user
|
||||
func GetUserNotifications(pid uint32) []*friends_wiiu.PersistentNotification {
|
||||
return make([]*friends_wiiu.PersistentNotification, 0)
|
||||
func GetUserNotifications(pid uint32) []*friends_wiiu_types.PersistentNotification {
|
||||
return make([]*friends_wiiu_types.PersistentNotification, 0)
|
||||
}
|
||||
|
||||
@@ -5,11 +5,11 @@ import (
|
||||
|
||||
"github.com/PretendoNetwork/friends-secure/database"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
|
||||
)
|
||||
|
||||
func GetUserPrincipalPreference(pid uint32) *friends_wiiu.PrincipalPreference {
|
||||
preference := friends_wiiu.NewPrincipalPreference()
|
||||
func GetUserPrincipalPreference(pid uint32) *friends_wiiu_types.PrincipalPreference {
|
||||
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)
|
||||
if err != nil {
|
||||
|
||||
@@ -3,10 +3,10 @@ package database_wiiu
|
||||
import (
|
||||
"github.com/PretendoNetwork/friends-secure/database"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
|
||||
)
|
||||
|
||||
func UpdateUserPrincipalPreference(pid uint32, principalPreference *friends_wiiu.PrincipalPreference) {
|
||||
func UpdateUserPrincipalPreference(pid uint32, principalPreference *friends_wiiu_types.PrincipalPreference) {
|
||||
_, err := database.Postgres.Exec(`
|
||||
INSERT INTO wiiu.user_data (pid, show_online, show_current_game, block_friend_requests)
|
||||
VALUES ($1, $2, $3, $4)
|
||||
|
||||
@@ -2,11 +2,19 @@ package globals
|
||||
|
||||
import (
|
||||
"github.com/PretendoNetwork/friends-secure/types"
|
||||
pb "github.com/PretendoNetwork/grpc-go/account"
|
||||
"github.com/PretendoNetwork/nex-go"
|
||||
"github.com/PretendoNetwork/plogger-go"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/metadata"
|
||||
)
|
||||
|
||||
var Logger = plogger.NewLogger()
|
||||
var NEXServer *nex.Server
|
||||
var KerberosPassword = "password" // * Default password
|
||||
var AuthenticationServer *nex.Server
|
||||
var SecureServer *nex.Server
|
||||
var ConnectedUsers map[uint32]*types.ConnectedUser
|
||||
var AESKey []byte
|
||||
var GRPCAccountClientConnection *grpc.ClientConn
|
||||
var GRPCAccountClient pb.AccountClient
|
||||
var GRPCAccountCommonMetadata metadata.MD
|
||||
|
||||
22
globals/password_from_pid.go
Normal file
22
globals/password_from_pid.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package globals
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
pb "github.com/PretendoNetwork/grpc-go/account"
|
||||
"github.com/PretendoNetwork/nex-go"
|
||||
"github.com/PretendoNetwork/nex-protocols-go/globals"
|
||||
"google.golang.org/grpc/metadata"
|
||||
)
|
||||
|
||||
func PasswordFromPID(pid uint32) (string, uint32) {
|
||||
ctx := metadata.NewOutgoingContext(context.Background(), GRPCAccountCommonMetadata)
|
||||
|
||||
response, err := GRPCAccountClient.GetNEXData(ctx, &pb.GetNEXDataRequest{Pid: pid})
|
||||
if err != nil {
|
||||
globals.Logger.Error(err.Error())
|
||||
return "", nex.Errors.RendezVous.InvalidUsername
|
||||
}
|
||||
|
||||
return response.Password, 0
|
||||
}
|
||||
35
go.mod
35
go.mod
@@ -3,25 +3,26 @@ module github.com/PretendoNetwork/friends-secure
|
||||
go 1.18
|
||||
|
||||
require (
|
||||
github.com/PretendoNetwork/grpc-go v0.0.0-20230418154649-25a94d02f01f
|
||||
github.com/PretendoNetwork/nex-go v1.0.26
|
||||
github.com/PretendoNetwork/nex-protocols-go v1.0.31
|
||||
github.com/PretendoNetwork/plogger-go v1.0.2
|
||||
github.com/PretendoNetwork/grpc-go v1.0.2
|
||||
github.com/PretendoNetwork/nex-go v1.0.29
|
||||
github.com/PretendoNetwork/nex-protocols-common-go v1.0.23
|
||||
github.com/PretendoNetwork/nex-protocols-go v1.0.41
|
||||
github.com/PretendoNetwork/plogger-go v1.0.3
|
||||
github.com/gocql/gocql v1.5.2
|
||||
github.com/golang/protobuf v1.5.3
|
||||
github.com/joho/godotenv v1.5.1
|
||||
github.com/lib/pq v1.10.9
|
||||
go.mongodb.org/mongo-driver v1.11.7
|
||||
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1
|
||||
google.golang.org/grpc v1.55.0
|
||||
go.mongodb.org/mongo-driver v1.12.0
|
||||
golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1
|
||||
google.golang.org/grpc v1.56.2
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/fatih/color v1.15.0 // indirect
|
||||
github.com/golang/snappy v0.0.4 // indirect
|
||||
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed // indirect
|
||||
github.com/jwalton/go-supportscolor v1.1.0 // indirect
|
||||
github.com/klauspost/compress v1.16.5 // indirect
|
||||
github.com/jwalton/go-supportscolor v1.2.0 // indirect
|
||||
github.com/klauspost/compress v1.16.7 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.19 // indirect
|
||||
github.com/montanaflynn/stats v0.7.1 // indirect
|
||||
@@ -32,13 +33,13 @@ require (
|
||||
github.com/xdg-go/scram v1.1.2 // indirect
|
||||
github.com/xdg-go/stringprep v1.0.4 // indirect
|
||||
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a // indirect
|
||||
golang.org/x/crypto v0.9.0 // indirect
|
||||
golang.org/x/net v0.10.0 // indirect
|
||||
golang.org/x/sync v0.2.0 // indirect
|
||||
golang.org/x/sys v0.9.0 // indirect
|
||||
golang.org/x/term v0.9.0 // indirect
|
||||
golang.org/x/text v0.10.0 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc // indirect
|
||||
google.golang.org/protobuf v1.30.0 // indirect
|
||||
golang.org/x/crypto v0.11.0 // indirect
|
||||
golang.org/x/net v0.12.0 // indirect
|
||||
golang.org/x/sync v0.3.0 // indirect
|
||||
golang.org/x/sys v0.10.0 // indirect
|
||||
golang.org/x/term v0.10.0 // indirect
|
||||
golang.org/x/text v0.11.0 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 // indirect
|
||||
google.golang.org/protobuf v1.31.0 // indirect
|
||||
gopkg.in/inf.v0 v0.9.1 // indirect
|
||||
)
|
||||
|
||||
54
go.sum
54
go.sum
@@ -1,11 +1,19 @@
|
||||
github.com/PretendoNetwork/grpc-go v0.0.0-20230418154649-25a94d02f01f h1:RfnZOFUIiw9rpxPo4RDkPXx7DdM8rxix3xfpbV/A2e8=
|
||||
github.com/PretendoNetwork/grpc-go v0.0.0-20230418154649-25a94d02f01f/go.mod h1:XZjEsij9lL7HJBNkH6JPbBIkUSq/1rjflvjGdv+DAj0=
|
||||
github.com/PretendoNetwork/nex-go v1.0.26 h1:lJqDS5F8s836xcQzCEI5hNvUesmTsh2NGDC4tZvG250=
|
||||
github.com/PretendoNetwork/nex-go v1.0.26/go.mod h1:qzc5s4iNrt1ubS9Axb38b2jPuEsiETN2mDijn+MthmI=
|
||||
github.com/PretendoNetwork/nex-protocols-go v1.0.31 h1:HnnfyXKO8HJRplL29VSmlGftBmITV91tnF1jVqjFw5Y=
|
||||
github.com/PretendoNetwork/nex-protocols-go v1.0.31/go.mod h1:Pw1u2rsZGXuv45iM9y/7nZ5TBr1L5hctv9ylNXlW1ws=
|
||||
github.com/PretendoNetwork/plogger-go v1.0.2 h1:vWKEnEmJJzYwqLxLyiSsAvCrZV6qnnu/a0GQOjIfzY0=
|
||||
github.com/PretendoNetwork/plogger-go v1.0.2/go.mod h1:7kD6M4vPq1JL4LTuPg6kuB1OvUBOwQOtAvTaUwMbwvU=
|
||||
github.com/PretendoNetwork/grpc-go v1.0.2 h1:9TvKmX7dCOANyoHEra1MMYqS1N/RGav66TRG4SHInvo=
|
||||
github.com/PretendoNetwork/grpc-go v1.0.2/go.mod h1:XZjEsij9lL7HJBNkH6JPbBIkUSq/1rjflvjGdv+DAj0=
|
||||
github.com/PretendoNetwork/nex-go v1.0.28 h1:g3892srP1T7LaeY5JklMtLZ03gTxE8wpXqpPQpXpN74=
|
||||
github.com/PretendoNetwork/nex-go v1.0.28/go.mod h1:tWfWhrC/DCJuS08jTk0ceOv2R1VtElvKSVv13To6miE=
|
||||
github.com/PretendoNetwork/nex-go v1.0.29 h1:Mu/UGpYEt0YHgJR/l+8Ysc5rlX91NE86ab3sMSKpPWo=
|
||||
github.com/PretendoNetwork/nex-go v1.0.29/go.mod h1:tWfWhrC/DCJuS08jTk0ceOv2R1VtElvKSVv13To6miE=
|
||||
github.com/PretendoNetwork/nex-protocols-common-go v1.0.23 h1:5nhsCg0NtJ+Wlq4eAxLkpazsBDWOnSHLgpllW3XUeE0=
|
||||
github.com/PretendoNetwork/nex-protocols-common-go v1.0.23/go.mod h1:WqdDoCdjAHg4cdnIGJCrBQUX/JQIJHbw0D5oQWZ8mfk=
|
||||
github.com/PretendoNetwork/nex-protocols-go v1.0.39 h1:l0wezyS1s8WELcuiZBV726C/cYE0GHHnnks2GLP+33Q=
|
||||
github.com/PretendoNetwork/nex-protocols-go v1.0.39/go.mod h1:jZSnoM2G4oc7tKXeUf2OkJ6VyfJc4nb7gR++2oNEh5A=
|
||||
github.com/PretendoNetwork/nex-protocols-go v1.0.41 h1:f4AJxoIgKt5k22IcYF/SM5MazR0/34hmyflZkFt/Hug=
|
||||
github.com/PretendoNetwork/nex-protocols-go v1.0.41/go.mod h1:DPRCNkz45onV4ySCRJNp2+69NQnRa+SRqeErsnjW6P4=
|
||||
github.com/PretendoNetwork/plogger-go v1.0.3 h1:KEnrUfPaCn0LFweg8OrhtiDhlN3pclWpNhlmAtmgfB0=
|
||||
github.com/PretendoNetwork/plogger-go v1.0.3/go.mod h1:7kD6M4vPq1JL4LTuPg6kuB1OvUBOwQOtAvTaUwMbwvU=
|
||||
github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932 h1:mXoPYz/Ul5HYEDvkta6I8/rnYM5gSdSV2tJ6XbZuEtY=
|
||||
github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932/go.mod h1:NOuUCSz6Q9T7+igc/hlvDOUdtWKryOrtFyIVABv/p7k=
|
||||
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 h1:DDGfHa7BWjL4YnC6+E63dPcxHo2sUxDIu8g3QgEJdRY=
|
||||
@@ -31,11 +39,13 @@ github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed h1:5upAirOpQc
|
||||
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed/go.mod h1:tMWxXQ9wFIaZeTI9F+hmhFiGpFmhOHzyShyFUhRm0H4=
|
||||
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
|
||||
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
||||
github.com/jwalton/go-supportscolor v1.1.0 h1:HsXFJdMPjRUAx8cIW6g30hVSFYaxh9yRQwEWgkAR7lQ=
|
||||
github.com/jwalton/go-supportscolor v1.1.0/go.mod h1:hFVUAZV2cWg+WFFC4v8pT2X/S2qUUBYMioBD9AINXGs=
|
||||
github.com/jwalton/go-supportscolor v1.2.0 h1:g6Ha4u7Vm3LIsQ5wmeBpS4gazu0UP1DRDE8y6bre4H8=
|
||||
github.com/jwalton/go-supportscolor v1.2.0/go.mod h1:hFVUAZV2cWg+WFFC4v8pT2X/S2qUUBYMioBD9AINXGs=
|
||||
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
|
||||
github.com/klauspost/compress v1.16.5 h1:IFV2oUNUzZaz+XyusxpLzpzS8Pt5rh0Z16For/djlyI=
|
||||
github.com/klauspost/compress v1.16.5/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
|
||||
github.com/klauspost/compress v1.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGCFR9I=
|
||||
github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
|
||||
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
@@ -78,14 +88,20 @@ github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a/go.mod h1:ul22v+Nro/
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
go.mongodb.org/mongo-driver v1.11.7 h1:LIwYxASDLGUg/8wOhgOOZhX8tQa/9tgZPgzZoVqJvcs=
|
||||
go.mongodb.org/mongo-driver v1.11.7/go.mod h1:G9TgswdsWjX4tmDA5zfs2+6AEPpYJwqblyjsfuh8oXY=
|
||||
go.mongodb.org/mongo-driver v1.12.0 h1:aPx33jmn/rQuJXPQLZQ8NtfPQG8CaqgLThFtqRb0PiE=
|
||||
go.mongodb.org/mongo-driver v1.12.0/go.mod h1:AZkxhPnFJUoH7kZlFkVKucV20K387miPfm7oimrSmK0=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/crypto v0.9.0 h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g=
|
||||
golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0=
|
||||
golang.org/x/crypto v0.11.0 h1:6Ewdq3tDic1mg5xRO4milcWCfMVQhI4NkqWWvqejpuA=
|
||||
golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio=
|
||||
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 h1:k/i9J1pBpvlfR+9QsetwPyERsqu1GIbi967PQMq3Ivc=
|
||||
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w=
|
||||
golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1 h1:MGwJjxBy0HJshjDNfLsYO8xppfqWlA5ZT9OhtUUhTNw=
|
||||
golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
@@ -94,11 +110,15 @@ golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qx
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M=
|
||||
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
|
||||
golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50=
|
||||
golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI=
|
||||
golang.org/x/sync v0.2.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
|
||||
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
@@ -109,20 +129,23 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s=
|
||||
golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA=
|
||||
golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.9.0 h1:GRRCnKYhdQrD8kfRAdQ6Zcw1P0OcELxGLKJvtjVMZ28=
|
||||
golang.org/x/term v0.9.0/go.mod h1:M6DEAAIenWoTxdKrOltXcmDY3rSplQUkrvaDU5FcQyo=
|
||||
golang.org/x/term v0.10.0 h1:3R7pNqamzBraeqj/Tj8qt1aQ2HpmlC+Cx/qL/7hn4/c=
|
||||
golang.org/x/term v0.10.0/go.mod h1:lpqdcUyK/oCiQxvxVrppt5ggO2KCZ5QblwqPnfZ6d5o=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
|
||||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.10.0 h1:UpjohKhiEgNc0CSauXmwYftY1+LlaC75SJwh0SgCX58=
|
||||
golang.org/x/text v0.10.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||
golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4=
|
||||
golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
@@ -130,16 +153,23 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc h1:XSJ8Vk1SWuNr8S18z1NZSziL0CPIXLCCMDOEFtHBOFc=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc/go.mod h1:66JfowdXAEgad5O9NnYcsNPLCPZJD++2L9X0PCMODrA=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 h1:bVf09lpb+OJbByTj913DRJioFFAjf/ZGxEz7MajTp2U=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98/go.mod h1:TUfxEVdsvPg18p6AslUXFoLdpED4oBnGwyqk3dV1XzM=
|
||||
google.golang.org/grpc v1.55.0 h1:3Oj82/tFSCeUrRTg/5E/7d/W5A1tj6Ky1ABAuZuv5ag=
|
||||
google.golang.org/grpc v1.55.0/go.mod h1:iYEXKGkEBhg1PjZQvoYEVPTDkHo1/bjTnfwTeGONTY8=
|
||||
google.golang.org/grpc v1.56.2 h1:fVRFRnXvU+x6C4IlHZewvJOVHoOv1TUuQyoRsYnB4bI=
|
||||
google.golang.org/grpc v1.56.2/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s=
|
||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng=
|
||||
google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
|
||||
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=
|
||||
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package grpc
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net"
|
||||
"os"
|
||||
|
||||
pb "github.com/PretendoNetwork/grpc-go/friends"
|
||||
"google.golang.org/grpc"
|
||||
@@ -13,7 +15,7 @@ type gRPCFriendsServer struct {
|
||||
}
|
||||
|
||||
func StartGRPCServer() {
|
||||
listener, err := net.Listen("tcp", ":50051")
|
||||
listener, err := net.Listen("tcp", fmt.Sprintf(":%s", os.Getenv("PN_FRIENDS_GRPC_SERVER_PORT")))
|
||||
if err != nil {
|
||||
log.Fatalf("failed to listen: %v", err)
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ func (s *gRPCFriendsServer) SendUserNotificationWiiU(ctx context.Context, in *pb
|
||||
requestPacket.AddFlag(nex.FlagNeedsAck)
|
||||
requestPacket.AddFlag(nex.FlagReliable)
|
||||
|
||||
globals.NEXServer.Send(requestPacket)
|
||||
globals.SecureServer.Send(requestPacket)
|
||||
}
|
||||
|
||||
return &empty.Empty{}, nil
|
||||
|
||||
20
init.go
20
init.go
@@ -2,12 +2,17 @@ package main
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/PretendoNetwork/friends-secure/database"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
"github.com/PretendoNetwork/friends-secure/types"
|
||||
pb "github.com/PretendoNetwork/grpc-go/account"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
"google.golang.org/grpc/metadata"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
)
|
||||
@@ -19,7 +24,7 @@ func init() {
|
||||
|
||||
err = godotenv.Load()
|
||||
if err != nil {
|
||||
log.Fatal("Error loading .env file")
|
||||
globals.Logger.Warningf("Error loading .env file: %s", err.Error())
|
||||
}
|
||||
|
||||
globals.AESKey, err = hex.DecodeString(os.Getenv("PN_FRIENDS_CONFIG_AES_KEY"))
|
||||
@@ -27,5 +32,18 @@ func init() {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
globals.GRPCAccountClientConnection, err = grpc.Dial(fmt.Sprintf("%s:%s", os.Getenv("PN_FRIENDS_ACCOUNT_GRPC_HOST"), os.Getenv("PN_FRIENDS_ACCOUNT_GRPC_PORT")), grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
if err != nil {
|
||||
globals.Logger.Criticalf("Failed to connect to account gRPC server: %v", err)
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
globals.GRPCAccountClient = pb.NewAccountClient(globals.GRPCAccountClientConnection)
|
||||
globals.GRPCAccountCommonMetadata = metadata.Pairs(
|
||||
"X-API-Key", os.Getenv("PN_FRIENDS_ACCOUNT_GRPC_APIKEY"),
|
||||
)
|
||||
|
||||
globals.KerberosPassword = os.Getenv("PN_FRIENDS_CONFIG_KERBEROS_PASSWORD")
|
||||
|
||||
database.Connect()
|
||||
}
|
||||
|
||||
5
main.go
5
main.go
@@ -10,10 +10,11 @@ import (
|
||||
var wg sync.WaitGroup
|
||||
|
||||
func main() {
|
||||
wg.Add(2)
|
||||
wg.Add(3)
|
||||
|
||||
go grpc.StartGRPCServer()
|
||||
go nex.StartNEXServer()
|
||||
go nex.StartAuthenticationServer()
|
||||
go nex.StartSecureServer()
|
||||
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"github.com/PretendoNetwork/friends-secure/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"
|
||||
)
|
||||
|
||||
func NintendoCreateAccount(err error, client *nex.Client, callID uint32, strPrincipalName string, strKey string, uiGroups uint32, strEmail string, oAuthData *nex.DataHolder) {
|
||||
@@ -27,11 +28,11 @@ func NintendoCreateAccount(err error, client *nex.Client, callID uint32, strPrin
|
||||
oAuthDataType := oAuthData.TypeName()
|
||||
|
||||
if oAuthDataType == "NintendoCreateAccountData" { // Wii U
|
||||
nintendoCreateAccountData := oAuthData.ObjectData().(*account_management.NintendoCreateAccountData)
|
||||
nintendoCreateAccountData := oAuthData.ObjectData().(*account_management_types.NintendoCreateAccountData)
|
||||
|
||||
tokenBase64 = nintendoCreateAccountData.Token
|
||||
} else if oAuthDataType == "AccountExtraInfo" { // 3DS
|
||||
accountExtraInfo := oAuthData.ObjectData().(*account_management.AccountExtraInfo)
|
||||
accountExtraInfo := oAuthData.ObjectData().(*account_management_types.AccountExtraInfo)
|
||||
|
||||
tokenBase64 = accountExtraInfo.NEXToken
|
||||
tokenBase64 = strings.Replace(tokenBase64, ".", "+", -1)
|
||||
@@ -56,7 +57,7 @@ func NintendoCreateAccount(err error, client *nex.Client, callID uint32, strPrin
|
||||
|
||||
pidHmac := hex.EncodeToString(mac.Sum(nil))
|
||||
|
||||
rmcResponseStream := nex.NewStreamOut(globals.NEXServer)
|
||||
rmcResponseStream := nex.NewStreamOut(globals.SecureServer)
|
||||
|
||||
rmcResponseStream.WriteUInt32LE(pid)
|
||||
rmcResponseStream.WriteString(pidHmac)
|
||||
@@ -79,5 +80,5 @@ func NintendoCreateAccount(err error, client *nex.Client, callID uint32, strPrin
|
||||
responsePacket.AddFlag(nex.FlagNeedsAck)
|
||||
responsePacket.AddFlag(nex.FlagReliable)
|
||||
|
||||
globals.NEXServer.Send(responsePacket)
|
||||
globals.SecureServer.Send(responsePacket)
|
||||
}
|
||||
|
||||
38
nex/authentication.go
Normal file
38
nex/authentication.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package nex
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
"github.com/PretendoNetwork/nex-go"
|
||||
)
|
||||
|
||||
var serverBuildString string
|
||||
|
||||
func StartAuthenticationServer() {
|
||||
globals.AuthenticationServer = nex.NewServer()
|
||||
globals.AuthenticationServer.SetPRUDPVersion(0)
|
||||
globals.AuthenticationServer.SetPRUDPProtocolMinorVersion(0) // TODO: Figure out what to put here
|
||||
globals.AuthenticationServer.SetDefaultNEXVersion(&nex.NEXVersion{
|
||||
Major: 1,
|
||||
Minor: 1,
|
||||
Patch: 0,
|
||||
})
|
||||
globals.AuthenticationServer.SetKerberosKeySize(16)
|
||||
globals.AuthenticationServer.SetKerberosPassword(globals.KerberosPassword)
|
||||
globals.AuthenticationServer.SetAccessKey("ridfebb9")
|
||||
|
||||
globals.AuthenticationServer.On("Data", func(packet *nex.PacketV0) {
|
||||
request := packet.RMCRequest()
|
||||
|
||||
fmt.Println("==Friends - Auth==")
|
||||
fmt.Printf("Protocol ID: %#v\n", request.ProtocolID())
|
||||
fmt.Printf("Method ID: %#v\n", request.MethodID())
|
||||
fmt.Println("===============")
|
||||
})
|
||||
|
||||
registerCommonAuthenticationServerProtocols()
|
||||
|
||||
globals.AuthenticationServer.Listen(fmt.Sprintf(":%s", os.Getenv("PN_FRIENDS_AUTHENTICATION_SERVER_PORT")))
|
||||
}
|
||||
@@ -10,17 +10,17 @@ func connect(packet *nex.PacketV0) {
|
||||
packet.Sender().SetClientConnectionSignature(packet.ConnectionSignature())
|
||||
|
||||
payload := packet.Payload()
|
||||
stream := nex.NewStreamIn(payload, globals.NEXServer)
|
||||
stream := nex.NewStreamIn(payload, globals.SecureServer)
|
||||
|
||||
ticketData, _ := stream.ReadBuffer()
|
||||
requestData, _ := stream.ReadBuffer()
|
||||
|
||||
serverKey := nex.DeriveKerberosKey(2, []byte(globals.NEXServer.KerberosPassword()))
|
||||
serverKey := nex.DeriveKerberosKey(2, []byte(globals.SecureServer.KerberosPassword()))
|
||||
|
||||
// TODO: use random key from auth server
|
||||
ticketDataEncryption, _ := nex.NewKerberosEncryption(serverKey)
|
||||
decryptedTicketData := ticketDataEncryption.Decrypt(ticketData)
|
||||
ticketDataStream := nex.NewStreamIn(decryptedTicketData, globals.NEXServer)
|
||||
ticketDataStream := nex.NewStreamIn(decryptedTicketData, globals.SecureServer)
|
||||
|
||||
_, _ = ticketDataStream.ReadUInt64LE() // expiration time
|
||||
_, _ = ticketDataStream.ReadUInt32LE() // User PID
|
||||
@@ -28,22 +28,22 @@ func connect(packet *nex.PacketV0) {
|
||||
|
||||
requestDataEncryption, _ := nex.NewKerberosEncryption(sessionKey)
|
||||
decryptedRequestData := requestDataEncryption.Decrypt(requestData)
|
||||
requestDataStream := nex.NewStreamIn(decryptedRequestData, globals.NEXServer)
|
||||
requestDataStream := nex.NewStreamIn(decryptedRequestData, globals.SecureServer)
|
||||
|
||||
userPID, _ := requestDataStream.ReadUInt32LE() // User PID
|
||||
|
||||
_, _ = requestDataStream.ReadUInt32LE() //CID of secure server station url
|
||||
responseCheck, _ := requestDataStream.ReadUInt32LE()
|
||||
|
||||
responseValueStream := nex.NewStreamOut(globals.NEXServer)
|
||||
responseValueStream := nex.NewStreamOut(globals.SecureServer)
|
||||
responseValueStream.WriteUInt32LE(responseCheck + 1)
|
||||
|
||||
responseValueBufferStream := nex.NewStreamOut(globals.NEXServer)
|
||||
responseValueBufferStream := nex.NewStreamOut(globals.SecureServer)
|
||||
responseValueBufferStream.WriteBuffer(responseValueStream.Bytes())
|
||||
|
||||
packet.Sender().UpdateRC4Key(sessionKey)
|
||||
|
||||
globals.NEXServer.AcknowledgePacket(packet, responseValueBufferStream.Bytes())
|
||||
globals.SecureServer.AcknowledgePacket(packet, responseValueBufferStream.Bytes())
|
||||
|
||||
packet.Sender().SetPID(userPID)
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
notifications_3ds "github.com/PretendoNetwork/friends-secure/notifications/3ds"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends/3ds"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends-3ds"
|
||||
)
|
||||
|
||||
func AddFriendshipByPrincipalID(err error, client *nex.Client, callID uint32, lfc uint64, pid uint32) {
|
||||
@@ -16,7 +16,7 @@ func AddFriendshipByPrincipalID(err error, client *nex.Client, callID uint32, lf
|
||||
go notifications_3ds.SendFriendshipCompleted(connectedUser.Client, pid, client.PID())
|
||||
}
|
||||
|
||||
rmcResponseStream := nex.NewStreamOut(globals.NEXServer)
|
||||
rmcResponseStream := nex.NewStreamOut(globals.SecureServer)
|
||||
|
||||
rmcResponseStream.WriteStructure(friendRelationship)
|
||||
|
||||
@@ -38,5 +38,5 @@ func AddFriendshipByPrincipalID(err error, client *nex.Client, callID uint32, lf
|
||||
responsePacket.AddFlag(nex.FlagNeedsAck)
|
||||
responsePacket.AddFlag(nex.FlagReliable)
|
||||
|
||||
globals.NEXServer.Send(responsePacket)
|
||||
globals.SecureServer.Send(responsePacket)
|
||||
}
|
||||
|
||||
@@ -4,13 +4,13 @@ import (
|
||||
database_3ds "github.com/PretendoNetwork/friends-secure/database/3ds"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends/3ds"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends-3ds"
|
||||
)
|
||||
|
||||
func GetAllFriends(err error, client *nex.Client, callID uint32) {
|
||||
friendRelationships := database_3ds.GetUserFriends(client.PID())
|
||||
|
||||
rmcResponseStream := nex.NewStreamOut(globals.NEXServer)
|
||||
rmcResponseStream := nex.NewStreamOut(globals.SecureServer)
|
||||
|
||||
rmcResponseStream.WriteListStructure(friendRelationships)
|
||||
|
||||
@@ -32,5 +32,5 @@ func GetAllFriends(err error, client *nex.Client, callID uint32) {
|
||||
responsePacket.AddFlag(nex.FlagNeedsAck)
|
||||
responsePacket.AddFlag(nex.FlagReliable)
|
||||
|
||||
globals.NEXServer.Send(responsePacket)
|
||||
globals.SecureServer.Send(responsePacket)
|
||||
}
|
||||
|
||||
@@ -4,13 +4,13 @@ import (
|
||||
database_3ds "github.com/PretendoNetwork/friends-secure/database/3ds"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends/3ds"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends-3ds"
|
||||
)
|
||||
|
||||
func GetFriendMii(err error, client *nex.Client, callID uint32, pids []uint32) {
|
||||
miiList := database_3ds.GetFriendMiis(pids)
|
||||
|
||||
rmcResponseStream := nex.NewStreamOut(globals.NEXServer)
|
||||
rmcResponseStream := nex.NewStreamOut(globals.SecureServer)
|
||||
|
||||
rmcResponseStream.WriteListStructure(miiList)
|
||||
|
||||
@@ -32,5 +32,5 @@ func GetFriendMii(err error, client *nex.Client, callID uint32, pids []uint32) {
|
||||
responsePacket.AddFlag(nex.FlagNeedsAck)
|
||||
responsePacket.AddFlag(nex.FlagReliable)
|
||||
|
||||
globals.NEXServer.Send(responsePacket)
|
||||
globals.SecureServer.Send(responsePacket)
|
||||
}
|
||||
|
||||
@@ -4,13 +4,13 @@ import (
|
||||
database_3ds "github.com/PretendoNetwork/friends-secure/database/3ds"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends/3ds"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends-3ds"
|
||||
)
|
||||
|
||||
func GetFriendPersistentInfo(err error, client *nex.Client, callID uint32, pids []uint32) {
|
||||
infoList := database_3ds.GetFriendPersistentInfos(client.PID(), pids)
|
||||
|
||||
rmcResponseStream := nex.NewStreamOut(globals.NEXServer)
|
||||
rmcResponseStream := nex.NewStreamOut(globals.SecureServer)
|
||||
|
||||
rmcResponseStream.WriteListStructure(infoList)
|
||||
|
||||
@@ -32,5 +32,5 @@ func GetFriendPersistentInfo(err error, client *nex.Client, callID uint32, pids
|
||||
responsePacket.AddFlag(nex.FlagNeedsAck)
|
||||
responsePacket.AddFlag(nex.FlagReliable)
|
||||
|
||||
globals.NEXServer.Send(responsePacket)
|
||||
globals.SecureServer.Send(responsePacket)
|
||||
}
|
||||
|
||||
@@ -3,17 +3,18 @@ package nex_friends_3ds
|
||||
import (
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends/3ds"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends-3ds"
|
||||
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/friends-3ds/types"
|
||||
)
|
||||
|
||||
func GetFriendPresence(err error, client *nex.Client, callID uint32, pids []uint32) {
|
||||
presenceList := make([]*friends_3ds.FriendPresence, 0)
|
||||
presenceList := make([]*friends_3ds_types.FriendPresence, 0)
|
||||
|
||||
for i := 0; i < len(pids); i++ {
|
||||
connectedUser := globals.ConnectedUsers[pids[i]]
|
||||
|
||||
if connectedUser != nil && connectedUser.Presence != nil {
|
||||
friendPresence := friends_3ds.NewFriendPresence()
|
||||
friendPresence := friends_3ds_types.NewFriendPresence()
|
||||
friendPresence.PID = pids[i]
|
||||
friendPresence.Presence = globals.ConnectedUsers[pids[i]].Presence
|
||||
|
||||
@@ -21,7 +22,7 @@ func GetFriendPresence(err error, client *nex.Client, callID uint32, pids []uint
|
||||
}
|
||||
}
|
||||
|
||||
rmcResponseStream := nex.NewStreamOut(globals.NEXServer)
|
||||
rmcResponseStream := nex.NewStreamOut(globals.SecureServer)
|
||||
|
||||
rmcResponseStream.WriteListStructure(presenceList)
|
||||
|
||||
@@ -43,5 +44,5 @@ func GetFriendPresence(err error, client *nex.Client, callID uint32, pids []uint
|
||||
responsePacket.AddFlag(nex.FlagNeedsAck)
|
||||
responsePacket.AddFlag(nex.FlagReliable)
|
||||
|
||||
globals.NEXServer.Send(responsePacket)
|
||||
globals.SecureServer.Send(responsePacket)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package nex_friends_3ds
|
||||
import (
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends/3ds"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends-3ds"
|
||||
)
|
||||
|
||||
func GetPrincipalIDByLocalFriendCode(err error, client *nex.Client, callID uint32, lfc uint64, lfcList []uint64) {
|
||||
@@ -25,5 +25,5 @@ func GetPrincipalIDByLocalFriendCode(err error, client *nex.Client, callID uint3
|
||||
responsePacket.AddFlag(nex.FlagNeedsAck)
|
||||
responsePacket.AddFlag(nex.FlagReliable)
|
||||
|
||||
globals.NEXServer.Send(responsePacket)
|
||||
globals.SecureServer.Send(responsePacket)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package nex_friends_3ds
|
||||
import (
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends/3ds"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends-3ds"
|
||||
)
|
||||
|
||||
func RemoveFriendByLocalFriendCode(err error, client *nex.Client, callID uint32, friendLFC uint64) {
|
||||
@@ -25,5 +25,5 @@ func RemoveFriendByLocalFriendCode(err error, client *nex.Client, callID uint32,
|
||||
responsePacket.AddFlag(nex.FlagNeedsAck)
|
||||
responsePacket.AddFlag(nex.FlagReliable)
|
||||
|
||||
globals.NEXServer.Send(responsePacket)
|
||||
globals.SecureServer.Send(responsePacket)
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
notifications_3ds "github.com/PretendoNetwork/friends-secure/notifications/3ds"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends/3ds"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends-3ds"
|
||||
)
|
||||
|
||||
func RemoveFriendByPrincipalID(err error, client *nex.Client, callID uint32, pid uint32) {
|
||||
@@ -28,5 +28,5 @@ func RemoveFriendByPrincipalID(err error, client *nex.Client, callID uint32, pid
|
||||
responsePacket.AddFlag(nex.FlagNeedsAck)
|
||||
responsePacket.AddFlag(nex.FlagReliable)
|
||||
|
||||
globals.NEXServer.Send(responsePacket)
|
||||
globals.SecureServer.Send(responsePacket)
|
||||
}
|
||||
|
||||
@@ -5,7 +5,8 @@ import (
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
notifications_3ds "github.com/PretendoNetwork/friends-secure/notifications/3ds"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends/3ds"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends-3ds"
|
||||
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/friends-3ds/types"
|
||||
"golang.org/x/exp/slices"
|
||||
)
|
||||
|
||||
@@ -32,7 +33,7 @@ func SyncFriend(err error, client *nex.Client, callID uint32, lfc uint64, pids [
|
||||
}
|
||||
}
|
||||
|
||||
rmcResponseStream := nex.NewStreamOut(globals.NEXServer)
|
||||
rmcResponseStream := nex.NewStreamOut(globals.SecureServer)
|
||||
|
||||
rmcResponseStream.WriteListStructure(friendRelationships)
|
||||
|
||||
@@ -54,10 +55,10 @@ func SyncFriend(err error, client *nex.Client, callID uint32, lfc uint64, pids [
|
||||
responsePacket.AddFlag(nex.FlagNeedsAck)
|
||||
responsePacket.AddFlag(nex.FlagReliable)
|
||||
|
||||
globals.NEXServer.Send(responsePacket)
|
||||
globals.SecureServer.Send(responsePacket)
|
||||
}
|
||||
|
||||
func isPIDInRelationships(relationships []*friends_3ds.FriendRelationship, pid uint32) bool {
|
||||
func isPIDInRelationships(relationships []*friends_3ds_types.FriendRelationship, pid uint32) bool {
|
||||
for i := range relationships {
|
||||
if relationships[i].PID == pid {
|
||||
return true
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
notifications_3ds "github.com/PretendoNetwork/friends-secure/notifications/3ds"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends/3ds"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends-3ds"
|
||||
)
|
||||
|
||||
func UpdateComment(err error, client *nex.Client, callID uint32, comment string) {
|
||||
@@ -28,5 +28,5 @@ func UpdateComment(err error, client *nex.Client, callID uint32, comment string)
|
||||
responsePacket.AddFlag(nex.FlagNeedsAck)
|
||||
responsePacket.AddFlag(nex.FlagReliable)
|
||||
|
||||
globals.NEXServer.Send(responsePacket)
|
||||
globals.SecureServer.Send(responsePacket)
|
||||
}
|
||||
|
||||
@@ -5,10 +5,11 @@ import (
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
notifications_3ds "github.com/PretendoNetwork/friends-secure/notifications/3ds"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends/3ds"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends-3ds"
|
||||
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/friends-3ds/types"
|
||||
)
|
||||
|
||||
func UpdateFavoriteGameKey(err error, client *nex.Client, callID uint32, gameKey *friends_3ds.GameKey) {
|
||||
func UpdateFavoriteGameKey(err error, client *nex.Client, callID uint32, gameKey *friends_3ds_types.GameKey) {
|
||||
go notifications_3ds.SendFavoriteUpdate(client, gameKey)
|
||||
database_3ds.UpdateUserFavoriteGame(client.PID(), gameKey)
|
||||
|
||||
@@ -28,5 +29,5 @@ func UpdateFavoriteGameKey(err error, client *nex.Client, callID uint32, gameKey
|
||||
responsePacket.AddFlag(nex.FlagNeedsAck)
|
||||
responsePacket.AddFlag(nex.FlagReliable)
|
||||
|
||||
globals.NEXServer.Send(responsePacket)
|
||||
globals.SecureServer.Send(responsePacket)
|
||||
}
|
||||
|
||||
@@ -5,10 +5,11 @@ import (
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
notifications_3ds "github.com/PretendoNetwork/friends-secure/notifications/3ds"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends/3ds"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends-3ds"
|
||||
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/friends-3ds/types"
|
||||
)
|
||||
|
||||
func UpdateMii(err error, client *nex.Client, callID uint32, mii *friends_3ds.Mii) {
|
||||
func UpdateMii(err error, client *nex.Client, callID uint32, mii *friends_3ds_types.Mii) {
|
||||
go notifications_3ds.SendMiiUpdateNotification(client)
|
||||
database_3ds.UpdateUserMii(client.PID(), mii)
|
||||
|
||||
@@ -28,5 +29,5 @@ func UpdateMii(err error, client *nex.Client, callID uint32, mii *friends_3ds.Mi
|
||||
responsePacket.AddFlag(nex.FlagNeedsAck)
|
||||
responsePacket.AddFlag(nex.FlagReliable)
|
||||
|
||||
globals.NEXServer.Send(responsePacket)
|
||||
globals.SecureServer.Send(responsePacket)
|
||||
}
|
||||
|
||||
@@ -5,13 +5,14 @@ import (
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
notifications_3ds "github.com/PretendoNetwork/friends-secure/notifications/3ds"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends/3ds"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends-3ds"
|
||||
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/friends-3ds/types"
|
||||
)
|
||||
|
||||
func UpdatePreference(err error, client *nex.Client, callID uint32, showOnline bool, showCurrentGame bool, showPlayedGame bool) {
|
||||
if !showCurrentGame {
|
||||
emptyPresence := friends_3ds.NewNintendoPresence()
|
||||
emptyPresence.GameKey = friends_3ds.NewGameKey()
|
||||
emptyPresence := friends_3ds_types.NewNintendoPresence()
|
||||
emptyPresence.GameKey = friends_3ds_types.NewGameKey()
|
||||
emptyPresence.ChangedFlags = 0xFFFFFFFF // All flags
|
||||
notifications_3ds.SendPresenceUpdate(client, emptyPresence)
|
||||
}
|
||||
@@ -37,5 +38,5 @@ func UpdatePreference(err error, client *nex.Client, callID uint32, showOnline b
|
||||
responsePacket.AddFlag(nex.FlagNeedsAck)
|
||||
responsePacket.AddFlag(nex.FlagReliable)
|
||||
|
||||
globals.NEXServer.Send(responsePacket)
|
||||
globals.SecureServer.Send(responsePacket)
|
||||
}
|
||||
|
||||
@@ -5,16 +5,17 @@ import (
|
||||
notifications_3ds "github.com/PretendoNetwork/friends-secure/notifications/3ds"
|
||||
"github.com/PretendoNetwork/friends-secure/types"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends/3ds"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends-3ds"
|
||||
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/friends-3ds/types"
|
||||
)
|
||||
|
||||
func UpdatePresence(err error, client *nex.Client, callID uint32, presence *friends_3ds.NintendoPresence, showGame bool) {
|
||||
func UpdatePresence(err error, client *nex.Client, callID uint32, presence *friends_3ds_types.NintendoPresence, showGame bool) {
|
||||
currentPresence := presence
|
||||
|
||||
// Send an entirely empty status, with every flag set to update
|
||||
if !showGame {
|
||||
currentPresence = friends_3ds.NewNintendoPresence()
|
||||
currentPresence.GameKey = friends_3ds.NewGameKey()
|
||||
currentPresence = friends_3ds_types.NewNintendoPresence()
|
||||
currentPresence.GameKey = friends_3ds_types.NewGameKey()
|
||||
currentPresence.ChangedFlags = 0xFFFFFFFF // All flags
|
||||
}
|
||||
|
||||
@@ -50,5 +51,5 @@ func UpdatePresence(err error, client *nex.Client, callID uint32, presence *frie
|
||||
responsePacket.AddFlag(nex.FlagNeedsAck)
|
||||
responsePacket.AddFlag(nex.FlagReliable)
|
||||
|
||||
globals.NEXServer.Send(responsePacket)
|
||||
globals.SecureServer.Send(responsePacket)
|
||||
}
|
||||
|
||||
@@ -4,10 +4,11 @@ import (
|
||||
database_3ds "github.com/PretendoNetwork/friends-secure/database/3ds"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends/3ds"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends-3ds"
|
||||
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/friends-3ds/types"
|
||||
)
|
||||
|
||||
func UpdateProfile(err error, client *nex.Client, callID uint32, profileData *friends_3ds.MyProfile) {
|
||||
func UpdateProfile(err error, client *nex.Client, callID uint32, profileData *friends_3ds_types.MyProfile) {
|
||||
database_3ds.UpdateUserProfile(client.PID(), profileData)
|
||||
|
||||
rmcResponse := nex.NewRMCResponse(friends_3ds.ProtocolID, callID)
|
||||
@@ -26,5 +27,5 @@ func UpdateProfile(err error, client *nex.Client, callID uint32, profileData *fr
|
||||
responsePacket.AddFlag(nex.FlagNeedsAck)
|
||||
responsePacket.AddFlag(nex.FlagReliable)
|
||||
|
||||
globals.NEXServer.Send(responsePacket)
|
||||
globals.SecureServer.Send(responsePacket)
|
||||
}
|
||||
|
||||
@@ -5,7 +5,8 @@ import (
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
notifications_wiiu "github.com/PretendoNetwork/friends-secure/notifications/wiiu"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
|
||||
)
|
||||
|
||||
func AcceptFriendRequest(err error, client *nex.Client, callID uint32, id uint64) {
|
||||
@@ -18,7 +19,7 @@ func AcceptFriendRequest(err error, client *nex.Client, callID uint32, id uint64
|
||||
senderPID := client.PID()
|
||||
senderConnectedUser := globals.ConnectedUsers[senderPID]
|
||||
|
||||
senderFriendInfo := friends_wiiu.NewFriendInfo()
|
||||
senderFriendInfo := friends_wiiu_types.NewFriendInfo()
|
||||
|
||||
senderFriendInfo.NNAInfo = senderConnectedUser.NNAInfo
|
||||
senderFriendInfo.Presence = senderConnectedUser.PresenceV2
|
||||
@@ -30,7 +31,7 @@ func AcceptFriendRequest(err error, client *nex.Client, callID uint32, id uint64
|
||||
go notifications_wiiu.SendFriendRequestAccepted(connectedUser.Client, senderFriendInfo)
|
||||
}
|
||||
|
||||
rmcResponseStream := nex.NewStreamOut(globals.NEXServer)
|
||||
rmcResponseStream := nex.NewStreamOut(globals.SecureServer)
|
||||
|
||||
rmcResponseStream.WriteStructure(friendInfo)
|
||||
|
||||
@@ -53,5 +54,5 @@ func AcceptFriendRequest(err error, client *nex.Client, callID uint32, id uint64
|
||||
responsePacket.AddFlag(nex.FlagNeedsAck)
|
||||
responsePacket.AddFlag(nex.FlagReliable)
|
||||
|
||||
globals.NEXServer.Send(responsePacket)
|
||||
globals.SecureServer.Send(responsePacket)
|
||||
}
|
||||
|
||||
@@ -6,10 +6,11 @@ import (
|
||||
database_wiiu "github.com/PretendoNetwork/friends-secure/database/wiiu"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
|
||||
)
|
||||
|
||||
func AddBlacklist(err error, client *nex.Client, callID uint32, blacklistPrincipal *friends_wiiu.BlacklistedPrincipal) {
|
||||
func AddBlacklist(err error, client *nex.Client, callID uint32, blacklistPrincipal *friends_wiiu_types.BlacklistedPrincipal) {
|
||||
currentBlacklistPrincipal := blacklistPrincipal
|
||||
|
||||
senderPID := currentBlacklistPrincipal.PrincipalBasicInfo.PID
|
||||
@@ -38,7 +39,7 @@ func AddBlacklist(err error, client *nex.Client, callID uint32, blacklistPrincip
|
||||
responsePacket.AddFlag(nex.FlagNeedsAck)
|
||||
responsePacket.AddFlag(nex.FlagReliable)
|
||||
|
||||
globals.NEXServer.Send(responsePacket)
|
||||
globals.SecureServer.Send(responsePacket)
|
||||
|
||||
return
|
||||
}
|
||||
@@ -48,7 +49,7 @@ func AddBlacklist(err error, client *nex.Client, callID uint32, blacklistPrincip
|
||||
|
||||
database_wiiu.SetUserBlocked(client.PID(), senderPID, titleID, titleVersion)
|
||||
|
||||
rmcResponseStream := nex.NewStreamOut(globals.NEXServer)
|
||||
rmcResponseStream := nex.NewStreamOut(globals.SecureServer)
|
||||
|
||||
rmcResponseStream.WriteStructure(blacklistPrincipal)
|
||||
|
||||
@@ -71,5 +72,5 @@ func AddBlacklist(err error, client *nex.Client, callID uint32, blacklistPrincip
|
||||
responsePacket.AddFlag(nex.FlagNeedsAck)
|
||||
responsePacket.AddFlag(nex.FlagReliable)
|
||||
|
||||
globals.NEXServer.Send(responsePacket)
|
||||
globals.SecureServer.Send(responsePacket)
|
||||
}
|
||||
|
||||
@@ -8,10 +8,11 @@ import (
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
notifications_wiiu "github.com/PretendoNetwork/friends-secure/notifications/wiiu"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
|
||||
)
|
||||
|
||||
func AddFriendRequest(err error, client *nex.Client, callID uint32, pid uint32, unknown2 uint8, message string, unknown4 uint8, unknown5 string, gameKey *friends_wiiu.GameKey, unknown6 *nex.DateTime) {
|
||||
func AddFriendRequest(err error, client *nex.Client, callID uint32, pid uint32, unknown2 uint8, message string, unknown4 uint8, unknown5 string, gameKey *friends_wiiu_types.GameKey, unknown6 *nex.DateTime) {
|
||||
senderPID := client.PID()
|
||||
recipientPID := pid
|
||||
|
||||
@@ -35,7 +36,7 @@ func AddFriendRequest(err error, client *nex.Client, callID uint32, pid uint32,
|
||||
responsePacket.AddFlag(nex.FlagNeedsAck)
|
||||
responsePacket.AddFlag(nex.FlagReliable)
|
||||
|
||||
globals.NEXServer.Send(responsePacket)
|
||||
globals.SecureServer.Send(responsePacket)
|
||||
|
||||
return
|
||||
}
|
||||
@@ -51,11 +52,11 @@ func AddFriendRequest(err error, client *nex.Client, callID uint32, pid uint32,
|
||||
|
||||
friendRequestID := database_wiiu.SaveFriendRequest(senderPID, recipientPID, sentTime.Value(), expireTime.Value(), message)
|
||||
|
||||
friendRequest := friends_wiiu.NewFriendRequest()
|
||||
friendRequest := friends_wiiu_types.NewFriendRequest()
|
||||
|
||||
friendRequest.PrincipalInfo = database_wiiu.GetUserInfoByPID(recipientPID)
|
||||
|
||||
friendRequest.Message = friends_wiiu.NewFriendRequestMessage()
|
||||
friendRequest.Message = friends_wiiu_types.NewFriendRequestMessage()
|
||||
friendRequest.Message.FriendRequestID = friendRequestID
|
||||
friendRequest.Message.Received = false
|
||||
friendRequest.Message.Unknown2 = 1 // replaying from real
|
||||
@@ -68,13 +69,13 @@ func AddFriendRequest(err error, client *nex.Client, callID uint32, pid uint32,
|
||||
friendRequest.SentOn = sentTime
|
||||
|
||||
// Why does this exist?? Always empty??
|
||||
friendInfo := friends_wiiu.NewFriendInfo()
|
||||
friendInfo := friends_wiiu_types.NewFriendInfo()
|
||||
|
||||
friendInfo.NNAInfo = friends_wiiu.NewNNAInfo()
|
||||
friendInfo.NNAInfo.PrincipalBasicInfo = friends_wiiu.NewPrincipalBasicInfo()
|
||||
friendInfo.NNAInfo = friends_wiiu_types.NewNNAInfo()
|
||||
friendInfo.NNAInfo.PrincipalBasicInfo = friends_wiiu_types.NewPrincipalBasicInfo()
|
||||
friendInfo.NNAInfo.PrincipalBasicInfo.PID = 0
|
||||
friendInfo.NNAInfo.PrincipalBasicInfo.NNID = ""
|
||||
friendInfo.NNAInfo.PrincipalBasicInfo.Mii = friends_wiiu.NewMiiV2()
|
||||
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
|
||||
@@ -84,7 +85,7 @@ func AddFriendRequest(err error, client *nex.Client, callID uint32, pid uint32,
|
||||
friendInfo.NNAInfo.Unknown1 = 0
|
||||
friendInfo.NNAInfo.Unknown2 = 0
|
||||
|
||||
friendInfo.Presence = friends_wiiu.NewNintendoPresenceV2()
|
||||
friendInfo.Presence = friends_wiiu_types.NewNintendoPresenceV2()
|
||||
friendInfo.Presence.ChangedFlags = 0
|
||||
friendInfo.Presence.Online = false
|
||||
friendInfo.Presence.GameKey = gameKey // maybe this is reused?
|
||||
@@ -101,7 +102,7 @@ func AddFriendRequest(err error, client *nex.Client, callID uint32, pid uint32,
|
||||
friendInfo.Presence.Unknown6 = 0
|
||||
friendInfo.Presence.Unknown7 = 0
|
||||
|
||||
friendInfo.Status = friends_wiiu.NewComment()
|
||||
friendInfo.Status = friends_wiiu_types.NewComment()
|
||||
friendInfo.Status.Unknown = 0
|
||||
friendInfo.Status.Contents = ""
|
||||
friendInfo.Status.LastChanged = nex.NewDateTime(0)
|
||||
@@ -114,11 +115,11 @@ func AddFriendRequest(err error, client *nex.Client, callID uint32, pid uint32,
|
||||
|
||||
if recipientClient != nil {
|
||||
|
||||
friendRequestNotificationData := friends_wiiu.NewFriendRequest()
|
||||
friendRequestNotificationData := friends_wiiu_types.NewFriendRequest()
|
||||
|
||||
friendRequestNotificationData.PrincipalInfo = database_wiiu.GetUserInfoByPID(senderPID)
|
||||
|
||||
friendRequestNotificationData.Message = friends_wiiu.NewFriendRequestMessage()
|
||||
friendRequestNotificationData.Message = friends_wiiu_types.NewFriendRequestMessage()
|
||||
friendRequestNotificationData.Message.FriendRequestID = friendRequestID
|
||||
friendRequestNotificationData.Message.Received = false
|
||||
friendRequestNotificationData.Message.Unknown2 = 1 // replaying from real
|
||||
@@ -133,7 +134,7 @@ func AddFriendRequest(err error, client *nex.Client, callID uint32, pid uint32,
|
||||
go notifications_wiiu.SendFriendRequest(recipientClient, friendRequestNotificationData)
|
||||
}
|
||||
|
||||
rmcResponseStream := nex.NewStreamOut(globals.NEXServer)
|
||||
rmcResponseStream := nex.NewStreamOut(globals.SecureServer)
|
||||
|
||||
rmcResponseStream.WriteStructure(friendRequest)
|
||||
rmcResponseStream.WriteStructure(friendInfo)
|
||||
@@ -157,5 +158,5 @@ func AddFriendRequest(err error, client *nex.Client, callID uint32, pid uint32,
|
||||
responsePacket.AddFlag(nex.FlagNeedsAck)
|
||||
responsePacket.AddFlag(nex.FlagReliable)
|
||||
|
||||
globals.NEXServer.Send(responsePacket)
|
||||
globals.SecureServer.Send(responsePacket)
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
notifications_wiiu "github.com/PretendoNetwork/friends-secure/notifications/wiiu"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu"
|
||||
)
|
||||
|
||||
func CancelFriendRequest(err error, client *nex.Client, callID uint32, id uint64) {
|
||||
@@ -33,5 +33,5 @@ func CancelFriendRequest(err error, client *nex.Client, callID uint32, id uint64
|
||||
responsePacket.AddFlag(nex.FlagNeedsAck)
|
||||
responsePacket.AddFlag(nex.FlagReliable)
|
||||
|
||||
globals.NEXServer.Send(responsePacket)
|
||||
globals.SecureServer.Send(responsePacket)
|
||||
}
|
||||
|
||||
@@ -3,11 +3,11 @@ package nex_friends_wiiu
|
||||
import (
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu"
|
||||
)
|
||||
|
||||
func CheckSettingStatus(err error, client *nex.Client, callID uint32) {
|
||||
rmcResponseStream := nex.NewStreamOut(globals.NEXServer)
|
||||
rmcResponseStream := nex.NewStreamOut(globals.SecureServer)
|
||||
|
||||
rmcResponseStream.WriteUInt8(0xFF)
|
||||
|
||||
@@ -30,5 +30,5 @@ func CheckSettingStatus(err error, client *nex.Client, callID uint32) {
|
||||
responsePacket.AddFlag(nex.FlagNeedsAck)
|
||||
responsePacket.AddFlag(nex.FlagReliable)
|
||||
|
||||
globals.NEXServer.Send(responsePacket)
|
||||
globals.SecureServer.Send(responsePacket)
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
database_wiiu "github.com/PretendoNetwork/friends-secure/database/wiiu"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu"
|
||||
)
|
||||
|
||||
func DeleteFriendRequest(err error, client *nex.Client, callID uint32, id uint64) {
|
||||
@@ -26,5 +26,5 @@ func DeleteFriendRequest(err error, client *nex.Client, callID uint32, id uint64
|
||||
responsePacket.AddFlag(nex.FlagNeedsAck)
|
||||
responsePacket.AddFlag(nex.FlagReliable)
|
||||
|
||||
globals.NEXServer.Send(responsePacket)
|
||||
globals.SecureServer.Send(responsePacket)
|
||||
}
|
||||
|
||||
@@ -3,10 +3,11 @@ package nex_friends_wiiu
|
||||
import (
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
|
||||
)
|
||||
|
||||
func DeletePersistentNotification(err error, client *nex.Client, callID uint32, notifications []*friends_wiiu.PersistentNotification) {
|
||||
func DeletePersistentNotification(err error, client *nex.Client, callID uint32, notifications []*friends_wiiu_types.PersistentNotification) {
|
||||
// TODO: Do something here
|
||||
|
||||
rmcResponse := nex.NewRMCResponse(friends_wiiu.ProtocolID, callID)
|
||||
@@ -25,5 +26,5 @@ func DeletePersistentNotification(err error, client *nex.Client, callID uint32,
|
||||
responsePacket.AddFlag(nex.FlagNeedsAck)
|
||||
responsePacket.AddFlag(nex.FlagReliable)
|
||||
|
||||
globals.NEXServer.Send(responsePacket)
|
||||
globals.SecureServer.Send(responsePacket)
|
||||
}
|
||||
|
||||
@@ -6,7 +6,8 @@ import (
|
||||
database_wiiu "github.com/PretendoNetwork/friends-secure/database/wiiu"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
|
||||
)
|
||||
|
||||
func DenyFriendRequest(err error, client *nex.Client, callID uint32, id uint64) {
|
||||
@@ -21,13 +22,13 @@ func DenyFriendRequest(err error, client *nex.Client, callID uint32, id uint64)
|
||||
date.FromTimestamp(time.Now())
|
||||
|
||||
// Create a new blacklist principal for the client, as unlike AddBlacklist they don't send one to us.
|
||||
blacklistPrincipal := friends_wiiu.NewBlacklistedPrincipal()
|
||||
blacklistPrincipal := friends_wiiu_types.NewBlacklistedPrincipal()
|
||||
|
||||
blacklistPrincipal.PrincipalBasicInfo = info
|
||||
blacklistPrincipal.GameKey = friends_wiiu.NewGameKey()
|
||||
blacklistPrincipal.GameKey = friends_wiiu_types.NewGameKey()
|
||||
blacklistPrincipal.BlackListedSince = date
|
||||
|
||||
rmcResponseStream := nex.NewStreamOut(globals.NEXServer)
|
||||
rmcResponseStream := nex.NewStreamOut(globals.SecureServer)
|
||||
|
||||
rmcResponseStream.WriteStructure(blacklistPrincipal)
|
||||
|
||||
@@ -50,5 +51,5 @@ func DenyFriendRequest(err error, client *nex.Client, callID uint32, id uint64)
|
||||
responsePacket.AddFlag(nex.FlagNeedsAck)
|
||||
responsePacket.AddFlag(nex.FlagReliable)
|
||||
|
||||
globals.NEXServer.Send(responsePacket)
|
||||
globals.SecureServer.Send(responsePacket)
|
||||
}
|
||||
|
||||
@@ -4,11 +4,12 @@ import (
|
||||
database_wiiu "github.com/PretendoNetwork/friends-secure/database/wiiu"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
|
||||
)
|
||||
|
||||
func GetBasicInfo(err error, client *nex.Client, callID uint32, pids []uint32) {
|
||||
infos := make([]*friends_wiiu.PrincipalBasicInfo, 0)
|
||||
infos := make([]*friends_wiiu_types.PrincipalBasicInfo, 0)
|
||||
|
||||
for i := 0; i < len(pids); i++ {
|
||||
pid := pids[i]
|
||||
@@ -19,7 +20,7 @@ func GetBasicInfo(err error, client *nex.Client, callID uint32, pids []uint32) {
|
||||
}
|
||||
}
|
||||
|
||||
rmcResponseStream := nex.NewStreamOut(globals.NEXServer)
|
||||
rmcResponseStream := nex.NewStreamOut(globals.SecureServer)
|
||||
|
||||
rmcResponseStream.WriteListStructure(infos)
|
||||
|
||||
@@ -42,5 +43,5 @@ func GetBasicInfo(err error, client *nex.Client, callID uint32, pids []uint32) {
|
||||
responsePacket.AddFlag(nex.FlagNeedsAck)
|
||||
responsePacket.AddFlag(nex.FlagReliable)
|
||||
|
||||
globals.NEXServer.Send(responsePacket)
|
||||
globals.SecureServer.Send(responsePacket)
|
||||
}
|
||||
|
||||
@@ -4,25 +4,26 @@ import (
|
||||
database_wiiu "github.com/PretendoNetwork/friends-secure/database/wiiu"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
|
||||
)
|
||||
|
||||
func GetRequestBlockSettings(err error, client *nex.Client, callID uint32, pids []uint32) {
|
||||
settings := make([]*friends_wiiu.PrincipalRequestBlockSetting, 0)
|
||||
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]
|
||||
|
||||
setting := friends_wiiu.NewPrincipalRequestBlockSetting()
|
||||
setting := friends_wiiu_types.NewPrincipalRequestBlockSetting()
|
||||
setting.PID = requestedPID
|
||||
setting.IsBlocked = database_wiiu.IsFriendRequestBlocked(client.PID(), requestedPID)
|
||||
|
||||
settings = append(settings, setting)
|
||||
}
|
||||
|
||||
rmcResponseStream := nex.NewStreamOut(globals.NEXServer)
|
||||
rmcResponseStream := nex.NewStreamOut(globals.SecureServer)
|
||||
|
||||
rmcResponseStream.WriteListStructure(settings)
|
||||
|
||||
@@ -45,5 +46,5 @@ func GetRequestBlockSettings(err error, client *nex.Client, callID uint32, pids
|
||||
responsePacket.AddFlag(nex.FlagNeedsAck)
|
||||
responsePacket.AddFlag(nex.FlagReliable)
|
||||
|
||||
globals.NEXServer.Send(responsePacket)
|
||||
globals.SecureServer.Send(responsePacket)
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
database_wiiu "github.com/PretendoNetwork/friends-secure/database/wiiu"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu"
|
||||
)
|
||||
|
||||
func MarkFriendRequestsAsReceived(err error, client *nex.Client, callID uint32, ids []uint64) {
|
||||
@@ -29,5 +29,5 @@ func MarkFriendRequestsAsReceived(err error, client *nex.Client, callID uint32,
|
||||
responsePacket.AddFlag(nex.FlagNeedsAck)
|
||||
responsePacket.AddFlag(nex.FlagReliable)
|
||||
|
||||
globals.NEXServer.Send(responsePacket)
|
||||
globals.SecureServer.Send(responsePacket)
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
database_wiiu "github.com/PretendoNetwork/friends-secure/database/wiiu"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu"
|
||||
)
|
||||
|
||||
func RemoveBlacklist(err error, client *nex.Client, callID uint32, blockedPID uint32) {
|
||||
@@ -26,5 +26,5 @@ func RemoveBlacklist(err error, client *nex.Client, callID uint32, blockedPID ui
|
||||
responsePacket.AddFlag(nex.FlagNeedsAck)
|
||||
responsePacket.AddFlag(nex.FlagReliable)
|
||||
|
||||
globals.NEXServer.Send(responsePacket)
|
||||
globals.SecureServer.Send(responsePacket)
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
notifications_wiiu "github.com/PretendoNetwork/friends-secure/notifications/wiiu"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu"
|
||||
)
|
||||
|
||||
func RemoveFriend(err error, client *nex.Client, callID uint32, pid uint32) {
|
||||
@@ -32,5 +32,5 @@ func RemoveFriend(err error, client *nex.Client, callID uint32, pid uint32) {
|
||||
responsePacket.AddFlag(nex.FlagNeedsAck)
|
||||
responsePacket.AddFlag(nex.FlagReliable)
|
||||
|
||||
globals.NEXServer.Send(responsePacket)
|
||||
globals.SecureServer.Send(responsePacket)
|
||||
}
|
||||
|
||||
@@ -8,10 +8,11 @@ import (
|
||||
notifications_wiiu "github.com/PretendoNetwork/friends-secure/notifications/wiiu"
|
||||
"github.com/PretendoNetwork/friends-secure/types"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
|
||||
)
|
||||
|
||||
func UpdateAndGetAllInformation(err error, client *nex.Client, callID uint32, nnaInfo *friends_wiiu.NNAInfo, presence *friends_wiiu.NintendoPresenceV2, birthday *nex.DateTime) {
|
||||
func UpdateAndGetAllInformation(err error, client *nex.Client, callID uint32, nnaInfo *friends_wiiu_types.NNAInfo, presence *friends_wiiu_types.NintendoPresenceV2, birthday *nex.DateTime) {
|
||||
|
||||
if err != nil {
|
||||
// TODO: Handle error
|
||||
@@ -50,22 +51,22 @@ func UpdateAndGetAllInformation(err error, client *nex.Client, callID uint32, nn
|
||||
notifications := database_wiiu.GetUserNotifications(pid)
|
||||
|
||||
if os.Getenv("PN_FRIENDS_CONFIG_ENABLE_BELLA") == "true" {
|
||||
bella := friends_wiiu.NewFriendInfo()
|
||||
bella := friends_wiiu_types.NewFriendInfo()
|
||||
|
||||
bella.NNAInfo = friends_wiiu.NewNNAInfo()
|
||||
bella.Presence = friends_wiiu.NewNintendoPresenceV2()
|
||||
bella.Status = friends_wiiu.NewComment()
|
||||
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.NNAInfo.PrincipalBasicInfo = friends_wiiu.NewPrincipalBasicInfo()
|
||||
bella.NNAInfo.PrincipalBasicInfo = friends_wiiu_types.NewPrincipalBasicInfo()
|
||||
bella.NNAInfo.Unknown1 = 0
|
||||
bella.NNAInfo.Unknown2 = 0
|
||||
|
||||
bella.NNAInfo.PrincipalBasicInfo.PID = 1743126339
|
||||
bella.NNAInfo.PrincipalBasicInfo.NNID = "bells1998"
|
||||
bella.NNAInfo.PrincipalBasicInfo.Mii = friends_wiiu.NewMiiV2()
|
||||
bella.NNAInfo.PrincipalBasicInfo.Mii = friends_wiiu_types.NewMiiV2()
|
||||
bella.NNAInfo.PrincipalBasicInfo.Unknown = 0
|
||||
|
||||
bella.NNAInfo.PrincipalBasicInfo.Mii.Name = "bella"
|
||||
@@ -89,7 +90,7 @@ func UpdateAndGetAllInformation(err error, client *nex.Client, callID uint32, nn
|
||||
|
||||
bella.Presence.ChangedFlags = 0x1EE
|
||||
bella.Presence.Online = true
|
||||
bella.Presence.GameKey = friends_wiiu.NewGameKey()
|
||||
bella.Presence.GameKey = friends_wiiu_types.NewGameKey()
|
||||
bella.Presence.Unknown1 = 0
|
||||
bella.Presence.Message = "Testing"
|
||||
//bella.Presence.Unknown2 = 2
|
||||
@@ -121,7 +122,7 @@ func UpdateAndGetAllInformation(err error, client *nex.Client, callID uint32, nn
|
||||
friendList = append(friendList, bella)
|
||||
}
|
||||
|
||||
rmcResponseStream := nex.NewStreamOut(globals.NEXServer)
|
||||
rmcResponseStream := nex.NewStreamOut(globals.SecureServer)
|
||||
|
||||
rmcResponseStream.WriteStructure(principalPreference)
|
||||
rmcResponseStream.WriteStructure(comment)
|
||||
@@ -154,5 +155,5 @@ func UpdateAndGetAllInformation(err error, client *nex.Client, callID uint32, nn
|
||||
responsePacket.AddFlag(nex.FlagNeedsAck)
|
||||
responsePacket.AddFlag(nex.FlagReliable)
|
||||
|
||||
globals.NEXServer.Send(responsePacket)
|
||||
globals.SecureServer.Send(responsePacket)
|
||||
}
|
||||
|
||||
@@ -4,15 +4,16 @@ import (
|
||||
database_wiiu "github.com/PretendoNetwork/friends-secure/database/wiiu"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
|
||||
)
|
||||
|
||||
func UpdateComment(err error, client *nex.Client, callID uint32, comment *friends_wiiu.Comment) {
|
||||
func UpdateComment(err error, client *nex.Client, callID uint32, comment *friends_wiiu_types.Comment) {
|
||||
// TODO: Do something with this
|
||||
|
||||
changed := database_wiiu.UpdateUserComment(client.PID(), comment.Contents)
|
||||
|
||||
rmcResponseStream := nex.NewStreamOut(globals.NEXServer)
|
||||
rmcResponseStream := nex.NewStreamOut(globals.SecureServer)
|
||||
|
||||
rmcResponseStream.WriteUInt64LE(changed)
|
||||
|
||||
@@ -34,5 +35,5 @@ func UpdateComment(err error, client *nex.Client, callID uint32, comment *friend
|
||||
responsePacket.AddFlag(nex.FlagNeedsAck)
|
||||
responsePacket.AddFlag(nex.FlagReliable)
|
||||
|
||||
globals.NEXServer.Send(responsePacket)
|
||||
globals.SecureServer.Send(responsePacket)
|
||||
}
|
||||
|
||||
@@ -4,10 +4,11 @@ import (
|
||||
database_wiiu "github.com/PretendoNetwork/friends-secure/database/wiiu"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
|
||||
)
|
||||
|
||||
func UpdatePreference(err error, client *nex.Client, callID uint32, principalPreference *friends_wiiu.PrincipalPreference) {
|
||||
func UpdatePreference(err error, client *nex.Client, callID uint32, principalPreference *friends_wiiu_types.PrincipalPreference) {
|
||||
database_wiiu.UpdateUserPrincipalPreference(client.PID(), principalPreference)
|
||||
|
||||
rmcResponse := nex.NewRMCResponse(friends_wiiu.ProtocolID, callID)
|
||||
@@ -26,5 +27,5 @@ func UpdatePreference(err error, client *nex.Client, callID uint32, principalPre
|
||||
responsePacket.AddFlag(nex.FlagNeedsAck)
|
||||
responsePacket.AddFlag(nex.FlagReliable)
|
||||
|
||||
globals.NEXServer.Send(responsePacket)
|
||||
globals.SecureServer.Send(responsePacket)
|
||||
}
|
||||
|
||||
@@ -5,10 +5,11 @@ import (
|
||||
notifications_wiiu "github.com/PretendoNetwork/friends-secure/notifications/wiiu"
|
||||
"github.com/PretendoNetwork/friends-secure/types"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
|
||||
)
|
||||
|
||||
func UpdatePresence(err error, client *nex.Client, callID uint32, presence *friends_wiiu.NintendoPresenceV2) {
|
||||
func UpdatePresence(err error, client *nex.Client, callID uint32, presence *friends_wiiu_types.NintendoPresenceV2) {
|
||||
pid := client.PID()
|
||||
|
||||
presence.Online = true // Force online status. I have no idea why this is always false
|
||||
@@ -45,5 +46,5 @@ func UpdatePresence(err error, client *nex.Client, callID uint32, presence *frie
|
||||
responsePacket.AddFlag(nex.FlagNeedsAck)
|
||||
responsePacket.AddFlag(nex.FlagReliable)
|
||||
|
||||
globals.NEXServer.Send(responsePacket)
|
||||
globals.SecureServer.Send(responsePacket)
|
||||
}
|
||||
|
||||
29
nex/register_common_authentication_server_protocols.go
Normal file
29
nex/register_common_authentication_server_protocols.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package nex
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
ticket_granting "github.com/PretendoNetwork/nex-protocols-common-go/ticket-granting"
|
||||
)
|
||||
|
||||
func registerCommonAuthenticationServerProtocols() {
|
||||
ticketGrantingProtocol := ticket_granting.NewCommonTicketGrantingProtocol(globals.AuthenticationServer)
|
||||
|
||||
secureStationURL := nex.NewStationURL("")
|
||||
secureStationURL.SetScheme("prudps")
|
||||
secureStationURL.SetAddress(os.Getenv("PN_FRIENDS_SECURE_SERVER_HOST"))
|
||||
secureStationURL.SetPort(os.Getenv("PN_FRIENDS_SECURE_SERVER_PORT"))
|
||||
secureStationURL.SetCID("1")
|
||||
secureStationURL.SetPID("2")
|
||||
secureStationURL.SetSID("1")
|
||||
secureStationURL.SetStream("10")
|
||||
secureStationURL.SetType("2")
|
||||
|
||||
ticketGrantingProtocol.SetSecureStationURL(secureStationURL)
|
||||
ticketGrantingProtocol.SetBuildName(serverBuildString)
|
||||
ticketGrantingProtocol.EnableInsecureLogin()
|
||||
|
||||
globals.AuthenticationServer.SetPasswordFromPIDFunction(globals.PasswordFromPID)
|
||||
}
|
||||
12
nex/register_common_secure_server_protocols.go
Normal file
12
nex/register_common_secure_server_protocols.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package nex
|
||||
|
||||
import (
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nex_secure_connection "github.com/PretendoNetwork/friends-secure/nex/secure-connection"
|
||||
secureconnection "github.com/PretendoNetwork/nex-protocols-common-go/secure-connection"
|
||||
)
|
||||
|
||||
func registerCommonSecureServerProtocols() {
|
||||
secureConnectionProtocol := secureconnection.NewCommonSecureConnectionProtocol(globals.SecureServer)
|
||||
secureConnectionProtocol.RegisterEx(nex_secure_connection.RegisterEx)
|
||||
}
|
||||
@@ -5,26 +5,19 @@ import (
|
||||
nex_account_management "github.com/PretendoNetwork/friends-secure/nex/account-management"
|
||||
nex_friends_3ds "github.com/PretendoNetwork/friends-secure/nex/friends-3ds"
|
||||
nex_friends_wiiu "github.com/PretendoNetwork/friends-secure/nex/friends-wiiu"
|
||||
nex_secure_connection "github.com/PretendoNetwork/friends-secure/nex/secure-connection"
|
||||
account_management "github.com/PretendoNetwork/nex-protocols-go/account-management"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends/3ds"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
secure_connection "github.com/PretendoNetwork/nex-protocols-go/secure-connection"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends-3ds"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu"
|
||||
)
|
||||
|
||||
func registerNEXProtocols() {
|
||||
secureConnectionProtocol := secure_connection.NewSecureConnectionProtocol(globals.NEXServer)
|
||||
accountManagementProtocol := account_management.NewAccountManagementProtocol(globals.NEXServer)
|
||||
friendsWiiUProtocol := friends_wiiu.NewFriendsWiiUProtocol(globals.NEXServer)
|
||||
friends3DSProtocol := friends_3ds.NewFriends3DSProtocol(globals.NEXServer)
|
||||
func registerSecureServerProtocols() {
|
||||
accountManagementProtocol := account_management.NewAccountManagementProtocol(globals.SecureServer)
|
||||
friendsWiiUProtocol := friends_wiiu.NewFriendsWiiUProtocol(globals.SecureServer)
|
||||
friends3DSProtocol := friends_3ds.NewFriends3DSProtocol(globals.SecureServer)
|
||||
|
||||
// Account Management protocol handles
|
||||
accountManagementProtocol.NintendoCreateAccount(nex_account_management.NintendoCreateAccount)
|
||||
|
||||
// Secure protocol handles
|
||||
secureConnectionProtocol.Register(nex_secure_connection.Register)
|
||||
secureConnectionProtocol.RegisterEx(nex_secure_connection.RegisterEx)
|
||||
|
||||
// Friends (WiiU) protocol handles
|
||||
friendsWiiUProtocol.UpdateAndGetAllInformation(nex_friends_wiiu.UpdateAndGetAllInformation)
|
||||
friendsWiiUProtocol.AddFriendRequest(nex_friends_wiiu.AddFriendRequest)
|
||||
@@ -1,48 +0,0 @@
|
||||
package nex_secure_connection
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
secure_connection "github.com/PretendoNetwork/nex-protocols-go/secure-connection"
|
||||
)
|
||||
|
||||
func Register(err error, client *nex.Client, callID uint32, stationUrls []*nex.StationURL) {
|
||||
localStation := stationUrls[0]
|
||||
|
||||
address := client.Address().IP.String()
|
||||
port := strconv.Itoa(client.Address().Port)
|
||||
|
||||
localStation.SetAddress(address)
|
||||
localStation.SetPort(port)
|
||||
|
||||
localStationURL := localStation.EncodeToString()
|
||||
|
||||
rmcResponseStream := nex.NewStreamOut(globals.NEXServer)
|
||||
|
||||
rmcResponseStream.WriteUInt32LE(0x10001) // Success
|
||||
rmcResponseStream.WriteUInt32LE(globals.NEXServer.ConnectionIDCounter().Increment())
|
||||
rmcResponseStream.WriteString(localStationURL)
|
||||
|
||||
rmcResponseBody := rmcResponseStream.Bytes()
|
||||
|
||||
// Build response packet
|
||||
rmcResponse := nex.NewRMCResponse(secure_connection.ProtocolID, callID)
|
||||
rmcResponse.SetSuccess(secure_connection.MethodRegister, rmcResponseBody)
|
||||
|
||||
rmcResponseBytes := rmcResponse.Bytes()
|
||||
|
||||
responsePacket, _ := nex.NewPacketV0(client, nil)
|
||||
|
||||
responsePacket.SetVersion(0)
|
||||
responsePacket.SetSource(0xA1)
|
||||
responsePacket.SetDestination(0xAF)
|
||||
responsePacket.SetType(nex.DataPacket)
|
||||
responsePacket.SetPayload(rmcResponseBytes)
|
||||
|
||||
responsePacket.AddFlag(nex.FlagNeedsAck)
|
||||
responsePacket.AddFlag(nex.FlagReliable)
|
||||
|
||||
globals.NEXServer.Send(responsePacket)
|
||||
}
|
||||
@@ -40,10 +40,11 @@ func RegisterEx(err error, client *nex.Client, callID uint32, stationUrls []*nex
|
||||
|
||||
localStationURL := localStation.EncodeToString()
|
||||
|
||||
rmcResponseStream := nex.NewStreamOut(globals.NEXServer)
|
||||
rmcResponseStream := nex.NewStreamOut(globals.SecureServer)
|
||||
|
||||
rmcResponseStream.WriteUInt32LE(0x10001) // Success
|
||||
rmcResponseStream.WriteUInt32LE(globals.NEXServer.ConnectionIDCounter().Increment())
|
||||
retval := nex.NewResultSuccess(nex.Errors.Core.Unknown)
|
||||
rmcResponseStream.WriteResult(retval)
|
||||
rmcResponseStream.WriteUInt32LE(globals.SecureServer.ConnectionIDCounter().Increment())
|
||||
rmcResponseStream.WriteString(localStationURL)
|
||||
|
||||
rmcResponseBody := rmcResponseStream.Bytes()
|
||||
@@ -65,5 +66,5 @@ func RegisterEx(err error, client *nex.Client, callID uint32, stationUrls []*nex
|
||||
responsePacket.AddFlag(nex.FlagNeedsAck)
|
||||
responsePacket.AddFlag(nex.FlagReliable)
|
||||
|
||||
globals.NEXServer.Send(responsePacket)
|
||||
globals.SecureServer.Send(responsePacket)
|
||||
}
|
||||
|
||||
@@ -15,16 +15,21 @@ import (
|
||||
_ "github.com/PretendoNetwork/nex-protocols-go"
|
||||
)
|
||||
|
||||
func StartNEXServer() {
|
||||
globals.NEXServer = nex.NewServer()
|
||||
globals.NEXServer.SetFragmentSize(900)
|
||||
globals.NEXServer.SetPRUDPVersion(0)
|
||||
globals.NEXServer.SetKerberosKeySize(16)
|
||||
globals.NEXServer.SetKerberosPassword(os.Getenv("PN_FRIENDS_CONFIG_KERBEROS_PASSWORD"))
|
||||
globals.NEXServer.SetPingTimeout(20) // Maybe too long?
|
||||
globals.NEXServer.SetAccessKey("ridfebb9")
|
||||
func StartSecureServer() {
|
||||
globals.SecureServer = nex.NewServer()
|
||||
globals.SecureServer.SetFragmentSize(900)
|
||||
globals.SecureServer.SetPRUDPVersion(0)
|
||||
globals.SecureServer.SetKerberosKeySize(16)
|
||||
globals.SecureServer.SetKerberosPassword(globals.KerberosPassword)
|
||||
globals.SecureServer.SetPingTimeout(20) // Maybe too long?
|
||||
globals.SecureServer.SetAccessKey("ridfebb9")
|
||||
globals.SecureServer.SetDefaultNEXVersion(&nex.NEXVersion{
|
||||
Major: 1,
|
||||
Minor: 1,
|
||||
Patch: 0,
|
||||
})
|
||||
|
||||
globals.NEXServer.On("Data", func(packet *nex.PacketV0) {
|
||||
globals.SecureServer.On("Data", func(packet *nex.PacketV0) {
|
||||
request := packet.RMCRequest()
|
||||
|
||||
fmt.Println("==Friends - Secure==")
|
||||
@@ -33,7 +38,7 @@ func StartNEXServer() {
|
||||
fmt.Println("====================")
|
||||
})
|
||||
|
||||
globals.NEXServer.On("Kick", func(packet *nex.PacketV0) {
|
||||
globals.SecureServer.On("Kick", func(packet *nex.PacketV0) {
|
||||
pid := packet.Sender().PID()
|
||||
|
||||
if globals.ConnectedUsers[pid] == nil {
|
||||
@@ -56,13 +61,14 @@ func StartNEXServer() {
|
||||
fmt.Println("Leaving (Kick)")
|
||||
})
|
||||
|
||||
globals.NEXServer.On("Disconnect", func(packet *nex.PacketV0) {
|
||||
globals.SecureServer.On("Disconnect", func(packet *nex.PacketV0) {
|
||||
fmt.Println("Leaving (Disconnect)")
|
||||
})
|
||||
|
||||
globals.NEXServer.On("Connect", connect)
|
||||
globals.SecureServer.On("Connect", connect)
|
||||
|
||||
registerNEXProtocols()
|
||||
registerCommonSecureServerProtocols()
|
||||
registerSecureServerProtocols()
|
||||
|
||||
globals.NEXServer.Listen(":60001")
|
||||
globals.SecureServer.Listen(fmt.Sprintf(":%s", os.Getenv("PN_FRIENDS_SECURE_SERVER_PORT")))
|
||||
}
|
||||
@@ -5,20 +5,21 @@ import (
|
||||
"github.com/PretendoNetwork/friends-secure/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"
|
||||
)
|
||||
|
||||
func SendCommentUpdate(client *nex.Client, comment string) {
|
||||
notificationEvent := nintendo_notifications.NewNintendoNotificationEventGeneral()
|
||||
notificationEvent := nintendo_notifications_types.NewNintendoNotificationEventGeneral()
|
||||
notificationEvent.StrParam = comment
|
||||
|
||||
eventObject := nintendo_notifications.NewNintendoNotificationEvent()
|
||||
eventObject := nintendo_notifications_types.NewNintendoNotificationEvent()
|
||||
eventObject.Type = 3
|
||||
eventObject.SenderPID = client.PID()
|
||||
eventObject.DataHolder = nex.NewDataHolder()
|
||||
eventObject.DataHolder.SetTypeName("NintendoNotificationEventGeneral")
|
||||
eventObject.DataHolder.SetObjectData(notificationEvent)
|
||||
|
||||
stream := nex.NewStreamOut(globals.NEXServer)
|
||||
stream := nex.NewStreamOut(globals.SecureServer)
|
||||
eventObjectBytes := eventObject.Bytes(stream)
|
||||
|
||||
rmcRequest := nex.NewRMCRequest()
|
||||
@@ -47,7 +48,7 @@ func SendCommentUpdate(client *nex.Client, comment string) {
|
||||
requestPacket.AddFlag(nex.FlagNeedsAck)
|
||||
requestPacket.AddFlag(nex.FlagReliable)
|
||||
|
||||
globals.NEXServer.Send(requestPacket)
|
||||
globals.SecureServer.Send(requestPacket)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,19 +4,20 @@ import (
|
||||
database_3ds "github.com/PretendoNetwork/friends-secure/database/3ds"
|
||||
"github.com/PretendoNetwork/friends-secure/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"
|
||||
nintendo_notifications "github.com/PretendoNetwork/nex-protocols-go/nintendo-notifications"
|
||||
nintendo_notifications_types "github.com/PretendoNetwork/nex-protocols-go/nintendo-notifications/types"
|
||||
)
|
||||
|
||||
func SendFavoriteUpdate(client *nex.Client, gameKey *friends_3ds.GameKey) {
|
||||
eventObject := nintendo_notifications.NewNintendoNotificationEvent()
|
||||
func SendFavoriteUpdate(client *nex.Client, 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)
|
||||
|
||||
stream := nex.NewStreamOut(globals.NEXServer)
|
||||
stream := nex.NewStreamOut(globals.SecureServer)
|
||||
eventObjectBytes := eventObject.Bytes(stream)
|
||||
|
||||
rmcRequest := nex.NewRMCRequest()
|
||||
@@ -45,7 +46,7 @@ func SendFavoriteUpdate(client *nex.Client, gameKey *friends_3ds.GameKey) {
|
||||
requestPacket.AddFlag(nex.FlagNeedsAck)
|
||||
requestPacket.AddFlag(nex.FlagReliable)
|
||||
|
||||
globals.NEXServer.Send(requestPacket)
|
||||
globals.SecureServer.Send(requestPacket)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,22 +4,23 @@ import (
|
||||
"github.com/PretendoNetwork/friends-secure/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"
|
||||
)
|
||||
|
||||
func SendFriendshipCompleted(client *nex.Client, friendPID uint32, senderPID uint32) {
|
||||
notificationEvent := nintendo_notifications.NewNintendoNotificationEventGeneral()
|
||||
notificationEvent := nintendo_notifications_types.NewNintendoNotificationEventGeneral()
|
||||
notificationEvent.U32Param = 0
|
||||
notificationEvent.U64Param1 = 0
|
||||
notificationEvent.U64Param2 = uint64(friendPID)
|
||||
|
||||
eventObject := nintendo_notifications.NewNintendoNotificationEvent()
|
||||
eventObject := nintendo_notifications_types.NewNintendoNotificationEvent()
|
||||
eventObject.Type = 7
|
||||
eventObject.SenderPID = senderPID
|
||||
eventObject.DataHolder = nex.NewDataHolder()
|
||||
eventObject.DataHolder.SetTypeName("NintendoNotificationEventGeneral")
|
||||
eventObject.DataHolder.SetObjectData(notificationEvent)
|
||||
|
||||
stream := nex.NewStreamOut(globals.NEXServer)
|
||||
stream := nex.NewStreamOut(globals.SecureServer)
|
||||
eventObjectBytes := eventObject.Bytes(stream)
|
||||
|
||||
rmcRequest := nex.NewRMCRequest()
|
||||
@@ -41,5 +42,5 @@ func SendFriendshipCompleted(client *nex.Client, friendPID uint32, senderPID uin
|
||||
requestPacket.AddFlag(nex.FlagNeedsAck)
|
||||
requestPacket.AddFlag(nex.FlagReliable)
|
||||
|
||||
globals.NEXServer.Send(requestPacket)
|
||||
globals.SecureServer.Send(requestPacket)
|
||||
}
|
||||
|
||||
@@ -5,19 +5,20 @@ import (
|
||||
"github.com/PretendoNetwork/friends-secure/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"
|
||||
)
|
||||
|
||||
func SendMiiUpdateNotification(client *nex.Client) {
|
||||
notificationEvent := nintendo_notifications.NewNintendoNotificationEventGeneral()
|
||||
notificationEvent := nintendo_notifications_types.NewNintendoNotificationEventGeneral()
|
||||
|
||||
eventObject := nintendo_notifications.NewNintendoNotificationEvent()
|
||||
eventObject := nintendo_notifications_types.NewNintendoNotificationEvent()
|
||||
eventObject.Type = 5
|
||||
eventObject.SenderPID = client.PID()
|
||||
eventObject.DataHolder = nex.NewDataHolder()
|
||||
eventObject.DataHolder.SetTypeName("NintendoNotificationEventGeneral")
|
||||
eventObject.DataHolder.SetObjectData(notificationEvent)
|
||||
|
||||
stream := nex.NewStreamOut(globals.NEXServer)
|
||||
stream := nex.NewStreamOut(globals.SecureServer)
|
||||
eventObjectBytes := eventObject.Bytes(stream)
|
||||
|
||||
rmcRequest := nex.NewRMCRequest()
|
||||
@@ -46,7 +47,7 @@ func SendMiiUpdateNotification(client *nex.Client) {
|
||||
requestPacket.AddFlag(nex.FlagNeedsAck)
|
||||
requestPacket.AddFlag(nex.FlagReliable)
|
||||
|
||||
globals.NEXServer.Send(requestPacket)
|
||||
globals.SecureServer.Send(requestPacket)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,19 +4,20 @@ import (
|
||||
database_3ds "github.com/PretendoNetwork/friends-secure/database/3ds"
|
||||
"github.com/PretendoNetwork/friends-secure/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"
|
||||
nintendo_notifications "github.com/PretendoNetwork/nex-protocols-go/nintendo-notifications"
|
||||
nintendo_notifications_types "github.com/PretendoNetwork/nex-protocols-go/nintendo-notifications/types"
|
||||
)
|
||||
|
||||
func SendPresenceUpdate(client *nex.Client, presence *friends_3ds.NintendoPresence) {
|
||||
eventObject := nintendo_notifications.NewNintendoNotificationEvent()
|
||||
func SendPresenceUpdate(client *nex.Client, 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)
|
||||
|
||||
stream := nex.NewStreamOut(globals.NEXServer)
|
||||
stream := nex.NewStreamOut(globals.SecureServer)
|
||||
eventObjectBytes := eventObject.Bytes(stream)
|
||||
|
||||
rmcRequest := nex.NewRMCRequest()
|
||||
@@ -46,7 +47,7 @@ func SendPresenceUpdate(client *nex.Client, presence *friends_3ds.NintendoPresen
|
||||
requestPacket.AddFlag(nex.FlagNeedsAck)
|
||||
requestPacket.AddFlag(nex.FlagReliable)
|
||||
|
||||
globals.NEXServer.Send(requestPacket)
|
||||
globals.SecureServer.Send(requestPacket)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"github.com/PretendoNetwork/friends-secure/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"
|
||||
)
|
||||
|
||||
func SendUserWentOfflineGlobally(client *nex.Client) {
|
||||
@@ -16,16 +17,16 @@ func SendUserWentOfflineGlobally(client *nex.Client) {
|
||||
}
|
||||
|
||||
func SendUserWentOffline(client *nex.Client, pid uint32) {
|
||||
notificationEvent := nintendo_notifications.NewNintendoNotificationEventGeneral()
|
||||
notificationEvent := nintendo_notifications_types.NewNintendoNotificationEventGeneral()
|
||||
|
||||
eventObject := nintendo_notifications.NewNintendoNotificationEvent()
|
||||
eventObject := nintendo_notifications_types.NewNintendoNotificationEvent()
|
||||
eventObject.Type = 10
|
||||
eventObject.SenderPID = client.PID()
|
||||
eventObject.DataHolder = nex.NewDataHolder()
|
||||
eventObject.DataHolder.SetTypeName("NintendoNotificationEventGeneral")
|
||||
eventObject.DataHolder.SetObjectData(notificationEvent)
|
||||
|
||||
stream := nex.NewStreamOut(globals.NEXServer)
|
||||
stream := nex.NewStreamOut(globals.SecureServer)
|
||||
eventObjectBytes := eventObject.Bytes(stream)
|
||||
|
||||
rmcRequest := nex.NewRMCRequest()
|
||||
@@ -50,6 +51,6 @@ func SendUserWentOffline(client *nex.Client, pid uint32) {
|
||||
requestPacket.AddFlag(nex.FlagNeedsAck)
|
||||
requestPacket.AddFlag(nex.FlagReliable)
|
||||
|
||||
globals.NEXServer.Send(requestPacket)
|
||||
globals.SecureServer.Send(requestPacket)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,19 +3,20 @@ package notifications_wiiu
|
||||
import (
|
||||
"github.com/PretendoNetwork/friends-secure/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"
|
||||
nintendo_notifications "github.com/PretendoNetwork/nex-protocols-go/nintendo-notifications"
|
||||
nintendo_notifications_types "github.com/PretendoNetwork/nex-protocols-go/nintendo-notifications/types"
|
||||
)
|
||||
|
||||
func SendFriendRequest(client *nex.Client, friendRequestNotificationData *friends_wiiu.FriendRequest) {
|
||||
eventObject := nintendo_notifications.NewNintendoNotificationEvent()
|
||||
func SendFriendRequest(client *nex.Client, 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)
|
||||
|
||||
stream := nex.NewStreamOut(globals.NEXServer)
|
||||
stream := nex.NewStreamOut(globals.SecureServer)
|
||||
eventObjectBytes := eventObject.Bytes(stream)
|
||||
|
||||
rmcRequest := nex.NewRMCRequest()
|
||||
@@ -37,5 +38,5 @@ func SendFriendRequest(client *nex.Client, friendRequestNotificationData *friend
|
||||
requestPacket.AddFlag(nex.FlagNeedsAck)
|
||||
requestPacket.AddFlag(nex.FlagReliable)
|
||||
|
||||
globals.NEXServer.Send(requestPacket)
|
||||
globals.SecureServer.Send(requestPacket)
|
||||
}
|
||||
|
||||
@@ -3,19 +3,20 @@ package notifications_wiiu
|
||||
import (
|
||||
"github.com/PretendoNetwork/friends-secure/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"
|
||||
nintendo_notifications "github.com/PretendoNetwork/nex-protocols-go/nintendo-notifications"
|
||||
nintendo_notifications_types "github.com/PretendoNetwork/nex-protocols-go/nintendo-notifications/types"
|
||||
)
|
||||
|
||||
func SendFriendRequestAccepted(client *nex.Client, friendInfo *friends_wiiu.FriendInfo) {
|
||||
eventObject := nintendo_notifications.NewNintendoNotificationEvent()
|
||||
func SendFriendRequestAccepted(client *nex.Client, 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)
|
||||
|
||||
stream := nex.NewStreamOut(globals.NEXServer)
|
||||
stream := nex.NewStreamOut(globals.SecureServer)
|
||||
eventObjectBytes := eventObject.Bytes(stream)
|
||||
|
||||
rmcRequest := nex.NewRMCRequest()
|
||||
@@ -37,5 +38,5 @@ func SendFriendRequestAccepted(client *nex.Client, friendInfo *friends_wiiu.Frie
|
||||
requestPacket.AddFlag(nex.FlagNeedsAck)
|
||||
requestPacket.AddFlag(nex.FlagReliable)
|
||||
|
||||
globals.NEXServer.Send(requestPacket)
|
||||
globals.SecureServer.Send(requestPacket)
|
||||
}
|
||||
|
||||
@@ -4,19 +4,20 @@ import (
|
||||
"github.com/PretendoNetwork/friends-secure/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"
|
||||
)
|
||||
|
||||
func SendFriendshipRemoved(client *nex.Client, senderPID uint32) {
|
||||
nintendoNotificationEventGeneral := nintendo_notifications.NewNintendoNotificationEventGeneral()
|
||||
nintendoNotificationEventGeneral := nintendo_notifications_types.NewNintendoNotificationEventGeneral()
|
||||
|
||||
eventObject := nintendo_notifications.NewNintendoNotificationEvent()
|
||||
eventObject := nintendo_notifications_types.NewNintendoNotificationEvent()
|
||||
eventObject.Type = 26
|
||||
eventObject.SenderPID = senderPID
|
||||
eventObject.DataHolder = nex.NewDataHolder()
|
||||
eventObject.DataHolder.SetTypeName("NintendoNotificationEventGeneral")
|
||||
eventObject.DataHolder.SetObjectData(nintendoNotificationEventGeneral)
|
||||
|
||||
stream := nex.NewStreamOut(globals.NEXServer)
|
||||
stream := nex.NewStreamOut(globals.SecureServer)
|
||||
stream.WriteStructure(eventObject)
|
||||
|
||||
rmcRequest := nex.NewRMCRequest()
|
||||
@@ -38,5 +39,5 @@ func SendFriendshipRemoved(client *nex.Client, senderPID uint32) {
|
||||
requestPacket.AddFlag(nex.FlagNeedsAck)
|
||||
requestPacket.AddFlag(nex.FlagReliable)
|
||||
|
||||
globals.NEXServer.Send(requestPacket)
|
||||
globals.SecureServer.Send(requestPacket)
|
||||
}
|
||||
|
||||
@@ -6,19 +6,20 @@ import (
|
||||
database_wiiu "github.com/PretendoNetwork/friends-secure/database/wiiu"
|
||||
"github.com/PretendoNetwork/friends-secure/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"
|
||||
nintendo_notifications "github.com/PretendoNetwork/nex-protocols-go/nintendo-notifications"
|
||||
nintendo_notifications_types "github.com/PretendoNetwork/nex-protocols-go/nintendo-notifications/types"
|
||||
)
|
||||
|
||||
func SendPresenceUpdate(presence *friends_wiiu.NintendoPresenceV2) {
|
||||
eventObject := nintendo_notifications.NewNintendoNotificationEvent()
|
||||
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)
|
||||
|
||||
stream := nex.NewStreamOut(globals.NEXServer)
|
||||
stream := nex.NewStreamOut(globals.SecureServer)
|
||||
eventObjectBytes := eventObject.Bytes(stream)
|
||||
|
||||
rmcRequest := nex.NewRMCRequest()
|
||||
@@ -70,7 +71,7 @@ func SendPresenceUpdate(presence *friends_wiiu.NintendoPresenceV2) {
|
||||
requestPacket.AddFlag(nex.FlagNeedsAck)
|
||||
requestPacket.AddFlag(nex.FlagReliable)
|
||||
|
||||
globals.NEXServer.Send(requestPacket)
|
||||
globals.SecureServer.Send(requestPacket)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"github.com/PretendoNetwork/friends-secure/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"
|
||||
)
|
||||
|
||||
func SendUserWentOfflineGlobally(client *nex.Client) {
|
||||
@@ -21,21 +22,21 @@ func SendUserWentOffline(client *nex.Client, pid uint32) {
|
||||
lastOnline := nex.NewDateTime(0)
|
||||
lastOnline.FromTimestamp(time.Now())
|
||||
|
||||
nintendoNotificationEventGeneral := nintendo_notifications.NewNintendoNotificationEventGeneral()
|
||||
nintendoNotificationEventGeneral := nintendo_notifications_types.NewNintendoNotificationEventGeneral()
|
||||
|
||||
nintendoNotificationEventGeneral.U32Param = 0
|
||||
nintendoNotificationEventGeneral.U64Param1 = 0
|
||||
nintendoNotificationEventGeneral.U64Param2 = lastOnline.Value()
|
||||
nintendoNotificationEventGeneral.StrParam = ""
|
||||
|
||||
eventObject := nintendo_notifications.NewNintendoNotificationEvent()
|
||||
eventObject := nintendo_notifications_types.NewNintendoNotificationEvent()
|
||||
eventObject.Type = 10
|
||||
eventObject.SenderPID = client.PID()
|
||||
eventObject.DataHolder = nex.NewDataHolder()
|
||||
eventObject.DataHolder.SetTypeName("NintendoNotificationEventGeneral")
|
||||
eventObject.DataHolder.SetObjectData(nintendoNotificationEventGeneral)
|
||||
|
||||
stream := nex.NewStreamOut(globals.NEXServer)
|
||||
stream := nex.NewStreamOut(globals.SecureServer)
|
||||
stream.WriteStructure(eventObject)
|
||||
|
||||
rmcRequest := nex.NewRMCRequest()
|
||||
@@ -60,6 +61,6 @@ func SendUserWentOffline(client *nex.Client, pid uint32) {
|
||||
requestPacket.AddFlag(nex.FlagNeedsAck)
|
||||
requestPacket.AddFlag(nex.FlagReliable)
|
||||
|
||||
globals.NEXServer.Send(requestPacket)
|
||||
globals.SecureServer.Send(requestPacket)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,17 +2,17 @@ package types
|
||||
|
||||
import (
|
||||
"github.com/PretendoNetwork/nex-go"
|
||||
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/friends/3ds"
|
||||
friends_wiiu "github.com/PretendoNetwork/nex-protocols-go/friends/wiiu"
|
||||
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/friends-3ds/types"
|
||||
friends_wiiu_types "github.com/PretendoNetwork/nex-protocols-go/friends-wiiu/types"
|
||||
)
|
||||
|
||||
type ConnectedUser struct {
|
||||
PID uint32
|
||||
Platform Platform
|
||||
Client *nex.Client
|
||||
NNAInfo *friends_wiiu.NNAInfo
|
||||
Presence *friends_3ds.NintendoPresence
|
||||
PresenceV2 *friends_wiiu.NintendoPresenceV2
|
||||
NNAInfo *friends_wiiu_types.NNAInfo
|
||||
Presence *friends_3ds_types.NintendoPresence
|
||||
PresenceV2 *friends_wiiu_types.NintendoPresenceV2
|
||||
}
|
||||
|
||||
func NewConnectedUser() *ConnectedUser {
|
||||
|
||||
@@ -2,7 +2,7 @@ package types
|
||||
|
||||
import (
|
||||
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"
|
||||
)
|
||||
|
||||
// FriendUser represents a user connected to the friends server
|
||||
@@ -10,13 +10,13 @@ import (
|
||||
type FriendUser struct {
|
||||
NNID string
|
||||
PID uint32
|
||||
Comment *friends_wiiu.Comment
|
||||
FriendRequestsOut []*friends_wiiu.FriendRequest
|
||||
FriendRequestsIn []*friends_wiiu.FriendRequest
|
||||
BlockedUsers []*friends_wiiu.BlacklistedPrincipal
|
||||
Comment *friends_wiiu_types.Comment
|
||||
FriendRequestsOut []*friends_wiiu_types.FriendRequest
|
||||
FriendRequestsIn []*friends_wiiu_types.FriendRequest
|
||||
BlockedUsers []*friends_wiiu_types.BlacklistedPrincipal
|
||||
LastOnline *nex.DateTime
|
||||
ActiveTitle *friends_wiiu.GameKey
|
||||
Notifications []*friends_wiiu.PersistentNotification
|
||||
ActiveTitle *friends_wiiu_types.GameKey
|
||||
Notifications []*friends_wiiu_types.PersistentNotification
|
||||
}
|
||||
|
||||
func (friendUser *FriendUser) FromPID(pid uint32) {
|
||||
|
||||
Reference in New Issue
Block a user