mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-02-04 09:15:08 +01:00
add option for maximum hexdump length
This commit is contained in:
@@ -1,81 +1,82 @@
|
|||||||
{
|
{
|
||||||
"host_ip": "127.0.0.1",
|
"host_ip": "127.0.0.1",
|
||||||
"bin_path": "bin",
|
"bin_path": "bin",
|
||||||
"devmode": true,
|
"devmode": true,
|
||||||
"devmodeoptions": {
|
"devmodeoptions": {
|
||||||
"serverName" : "",
|
"serverName" : "",
|
||||||
"cleandb": false,
|
"cleandb": false,
|
||||||
"maxlauncherhr": true,
|
"maxlauncherhr": true,
|
||||||
"LogInboundMessages": false,
|
"LogInboundMessages": false,
|
||||||
"LogOutboundMessages": false,
|
"LogOutboundMessages": false,
|
||||||
"Event": 0,
|
"MaxHexdumpLength": 256,
|
||||||
"DivaEvent": 0,
|
"Event": 0,
|
||||||
"FestaEvent": 0,
|
"DivaEvent": 0,
|
||||||
"TournamentEvent": 0,
|
"FestaEvent": 0,
|
||||||
"MezFesEvent": true,
|
"TournamentEvent": 0,
|
||||||
"SaveDumps": {
|
"MezFesEvent": true,
|
||||||
"Enabled": true,
|
"SaveDumps": {
|
||||||
"OutputDir": "savedata"
|
"Enabled": true,
|
||||||
}
|
"OutputDir": "savedata"
|
||||||
},
|
}
|
||||||
"discord": {
|
},
|
||||||
"enabled": false,
|
"discord": {
|
||||||
"bottoken": "",
|
"enabled": false,
|
||||||
"realtimeChannelID": "",
|
"bottoken": "",
|
||||||
"serverId": "",
|
"realtimeChannelID": "",
|
||||||
"devRoles": [],
|
"serverId": "",
|
||||||
"devMode": false
|
"devRoles": [],
|
||||||
},
|
"devMode": false
|
||||||
"database": {
|
},
|
||||||
"host": "localhost",
|
"database": {
|
||||||
"port": 5432,
|
"host": "localhost",
|
||||||
"user": "postgres",
|
"port": 5432,
|
||||||
"password": "",
|
"user": "postgres",
|
||||||
"database": "erupe"
|
"password": "",
|
||||||
},
|
"database": "erupe"
|
||||||
"launcher": {
|
},
|
||||||
"port": 80,
|
"launcher": {
|
||||||
"UseOriginalLauncherFiles": false
|
"port": 80,
|
||||||
},
|
"UseOriginalLauncherFiles": false
|
||||||
"sign": {
|
},
|
||||||
"port": 53312
|
"sign": {
|
||||||
},
|
"port": 53312
|
||||||
"entrance": {
|
},
|
||||||
"port": 53310,
|
"entrance": {
|
||||||
"entries": [
|
"port": 53310,
|
||||||
{
|
"entries": [
|
||||||
"name": "Newbie", "description": "", "ip": "", "type": 3, "recommended": 2, "allowedclientflags": 0,
|
{
|
||||||
"channels": [
|
"name": "Newbie", "description": "", "ip": "", "type": 3, "recommended": 2, "allowedclientflags": 0,
|
||||||
{ "port": 54001, "MaxPlayers": 50, "Unk0": 319, "Unk1": 252, "Unk2": 248 },
|
"channels": [
|
||||||
{ "port": 54002, "MaxPlayers": 50, "Unk0": 319, "Unk1": 252, "Unk2": 248 }
|
{ "port": 54001, "MaxPlayers": 50, "Unk0": 319, "Unk1": 252, "Unk2": 248 },
|
||||||
]
|
{ "port": 54002, "MaxPlayers": 50, "Unk0": 319, "Unk1": 252, "Unk2": 248 }
|
||||||
}, {
|
]
|
||||||
"name": "Normal", "description": "", "ip": "", "type": 1, "recommended": 0, "allowedclientflags": 0,
|
}, {
|
||||||
"channels": [
|
"name": "Normal", "description": "", "ip": "", "type": 1, "recommended": 0, "allowedclientflags": 0,
|
||||||
{ "port": 54003, "MaxPlayers": 50, "Unk0": 319, "Unk1": 252, "Unk2": 248 },
|
"channels": [
|
||||||
{ "port": 54004, "MaxPlayers": 50, "Unk0": 319, "Unk1": 252, "Unk2": 248 }
|
{ "port": 54003, "MaxPlayers": 50, "Unk0": 319, "Unk1": 252, "Unk2": 248 },
|
||||||
]
|
{ "port": 54004, "MaxPlayers": 50, "Unk0": 319, "Unk1": 252, "Unk2": 248 }
|
||||||
}, {
|
]
|
||||||
"name": "Cities", "description": "", "ip": "", "type": 2, "recommended": 0, "allowedclientflags": 0,
|
}, {
|
||||||
"channels": [
|
"name": "Cities", "description": "", "ip": "", "type": 2, "recommended": 0, "allowedclientflags": 0,
|
||||||
{ "port": 54005, "MaxPlayers": 50, "Unk0": 319, "Unk1": 252, "Unk2": 248 }
|
"channels": [
|
||||||
]
|
{ "port": 54005, "MaxPlayers": 50, "Unk0": 319, "Unk1": 252, "Unk2": 248 }
|
||||||
}, {
|
]
|
||||||
"name": "Tavern", "description": "", "ip": "", "type": 4, "recommended": 0, "allowedclientflags": 0,
|
}, {
|
||||||
"channels": [
|
"name": "Tavern", "description": "", "ip": "", "type": 4, "recommended": 0, "allowedclientflags": 0,
|
||||||
{ "port": 54006, "MaxPlayers": 50, "Unk0": 319, "Unk1": 252, "Unk2": 248 }
|
"channels": [
|
||||||
]
|
{ "port": 54006, "MaxPlayers": 50, "Unk0": 319, "Unk1": 252, "Unk2": 248 }
|
||||||
}, {
|
]
|
||||||
"name": "Return", "description": "", "ip": "", "type": 5, "recommended": 0, "allowedclientflags": 0,
|
}, {
|
||||||
"channels": [
|
"name": "Return", "description": "", "ip": "", "type": 5, "recommended": 0, "allowedclientflags": 0,
|
||||||
{ "port": 54007, "MaxPlayers": 50, "Unk0": 319, "Unk1": 252, "Unk2": 248 }
|
"channels": [
|
||||||
]
|
{ "port": 54007, "MaxPlayers": 50, "Unk0": 319, "Unk1": 252, "Unk2": 248 }
|
||||||
}, {
|
]
|
||||||
"name": "MezFes", "description": "", "ip": "", "type": 6, "recommended": 6, "allowedclientflags": 0,
|
}, {
|
||||||
"channels": [
|
"name": "MezFes", "description": "", "ip": "", "type": 6, "recommended": 6, "allowedclientflags": 0,
|
||||||
{ "port": 54008, "MaxPlayers": 50, "Unk0": 319, "Unk1": 252, "Unk2": 248 }
|
"channels": [
|
||||||
]
|
{ "port": 54008, "MaxPlayers": 50, "Unk0": 319, "Unk1": 252, "Unk2": 248 }
|
||||||
}
|
]
|
||||||
]
|
}
|
||||||
}
|
]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,145 +1,146 @@
|
|||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config holds the global server-wide config.
|
// Config holds the global server-wide config.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
HostIP string `mapstructure:"host_ip"`
|
HostIP string `mapstructure:"host_ip"`
|
||||||
BinPath string `mapstructure:"bin_path"`
|
BinPath string `mapstructure:"bin_path"`
|
||||||
DevMode bool
|
DevMode bool
|
||||||
|
|
||||||
DevModeOptions DevModeOptions
|
DevModeOptions DevModeOptions
|
||||||
Discord Discord
|
Discord Discord
|
||||||
Database Database
|
Database Database
|
||||||
Launcher Launcher
|
Launcher Launcher
|
||||||
Sign Sign
|
Sign Sign
|
||||||
Entrance Entrance
|
Entrance Entrance
|
||||||
}
|
}
|
||||||
|
|
||||||
// DevModeOptions holds various debug/temporary options for use while developing Erupe.
|
// DevModeOptions holds various debug/temporary options for use while developing Erupe.
|
||||||
type DevModeOptions struct {
|
type DevModeOptions struct {
|
||||||
ServerName string // To get specific instance server about (Current Players/Event Week)
|
ServerName string // To get specific instance server about (Current Players/Event Week)
|
||||||
CleanDB bool // Automatically wipes the DB on server reset.
|
CleanDB bool // Automatically wipes the DB on server reset.
|
||||||
MaxLauncherHR bool // Sets the HR returned in the launcher to HR9 so that you can join non-beginner worlds.
|
MaxLauncherHR bool // Sets the HR returned in the launcher to HR9 so that you can join non-beginner worlds.
|
||||||
FixedStageID bool // Causes all move_stage to use the ID sl1Ns200p0a0u0 to get you into all stages
|
FixedStageID bool // Causes all move_stage to use the ID sl1Ns200p0a0u0 to get you into all stages
|
||||||
LogInboundMessages bool // Log all messages sent to the server
|
LogInboundMessages bool // Log all messages sent to the server
|
||||||
LogOutboundMessages bool // Log all messages sent to the clients
|
LogOutboundMessages bool // Log all messages sent to the clients
|
||||||
DivaEvent int // Diva Defense event status
|
MaxHexdumpLength int // Maximum number of bytes printed when logs are enabled
|
||||||
FestaEvent int // Hunter's Festa event status
|
DivaEvent int // Diva Defense event status
|
||||||
TournamentEvent int // VS Tournament event status
|
FestaEvent int // Hunter's Festa event status
|
||||||
MezFesEvent bool // MezFes status
|
TournamentEvent int // VS Tournament event status
|
||||||
SaveDumps SaveDumpOptions
|
MezFesEvent bool // MezFes status
|
||||||
}
|
SaveDumps SaveDumpOptions
|
||||||
|
}
|
||||||
type SaveDumpOptions struct {
|
|
||||||
Enabled bool
|
type SaveDumpOptions struct {
|
||||||
OutputDir string
|
Enabled bool
|
||||||
}
|
OutputDir string
|
||||||
|
}
|
||||||
// Discord holds the discord integration config.
|
|
||||||
type Discord struct {
|
// Discord holds the discord integration config.
|
||||||
Enabled bool
|
type Discord struct {
|
||||||
BotToken string
|
Enabled bool
|
||||||
ServerID string
|
BotToken string
|
||||||
RealtimeChannelID string
|
ServerID string
|
||||||
DevRoles []string
|
RealtimeChannelID string
|
||||||
DevMode bool
|
DevRoles []string
|
||||||
}
|
DevMode bool
|
||||||
|
}
|
||||||
// Database holds the postgres database config.
|
|
||||||
type Database struct {
|
// Database holds the postgres database config.
|
||||||
Host string
|
type Database struct {
|
||||||
Port int
|
Host string
|
||||||
User string
|
Port int
|
||||||
Password string
|
User string
|
||||||
Database string
|
Password string
|
||||||
}
|
Database string
|
||||||
|
}
|
||||||
// Launcher holds the launcher server config.
|
|
||||||
type Launcher struct {
|
// Launcher holds the launcher server config.
|
||||||
Port int
|
type Launcher struct {
|
||||||
UseOriginalLauncherFiles bool
|
Port int
|
||||||
}
|
UseOriginalLauncherFiles bool
|
||||||
|
}
|
||||||
// Sign holds the sign server config.
|
|
||||||
type Sign struct {
|
// Sign holds the sign server config.
|
||||||
Port int
|
type Sign struct {
|
||||||
}
|
Port int
|
||||||
|
}
|
||||||
// Entrance holds the entrance server config.
|
|
||||||
type Entrance struct {
|
// Entrance holds the entrance server config.
|
||||||
Port uint16
|
type Entrance struct {
|
||||||
Entries []EntranceServerInfo
|
Port uint16
|
||||||
}
|
Entries []EntranceServerInfo
|
||||||
|
}
|
||||||
// EntranceServerInfo represents an entry in the serverlist.
|
|
||||||
type EntranceServerInfo struct {
|
// EntranceServerInfo represents an entry in the serverlist.
|
||||||
IP string
|
type EntranceServerInfo struct {
|
||||||
Type uint8 // Server type. 0=?, 1=open, 2=cities, 3=newbie, 4=bar
|
IP string
|
||||||
Season uint8 // Server activity. 0 = green, 1 = orange, 2 = blue
|
Type uint8 // Server type. 0=?, 1=open, 2=cities, 3=newbie, 4=bar
|
||||||
Recommended uint8 // Something to do with server recommendation on 0, 3, and 5.
|
Season uint8 // Server activity. 0 = green, 1 = orange, 2 = blue
|
||||||
Name string // Server name, 66 byte null terminated Shift-JIS(JP) or Big5(TW).
|
Recommended uint8 // Something to do with server recommendation on 0, 3, and 5.
|
||||||
Description string // Server description
|
Name string // Server name, 66 byte null terminated Shift-JIS(JP) or Big5(TW).
|
||||||
// 4096(PC, PS3/PS4)?, 8258(PC, PS3/PS4)?, 8192 == nothing?
|
Description string // Server description
|
||||||
// THIS ONLY EXISTS IF Binary8Header.type == "SV2", NOT "SVR"!
|
// 4096(PC, PS3/PS4)?, 8258(PC, PS3/PS4)?, 8192 == nothing?
|
||||||
AllowedClientFlags uint32
|
// THIS ONLY EXISTS IF Binary8Header.type == "SV2", NOT "SVR"!
|
||||||
|
AllowedClientFlags uint32
|
||||||
Channels []EntranceChannelInfo
|
|
||||||
}
|
Channels []EntranceChannelInfo
|
||||||
|
}
|
||||||
// EntranceChannelInfo represents an entry in a server's channel list.
|
|
||||||
type EntranceChannelInfo struct {
|
// EntranceChannelInfo represents an entry in a server's channel list.
|
||||||
Port uint16
|
type EntranceChannelInfo struct {
|
||||||
MaxPlayers uint16
|
Port uint16
|
||||||
CurrentPlayers uint16
|
MaxPlayers uint16
|
||||||
Unk0 uint16
|
CurrentPlayers uint16
|
||||||
Unk1 uint16
|
Unk0 uint16
|
||||||
Unk2 uint16
|
Unk1 uint16
|
||||||
}
|
Unk2 uint16
|
||||||
|
}
|
||||||
// getOutboundIP4 gets the preferred outbound ip4 of this machine
|
|
||||||
// From https://stackoverflow.com/a/37382208
|
// getOutboundIP4 gets the preferred outbound ip4 of this machine
|
||||||
func getOutboundIP4() net.IP {
|
// From https://stackoverflow.com/a/37382208
|
||||||
conn, err := net.Dial("udp4", "8.8.8.8:80")
|
func getOutboundIP4() net.IP {
|
||||||
if err != nil {
|
conn, err := net.Dial("udp4", "8.8.8.8:80")
|
||||||
log.Fatal(err)
|
if err != nil {
|
||||||
}
|
log.Fatal(err)
|
||||||
defer conn.Close()
|
}
|
||||||
|
defer conn.Close()
|
||||||
localAddr := conn.LocalAddr().(*net.UDPAddr)
|
|
||||||
|
localAddr := conn.LocalAddr().(*net.UDPAddr)
|
||||||
return localAddr.IP.To4()
|
|
||||||
}
|
return localAddr.IP.To4()
|
||||||
|
}
|
||||||
// LoadConfig loads the given config toml file.
|
|
||||||
func LoadConfig() (*Config, error) {
|
// LoadConfig loads the given config toml file.
|
||||||
viper.SetConfigName("config")
|
func LoadConfig() (*Config, error) {
|
||||||
viper.AddConfigPath(".")
|
viper.SetConfigName("config")
|
||||||
|
viper.AddConfigPath(".")
|
||||||
viper.SetDefault("DevModeOptions.SaveDumps", SaveDumpOptions{
|
|
||||||
Enabled: false,
|
viper.SetDefault("DevModeOptions.SaveDumps", SaveDumpOptions{
|
||||||
OutputDir: "savedata",
|
Enabled: false,
|
||||||
})
|
OutputDir: "savedata",
|
||||||
|
})
|
||||||
err := viper.ReadInConfig()
|
|
||||||
if err != nil {
|
err := viper.ReadInConfig()
|
||||||
return nil, err
|
if err != nil {
|
||||||
}
|
return nil, err
|
||||||
|
}
|
||||||
c := &Config{}
|
|
||||||
err = viper.Unmarshal(c)
|
c := &Config{}
|
||||||
if err != nil {
|
err = viper.Unmarshal(c)
|
||||||
return nil, err
|
if err != nil {
|
||||||
}
|
return nil, err
|
||||||
|
}
|
||||||
if c.HostIP == "" {
|
|
||||||
c.HostIP = getOutboundIP4().To4().String()
|
if c.HostIP == "" {
|
||||||
}
|
c.HostIP = getOutboundIP4().To4().String()
|
||||||
|
}
|
||||||
return c, nil
|
|
||||||
}
|
return c, nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -239,5 +239,9 @@ func (s *Session) logMessage(opcode uint16, data []byte, sender string, recipien
|
|||||||
}
|
}
|
||||||
fmt.Printf("[%s] -> [%s]\n", sender, recipient)
|
fmt.Printf("[%s] -> [%s]\n", sender, recipient)
|
||||||
fmt.Printf("Opcode: %s\n", opcodePID)
|
fmt.Printf("Opcode: %s\n", opcodePID)
|
||||||
fmt.Printf("Data [%d bytes]:\n%s\n", len(data), hex.Dump(data))
|
if len(data) <= s.server.erupeConfig.DevModeOptions.MaxHexdumpLength {
|
||||||
|
fmt.Printf("Data [%d bytes]:\n%s\n", len(data), hex.Dump(data))
|
||||||
|
} else {
|
||||||
|
fmt.Printf("Data [%d bytes]:\n(Too long!)\n\n", len(data))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user