مراية لـ
https://github.com/postalserver/postal.git
تم المزامنة 2026-01-18 05:49:47 +00:00
feat: new configuration system (and schema) (#2819)
هذا الالتزام موجود في:
@@ -38,9 +38,9 @@ module Postal
|
||||
require "tracking_middleware"
|
||||
config.middleware.insert_before ActionDispatch::HostAuthorization, TrackingMiddleware
|
||||
|
||||
config.hosts << Postal.config.web.host
|
||||
config.hosts << Postal::Config.postal.web_hostname
|
||||
|
||||
if Postal.config.logging.rails_log == false
|
||||
unless Postal::Config.logging.rails_log_enabled?
|
||||
config.logger = Logger.new("/dev/null")
|
||||
end
|
||||
|
||||
|
||||
@@ -5,6 +5,5 @@ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
||||
require "bundler/setup" # Set up gems listed in the Gemfile.
|
||||
|
||||
require_relative "../lib/postal/config"
|
||||
Postal.check_config!
|
||||
|
||||
ENV["RAILS_ENV"] = Postal.config.rails&.environment || "development"
|
||||
ENV["RAILS_ENV"] = Postal::Config.rails.environment || "development"
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
default: &default
|
||||
adapter: mysql2
|
||||
reconnect: true
|
||||
encoding: <%= Postal.config.main_db.encoding %>
|
||||
pool: <%= Postal.config.main_db.pool_size %>
|
||||
username: <%= Postal.config.main_db.username %>
|
||||
password: <%= Postal.config.main_db.password %>
|
||||
host: <%= Postal.config.main_db.host %>
|
||||
port: <%= Postal.config.main_db.port %>
|
||||
database: <%= Postal.config.main_db.database %>
|
||||
encoding: "<%= Postal::Config.main_db.encoding %>"
|
||||
pool: <%= Postal::Config.main_db.pool_size %>
|
||||
username: "<%= Postal::Config.main_db.username %>"
|
||||
password: "<%= Postal::Config.main_db.password %>"
|
||||
host: "<%= Postal::Config.main_db.host %>"
|
||||
port: <%= Postal::Config.main_db.port %>
|
||||
database: "<%= Postal::Config.main_db.database %>"
|
||||
|
||||
development:
|
||||
<<: *default
|
||||
|
||||
@@ -1,17 +1,13 @@
|
||||
web:
|
||||
host: postal.example.dev
|
||||
protocol: https
|
||||
# This is an example Postal configuration file for use in
|
||||
# development environments. For a production example, see
|
||||
# the https://github.com/postalserver/install repository.
|
||||
|
||||
web_server:
|
||||
bind_address: 0.0.0.0
|
||||
port: 4010
|
||||
version: 2
|
||||
|
||||
smtp_server:
|
||||
port: 2525
|
||||
|
||||
logging:
|
||||
rails_log: true
|
||||
stdout: true
|
||||
postal:
|
||||
web_hostname: postal.example.com
|
||||
web_protocol: https
|
||||
smtp_hostname: postal.example.com
|
||||
|
||||
main_db:
|
||||
host: 127.0.0.1
|
||||
@@ -25,13 +21,9 @@ message_db:
|
||||
password:
|
||||
prefix: postal
|
||||
|
||||
smtp:
|
||||
host: 127.0.0.1
|
||||
port: 2525
|
||||
username:
|
||||
password:
|
||||
from_name: Postal
|
||||
from_address: postal@yourdomain.com
|
||||
logging:
|
||||
rails_log_enabled: true
|
||||
highlighting_enabled: true
|
||||
|
||||
rails:
|
||||
environment: development
|
||||
25
config/examples/test.yml
Normal file
25
config/examples/test.yml
Normal file
@@ -0,0 +1,25 @@
|
||||
# This is an example Postal configuration file for use in
|
||||
# test environments. For a production example, see
|
||||
# the https://github.com/postalserver/install repository.
|
||||
|
||||
version: 2
|
||||
|
||||
main_db:
|
||||
host: 127.0.0.1
|
||||
username: root
|
||||
password:
|
||||
database: postal-test
|
||||
|
||||
message_db:
|
||||
host: 127.0.0.1
|
||||
username: root
|
||||
password:
|
||||
prefix: postal-test
|
||||
|
||||
logging:
|
||||
enabled: false
|
||||
rails_log_enabled: false
|
||||
|
||||
rails:
|
||||
environment: test
|
||||
secret_key: 7f27856d26e864bafd49d0df37ad3d1339086e86ef0447e0f1814dde5277452fea97dab9e3aad6dfa11bfe359c82ce302d97bf1e58f6103c4408e4fbad4eeccf
|
||||
@@ -1,7 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
if Postal.config.rails&.secret_key
|
||||
Rails.application.secrets.secret_key_base = Postal.config.rails.secret_key
|
||||
if Postal::Config.rails.secret_key
|
||||
Rails.application.secrets.secret_key_base = Postal::Config.rails.secret_key
|
||||
else
|
||||
warn "No secret key was specified in the Postal config file. Using one for just this session"
|
||||
Rails.application.secrets.secret_key_base = SecureRandom.hex(128)
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
require "postal/config"
|
||||
|
||||
if Postal.config.general&.exception_url
|
||||
if Postal::Config.logging.sentry_dsn
|
||||
Sentry.init do |config|
|
||||
config.dsn = Postal.config.general.exception_url
|
||||
config.dsn = Postal::Config.logging.sentry_dsn
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
|
||||
require "postal/config"
|
||||
|
||||
if Postal.config&.smtp
|
||||
# TODO: by default, we should just send mail through the local Postal
|
||||
# installation rather than having to actually configure an SMTP server.
|
||||
ActionMailer::Base.delivery_method = :smtp
|
||||
ActionMailer::Base.smtp_settings = { address: Postal.config.smtp.host, user_name: Postal.config.smtp.username, password: Postal.config.smtp.password, port: Postal.config.smtp.port || 25 }
|
||||
end
|
||||
ActionMailer::Base.delivery_method = :smtp
|
||||
ActionMailer::Base.smtp_settings = {
|
||||
address: Postal::Config.smtp.host,
|
||||
user_name: Postal::Config.smtp.username,
|
||||
password: Postal::Config.smtp.password,
|
||||
port: Postal::Config.smtp.port
|
||||
}
|
||||
|
||||
@@ -1,111 +0,0 @@
|
||||
# These are the default configuration options that will be used if they aren't overriden
|
||||
# in your postal.yml configuration file. No changes should be made to this file for
|
||||
# your installation.
|
||||
|
||||
# You can refer to this for a complete listing all available configuration options.
|
||||
|
||||
web:
|
||||
host: <%= ENV.fetch('POSTAL_HOST', 'postal.example.com') %>
|
||||
protocol: <%= ENV.fetch('POSTAL_PROTOCOL', 'https') %>
|
||||
|
||||
general:
|
||||
use_ip_pools: <%= ENV.fetch('POSTAL_USE_IP_POOLS', 'false') %>
|
||||
exception_url: <%= ENV.fetch('POSTAL_EXCEPTION_URL', '') %>
|
||||
maximum_delivery_attempts: <%= ENV.fetch('POSTAL_MAXIMUM_DELIVERY_ATTEMPTS', '18') %>
|
||||
maximum_hold_expiry_days: <%= ENV.fetch('POSTAL_MAXIMUM_HOLD_EXPIRY_DAYS', '7') %>
|
||||
suppression_list_removal_delay: <%= ENV.fetch('POSTAL_SUPPRESSION_LIST_REMOVAL_DELAY', '30') %>
|
||||
use_local_ns_for_domains: <%= ENV.fetch('POSTAL_USE_LOCAL_NS_FOR_DOMAINS', 'false') %>
|
||||
default_spam_threshold: <%= ENV.fetch('POSTAL_DEFAULT_SPAM_THRESHOLD', '5.0') %>
|
||||
default_spam_failure_threshold: <%= ENV.fetch('POSTAL_DEFAULT_SPAM_FAILURE_THRESHOLD', '20.0') %>
|
||||
use_resent_sender_header: <%= ENV.fetch('POSTAL_USE_RESENT_SENDER_HEADER', 'true') %>
|
||||
|
||||
web_server:
|
||||
bind_address: <%= ENV.fetch('WEB_SERVER_BIND_ADDRESS', '0.0.0.0') %>
|
||||
port: <%= ENV.fetch('WEB_SERVER_PORT', '5000') %>
|
||||
max_threads: <%= ENV.fetch('WEB_SERVER_MAX_THREADS', '5') %>
|
||||
|
||||
main_db:
|
||||
host: <%= ENV.fetch('MAIN_DB_HOST', '127.0.0.1') %>
|
||||
port: <%= ENV.fetch('MAIN_DB_PORT', '3306') %>
|
||||
username: <%= ENV.fetch('MAIN_DB_USERNAME', 'postal') %>
|
||||
password: <%= ENV.fetch('MAIN_DB_PASSWORD', '') %>
|
||||
database: <%= ENV.fetch('MAIN_DB_DATABASE', 'postal') %>
|
||||
pool_size: <%= ENV.fetch('MAIN_DB_POOL_SIZE', '5') %>
|
||||
encoding: <%= ENV.fetch('MAIN_DB_ENCODING', 'utf8mb4') %>
|
||||
|
||||
message_db:
|
||||
host: <%= ENV.fetch('MESSAGE_DB_HOST', '127.0.0.1') %>
|
||||
port: <%= ENV.fetch('MESSAGE_DB_PORT', '3306') %>
|
||||
username: <%= ENV.fetch('MESSAGE_DB_USERNAME', 'postal') %>
|
||||
password: <%= ENV.fetch('MESSAGE_DB_PASSWORD', '') %>
|
||||
prefix: <%= ENV.fetch('MESSAGE_DB_PREFIX', 'postal') %>
|
||||
|
||||
logging:
|
||||
rails_log: <%= ENV.fetch('LOGGING_RAILS_LOG', 'false') %>
|
||||
graylog:
|
||||
host: <%= ENV.fetch('GRAYLOG_HOST', '') %>
|
||||
port: <%= ENV.fetch('GRAYLOG_PORT', '12201') %>
|
||||
facility: <%= ENV.fetch('GRAYLOG_FACILITY', 'postal') %>
|
||||
|
||||
smtp_server:
|
||||
port: <%= ENV.fetch('SMTP_SERVER_PORT', '25') %>
|
||||
bind_address: "<%= ENV.fetch('SMTP_SERVER_BIND_ADDRESS', '::') %>"
|
||||
tls_enabled: <%= ENV.fetch('SMTP_SERVER_TLS_ENABLED', 'false') %>
|
||||
tls_certificate_path: <%= ENV.fetch('SMTP_SERVER_TLS_CERTIFICATE_PATH', '') %> # Defaults to config/smtp.cert
|
||||
tls_private_key_path: <%= ENV.fetch('SMTP_SERVER_TLS_PRIVATE_KEY_PATH', '') %> # Defaults to config/smtp.key
|
||||
tls_ciphers: <%= ENV.fetch('SMTP_SERVER_TLS_CIPHERS', '') %>
|
||||
ssl_version: <%= ENV.fetch('SMTP_SERVER_SSL_VERSION', 'SSLv23') %>
|
||||
proxy_protocol: <%= ENV.fetch('SMTP_SERVER_PROXY_PROTOCOL', 'false') %>
|
||||
log_connect: <%= ENV.fetch('SMTP_SERVER_LOG_CONNECT', 'false') %>
|
||||
max_message_size: <%= ENV.fetch('SMTP_SERVER_MAX_MESSAGE_SIZE', '14') %> # size in Megabytes
|
||||
|
||||
smtp_relays:
|
||||
- hostname:
|
||||
port: 25
|
||||
ssl_mode: Auto
|
||||
|
||||
dns:
|
||||
mx_records: <%= ENV.fetch('DNS_MX_RECORDS', 'mx.postal.example.com'.split(',').inspect) %>
|
||||
smtp_server_hostname: <%= ENV.fetch('DNS_SMTP_SERVER_HOSTNAME', 'postal.example.com') %>
|
||||
spf_include: <%= ENV.fetch('DNS_SPF_INCLUDE', 'spf.postal.example.com') %>
|
||||
return_path: <%= ENV.fetch('DNS_RETURN_PATH', 'rp.postal.example.com') %>
|
||||
route_domain: <%= ENV.fetch('DNS_ROUTE_DOMAIN', 'routes.postal.example.com') %>
|
||||
track_domain: <%= ENV.fetch('DNS_TRACK_DOMAIN', 'track.postal.example.com') %>
|
||||
helo_hostname: <%= ENV.fetch('DNS_HELO_HOSTNAME', '') %> # By default, this will be the same as the `smtp_server_hostname`
|
||||
dkim_identifier: <%= ENV.fetch('DNS_DKIM_IDENTIFIER', 'postal') %>
|
||||
domain_verify_prefix: <%= ENV.fetch('DNS_DOMAIN_VERIFY_PREFIX', 'postal-verification') %>
|
||||
custom_return_path_prefix: <%= ENV.fetch('DNS_CUSTOM_RETURN_PATH_PREFIX', 'psrp') %>
|
||||
|
||||
smtp:
|
||||
host: <%= ENV.fetch('SMTP_HOST', '127.0.0.1') %>
|
||||
port: <%= ENV.fetch('SMTP_PORT', '25') %>
|
||||
username: <%= ENV.fetch('SMTP_USERNAME', '') %> # Complete when Postal is running and you can
|
||||
password: <%= ENV.fetch('SMTP_PASSWORD', '') %> # generate the credentials within the interface.
|
||||
from_name: <%= ENV.fetch('SMTP_FROM_NAME', 'Postal') %>
|
||||
from_address: <%= ENV.fetch('SMTP_FROM_ADDRESS', 'postal@example.com') %>
|
||||
|
||||
rails:
|
||||
environment: <%= ENV.fetch('RAILS_ENV', 'production') %>
|
||||
secret_key: <%= ENV.fetch('RAILS_SECRET_KEY_BASE', '') %>
|
||||
|
||||
rspamd:
|
||||
enabled: <%= ENV.fetch('RSPAMD_ENABLED', 'false') %>
|
||||
host: <%= ENV.fetch('RSPAMD_HOST', '127.0.0.1') %>
|
||||
port: <%= ENV.fetch('RSPAMD_PORT', '11334') %>
|
||||
ssl: <%= ENV.fetch('RSPAMD_SSL', 'false') %>
|
||||
password: <%= ENV.fetch('RSPAMD_PASSWORD', '') %>
|
||||
flags: <%= ENV.fetch('RSPAMD_FLAGS', '') %>
|
||||
|
||||
spamd:
|
||||
enabled: <%= ENV.fetch('SPAMD_ENABLED', 'false') %>
|
||||
host: <%= ENV.fetch('SPAMD_HOST', '127.0.0.1') %>
|
||||
port: <%= ENV.fetch('SPAMD_PORT', '783') %>
|
||||
|
||||
clamav:
|
||||
enabled: <%= ENV.fetch('CLAMAV_ENABLED', 'false') %>
|
||||
host: <%= ENV.fetch('CLAMAV_HOST', '127.0.0.1') %>
|
||||
port: <%= ENV.fetch('CLAMAV_PORT', '2000') %>
|
||||
|
||||
smtp_client:
|
||||
open_timeout: <%= ENV.fetch('SMTP_CLIENT_OPEN_TIMEOUT', '30') %>
|
||||
read_timeout: <%= ENV.fetch('SMTP_CLIENT_READ_TIMEOUT', '60') %>
|
||||
@@ -1,11 +1,12 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require_relative "../lib/postal/config"
|
||||
threads_count = Postal.config.web_server&.max_threads&.to_i || 5
|
||||
|
||||
threads_count = Postal::Config.web_server.max_threads
|
||||
threads threads_count, threads_count
|
||||
bind_address = Postal.config.web_server&.bind_address || "127.0.0.1"
|
||||
bind_port = Postal.config.web_server&.port&.to_i || ENV["PORT"] || 5000
|
||||
bind_address = ENV.fetch("BIND_ADDRESS", Postal::Config.web_server.default_bind_address)
|
||||
bind_port = ENV.fetch("PORT", Postal::Config.web_server.default_port)
|
||||
bind "tcp://#{bind_address}:#{bind_port}"
|
||||
environment Postal.config.rails&.environment || "development"
|
||||
environment Postal::Config.rails.environment || "development"
|
||||
prune_bundler
|
||||
quiet false
|
||||
|
||||
المرجع في مشكلة جديدة
حظر مستخدم