nex

package module
v0.0.0-...-41b88c9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 12, 2025 License: MPL-2.0 Imports: 15 Imported by: 0

README

Rendez-Vous server library written in Go

GoDoc

Install

go get github.com/Link-3DS/Rendez-Vous

Usage note

This module provides a barebones PRUDP server for use with titles using the Nintendo NEX library. It does not provide any support for titles using the original Rendez-Vous library developed by Quazal. This library only provides the low level packet data, as such it is recommended to use NEX Protocols Go to develop servers.

Usage
package main

import (
	"fmt"

	nex "github.com/Link-3DS/Rendez-Vous"
)

func main() {
	server := nex.NewServer() // Handle Server
	server.SetPrudpVersion(0) // PRUDP Version
	server.SetSignatureVersion(1) // Signature Version
	server.SetKerberosKeySize(16) // Kerberos Key Size
	server.SetAccessKey("ridfebb9") // Access Key

	server.On("Data", func(packet *nex.PacketV0) {
		// Handle Data Packet
	})

	server.Listen(":60000") // Listen UDP
}

Documentation

Index

Constants

View Source
const (
	// FlagAck is the ID for the PRUDP Ack Flag
	FlagAck uint16 = 0x1

	// FlagReliable is the ID for the PRUDP Reliable Flag
	FlagReliable uint16 = 0x2

	// FlagNeedsAck is the ID for the PRUDP NeedsAck Flag
	FlagNeedsAck uint16 = 0x4

	// FlagHasSize is the ID for the PRUDP HasSize Flag
	FlagHasSize uint16 = 0x8

	// FlagMultiAck is the ID for the PRUDP MultiAck Flag
	FlagMultiAck uint16 = 0x200
)
View Source
const (
	// SynPacket is the ID for the PRUDP Syn Packet type
	SynPacket uint16 = 0x0

	// ConnectPacket is the ID for the PRUDP Connect Packet type
	ConnectPacket uint16 = 0x1

	// DataPacket is the ID for the PRUDP Data Packet type
	DataPacket uint16 = 0x2

	// DisconnectPacket is the ID for the PRUDP Disconnect Packet type
	DisconnectPacket uint16 = 0x3

	// PingPacket is the ID for the PRUDP Ping Packet type
	PingPacket uint16 = 0x4
)

Variables

View Source
var ErrorNames = map[uint32]string{}
View Source
var OptionAllFunctions = 0xFFFFFFFF

OptionAllFunctions is used with OptionSupportedFunctions to support all methods

View Source
var OptionConnectionSignature uint8 = 1

OptionConnectionSignature is the ID for the Connection Signature option in PRUDP v1 packets

View Source
var OptionFragmentID uint8 = 2

OptionFragmentID is the ID for the Fragment ID option in PRUDP v1 packets

View Source
var OptionInitialSequenceID uint8 = 3

OptionInitialSequenceID is the ID for the initial sequence ID option in PRUDP v1 packets

View Source
var OptionMaxSubstreamID uint8 = 4

OptionMaxSubstreamID is the ID for the max substream ID option in PRUDP v1 packets

View Source
var OptionSupportedFunctions uint8 = 0

OptionSupportedFunctions is the ID for the Supported Functions option in PRUDP v1 packets

Functions

func ErrorNameFromCode

func ErrorNameFromCode(errorCode uint32) string

func InitErrorsData

func InitErrorsData()

func MD5Hash

func MD5Hash(text []byte) []byte

MD5Hash returns the MD5 hash of the input

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client represents a connected or non-connected PRUDP client

func NewClient

func NewClient(address *net.UDPAddr, server *Server) *Client

NewClient returns a new PRUDP client

func (*Client) Address

func (client *Client) Address() *net.UDPAddr

Address returns the clients UDP address

func (*Client) Cipher

func (client *Client) Cipher() *rc4.Cipher

Cipher returns the RC4 cipher stream for out-bound packets

func (*Client) ClientConnectionSignature

func (client *Client) ClientConnectionSignature() []byte

ClientConnectionSignature returns the clients client-side connection signature

func (*Client) ConnectionID

func (client *Client) ConnectionID() uint32

ConnectionID returns the clients Connection ID

func (*Client) Decipher

func (client *Client) Decipher() *rc4.Cipher

Decipher returns the RC4 cipher stream for in-bound packets

func (*Client) IncreasePingTimeoutTime

func (client *Client) IncreasePingTimeoutTime(seconds int)

IncreasePingTimeoutTime adds a number of seconds to the check timer

func (*Client) LocalStationUrl

func (client *Client) LocalStationUrl() string

LocalStationUrl returns the clients Local Station URL

func (*Client) PID

func (client *Client) PID() uint32

PID returns the clients NEX PID

func (*Client) Reset

func (client *Client) Reset()

Reset resets the Client to default values

func (*Client) SequenceIDCounterIn

func (client *Client) SequenceIDCounterIn() *Counter

SequenceIDCounterIn returns the clients packet SequenceID counter for incoming packets

func (*Client) SequenceIDCounterOut

func (client *Client) SequenceIDCounterOut() *Counter

SequenceIDCounterOut returns the clients packet SequenceID counter for out-going packets

func (*Client) Server

func (client *Client) Server() *Server

Server returns the server the client is currently connected to

func (*Client) ServerConnectionSignature

func (client *Client) ServerConnectionSignature() []byte

ServerConnectionSignature returns the clients server-side connection signature

func (*Client) SessionKey

func (client *Client) SessionKey() []byte

SessionKey returns the clients session key

func (*Client) SetClientConnectionSignature

func (client *Client) SetClientConnectionSignature(clientConnectionSignature []byte)

SetClientConnectionSignature sets the clients client-side connection signature

func (*Client) SetConnected

func (client *Client) SetConnected(connected bool)

SetConnected sets the clients connection status

func (*Client) SetConnectionID

func (client *Client) SetConnectionID(connectionID uint32)

SetConnectionID sets the clients Connection ID

func (*Client) SetLocalStationUrl

func (client *Client) SetLocalStationUrl(localStationUrl string)

SetLocalStationUrl sets the clients Local Station URL

func (*Client) SetPID

func (client *Client) SetPID(pid uint32)

SetPID sets the clients NEX PID

func (*Client) SetServerConnectionSignature

func (client *Client) SetServerConnectionSignature(serverConnectionSignature []byte)

