mirror of
https://github.com/neilalexander/yggmail.git
synced 2026-05-08 04:46:28 +03:00
Base62 mail domains
This commit is contained in:
@@ -2,13 +2,13 @@ package smtpserver
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"io"
|
||||
"time"
|
||||
|
||||
"github.com/emersion/go-message"
|
||||
"github.com/emersion/go-smtp"
|
||||
"github.com/jxskiss/base62"
|
||||
"github.com/neilalexander/yggmail/internal/smtpsender"
|
||||
)
|
||||
|
||||
@@ -25,7 +25,7 @@ func (s *SessionLocal) Mail(from string, opts smtp.MailOptions) error {
|
||||
return fmt.Errorf("parseAddress: %w", err)
|
||||
}
|
||||
|
||||
if host != hex.EncodeToString(s.backend.Config.PublicKey) {
|
||||
if host != base62.EncodeToString(s.backend.Config.PublicKey) {
|
||||
return fmt.Errorf("not allowed to send outgoing mail as %s", from)
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ func (s *SessionLocal) Data(r io.Reader) error {
|
||||
m.Header.Add(
|
||||
"Received", fmt.Sprintf("from %s by Yggmail %s; %s",
|
||||
s.state.RemoteAddr.String(),
|
||||
hex.EncodeToString(s.backend.Config.PublicKey),
|
||||
base62.EncodeToString(s.backend.Config.PublicKey),
|
||||
time.Now().String(),
|
||||
),
|
||||
)
|
||||
@@ -65,7 +65,7 @@ func (s *SessionLocal) Data(r io.Reader) error {
|
||||
}
|
||||
servers[host] = struct{}{}
|
||||
|
||||
if host == hex.EncodeToString(s.backend.Config.PublicKey) {
|
||||
if host == base62.EncodeToString(s.backend.Config.PublicKey) {
|
||||
var b bytes.Buffer
|
||||
if err := m.WriteTo(&b); err != nil {
|
||||
return fmt.Errorf("m.WriteTo: %w", err)
|
||||
|
||||
@@ -3,13 +3,13 @@ package smtpserver
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/ed25519"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"io"
|
||||
"time"
|
||||
|
||||
"github.com/emersion/go-message"
|
||||
"github.com/emersion/go-smtp"
|
||||
"github.com/jxskiss/base62"
|
||||
)
|
||||
|
||||
type SessionRemote struct {
|
||||
@@ -40,7 +40,7 @@ func (s *SessionRemote) Rcpt(to string) error {
|
||||
return fmt.Errorf("mail.ParseAddress: %w", err)
|
||||
}
|
||||
|
||||
if local := hex.EncodeToString(s.backend.Config.PublicKey); host != local {
|
||||
if local := base62.EncodeToString(s.backend.Config.PublicKey); host != local {
|
||||
return fmt.Errorf("not allowed to send mail to %q", host)
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ func (s *SessionRemote) Data(r io.Reader) error {
|
||||
|
||||
m.Header.Add(
|
||||
"Received", fmt.Sprintf("from Yggmail %s; %s",
|
||||
hex.EncodeToString(s.public),
|
||||
base62.EncodeToString(s.public),
|
||||
time.Now().String(),
|
||||
),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user