-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
66 lines (58 loc) · 2.81 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package websocket
import (
"github.com/kyaxcorp/go-helper/_struct"
loggerConfig "github.com/kyaxcorp/go-logger/config"
)
type Config struct {
// Should be in this format: 192.168.0.1:8080, localhost:8080 etc.. 0.0.0.0:8080
IsEnabled string `yaml:"is_enabled" mapstructure:"is_enabled" default:"yes"`
Name string
Description string
// Enable server status which will give information about the server
EnableServerStatus string `yaml:"enable_server_status" mapstructure:"enable_server_status" default:"yes"`
// Credentials for Status Access
ServerStatusUsername string `yaml:"server_status_username" mapstructure:"server_status_username" default:"admin"`
ServerStatusPassword string `yaml:"server_status_password" mapstructure:"server_status_password" default:"admin_password"`
//
EnableSSL string `yaml:"enable_ssl" mapstructure:"enable_ssl" default:"yes"`
// This is the path where the ssl cert file is being read, if no path provided, then an autogenerated certificate
//will be made and used
SSLCertFilePath string `yaml:"ssl_cert_file_path" mapstructure:"ssl_cert_file_path"`
// This is the path where the ssl key file is being read, if no path provided, then an autogenerated certificate
//will be made and used
SSLKeyFilePath string `yaml:"ssl_key_file_path" mapstructure:"ssl_key_file_path"`
// Gives permission to autogenerate certificates if are missing
SSLAutoGenerateCerts string `yaml:"ssl_auto_generate_certs" mapstructure:"ssl_auto_generate_certs" default:"yes"`
// Allow Listening on HTTP only without encryption
EnableUnsecure string `yaml:"enable_unsecure" mapstructure:"enable_unsecure" default:"yes"`
// Websocket param -> Enables compression between peers (client->server, server->client)
EnableCompression string `yaml:"enable_compression" mapstructure:"enable_compression" default:"yes"`
// Websocket param
ReadBufferSize uint64 `yaml:"read_buffer_size" mapstructure:"read_buffer_size" default:"1024"`
// Websocket param
WriteBufferSize uint64 `yaml:"write_buffer_size" mapstructure:"write_buffer_size" default:"1024"`
// HTTP Listening
ListeningAddresses []string `yaml:"listening_addresses" mapstructure:"listening_addresses"`
// HTTPS Listening
ListeningAddressesSSL []string `yaml:"listening_addresses_ssl" mapstructure:"listening_addresses_ssl"`
// This is the logger configuration!
Logger loggerConfig.Config
}
// DefaultConfig -> it will return the default config with default values
func DefaultConfig(configObj *Config) (Config, error) {
if configObj == nil {
configObj = &Config{}
}
var _err error
// Set the default values for the object!
_err = _struct.SetDefaultValues(configObj)
if _err != nil {
return *configObj, _err
}
// Setting logger defaults
_err = _struct.SetDefaultValues(&configObj.Logger)
if _err != nil {
return *configObj, _err
}
return *configObj, _err
}