SetServerConnectionSignature sets the clients server-side connection signature

func (*Client) SetSessionKey

func (client *Client) SetSessionKey(sessionKey []byte)

SetSessionKey sets the clients session key

func (*Client) SignatureBase

func (client *Client) SignatureBase() int

SignatureBase returns the v0 checksum signature base

func (*Client) SignatureKey

func (client *Client) SignatureKey() []byte

SignatureKey returns signature key

func (*Client) StartTimeoutTimer

func (client *Client) StartTimeoutTimer()

StartTimeoutTimer begins the packet timeout timer

func (*Client) UpdateAccessKey

func (client *Client) UpdateAccessKey(accessKey string)

UpdateAccessKey sets the client signature base and signature key

func (*Client) UpdateRC4Key

func (client *Client) UpdateRC4Key(RC4Key []byte)

UpdateRC4Key sets the client RC4 stream key

type Counter

type Counter struct {
	// contains filtered or unexported fields
}

Counter represents an incremental counter

func NewCounter

func NewCounter(start uint32) *Counter

NewCounter returns a new Counter, with a starting number

func (*Counter) Increment

func (counter *Counter) Increment() uint32

Increment increments the counter by 1 and returns the value

func (Counter) Value

func (counter Counter) Value() uint32

Value returns the counters current value

type DataHolder

type DataHolder struct {
	Name   string
	Object StructureInterface
}

func NewDataHolder

func NewDataHolder() *DataHolder

NewDataHolder returns a new DataHolder

func (*DataHolder) Bytes

func (dataholder *DataHolder) Bytes(stream *StreamOut) []byte

type DateTime

type DateTime struct {
	// contains filtered or unexported fields
}

DateTime represents a NEX DateTime type

func NewDateTime

func NewDateTime(value uint64) *DateTime

NewDateTime returns a new DateTime instance

func (*DateTime) FromTimestamp

func (datetime *DateTime) FromTimestamp(timestamp time.Time) uint64

FromTimestamp converts a Time timestamp into a NEX DateTime

func (*DateTime) Make

func (datetime *DateTime) Make(year, month, day, hour, minute, second int) uint64

Make initilizes a DateTime with the input data

func (*DateTime) Now

func (datetime *DateTime) Now() uint64

Now converts the current Time timestamp to a NEX DateTime

func (*DateTime) Value

func (datetime *DateTime) Value() uint64

Value returns the stored DateTime time

type DummyCompression

type DummyCompression struct{}

DummyCompression represents no compression

func (*DummyCompression) Compress

func (compression *DummyCompression) Compress(data []byte) []byte

Compress returns the data as-is

func (*DummyCompression) Decompress

func (compression *DummyCompression) Decompress(data []byte) []byte

Decompress returns the data as-is

type ErrorsStruct

