nexproto

package module
v0.0.0-...-a029c78 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2026 License: AGPL-3.0 Imports: 4 Imported by: 0

README

Rendez-vous servers with protocol support in Go

GoDoc

Usage note

This library is designed around, and customized for, Rock Band 3. While it may work with other Quazal Rendez-vous titles that aren't Rock Band 3, do not expect it to work correctly out of the box with anything but Rock Band 3. If you are looking for a more generic NEX/PRUDP protocol library, see the upstream version of this repository.

Install

go get github.com/ihatecompvir/nex-protocols-go

Example (Secure server)

func main() {
    nexServer := nex.NewServer()
    nexServer.SetPrudpVersion(0)
    nexServer.SetSignatureVersion(1)
    nexServer.SetKerberosKeySize(16)
    nexServer.SetAccessKey("ridfebb9")

    secureServer := nexproto.NewSecureProtocol(nexServer)
    friendsServer := nexproto.NewFriendsProtocol(nexServer)

    // Handle PRUDP CONNECT packet (not an RMC method)
    nexServer.On("Connect", func(packet *nex.PacketV0) {
        packet.GetSender().SetClientConnectionSignature(packet.GetConnectionSignature())

        payload := packet.GetPayload()
        stream := nex.NewStream(payload)

        ticketData := stream.ReadNEXBufferNext()
        requestData := stream.ReadNEXBufferNext()

        // TODO: use random key from auth server
        ticketDataEncryption := nex.NewKerberosEncryption([]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0})
        decryptedTicketData := ticketDataEncryption.Decrypt(ticketData)
        ticketDataStream := nex.NewStream(decryptedTicketData)

        _ = ticketDataStream.ReadU64LENext(1)[0] // expiration time
        _ = ticketDataStream.ReadU32LENext(1)[0] // User PID
        sessionKey := ticketDataStream.ReadBytesNext(16)

        requestDataEncryption := nex.NewKerberosEncryption(sessionKey)
        decryptedRequestData := requestDataEncryption.Decrypt(requestData)
        requestDataStream := nex.NewStream(decryptedRequestData)

        _ = requestDataStream.ReadU32LENext(1)[0] // User PID
        _ = requestDataStream.ReadU32LENext(1)[0] //CID of secure server station url
        responseCheck := requestDataStream.ReadU32LENext(1)[0]

        responseValueStream := nex.NewStream(make([]byte, 4))
        responseValueBufferStream := nex.NewStream()
        responseValueBufferStream.Grow(8)

        responseValueStream.WriteU32LENext([]uint32{responseCheck + 1})
        responseValueBufferStream.WriteNEXBuffer(responseValueStream.Bytes())

        packet.GetSender().UpdateRC4Key(sessionKey)

        nexServer.AcknowledgePacket(packet, responseValueBufferStream.Bytes())
    })

    // Secure protocol handles

    // Handle Register RMC method
    secureServer.Register(func(client *nex.Client, callID uint32, stationUrls []*nex.StationURL) {
        localStation := stationUrls[0]

        address := client.GetAddress().IP.String()
        port := string(client.GetAddress().Port)

        localStation.SetAddress(&address)
        localStation.SetPort(&port)

        localStationURL := localStation.EncodeToString()

        rmcResponseStream := nex.NewStream()
        rmcResponseStream.Grow(int64(4 + 4 + 2 + len(localStationURL) + 1))

        rmcResponseStream.WriteU32LENext([]uint32{0x10001}) // Success
        rmcResponseStream.WriteU32LENext([]uint32{uint32(secureServer.ConnectionIDCounter.Increment())})
        rmcResponseStream.WriteNEXStringNext(localStationURL)

        rmcResponseBody := rmcResponseStream.Bytes()

        // Build response packet
        rmcResponse := nex.NewRMCResponse(nexproto.SecureProtocolID, callID)
        rmcResponse.SetSuccess(nexproto.SecureMethodRegisterEx, rmcResponseBody)

        rmcResponseBytes := rmcResponse.Bytes()

        responsePacket := nex.NewPacketV0(client, nil)

        responsePacket.SetVersion(0)
        responsePacket.SetSource(0xA1)
        responsePacket.SetDestination(0xAF)
        responsePacket.SetType(nex.DataPacket)
        responsePacket.SetPayload(rmcResponseBytes)

        responsePacket.AddFlag(nex.FlagNeedsAck)
        responsePacket.AddFlag(nex.FlagReliable)

        nexServer.Send(responsePacket)
    })

    // Handle RegisterEx RMC method
    secureServer.RegisterEx(func(client *nex.Client, callID uint32, stationUrls []*nex.StationURL, loginData nexproto.NintendoLoginData) {
        // TODO: Validate loginData
        secureServer.RegisterHandler(client, callID, stationUrls)
    })

    // Friends (WiiU) protocol handles

    friendsServer.CheckSettingStatus(func(client *nex.Client, callID uint32) {
        rmcResponseStream := nex.NewStream()
        rmcResponseStream.Grow(1)

        rmcResponseStream.WriteByteNext(0xFF)

        rmcResponseBody := rmcResponseStream.Bytes()

        // Build response packet
        rmcResponse := nex.NewRMCResponse(nexproto.FriendsProtocolID, callID)
        rmcResponse.SetSuccess(nexproto.FriendsMethodCheckSettingStatus, rmcResponseBody)

        rmcResponseBytes := rmcResponse.Bytes()

        responsePacket := nex.NewPacketV0(client, nil)

        responsePacket.SetVersion(0)
        responsePacket.SetSource(0xA1)
        responsePacket.SetDestination(0xAF)
        responsePacket.SetType(nex.DataPacket)
        responsePacket.SetPayload(rmcResponseBytes)

        responsePacket.AddFlag(nex.FlagNeedsAck)
        responsePacket.AddFlag(nex.FlagReliable)

        nexServer.Send(responsePacket)
    })

    friendsServer.UpdateAndGetAllInformation(func(client *nex.Client, callID uint32, nnaInfo *nexproto.NNAInfo, presence *nexproto.NintendoPresenceV2, birthday *nex.DateTime) {
        comment := "Pretendo Online"
        datetime := nex.NewDateTime(0)

        rmcResponseStream := nex.NewStream()
        rmcResponseStream.Grow(int64(
            3 + // PrincipalPreference
            1 + 2 + len(comment) + 1 + 8 + // Comment
            4 + // FriendInfo List length
            4 + // FriendRequest (Sent) List length
            4 + // FriendRequest (Received) List length
            4 + // BlacklistedPrincipal List length
            1 + // Unknown
            4 + // PersistentNotification List length
            1)) // Unknown

        // TODO: Make the following fields into structs and encode them

        //PrincipalPreference
        rmcResponseStream.WriteByteNext(0)
        rmcResponseStream.WriteByteNext(0)
        rmcResponseStream.WriteByteNext(0)
        //Comment
        rmcResponseStream.WriteByteNext(0)
        rmcResponseStream.WriteNEXStringNext(comment)
        rmcResponseStream.WriteU64LENext([]uint64{datetime.Now()})
        //List<FriendInfo>
        rmcResponseStream.WriteU32LENext([]uint32{0})
        //List<FriendRequest> (Sent)
        rmcResponseStream.WriteU32LENext([]uint32{0})
        //List<FriendRequest> (Received)
        rmcResponseStream.WriteU32LENext([]uint32{0})
        //List<BlacklistedPrincipal>
        rmcResponseStream.WriteU32LENext([]uint32{0})
        //Unknown
        rmcResponseStream.WriteByteNext(0)
        //List<PersistentNotification>
        rmcResponseStream.WriteU32LENext([]uint32{0})
        //Unknown
        rmcResponseStream.WriteByteNext(0)

        rmcResponseBody := rmcResponseStream.Bytes()

        // Build response packet
        rmcResponse := nex.NewRMCResponse(nexproto.FriendsProtocolID, callID)
        rmcResponse.SetSuccess(nexproto.FriendsMethodUpdateAndGetAllInformation, rmcResponseBody)

        rmcResponseBytes := rmcResponse.Bytes()

        responsePacket := nex.NewPacketV0(client, nil)

        responsePacket.SetVersion(0)
        responsePacket.SetSource(0xA1)
        responsePacket.SetDestination(0xAF)
        responsePacket.SetType(nex.DataPacket)
        responsePacket.SetPayload(rmcResponseBytes)

        responsePacket.AddFlag(nex.FlagNeedsAck)
        responsePacket.AddFlag(nex.FlagReliable)

        nexServer.Send(responsePacket)
    })

    nexServer.Listen("192.168.0.28:60001")
}

