Barebones PRUDP/NEX server library written in Go
Find a file
2024-01-25 17:35:00 +00:00
compression prudp: completely redo virtual connections 2024-01-15 15:01:26 -05:00
encryption encryption: updated RC4 Godoc comment 2024-01-15 15:08:17 -05:00
test update: added new Error type which conforms to the error interface 2024-01-24 14:27:17 -05:00
types types: add nil and type ID checks to Variant 2024-01-24 15:57:48 -05:00
.gitignore Updated .gitignore 2022-08-29 18:06:53 -04:00
.golangci.yml Added golangci-lint config for aggregated linting 2022-12-31 13:16:55 -05:00
account.go prudp: rework Kerberos ticket generation to use user accounts properly 2024-01-24 12:42:11 -05:00
byte_stream_in.go streams: added ByteStreamSettings 2023-12-31 23:51:18 -05:00
byte_stream_out.go streams: added ByteStreamSettings 2023-12-31 23:51:18 -05:00
byte_stream_settings.go streams: added ByteStreamSettings 2023-12-31 23:51:18 -05:00
client_interface.go expanded all types into dedicated files and made the stream API generic 2023-12-23 13:03:32 -05:00
counter.go total rewrite 2023-11-10 01:28:25 -05:00
error.go update: added new Error type which conforms to the error interface 2024-01-24 14:27:17 -05:00
go.mod prudp: support LZO compressed payloads 2023-12-15 16:54:52 -05:00
go.sum prudp: support LZO compressed payloads 2023-12-15 16:54:52 -05:00
hpp_client.go expanded all types into dedicated files and made the stream API generic 2023-12-23 13:03:32 -05:00
hpp_packet.go prudp: rework Kerberos ticket generation to use user accounts properly 2024-01-24 12:42:11 -05:00
hpp_server.go update: added RegisterServiceProtocol to HPP and PRUDP servers 2024-01-24 16:40:38 -05:00
init.go chore: rename errors to result codes 2024-01-24 13:19:23 -05:00
kerberos.go prudp: removed unnecessary getters/setters 2024-01-24 13:08:49 -05:00
library_version.go total rewrite 2023-11-10 01:28:25 -05:00
LICENSE Create LICENSE 2022-08-13 20:16:23 -04:00
mutex_map.go added FindClientByConnectionID field on PRUDPServer 2023-11-12 01:28:44 -05:00
packet_interface.go total rewrite 2023-11-10 01:28:25 -05:00
prudp_connection.go prudp: added StationURLs to PRUDPConnection 2024-01-22 10:43:38 -05:00
prudp_endpoint.go prudp: DefaultstreamSettings -> DefaultStreamSettings 2024-01-25 17:35:00 +00:00
prudp_packet.go encryption: added QuazalRC4 2024-01-15 15:07:57 -05:00
prudp_packet_flags.go total rewrite 2023-11-10 01:28:25 -05:00
prudp_packet_interface.go prudp: completely redo virtual connections 2024-01-15 15:01:26 -05:00
prudp_packet_lite.go prudp: completely redo virtual connections 2024-01-15 15:01:26 -05:00
prudp_packet_types.go total rewrite 2023-11-10 01:28:25 -05:00
prudp_packet_v0.go prudp: completely redo virtual connections 2024-01-15 15:01:26 -05:00
prudp_packet_v1.go prudp: completely redo virtual connections 2024-01-15 15:01:26 -05:00
prudp_server.go update: added RegisterServiceProtocol to HPP and PRUDP servers 2024-01-24 16:40:38 -05:00
prudp_v0_settings.go prudp: added PRUDPV0Settings 2024-01-01 00:50:45 -05:00
README.md chore: update README 2024-01-15 15:13:43 -05:00
reliable_packet_substream_manager.go total rewrite 2023-11-10 01:28:25 -05:00
resend_scheduler.go prudp: completely redo virtual connections 2024-01-15 15:01:26 -05:00
result_codes.go chore: rename errors to result codes 2024-01-24 13:19:23 -05:00
rmc_message.go streams: rename streams to ByteStreams 2023-12-31 23:22:41 -05:00
server_interface.go update: added RegisterServiceProtocol to HPP and PRUDP servers 2024-01-24 16:40:38 -05:00
service_protocol.go update: added RegisterServiceProtocol to HPP and PRUDP servers 2024-01-24 16:40:38 -05:00
sliding_window.go prudp: completely redo virtual connections 2024-01-15 15:01:26 -05:00
socket_connection.go prudp: completely redo virtual connections 2024-01-15 15:01:26 -05:00
stream_settings.go chore: fix MaxPacketRetransmissions comment on StreamSettings 2024-01-24 13:10:42 -05:00
stream_type.go prudp: completely redo virtual connections 2024-01-15 15:01:26 -05:00
sum.go total rewrite 2023-11-10 01:28:25 -05:00
virtual_port.go prudp: remove TODO from virtual_port.go 2024-01-15 17:57:37 -05:00
websocket_server.go prudp: completely redo virtual connections 2024-01-15 15:01:26 -05:00

