Use .yggmail TLD

This commit is contained in:
Neil Alexander
2021-07-08 21:58:55 +01:00
parent 48e2c96924
commit 8b21aa84f9
3 changed files with 8 additions and 3 deletions

View File

@@ -12,7 +12,7 @@ Yggmail is a single-binary all-in-one mail transfer agent which sends and receiv
* All mail exchange traffic between any two Yggmail nodes is always end-to-end encrypted without exception; * All mail exchange traffic between any two Yggmail nodes is always end-to-end encrypted without exception;
* Yggdrasil and Yggmail nodes on the same network are discovered automatically using multicast or you can configure a static Yggdrasil peer. * Yggdrasil and Yggmail nodes on the same network are discovered automatically using multicast or you can configure a static Yggdrasil peer.
Email addresses are based on your public key, like `neilalexander@e3bf4665ae1ff714e0112040af8ddfc8e4b664a28e4afa40746e13952550f9ef`. Email addresses are based on your public key, like `neilalexander@e3bf4665ae1ff714e0112040af8ddfc8e4b664a28e4afa40746e13952550f9ef.yggmail`.
## Quickstart ## Quickstart

View File

@@ -92,7 +92,7 @@ func main() {
panic(err) panic(err)
} }
fmt.Printf("Created user %q\n", *createuser) fmt.Printf("Created user %q\n", *createuser)
fmt.Printf("Email address will be %s@%s\n", *createuser, hex.EncodeToString(pk)) fmt.Printf("Email address will be %s@%s%s\n", *createuser, hex.EncodeToString(pk), smtpserver.TLD)
os.Exit(0) os.Exit(0)
} }

View File

@@ -5,10 +5,15 @@ import (
"strings" "strings"
) )
const TLD = ".yggmail"
func parseAddress(email string) (string, string, error) { func parseAddress(email string) (string, string, error) {
if !strings.HasSuffix(email, TLD) {
return "", "", fmt.Errorf("invalid TLD")
}
at := strings.LastIndex(email, "@") at := strings.LastIndex(email, "@")
if at == 0 { if at == 0 {
return "", "", fmt.Errorf("invalid email address") return "", "", fmt.Errorf("invalid email address")
} }
return email[:at], email[at+1:], nil return email[:at], strings.TrimSuffix(email[at+1:], TLD), nil
} }