From 9d256dfcbac1676aea70a0d9360e0cc334639b94 Mon Sep 17 00:00:00 2001 From: Mike Sutton Date: Wed, 16 Nov 2022 01:02:18 +0100 Subject: [PATCH] added services --- services/.gitattributes | 8 + services/.gitignore | 30 +++ services/.ruby-gemset | 1 + services/.ruby-version | 1 + services/Gemfile | 17 ++ services/Gemfile.lock | 173 ++++++++++++++++++ services/README.md | 24 +++ services/Rakefile | 6 + services/app/assets/config/manifest.js | 0 services/app/models/application_record.rb | 3 + services/app/models/concerns/.keep | 0 services/app/models/mail_recipient.rb | 4 + services/app/models/received_mail.rb | 4 + services/app/models/recipient.rb | 3 + services/app/models/sender.rb | 3 + services/bin/bundle | 114 ++++++++++++ services/bin/rails | 4 + services/bin/rake | 4 + services/bin/setup | 33 ++++ services/config.ru | 6 + services/config/application.rb | 40 ++++ services/config/boot.rb | 3 + services/config/credentials.yml.enc | 1 + services/config/environment.rb | 5 + services/config/environments/development.rb | 68 +++++++ services/config/environments/production.rb | 103 +++++++++++ services/config/environments/test.rb | 49 +++++ services/config/locales/en.yml | 33 ++++ services/config/puma.rb | 43 +++++ services/config/routes.rb | 3 + services/db/migrate/20221115164901_setup.rb | 39 ++++ services/db/schema.rb | 56 ++++++ services/db/seeds.rb | 7 + services/lib/assets/.keep | 0 services/lib/bettermail/consumer.rb | 63 +++++++ services/lib/bettermail/proxy.rb | 79 ++++++++ services/lib/tasks/.keep | 0 services/lib/tasks/consumer.rake | 46 +++++ services/lib/tasks/proxy.rake | 58 ++++++ services/log/.keep | 0 services/public/404.html | 67 +++++++ services/public/422.html | 67 +++++++ services/public/500.html | 66 +++++++ .../public/apple-touch-icon-precomposed.png | 0 services/public/apple-touch-icon.png | 0 services/public/favicon.ico | 0 services/public/robots.txt | 1 + services/ssl/cert.pem | 32 ++++ services/ssl/key.pem | 52 ++++++ services/tmp/.keep | 0 services/tmp/pids/.keep | 0 services/vendor/.keep | 0 52 files changed, 1419 insertions(+) create mode 100644 services/.gitattributes create mode 100644 services/.gitignore create mode 100644 services/.ruby-gemset create mode 100644 services/.ruby-version create mode 100644 services/Gemfile create mode 100644 services/Gemfile.lock create mode 100644 services/README.md create mode 100644 services/Rakefile create mode 100644 services/app/assets/config/manifest.js create mode 100644 services/app/models/application_record.rb create mode 100644 services/app/models/concerns/.keep create mode 100644 services/app/models/mail_recipient.rb create mode 100644 services/app/models/received_mail.rb create mode 100644 services/app/models/recipient.rb create mode 100644 services/app/models/sender.rb create mode 100755 services/bin/bundle create mode 100755 services/bin/rails create mode 100755 services/bin/rake create mode 100755 services/bin/setup create mode 100644 services/config.ru create mode 100644 services/config/application.rb create mode 100644 services/config/boot.rb create mode 100644 services/config/credentials.yml.enc create mode 100644 services/config/environment.rb create mode 100644 services/config/environments/development.rb create mode 100644 services/config/environments/production.rb create mode 100644 services/config/environments/test.rb create mode 100644 services/config/locales/en.yml create mode 100644 services/config/puma.rb create mode 100644 services/config/routes.rb create mode 100644 services/db/migrate/20221115164901_setup.rb create mode 100644 services/db/schema.rb create mode 100644 services/db/seeds.rb create mode 100644 services/lib/assets/.keep create mode 100644 services/lib/bettermail/consumer.rb create mode 100644 services/lib/bettermail/proxy.rb create mode 100644 services/lib/tasks/.keep create mode 100644 services/lib/tasks/consumer.rake create mode 100644 services/lib/tasks/proxy.rake create mode 100644 services/log/.keep create mode 100644 services/public/404.html create mode 100644 services/public/422.html create mode 100644 services/public/500.html create mode 100644 services/public/apple-touch-icon-precomposed.png create mode 100644 services/public/apple-touch-icon.png create mode 100644 services/public/favicon.ico create mode 100644 services/public/robots.txt create mode 100644 services/ssl/cert.pem create mode 100644 services/ssl/key.pem create mode 100644 services/tmp/.keep create mode 100644 services/tmp/pids/.keep create mode 100644 services/vendor/.keep diff --git a/services/.gitattributes b/services/.gitattributes new file mode 100644 index 0000000..dff662b --- /dev/null +++ b/services/.gitattributes @@ -0,0 +1,8 @@ +# See https://git-scm.com/docs/gitattributes for more about git attribute files. + +# Mark the database schema as having been generated. +db/schema.rb linguist-generated + + +# Mark any vendored files as having been vendored. +vendor/* linguist-vendored diff --git a/services/.gitignore b/services/.gitignore new file mode 100644 index 0000000..eb612ef --- /dev/null +++ b/services/.gitignore @@ -0,0 +1,30 @@ +# See https://help.github.com/articles/ignoring-files for more about ignoring files. +# +# If you find yourself ignoring temporary files generated by your text editor +# or operating system, you probably want to add a global ignore instead: +# git config --global core.excludesfile '~/.gitignore_global' + +# Ignore bundler config. +/.bundle + +# Ignore the default SQLite database. +/db/*.sqlite3 +/db/*.sqlite3-* + +# Ignore all logfiles and tempfiles. +/log/* +/tmp/* +!/log/.keep +!/tmp/.keep + +# Ignore pidfiles, but keep the directory. +/tmp/pids/* +!/tmp/pids/ +!/tmp/pids/.keep + + +/public/assets +.byebug_history + +# Ignore master key for decrypting credentials and more. +/config/master.key diff --git a/services/.ruby-gemset b/services/.ruby-gemset new file mode 100644 index 0000000..ab3f356 --- /dev/null +++ b/services/.ruby-gemset @@ -0,0 +1 @@ +bettermail_services diff --git a/services/.ruby-version b/services/.ruby-version new file mode 100644 index 0000000..2eb2fe9 --- /dev/null +++ b/services/.ruby-version @@ -0,0 +1 @@ +ruby-2.7.2 diff --git a/services/Gemfile b/services/Gemfile new file mode 100644 index 0000000..a225ec6 --- /dev/null +++ b/services/Gemfile @@ -0,0 +1,17 @@ +source 'https://rubygems.org' +git_source(:github) { |repo| "https://github.com/#{repo}.git" } + +ruby '2.7.2' +gem 'dotenv-rails' +gem 'bunny' +gem 'mail' +gem 'pg' +gem 'rails', '~> 6.1.7' +gem 'midi-smtp-server', '~> 3.0.1' +gem 'openssl' + +group :development do + # Call 'byebug' anywhere in the code to stop execution and get a debugger console + gem 'listen', '~> 3.3' + gem 'spring' +end diff --git a/services/Gemfile.lock b/services/Gemfile.lock new file mode 100644 index 0000000..9f22b85 --- /dev/null +++ b/services/Gemfile.lock @@ -0,0 +1,173 @@ +GEM + remote: https://rubygems.org/ + specs: + actioncable (6.1.7) + actionpack (= 6.1.7) + activesupport (= 6.1.7) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailbox (6.1.7) + actionpack (= 6.1.7) + activejob (= 6.1.7) + activerecord (= 6.1.7) + activestorage (= 6.1.7) + activesupport (= 6.1.7) + mail (>= 2.7.1) + actionmailer (6.1.7) + actionpack (= 6.1.7) + actionview (= 6.1.7) + activejob (= 6.1.7) + activesupport (= 6.1.7) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 2.0) + actionpack (6.1.7) + actionview (= 6.1.7) + activesupport (= 6.1.7) + rack (~> 2.0, >= 2.0.9) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.2.0) + actiontext (6.1.7) + actionpack (= 6.1.7) + activerecord (= 6.1.7) + activestorage (= 6.1.7) + activesupport (= 6.1.7) + nokogiri (>= 1.8.5) + actionview (6.1.7) + activesupport (= 6.1.7) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.1, >= 1.2.0) + activejob (6.1.7) + activesupport (= 6.1.7) + globalid (>= 0.3.6) + activemodel (6.1.7) + activesupport (= 6.1.7) + activerecord (6.1.7) + activemodel (= 6.1.7) + activesupport (= 6.1.7) + activestorage (6.1.7) + actionpack (= 6.1.7) + activejob (= 6.1.7) + activerecord (= 6.1.7) + activesupport (= 6.1.7) + marcel (~> 1.0) + mini_mime (>= 1.1.0) + activesupport (6.1.7) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + zeitwerk (~> 2.3) + amq-protocol (2.3.2) + builder (3.2.4) + bunny (2.19.0) + amq-protocol (~> 2.3, >= 2.3.1) + sorted_set (~> 1, >= 1.0.2) + concurrent-ruby (1.1.10) + crass (1.0.6) + dotenv (2.8.1) + dotenv-rails (2.8.1) + dotenv (= 2.8.1) + railties (>= 3.2) + erubi (1.11.0) + ffi (1.15.5) + globalid (1.0.0) + activesupport (>= 5.0) + i18n (1.12.0) + concurrent-ruby (~> 1.0) + listen (3.7.1) + rb-fsevent (~> 0.10, >= 0.10.3) + rb-inotify (~> 0.9, >= 0.9.10) + loofah (2.19.0) + crass (~> 1.0.2) + nokogiri (>= 1.5.9) + mail (2.7.1) + mini_mime (>= 0.1.1) + marcel (1.0.2) + method_source (1.0.0) + midi-smtp-server (3.0.3) + mini_mime (1.1.2) + mini_portile2 (2.8.0) + minitest (5.16.3) + nio4r (2.5.8) + nokogiri (1.13.9) + mini_portile2 (~> 2.8.0) + racc (~> 1.4) + openssl (3.0.1) + pg (1.4.4) + racc (1.6.0) + rack (2.2.4) + rack-test (2.0.2) + rack (>= 1.3) + rails (6.1.7) + actioncable (= 6.1.7) + actionmailbox (= 6.1.7) + actionmailer (= 6.1.7) + actionpack (= 6.1.7) + actiontext (= 6.1.7) + actionview (= 6.1.7) + activejob (= 6.1.7) + activemodel (= 6.1.7) + activerecord (= 6.1.7) + activestorage (= 6.1.7) + activesupport (= 6.1.7) + bundler (>= 1.15.0) + railties (= 6.1.7) + sprockets-rails (>= 2.0.0) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.4.3) + loofah (~> 2.3) + railties (6.1.7) + actionpack (= 6.1.7) + activesupport (= 6.1.7) + method_source + rake (>= 12.2) + thor (~> 1.0) + rake (13.0.6) + rb-fsevent (0.11.2) + rb-inotify (0.10.1) + ffi (~> 1.0) + rbtree (0.4.5) + set (1.0.3) + sorted_set (1.0.3) + rbtree + set (~> 1.0) + spring (4.1.0) + sprockets (4.1.1) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.4.2) + actionpack (>= 5.2) + activesupport (>= 5.2) + sprockets (>= 3.0.0) + thor (1.2.1) + tzinfo (2.0.5) + concurrent-ruby (~> 1.0) + websocket-driver (0.7.5) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + zeitwerk (2.6.6) + +PLATFORMS + ruby + +DEPENDENCIES + bunny + dotenv-rails + listen (~> 3.3) + mail + midi-smtp-server (~> 3.0.1) + openssl + pg + rails (~> 6.1.7) + spring + +RUBY VERSION + ruby 2.7.2p137 + +BUNDLED WITH + 2.1.4 diff --git a/services/README.md b/services/README.md new file mode 100644 index 0000000..7db80e4 --- /dev/null +++ b/services/README.md @@ -0,0 +1,24 @@ +# README + +This README would normally document whatever steps are necessary to get the +application up and running. + +Things you may want to cover: + +* Ruby version + +* System dependencies + +* Configuration + +* Database creation + +* Database initialization + +* How to run the test suite + +* Services (job queues, cache servers, search engines, etc.) + +* Deployment instructions + +* ... diff --git a/services/Rakefile b/services/Rakefile new file mode 100644 index 0000000..9a5ea73 --- /dev/null +++ b/services/Rakefile @@ -0,0 +1,6 @@ +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + +require_relative "config/application" + +Rails.application.load_tasks diff --git a/services/app/assets/config/manifest.js b/services/app/assets/config/manifest.js new file mode 100644 index 0000000..e69de29 diff --git a/services/app/models/application_record.rb b/services/app/models/application_record.rb new file mode 100644 index 0000000..10a4cba --- /dev/null +++ b/services/app/models/application_record.rb @@ -0,0 +1,3 @@ +class ApplicationRecord < ActiveRecord::Base + self.abstract_class = true +end diff --git a/services/app/models/concerns/.keep b/services/app/models/concerns/.keep new file mode 100644 index 0000000..e69de29 diff --git a/services/app/models/mail_recipient.rb b/services/app/models/mail_recipient.rb new file mode 100644 index 0000000..a6287be --- /dev/null +++ b/services/app/models/mail_recipient.rb @@ -0,0 +1,4 @@ +class MailRecipient < ApplicationRecord + belongs_to :received_mail + belongs_to :recipient +end diff --git a/services/app/models/received_mail.rb b/services/app/models/received_mail.rb new file mode 100644 index 0000000..c93e322 --- /dev/null +++ b/services/app/models/received_mail.rb @@ -0,0 +1,4 @@ +class ReceivedMail < ApplicationRecord + belongs_to :sender + has_many :mail_recipients +end diff --git a/services/app/models/recipient.rb b/services/app/models/recipient.rb new file mode 100644 index 0000000..f7eed0a --- /dev/null +++ b/services/app/models/recipient.rb @@ -0,0 +1,3 @@ +class Recipient < ApplicationRecord + has_many :emails, foreign_key: :recipient_id, class_name: 'MailRecipient' +end diff --git a/services/app/models/sender.rb b/services/app/models/sender.rb new file mode 100644 index 0000000..d193246 --- /dev/null +++ b/services/app/models/sender.rb @@ -0,0 +1,3 @@ +class Sender < ApplicationRecord + has_many :sent_mails, foreign_key: :sender_id, class_name: 'ReceivedMail' +end diff --git a/services/bin/bundle b/services/bin/bundle new file mode 100755 index 0000000..5b593cb --- /dev/null +++ b/services/bin/bundle @@ -0,0 +1,114 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'bundle' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require "rubygems" + +m = Module.new do + module_function + + def invoked_as_script? + File.expand_path($0) == File.expand_path(__FILE__) + end + + def env_var_version + ENV["BUNDLER_VERSION"] + end + + def cli_arg_version + return unless invoked_as_script? # don't want to hijack other binstubs + return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update` + bundler_version = nil + update_index = nil + ARGV.each_with_index do |a, i| + if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN + bundler_version = a + end + next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/ + bundler_version = $1 + update_index = i + end + bundler_version + end + + def gemfile + gemfile = ENV["BUNDLE_GEMFILE"] + return gemfile if gemfile && !gemfile.empty? + + File.expand_path("../../Gemfile", __FILE__) + end + + def lockfile + lockfile = + case File.basename(gemfile) + when "gems.rb" then gemfile.sub(/\.rb$/, gemfile) + else "#{gemfile}.lock" + end + File.expand_path(lockfile) + end + + def lockfile_version + return unless File.file?(lockfile) + lockfile_contents = File.read(lockfile) + return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/ + Regexp.last_match(1) + end + + def bundler_requirement + @bundler_requirement ||= + env_var_version || cli_arg_version || + bundler_requirement_for(lockfile_version) + end + + def bundler_requirement_for(version) + return "#{Gem::Requirement.default}.a" unless version + + bundler_gem_version = Gem::Version.new(version) + + requirement = bundler_gem_version.approximate_recommendation + + return requirement unless Gem.rubygems_version < Gem::Version.new("2.7.0") + + requirement += ".a" if bundler_gem_version.prerelease? + + requirement + end + + def load_bundler! + ENV["BUNDLE_GEMFILE"] ||= gemfile + + activate_bundler + end + + def activate_bundler + gem_error = activation_error_handling do + gem "bundler", bundler_requirement + end + return if gem_error.nil? + require_error = activation_error_handling do + require "bundler/version" + end + return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION)) + warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`" + exit 42 + end + + def activation_error_handling + yield + nil + rescue StandardError, LoadError => e + e + end +end + +m.load_bundler! + +if m.invoked_as_script? + load Gem.bin_path("bundler", "bundle") +end diff --git a/services/bin/rails b/services/bin/rails new file mode 100755 index 0000000..6fb4e40 --- /dev/null +++ b/services/bin/rails @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +APP_PATH = File.expand_path('../config/application', __dir__) +require_relative "../config/boot" +require "rails/commands" diff --git a/services/bin/rake b/services/bin/rake new file mode 100755 index 0000000..4fbf10b --- /dev/null +++ b/services/bin/rake @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +require_relative "../config/boot" +require "rake" +Rake.application.run diff --git a/services/bin/setup b/services/bin/setup new file mode 100755 index 0000000..5792302 --- /dev/null +++ b/services/bin/setup @@ -0,0 +1,33 @@ +#!/usr/bin/env ruby +require "fileutils" + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +FileUtils.chdir APP_ROOT do + # This script is a way to set up or update your development environment automatically. + # This script is idempotent, so that you can run it at any time and get an expectable outcome. + # Add necessary setup steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # puts "\n== Copying sample files ==" + # unless File.exist?('config/database.yml') + # FileUtils.cp 'config/database.yml.sample', 'config/database.yml' + # end + + puts "\n== Preparing database ==" + system! 'bin/rails db:prepare' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/services/config.ru b/services/config.ru new file mode 100644 index 0000000..4a3c09a --- /dev/null +++ b/services/config.ru @@ -0,0 +1,6 @@ +# This file is used by Rack-based servers to start the application. + +require_relative "config/environment" + +run Rails.application +Rails.application.load_server diff --git a/services/config/application.rb b/services/config/application.rb new file mode 100644 index 0000000..14e8219 --- /dev/null +++ b/services/config/application.rb @@ -0,0 +1,40 @@ +require_relative "boot" + +require "rails" +# Pick the frameworks you want: +require "active_model/railtie" +require "active_record/railtie" +# require "active_job/railtie" +# require "active_storage/engine" +# require "action_controller/railtie" +# require "action_mailer/railtie" +# require "action_mailbox/engine" +# require "action_text/engine" +# require "action_view/railtie" +# require "action_cable/engine" +require "sprockets/railtie" +# require "rails/test_unit/railtie" + +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) + +module Consumer + class Application < Rails::Application + config.autoload_paths << Rails.root.join('lib') + config.eager_load_paths << Rails.root.join('lib') + # Initialize configuration defaults for originally generated Rails version. + config.load_defaults 6.1 + + # Configuration for the application, engines, and railties goes here. + # + # These settings can be overridden in specific environments using the files + # in config/environments, which are processed later. + # + # config.time_zone = "Central Time (US & Canada)" + # config.eager_load_paths << Rails.root.join("extras") + + # Don't generate system test files. + config.generators.system_tests = nil + end +end diff --git a/services/config/boot.rb b/services/config/boot.rb new file mode 100644 index 0000000..d69bd27 --- /dev/null +++ b/services/config/boot.rb @@ -0,0 +1,3 @@ +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) + +require "bundler/setup" # Set up gems listed in the Gemfile. diff --git a/services/config/credentials.yml.enc b/services/config/credentials.yml.enc new file mode 100644 index 0000000..b9d2a00 --- /dev/null +++ b/services/config/credentials.yml.enc @@ -0,0 +1 @@ +3bgXrcBmEQAiInnCmLeo+uzTTZv/XdKvZnr5agIilz+zG5sdTcS6NKTDodS3Z9zla1eH/YPVW+b/yZbTpqf56hu/OY4WO09NA1lWsrWxIgstXCZA6GxUOMnLs1naaYuyV5L/QUo0nvL2HER3wimYr8oG0uF50tRSBdnU21XMXmrKue6noNy1FHfXzRbmqcr2DrYaEPDfEBgFVCtaRR3/lcHstUIu5LgbKThgJFUY1NCkjRQUcGKD94rACQ1FaVoJw+33syRnEEVqEE/pJDX03U+domMLf7JLsu9BqAiBxtyiy/ZmaqZ+bP+R/NiXzuLxrc7x4Lup0cExBalfRwf0PLmOYOoRfuFOhuOtkYRL7dwIVkgm8uf+vtBWLLNFdwwSgK3BsnZqp2HdUH9iLaJUBZEIxuJe0tUj3avg--3B+JnjSZfI0pkw11--gObP0g/Ae5hz20kfQwnfhA== \ No newline at end of file diff --git a/services/config/environment.rb b/services/config/environment.rb new file mode 100644 index 0000000..cac5315 --- /dev/null +++ b/services/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require_relative "application" + +# Initialize the Rails application. +Rails.application.initialize! diff --git a/services/config/environments/development.rb b/services/config/environments/development.rb new file mode 100644 index 0000000..c3b88cd --- /dev/null +++ b/services/config/environments/development.rb @@ -0,0 +1,68 @@ +require "active_support/core_ext/integer/time" + +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # In the development environment your application's code is reloaded any time + # it changes. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports. + config.consider_all_requests_local = true + + # Enable/disable caching. By default caching is disabled. + # Run rails dev:cache to toggle caching. + if Rails.root.join('tmp', 'caching-dev.txt').exist? + config.action_controller.perform_caching = true + config.action_controller.enable_fragment_cache_logging = true + + config.cache_store = :memory_store + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{2.days.to_i}" + } + else + config.action_controller.perform_caching = false + + config.cache_store = :null_store + end + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Raise exceptions for disallowed deprecations. + config.active_support.disallowed_deprecation = :raise + + # Tell Active Support which deprecation messages to disallow. + config.active_support.disallowed_deprecation_warnings = [] + + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load + + # Highlight code that triggered database queries in logs. + config.active_record.verbose_query_logs = true + + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true + + # Suppress logger output for asset requests. + config.assets.quiet = true + + # Raises error for missing translations. + # config.i18n.raise_on_missing_translations = true + + # Annotate rendered view with file names. + # config.action_view.annotate_rendered_view_with_filenames = true + + # Use an evented file watcher to asynchronously detect changes in source code, + # routes, locales, etc. This feature depends on the listen gem. + config.file_watcher = ActiveSupport::EventedFileUpdateChecker + + # Uncomment if you wish to allow Action Cable access from any origin. + # config.action_cable.disable_request_forgery_protection = true +end diff --git a/services/config/environments/production.rb b/services/config/environments/production.rb new file mode 100644 index 0000000..b876cdf --- /dev/null +++ b/services/config/environments/production.rb @@ -0,0 +1,103 @@ +require "active_support/core_ext/integer/time" + +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. + config.cache_classes = true + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] + # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). + # config.require_master_key = true + + # Disable serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? + + # Compress CSS using a preprocessor. + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.asset_host = 'http://assets.example.com' + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Include generic and useful information about system operation, but avoid logging too much + # information to avoid inadvertent exposure of personally identifiable information (PII). + config.log_level = :info + + # Prepend all log lines with the following tags. + config.log_tags = [ :request_id ] + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners. + config.active_support.deprecation = :notify + + # Log disallowed deprecations. + config.active_support.disallowed_deprecation = :log + + # Tell Active Support which deprecation messages to disallow. + config.active_support.disallowed_deprecation_warnings = [] + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new + + # Use a different logger for distributed setups. + # require "syslog/logger" + # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') + + if ENV["RAILS_LOG_TO_STDOUT"].present? + logger = ActiveSupport::Logger.new(STDOUT) + logger.formatter = config.log_formatter + config.logger = ActiveSupport::TaggedLogging.new(logger) + end + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false + + # Inserts middleware to perform automatic connection switching. + # The `database_selector` hash is used to pass options to the DatabaseSelector + # middleware. The `delay` is used to determine how long to wait after a write + # to send a subsequent read to the primary. + # + # The `database_resolver` class is used by the middleware to determine which + # database is appropriate to use based on the time delay. + # + # The `database_resolver_context` class is used by the middleware to set + # timestamps for the last write to the primary. The resolver uses the context + # class timestamps to determine how long to wait before reading from the + # replica. + # + # By default Rails will store a last write timestamp in the session. The + # DatabaseSelector middleware is designed as such you can define your own + # strategy for connection switching and pass that into the middleware through + # these configuration options. + # config.active_record.database_selector = { delay: 2.seconds } + # config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver + # config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session +end diff --git a/services/config/environments/test.rb b/services/config/environments/test.rb new file mode 100644 index 0000000..9fa79dd --- /dev/null +++ b/services/config/environments/test.rb @@ -0,0 +1,49 @@ +require "active_support/core_ext/integer/time" + +# The test environment is used exclusively to run your application's +# test suite. You never need to work with it otherwise. Remember that +# your test database is "scratch space" for the test suite and is wiped +# and recreated between test runs. Don't rely on the data there! + +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + config.cache_classes = true + + # Do not eager load code on boot. This avoids loading your whole application + # just for the purpose of running a single test. If you are using a tool that + # preloads Rails for running tests, you may have to set it to true. + config.eager_load = false + + # Configure public file server for tests with Cache-Control for performance. + config.public_file_server.enabled = true + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{1.hour.to_i}" + } + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + config.cache_store = :null_store + + # Raise exceptions instead of rendering exception templates. + config.action_dispatch.show_exceptions = false + + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + # Raise exceptions for disallowed deprecations. + config.active_support.disallowed_deprecation = :raise + + # Tell Active Support which deprecation messages to disallow. + config.active_support.disallowed_deprecation_warnings = [] + + # Raises error for missing translations. + # config.i18n.raise_on_missing_translations = true + + # Annotate rendered view with file names. + # config.action_view.annotate_rendered_view_with_filenames = true +end diff --git a/services/config/locales/en.yml b/services/config/locales/en.yml new file mode 100644 index 0000000..cf9b342 --- /dev/null +++ b/services/config/locales/en.yml @@ -0,0 +1,33 @@ +# Files in the config/locales directory are used for internationalization +# and are automatically loaded by Rails. If you want to use locales other +# than English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t 'hello' +# +# In views, this is aliased to just `t`: +# +# <%= t('hello') %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# The following keys must be escaped otherwise they will not be retrieved by +# the default I18n backend: +# +# true, false, on, off, yes, no +# +# Instead, surround them with single quotes. +# +# en: +# 'true': 'foo' +# +# To learn more, please read the Rails Internationalization guide +# available at https://guides.rubyonrails.org/i18n.html. + +en: + hello: "Hello world" diff --git a/services/config/puma.rb b/services/config/puma.rb new file mode 100644 index 0000000..d9b3e83 --- /dev/null +++ b/services/config/puma.rb @@ -0,0 +1,43 @@ +# Puma can serve each request in a thread from an internal thread pool. +# The `threads` method setting takes two numbers: a minimum and maximum. +# Any libraries that use thread pools should be configured to match +# the maximum value specified for Puma. Default is set to 5 threads for minimum +# and maximum; this matches the default thread size of Active Record. +# +max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } +min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count } +threads min_threads_count, max_threads_count + +# Specifies the `worker_timeout` threshold that Puma will use to wait before +# terminating a worker in development environments. +# +worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development" + +# Specifies the `port` that Puma will listen on to receive requests; default is 3000. +# +port ENV.fetch("PORT") { 3000 } + +# Specifies the `environment` that Puma will run in. +# +environment ENV.fetch("RAILS_ENV") { "development" } + +# Specifies the `pidfile` that Puma will use. +pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } + +# Specifies the number of `workers` to boot in clustered mode. +# Workers are forked web server processes. If using threads and workers together +# the concurrency of the application would be max `threads` * `workers`. +# Workers do not work on JRuby or Windows (both of which do not support +# processes). +# +# workers ENV.fetch("WEB_CONCURRENCY") { 2 } + +# Use the `preload_app!` method when specifying a `workers` number. +# This directive tells Puma to first boot the application and load code +# before forking the application. This takes advantage of Copy On Write +# process behavior so workers use less memory. +# +# preload_app! + +# Allow puma to be restarted by `rails restart` command. +plugin :tmp_restart diff --git a/services/config/routes.rb b/services/config/routes.rb new file mode 100644 index 0000000..c06383a --- /dev/null +++ b/services/config/routes.rb @@ -0,0 +1,3 @@ +Rails.application.routes.draw do + # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html +end diff --git a/services/db/migrate/20221115164901_setup.rb b/services/db/migrate/20221115164901_setup.rb new file mode 100644 index 0000000..f454b31 --- /dev/null +++ b/services/db/migrate/20221115164901_setup.rb @@ -0,0 +1,39 @@ +class Setup < ActiveRecord::Migration[6.1] + def change + enable_extension 'uuid-ossp' + enable_extension 'pgcrypto' + + create_table :senders, id: :string do |t| + t.timestamps + end + + create_table :recipients, id: :string do |t| + t.string :verification_status, default: 'unverified', nullable: false + t.datetime :last_verified_at, nullable: true + t.string :bounce_status , default: 'unknown' + t.datetime :bounce_status_changed_at, nullable: true + t.timestamps + end + + create_table :received_mails, id: :uuid do |t| + t.string :sender_id, nullable: false + t.string :message_id, nullable: false + t.binary :body, nullable: false + t.string :delivery_status, default: 'queued', nullable: false + t.string :delivery_status_changed_at + t.timestamps + end + + create_table :mail_recipients, id: false do |t| + t.uuid :received_mail_id + t.string :recipient_id + t.string :delivery_status, default: 'delivered', nullable: false + t.string :delivery_status_changed_at + t.timestamps + end + + add_index :received_mails, :sender_id + add_index :received_mails, :message_id, unique: true + add_index :mail_recipients, %i[received_mail_id recipient_id], unique: true + end +end diff --git a/services/db/schema.rb b/services/db/schema.rb new file mode 100644 index 0000000..833e0a7 --- /dev/null +++ b/services/db/schema.rb @@ -0,0 +1,56 @@ +# This file is auto-generated from the current state of the database. Instead +# of editing this file, please use the migrations feature of Active Record to +# incrementally modify your database, and then regenerate this schema definition. +# +# This file is the source Rails uses to define your schema when running `bin/rails +# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to +# be faster and is potentially less error prone than running all of your +# migrations from scratch. Old migrations may fail to apply correctly if those +# migrations use external dependencies or application code. +# +# It's strongly recommended that you check this file into your version control system. + +ActiveRecord::Schema.define(version: 2022_11_15_164901) do + + # These are extensions that must be enabled in order to support this database + enable_extension "pgcrypto" + enable_extension "plpgsql" + enable_extension "uuid-ossp" + + create_table "mail_recipients", id: false, force: :cascade do |t| + t.uuid "received_mail_id" + t.string "recipient_id" + t.string "delivery_status", default: "delivered" + t.string "delivery_status_changed_at" + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + t.index ["received_mail_id", "recipient_id"], name: "index_mail_recipients_on_received_mail_id_and_recipient_id", unique: true + end + + create_table "received_mails", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + t.string "sender_id" + t.string "message_id" + t.binary "body" + t.string "delivery_status", default: "queued" + t.string "delivery_status_changed_at" + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + t.index ["message_id"], name: "index_received_mails_on_message_id", unique: true + t.index ["sender_id"], name: "index_received_mails_on_sender_id" + end + + create_table "recipients", id: :string, force: :cascade do |t| + t.string "verification_status", default: "unverified" + t.datetime "last_verified_at" + t.string "bounce_status", default: "unknown" + t.datetime "bounce_status_changed_at" + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + end + + create_table "senders", id: :string, force: :cascade do |t| + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + end + +end diff --git a/services/db/seeds.rb b/services/db/seeds.rb new file mode 100644 index 0000000..f3a0480 --- /dev/null +++ b/services/db/seeds.rb @@ -0,0 +1,7 @@ +# This file should contain all the record creation needed to seed the database with its default values. +# The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup). +# +# Examples: +# +# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) +# Character.create(name: 'Luke', movie: movies.first) diff --git a/services/lib/assets/.keep b/services/lib/assets/.keep new file mode 100644 index 0000000..e69de29 diff --git a/services/lib/bettermail/consumer.rb b/services/lib/bettermail/consumer.rb new file mode 100644 index 0000000..e14cf24 --- /dev/null +++ b/services/lib/bettermail/consumer.rb @@ -0,0 +1,63 @@ +# frozen_string_literal: true + +require 'mail' +require 'bunny' + +# in module for neatness +module Bettermail + # The General purpose consumer + class Consumer + def initialize + end + + def default_smtp_settings + { + address: ENV['DEFAULT_SMTP_HOST'], + port: ENV['DEFAULT_SMTP_PORT'], + user_name: ENV['DEFAULT_SMTP_UID'], + password: ENV['DEFAULT_SMTP_PWD'], + enable_starttls_auto: true, + authentication: 'plain', + } + end + + + + def start + begin + puts ' [*] Waiting for messages. To exit press CTRL+C' + new_mail_queue = bunny_channel.queue(ENV['RABBIT_MAIL_QUEUE']) + new_mail_queue.subscribe(block: true) do |_delivery_info, _properties, body| + instructions = JSON.parse(body) + recipient = Recipient.create_or_find_by(id: instructions["recipient"]) + email = ReceivedMail.find_by(message_id: instructions["message"]) + recipient.emails.create(received_mail: email, delivery_status: 'queued') + 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 send_mail(mail) + mail.delivery_method :smtp, default_smtp_settings + mail.deliver! + end + + def stop + @bunny_conn&.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 +end diff --git a/services/lib/bettermail/proxy.rb b/services/lib/bettermail/proxy.rb new file mode 100644 index 0000000..71d5ca5 --- /dev/null +++ b/services/lib/bettermail/proxy.rb @@ -0,0 +1,79 @@ +# frozen_string_literal: true + +require 'midi-smtp-server' +require 'mail' +require 'bunny' +require 'securerandom' + +# in module for neatness +module Bettermail + # The SMTPProxy + class Proxy < 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 + + def save_mail(ctx, sender) + mail = Mail.read_from_string(ctx[:message][:data]) + sender = Sender.create_or_find_by(id: sender) + message_id = "#{SecureRandom.uuid}@bettermail.wizewerx.tech" + saved_mail = sender.sent_mails.create(message_id: message_id, body: mail.to_s) + message_id + end + + def on_mail_from_event(ctx, mail_from_data) + # tag the message here OR write it once to the database + ctx[:message][:message_id] = save_mail(ctx, mail_from_data) + end + + # simple rewrite and return value + def on_rcpt_to_event(ctx, data) + bunny.publish({message: ctx[:message][:message_id], recipient: data}.to_json, :headers => { }, :routing_key => ENV["RABBIT_MAIL_QUEUE"]) + end + end +end diff --git a/services/lib/tasks/.keep b/services/lib/tasks/.keep new file mode 100644 index 0000000..e69de29 diff --git a/services/lib/tasks/consumer.rake b/services/lib/tasks/consumer.rake new file mode 100644 index 0000000..fc7fc91 --- /dev/null +++ b/services/lib/tasks/consumer.rake @@ -0,0 +1,46 @@ +namespace :consumer do + task start: :environment do + 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 = Bettermail::Consumer.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 + end +end diff --git a/services/lib/tasks/proxy.rake b/services/lib/tasks/proxy.rake new file mode 100644 index 0000000..8950840 --- /dev/null +++ b/services/lib/tasks/proxy.rake @@ -0,0 +1,58 @@ +namespace :proxy do + task start: :environment do + # 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 = Bettermail::Proxy.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 + end +end + diff --git a/services/log/.keep b/services/log/.keep new file mode 100644 index 0000000..e69de29 diff --git a/services/public/404.html b/services/public/404.html new file mode 100644 index 0000000..2be3af2 --- /dev/null +++ b/services/public/404.html @@ -0,0 +1,67 @@ + + + + The page you were looking for doesn't exist (404) + + + + + + +
+
+

