Refactor server configuration and update certificate handling

- Changed the NotifyUrl in PostMeasureTaskToNF to use a hardcoded port (33030).
- Updated GetEMSState to retrieve the port from the server configuration instead of the YAML config.
- Removed deprecated RestParam struct and related code from YamlConfig.
- Deleted old certificate files (omc-server.crt, omc-server.key, omc-web.crt, omc-web.key).
- Added new certificate files (www.omc.net.crt, www.omc.net.key) for updated server configuration.
- Modified local/omc.yaml to reflect changes in server configuration and certificate paths.
- Updated main.go to load server configuration instead of rest configuration, ensuring proper handling of multiple HTTP services.
This commit is contained in:
TsMask
2025-04-27 17:21:55 +08:00
parent 80d612c56c
commit afbe029a28
12 changed files with 232 additions and 253 deletions

View File

@@ -22,39 +22,6 @@ type YamlConfig struct {
Count int `yaml:"count"`
} `yaml:"logger"`
Pprof struct {
Enabled bool `yaml:"enabled"`
Addr string `yaml:"addr"`
} `yaml:"pprof"`
// Rest []struct {
// IPv4 string `yaml:"ipv4"`
// IPv6 string `yaml:"ipv6"`
// Port uint16 `yaml:"port"`
// Scheme string `yaml:"scheme"`
// ClientAuthType int `yaml:"clientAuthType"`
// CaFile string `yaml:"caFile"`
// CertFile string `yaml:"certFile"`
// KeyFile string `yaml:"keyFile"`
// } `yaml:"rest"`
Rest []RestParam
WebServer struct {
Enabled bool `yaml:"enabled"`
RootDir string `yaml:"rootDir"`
Listen []struct {
Addr string `yaml:"addr"`
Scheme string `yaml:"scheme"`
ClientAuthType int `yaml:"clientAuthType"`
CaFile string `yaml:"caFile"`
CertFile string `yaml:"certFile"`
KeyFile string `yaml:"keyFile"`
} `yaml:"listen"`
} `yaml:"webServer"`
// Database DbConfig `yaml:"database"`
OMC struct {
UriPrefix string `yaml:"uriPrefix"`
NeType string `yaml:"neType"`
@@ -128,17 +95,6 @@ type YamlConfig struct {
} `yaml:"testConfig"`
}
type RestParam struct {
IPv4 string `yaml:"ipv4"`
IPv6 string `yaml:"ipv6"`
Port uint16 `yaml:"port"`
Scheme string `yaml:"scheme,omitempty" default:"http"`
ClientAuthType int `yaml:"clientAuthType"`
CaFile string `yaml:"caFile"`
CertFile string `yaml:"certFile"`
KeyFile string `yaml:"keyFile"`
}
// type DbConfig struct {
// Type string `yaml:"type"`
// User string `yaml:"user"`
@@ -486,23 +442,6 @@ func GetDefaultUserAgent() string {
return "OMC/" + global.Version
}
func GetOMCHostUrl() string {
var omcip string = "127.0.0.1"
var rest RestParam = yamlConfig.Rest[0]
var port uint16 = rest.Port
if rest.IPv4 != "0.0.0.0" && rest.IPv4 != "" {
omcip = rest.IPv4
} else if rest.IPv6 != "::" && rest.IPv6 != "" {
omcip = "[" + rest.IPv6 + "]"
}
var scheme string = "http"
if rest.Scheme != "" {
scheme = rest.Scheme
}
return fmt.Sprintf("%s://%s:%d", scheme, omcip, port)
}
// const defaultConfigFile = "./etc/restconf.yaml"
// func init() {