Reusable implementations of NEX methods found in many servers
Find a file
Daniel López Guimaraes 7b42e6a794
chore: Update go modules
2024-11-04 12:05:06 +00:00
datastore feat!(datastore): Add requesting PID to GetObjectInfosByDataStoreSearchParam 2024-05-03 22:27:09 +10:00
globals chore: Remove debug log from SendNotificationEvent 2024-11-04 12:04:12 +00:00
match-making fix(match-making): Change host when host disconnects 2024-10-03 20:13:33 +01:00
match-making-ext feat: Add MatchmakingManager abstraction 2024-07-03 02:08:45 +01:00
matchmake-extension fix(matchmake-extension): Only use attribute 1 on selection method 2024-09-30 17:01:24 +01:00
nat-traversal chore: Update module version to v2 2024-04-07 23:56:20 +01:00
ranking chore: Update module version to v2 2024-04-07 23:56:20 +01:00
secure-connection feat(secure-connection): Add methods for NEX 1 2024-06-30 02:12:07 +01:00
ticket-granting ticket-granting: Set the StructureVersion for NEX >3.5 2024-04-18 16:42:51 +10:00
utility chore: Update module version to v2 2024-04-07 23:56:20 +01:00
.gitignore Updated .gitignore 2022-08-29 18:13:11 -04:00
go.mod chore: Update go modules 2024-11-04 12:05:06 +00:00
go.sum chore: Update go modules 2024-11-04 12:05:06 +00:00
LICENSE Create LICENSE 2022-08-13 20:18:19 -04:00
README.md chore: Update module version to v2 2024-04-07 23:56:20 +01:00

NEX Protocols Common Go

NEX protocols used by many games with premade handlers and a high level API

GoDoc

Other NEX libraries

nex-go - Barebones NEX/PRUDP server implementation

nex-protocols-go - NEX protocol definitions

Install

go get github.com/PretendoNetwork/nex-protocols-common-go/v2

Usage

nex-protocols-common-go provides a higher level API than the NEX Protocols Go module. This module handles many of the more common protcols and methods used shared by many servers. Instead of working directly with the NEX server, this module exposes an API for defining helper functions to provide the module with the data it needs to run

Example, friends (Wii U) authentication server

For a complete example, see the complete Friends Server, and other game servers

package main

import (
	"fmt"
	"os"

	"github.com/PretendoNetwork/nex-go/v2"
	ticket_granting "github.com/PretendoNetwork/nex-protocols-go/v2/ticket-granting"
	common_ticket_granting "github.com/PretendoNetwork/nex-protocols-common-go/v2/ticket-granting"
)

var nexServer *nex.PRUDPServer

func main() {
	nexServer := nex.NewPRUDPServer()

	endpoint := nex.NewPRUDPEndPoint(1)
	endpoint.ServerAccount = nex.NewAccount(types.NewPID(1), "Quazal Authentication", "password"))
	endpoint.AccountDetailsByPID = accountDetailsByPID
	endpoint.AccountDetailsByUsername = accountDetailsByUsername

	endpoint.OnData(func(packet nex.PacketInterface) {
		request := packet.RMCMessage()

		fmt.Println("==Friends - Auth==")
		fmt.Printf("Protocol ID: %#v\n", request.ProtocolID)
		fmt.Printf("Method ID: %#v\n", request.MethodID)
		fmt.Println("==================")
	})

	nexServer.SetFragmentSize(962)
	nexServer.LibraryVersions.SetDefault(nex.NewLibraryVersion(1, 1, 0))
	nexServer.SessionKeyLength = 16
	nexServer.AccessKey = "ridfebb9"

	ticketGrantingProtocol := ticket_granting.NewProtocol(endpoint)
	endpoint.RegisterServiceProtocol(ticketGrantingProtocol)
	commonTicketGrantingProtocol := common_ticket_granting.NewCommonProtocol(ticketGrantingProtocol)

	secureStationURL := nex.NewStationURL("")
	secureStationURL.Scheme = "prudps"
	secureStationURL.Fields.Set("address", os.Getenv("SECURE_SERVER_LOCATION"))
	secureStationURL.Fields.Set("port", os.Getenv("SECURE_SERVER_PORT"))
	secureStationURL.Fields.Set("CID", "1")
	secureStationURL.Fields.Set("PID", "2")
	secureStationURL.Fields.Set("sid", "1")
	secureStationURL.Fields.Set("stream", "10")
	secureStationURL.Fields.Set("type", "2")

	commonTicketGrantingProtocol.SecureStationURL = secureStationURL
	commonTicketGrantingProtocol.BuildName = "Pretendo Friends Auth"

	nexServer.Listen(60000)
}