()
| 86 | } |
| 87 | |
| 88 | func (s *UdpServer) loadBaseConfig() error { |
| 89 | // config.toml |
| 90 | fileName := filepath.Join(ExeDirPath, "etc", "config.toml") |
| 91 | content, err := s.loadConfigFile(fileName) |
| 92 | if err != nil { |
| 93 | log.Error("load base config err: %v", err) |
| 94 | return err |
| 95 | } |
| 96 | // pelletier/go-toml/v2 silently drops unknown sections, so a stale |
| 97 | // [webrtc] block in an upgraded config.toml would otherwise produce |
| 98 | // no signal that the transport is gone. Warn loudly once at load. |
| 99 | if strings.Contains(string(content), "[webrtc]") { |
| 100 | log.Warning("[loadBaseConfig] [webrtc] section in config.toml is ignored: " + |
| 101 | "the WebRTC transport was removed; delete the section to silence this warning") |
| 102 | } |
| 103 | |
| 104 | var config Config |
| 105 | if err := toml.Unmarshal(content, &config); err != nil { |
| 106 | log.Error("failed to unmarshal base config: %v", err) |
| 107 | } |
| 108 | if err = s.updateBaseConfig(config); err != nil { |
| 109 | // report base config error |
| 110 | return err |
| 111 | } |
| 112 | |
| 113 | baseConfigWatch = utils.WatchFile(fileName, func() { |
| 114 | log.Info("base config: %s has been updated", fileName) |
| 115 | if content, err = s.loadConfigFile(fileName); err == nil { |
| 116 | if err = toml.Unmarshal(content, &config); err == nil { |
| 117 | _ = s.updateBaseConfig(config) |
| 118 | } |
| 119 | |
| 120 | } |
| 121 | }) |
| 122 | return nil |
| 123 | } |
| 124 | |
| 125 | func (s *UdpServer) loadHttpConfig() error { |
| 126 | // http.toml |
no test coverage detected