type ErrorsStruct struct {
	Success uint32

	Core struct {
		Unknown               uint32
		NotImplemented        uint32
		InvalidPointer        uint32
		OperationAborted      uint32
		Exception             uint32
		AccessDenied          uint32
		InvalidHandle         uint32
		InvalidIndex          uint32
		OutOfMemory           uint32
		InvalidArgument       uint32
		Timeout               uint32
		InitializationFailure uint32
		CallInitiationFailure uint32
		RegistrationError     uint32
		BufferOverflow        uint32
		InvalidLockState      uint32
		InvalidSequence       uint32
		SystemError           uint32
		Cancelled             uint32
	}

	DDL struct {
		InvalidSignature uint32
		IncorrectVersion uint32
	}

	RendezVous struct {
		ConnectionFailure                        uint32
		NotAuthenticated                         uint32
		InvalidUsername                          uint32
		InvalidPassword                          uint32
		UsernameAlreadyExists                    uint32
		AccountDisabled                          uint32
		AccountExpired                           uint32
		ConcurrentLoginDenied                    uint32
		EncryptionFailure                        uint32
		InvalidPID                               uint32
		MaxConnectionsReached                    uint32
		InvalidGID                               uint32
		InvalidControlScriptID                   uint32
		InvalidOperationInLiveEnvironment        uint32
		DuplicateEntry                           uint32
		ControlScriptFailure                     uint32
		ClassNotFound                            uint32
		SessionVoid                              uint32
		DDLMismatch                              uint32
		InvalidConfiguration                     uint32
		SessionFull                              uint32
		InvalidGatheringPassword                 uint32
		WithoutParticipationPeriod               uint32
		PersistentGatheringCreationMax           uint32
		PersistentGatheringParticipationMax      uint32
		DeniedByParticipants                     uint32
		ParticipantInBlackList                   uint32
		GameServerMaintenance                    uint32
		OperationPostpone                        uint32
		OutOfRatingRange                         uint32
		ConnectionDisconnected                   uint32
		InvalidOperation                         uint32
		NotParticipatedGathering                 uint32
		MatchmakeSessionUserPasswordUnmatch      uint32
		MatchmakeSessionSystemPasswordUnmatch    uint32
		UserIsOffline                            uint32
		AlreadyParticipatedGathering             uint32
		PermissionDenied                         uint32
		NotFriend                                uint32
		SessionClosed                            uint32
		DatabaseTemporarilyUnavailable           uint32
		InvalidUniqueId                          uint32
		MatchmakingWithdrawn                     uint32
		LimitExceeded                            uint32
		AccountTemporarilyDisabled               uint32
		PartiallyServiceClosed                   uint32
		ConnectionDisconnectedForConcurrentLogin uint32
	}

	PythonCore struct {
		Exception        uint32
		TypeError        uint32
		IndexError       uint32
		InvalidReference uint32
		CallFailure      uint32
		MemoryError      uint32
		KeyError         uint32
		OperationError   uint32
		ConversionError  uint32
		ValidationError  uint32
	}

	Transport struct {
		Unknown                       uint32
		ConnectionFailure             uint32
		InvalidUrl                    uint32
		InvalidKey                    uint32
		InvalidURLType                uint32
		DuplicateEndpoint             uint32
		IOError                       uint32
		Timeout                       uint32
		ConnectionReset               uint32
		IncorrectRemoteAuthentication uint32
		ServerRequestError            uint32
		DecompressionFailure          uint32
		ReliableSendBufferFullFatal   uint32
		UPnPCannotInit                uint32
		UPnPCannotAddMapping          uint32
		NatPMPCannotInit              uint32
		NatPMPCannotAddMapping        uint32
		UnsupportedNAT                uint32
		DnsError                      uint32
		ProxyError                    uint32
		DataRemaining                 uint32
		NoBuffer                      uint32
		NotFound                      uint32
		TemporaryServerError          uint32
		PermanentServerError          uint32
		ServiceUnavailable            uint32
		ReliableSendBufferFull        uint32
		InvalidStation                uint32
		InvalidSubStreamID            uint32
		PacketBufferFull              uint32
		NatTraversalError             uint32
		NatCheckError                 uint32
	}

	DOCore struct {
		StationNotReached             uint32
		TargetStationDisconnect       uint32
		LocalStationLeaving           uint32
		ObjectNotFound                uint32
		InvalidRole                   uint32
		CallTimeout                   uint32
		RMCDispatchFailed             uint32
		MigrationInProgress           uint32
		NoAuthority                   uint32
		NoTargetStationSpecified      uint32
		JoinFailed                    uint32
		JoinDenied                    uint32
		ConnectivityTestFailed        uint32
		Unknown                       uint32
		UnfreedReferences             uint32
		JobTerminationFailed          uint32
		InvalidState                  uint32
		FaultRecoveryFatal            uint32
		FaultRecoveryJobProcessFailed uint32
		StationInconsitency           uint32
		AbnormalMasterState           uint32
		VersionMismatch               uint32
	}

	FPD struct {
		NotInitialized               uint32
		AlreadyInitialized           uint32
		NotConnected                 uint32
		Connected                    uint32
		InitializationFailure        uint32
		OutOfMemory                  uint32
		RmcFailed                    uint32
		InvalidArgument              uint32
		InvalidLocalAccountID        uint32
		InvalidPrincipalID           uint32
		InvalidLocalFriendCode       uint32
		LocalAccountNotExists        uint32
		LocalAccountNotLoaded        uint32
		LocalAccountAlreadyLoaded    uint32
		FriendAlreadyExists          uint32
		FriendNotExists              uint32
		FriendNumMax                 uint32
		NotFriend                    uint32
		FileIO                       uint32
		P2PInternetProhibited        uint32
		Unknown                      uint32
		InvalidState                 uint32
		AddFriendProhibited          uint32
		InvalidAccount               uint32
		BlacklistedByMe              uint32
		FriendAlreadyAdded           uint32
		MyFriendListLimitExceed      uint32
		RequestLimitExceed           uint32
		InvalidMessageID             uint32
		MessageIsNotMine             uint32
		MessageIsNotForMe            uint32
		FriendRequestBlocked         uint32
		NotInMyFriendList            uint32
		FriendListedByMe             uint32
		NotInMyBlacklist             uint32
		IncompatibleAccount          uint32
		BlockSettingChangeNotAllowed uint32
		SizeLimitExceeded            uint32
		OperationNotAllowed          uint32
		NotNetworkAccount            uint32
		NotificationNotFound         uint32
		PreferenceNotInitialized     uint32
		FriendRequestNotAllowed      uint32
	}

	Ranking struct {
		NotInitialized    uint32
		InvalidArgument   uint32
		RegistrationError uint32
		NotFound          uint32
		InvalidScore      uint32
		InvalidDataSize   uint32
		PermissionDenied  uint32
		Unknown           uint32
		NotImplemented    uint32
	}

	Authentication struct {
		NASAuthenticateError             uint32
		TokenParseError                  uint32
		HttpConnectionError              uint32
		HttpDNSError                     uint32
		HttpGetProxySetting              uint32
		TokenExpired                     uint32
		ValidationFailed                 uint32
		InvalidParam                     uint32
		PrincipalIdUnmatched             uint32
		MoveCountUnmatch                 uint32
		UnderMaintenance                 uint32
		UnsupportedVersion               uint32
		ServerVersionIsOld               uint32
		Unknown                          uint32
		ClientVersionIsOld               uint32
		AccountLibraryError              uint32
		ServiceNoLongerAvailable         uint32
		UnknownApplication               uint32
		ApplicationVersionIsOld          uint32
		OutOfService                     uint32
		NetworkServiceLicenseRequired    uint32
		NetworkServiceLicenseSystemError uint32
		NetworkServiceLicenseError3      uint32
		NetworkServiceLicenseError4      uint32
	}

	DataStore struct {
		Unknown             uint32
		InvalidArgument     uint32
		PermissionDenied    uint32
		NotFound            uint32
		AlreadyLocked       uint32
		UnderReviewing      uint32
		Expired             uint32
		InvalidCheckToken   uint32
		SystemFileError     uint32
		OverCapacity        uint32
		OperationNotAllowed uint32
		InvalidPassword     uint32
		ValueNotEqual       uint32
	}

	ServiceItem struct {
		Unknown                  uint32
		InvalidArgument          uint32
		EShopUnknownHttpError    uint32
		EShopResponseParseError  uint32
		NotOwned                 uint32
		InvalidLimitationType    uint32
		ConsumptionRightShortage uint32
	}

	MatchmakeReferee struct {
		Unknown                  uint32
		InvalidArgument          uint32
		AlreadyExists            uint32
		NotParticipatedGathering uint32
		NotParticipatedRound     uint32
		StatsNotFound            uint32
		RoundNotFound            uint32
		RoundArbitrated          uint32
		RoundNotArbitrated       uint32
	}

	Subscriber struct {
		Unknown          uint32
		InvalidArgument  uint32
		OverLimit        uint32
		PermissionDenied uint32
	}

	Ranking2 struct {
		Unknown         uint32
		InvalidArgument uint32
		InvalidScore    uint32
	}

	SmartDeviceVoiceChat struct {
		Unknown                       uint32
		InvalidArgument               uint32
		InvalidResponse               uint32
		InvalidAccessToken            uint32
		Unauthorized                  uint32
		AccessError                   uint32
		UserNotFound                  uint32
		RoomNotFound                  uint32
		RoomNotActivated              uint32
		ApplicationNotSupported       uint32
		InternalServerError           uint32
		ServiceUnavailable            uint32
		UnexpectedError               uint32
		UnderMaintenance              uint32
		ServiceNoLongerAvailable      uint32
		AccountTemporarilyDisabled    uint32
		PermissionDenied              uint32
		NetworkServiceLicenseRequired uint32
		AccountLibraryError           uint32
		GameModeNotFound              uint32
	}

	Screening struct {
		Unknown         uint32
		InvalidArgument uint32
		NotFound        uint32
	}

	Custom struct {
		Unknown uint32
	}

	Ess struct {
		Unknown                uint32
		GameSessionError       uint32
		GameSessionMaintenance uint32
	}
}
var Errors ErrorsStruct

