Loading .gitignore +1 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ build/* data/* .GITHUB_TOKEN .idea *.iml install/cloud/**/*.json ### Go ### Loading CHANGELOG.md +4 −0 Original line number Diff line number Diff line Loading @@ -5,6 +5,10 @@ The format is based on [keep a changelog](http://keepachangelog.com/) and this p ## [Unreleased] ### Changed - Configuration in dashboard is now displayed as YAML. ### Fixed - Improve group SQL query with type information. Loading dashboard/src/components/ConfigViewer.vue +32 −1 Original line number Diff line number Diff line Loading @@ -33,6 +33,37 @@ d: '', }; function jsonToYaml(obj, depth, acc) { const type = typeof obj; if (obj instanceof Array) { obj.forEach((ele) => { const subAcc = []; jsonToYaml(ele, depth + 1, subAcc); const empty = subAcc.length === 0; const prefix = `${' '.repeat(depth)}- `; acc.push((empty ? '' : '\n') + (empty ? '' : prefix) + subAcc.join(`\n${prefix}`).trim()); }); } else if (type === 'object') { let first = true; const prefix = ' '.repeat(depth); Object.keys(obj).forEach((k) => { if (Object.prototype.hasOwnProperty.call(obj, k)) { acc.push(`${first ? `\n${prefix}` : prefix}${k}:${jsonToYaml(obj[k], depth + 1, [])}`); first = false; } }); } else if (type === 'string') { acc.push(` "${obj}"`); } else if (type === 'boolean') { acc.push(obj ? ' true' : ' false'); } else if (type === 'number') { acc.push(` ${obj.toString()}`); } else { acc.push(' null'); } return acc.join('\n'); } export default { name: 'config-viewer', created() { Loading @@ -50,7 +81,7 @@ this.$notify.error({ title: 'Operation Failed', message: response.statusText }); } response.json().then((json) => { configData.d = JSON.stringify(json, null, 2); configData.d = jsonToYaml(json, 0, []).trim(); }); }).catch(() => { loadingInstance.close(); Loading server/config.go +22 −22 Original line number Diff line number Diff line Loading @@ -36,15 +36,15 @@ type Config interface { } type config struct { Name string `yaml:"name"` Datadir string `yaml:"data_dir"` Port int `yaml:"port"` OpsPort int `yaml:"ops_port"` Dsns []string `yaml:"dsns"` Session *SessionConfig `yaml:"session"` Transport *TransportConfig `yaml:"transport"` Database *DatabaseConfig `yaml:"database"` Social *SocialConfig `yaml:"social"` Name string `yaml:"name" json:"name"` Datadir string `yaml:"data_dir" json:"data_dir"` Port int `yaml:"port" json:"port"` OpsPort int `yaml:"ops_port" json:"ops_port"` Dsns []string `yaml:"dsns" json:"dsns"` Session *SessionConfig `yaml:"session" json:"session"` Transport *TransportConfig `yaml:"transport" json:"transport"` Database *DatabaseConfig `yaml:"database" json:"database"` Social *SocialConfig `yaml:"social" json:"social"` } // NewConfig constructs a Config struct which represents server settings. Loading Loading @@ -103,8 +103,8 @@ func (c *config) GetSocial() *SocialConfig { // SessionConfig is configuration relevant to the session type SessionConfig struct { EncryptionKey string `yaml:"encryption_key"` TokenExpiryMs int64 `yaml:"token_expiry_ms"` EncryptionKey string `yaml:"encryption_key" json:"encryption_key"` TokenExpiryMs int64 `yaml:"token_expiry_ms" json:"token_expiry_ms"` } // NewSessionConfig creates a new SessionConfig struct Loading @@ -117,11 +117,11 @@ func NewSessionConfig() *SessionConfig { // TransportConfig is configuration relevant to the transport socket and protocol type TransportConfig struct { ServerKey string `yaml:"server_key"` MaxMessageSizeBytes int64 `yaml:"max_message_size_bytes"` WriteWaitMs int `yaml:"write_wait_ms"` PongWaitMs int `yaml:"pong_wait_ms"` PingPeriodMs int `yaml:"ping_period_ms"` ServerKey string `yaml:"server_key" json:"server_key"` MaxMessageSizeBytes int64 `yaml:"max_message_size_bytes" json:"max_message_size_bytes"` WriteWaitMs int `yaml:"write_wait_ms" json:"write_wait_ms"` PongWaitMs int `yaml:"pong_wait_ms" json:"pong_wait_ms"` PingPeriodMs int `yaml:"ping_period_ms" json:"ping_period_ms"` } // NewTransportConfig creates a new TransportConfig struct Loading @@ -137,9 +137,9 @@ func NewTransportConfig() *TransportConfig { // DatabaseConfig is configuration relevant to the Database storage type DatabaseConfig struct { ConnMaxLifetimeMs int `yaml:"conn_max_lifetime_ms"` MaxOpenConns int `yaml:"max_open_conns"` MaxIdleConns int `yaml:"max_idle_conns"` ConnMaxLifetimeMs int `yaml:"conn_max_lifetime_ms" json:"conn_max_lifetime_ms"` MaxOpenConns int `yaml:"max_open_conns" json:"max_open_conns"` MaxIdleConns int `yaml:"max_idle_conns" json:"max_idle_conns"` } // NewDatabaseConfig creates a new DatabaseConfig struct Loading @@ -153,13 +153,13 @@ func NewDatabaseConfig() *DatabaseConfig { // SocialConfig is configuration relevant to the Social providers type SocialConfig struct { Steam *SocialConfigSteam `yaml:"steam"` Steam *SocialConfigSteam `yaml:"steam" json:"steam"` } // SocialConfigSteam is configuration relevant to Steam type SocialConfigSteam struct { PublisherKey string `yaml:"publisher_key"` AppID int `yaml:"app_id"` PublisherKey string `yaml:"publisher_key" json:"publisher_key"` AppID int `yaml:"app_id" json:"app_id"` } // NewSocialConfig creates a new SocialConfig struct Loading Loading
.gitignore +1 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ build/* data/* .GITHUB_TOKEN .idea *.iml install/cloud/**/*.json ### Go ### Loading
CHANGELOG.md +4 −0 Original line number Diff line number Diff line Loading @@ -5,6 +5,10 @@ The format is based on [keep a changelog](http://keepachangelog.com/) and this p ## [Unreleased] ### Changed - Configuration in dashboard is now displayed as YAML. ### Fixed - Improve group SQL query with type information. Loading
dashboard/src/components/ConfigViewer.vue +32 −1 Original line number Diff line number Diff line Loading @@ -33,6 +33,37 @@ d: '', }; function jsonToYaml(obj, depth, acc) { const type = typeof obj; if (obj instanceof Array) { obj.forEach((ele) => { const subAcc = []; jsonToYaml(ele, depth + 1, subAcc); const empty = subAcc.length === 0; const prefix = `${' '.repeat(depth)}- `; acc.push((empty ? '' : '\n') + (empty ? '' : prefix) + subAcc.join(`\n${prefix}`).trim()); }); } else if (type === 'object') { let first = true; const prefix = ' '.repeat(depth); Object.keys(obj).forEach((k) => { if (Object.prototype.hasOwnProperty.call(obj, k)) { acc.push(`${first ? `\n${prefix}` : prefix}${k}:${jsonToYaml(obj[k], depth + 1, [])}`); first = false; } }); } else if (type === 'string') { acc.push(` "${obj}"`); } else if (type === 'boolean') { acc.push(obj ? ' true' : ' false'); } else if (type === 'number') { acc.push(` ${obj.toString()}`); } else { acc.push(' null'); } return acc.join('\n'); } export default { name: 'config-viewer', created() { Loading @@ -50,7 +81,7 @@ this.$notify.error({ title: 'Operation Failed', message: response.statusText }); } response.json().then((json) => { configData.d = JSON.stringify(json, null, 2); configData.d = jsonToYaml(json, 0, []).trim(); }); }).catch(() => { loadingInstance.close(); Loading
server/config.go +22 −22 Original line number Diff line number Diff line Loading @@ -36,15 +36,15 @@ type Config interface { } type config struct { Name string `yaml:"name"` Datadir string `yaml:"data_dir"` Port int `yaml:"port"` OpsPort int `yaml:"ops_port"` Dsns []string `yaml:"dsns"` Session *SessionConfig `yaml:"session"` Transport *TransportConfig `yaml:"transport"` Database *DatabaseConfig `yaml:"database"` Social *SocialConfig `yaml:"social"` Name string `yaml:"name" json:"name"` Datadir string `yaml:"data_dir" json:"data_dir"` Port int `yaml:"port" json:"port"` OpsPort int `yaml:"ops_port" json:"ops_port"` Dsns []string `yaml:"dsns" json:"dsns"` Session *SessionConfig `yaml:"session" json:"session"` Transport *TransportConfig `yaml:"transport" json:"transport"` Database *DatabaseConfig `yaml:"database" json:"database"` Social *SocialConfig `yaml:"social" json:"social"` } // NewConfig constructs a Config struct which represents server settings. Loading Loading @@ -103,8 +103,8 @@ func (c *config) GetSocial() *SocialConfig { // SessionConfig is configuration relevant to the session type SessionConfig struct { EncryptionKey string `yaml:"encryption_key"` TokenExpiryMs int64 `yaml:"token_expiry_ms"` EncryptionKey string `yaml:"encryption_key" json:"encryption_key"` TokenExpiryMs int64 `yaml:"token_expiry_ms" json:"token_expiry_ms"` } // NewSessionConfig creates a new SessionConfig struct Loading @@ -117,11 +117,11 @@ func NewSessionConfig() *SessionConfig { // TransportConfig is configuration relevant to the transport socket and protocol type TransportConfig struct { ServerKey string `yaml:"server_key"` MaxMessageSizeBytes int64 `yaml:"max_message_size_bytes"` WriteWaitMs int `yaml:"write_wait_ms"` PongWaitMs int `yaml:"pong_wait_ms"` PingPeriodMs int `yaml:"ping_period_ms"` ServerKey string `yaml:"server_key" json:"server_key"` MaxMessageSizeBytes int64 `yaml:"max_message_size_bytes" json:"max_message_size_bytes"` WriteWaitMs int `yaml:"write_wait_ms" json:"write_wait_ms"` PongWaitMs int `yaml:"pong_wait_ms" json:"pong_wait_ms"` PingPeriodMs int `yaml:"ping_period_ms" json:"ping_period_ms"` } // NewTransportConfig creates a new TransportConfig struct Loading @@ -137,9 +137,9 @@ func NewTransportConfig() *TransportConfig { // DatabaseConfig is configuration relevant to the Database storage type DatabaseConfig struct { ConnMaxLifetimeMs int `yaml:"conn_max_lifetime_ms"` MaxOpenConns int `yaml:"max_open_conns"` MaxIdleConns int `yaml:"max_idle_conns"` ConnMaxLifetimeMs int `yaml:"conn_max_lifetime_ms" json:"conn_max_lifetime_ms"` MaxOpenConns int `yaml:"max_open_conns" json:"max_open_conns"` MaxIdleConns int `yaml:"max_idle_conns" json:"max_idle_conns"` } // NewDatabaseConfig creates a new DatabaseConfig struct Loading @@ -153,13 +153,13 @@ func NewDatabaseConfig() *DatabaseConfig { // SocialConfig is configuration relevant to the Social providers type SocialConfig struct { Steam *SocialConfigSteam `yaml:"steam"` Steam *SocialConfigSteam `yaml:"steam" json:"steam"` } // SocialConfigSteam is configuration relevant to Steam type SocialConfigSteam struct { PublisherKey string `yaml:"publisher_key"` AppID int `yaml:"app_id"` PublisherKey string `yaml:"publisher_key" json:"publisher_key"` AppID int `yaml:"app_id" json:"app_id"` } // NewSocialConfig creates a new SocialConfig struct Loading