2022-09-03 11:42:05 +01:00
|
|
|
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
|
2023-05-21 15:24:31 +01:00
|
|
|
case Discriminator:
|
|
|
|
m.config._discriminator = append(m.config._discriminator[:0], v...)
|
|
|
|
case DiscriminatorMatch:
|
|
|
|
m.config._discriminatorMatch = v
|
2022-09-03 11:42:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type SetupOption interface {
|
|
|
|
isSetupOption()
|
|
|
|
}
|
|
|
|
|
|
|
|
type MulticastInterface struct {
|
2022-10-26 18:25:48 +01:00
|
|
|
Regex *regexp.Regexp
|
|
|
|
Beacon bool
|
|
|
|
Listen bool
|
|
|
|
Port uint16
|
|
|
|
Priority uint8
|
2022-09-03 11:42:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
type GroupAddress string
|
2023-05-21 15:24:31 +01:00
|
|
|
type Discriminator []byte
|
|
|
|
type DiscriminatorMatch func([]byte) bool
|
2022-09-03 11:42:05 +01:00
|
|
|
|
|
|
|
func (a MulticastInterface) isSetupOption() {}
|
|
|
|
func (a GroupAddress) isSetupOption() {}
|
2023-05-21 15:24:31 +01:00
|
|
|
func (a Discriminator) isSetupOption() {}
|
|
|
|
func (a DiscriminatorMatch) isSetupOption() {}
|