2022-11-29 20:38:39 +00:00
|
|
|
package config
|
2022-11-19 18:19:42 +00:00
|
|
|
|
|
|
|
// Config of the program.
|
|
|
|
type Config struct {
|
2022-12-02 19:10:32 +00:00
|
|
|
Cache
|
2022-11-19 18:19:42 +00:00
|
|
|
Logging
|
2022-11-19 18:34:11 +00:00
|
|
|
Server
|
2022-12-02 19:10:32 +00:00
|
|
|
Uplink
|
2022-11-19 18:19:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Logging configuration.
|
|
|
|
type Logging struct {
|
|
|
|
|
|
|
|
// AccessLog path.
|
|
|
|
AccessLog string
|
|
|
|
|
2022-11-20 16:53:51 +00:00
|
|
|
// ErrorsLog path.
|
|
|
|
ErrorsLog string
|
|
|
|
|
2022-11-19 18:19:42 +00:00
|
|
|
// Interval between access log flushes, in seconds.
|
|
|
|
Interval int
|
|
|
|
}
|
|
|
|
|
2022-11-19 18:34:11 +00:00
|
|
|
// Server configuration.
|
|
|
|
type Server struct {
|
|
|
|
|
|
|
|
// PortHTTP is port where HTTP server must listen.
|
|
|
|
// If 0, HTTP is disabled.
|
|
|
|
PortHTTP int
|
|
|
|
|
|
|
|
// PortHTTP is port where the HTTPS server must listen.
|
|
|
|
// If 0, HTTPS is disabled.
|
|
|
|
PortHTTPS int
|
2022-11-20 09:03:31 +00:00
|
|
|
|
|
|
|
// TLSCertFile contains path to cert file for TLS Server.
|
|
|
|
TLSCertFile string
|
|
|
|
|
|
|
|
// TLSCertFile contains path to key file for TLS Server.
|
|
|
|
TLSKeyFile string
|
2022-11-19 18:34:11 +00:00
|
|
|
}
|
|
|
|
|
2022-12-02 19:10:32 +00:00
|
|
|
// Uplink configuration.
|
|
|
|
type Uplink struct {
|
|
|
|
// Address contains address of the uplink server in form IP:PORT.
|
|
|
|
Address string
|
|
|
|
|
|
|
|
// Timeout for upstream queries.
|
|
|
|
Timeout int
|
|
|
|
|
|
|
|
// PrefetchInterval contains time (in milliseconds) indicating,
|
|
|
|
// how long the prefetch procedure should take.
|
|
|
|
PrefetchInterval int
|
|
|
|
}
|
|
|
|
|
|
|
|
// Cache configuration.
|
|
|
|
type Cache struct {
|
|
|
|
// Size of the main cache.
|
|
|
|
Size int
|
2022-11-19 18:19:42 +00:00
|
|
|
}
|
2022-12-02 19:10:32 +00:00
|
|
|
|
|
|
|
// Default contains the default configuration.
|
|
|
|
func Default() *Config {
|
|
|
|
return &Config{
|
|
|
|
Cache{
|
|
|
|
Size: 12800,
|
|
|
|
},
|
|
|
|
Logging{
|
|
|
|
AccessLog: "/wttr.in/log/access.log",
|
|
|
|
ErrorsLog: "/wttr.in/log/errors.log",
|
|
|
|
Interval: 300,
|
|
|
|
},
|
|
|
|
Server{
|
|
|
|
PortHTTP: 8083,
|
|
|
|
PortHTTPS: 8084,
|
|
|
|
TLSCertFile: "/wttr.in/etc/fullchain.pem",
|
|
|
|
TLSKeyFile: "/wttr.in/etc/privkey.pem",
|
|
|
|
},
|
|
|
|
Uplink{
|
|
|
|
Address: "127.0.0.1:9002",
|
|
|
|
Timeout: 30,
|
|
|
|
PrefetchInterval: 300,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Conf contains the current configuration
|
|
|
|
var Conf = Default()
|