1
0
مراية لـ https://github.com/postalserver/postal.git تم المزامنة 2025-11-30 21:32:30 +00:00

feat: configurable trusted proxies for web requests

هذا الالتزام موجود في:
Adam Cooke
2024-03-05 22:54:19 +00:00
الأصل 9bf6152060
التزام 3785c99851
4 ملفات معدلة مع 16 إضافات و12 حذوفات

عرض الملف

@@ -1,15 +1,10 @@
# frozen_string_literal: true
module Rack
class Request
module Helpers
def trusted_proxy?(ip)
ip =~ /^127\.0\.0\.1$|^localhost$|^unix$$/i
end
end
Rack::Request.ip_filter = lambda { |ip|
if Postal::Config.postal.trusted_proxies.any? { |net| net.include?(ip) } ||
ip.match(/\A127\.0\.0\.1\Z|\A::1\Z|\Afd[0-9a-f]{2}:.+|\Alocalhost\Z|\Aunix\Z|\Aunix:/i)
true
else
false
end
end
}