mirror of
https://github.com/neilalexander/yggmail.git
synced 2026-05-24 11:56:28 +03:00
User-facing command lines
This commit is contained in:
@@ -33,15 +33,17 @@ Create a mailbox and set your password. Your Yggmail database will automatically
|
|||||||
yggmail -password
|
yggmail -password
|
||||||
```
|
```
|
||||||
|
|
||||||
Start Yggmail, using the database in your working directory:
|
Start Yggmail, using the database in your working directory, with either multicast enabled, an [Yggdrasil static peer](https://publicpeers.neilalexander.dev/) specified or both:
|
||||||
```
|
```
|
||||||
yggmail -smtp=localhost:1025 -imap=localhost:1026
|
yggmail -multicast
|
||||||
|
yggmail -peer=tls://...
|
||||||
|
yggmail -multicast -peer=tls://...
|
||||||
```
|
```
|
||||||
|
|
||||||
Connect your mail client to Yggmail. In the above example:
|
Connect your mail client to Yggmail. In the above example:
|
||||||
|
|
||||||
* SMTP is listening on `localhost` port 1025, password authentication, no SSL/TLS
|
* SMTP is listening on `localhost` port 1025, password authentication, no SSL/TLS
|
||||||
* IMAP is listening on `localhost` port 1026, password authentication, no SSL/TLS
|
* IMAP is listening on `localhost` port 1143, password authentication, no SSL/TLS
|
||||||
|
|
||||||
Then try sending a mail to another Yggmail user!
|
Then try sending a mail to another Yggmail user!
|
||||||
|
|
||||||
@@ -50,6 +52,7 @@ Then try sending a mail to another Yggmail user!
|
|||||||
The following command line switches are supported by the `yggmail` binary:
|
The following command line switches are supported by the `yggmail` binary:
|
||||||
|
|
||||||
* `-peer=tls://...` or `-peer=tcp://...` — connect to a specific Yggdrasil node, like one of the [Public Peers](https://publicpeers.neilalexander.dev/);
|
* `-peer=tls://...` or `-peer=tcp://...` — connect to a specific Yggdrasil node, like one of the [Public Peers](https://publicpeers.neilalexander.dev/);
|
||||||
|
* `-multicast` - enable multicast peer discovery for Yggdrasil nodes on your LAN
|
||||||
* `-database=/path/to/yggmail.db` — use a specific database file;
|
* `-database=/path/to/yggmail.db` — use a specific database file;
|
||||||
* `-smtp=listenaddr:port` — listen for SMTP on a specific address/port
|
* `-smtp=listenaddr:port` — listen for SMTP on a specific address/port
|
||||||
* `-imap=listenaddr:port` — listen for IMAP on a specific address/port;
|
* `-imap=listenaddr:port` — listen for IMAP on a specific address/port;
|
||||||
|
|||||||
@@ -27,16 +27,26 @@ import (
|
|||||||
|
|
||||||
var database = flag.String("database", "yggmail.db", "SQLite database file")
|
var database = flag.String("database", "yggmail.db", "SQLite database file")
|
||||||
var smtpaddr = flag.String("smtp", "localhost:1025", "SMTP listen address")
|
var smtpaddr = flag.String("smtp", "localhost:1025", "SMTP listen address")
|
||||||
var imapaddr = flag.String("imap", "localhost:1026", "IMAP listen address")
|
var imapaddr = flag.String("imap", "localhost:1143", "IMAP listen address")
|
||||||
var peeraddr = flag.String("peer", "", "Yggdrasil static peer")
|
var peeraddr = flag.String("peer", "", "Connect to a specific Yggdrasil static peer")
|
||||||
|
var multicast = flag.Bool("multicast", false, "Connect to Yggdrasil peers on your LAN")
|
||||||
var password = flag.Bool("password", false, "Set a new IMAP/SMTP password")
|
var password = flag.Bool("password", false, "Set a new IMAP/SMTP password")
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
flag.Parse()
|
|
||||||
|
|
||||||
rawlog := log.New(os.Stdout, "", 0)
|
rawlog := log.New(os.Stdout, "", 0)
|
||||||
log := log.New(rawlog.Writer(), "[ \033[32mYggmail\033[0m ] ", 0)
|
log := log.New(rawlog.Writer(), "[ \033[32mYggmail\033[0m ] ", 0)
|
||||||
|
|
||||||
|
flag.Parse()
|
||||||
|
if flag.NFlag() == 0 {
|
||||||
|
fmt.Println("Yggmail must be started with either an Yggdrasil peer")
|
||||||
|
fmt.Println("specified, multicast enabled, or both.")
|
||||||
|
fmt.Println()
|
||||||
|
fmt.Println("Available options:")
|
||||||
|
fmt.Println()
|
||||||
|
flag.PrintDefaults()
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
storage, err := sqlite3.NewSQLite3StorageStorage(*database)
|
storage, err := sqlite3.NewSQLite3StorageStorage(*database)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
@@ -95,6 +105,10 @@ func main() {
|
|||||||
|
|
||||||
log.Println("Password for IMAP and SMTP has been updated!")
|
log.Println("Password for IMAP and SMTP has been updated!")
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
|
|
||||||
|
case (multicast == nil || !*multicast) && (peeraddr == nil || *peeraddr == ""):
|
||||||
|
log.Printf("You must specify either -peer, -multicast or both!")
|
||||||
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg := &config.Config{
|
cfg := &config.Config{
|
||||||
@@ -104,7 +118,7 @@ func main() {
|
|||||||
wg := &sync.WaitGroup{}
|
wg := &sync.WaitGroup{}
|
||||||
wg.Add(2)
|
wg.Add(2)
|
||||||
|
|
||||||
transport, err := transport.NewYggdrasilTransport(rawlog, sk, pk, *peeraddr)
|
transport, err := transport.NewYggdrasilTransport(rawlog, sk, pk, *peeraddr, *multicast)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ type YggdrasilTransport struct {
|
|||||||
Sessions *utp.Socket
|
Sessions *utp.Socket
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewYggdrasilTransport(log *log.Logger, sk ed25519.PrivateKey, pk ed25519.PublicKey, peer string) (*YggdrasilTransport, error) {
|
func NewYggdrasilTransport(log *log.Logger, sk ed25519.PrivateKey, pk ed25519.PublicKey, peer string, mcast bool) (*YggdrasilTransport, error) {
|
||||||
config := &config.NodeConfig{
|
config := &config.NodeConfig{
|
||||||
PublicKey: hex.EncodeToString(pk),
|
PublicKey: hex.EncodeToString(pk),
|
||||||
PrivateKey: hex.EncodeToString(sk),
|
PrivateKey: hex.EncodeToString(sk),
|
||||||
@@ -33,6 +33,7 @@ func NewYggdrasilTransport(log *log.Logger, sk ed25519.PrivateKey, pk ed25519.Pu
|
|||||||
NodeInfo: map[string]interface{}{
|
NodeInfo: map[string]interface{}{
|
||||||
"name": "Yggmail",
|
"name": "Yggmail",
|
||||||
},
|
},
|
||||||
|
NodeInfoPrivacy: true,
|
||||||
}
|
}
|
||||||
if peer != "" {
|
if peer != "" {
|
||||||
config.Peers = append(config.Peers, peer)
|
config.Peers = append(config.Peers, peer)
|
||||||
@@ -45,6 +46,7 @@ func NewYggdrasilTransport(log *log.Logger, sk ed25519.PrivateKey, pk ed25519.Pu
|
|||||||
if err := core.Start(config, glog); err != nil {
|
if err := core.Start(config, glog); err != nil {
|
||||||
return nil, fmt.Errorf("core.Start: %w", err)
|
return nil, fmt.Errorf("core.Start: %w", err)
|
||||||
}
|
}
|
||||||
|
if mcast {
|
||||||
multicast := &multicast.Multicast{}
|
multicast := &multicast.Multicast{}
|
||||||
if err := multicast.Init(core, config, glog, nil); err != nil {
|
if err := multicast.Init(core, config, glog, nil); err != nil {
|
||||||
return nil, fmt.Errorf("multicast.Init: %w", err)
|
return nil, fmt.Errorf("multicast.Init: %w", err)
|
||||||
@@ -52,6 +54,7 @@ func NewYggdrasilTransport(log *log.Logger, sk ed25519.PrivateKey, pk ed25519.Pu
|
|||||||
if err := multicast.Start(); err != nil {
|
if err := multicast.Start(); err != nil {
|
||||||
return nil, fmt.Errorf("multicast.Start: %w", err)
|
return nil, fmt.Errorf("multicast.Start: %w", err)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
us, err := utp.NewSocketFromPacketConnNoClose(core)
|
us, err := utp.NewSocketFromPacketConnNoClose(core)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("utp.NewSocketFromPacketConnNoClose: %w", err)
|
return nil, fmt.Errorf("utp.NewSocketFromPacketConnNoClose: %w", err)
|
||||||
|
|||||||
Reference in New Issue
Block a user