type KerberosEncryption

type KerberosEncryption struct {
	// contains filtered or unexported fields
}

KerberosEncryption is used to encrypt/decrypt using Kerberos

func NewKerberosEncryption

func NewKerberosEncryption(key []byte) *KerberosEncryption

NewKerberosEncryption returns a new KerberosEncryption instance

func (*KerberosEncryption) Decrypt

func (encryption *KerberosEncryption) Decrypt(buffer []byte) []byte

Decrypt will decrypt the given data using Kerberos

func (*KerberosEncryption) Encrypt

func (encryption *KerberosEncryption) Encrypt(buffer []byte) []byte

Encrypt will encrypt the given data using Kerberos

func (*KerberosEncryption) Validate

func (encryption *KerberosEncryption) Validate(buffer []byte) bool

Validate will check the HMAC of the encrypted data

type NullData

type NullData struct {
	*Structure
}

NullData represents a structure with no data

func NewNullData

func NewNullData() *NullData

NewNullData returns a new NullData Structure

func (*NullData) Bytes

func (nullData *NullData) Bytes(stream *StreamOut) []byte

Bytes does nothing for NullData

func (*NullData) ExtractFromStream

func (nullData *NullData) ExtractFromStream(stream *StreamIn) error

ExtractFromStream does nothing for NullData

type Packet

type Packet struct {
	PacketInterface
	// contains filtered or unexported fields
}

Packet represents a generic PRUDP packet

func NewPacket

func NewPacket(client *Client, data []byte) Packet

NewPacket returns a new PRUDP packet generic

func (*Packet) AddFlag

func (packet *Packet) AddFlag(flag uint16)

AddFlag adds the given flag to the packet flag bitmask

func (*Packet) ClearFlag

func (packet *Packet) ClearFlag(flag uint16)

ClearFlag removes the given flag from the packet bitmask

func (*Packet) ConnectionSignature

func (packet *Packet) ConnectionSignature() []byte

ConnectionSignature returns the packet connection signature

func (*Packet) Data

func (packet *Packet) Data() []byte

Data returns bytes used to create the packet (this is not the same as Bytes())

func (*Packet) Destination

func (packet *Packet) Destination() uint8

Destination returns the packet destination

func (*Packet) Flags

func (packet *Packet) Flags() uint16

Flags returns the packet flag bitmask

func (*Packet) FragmentID

func (packet *Packet) FragmentID() uint8

FragmentID returns the packet fragmentID

func (*Packet) HasFlag

func (packet *Packet) HasFlag(flag uint16) bool

HasFlag checks if the packet has the given flag

func (*Packet) Payload

func (packet *Packet) Payload() []byte

Payload returns the packet payload

func (*Packet) RMCRequest

func (packet *Packet) RMCRequest() RMCRequest

RMCRequest returns the packet RMC request

func (*Packet) Sender

func (packet *Packet) Sender() *Client

Sender returns the packet sender

func (*Packet) SequenceID

func (packet *Packet) SequenceID() uint16

SequenceID returns the packet sequenceID

func (*Packet) SessionID

func (packet *Packet) SessionID() uint8

SessionID returns the packet sessionID

func (*Packet) SetConnectionSignature

func (packet *Packet) SetConnectionSignature(connectionSignature []byte)

SetConnectionSignature sets the packet connection signature

func (*Packet) SetDestination

func (packet *Packet) SetDestination(destination uint8)

SetDestination sets the packet destination

func (*Packet) SetFlags

func (packet *Packet) SetFlags(bitmask uint16)

SetFlags sets the packet flag bitmask

func (*Packet) SetFragmentID

func (packet *Packet) SetFragmentID(fragmentID uint8)

SetFragmentID sets the packet fragmentID

func (*Packet) SetPayload

func (packet *Packet) SetPayload(payload []byte)

SetPayload sets the packet payload

func (*Packet) SetSequenceID

func (packet *Packet) SetSequenceID(sequenceID uint16)

SetSequenceID sets the packet sequenceID

func (*Packet) SetSessionID

func (packet *Packet) SetSessionID(sessionID uint8)

SetSessionID sets the packet sessionID

func (*Packet) SetSignature

func (packet *Packet) SetSignature(signature []byte)

SetSignature sets the packet signature

func (*Packet) SetSource

func (packet *Packet) SetSource(source uint8)

SetSource sets the packet source

func (*Packet) SetType

func (packet *Packet) SetType(packetType uint16)

SetType sets the packet type

func (*Packet) SetVersion

func (packet *Packet) SetVersion(version uint8)

SetVersion sets the packet PRUDP version

func (*Packet) Signature

func (packet *Packet) Signature() []byte

Signature returns the packet signature

func (*Packet) Source

func (packet *Packet) Source() uint8

Source returns the packet source

func (*Packet) Type

func (packet *Packet) Type() uint16

Type returns the packet type

func (*Packet) Version

func (packet *Packet) Version() uint8

Version gets the packet PRUDP version

type PacketInterface

type PacketInterface interface {
	Sender() *Client
	SetVersion(version uint8)
	Version() uint8
	SetSource(source uint8)
	Source() uint8
	SetDestination(destination uint8)
	Destination() uint8
	SetType(packetType uint16)
	Type() uint16
	SetFlags(bitmask uint16)
	Flags() uint16
	HasFlag(flag uint16) bool
	AddFlag(flag uint16)
	ClearFlag(flag uint16)
	SetSessionID(sessionID uint8)
	SessionID() uint8
	SetSignature(signature []byte)
	Signature() []byte
	SetSequenceID(sequenceID uint16)
	SequenceID() uint16
	SetConnectionSignature(connectionSignature []byte)
	ConnectionSignature() []byte
	SetFragmentID(fragmentID uint8)
	FragmentID() uint8
	SetPayload(payload []byte)
	Payload() []byte
	RMCRequest() RMCRequest
	Bytes() []byte
}

PacketInterface implements all Packet methods

