summaryrefslogtreecommitdiffstats
path: root/katzenpost/dispatcher/envelope.go
diff options
context:
space:
mode:
authorGab <24553253+gabrix73@users.noreply.github.com>2026-08-14 20:39:22 +0200
committerGab <24553253+gabrix73@users.noreply.github.com>2026-08-14 20:39:22 +0200
commit43fbddf016f94f4ba006d82c9a67dca61b5852a1 (patch)
tree70054d5fa8a34bb094b8c3ef8ddc9c1fcea3b3d5 /katzenpost/dispatcher/envelope.go
parent994071243fc80990cf09e820b671006e9bd31c76 (diff)
downloadyamnweb-43fbddf016f94f4ba006d82c9a67dca61b5852a1.tar.gz
yamnweb-43fbddf016f94f4ba006d82c9a67dca61b5852a1.tar.xz
yamnweb-43fbddf016f94f4ba006d82c9a67dca61b5852a1.zip
Complete Nym and YAMN transport integration
Diffstat (limited to 'katzenpost/dispatcher/envelope.go')
-rw-r--r--katzenpost/dispatcher/envelope.go45
1 files changed, 0 insertions, 45 deletions
diff --git a/katzenpost/dispatcher/envelope.go b/katzenpost/dispatcher/envelope.go
deleted file mode 100644
index b9ff7b8..0000000
--- a/katzenpost/dispatcher/envelope.go
+++ /dev/null
@@ -1,45 +0,0 @@
-package dispatcher
-
-import (
- "bytes"
- "errors"
- "fmt"
- "net/mail"
- "strings"
-)
-
-const MaxEnvelopeBytes = 64 * 1024
-
-// Envelope is the only application payload accepted by the dispatcher. Message
-// must already be a complete YAMN transport envelope, not user supplied mail.
-type Envelope struct {
- EntryAddress string `json:"entry_address"`
- Message []byte `json:"message"`
-}
-
-func (e Envelope) Validate(allowedDomains map[string]struct{}) error {
- if len(e.Message) == 0 || len(e.Message) > MaxEnvelopeBytes {
- return fmt.Errorf("invalid YAMN envelope size")
- }
- if bytes.Contains(e.Message, []byte("\r")) {
- return errors.New("YAMN envelope must use LF line endings")
- }
- address, err := mail.ParseAddress(e.EntryAddress)
- if err != nil || address.Address != e.EntryAddress {
- return errors.New("invalid entry remailer address")
- }
- parts := strings.Split(address.Address, "@")
- if len(parts) != 2 || parts[0] == "" || parts[1] == "" {
- return errors.New("invalid entry remailer address")
- }
- if _, ok := allowedDomains[strings.ToLower(parts[1])]; !ok {
- return errors.New("entry remailer domain is not allowed")
- }
- if !bytes.HasPrefix(e.Message, []byte("To: "+e.EntryAddress+"\n")) {
- return errors.New("YAMN envelope recipient does not match entry remailer")
- }
- if !bytes.Contains(e.Message, []byte("-----BEGIN REMAILER MESSAGE-----\n")) {
- return errors.New("invalid YAMN envelope")
- }
- return nil
-}