mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-29 06:35:07 +03:00
Refactor multicast setup (isolated config, etc)
This commit is contained in:
parent
dad0b10dfe
commit
493208fb37
10 changed files with 215 additions and 150 deletions
28
src/multicast/options.go
Normal file
28
src/multicast/options.go
Normal file
|
@ -0,0 +1,28 @@
|
|||
package multicast
|
||||
|
||||
import "regexp"
|
||||
|
||||
func (m *Multicast) _applyOption(opt SetupOption) {
|
||||
switch v := opt.(type) {
|
||||
case MulticastInterface:
|
||||
m.config._interfaces[v] = struct{}{}
|
||||
case GroupAddress:
|
||||
m.config._groupAddr = v
|
||||
}
|
||||
}
|
||||
|
||||
type SetupOption interface {
|
||||
isSetupOption()
|
||||
}
|
||||
|
||||
type MulticastInterface struct {
|
||||
Regex *regexp.Regexp
|
||||
Beacon bool
|
||||
Listen bool
|
||||
Port uint16
|
||||
}
|
||||
|
||||
type GroupAddress string
|
||||
|
||||
func (a MulticastInterface) isSetupOption() {}
|
||||
func (a GroupAddress) isSetupOption() {}
|
Loading…
Add table
Add a link
Reference in a new issue