Spaces:
Running
Running
OpenCode Bot commited on
Commit ·
47887be
1
Parent(s): e8cfd54
Disable STARTTLS for local SMTP proxy
Browse filesFiles changed (3)
- Dockerfile+4-2
- disable-starttls.pyAdded+36
- start.sh+1
2 unmodified lines345678910111213142 unmodified linesFROM python:3.13-slimRUN apt-get update \&& apt-get install -y --no-install-recommends ca-certificates openssl tzdata \&& rm -rf /var/lib/apt/lists/* \&& update-ca-certificatesCOPY --from=upstream /new-api /new-apiCOPY smtp-proxy.py /app/smtp-proxy.pyCOPY start.sh /app/start.shRUN openssl req -x509 -newkey rsa:2048 -nodes \-keyout /app/smtp-proxy.key \2 unmodified lines3456789101112131415162 unmodified linesFROM python:3.13-slimRUN apt-get update \&& apt-get install -y --no-install-recommends ca-certificates gcc libpq-dev openssl tzdata \&& rm -rf /var/lib/apt/lists/* \&& update-ca-certificates \&& pip install --no-cache-dir psycopg2-binaryCOPY --from=upstream /new-api /new-apiCOPY smtp-proxy.py /app/smtp-proxy.pyCOPY disable-starttls.py /app/disable-starttls.pyCOPY start.sh /app/start.shRUN openssl req -x509 -newkey rsa:2048 -nodes \-keyout /app/smtp-proxy.key \
123456789101112131415161718192021222324252627282930313233343536#!/usr/bin/env python3import osimport sysimport urllib.parse
def main() -> int: dsn = os.environ.get("SQL_DSN", "").strip() if not dsn: return 0 parsed = urllib.parse.urlparse(dsn) if parsed.scheme not in {"postgres", "postgresql"}: return 0 try: import psycopg2 except Exception: return 0 conn = psycopg2.connect(dsn.replace("postgres://", "postgresql://", 1)) try: with conn: with conn.cursor() as cur: cur.execute( """ insert into options (key, value) values (%s, %s) on conflict (key) do update set value = excluded.value """, ("SMTPStartTLSEnabled", "false"), ) finally: conn.close() print("SMTPStartTLSEnabled=false") return 0
if __name__ == "__main__": sys.exit(main())2 unmodified lines3456782 unmodified linesecho "Starting local SMTP-to-Resend API proxy on 127.0.0.1:587..."printf '\n127.0.0.1 smtp.resend.com\n' >> /etc/hostspython3 /app/smtp-proxy.py &PROXY_PID=$!2 unmodified lines34567892 unmodified linesecho "Starting local SMTP-to-Resend API proxy on 127.0.0.1:587..."printf '\n127.0.0.1 smtp.resend.com\n' >> /etc/hostspython3 /app/disable-starttls.py || echo "WARNING: failed to disable SMTP STARTTLS option"python3 /app/smtp-proxy.py &PROXY_PID=$!
Dockerfile+4-2
disable-starttls.pyAdded+36
start.sh+1