The page you were looking for doesn't exist.

+

You may have mistyped the address or the page may have moved.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/services/public/422.html b/services/public/422.html new file mode 100644 index 0000000..c08eac0 --- /dev/null +++ b/services/public/422.html @@ -0,0 +1,67 @@ + + + + The change you wanted was rejected (422) + + + + + + +
+
+

The change you wanted was rejected.

+

Maybe you tried to change something you didn't have access to.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/services/public/500.html b/services/public/500.html new file mode 100644 index 0000000..78a030a --- /dev/null +++ b/services/public/500.html @@ -0,0 +1,66 @@ + + + + We're sorry, but something went wrong (500) + + + + + + +
+
+

We're sorry, but something went wrong.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/services/public/apple-touch-icon-precomposed.png b/services/public/apple-touch-icon-precomposed.png new file mode 100644 index 0000000..e69de29 diff --git a/services/public/apple-touch-icon.png b/services/public/apple-touch-icon.png new file mode 100644 index 0000000..e69de29 diff --git a/services/public/favicon.ico b/services/public/favicon.ico new file mode 100644 index 0000000..e69de29 diff --git a/services/public/robots.txt b/services/public/robots.txt new file mode 100644 index 0000000..c19f78a --- /dev/null +++ b/services/public/robots.txt @@ -0,0 +1 @@ +# See https://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file diff --git a/services/ssl/cert.pem b/services/ssl/cert.pem new file mode 100644 index 0000000..3a56cd6 --- /dev/null +++ b/services/ssl/cert.pem @@ -0,0 +1,32 @@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B0GA1UdDgQWBBSL6Xv5EJCvf/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----- diff --git a/services/ssl/key.pem b/services/ssl/key.pem new file mode 100644 index 0000000..0dec64b --- /dev/null +++ b/services/ssl/key.pem @@ -0,0 +1,52 @@ +-----BEGIN PRIVATE KEY----- +MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQC2gTesDCOpLjHH +mz+yk54/7lQmsOn6uQJ50bR0ZdoNuikA4b8i4wYtwW6f80YJtrhKa4ZBy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oZ5 +gacuHtxt2RRmJLNKNvp7AvuVcTHJcf9nIkafuYLkdKs3H8bjF2etnNN0FdL1FZX9 ++UV+A+RG6CgOr0AUiIuw82R2b9xJae23ypq6VizctpDUo5rKow2YZKTEFDPE6WtQ +cBkPHapKMmHSsBAVWAlof7Ve+UhGmunys4Kh/znLJSf86IQdah4NlaP1bPrsrXwY +pNOSMPGKXgTdffO+VaCRDVbUIv0ZJGoSTcEFXuUCggEBAJu77k69/6zRJ3KvIKOP +nrNo7maWdQ2bWZRiLA1Vs7Tdx0wUUgalD/DQPMTKkcn8F/ik7BDMbLUs6xp+SWli +JqjC9cmryT2N2hOTD91YBoJt5tzqFr4QhV1ps5jJS9HmcP+IICgXWFIHVFkzoqhz +9yJRAhvC7wRAByuA3EK++R+ZWhU7RhF6a+QkUIp1Q9YvwCoMPJ+oz3SIOk88qnBg +euY1/a2y0xb7ZUCEiSD69mOHf/lRKJp4BI982IsF3R5NqVVMfn4hVUVFvZn8OjMv +FqCOjAPe3DIeBEJ8SFvF9sk0cTQn8gACN+82OnPpLyYMrpyB425KIDoYOOg941TA +zmECggEALQrypG6EB54J/rZTxX9m3jtFNgys4GWVnkseqZR+kozJ5cCG5RyxFjlG +sBlA9g2jwjUHqPuhZeTnJ7xN994KpXK86YQ4v/hLMSMQ7wWdVcIW7w2BJLxvBA2Q +LVLLfEsFJloCoigoMEVeiTeiZhBRj28Cb9txAQ45SFI0gvVvl2I+ZAP9M0k9Cdc/ +9vWblChgTPLkfpNsK00wiOG1Lji9KeRDhwm2ht1jHBhhk+dVaLyZPD7hFnog6cIV +dJdrln0uZBTkWf55AOcyN/jHdXsdxQBEVA3I3E2UwsZxRdZT7DIhNggL4xQ6RtBE +5ZADVjSHf21VhXCmSSGtL59GcaMYVA== +-----END PRIVATE KEY----- diff --git a/services/tmp/.keep b/services/tmp/.keep new file mode 100644 index 0000000..e69de29 diff --git a/services/tmp/pids/.keep b/services/tmp/pids/.keep new file mode 100644 index 0000000..e69de29 diff --git a/services/vendor/.keep b/services/vendor/.keep new file mode 100644 index 0000000..e69de29