type PacketV0

type PacketV0 struct {
	Packet
	// contains filtered or unexported fields
}

PacketV0 reresents a PRUDPv0 packet

func NewPacketV0

func NewPacketV0(client *Client, data []byte) (*PacketV0, error)

NewPacketV0 returns a new PRUDPv0 packet

func (*PacketV0) Bytes

func (packet *PacketV0) Bytes() []byte

Bytes encodes the packet and returns a byte array

func (*PacketV0) Checksum

func (packet *PacketV0) Checksum() uint8

Checksum returns the packet checksum

func (*PacketV0) Decode

func (packet *PacketV0) Decode() error

Decode decodes the packet

func (*PacketV0) SetChecksum

func (packet *PacketV0) SetChecksum(checksum uint8)

SetChecksum sets the packet checksum

type PacketV1

type PacketV1 struct {
	Packet
	// contains filtered or unexported fields
}

PacketV1 reresents a PRUDPv1 packet

func NewPacketV1

func NewPacketV1(client *Client, data []byte) (*PacketV1, error)

NewPacketV1 returns a new PRUDPv1 packet

func (*PacketV1) Bytes

func (packet *PacketV1) Bytes() []byte

Bytes encodes the packet and returns a byte array

func (*PacketV1) Decode

func (packet *PacketV1) Decode() error

Decode decodes the packet

func (*PacketV1) InitialSequenceID

func (packet *PacketV1) InitialSequenceID() uint16

InitialSequenceID returns the packet initial sequence ID for unreliable packets

func (*PacketV1) MaximumSubstreamID

func (packet *PacketV1) MaximumSubstreamID() uint8

MaximumSubstreamID returns the packet maximum substream ID

func (*PacketV1) SetInitialSequenceID

func (packet *PacketV1) SetInitialSequenceID(initialSequenceID uint16)

SetInitialSequenceID sets the packet initial sequence ID for unreliable packets

func (*PacketV1) SetMaximumSubstreamID

func (packet *PacketV1) SetMaximumSubstreamID(maximumSubstreamID uint8)

SetMaximumSubstreamID sets the packet maximum substream ID

func (*PacketV1) SetSubstreamID

func (packet *PacketV1) SetSubstreamID(substreamID uint8)

SetSubstreamID sets the packet substream ID

func (*PacketV1) SetSupportedFunctions

func (packet *PacketV1) SetSupportedFunctions(supportedFunctions uint32)

SetSupportedFunctions sets the packet supported functions flags

func (*PacketV1) SubstreamID

func (packet *PacketV1) SubstreamID() uint8

SubstreamID returns the packet substream ID

func (*PacketV1) SupportedFunctions

func (packet *PacketV1) SupportedFunctions() uint32

SupportedFunctions returns the packet supported functions flags

type RMCRequest

type RMCRequest struct {
	// contains filtered or unexported fields
}

RMCRequest represets a RMC request

func NewRMCRequest

func NewRMCRequest() RMCRequest

NewRMCRequest returns a new blank RMCRequest

func (*RMCRequest) Bytes

func (request *RMCRequest) Bytes() []byte

Bytes converts a RMCRequest struct into a usable byte array

func (*RMCRequest) CallID

func (request *RMCRequest) CallID() uint32

CallID sets the RMC request callID

func (*RMCRequest) CustomID

func (request *RMCRequest) CustomID() uint16

customID sets the RMC request customID

func (*RMCRequest) FromBytes

func (request *RMCRequest) FromBytes(data []byte) error

FromBytes converts a byte slice into a RMCRequest

func (*RMCRequest) MethodID

func (request *RMCRequest) MethodID() uint32

MethodID sets the RMC request methodID

func (*RMCRequest) Parameters

func (request *RMCRequest) Parameters() []byte

Parameters sets the RMC request parameters

func (*RMCRequest) ProtocolID

func (request *RMCRequest) ProtocolID() uint8

ProtocolID sets the RMC request protocolID

func (*RMCRequest) SetCallID

func (request *RMCRequest) SetCallID(callID uint32)

CallID sets the RMC request callID

func (*RMCRequest) SetCustomID

func (request *RMCRequest) SetCustomID(customID uint16)

CustomID sets the RMC request customID

func (*RMCRequest) SetMethodID

func (request *RMCRequest) SetMethodID(methodID uint32)

MethodID sets the RMC request methodID

func (*RMCRequest) SetParameters

func (request *RMCRequest) SetParameters(parameters []byte)

Parameters sets the RMC request parameters

func (*RMCRequest) SetProtocolID

func (request *RMCRequest) SetProtocolID(protocolID uint8)

ProtocolID sets the RMC request protocolID

type RMCResponse

type RMCResponse struct {
	// contains filtered or unexported fields
}

RMCResponse represents a RMC response

func NewRMCResponse

func NewRMCResponse(protocolID uint8, callID uint32) RMCResponse

NewRMCResponse returns a new RMCResponse

func (*RMCResponse) Bytes

func (response *RMCResponse) Bytes() []byte

Bytes converts a RMCResponse struct into a usable byte array

func (*RMCResponse) SetError

func (response *RMCResponse) SetError(errorCode uint32)

SetError sets the RMCResponse payload to an instance of RMCError

func (*RMCResponse) SetSuccess

func (response *RMCResponse) SetSuccess(methodID uint32, data []byte)

SetSuccess sets the RMCResponse payload to an instance of RMCSuccess

type RVConnectionData

type RVConnectionData struct {
	Structure
	// contains filtered or unexported fields
}

RVConnectionData represents a nex RVConnectionData type

func NewRVConnectionData

func NewRVConnectionData() *RVConnectionData

NewRVConnectionData returns a new RVConnectionData

func (*RVConnectionData) Bytes

func (rvConnectionData *RVConnectionData) Bytes(stream *StreamOut) []byte

Bytes encodes the RVConnectionData and returns a byte array

func (*RVConnectionData) SetSpecialProtocols

func (rvConnectionData *RVConnectionData) SetSpecialProtocols(specialProtocols []byte)

SetSpecialProtocols sets the RVConnectionData special protocol list (unused by Nintendo)

func (*RVConnectionData) SetStationURL

func (rvConnectionData *RVConnectionData) SetStationURL(stationURL string)

SetStationURL sets the RVConnectionData station URL

func (*RVConnectionData) SetStationURLSpecialProtocols

