Skip to content

Commit

Permalink
Merge pull request #40 from ufm/main
Browse files Browse the repository at this point in the history
The mcastregexp parameter has been added
  • Loading branch information
neilalexander authored Oct 2, 2024
2 parents 1d5545a + 8146bcd commit 0b1d6ca
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ 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/);
* `-multicast` - enable multicast peer discovery for Yggdrasil nodes on your LAN
* `-mcastregexp=".*"` - regexp used in muticast peer discovery for interface name selection.
* `-database=/path/to/yggmail.db` — use a specific database file;
* `-smtp=listenaddr:port` — listen for SMTP on a specific address/port
* `-imap=listenaddr:port` — listen for IMAP on a specific address/port;
Expand Down
4 changes: 3 additions & 1 deletion cmd/yggmail/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func main() {
smtpaddr := flag.String("smtp", "localhost:1025", "SMTP listen address")
imapaddr := flag.String("imap", "localhost:1143", "IMAP listen address")
multicast := flag.Bool("multicast", false, "Connect to Yggdrasil peers on your LAN")
mcastregexp := flag.String("mcastregexp", ".*", "Regexp for multicast")
password := flag.Bool("password", false, "Set a new IMAP/SMTP password")
flag.Var(&peerAddrs, "peer", "Connect to a specific Yggdrasil static peer (this option can be given more than once)")
flag.Parse()
Expand Down Expand Up @@ -135,14 +136,15 @@ func main() {
case (multicast == nil || !*multicast) && len(peerAddrs) == 0:
log.Printf("You must specify either -peer, -multicast or both!")
os.Exit(0)

}

cfg := &config.Config{
PublicKey: pk,
PrivateKey: sk,
}

transport, err := transport.NewYggdrasilTransport(rawlog, sk, pk, peerAddrs, *multicast)
transport, err := transport.NewYggdrasilTransport(rawlog, sk, pk, peerAddrs, *multicast, *mcastregexp)
if err != nil {
panic(err)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/transport/yggdrasil.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ type yggdrasilDial struct {
context.CancelFunc
}

func NewYggdrasilTransport(log *log.Logger, sk ed25519.PrivateKey, pk ed25519.PublicKey, peers []string, mcast bool) (*YggdrasilTransport, error) {
func NewYggdrasilTransport(log *log.Logger, sk ed25519.PrivateKey, pk ed25519.PublicKey, peers []string, mcast bool, mcastregexp string) (*YggdrasilTransport, error) {
yellow := color.New(color.FgYellow).SprintfFunc()
glog := gologme.New(log.Writer(), fmt.Sprintf("[ %s ] ", yellow("Yggdrasil")), gologme.LstdFlags|gologme.Lmsgprefix)
glog.EnableLevel("warn")
Expand Down Expand Up @@ -86,7 +86,7 @@ func NewYggdrasilTransport(log *log.Logger, sk ed25519.PrivateKey, pk ed25519.Pu
{
options := []multicast.SetupOption{
multicast.MulticastInterface{
Regex: regexp.MustCompile(".*"),
Regex: regexp.MustCompile(mcastregexp),
Beacon: mcast,
Listen: mcast,
},
Expand Down

0 comments on commit 0b1d6ca

Please sign in to comment.