Reusable implementations of NEX methods found in many servers
Find a file
2023-08-29 13:49:14 -04:00
globals Improved matchmake criteria searching 2023-08-27 18:21:16 -04:00
matchmake-extension Added JoinMatchmakeSessionWithParam 2023-08-28 05:35:14 -04:00
matchmaking Added FindBySingleID 2023-08-28 05:03:49 -04:00
matchmaking-ext Update go modules and proper error handling 2023-08-06 01:44:42 +01:00
nat-traversal Improved NAT and StationURL handling 2023-08-15 06:49:48 -04:00
secure-connection Improved NAT and StationURL handling 2023-08-15 06:49:48 -04:00
ticket-granting Check err on rand.Read(sessionKey) 2023-08-07 13:09:03 -04:00
.gitignore Updated .gitignore 2022-08-29 18:13:11 -04:00
go.mod Updated Go modules 2023-08-29 13:49:14 -04:00
go.sum Updated Go modules 2023-08-29 13:49:14 -04:00
LICENSE Create LICENSE 2022-08-13 20:18:19 -04:00
README.md Updated NEX library versions 2023-04-07 21:03:47 -04: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

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 Authentication Server, and other game servers

package main

import (
	"fmt"
	"os"

	"github.com/PretendoNetwork/nex-go"
	"github.com/PretendoNetwork/nex-protocols-common-go/authentication"
)

var nexServer *nex.Server

func main() {
	nexServer = nex.NewServer()
	nexServer.SetPRUDPVersion(0)
	nexServer.SetKerberosKeySize(16)
	nexServer.SetKerberosPassword(os.Getenv("KERBEROS_PASSWORD"))
	nexServer.SetAccessKey("ridfebb9")

	nexServer.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("==================")
	})

	authenticationProtocol := authentication.NewCommonAuthenticationProtocol(nexServer)

	secureStationURL := nex.NewStationURL("")
	secureStationURL.SetScheme("prudps")
	secureStationURL.SetAddress(os.Getenv("SECURE_SERVER_LOCATION"))
	secureStationURL.SetPort(os.Getenv("SECURE_SERVER_PORT"))
	secureStationURL.SetCID("1")
	secureStationURL.SetPID("2")
	secureStationURL.SetSID("1")
	secureStationURL.SetStream("10")
	secureStationURL.SetType("2")

	authenticationProtocol.SetSecureStationURL(secureStationURL)
	authenticationProtocol.SetBuildName("Pretendo Friends Auth")
	authenticationProtocol.SetPasswordFromPIDFunction(passwordFromPID)

	nexServer.Listen(":60000")
}