Documentation

Index

Constants

View Source
const (
	// AccountManagementProtocolID is the protocol ID for the Account Management protocol
	AccountManagementProtocolID = 0x19
	DeleteAccount               = 0x02
	SetStatus                   = 0x11
	GetStatus                   = 0x12
	FindByNameLike              = 0x19
	LookupOrCreateAccount       = 0x1B // also used by Xbox 360 when multiple profiles are signed in
)
View Source
const (
	// AuthenticationProtocolID is the protocol ID for the Authentication protocol
	AuthenticationProtocolID = 0xA

	// AuthenticationMethodLogin is the method ID for the method Login
	AuthenticationMethodLogin = 0x1

	// AuthenticationMethodLoginEx is the method ID for the method LoginEx
	AuthenticationMethodLoginEx = 0x2

	// AuthenticationMethodRequestTicket is the method ID for the method RequestTicket
	AuthenticationMethodRequestTicket = 0x3

	// AuthenticationMethodGetPID is the method ID for the method GetPID
	AuthenticationMethodGetPID = 0x4

	// AuthenticationMethodGetName is the method ID for the method GetName
	AuthenticationMethodGetName = 0x5

	// AuthenticationMethodLoginWithParam is the method ID for the method LoginWithParam
	AuthenticationMethodLoginWithParam = 0x6
)
View Source
const (
	CustomMatchmakingProtocolID = 0x6E

	CustomFind = 0x1
)
View Source
const (
	// SecureProtocolID is the protocol ID for the Secure Connection protocol
	JsonProtocolID = 0x75

	JsonRequest  = 0x1
	JsonRequest2 = 0x2 // used for telemetry and other things that are not crucial to the game functioning
)
View Source
const (
	MatchmakingProtocolID = 0x15 // the first matchmaking service protocol

	RegisterGathering   = 0x1  // registers a gathering with the server
	TerminateGathering  = 0x2  // ends a gathering
	UpdateGathering     = 0x4  // updates a gathering
	Participate         = 0xB  // used to denote that a player is in a particular session
	CancelParticipation = 0xC  // used to denote that a player is no longer in a particular session
	FindBySingleID      = 0x15 // looks up a gathering by its ID
	LaunchSession       = 0x1A // "launches" the session and makes it officially active
	SetState            = 0x1E // sets the state of a gathering (in song, etc.)
)
View Source
const (
	MessageDeliveryProtocolID = 0x1B
	DeliverMessage            = 0x1
)
View Source
const (
	MessagingProtocolID = 0x17

	GetNumberOfMessages = 0x2
	GetMessageHeaders   = 0x3
	RetrieveMessages    = 0x5
	DeleteMessages      = 0x6
)
View Source
const (
	NATTraversalProtocolID = 0x3

	RequestProbeInitiation = 0x1
	InitiateProbe          = 0x2
)
View Source
const (
	NintendoManagementProtocolID = 0x53

	GetConsoleUsernames = 2 // returns a list of users on a particular console by its friend code
)
View Source
const (
	RBBinaryDataProtocolID = 0x76

	// uploads a blob of binary data
	SaveBinaryData = 1

	// retrieves a blob of binary data
	GetBinaryData = 2
)
View Source
const (
	// SecureProtocolID is the protocol ID for the Secure Connection protocol
	SecureProtocolID = 0xB

	// SecureMethodRegister is the method ID for the method Register
	SecureMethodRegister = 0x1

	// SecureMethodRequestConnectionData is the method ID for the method RequestConnectionData
	SecureMethodRequestConnectionData = 0x2

	// SecureMethodRequestURLs is the method ID for the method RequestURLs
	SecureMethodRequestURLs = 0x3

	// SecureMethodRegisterEx is the method ID for the method RegisterEx
	SecureMethodRegisterEx = 0x4

	// SecureMethodTestConnectivity is the method ID for the method TestConnectivity
	SecureMethodTestConnectivity = 0x5

	// SecureMethodUpdateURLs is the method ID for the method UpdateURLs
	SecureMethodUpdateURLs = 0x6

	// SecureMethodReplaceURL is the method ID for the method ReplaceURL
	SecureMethodReplaceURL = 0x7

	// SecureMethodSendReport is the method ID for the method SendReport
	SecureMethodSendReport = 0x8
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountManagementProtocol

type AccountManagementProtocol struct {
	DeleteAccountHandler         func(err error, client *nex.Client, callID uint32, pid uint32)
	LookupOrCreateAccountHandler func(err error, client *nex.Client, callID uint32, username string, key string, groups uint32, email string)
	SetStatusHandler             func(err error, client *nex.Client, callID uint32, status string)
	GetStatusHandler             func(err error, client *nex.Client, callID uint32, pid uint32)
	FindByNameLikeHandler        func(err error, client *nex.Client, callID uint32, uiGroups uint32, name string)
	// contains filtered or unexported fields
}

AccountManagementProtocol handles the Account Management nex protocol

func NewAccountManagementProtocol

func NewAccountManagementProtocol(server *nex.Server) *AccountManagementProtocol

NewAccountManagementProtocol returns a new AccountManagementProtocol

func (*AccountManagementProtocol) DeleteAccount

func (accountManagementProtocol *AccountManagementProtocol) DeleteAccount(handler func(err error, client *nex.Client, callID uint32, pid uint32))

DeleteAccount sets the DeleteAccount handler function

func (*AccountManagementProtocol) FindByNameLike

func (accountManagementProtocol *AccountManagementProtocol) FindByNameLike(handler func(err error, client *nex.Client, callID uint32, uiGroups uint32, name string))

FindByNameLike sets the FindByNameLike handler function

func (*AccountManagementProtocol) GetStatus

func (accountManagementProtocol *AccountManagementProtocol) GetStatus(handler func(err error, client *nex.Client, callID uint32, pid uint32))

GetStatus sets the GetStatus handler function

func (*AccountManagementProtocol) LookupOrCreateAccount

func (accountManagementProtocol *AccountManagementProtocol) LookupOrCreateAccount(handler func(err error, client *nex.Client, callID uint32, username string, key string, groups uint32, email string))

CreateAccount sets the CreateAccount handler function

func (*AccountManagementProtocol) SetStatus

func (accountManagementProtocol *AccountManagementProtocol) SetStatus(handler func(err error, client *nex.Client, callID uint32, status string))

SetStatus sets the SetStatus handler function

func (*AccountManagementProtocol) Setup

func (accountManagementProtocol *AccountManagementProtocol) Setup()

Setup initializes the protocol

type AuthenticationInfo

type AuthenticationInfo struct {
	Token         string
	NGSVersion    uint32
	TokenType     uint8
	ServerVersion uint32

	*nex.NullData
	// contains filtered or unexported fields
}

AuthenticationInfo holds information about an authentication request

func NewAuthenticationInfo

func NewAuthenticationInfo() *AuthenticationInfo

NewAuthenticationInfo returns a new AuthenticationInfo

func (*AuthenticationInfo) ExtractFromStream

func (authenticationInfo *AuthenticationInfo) ExtractFromStream(stream *nex.StreamIn) error

ExtractFromStream extracts a AuthenticationInfo structure from a stream

func (*AuthenticationInfo) GetHierarchy

func (authenticationInfo *AuthenticationInfo) GetHierarchy() []nex.StructureInterface

GetHierarchy returns the Structure hierarchy

type AuthenticationProtocol

type AuthenticationProtocol struct {
	LoginHandler          func(err error, client *nex.Client, callID uint32, username string)
	LoginExHandler        func(err error, client *nex.Client, callID uint32, username string, authenticationInfo *AuthenticationInfo)
	RequestTicketHandler  func(err error, client *nex.Client, callID uint32, userPID uint32, serverPID uint32)
	GetPIDHandler         func(err error, client *nex.Client, callID uint32, username string)
	GetNameHandler        func(err error, client *nex.Client, callID uint32, userPID uint32)
	LoginWithParamHandler func(err error, client *nex.Client, callID uint32)
	// contains filtered or unexported fields
}

AuthenticationProtocol handles the Authentication nex protocol

func NewAuthenticationProtocol

func NewAuthenticationProtocol(server *nex.Server) *AuthenticationProtocol

NewAuthenticationProtocol returns a new AuthenticationProtocol

func (*AuthenticationProtocol) GetName

func (authenticationProtocol *AuthenticationProtocol) GetName(handler func(err error, client *nex.Client, callID uint32, userPID uint32))

GetName sets the GetName handler function

func (*AuthenticationProtocol) GetPID

func (authenticationProtocol *AuthenticationProtocol) GetPID(handler func(err error, client *nex.Client, callID uint32, username string))

GetPID sets the GetPID handler function

func (*AuthenticationProtocol) Login

func (authenticationProtocol *AuthenticationProtocol) Login(handler func(err error, client *nex.Client, callID uint32, username string))

Login sets the Login handler function

func (*AuthenticationProtocol) LoginEx

func (authenticationProtocol *AuthenticationProtocol) LoginEx(handler func(err error, client *nex.Client, callID uint32, username string, authenticationInfo *AuthenticationInfo))

LoginEx sets the LoginEx handler function

func (*AuthenticationProtocol) LoginWithParam

func (authenticationProtocol *AuthenticationProtocol) LoginWithParam(handler func(err error, client *nex.Client, callID uint32))

LoginWithParam sets the LoginWithParam handler function

func (*AuthenticationProtocol) RequestTicket

func (authenticationProtocol *AuthenticationProtocol) RequestTicket(handler func(err error, client *nex.Client, callID uint32, userPID uint32, serverPID uint32))

RequestTicket sets the RequestTicket handler function

func (*AuthenticationProtocol) Setup

func (authenticationProtocol *AuthenticationProtocol) Setup()

Setup initializes the protocol

type CustomMatchmakingProtocol

type CustomMatchmakingProtocol struct {
	ConnectionIDCounter *nex.Counter
	CustomFindHandler   func(err error, client *nex.Client, callID uint32, data []byte)
	// contains filtered or unexported fields
}

JsonProtocol handles the Json requests

func NewCustomMatchmakingProtocol

func NewCustomMatchmakingProtocol(server *nex.Server) *CustomMatchmakingProtocol

NewCustomMatchmakingProtocol returns a new CustomMatchmakingProtocol

func (*CustomMatchmakingProtocol) CustomFind

func (customMatchmakingProtocol *CustomMatchmakingProtocol) CustomFind(handler func(err error, client *nex.Client, callID uint32, data []byte))

func (*CustomMatchmakingProtocol) Setup

func (customMatchmakingProtocol *CustomMatchmakingProtocol) Setup()

type JsonProtocol

type JsonProtocol struct {
	ConnectionIDCounter *nex.Counter
	JSONRequestHandler  func(err error, client *nex.Client, callID uint32, rawJson string)
	JSONRequest2Handler func(err error, client *nex.Client, callID uint32, rawJson string)
	// contains filtered or unexported fields
}

JsonProtocol handles the Json requests

func NewJsonProtocol

func NewJsonProtocol(server *nex.Server) *JsonProtocol

NewJsonProtocol returns a new JsonProtocol

func (*JsonProtocol) JSONRequest

func (jsonProtocol *JsonProtocol) JSONRequest(handler func(err error, client *nex.Client, callID uint32, rawJson string))

Register sets the Register handler function

func (*JsonProtocol) JSONRequest2

func (jsonProtocol *JsonProtocol) JSONRequest2(handler func(err error, client *nex.Client, callID uint32, rawJson string))

func (*JsonProtocol) Setup

func (jsonProtocol *JsonProtocol) Setup()

Setup initializes the protocol

type MatchmakingProtocol

type MatchmakingProtocol struct {
	ConnectionIDCounter        *nex.Counter
	RegisterGatheringHandler   func(err error, client *nex.Client, callID uint32, gathering []byte)
	UpdateGatheringHandler     func(err error, client *nex.Client, callID uint32, gathering []byte, gatheringID uint32)
	ParticipateHandler         func(err error, client *nex.Client, callID uint32, gatheringID uint32)
	CancelParticipationHandler func(err error, client *nex.Client, callID uint32, gatheringID uint32)
	LaunchSessionHandler       func(err error, client *nex.Client, callID uint32, gatheringID uint32)
	TerminateGatheringHandler  func(err error, client *nex.Client, callID uint32, gatheringID uint32)
	SetStateHandler            func(err error, client *nex.Client, callID uint32, gatheringID uint32, state uint32)
	FindBySingleIDHandler      func(err error, client *nex.Client, callID uint32, gatheringID uint32)
	// contains filtered or unexported fields
}

JsonProtocol handles the Json requests

func NewMatchmakingProtocol

func NewMatchmakingProtocol(server *nex.Server) *MatchmakingProtocol

NewMatchmakingProtocol returns a new MatchmakingProtocol

func (*MatchmakingProtocol) CancelParticipation

func (matchmakingProtocol *MatchmakingProtocol) CancelParticipation(handler func(err error, client *nex.Client, callID uint32, gatheringID uint32))

func (*MatchmakingProtocol) FindBySingleID

func (matchmakingProtocol *MatchmakingProtocol) FindBySingleID(handler func(err error, client *nex.Client, callID uint32, gatheringID uint32))

func (*MatchmakingProtocol) LaunchSession

func (matchmakingProtocol *MatchmakingProtocol) LaunchSession(handler func(err error, client *nex.Client, callID uint32, gatheringID uint32))

func (*MatchmakingProtocol) Participate

func (matchmakingProtocol *MatchmakingProtocol) Participate(handler func(err error, client *nex.Client, callID uint32, gatheringID uint32))

func (*MatchmakingProtocol) RegisterGathering

func (matchmakingProtocol *MatchmakingProtocol) RegisterGathering(handler func(err error, client *nex.Client, callID uint32, gathering []byte))

func (*MatchmakingProtocol) SetState

func (matchmakingProtocol *MatchmakingProtocol) SetState(handler func(err error, client *nex.Client, callID uint32, gatheringID uint32, state uint32))

func (*MatchmakingProtocol) Setup

func (matchmakingProtocol *MatchmakingProtocol) Setup()

func (*MatchmakingProtocol) TerminateGathering

func (matchmakingProtocol *MatchmakingProtocol) TerminateGathering(handler func(err error, client *nex.Client, callID uint32, gatheringID uint32))

func (*MatchmakingProtocol) UpdateGathering

func (matchmakingProtocol *MatchmakingProtocol) UpdateGathering(handler func(err error, client *nex.Client, callID uint32, gathering []byte, gatheringID uint32))

type MessageDeliveryProtocol

type MessageDeliveryProtocol struct {
	ConnectionIDCounter   *nex.Counter
	DeliverMessageHandler func(err error, client *nex.Client, callID uint32, data []byte)
	// contains filtered or unexported fields
}

func NewMessageDeliveryProtocol

func NewMessageDeliveryProtocol(server *nex.Server) *MessageDeliveryProtocol

NewMessageDeliveryProtocol returns a new MessageDeliveryProtocol

func (*MessageDeliveryProtocol) DeliverMessage

func (messageDeliveryProtocol *MessageDeliveryProtocol) DeliverMessage(handler func(err error, client *nex.Client, callID uint32, data []byte))

func (*MessageDeliveryProtocol) Setup

func (unknownProtocol *MessageDeliveryProtocol) Setup()

type MessagingProtocol

type MessagingProtocol struct {
	ConnectionIDCounter        *nex.Counter
	GetNumberOfMessagesHandler func(err error, client *nex.Client, callID uint32, pid uint32, recipientType uint32)
	GetMessageHeadersHandler   func(err error, client *nex.Client, callID uint32, pid uint32, recipientType uint32, rangeOffset uint32, rangeSize uint32)
	RetrieveMessagesHandler    func(err error, client *nex.Client, callID uint32, pid uint32, recipientType uint32, lastMessageIDs []uint32, leaveOnServer bool)
	DeleteMessagesHandler      func(err error, client *nex.Client, callID uint32, pid uint32, recipientType uint32, messageIDs []uint32)
	// contains filtered or unexported fields
}

func NewMessagingProtocol

func NewMessagingProtocol(server *nex.Server) *MessagingProtocol

NewMessagingProtocol returns a new MessagingProtocol

func (*MessagingProtocol) DeleteMessages

func (messagingProtocol *MessagingProtocol) DeleteMessages(handler func(err error, client *nex.Client, callID uint32, pid uint32, recipientType uint32, messageIDs []uint32))

func (*MessagingProtocol) GetMessageHeaders

func (messagingProtocol *MessagingProtocol) GetMessageHeaders(handler func(err error, client *nex.Client, callID uint32, pid uint32, recipientType uint32, rangeOffset uint32, rangeSize uint32))

func (*MessagingProtocol) GetNumberOfMessages

func (messagingProtocol *MessagingProtocol) GetNumberOfMessages(handler func(err error, client *nex.Client, callID uint32, pid uint32, recipientType uint32))

func (*MessagingProtocol) RetrieveMessages

func (messagingProtocol *MessagingProtocol) RetrieveMessages(handler func(err error, client *nex.Client, callID uint32, pid uint32, recipientType uint32, lastMessageIDs []uint32, leaveOnServer bool))

func (*MessagingProtocol) Setup

func (unknownProtocol *MessagingProtocol) Setup()

type NATTraversalProtocol

type NATTraversalProtocol struct {
	ConnectionIDCounter           *nex.Counter
	RequestProbeInitiationHandler func(err error, client *nex.Client, callID uint32, stationURLs []string)
	// contains filtered or unexported fields
}

JsonProtocol handles the Json requests

func NewNATTraversalProtocol

func NewNATTraversalProtocol(server *nex.Server) *NATTraversalProtocol

NewSecureProtocol returns a new SecureProtocol

func (*NATTraversalProtocol) RequestProbeInitiation

func (natTraversalProtocol *NATTraversalProtocol) RequestProbeInitiation(handler func(err error, client *nex.Client, callID uint32, stationURLs []string))

func (*NATTraversalProtocol) Setup

func (natTraversalProtocol *NATTraversalProtocol) Setup()

type NintendoLoginData

type NintendoLoginData struct {
	Token string
}

NintendoLoginData holds a nex auth token

type NintendoManagementProtocol

type NintendoManagementProtocol struct {
	GetConsoleUsernamesHandler func(err error, client *nex.Client, callID uint32, friendCode string)
	// contains filtered or unexported fields
}

func NewNintendoManagementProtocol

func NewNintendoManagementProtocol(server *nex.Server) *NintendoManagementProtocol

NewRBBinaryDataProtocol returns a new RBBinaryDataProtocol

func (*NintendoManagementProtocol) GetConsoleUsernames

func (nintendoManagementProtocol *NintendoManagementProtocol) GetConsoleUsernames(handler func(err error, client *nex.Client, callID uint32, friendCode string))

GetConsoleUsernames sets the GetConsoleUsernames handler function

func (*NintendoManagementProtocol) Setup

func (nintendoManagementProtocol *NintendoManagementProtocol) Setup()

Setup initializes the protocol

type RBBinaryDataProtocol

type RBBinaryDataProtocol struct {
	SaveBinaryDataHandler func(err error, client *nex.Client, callID uint32, metadata string, blob []byte)
	GetBinaryDataHandler  func(err error, client *nex.Client, callID uint32, metadata string)
	// contains filtered or unexported fields
}

func NewRBBinaryDataProtocol

func NewRBBinaryDataProtocol(server *nex.Server) *RBBinaryDataProtocol

NewRBBinaryDataProtocol returns a new RBBinaryDataProtocol

func (*RBBinaryDataProtocol) GetBinaryData

func (rbBinaryDataProtocol *RBBinaryDataProtocol) GetBinaryData(handler func(err error, client *nex.Client, callID uint32, metadata string))

GetBinaryData sets the GetBinaryData handler function

func (*RBBinaryDataProtocol) SaveBinaryData

func (rbBinaryDataProtocol *RBBinaryDataProtocol) SaveBinaryData(handler func(err error, client *nex.Client, callID uint32, metadata string, blob []byte))

SaveBinaryData sets the SaveBinaryData handler function

func (*RBBinaryDataProtocol) Setup

func (rbBinaryDataProtocol *RBBinaryDataProtocol) Setup()

Setup initializes the protocol

type SecureProtocol

type SecureProtocol struct {
	ConnectionIDCounter          *nex.Counter
	RegisterHandler              func(err error, client *nex.Client, callID uint32, stationUrls []*nex.StationURL)
	RequestConnectionDataHandler func(err error, client *nex.Client, callID uint32, stationCID uint32, stationPID uint32)
	RequestURLsHandler           func(err error, client *nex.Client, callID uint32, stationCID uint32, stationPID uint32)
	RegisterExHandler            func(err error, client *nex.Client, callID uint32, stationUrls []string, className string, ticketData []byte)
	TestConnectivityHandler      func(err error, client *nex.Client, callID uint32)
	UpdateURLsHandler            func(err error, client *nex.Client, callID uint32, stationUrls []*nex.StationURL)
	ReplaceURLHandler            func(err error, client *nex.Client, callID uint32, oldStation *nex.StationURL, newStation *nex.StationURL)
	SendReportHandler            func(err error, client *nex.Client, callID uint32, reportID uint32, report []byte)
	// contains filtered or unexported fields
}

SecureProtocol handles the Secure Connection nex protocol

func NewSecureProtocol

func NewSecureProtocol(server *nex.Server) *SecureProtocol

NewSecureProtocol returns a new SecureProtocol

func (*SecureProtocol) Register

func (secureProtocol *SecureProtocol) Register(handler func(err error, client *nex.Client, callID uint32, stationUrls []*nex.StationURL))

Register sets the Register handler function

func (*SecureProtocol) RegisterEx

func (secureProtocol *SecureProtocol) RegisterEx(handler func(err error, client *nex.Client, callID uint32, stationUrls []string, className string, ticketData []byte))

RegisterEx sets the RegisterEx handler function

func (*SecureProtocol) ReplaceURL

func (secureProtocol *SecureProtocol) ReplaceURL(handler func(err error, client *nex.Client, callID uint32, oldStation *nex.StationURL, newStation *nex.StationURL))

ReplaceURL sets the ReplaceURL handler function

func (*SecureProtocol) RequestConnectionData

func (secureProtocol *SecureProtocol) RequestConnectionData(handler func(err error, client *nex.Client, callID uint32, stationCID uint32, stationPID uint32))

RequestConnectionData sets the RequestConnectionData handler function

func (*SecureProtocol) RequestURLs

func (secureProtocol *SecureProtocol) RequestURLs(handler func(err error, client *nex.Client, callID uint32, stationCID uint32, stationPID uint32))

RequestURLs sets the RequestURLs handler function

func (*SecureProtocol) SendReport

func (secureProtocol *SecureProtocol) SendReport(handler func(err error, client *nex.Client, callID uint32, reportID uint32, report []byte))

SendReport sets the SendReport handler function

func (*SecureProtocol) Setup

func (secureProtocol *SecureProtocol) Setup()

Setup initializes the protocol

func (*SecureProtocol) TestConnectivity

func (secureProtocol *SecureProtocol) TestConnectivity(handler func(err error, client *nex.Client, callID uint32))

TestConnectivity sets the TestConnectivity handler function

func (*SecureProtocol) UpdateURLs

func (secureProtocol *SecureProtocol) UpdateURLs(handler func(err error, client *nex.Client, callID uint32, stationUrls []*nex.StationURL))

UpdateURLs sets the UpdateURLs handler function

type StreamIn

type StreamIn struct {
	*nex.StreamIn
}

StreamIn is an abstraction of StreamIn from github.com/ihatecompvir/nex-go Adds protocol-specific Structure list support

func NewStreamIn

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

NewStreamIn returns a new nexproto output stream

func (*StreamIn) ReadListStationURL

func (stream *StreamIn) ReadListStationURL() ([]*nex.StationURL, error)

ReadListStationURL reads a list of StationURL structures

Jump to

Keyboard shortcuts

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