Pass stanzas from any trusted backend

Stephen Paul Weber created

Change summary

sgx_jmp.rb | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)

Detailed changes

sgx_jmp.rb 🔗

@@ -254,11 +254,15 @@ message to: /\Aaccount@/, body: /./ do |m|
 	}
 end
 
+FROM_BACKEND =
+	"(?:#{([CONFIG[:sgx]] + CONFIG[:sgx_creds].keys)
+		.map(&Regexp.method(:escape)).join('|')})"
+
 before(
 	:iq,
 	type: [:error, :result],
 	to: /\Acustomer_/,
-	from: /(\A|@)#{CONFIG[:sgx]}(\/|\Z)/
+	from: /(\A|@)#{FROM_BACKEND}(\/|\Z)/
 ) { |iq| halt if IQ_MANAGER.fulfill(iq) }
 
 SPAM_ERRS = [
@@ -267,7 +271,7 @@ SPAM_ERRS = [
 	"destination-rejected-due-to-spam-detection"
 ].freeze
 
-before nil, to: /\Acustomer_/, from: /(\A|@)#{CONFIG[:sgx]}(\/|\Z)/ do |s|
+before nil, to: /\Acustomer_/, from: /(\A|@)#{FROM_BACKEND}(\/|\Z)/ do |s|
 	StatsD.increment("stanza_customer")
 
 	Sentry.get_current_scope.set_transaction_name("stanza_customer")
@@ -299,7 +303,7 @@ end
 ADDRESSES_NS = "http://jabber.org/protocol/address"
 message(
 	to: /\A#{CONFIG[:component][:jid]}\Z/,
-	from: /(\A|@)#{CONFIG[:sgx]}(\/|\Z)/
+	from: /(\A|@)#{FROM_BACKEND}(\/|\Z)/
 ) do |m|
 	StatsD.increment("inbound_group_text")
 	Sentry.get_current_scope.set_transaction_name("inbound_group_text")