mirror of
https://github.com/PretendoNetwork/super-mario-maker.git
synced 2026-10-01 12:26:39 -05:00
Add authentication, rename secure
This commit is contained in:
5
main.go
5
main.go
@@ -9,10 +9,11 @@ import (
|
||||
var wg sync.WaitGroup
|
||||
|
||||
func main() {
|
||||
wg.Add(1)
|
||||
wg.Add(2)
|
||||
|
||||
// TODO - Add gRPC server
|
||||
go nex.StartNEXServer()
|
||||
go nex.StartAuthenticationServer()
|
||||
go nex.StartSecureServer()
|
||||
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
35
nex/authentication.go
Normal file
35
nex/authentication.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package nex
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
"github.com/PretendoNetwork/super-mario-maker-secure/globals"
|
||||
)
|
||||
|
||||
var serverBuildString string
|
||||
|
||||
func StartAuthenticationServer() {
|
||||
globals.AuthenticationServer = nex.NewServer()
|
||||
globals.AuthenticationServer.SetPRUDPVersion(1)
|
||||
globals.AuthenticationServer.SetPRUDPProtocolMinorVersion(2)
|
||||
globals.AuthenticationServer.SetDefaultNEXVersion(nex.NewNEXVersion(3, 8, 3))
|
||||
globals.AuthenticationServer.SetKerberosPassword(globals.KerberosPassword)
|
||||
globals.AuthenticationServer.SetAccessKey("9f2b4678")
|
||||
|
||||
globals.AuthenticationServer.On("Data", func(packet *nex.PacketV1) {
|
||||
request := packet.RMCRequest()
|
||||
|
||||
fmt.Println("==SMM1 - Auth==")
|
||||
fmt.Printf("Protocol ID: %d\n", request.ProtocolID())
|
||||
fmt.Printf("Method ID: %d\n", request.MethodID())
|
||||
fmt.Println("===============")
|
||||
})
|
||||
|
||||
serverBuildString = "build:3_8_29_3022_0"
|
||||
|
||||
registerCommonAuthenticationServerProtocols()
|
||||
|
||||
globals.AuthenticationServer.Listen(fmt.Sprintf(":%s", os.Getenv("PN_SMM_AUTHENTICATION_SERVER_PORT")))
|
||||
}
|
||||
30
nex/register_common_authentication_server_protocols.go
Executable file
30
nex/register_common_authentication_server_protocols.go
Executable file
@@ -0,0 +1,30 @@
|
||||
package nex
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
nex "github.com/PretendoNetwork/nex-go"
|
||||
ticket_granting "github.com/PretendoNetwork/nex-protocols-common-go/ticket-granting"
|
||||
"github.com/PretendoNetwork/super-mario-maker-secure/globals"
|
||||
)
|
||||
|
||||
func registerCommonAuthenticationServerProtocols() {
|
||||
ticketGrantingProtocol := ticket_granting.NewCommonTicketGrantingProtocol(globals.AuthenticationServer)
|
||||
|
||||
secureStationURL := nex.NewStationURL("")
|
||||
secureStationURL.SetScheme("prudps")
|
||||
secureStationURL.SetAddress(os.Getenv("PN_SMM_SECURE_SERVER_HOST"))
|
||||
port, _ := strconv.ParseUint(os.Getenv("PN_SMM_SECURE_SERVER_PORT"), 10, 32)
|
||||
secureStationURL.SetPort(uint32(port))
|
||||
secureStationURL.SetCID(1)
|
||||
secureStationURL.SetPID(2)
|
||||
secureStationURL.SetSID(1)
|
||||
secureStationURL.SetStream(10)
|
||||
secureStationURL.SetType(2)
|
||||
|
||||
ticketGrantingProtocol.SetSecureStationURL(secureStationURL)
|
||||
ticketGrantingProtocol.SetBuildName(serverBuildString)
|
||||
|
||||
globals.AuthenticationServer.SetPasswordFromPIDFunction(globals.PasswordFromPID)
|
||||
}
|
||||
@@ -5,6 +5,6 @@ import (
|
||||
"github.com/PretendoNetwork/super-mario-maker-secure/globals"
|
||||
)
|
||||
|
||||
func registerCommonProtocols() {
|
||||
secureconnection.NewCommonSecureConnectionProtocol(globals.NEXServer)
|
||||
func registerCommonSecureProtocols() {
|
||||
secureconnection.NewCommonSecureConnectionProtocol(globals.SecureServer)
|
||||
}
|
||||
33
nex/secure.go
Normal file
33
nex/secure.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package nex
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/PretendoNetwork/nex-go"
|
||||
"github.com/PretendoNetwork/super-mario-maker-secure/globals"
|
||||
)
|
||||
|
||||
func StartSecureServer() {
|
||||
globals.SecureServer = nex.NewServer()
|
||||
globals.SecureServer.SetPRUDPVersion(1)
|
||||
globals.SecureServer.SetPRUDPProtocolMinorVersion(2)
|
||||
globals.SecureServer.SetDefaultNEXVersion(nex.NewNEXVersion(3, 8, 3))
|
||||
globals.SecureServer.SetKerberosPassword(globals.KerberosPassword)
|
||||
globals.SecureServer.SetAccessKey("9f2b4678")
|
||||
|
||||
globals.SecureServer.On("Data", func(packet *nex.PacketV1) {
|
||||
request := packet.RMCRequest()
|
||||
|
||||
fmt.Println("==SMM1 - Secure==")
|
||||
fmt.Printf("Protocol ID: %d\n", request.ProtocolID())
|
||||
fmt.Printf("Method ID: %d\n", request.MethodID())
|
||||
fmt.Println("===============")
|
||||
})
|
||||
|
||||
// * Register the common handlers first so that they can be overridden if needed
|
||||
registerCommonSecureProtocols()
|
||||
registerNEXProtocols()
|
||||
|
||||
globals.SecureServer.Listen(fmt.Sprintf(":%s", os.Getenv("PN_SMM_SECURE_SERVER_PORT")))
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
package nex
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/PretendoNetwork/nex-go"
|
||||
"github.com/PretendoNetwork/super-mario-maker-secure/globals"
|
||||
)
|
||||
|
||||
func StartNEXServer() {
|
||||
globals.NEXServer = nex.NewServer()
|
||||
globals.NEXServer.SetPRUDPVersion(1)
|
||||
globals.NEXServer.SetPRUDPProtocolMinorVersion(2)
|
||||
globals.NEXServer.SetDefaultNEXVersion(nex.NewNEXVersion(3, 8, 3))
|
||||
globals.NEXServer.SetKerberosPassword(os.Getenv("KERBEROS_PASSWORD"))
|
||||
globals.NEXServer.SetAccessKey("9f2b4678")
|
||||
|
||||
globals.NEXServer.On("Data", func(packet *nex.PacketV1) {
|
||||
request := packet.RMCRequest()
|
||||
|
||||
fmt.Println("==SMM1 - Secure==")
|
||||
fmt.Printf("Protocol ID: %#v\n", request.ProtocolID())
|
||||
fmt.Printf("Method ID: %#v\n", request.MethodID())
|
||||
fmt.Println("===============")
|
||||
})
|
||||
|
||||
// * Register the common handlers first so that they can be overridden if needed
|
||||
registerCommonProtocols()
|
||||
registerNEXProtocols()
|
||||
|
||||
globals.NEXServer.Listen(":60003")
|
||||
}
|
||||
Reference in New Issue
Block a user