29 lines
600 B
Go
29 lines
600 B
Go
package config
|
|
|
|
import common_utils "nettools/common"
|
|
|
|
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),
|
|
}
|
|
}
|