Reusable implementations of NEX methods found in many servers
Find a file
Jonathan Barrow 5785c860f9
Merge pull request #13 from DaniElectra/login-version
Set  RVConnectionData time as DateTime
2023-06-21 17:20:14 -04:00
authentication Set RVConnectionData time to DateTime 2023-06-21 22:16:41 +01:00
globals Fix PR issues 2023-06-12 19:04:17 +01:00
matchmake-extension Update go modules 2023-06-15 19:06:08 +01:00
matchmaking Update go modules 2023-06-15 19:06:08 +01:00
matchmaking-ext Update go modules 2023-06-15 19:06:08 +01:00
nat-traversal Address PR issues 2023-06-06 21:29:47 +01:00
secure-connection Fix time validation of Kerberos tickets 2023-06-15 19:35:24 +01:00
.gitignore Updated .gitignore 2022-08-29 18:13:11 -04:00
go.mod Update go modules 2023-06-21 22:14:35 +01:00
go.sum Update go modules 2023-06-21 22:14:35 +01: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")
}