mirror of
https://blitiri.com.ar/repos/chasquid
synced 2025-12-17 14:37:02 +00:00
Implement basic IDNA support
This patch implements the first steps of support for IDNA (Internationalized Domain Names for Applications). Internally, we maintain the byte-agnostic representation, including configuration. We support receiving IDNA mail over SMTP, which we convert to unicode for internal handling. Local deliveries are still kept agnostic. For sending over SMTP, we use IDNA for DNS resolution, but there are some corner cases pending in the SMTP courier that are tied with SMTPUTF8 and will be fixed in subsequent patches.
This commit is contained in:
@@ -39,8 +39,11 @@ function chasquid() {
|
||||
}
|
||||
|
||||
function add_user() {
|
||||
CONFDIR="${CONFDIR:-config}"
|
||||
mkdir -p "${CONFDIR}/domains/${1}/"
|
||||
go run ${TBASE}/../../cmd/chasquid-util/chasquid-util.go \
|
||||
adduser "config/domains/${1}/users" "${2}" --password "${3}" \
|
||||
adduser "${CONFDIR}/domains/${1}/users" "${2}" \
|
||||
--password "${3}" \
|
||||
>> .add_user_logs
|
||||
}
|
||||
|
||||
@@ -52,6 +55,10 @@ function run_msmtp() {
|
||||
msmtp -C msmtprc "$@"
|
||||
}
|
||||
|
||||
function smtpc.py() {
|
||||
${UTILDIR}/smtpc.py "$@"
|
||||
}
|
||||
|
||||
function mail_diff() {
|
||||
${UTILDIR}/mail_diff "$@"
|
||||
}
|
||||
@@ -82,9 +89,21 @@ function wait_for_file() {
|
||||
|
||||
# Generate certs for the given hostname.
|
||||
function generate_certs_for() {
|
||||
mkdir -p config/certs/${1}/
|
||||
CONFDIR="${CONFDIR:-config}"
|
||||
mkdir -p ${CONFDIR}/certs/${1}/
|
||||
(
|
||||
cd config/certs/${1}
|
||||
cd ${CONFDIR}/certs/${1}
|
||||
generate_cert -ca -duration=1h -host=${1}
|
||||
)
|
||||
}
|
||||
|
||||
# Check the Python version, and skip if it's too old.
|
||||
# This will check against the version required for smtpc.py.
|
||||
function skip_if_python_is_too_old() {
|
||||
# We need Python >= 3.5 to be able to use SMTPUTF8.
|
||||
check='import sys; sys.exit(0 if sys.version_info >= (3, 5) else 1)'
|
||||
if ! python3 -c "${check}"; then
|
||||
skip "python3 >= 3.5 not available"
|
||||
exit 0
|
||||
fi
|
||||
}
|
||||
|
||||
30
test/util/smtpc.py
Executable file
30
test/util/smtpc.py
Executable file
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# Simple SMTP client for testing purposes.
|
||||
|
||||
import argparse
|
||||
import email.parser
|
||||
import email.policy
|
||||
import smtplib
|
||||
import sys
|
||||
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("--server", help="SMTP server to connect to")
|
||||
ap.add_argument("--user", help="Username to use in SMTP AUTH")
|
||||
ap.add_argument("--password", help="Password to use in SMTP AUTH")
|
||||
args = ap.parse_args()
|
||||
|
||||
# Parse the email using the "default" policy, which is not really the default.
|
||||
# If unspecified, compat32 is used, which does not support UTF8.
|
||||
msg = email.parser.Parser(policy=email.policy.default).parse(sys.stdin)
|
||||
|
||||
s = smtplib.SMTP(args.server)
|
||||
s.starttls()
|
||||
s.login(args.user, args.password)
|
||||
|
||||
# Note this does NOT support non-ascii message payloads transparently (headers
|
||||
# are ok).
|
||||
s.send_message(msg)
|
||||
s.quit()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user