summaryrefslogtreecommitdiffstats
path: root/gateway/gateway.go
diff options
context:
space:
mode:
Diffstat (limited to 'gateway/gateway.go')
-rw-r--r--gateway/gateway.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/gateway/gateway.go b/gateway/gateway.go
index b875ccae..af8aecd8 100644
--- a/gateway/gateway.go
+++ b/gateway/gateway.go
@@ -85,6 +85,7 @@ func (gw *Gateway) FindCanonicalMsgID(protocol string, mID string) string {
func (gw *Gateway) AddBridge(cfg *config.Bridge) error {
br := gw.Router.getBridge(cfg.Account)
if br == nil {
+ gw.checkConfig(cfg)
br = bridge.New(cfg)
br.Config = gw.Router.Config
br.General = &gw.BridgeValues().General
@@ -104,6 +105,19 @@ func (gw *Gateway) AddBridge(cfg *config.Bridge) error {
return nil
}
+func (gw *Gateway) checkConfig(cfg *config.Bridge) {
+ match := false
+ for _, key := range gw.Router.Config.Viper().AllKeys() {
+ if strings.HasPrefix(key, cfg.Account) {
+ match = true
+ break
+ }
+ }
+ if !match {
+ gw.logger.Fatalf("Account %s defined in gateway %s but no configuration found, exiting.", cfg.Account, gw.Name)
+ }
+}
+
// AddConfig associates a new configuration with the gateway object.
func (gw *Gateway) AddConfig(cfg *config.Gateway) error {
gw.Name = cfg.Name