2024-11-12 08:10:09 +00:00
|
|
|
package config
|
|
|
|
|
2024-11-12 08:59:34 +00:00
|
|
|
import common_utils "git.mic.pp.ua/anderson/nettools/common"
|
2024-11-12 08:10:09 +00:00
|
|
|
|
|
|
|
type FileTLS struct {
|
|
|
|
Enable bool `yaml:"enable" json:"enable"`
|
|
|
|
Cert string `yaml:"cert" json:"cert"`
|
|
|
|
Key string `yaml:"key" json:"key"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type TLS struct {
|
|
|
|
Cert string
|
|
|
|
Key string
|
|
|
|
}
|
|
|
|
|
|
|
|
func ApplyEnv(fileCfg FileTLS) *FileTLS {
|
|
|
|
return &FileTLS{}
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewTlsConfigFromFile(fileCfg *FileTLS, defaultCertPath, defaultKeyPath string) *TLS {
|
|
|
|
if !fileCfg.Enable {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return &TLS{
|
|
|
|
Cert: common_utils.ValOrDefaultStr(fileCfg.Cert, defaultCertPath),
|
|
|
|
Key: common_utils.ValOrDefaultStr(fileCfg.Key, defaultKeyPath),
|
|
|
|
}
|
|
|
|
}
|