Reusable implementations of NEX methods found in many servers
Find a file
Jonathan Barrow d3e1504e17
Merge pull request #14 from shutterbug2000/pokegen6-pt1
Implement methods for Pokemon Gen6
2023-07-12 15:46:27 -04:00
globals Fix code review issues 2023-07-12 19:31:54 +00:00
matchmake-extension Apply suggestions from code review 2023-07-12 14:40:58 -05:00
matchmaking Moved to new protocol library format 2023-07-04 23:32:42 -04:00
matchmaking-ext Fix code review issues 2023-07-12 19:31:54 +00:00
nat-traversal Fix code review issues 2023-07-12 19:31:54 +00:00
secure-connection Fix time validation of Kerberos tickets 2023-06-15 19:35:24 +01:00
ticket-granting Disable insecure Login method by default 2023-07-05 01:03:06 -04:00
.gitignore Updated .gitignore 2022-08-29 18:13:11 -04:00
go.mod Update Go modules 2023-07-12 19:45:07 +00:00
go.sum Update Go modules 2023-07-12 19:45:07 +00: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")
}