func (rvConnectionData *RVConnectionData) SetStationURLSpecialProtocols(stationURLSpecialProtocols string)

SetStationURLSpecialProtocols sets the RVConnectionData special station URL (unused by Nintendo)

func (*RVConnectionData) SetTime

func (rvConnectionData *RVConnectionData) SetTime(time uint64)

SetTime sets the RVConnectionData time

type Result

type Result struct {
	ResultCode uint32
}

Result is sent in methods which query large objects

func NewResult

func NewResult(ResultCode uint32) *Result

NewResult returns a new Result

func (*Result) Bytes

func (result *Result) Bytes(stream *StreamOut) []byte

Bytes encodes the Result and returns a byte array

func (*Result) ExtractFromStream

func (result *Result) ExtractFromStream(stream *StreamIn) error

ExtractFromStream extracts a Result structure from a stream

type ResultRange

type ResultRange struct {
	Offset uint32
	Length uint32
	Structure
}

ResultRange is sent in methods which query large objects

func NewResultRange

func NewResultRange() *ResultRange

NewResultRange returns a new ResultRange

func (*ResultRange) ExtractFromStream

func (resultRange *ResultRange) ExtractFromStream(stream *StreamIn) error

ExtractFromStream extracts a ResultRange structure from a stream

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server represents a PRUDP server

func NewServer

func NewServer() *Server

NewServer returns a new NEX server

func (*Server) AccessKey

func (server *Server) AccessKey() string

AccessKey returns the server access key

func (*Server) AcknowledgePacket

func (server *Server) AcknowledgePacket(packet PacketInterface, payload []byte)

AcknowledgePacket acknowledges that the given packet was recieved

func (*Server) ClientConnected

func (server *Server) ClientConnected(client *Client) bool

ClientConnected checks if a given client is stored on the server

func (*Server) ConnectionIDCounter

func (server *Server) ConnectionIDCounter() *Counter

ConnectionIDCounter gets the server connection ID counter

func (*Server) Emit

func (server *Server) Emit(event string, packet interface{})

Emit runs the given event handle

func (*Server) FindClientFromConnectionID

func (server *Server) FindClientFromConnectionID(rvcid uint32) *Client

FindClientFromConnectionID finds a client by their Connection ID

func (*Server) FindClientFromPID

func (server *Server) FindClientFromPID(pid uint32) *Client

FindClientFromPID finds a client by their PID

func (*Server) KerberosKeySize

func (server *Server) KerberosKeySize() int

KerberosKeySize returns the server kerberos key size

func (*Server) KerberosTicketVersion

func (server *Server) KerberosTicketVersion() int

KerberosTicketVersion returns the server kerberos ticket contents version

func (*Server) Kick

func (server *Server) Kick(client *Client)

Kick removes a client from the server

func (*Server) Listen

func (server *Server) Listen(address string)

Listen starts a NEX server on a given address

func (*Server) NexVersion

func (server *Server) NexVersion() int

NexVersion returns the server NEX version

func (*Server) On

func (server *Server) On(event string, handler interface{})

On sets the data event handler

func (*Server) PingTimeout

func (server *Server) PingTimeout() int

PingTimeout returns the server ping timeout time in seconds

func (*Server) PrudpVersion

func (server *Server) PrudpVersion() int

PrudpVersion returns the server PRUDP version

func (*Server) Send

func (server *Server) Send(packet PacketInterface)

Send writes data to client

func (*Server) SendFragment

func (server *Server) SendFragment(packet PacketInterface, fragmentID uint8)

SendFragment sends a packet fragment to the client

func (*Server) SendPing

func (server *Server) SendPing(client *Client)

SendPing sends a ping packet to the given client

func (*Server) SendRaw

func (server *Server) SendRaw(conn *net.UDPAddr, data []byte)

SendRaw writes raw packet data to the client socket

func (*Server) SetAccessKey

func (server *Server) SetAccessKey(accessKey string)

SetAccessKey sets the server access key

func (*Server) SetFragmentSize

func (server *Server) SetFragmentSize(fragmentSize int16)

SetFragmentSize sets the packet fragment size

func (*Server) SetKerberosKeySize

func (server *Server) SetKerberosKeySize(kerberosKeySize int)

SetKerberosKeySize sets the server kerberos key size

func (*Server) SetKerberosTicketVersion

func (server *Server) SetKerberosTicketVersion(ticketVersion int)

SetKerberosTicketVersion sets the server kerberos ticket contents version

func (*Server) SetNexVersion

func (server *Server) SetNexVersion(nexVersion int)

SetNexVersion sets the server NEX version

func (*Server) SetPingTimeout

func (server *Server) SetPingTimeout(pingTimeout int)

SetPingTimeout sets the server ping timeout time in seconds

func (*Server) SetPrudpVersion

func (server *Server) SetPrudpVersion(prudpVersion int)

SetPrudpVersion sets the server PRUDP version

func (*Server) SetSocket

func (server *Server) SetSocket(socket *net.UDPConn)

SetSocket sets the underlying UDP socket

func (*Server) Socket

func (server *Server) Socket() *net.UDPConn

Socket returns the underlying server UDP socket

type StationURL

type StationURL struct {
	// contains filtered or unexported fields
}

StationURL contains the data for a NEX station URL

func NewStationURL

func NewStationURL(str string) *StationURL

func (*StationURL) Address

func (station *StationURL) Address() string

func (*StationURL) CID

func (station *StationURL) CID() string

func (*StationURL) EncodeToString

func (station *StationURL) EncodeToString() string

EncodeToString encodes the StationURL into a string

func (*StationURL) FromString

func (station *StationURL) FromString(str string)

FromString parses the StationURL data from a string

func (*StationURL) Natf

func (station *StationURL) Natf() string

func (*StationURL) Natm

func (station *StationURL) Natm() string

func (*StationURL) PID

func (station *StationURL) PID() string

func (*StationURL) PRID

func (station *StationURL) PRID() string

func (*StationURL) Pmp

func (station *StationURL) Pmp() string

func (*StationURL) Port

func (station *StationURL) Port() string

func (*StationURL) ProbeInit

func (station *StationURL) ProbeInit() string

func (*StationURL) RVCID

func (station *StationURL) RVCID() string

func (*StationURL) SID

func (station *StationURL) SID() string

func (*StationURL) Scheme

