combined consumer and proxy into minimal rails backed
This commit is contained in:
parent
d3be685b08
commit
329e66c949
@ -1 +0,0 @@
|
|||||||
bettermail_consumer
|
|
@ -1,88 +0,0 @@
|
|||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
require 'dotenv/load'
|
|
||||||
require 'pg'
|
|
||||||
require 'mail'
|
|
||||||
require 'bunny'
|
|
||||||
|
|
||||||
# Server class
|
|
||||||
class BettermailConsumer
|
|
||||||
def initialize
|
|
||||||
@pg = PG::Connection.new(ENV['DATABASE_URL'])
|
|
||||||
end
|
|
||||||
|
|
||||||
def start
|
|
||||||
begin
|
|
||||||
puts ' [*] Waiting for messages. To exit press CTRL+C'
|
|
||||||
mail_queue = bunny_channel.queue(ENV['RABBIT_MAIL_QUEUE'])
|
|
||||||
mail_queue.subscribe(block: true) do |_delivery_info, _properties, body|
|
|
||||||
mail = Mail.read_from_string(body)
|
|
||||||
puts mail
|
|
||||||
end
|
|
||||||
sns_queue = bunny_channel.queue(ENV['RABBIT_SNS_QUEUE'])
|
|
||||||
sns_queue.subscribe(block: true) do |_delivery_info, _properties, body|
|
|
||||||
puts " [x] Received #{_delivery_info}"
|
|
||||||
end
|
|
||||||
rescue Interrupt => _
|
|
||||||
stop
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
def stop
|
|
||||||
@bunny_conn&.close
|
|
||||||
@pg&.close
|
|
||||||
end
|
|
||||||
|
|
||||||
def bunny_channel
|
|
||||||
if @bunny_channel.nil?
|
|
||||||
@bunny_conn = Bunny.new
|
|
||||||
@bunny_conn.start
|
|
||||||
@bunny_channel = @bunny_conn.create_channel
|
|
||||||
end
|
|
||||||
@bunny_channel
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
service_name='BetterMail::Consumer'
|
|
||||||
# Create a new server instance for listening at localhost interfaces 127.0.0.1:2525
|
|
||||||
# and accepting a maximum of 4 simultaneous connections per default
|
|
||||||
service = BettermailConsumer.new
|
|
||||||
|
|
||||||
# save flag for Ctrl-C pressed
|
|
||||||
flag_status_ctrl_c_pressed = false
|
|
||||||
|
|
||||||
# try to gracefully shutdown on Ctrl-C
|
|
||||||
trap('INT') do
|
|
||||||
# print an empty line right after ^C
|
|
||||||
puts
|
|
||||||
# notify flag about Ctrl-C was pressed
|
|
||||||
flag_status_ctrl_c_pressed = true
|
|
||||||
# signal exit to app
|
|
||||||
exit 0
|
|
||||||
end
|
|
||||||
|
|
||||||
# Output for debug
|
|
||||||
puts("Starting #{service_name}")
|
|
||||||
|
|
||||||
# setup exit code
|
|
||||||
at_exit do
|
|
||||||
# check to shutdown connection
|
|
||||||
if service
|
|
||||||
# Output for debug
|
|
||||||
puts('Ctrl-C interrupted, exit now...') if flag_status_ctrl_c_pressed
|
|
||||||
# info about shutdown
|
|
||||||
puts("Shutdown #{service_name}...")
|
|
||||||
# stop all threads and connections gracefully
|
|
||||||
service.stop
|
|
||||||
end
|
|
||||||
|
|
||||||
# Output for debug
|
|
||||||
puts "#{service_name} stopped!"
|
|
||||||
end
|
|
||||||
|
|
||||||
# Start the server
|
|
||||||
service.start
|
|
||||||
|
|
||||||
# Run on server forever
|
|
||||||
service.join
|
|
@ -1 +0,0 @@
|
|||||||
ruby ./bettermail_consumer.rb
|
|
@ -1 +0,0 @@
|
|||||||
bettermail_proxy
|
|
@ -1 +0,0 @@
|
|||||||
ruby-2.7.2
|
|
@ -1,7 +0,0 @@
|
|||||||
source 'https://rubygems.org'
|
|
||||||
ruby '2.7.2'
|
|
||||||
gem 'dotenv'
|
|
||||||
gem 'bunny'
|
|
||||||
gem 'midi-smtp-server', '~> 3.0.1'
|
|
||||||
gem 'mail'
|
|
||||||
gem 'openssl'
|
|
@ -1,34 +0,0 @@
|
|||||||
GEM
|
|
||||||
remote: https://rubygems.org/
|
|
||||||
specs:
|
|
||||||
amq-protocol (2.3.2)
|
|
||||||
bunny (2.19.0)
|
|
||||||
amq-protocol (~> 2.3, >= 2.3.1)
|
|
||||||
sorted_set (~> 1, >= 1.0.2)
|
|
||||||
dotenv (2.8.1)
|
|
||||||
mail (2.7.1)
|
|
||||||
mini_mime (>= 0.1.1)
|
|
||||||
midi-smtp-server (3.0.3)
|
|
||||||
mini_mime (1.1.2)
|
|
||||||
openssl (3.0.1)
|
|
||||||
rbtree (0.4.5)
|
|
||||||
set (1.0.3)
|
|
||||||
sorted_set (1.0.3)
|
|
||||||
rbtree
|
|
||||||
set (~> 1.0)
|
|
||||||
|
|
||||||
PLATFORMS
|
|
||||||
ruby
|
|
||||||
|
|
||||||
DEPENDENCIES
|
|
||||||
bunny
|
|
||||||
dotenv
|
|
||||||
mail
|
|
||||||
midi-smtp-server (~> 3.0.1)
|
|
||||||
openssl
|
|
||||||
|
|
||||||
RUBY VERSION
|
|
||||||
ruby 2.7.2p137
|
|
||||||
|
|
||||||
BUNDLED WITH
|
|
||||||
2.1.4
|
|
@ -1,122 +0,0 @@
|
|||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
require 'dotenv/load'
|
|
||||||
require 'midi-smtp-server'
|
|
||||||
require 'mail'
|
|
||||||
require 'bunny'
|
|
||||||
|
|
||||||
# Server class
|
|
||||||
class BettermailProxy < MidiSmtpServer::Smtpd
|
|
||||||
|
|
||||||
def stop(wait_seconds_before_close: nil, gracefully: nil)
|
|
||||||
super()
|
|
||||||
@bunny_conn&.close
|
|
||||||
end
|
|
||||||
|
|
||||||
def bunny
|
|
||||||
if @bunny.nil?
|
|
||||||
@bunny_conn = Bunny.new
|
|
||||||
@bunny_conn.start
|
|
||||||
ch = @bunny_conn.create_channel
|
|
||||||
ch.direct(ENV['RABBIT_CHANNEL'])
|
|
||||||
ch.queue(ENV['RABBIT_MAIL_QUEUE'])
|
|
||||||
@bunny = ch.default_exchange
|
|
||||||
end
|
|
||||||
@bunny
|
|
||||||
end
|
|
||||||
|
|
||||||
# update local welcome and helo response
|
|
||||||
def on_connect_event(ctx)
|
|
||||||
ctx[:server][:local_response] = 'Client connected'
|
|
||||||
ctx[:server][:helo_response] = 'Welcome to the BetterMail proxy - an SMTP drop in replacement'
|
|
||||||
end
|
|
||||||
|
|
||||||
def on_message_data_headers_event(ctx)
|
|
||||||
# check and append all headers
|
|
||||||
ctx[:message][:data] << "X-bettermail: Received by proxy at #{Time.now}" << ctx[:message][:crlf]
|
|
||||||
end
|
|
||||||
|
|
||||||
# check the authentication
|
|
||||||
# if any value returned, that will be used for ongoing processing
|
|
||||||
# otherwise the original value will be used for authorization_id
|
|
||||||
def on_auth_event(ctx, authorization_id, authentication_id, authentication)
|
|
||||||
# to proceed this test use commands ...
|
|
||||||
# auth plain
|
|
||||||
# > AGFkbWluaXN0cmF0b3IAcGFzc3dvcmQ=
|
|
||||||
# auth login
|
|
||||||
# > YWRtaW5pc3RyYXRvcg==
|
|
||||||
# > cGFzc3dvcmQ=
|
|
||||||
# if authorization_id == '' && authentication_id == 'administrator' && authentication == 'password'
|
|
||||||
# # yes
|
|
||||||
# return 'supervisor'
|
|
||||||
# end
|
|
||||||
# # otherwise exit with authentication exception
|
|
||||||
# raise MidiSmtpServer::Smtpd535Exception
|
|
||||||
logger.debug("Authenticated id: #{authentication_id} with authentication: #{authentication} from: #{ctx[:server][:remote_ip]}:#{ctx[:server][:remote_port]}")
|
|
||||||
authentication_id
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
# get each message after DATA <message> .
|
|
||||||
def on_message_data_event(ctx)
|
|
||||||
# Just decode message once to make sure, that this message ist readable
|
|
||||||
mail = Mail.read_from_string(ctx[:message][:data])
|
|
||||||
logger.info('Message good. Sending to queue for processing')
|
|
||||||
bunny.publish(mail.to_s, :headers => { 'x-smtp' => mail.header.to_s }, :routing_key => ENV["RABBIT_MAIL_QUEUE"])
|
|
||||||
logger.info('Done')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Create a new server instance for listening at localhost interfaces 127.0.0.1:2525
|
|
||||||
# and accepting a maximum of 4 simultaneous connections per default
|
|
||||||
service = BettermailProxy.new(
|
|
||||||
ports: ENV['PROXY_PORTS'],
|
|
||||||
hosts: ENV['PROXY_HOSTS'],
|
|
||||||
max_processings: 10,
|
|
||||||
auth_mode: :AUTH_REQUIRED,
|
|
||||||
tls_mode: :TLS_REQUIRED,
|
|
||||||
tls_cert_path: './ssl/cert.pem',
|
|
||||||
tls_key_path: './ssl/key.pem'
|
|
||||||
)
|
|
||||||
|
|
||||||
service_name='BetterMail::SMTPProxy'
|
|
||||||
# Create a new server instance for listening at localhost interfaces 127.0.0.1:2525
|
|
||||||
# and accepting a maximum of 4 simultaneous connections per default
|
|
||||||
|
|
||||||
# save flag for Ctrl-C pressed
|
|
||||||
flag_status_ctrl_c_pressed = false
|
|
||||||
|
|
||||||
# try to gracefully shutdown on Ctrl-C
|
|
||||||
trap('INT') do
|
|
||||||
# print an empty line right after ^C
|
|
||||||
puts
|
|
||||||
# notify flag about Ctrl-C was pressed
|
|
||||||
flag_status_ctrl_c_pressed = true
|
|
||||||
# signal exit to app
|
|
||||||
exit(0)
|
|
||||||
end
|
|
||||||
|
|
||||||
# Output for debug
|
|
||||||
puts("Starting #{service_name}")
|
|
||||||
|
|
||||||
# setup exit code
|
|
||||||
at_exit do
|
|
||||||
# check to shutdown connection
|
|
||||||
if service
|
|
||||||
# Output for debug
|
|
||||||
puts('Ctrl-C interrupted, exit now...') if flag_status_ctrl_c_pressed
|
|
||||||
# info about shutdown
|
|
||||||
puts("Shutdown #{service_name}...")
|
|
||||||
# stop all threads and connections gracefully
|
|
||||||
service.stop
|
|
||||||
end
|
|
||||||
|
|
||||||
# Output for debug
|
|
||||||
puts "#{service_name} stopped!"
|
|
||||||
end
|
|
||||||
|
|
||||||
# Start the server
|
|
||||||
service.start
|
|
||||||
|
|
||||||
# Run on server forever
|
|
||||||
service.join
|
|
@ -1,32 +0,0 @@
|
|||||||
-----BEGIN CERTIFICATE-----
|
|
||||||
MIIFbTCCA1WgAwIBAgIUAf9HBsl8FOGp9rGyrroaRmBraFAwDQYJKoZIhvcNAQEL
|
|
||||||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r0JQiIshDXV
|
|
||||||
tgElAgMBAAGjUzBRMB0GA1UdDgQWBBSL6Xv5EJCvf/MJO7U/HABHivI9dTAfBgNV
|
|
||||||
HSMEGDAWgBSL6Xv5EJCvf/MJO7U/HABHivI9dTAPBgNVHRMBAf8EBTADAQH/MA0G
|
|
||||||
CSqGSIb3DQEBCwUAA4ICAQAArEGEwU/uvTSg9ekkufsOYr7yKnlmXdoHN9BTN/6V
|
|
||||||
7sXhWdFQguW41/u/Xzm24SvaSSr0DCVs2h75tgnms/Bf9x2OK9WGTNCLmI9YDWyD
|
|
||||||
By050oQ+0BDWdDXxVAX1tz5dm4H0fTU+jzr58CoQpR1wIkmSNBdWwbWvMQeqAL8r
|
|
||||||
b6pLVElM5LdCX0OZYDt1E3Hpja6UYBro0ziGnfVLO4/UWVYBgHWU+IpiM1bZI1Iq
|
|
||||||
SYIqJwy1bC3duU0z76YvvUkNA0UiGMQbbjqorrR8ltzArV4qZaV3JcLZa1LpvTGc
|
|
||||||
7qLGNutkJvmksahvgklreb6oEc1FbFt5wew8FUgLeAZXgy8LwTyKXLq1YSLJc/QE
|
|
||||||
OaJfb7Tork2sd+/9kGwyPQ36/YaRRGIs6OaNbFTjCJs73Zyycu+RFaxewjo8offP
|
|
||||||
sozyilQAU6jl4XGO7fQOVJsUgb33pOrgI7f8EMbUAYZHGUwrbiCxNoiJRxM5e4J+
|
|
||||||
7AsPU4C21mIysndXT6v14HZBTMLbjfPASOr+FdZw7L+rtHk2iLvAfFeeMDPd4Zrb
|
|
||||||
1/xtQ6iAd64RkmwlrFvbLPWLuFK7QVRHIpAGa/aFRPq7xECuHI8cGupU+lZtrORo
|
|
||||||
YBRsYyizGXwiuMstzx8ZV+CpeW4hBfCvHiYqshceAeQd+89ljoc/iJNf0PdUgN+Q
|
|
||||||
og==
|
|
||||||
-----END CERTIFICATE-----
|
|
@ -1,52 +0,0 @@
|
|||||||
-----BEGIN PRIVATE KEY-----
|
|
||||||
MIIJQgIBADANBgkqhkiG9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xX9m3jtFNgys4GWVnkseqZR+kozJ5cCG5RyxFjlG
|
|
||||||
sBlA9g2jwjUHqPuhZeTnJ7xN994KpXK86YQ4v/hLMSMQ7wWdVcIW7w2BJLxvBA2Q
|
|
||||||
LVLLfEsFJloCoigoMEVeiTeiZhBRj28Cb9txAQ45SFI0gvVvl2I+ZAP9M0k9Cdc/
|
|
||||||
9vWblChgTPLkfpNsK00wiOG1Lji9KeRDhwm2ht1jHBhhk+dVaLyZPD7hFnog6cIV
|
|
||||||
dJdrln0uZBTkWf55AOcyN/jHdXsdxQBEVA3I3E2UwsZxRdZT7DIhNggL4xQ6RtBE
|
|
||||||
5ZADVjSHf21VhXCmSSGtL59GcaMYVA==
|
|
||||||
-----END PRIVATE KEY-----
|
|
@ -1 +0,0 @@
|
|||||||
ruby ./bettermail_proxy.rb
|
|
1
tests/.ruby-gemset
Normal file
1
tests/.ruby-gemset
Normal file
@ -0,0 +1 @@
|
|||||||
|
bettermail_tests
|
@ -1,6 +1,5 @@
|
|||||||
source 'https://rubygems.org'
|
source 'https://rubygems.org'
|
||||||
ruby '2.7.2'
|
ruby '2.7.2'
|
||||||
gem 'dotenv'
|
|
||||||
gem 'bunny'
|
gem 'bunny'
|
||||||
gem 'mail'
|
gem 'mail'
|
||||||
gem 'pg'
|
|
@ -5,11 +5,9 @@ GEM
|
|||||||
bunny (2.19.0)
|
bunny (2.19.0)
|
||||||
amq-protocol (~> 2.3, >= 2.3.1)
|
amq-protocol (~> 2.3, >= 2.3.1)
|
||||||
sorted_set (~> 1, >= 1.0.2)
|
sorted_set (~> 1, >= 1.0.2)
|
||||||
dotenv (2.8.1)
|
|
||||||
mail (2.7.1)
|
mail (2.7.1)
|
||||||
mini_mime (>= 0.1.1)
|
mini_mime (>= 0.1.1)
|
||||||
mini_mime (1.1.2)
|
mini_mime (1.1.2)
|
||||||
pg (1.4.4)
|
|
||||||
rbtree (0.4.5)
|
rbtree (0.4.5)
|
||||||
set (1.0.3)
|
set (1.0.3)
|
||||||
sorted_set (1.0.3)
|
sorted_set (1.0.3)
|
||||||
@ -21,9 +19,7 @@ PLATFORMS
|
|||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
bunny
|
bunny
|
||||||
dotenv
|
|
||||||
mail
|
mail
|
||||||
pg
|
|
||||||
|
|
||||||
RUBY VERSION
|
RUBY VERSION
|
||||||
ruby 2.7.2p137
|
ruby 2.7.2p137
|
31
tests/test_sending_emails.rb
Normal file
31
tests/test_sending_emails.rb
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require 'mail'
|
||||||
|
require 'bunny'
|
||||||
|
require 'securerandom'
|
||||||
|
|
||||||
|
@default_smtp_settings = {
|
||||||
|
address: 'localhost',
|
||||||
|
port: '2025',
|
||||||
|
user_name: 'hello',
|
||||||
|
password: 'world',
|
||||||
|
enable_starttls_auto: true,
|
||||||
|
authentication: 'plain',
|
||||||
|
openssl_verify_mode: 'none'
|
||||||
|
}
|
||||||
|
|
||||||
|
def send_mail(index)
|
||||||
|
mail = Mail.new(
|
||||||
|
from: "test-#{index}-#{SecureRandom.uuid}@thefactory.local",
|
||||||
|
to: "#{SecureRandom.uuid}@acme.local",
|
||||||
|
cc: "cc-#{SecureRandom.uuid}@acme.local",
|
||||||
|
bcc: "bcc-#{SecureRandom.uuid}@acme.local",
|
||||||
|
subject: "Testing #{index}",
|
||||||
|
)
|
||||||
|
mail.delivery_method :smtp, @default_smtp_settings
|
||||||
|
mail.deliver!
|
||||||
|
end
|
||||||
|
|
||||||
|
number_of_emails = ARGV[0] || 1
|
||||||
|
|
||||||
|
send_mail number_of_emails
|
Loading…
x
Reference in New Issue
Block a user