مراية لـ
https://github.com/postalserver/postal.git
تم المزامنة 2025-12-01 05:43:04 +00:00
fix(smtp-server): remove ::ffff: from the start of ipv4 addresses
هذا الالتزام موجود في:
@@ -112,21 +112,23 @@ module SMTPServer
|
|||||||
# Accept the connection
|
# Accept the connection
|
||||||
new_io = io.accept
|
new_io = io.accept
|
||||||
increment_prometheus_counter :postal_smtp_server_connections_total
|
increment_prometheus_counter :postal_smtp_server_connections_total
|
||||||
|
# Get the client's IP address and strip `::ffff:` for consistency.
|
||||||
|
client_ip_address = new_io.remote_address.ip_address.sub(/\A::ffff:/, "")
|
||||||
if Postal::Config.smtp_server.proxy_protocol?
|
if Postal::Config.smtp_server.proxy_protocol?
|
||||||
# If we are using the haproxy proxy protocol, we will be sent the
|
# If we are using the haproxy proxy protocol, we will be sent the
|
||||||
# client's IP later. Delay the welcome process.
|
# client's IP later. Delay the welcome process.
|
||||||
client = Client.new(nil)
|
client = Client.new(nil)
|
||||||
if Postal::Config.smtp_server.log_connections?
|
if Postal::Config.smtp_server.log_connections?
|
||||||
client.logger&.debug "Connection opened from #{new_io.remote_address.ip_address}"
|
client.logger&.debug "Connection opened from #{client_ip_address}"
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
# We're not using the proxy protocol so we already know the client's IP
|
# We're not using the proxy protocol so we already know the client's IP
|
||||||
client = Client.new(new_io.remote_address.ip_address)
|
client = Client.new(client_ip_address)
|
||||||
if Postal::Config.smtp_server.log_connections?
|
if Postal::Config.smtp_server.log_connections?
|
||||||
client.logger&.debug "Connection opened from #{new_io.remote_address.ip_address}"
|
client.logger&.debug "Connection opened from #{client_ip_address}"
|
||||||
end
|
end
|
||||||
# We know who the client is, welcome them.
|
# We know who the client is, welcome them.
|
||||||
client.logger&.debug "Client identified as #{new_io.remote_address.ip_address}"
|
client.logger&.debug "Client identified as #{client_ip_address}"
|
||||||
new_io.print("220 #{Postal::Config.postal.smtp_hostname} ESMTP Postal/#{client.trace_id}")
|
new_io.print("220 #{Postal::Config.postal.smtp_hostname} ESMTP Postal/#{client.trace_id}")
|
||||||
end
|
end
|
||||||
# Register the client and its socket with nio4r
|
# Register the client and its socket with nio4r
|
||||||
|
|||||||
المرجع في مشكلة جديدة
حظر مستخدم