func (station *StationURL) Scheme() string

func (*StationURL) SetAddress

func (station *StationURL) SetAddress(address string)

SetAddress sets the StationURL address

func (*StationURL) SetCID

func (station *StationURL) SetCID(cid string)

SetCID sets the StationURL CID

func (*StationURL) SetNatf

func (station *StationURL) SetNatf(natf string)

SetNatf sets the StationURL Natf

func (*StationURL) SetNatm

func (station *StationURL) SetNatm(natm string)

SetNatm sets the StationURL Natm

func (*StationURL) SetPID

func (station *StationURL) SetPID(pid string)

SetPid sets the StationURL PID

func (*StationURL) SetPRID

func (station *StationURL) SetPRID(prid string)

SetPRID sets the StationURL PRID

func (*StationURL) SetPmp

func (station *StationURL) SetPmp(pmp string)

SetPmp sets the StationURL Pmp

func (*StationURL) SetPort

func (station *StationURL) SetPort(port string)

SetPort sets the StationURL port

func (*StationURL) SetProbeInit

func (station *StationURL) SetProbeInit(probeinit string)

SetProbeInit sets the StationURL ProbeInit

func (*StationURL) SetRVCID

func (station *StationURL) SetRVCID(rvcid string)

SetRVCID sets the StationURL RVCID

func (*StationURL) SetSID

func (station *StationURL) SetSID(sid string)

SetSID sets the StationURL SID

func (*StationURL) SetScheme

func (station *StationURL) SetScheme(scheme string)

SetScheme sets the StationURL scheme

func (*StationURL) SetStream

func (station *StationURL) SetStream(stream string)

SetStream sets the StationURL stream

func (*StationURL) SetType

func (station *StationURL) SetType(transportType string)

SetType sets the StationURL transportType

func (*StationURL) SetUpnp

func (station *StationURL) SetUpnp(upnp string)

SetUpnp sets the StationURL Upnp

func (*StationURL) Stream

func (station *StationURL) Stream() string

func (*StationURL) Type

func (station *StationURL) Type() string

func (*StationURL) Upnp

func (station *StationURL) Upnp() string

type StreamIn

type StreamIn struct {
	*crunch.Buffer
	Server *Server
}

StreamIn is an input stream abstraction of github.com/superwhiskers/crunch with nex type support

func NewStreamIn

func NewStreamIn(data []byte, server *Server) *StreamIn

NewStreamIn returns a new NEX input stream

func (*StreamIn) ReadBool

func (stream *StreamIn) ReadBool() bool

ReadBool reads a bool

func (*StreamIn) ReadBuffer

func (stream *StreamIn) ReadBuffer() ([]byte, error)

ReadBuffer reads a nex Buffer type

func (*StreamIn) ReadInt32LE

func (stream *StreamIn) ReadInt32LE() int32

ReadInt32LE reads a int32

func (*StreamIn) ReadListInt32LE

func (stream *StreamIn) ReadListInt32LE() []int32

ReadListInt32LE reads a list of int32 types

func (*StreamIn) ReadListQBuffer

func (stream *StreamIn) ReadListQBuffer() [][]byte

ReadListQBuffer reads a list of NEX QBuffer types

func (*StreamIn) ReadListString

func (stream *StreamIn) ReadListString() []string

ReadListString reads a list of NEX String types

func (*StreamIn) ReadListUInt8

func (stream *StreamIn) ReadListUInt8() []uint8

ReadListUInt8 reads a list of uint8 types

func (*StreamIn) ReadListUInt16LE

func (stream *StreamIn) ReadListUInt16LE() []uint16

ReadListUInt16LE reads a list of uint16 types

func (*StreamIn) ReadListUInt32LE

func (stream *StreamIn) ReadListUInt32LE() []uint32

ReadListUInt32LE reads a list of uint32 types

func (*StreamIn) ReadListUInt64LE

func (stream *StreamIn) ReadListUInt64LE() []uint64

ReadListUInt64LE reads a list of uint64 types

func (*StreamIn) ReadMap

func (stream *StreamIn) ReadMap(keyFunction interface{}, valueFunction interface{}) (map[interface{}]interface{}, error)

ReadMap reads a Map type with the given key and value types

func (*StreamIn) ReadQBuffer

func (stream *StreamIn) ReadQBuffer() ([]byte, error)

ReadQBuffer reads a nex qBuffer type

func (*StreamIn) ReadString

func (stream *StreamIn) ReadString() (string, error)

ReadString reads and returns a nex string type

func (*StreamIn) ReadStructure

func (stream *StreamIn) ReadStructure(structure StructureInterface) (StructureInterface, error)

ReadStructure reads a nex Structure type

func (*StreamIn) ReadUInt8

func (stream *StreamIn) ReadUInt8() uint8

ReadUInt8 reads a uint8

func (*StreamIn) ReadUInt16LE

func (stream *StreamIn) ReadUInt16LE() uint16

ReadUInt16LE reads a uint16

func (*StreamIn) ReadUInt32LE

func (stream *StreamIn) ReadUInt32LE() uint32

ReadUInt32LE reads a uint32

func (*StreamIn) ReadUInt64LE

func (stream *StreamIn) ReadUInt64LE() uint64

ReadUInt64LE reads a uint64

func (*StreamIn) ReadVariant

func (stream *StreamIn) ReadVariant() interface{}

ReadVariant reads a Variant type. This type can hold 7 different types

type StreamOut

type StreamOut struct {
	*crunch.Buffer
	Server *Server
}

StreamOut is an abstraction of github.com/superwhiskers/crunch with nex type support

func NewStreamOut

func NewStreamOut(server *Server) *StreamOut

NewStreamOut returns a new nex output stream

func (*StreamOut) WriteBool

func (stream *StreamOut) WriteBool(b bool)

WriteBool writes a bool

func (*StreamOut) WriteBuffer

func (stream *StreamOut) WriteBuffer(data []byte)

WriteBuffer writes a NEX Buffer type

func (*StreamOut) WriteDataHolder

func (stream *StreamOut) WriteDataHolder(dataholder *DataHolder)

WriteDataHolder writes a NEX DataHolder type

func (*StreamOut) WriteInt32LE

func (stream *StreamOut) WriteInt32LE(s32 int32)

WriteInt32LE writes a int32 as LE

func (*StreamOut) WriteInt64LE