NEX Go

GoDoc

Overview

NEX is the networking library used by all 1st party, and many 3rd party, games on the Nintendo Wii U, 3DS, and Switch which have online features. The NEX library has many different parts, ranging from low level packet transport to higher level service implementations

This library implements the lowest level parts of NEX, the transport protocols. For other parts of the NEX stack, see the below libraries. For detailed information on NEX as a whole, see our wiki docs https://nintendo-wiki.pretendo.network/docs/nex

Install

go get github.com/PretendoNetwork/nex-go

Other NEX libraries

Quazal Rendez-Vous

Nintendo did not make NEX from scratch. NEX is largely based on an existing library called Rendez-Vous (QRV), made by Canadian software company Quazal. Quazal licensed Rendez-Vous out to many other companies, and was eventually bought out by Ubisoft. Because of this, QRV is seen in many many other games on all major platforms, especially Ubisoft

Nintendo modified Rendez-Vous somewhat heavily, simplifying the library/transport protocol quite a bit, and adding several custom services

While the main goal of this library is to support games which use the NEX variant of Rendez-Vous made by Nintendo, we also aim to be compatible with games using the original Rendez-Vous library. Due to the extensible nature of Rendez-Vous, many games may feature customizations much like NEX and have non-standard features/behavior. We do our best to support these cases, but there may be times where supporting all variations becomes untenable. In those cases, a fork of these libraries should be made instead if they require heavy modifications

Supported features

  • Quazal compatibility mode/settings
  • HPP servers (NEX over HTTP)
  • PRUDP servers
    • UDP transport
    • WebSocket transport (Experimental, largely untested)
    • PRUDPv0 packets
    • PRUDPv1 packets
    • PRUDPLite packets
  • Fragmented packet payloads
  • Packet retransmission
  • Reliable packets
  • Unreliable packets
  • Virtual ports
  • Packet compression
  • RMC
    • Request messages
    • Response messages
    • "Packed" encoded messages
    • "Packed" (extended) encoded messages
    • "Verbose" encoded messages
  • Kerberos authentication

Example

package main

import (
	"fmt"

	nex "github.com/PretendoNetwork/nex-go"
)

func main() {
	// Skeleton of a WiiU/3DS Friends server running on PRUDPv0 with a single endpoint

	authServer := nex.NewPRUDPServer() // The main PRUDP server
	endpoint := nex.NewPRUDPEndPoint(1) // A PRUDP endpoint for PRUDP connections to connect to. Bound to StreamID 1

	// Setup event handlers for the endpoint
	endpoint.OnData(func(packet nex.PacketInterface) {
		if packet, ok := packet.(nex.PRUDPPacketInterface); ok {
			request := packet.RMCMessage()

			fmt.Println("[AUTH]", request.ProtocolID, request.MethodID)

			if request.ProtocolID == 0xA { // TicketGrantingProtocol
				if request.MethodID == 0x1 { // TicketGrantingProtocol::Login
					handleLogin(packet)
				}

				if request.MethodID == 0x3 { // TicketGrantingProtocol::RequestTicket
					handleRequestTicket(packet)
				}
			}
		}
	})

	// Bind the endpoint to the server and configure it's settings
	authServer.BindPRUDPEndPoint(endpoint)
	authServer.SetFragmentSize(962)
	authServer.SetDefaultLibraryVersion(nex.NewLibraryVersion(1, 1, 0))
	authServer.SetKerberosPassword([]byte("password"))
	authServer.SetKerberosKeySize(16)
	authServer.SetAccessKey("ridfebb9")
	authServer.Listen(60000)
}