mirror of
https://github.com/neilalexander/yggmail.git
synced 2026-05-07 04:16:28 +03:00
Add broadcast regexp parameter
This commit is contained in:
@@ -55,6 +55,7 @@ func main() {
|
|||||||
smtpaddr := flag.String("smtp", "localhost:1025", "SMTP listen address")
|
smtpaddr := flag.String("smtp", "localhost:1025", "SMTP listen address")
|
||||||
imapaddr := flag.String("imap", "localhost:1143", "IMAP listen address")
|
imapaddr := flag.String("imap", "localhost:1143", "IMAP listen address")
|
||||||
multicast := flag.Bool("multicast", false, "Connect to Yggdrasil peers on your LAN")
|
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")
|
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.Var(&peerAddrs, "peer", "Connect to a specific Yggdrasil static peer (this option can be given more than once)")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
@@ -135,6 +136,7 @@ func main() {
|
|||||||
case (multicast == nil || !*multicast) && len(peerAddrs) == 0:
|
case (multicast == nil || !*multicast) && len(peerAddrs) == 0:
|
||||||
log.Printf("You must specify either -peer, -multicast or both!")
|
log.Printf("You must specify either -peer, -multicast or both!")
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg := &config.Config{
|
cfg := &config.Config{
|
||||||
@@ -142,7 +144,7 @@ func main() {
|
|||||||
PrivateKey: sk,
|
PrivateKey: sk,
|
||||||
}
|
}
|
||||||
|
|
||||||
transport, err := transport.NewYggdrasilTransport(rawlog, sk, pk, peerAddrs, *multicast)
|
transport, err := transport.NewYggdrasilTransport(rawlog, sk, pk, peerAddrs, *multicast, *mcastregexp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ type yggdrasilDial struct {
|
|||||||
context.CancelFunc
|
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()
|
yellow := color.New(color.FgYellow).SprintfFunc()
|
||||||
glog := gologme.New(log.Writer(), fmt.Sprintf("[ %s ] ", yellow("Yggdrasil")), gologme.LstdFlags|gologme.Lmsgprefix)
|
glog := gologme.New(log.Writer(), fmt.Sprintf("[ %s ] ", yellow("Yggdrasil")), gologme.LstdFlags|gologme.Lmsgprefix)
|
||||||
glog.EnableLevel("warn")
|
glog.EnableLevel("warn")
|
||||||
@@ -86,7 +86,7 @@ func NewYggdrasilTransport(log *log.Logger, sk ed25519.PrivateKey, pk ed25519.Pu
|
|||||||
{
|
{
|
||||||
options := []multicast.SetupOption{
|
options := []multicast.SetupOption{
|
||||||
multicast.MulticastInterface{
|
multicast.MulticastInterface{
|
||||||
Regex: regexp.MustCompile(".*"),
|
Regex: regexp.MustCompile(mcastregexp),
|
||||||
Beacon: mcast,
|
Beacon: mcast,
|
||||||
Listen: mcast,
|
Listen: mcast,
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user