func (stream *StreamOut) WriteInt64LE(s64 int64)

WriteInt64LE writes a int64 as LE

func (*StreamOut) WriteListInt64LE

func (stream *StreamOut) WriteListInt64LE(list []int64)

WriteListInt64LE writes a list of int64 types

func (*StreamOut) WriteListQBuffer

func (stream *StreamOut) WriteListQBuffer(buffers [][]byte)

WriteListQBuffer writes a list of NEX qBuffer types

func (*StreamOut) WriteListString

func (stream *StreamOut) WriteListString(strings []string)

WriteListString writes a list of NEX String types

func (*StreamOut) WriteListStructure

func (stream *StreamOut) WriteListStructure(structures interface{})

WriteListStructure writes a list of NEX Structure types

func (*StreamOut) WriteListUInt8

func (stream *StreamOut) WriteListUInt8(list []uint8)

WriteListUInt8 writes a list of uint8 types

func (*StreamOut) WriteListUInt16LE

func (stream *StreamOut) WriteListUInt16LE(list []uint16)

WriteListUInt16LE writes a list of uint16 types

func (*StreamOut) WriteListUInt32LE

func (stream *StreamOut) WriteListUInt32LE(list []uint32)

WriteListUInt32LE writes a list of uint32 types

func (*StreamOut) WriteListUInt64LE

func (stream *StreamOut) WriteListUInt64LE(list []uint64)

WriteListUInt64LE writes a list of uint64 types

func (*StreamOut) WriteQBuffer

func (stream *StreamOut) WriteQBuffer(data []byte)

WriteQBuffer writes a NEX qBuffer type

func (*StreamOut) WriteString

func (stream *StreamOut) WriteString(str string)

WriteString writes a NEX string type

func (*StreamOut) WriteStructure

func (stream *StreamOut) WriteStructure(structure StructureInterface)

WriteStructure writes a nex Structure type

func (*StreamOut) WriteUInt8

func (stream *StreamOut) WriteUInt8(u8 uint8)

WriteUInt8 writes a uint8

func (*StreamOut) WriteUInt16LE

func (stream *StreamOut) WriteUInt16LE(u16 uint16)

WriteUInt16LE writes a uint16 as LE

func (*StreamOut) WriteUInt32LE

func (stream *StreamOut) WriteUInt32LE(u32 uint32)

WriteUInt32LE writes a uint32 as LE

func (*StreamOut) WriteUInt64LE

func (stream *StreamOut) WriteUInt64LE(u64 uint64)

WriteUInt64LE writes a uint64 as LE

type Structure

type Structure struct {
	StructureInterface
}

Structure represents a nex Structure type

func (*Structure) Hierarchy

func (structure *Structure) Hierarchy() []StructureInterface

Hierarchy returns a Structure hierarchy

type StructureInterface

type StructureInterface interface {
	Hierarchy() []StructureInterface
	ExtractFromStream(*StreamIn) error
	Bytes(*StreamOut) []byte
}

StructureInterface implements all Structure methods

type Ticket

type Ticket struct {
	// contains filtered or unexported fields
}

Ticket represents a Kerberos authentication ticket

func NewKerberosTicket

func NewKerberosTicket() *Ticket

NewKerberosTicket returns a new Ticket instance

func (*Ticket) Encrypt

func (ticket *Ticket) Encrypt(key []byte, stream *StreamOut) []byte

Encrypt writes the ticket data to the provided stream and returns the encrypted byte slice

func (*Ticket) InternalData

func (ticket *Ticket) InternalData() []byte

InternalData returns the Tickets internal data buffer

func (*Ticket) SessionKey

func (ticket *Ticket) SessionKey() []byte

SessionKey returns the Tickets session key

func (*Ticket) SetInternalData

func (ticket *Ticket) SetInternalData(internalData []byte)

SetInternalData sets the Tickets internal data buffer

func (*Ticket) SetSessionKey

func (ticket *Ticket) SetSessionKey(sessionKey []byte)

SetSessionKey sets the Tickets session key

func (*Ticket) SetTargetPID

func (ticket *Ticket) SetTargetPID(targetPID uint32)

SetTargetPID sets the Tickets target PID

func (*Ticket) TargetPID

func (ticket *Ticket) TargetPID() uint32

TargetPID returns the Tickets target PID

type TicketInternalData

type TicketInternalData struct {
	// contains filtered or unexported fields
}

TicketInternalData contains information sent to the secure server

func NewKerberosTicketInternalData

func NewKerberosTicketInternalData() *TicketInternalData

NewKerberosTicketInternalData returns a new TicketInternalData instance

func (*TicketInternalData) Encrypt

func (ticketInternalData *TicketInternalData) Encrypt(key []byte, stream *StreamOut) []byte

Encrypt writes the ticket data to the provided stream and returns the encrypted byte slice

func (*TicketInternalData) SessionKey

func (ticketInternalData *TicketInternalData) SessionKey() []byte

SessionKey returns the TicketInternalDatas session key

func (*TicketInternalData) SetSessionKey

func (ticketInternalData *TicketInternalData) SetSessionKey(sessionKey []byte)

SetSessionKey sets the TicketInternalDatas session key

func (*TicketInternalData) SetTimestamp

func (ticketInternalData *TicketInternalData) SetTimestamp(timestamp *DateTime)

SetSessionKey sets the TicketInternalDatas session key

func (*TicketInternalData) SetUserPID

func (ticketInternalData *TicketInternalData) SetUserPID(userPID uint32)

SetUserPID sets the TicketInternalDatas user PID

func (*TicketInternalData) Timestamp

func (ticketInternalData *TicketInternalData) Timestamp() *DateTime

Timestamp returns the TicketInternalDatas timestamp

func (*TicketInternalData) UserPID

func (ticketInternalData *TicketInternalData) UserPID() uint32

UserPID returns the TicketInternalDatas user PID

type ZLibCompression

type ZLibCompression struct{}

ZLibCompression represents ZLib compression

func (*ZLibCompression) Compress

func (compression *ZLibCompression) Compress(data []byte) []byte

Compress returns the data as-is (needs to be updated to return ZLib compressed data)

func (*ZLibCompression) Decompress

func (compression *ZLibCompression) Decompress(data []byte) []byte

Decompress returns the data as-is (needs to be updated to return ZLib decompressed data)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL