Added README, CHANGELOG.

This commit is contained in:
Mauro D 2023-02-24 15:28:02 +00:00
parent df33eea95c
commit 97bc5bbd3b
11 changed files with 605 additions and 65 deletions

13
.github/FUNDING.yml vendored Normal file
View file

@ -0,0 +1,13 @@
# These are supported funding model platforms
github: stalwartlabs
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

251
.github/workflows/build.yml vendored Normal file
View file

@ -0,0 +1,251 @@
name: Build
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
tags:
- v*.*.*
jobs:
build:
name: Building for ${{ matrix.target }} on ${{ matrix.host_os }}
runs-on: ${{ matrix.host_os }}
strategy:
matrix:
include:
- target: aarch64-unknown-linux-gnu
host_os: ubuntu-20.04
- target: aarch64-apple-darwin
host_os: macos-latest
- target: x86_64-pc-windows-msvc
host_os: windows-2022
- target: x86_64-apple-darwin
host_os: macos-latest
- target: x86_64-unknown-linux-gnu
host_os: ubuntu-20.04
#- target: aarch64-pc-windows-msvc
# host_os: windows-2022
#- target: aarch64-unknown-linux-musl
# host_os: ubuntu-20.04
#- target: arm-unknown-linux-musleabihf
# host_os: ubuntu-20.04
#- target: arm-unknown-linux-gnueabihf
# host_os: ubuntu-20.04
#- target: armv7-unknown-linux-musleabihf
# host_os: ubuntu-20.04
#- target: armv7-unknown-linux-gnueabihf
# host_os: ubuntu-20.04
#- target: x86_64-unknown-linux-musl
# host_os: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
with:
persist-credentials: false
- name: Install LLVM and Clang (Windows)
uses: KyleMayes/install-llvm-action@32c4866ebb71e0949e8833eb49beeebed48532bd
if: ${{ contains(matrix.host_os, 'windows') }}
with:
version: "14.0"
directory: ${{ runner.temp }}/llvm
- name: Set LIBCLANG_PATH
run: echo "LIBCLANG_PATH=$((gcm clang).source -replace "clang.exe")" >> $env:GITHUB_ENV
if: ${{ contains(matrix.host_os, 'windows') }}
- name: Install LLVM and Clang (Linux)
if: ${{ contains(matrix.host_os, 'ubuntu') }}
run: |
sudo apt-get update -y
sudo wget https://apt.llvm.org/llvm.sh
sudo chmod +x llvm.sh
sudo ./llvm.sh 14 all
- name: Install ARM64 Linux build tools
if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' }}
run: |
sudo apt-get -yq --no-install-suggests --no-install-recommends install \
gcc-aarch64-linux-gnu \
g++-aarch64-linux-gnu \
libc6-dev-arm64-cross
- name: Install ARM7 Linux build tools
if: ${{ matrix.target == 'armv7-unknown-linux-gnueabihf' ||
matrix.target == 'arm-unknown-linux-gnueabihf' }}
run: |
sudo apt-get -yq --no-install-suggests --no-install-recommends install \
gcc-arm-linux-gnueabihf \
g++-arm-linux-gnueabihf \
libc6-dev-armhf-cross
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
override: true
target: ${{ matrix.target }}
toolchain: stable
- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.host_os }}-${{ matrix.target }}-smtp
- name: XCode Version
if: ${{ matrix.target == 'aarch64-apple-darwin' }}
run: |
sudo xcode-select -s /Applications/Xcode_12.4.app &&
sudo rm -Rf /Library/Developer/CommandLineTools/SDKs/*
- name: ARM64 Windows setup
if: ${{ matrix.target == 'aarch64-pc-windows-msvc' }}
shell: bash
run: |
echo "C:\Program Files (x86)\Microsoft Visual Studio\2022\Enterprise\VC\Tools\Llvm\x64\bin" >> $GITHUB_PATH
echo "RUSTFLAGS=-C target-feature=+crt-static" >> $GITHUB_ENV
- name: Building binary (Linux/MacOS)
if: ${{ !contains(matrix.host_os, 'windows') }}
run: |
case "${{ matrix.target }}" in
aarch64-unknown-linux-gnu)
export CC_aarch64_unknown_linux_gnu=clang-14
export AR_aarch64_unknown_linux_gnu=llvm-ar-14
export CFLAGS_aarch64_unknown_linux_gnu="--sysroot=/usr/aarch64-linux-gnu"
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc
;;
aarch64-unknown-linux-musl)
export CC_aarch64_unknown_linux_musl=clang-14
export AR_aarch64_unknown_linux_musl=llvm-ar-14
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_RUSTFLAGS="-Clink-self-contained=yes -Clinker=rust-lld"
;;
arm-unknown-linux-gnueabihf)
export CC_arm_unknown_linux_gnueabihf=arm-linux-gnueabihf-gcc
export AR_arm_unknown_linux_gnueabihf=arm-linux-gnueabihf-gcc-ar
export CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc
;;
arm-unknown-linux-musleabihf)
export CC_arm_unknown_linux_musleabihf=clang-14
export AR_arm_unknown_linux_musleabihf=llvm-ar-14
export CARGO_TARGET_ARM_UNKNOWN_LINUX_MUSLEABIHF_RUSTFLAGS="-Clink-self-contained=yes -Clinker=rust-lld"
;;
armv7-unknown-linux-gnueabihf)
export CC_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-gcc
export AR_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-gcc-ar
export CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc
;;
armv7-unknown-linux-musleabihf)
export CC_armv7_unknown_linux_musleabihf=clang-14
export AR_armv7_unknown_linux_musleabihf=llvm-ar-14
export CARGO_TARGET_ARMV7_UNKNOWN_LINUX_MUSLEABIHF_RUSTFLAGS="-Clink-self-contained=yes -Clinker=rust-lld"
;;
x86_64-unknown-linux-musl)
export CC_x86_64_unknown_linux_musl=clang-14
export AR_x86_64_unknown_linux_musl=llvm-ar-14
export CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_RUSTFLAGS="-Clink-self-contained=yes -Clinker=rust-lld"
;;
*)
;;
esac
cargo build --target=${{ matrix.target }} --release
- name: Building binary (Windows)
if: ${{ contains(matrix.host_os, 'windows') }}
shell: bash
run: |
cargo build --target=${{ matrix.target }} --release
- name: Package (tar.gz)
if: ${{ !contains(matrix.host_os, 'windows') }}
shell: bash
run: |
cd target/${{ matrix.target }}/release
tar czvf ../../../stalwart-smtp-${{ matrix.target }}.tar.gz stalwart-smtp
cd -
- name: Package (7z)
if: ${{ contains(matrix.host_os, 'windows') }}
shell: bash
run: |
cd target/${{ matrix.target }}/release
7z a ../../../stalwart-smtp-${{ matrix.target }}.zip stalwart-smtp.exe
cd -
- name: Publish Release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v1
with:
files: 'stalwart-smtp*'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
docker-amd:
needs: build
name: Build Docker AMD64 images
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
push: true
platforms: linux/amd64
tags: stalwartlabs/smtp-server:latest
cache-from: type=registry,ref=stalwartlabs/smtp-server:buildcache
cache-to: type=registry,ref=stalwartlabs/smtp-server:buildcache,mode=max
#cache-from: type=gha
#cache-to: type=gha,mode=max
docker-arm:
needs: [build, docker-amd]
name: Build Docker ARM64 images
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
push: true
platforms: linux/arm64
tags: stalwartlabs/smtp-server:latest
cache-from: type=registry,ref=stalwartlabs/smtp-server:buildcache
cache-to: type=registry,ref=stalwartlabs/smtp-server:buildcache,mode=max
#cache-from: type=gha
#cache-to: type=gha,mode=max

83
.github/workflows/test.yml vendored Normal file
View file

@ -0,0 +1,83 @@
name: Test
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
jobs:
style:
name: Check Style
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: rustfmt
profile: minimal
override: true
- name: cargo fmt -- --check
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
test:
name: Test
needs: [style]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
- name: Basic Tests
uses: actions-rs/cargo@v1
with:
command: test
args: --all
- name: Database Tests
uses: actions-rs/cargo@v1
with:
command: test
args: store_tests --all
- name: JMAP Core Tests
uses: actions-rs/cargo@v1
with:
command: test
args: jmap_core_tests -- --ignored
- name: JMAP Mail Tests
uses: actions-rs/cargo@v1
with:
command: test
args: jmap_mail_tests -- --ignored
- name: Stress Tests
uses: actions-rs/cargo@v1
with:
command: test
args: jmap_stress_tests -- --ignored
- name: Cluster Tests
uses: actions-rs/cargo@v1
with:
command: test
args: cluster_tests -- --ignored

3
CHANGELOG.md Normal file
View file

@ -0,0 +1,3 @@
stalwart-smtp 0.1.0
================================
- Initial release.

1
CNAME Normal file
View file

@ -0,0 +1 @@
smtp.stalw.art

92
Cargo.lock generated
View file

@ -2475,52 +2475,6 @@ name = "smtp-proto"
version = "0.1.1"
source = "git+https://github.com/stalwartlabs/smtp-proto#94c16ce6d76edaed9f002c03c6850cb020a57e58"
[[package]]
name = "smtp-server"
version = "0.1.0"
dependencies = [
"ahash 0.8.3",
"blake3",
"criterion",
"dashmap",
"form_urlencoded",
"http-body-util",
"hyper 1.0.0-rc.2",
"lru-cache",
"mail-auth",
"mail-builder",
"mail-parser",
"mail-send",
"num_cpus",
"opentelemetry",
"opentelemetry-otlp",
"opentelemetry-semantic-conventions",
"parking_lot 0.12.1",
"privdrop",
"rand",
"rayon",
"regex",
"reqwest",
"rustls",
"rustls-pemfile",
"serde",
"serde_json",
"serial_test",
"sha1",
"sha2",
"sieve-rs",
"smtp-proto",
"sqlx",
"tokio",
"tokio-rustls",
"tracing",
"tracing-appender",
"tracing-opentelemetry",
"tracing-subscriber",
"webpki-roots",
"x509-parser",
]
[[package]]
name = "socket2"
version = "0.4.7"
@ -2670,6 +2624,52 @@ dependencies = [
"tokio-rustls",
]
[[package]]
name = "stalwart-smtp"
version = "0.1.0"
dependencies = [
"ahash 0.8.3",
"blake3",
"criterion",
"dashmap",
"form_urlencoded",
"http-body-util",
"hyper 1.0.0-rc.2",
"lru-cache",
"mail-auth",
"mail-builder",
"mail-parser",
"mail-send",
"num_cpus",
"opentelemetry",
"opentelemetry-otlp",
"opentelemetry-semantic-conventions",
"parking_lot 0.12.1",
"privdrop",
"rand",
"rayon",
"regex",
"reqwest",
"rustls",
"rustls-pemfile",
"serde",
"serde_json",
"serial_test",
"sha1",
"sha2",
"sieve-rs",
"smtp-proto",
"sqlx",
"tokio",
"tokio-rustls",
"tracing",
"tracing-appender",
"tracing-opentelemetry",
"tracing-subscriber",
"webpki-roots",
"x509-parser",
]
[[package]]
name = "static_assertions"
version = "1.1.0"

View file

@ -1,7 +1,15 @@
[package]
name = "smtp-server"
name = "stalwart-smtp"
description = "Stalwart SMTP Server"
authors = [ "Stalwart Labs Ltd. <hello@stalw.art>"]
repository = "https://github.com/stalwartlabs/smtp-server"
homepage = "https://stalw.art/smtp"
keywords = ["smtp", "email", "mail", "server"]
categories = ["email"]
license = "AGPL-3.0-only"
version = "0.1.0"
edition = "2021"
resolver = "2"
[dependencies]
mail-auth = { git = "https://github.com/stalwartlabs/mail-auth" }
@ -51,14 +59,3 @@ serial_test = "1.0.0"
[[bench]]
name = "hash"
harness = false
[features]
removeme = []
#[[bin]]
#name = "daemon"
#path = "src/daemon/bin/main.rs"
#[[bin]]
#name = "client"
#path = "src/client/bin/main.rs"

47
Dockerfile Normal file
View file

@ -0,0 +1,47 @@
FROM debian:buster-slim AS chef
RUN apt-get update && \
export DEBIAN_FRONTEND=noninteractive && \
apt-get install -yq \
build-essential \
cmake \
clang \
curl
ENV RUSTUP_HOME=/opt/rust/rustup \
PATH=/home/root/.cargo/bin:/opt/rust/cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
RUN curl https://sh.rustup.rs -sSf | \
env CARGO_HOME=/opt/rust/cargo \
sh -s -- -y --default-toolchain stable --profile minimal --no-modify-path && \
env CARGO_HOME=/opt/rust/cargo \
rustup component add rustfmt
RUN env CARGO_HOME=/opt/rust/cargo cargo install cargo-chef && \
rm -rf /opt/rust/cargo/registry/
WORKDIR /app
FROM chef AS planner
COPY Cargo.toml .
COPY Cargo.lock .
COPY src/ src/
COPY components/ components/
COPY resources/ resources/
RUN cargo chef prepare --recipe-path recipe.json
FROM chef AS builder
COPY --from=planner /app/recipe.json recipe.json
RUN cargo chef cook --release --recipe-path recipe.json
COPY Cargo.toml .
COPY Cargo.lock .
COPY src/ src/
COPY components/ components/
COPY resources/ resources/
RUN cargo build --release
FROM debian:buster-slim AS runtime
COPY --from=builder /app/target/release/stalwart-smtp /usr/local/bin/stalwart-smtp
RUN useradd stalwart-smtp -s /sbin/nologin -M
RUN mkdir -p /usr/local/stalwart-smtp
RUN chown stalwart-smtp:stalwart-smtp /usr/local/stalwart-smtp
#USER stalwart-smtp
ENTRYPOINT ["/usr/local/bin/stalwart-smtp"]

153
README.md
View file

@ -1,6 +1,151 @@
# smtp-server
Stalwart SMTP Server
# Stalwart SMTP Server
# TODO
- OpenTelemetry
[![Test](https://github.com/stalwartlabs/smtp-server/actions/workflows/test.yml/badge.svg)](https://github.com/stalwartlabs/smtp-server/actions/workflows/test.yml)
[![Build](https://github.com/stalwartlabs/smtp-server/actions/workflows/build.yml/badge.svg)](https://github.com/stalwartlabs/smtp-server/actions/workflows/build.yml)
[![License: AGPL v3](https://img.shields.io/badge/License-AGPL_v3-blue.svg)](https://www.gnu.org/licenses/agpl-3.0)
[![](https://img.shields.io/discord/923615863037390889?label=Chat)](https://discord.gg/jtgtCNj66U)
[![](https://img.shields.io/twitter/follow/stalwartlabs?style=flat)](https://twitter.com/stalwartlabs)
**Stalwart SMTP** is a modern SMTP server developed in Rust with a focus on security, speed, and extensive configurability.
It features built-in DMARC, DKIM, SPF and ARC support for message and sender authentication, strong transport security through DANE, MTA-STS, SMTP TLS reporting and offers great flexibility and customization thanks to its configurable rules and native support for Sieve scripts.
Key features:
- Sender and Message Authentication:
- Domain-based Message Authentication, Reporting, and Conformance (**DMARC**) verification and failure/aggregate reporting.
- DomainKeys Identified Mail (**DKIM**) verification, signing and failure reporting.
- Sender Policy Framework (**SPF**) policy evaluation and failure reporting.
- Authenticated Received Chain (**ARC**) verification and sealing.
- Reverse IP (**iprev**) validation.
- Strong Transport Security:
- DNS-Based Authentication of Named Entities (**DANE**) Transport Layer Security.
- SMTP MTA Strict Transport Security (**MTA-STS**).
- SMTP TLS Reporting (**TLSRPT**) delivery and analysis.
- Inbound Filtering and Throttling:
- Sieve scripting language with support for all [registered extensions](https://www.iana.org/assignments/sieve-extensions/sieve-extensions.xhtml).
- Filtering, modification and removal of MIME parts or headers.
- DNS block lists (**DNSBL**).
- Greylisting.
- Inbound concurrency and rate limiting.
- Integration with external content filtering systems such as SpamAssassin and ClamAV.
- Flexible Queues:
- Unlimited virtual queues.
- Delayed delivery with `FUTURERELEASE` and `DELIVERBY` extensions support.
- Priority delivery with `MT-PRIORITY` extension support.
- Quotas.
- Outbound throttling.
- Custom routing rules.
- Logging and Reporting:
- Detailed logging of SMTP transactions and events, including delivery attempts, errors, and policy violations.
- Integration with **OpenTelemetry** to enable monitoring, tracing, and performance analysis of SMTP server operations.
- Automatic analysis of incoming DMARC/TLS aggregate reports, DMARC/DKIM/SPF authentication failure reports as well as abuse reports.
- And more:
- SASL authentication.
- PostgreSQL, MySQL, MSSQL and SQLite support.
- Granular configuration rules.
- REST API for management.
- Memory safe (thanks to Rust).
## Get Started
Install Stalwart SMTP on your server by following the instructions for your platform:
- [Linux / MacOS](https://stalw.art/smtp/get-started/linux/)
- [Windows](https://stalw.art/smtp/get-started/windows/)
- [Docker](https://stalw.art/smtp/get-started/docker/)
You may also [compile Stalwart SMTP from the source](https://stalw.art/smtp/development/compile/).
## Support
If you are having problems running Stalwart SMTP, you found a bug or just have a question,
do not hesitate to reach us on [Github Discussions](https://github.com/stalwartlabs/smtp-server/discussions),
[Reddit](https://www.reddit.com/r/stalwartlabs) or [Discord](https://discord.gg/jtgtCNj66U).
Additionally you may become a sponsor to obtain priority support from Stalwart Labs Ltd.
## Documentation
Table of Contents
- Get Started
- [Linux / MacOS](https://stalw.art/smtp/get-started/linux/)
- [Windows](https://stalw.art/smtp/get-started/windows/)
- [Docker](https://stalw.art/smtp/get-started/docker/)
- Configuration
- Overview
- General
- Listeners
- Rules
- Scripting
- Certificates
- Remote
- Databases
- Lists
- Resolver
- Logging
- Inbound
- Overview
- Connect
- Extensions
- Ehlo
- Authentication
- Mail-From
- Data
- Outbound
- Overview
- Schedule
- Queue strategy
- Throttling
- Quotas
- Authentication
- Overview
- Signatures
- DKIM
- SPF
- ARC
- DMARC
- IpRev
- DNSBL
- Management
- Overview
- Configuration
- Queue
- Reports
- Development
- [Compiling](https://stalw.art/smtp/development/compile/)
- [Tests](https://stalw.art/smtp/development/test/)
- [RFCs conformed](https://stalw.art/smtp/development/rfc/)
## Roadmap
The following major features and enhancements are planned for Stalwart SMTP:
- Embedded Antispam and Antivirus
- WASM filters
- Distributed mode
- Web-based administration
## Testing & Fuzzing
To run the test suite execute:
```bash
cargo test
```
To run the fuzz tests please refer to the Stalwart libraries that handle parsing for the SMTP server: [smtp-proto](https://github.com/stalwartlabs/smtp-proto),
[mail-parser](https://github.com/stalwartlabs/mail-parser),
[mail-auth](https://github.com/stalwartlabs/mail-auth) and [sieve-rs](https://github.com/stalwartlabs/sieve).
## License
Licensed under the terms of the [GNU Affero General Public License](https://www.gnu.org/licenses/agpl-3.0.en.html) as published by
the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
See [LICENSE](LICENSE) for more details.
You can be released from the requirements of the AGPLv3 license by purchasing
a commercial license. Please contact licensing@stalw.art for more details.
## Copyright
Copyright (C) 2020-2023, Stalwart Labs Ltd.

View file

@ -29,7 +29,7 @@ use std::{
use ahash::RandomState;
use criterion::{criterion_group, criterion_main, Criterion};
use dashmap::DashMap;
use smtp_server::{
use stalwart_smtp::{
config::*,
core::{
throttle::{ThrottleKey, ThrottleKeyHasherBuilder},

View file

@ -34,7 +34,7 @@ use opentelemetry::{
};
use opentelemetry_otlp::WithExportConfig;
use opentelemetry_semantic_conventions::resource::{SERVICE_NAME, SERVICE_VERSION};
use smtp_server::{
use stalwart_smtp::{
config::{Config, ConfigContext, ServerProtocol},
core::{
throttle::{ConcurrencyLimiter, ThrottleKeyHasherBuilder},
@ -259,7 +259,7 @@ async fn main() -> std::io::Result<()> {
Ok(())
}
fn enable_tracing(config: &Config) -> smtp_server::config::Result<Option<WorkerGuard>> {
fn enable_tracing(config: &Config) -> stalwart_smtp::config::Result<Option<WorkerGuard>> {
let level = config.value("global.tracing.level").unwrap_or("info");
let env_filter = EnvFilter::builder()
.parse(format!("smtp_server={}", level))