Skip to content

Commit

Permalink
add the ability to specify additonal fallback relay configs
Browse files Browse the repository at this point in the history
  • Loading branch information
tpetr committed Sep 27, 2023
1 parent 59d4049 commit 5aa5810
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
11 changes: 6 additions & 5 deletions pkg/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,12 @@ type InboundProxyConfig struct {
}

type FilteredRelayConfig struct {
DestinationURL string `mapstructure:"destinationUrl"`
JSONPath string `mapstructure:"jsonPath"`
Contains []string `mapstructure:"contains"`
Equals []string `mapstructure:"equals"`
HasPrefix []string `mapstructure:"hasPrefix"`
DestinationURL string `mapstructure:"destinationUrl"`
JSONPath string `mapstructure:"jsonPath"`
Contains []string `mapstructure:"contains"`
Equals []string `mapstructure:"equals"`
HasPrefix []string `mapstructure:"hasPrefix"`
AdditionalConfigs []FilteredRelayConfig `mapstructure:"additionalConfigs"` // this is awful, but we can refactor this in the near future
}

type OutboundProxyConfig struct {
Expand Down
8 changes: 8 additions & 0 deletions pkg/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ func (config *FilteredRelayConfig) Matches(value map[string]interface{}) (bool,
return true, nil
}
}

for i := range config.AdditionalConfigs {
inner_match, inner_err := config.AdditionalConfigs[i].Matches(value)
if inner_match || inner_err != nil {
return inner_match, inner_err
}
}

return false, nil
}

Expand Down

0 comments on commit 5aa5810

Please sign in to comment.