mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-11-29 13:11:36 +00:00
Add LinkLocalTCPPort option
This commit is contained in:
parent
07822a74c7
commit
9d5ca85424
@ -34,6 +34,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|||||||
- Yggdrasil will now attempt to clean up UNIX admin sockets on startup if left behind by a previous crash
|
- Yggdrasil will now attempt to clean up UNIX admin sockets on startup if left behind by a previous crash
|
||||||
- Admin socket `getTunnelRouting` and `setTunnelRouting` calls for enabling and disabling crypto-key routing during runtime
|
- Admin socket `getTunnelRouting` and `setTunnelRouting` calls for enabling and disabling crypto-key routing during runtime
|
||||||
- On macOS, Yggdrasil will now try to wake up AWDL on start-up when `awdl0` is a configured multicast interface, to keep it awake after system sleep, and to stop waking it when no longer needed
|
- On macOS, Yggdrasil will now try to wake up AWDL on start-up when `awdl0` is a configured multicast interface, to keep it awake after system sleep, and to stop waking it when no longer needed
|
||||||
|
- Added `LinkLocalTCPPort` option for controlling the port number that link-local TCP listeners will listen on by default when setting up `MulticastInterfaces`
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- The `Listen` configuration statement is now an array instead of a string
|
- The `Listen` configuration statement is now an array instead of a string
|
||||||
|
@ -22,6 +22,7 @@ type NodeConfig struct {
|
|||||||
SigningPublicKey string `comment:"Your public signing key. You should not ordinarily need to share\nthis with anyone."`
|
SigningPublicKey string `comment:"Your public signing key. You should not ordinarily need to share\nthis with anyone."`
|
||||||
SigningPrivateKey string `comment:"Your private signing key. DO NOT share this with anyone!"`
|
SigningPrivateKey string `comment:"Your private signing key. DO NOT share this with anyone!"`
|
||||||
MulticastInterfaces []string `comment:"Regular expressions for which interfaces multicast peer discovery\nshould be enabled on. If none specified, multicast peer discovery is\ndisabled. The default value is .* which uses all interfaces."`
|
MulticastInterfaces []string `comment:"Regular expressions for which interfaces multicast peer discovery\nshould be enabled on. If none specified, multicast peer discovery is\ndisabled. The default value is .* which uses all interfaces."`
|
||||||
|
LinkLocalTCPPort uint16 `comment:"The port number to be used for the link-local TCP listeners for the\nconfigured MulticastInterfaces. This option does not affect listeners\nspecified in the Listen option. Unless you plan to firewall link-local\ntraffic, it is best to leave this as the default value of 0."`
|
||||||
IfName string `comment:"Local network interface name for TUN/TAP adapter, or \"auto\" to select\nan interface automatically, or \"none\" to run without TUN/TAP."`
|
IfName string `comment:"Local network interface name for TUN/TAP adapter, or \"auto\" to select\nan interface automatically, or \"none\" to run without TUN/TAP."`
|
||||||
IfTAPMode bool `comment:"Set local network interface to TAP mode rather than TUN mode if\nsupported by your platform - option will be ignored if not."`
|
IfTAPMode bool `comment:"Set local network interface to TAP mode rather than TUN mode if\nsupported by your platform - option will be ignored if not."`
|
||||||
IfMTU int `comment:"Maximux Transmission Unit (MTU) size for your local TUN/TAP interface.\nDefault is the largest supported size for your platform. The lowest\npossible value is 1280."`
|
IfMTU int `comment:"Maximux Transmission Unit (MTU) size for your local TUN/TAP interface.\nDefault is the largest supported size for your platform. The lowest\npossible value is 1280."`
|
||||||
|
@ -16,12 +16,16 @@ type multicast struct {
|
|||||||
sock *ipv6.PacketConn
|
sock *ipv6.PacketConn
|
||||||
groupAddr string
|
groupAddr string
|
||||||
listeners map[string]*tcpListener
|
listeners map[string]*tcpListener
|
||||||
|
listenPort uint16
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *multicast) init(core *Core) {
|
func (m *multicast) init(core *Core) {
|
||||||
m.core = core
|
m.core = core
|
||||||
m.reconfigure = make(chan chan error, 1)
|
m.reconfigure = make(chan chan error, 1)
|
||||||
m.listeners = make(map[string]*tcpListener)
|
m.listeners = make(map[string]*tcpListener)
|
||||||
|
m.core.configMutex.RLock()
|
||||||
|
m.listenPort = m.core.config.LinkLocalTCPPort
|
||||||
|
m.core.configMutex.RUnlock()
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
e := <-m.reconfigure
|
e := <-m.reconfigure
|
||||||
@ -148,12 +152,14 @@ func (m *multicast) announce() {
|
|||||||
var listener *tcpListener
|
var listener *tcpListener
|
||||||
if l, ok := m.listeners[iface.Name]; !ok || l.listener == nil {
|
if l, ok := m.listeners[iface.Name]; !ok || l.listener == nil {
|
||||||
// No listener was found - let's create one
|
// No listener was found - let's create one
|
||||||
listenaddr := fmt.Sprintf("[%s%%%s]:0", addrIP, iface.Name)
|
listenaddr := fmt.Sprintf("[%s%%%s]:%d", addrIP, iface.Name, m.listenPort)
|
||||||
if li, err := m.core.link.tcp.listen(listenaddr); err == nil {
|
if li, err := m.core.link.tcp.listen(listenaddr); err == nil {
|
||||||
m.core.log.Debugln("Started multicasting on", iface.Name)
|
m.core.log.Debugln("Started multicasting on", iface.Name)
|
||||||
// Store the listener so that we can stop it later if needed
|
// Store the listener so that we can stop it later if needed
|
||||||
m.listeners[iface.Name] = li
|
m.listeners[iface.Name] = li
|
||||||
listener = li
|
listener = li
|
||||||
|
} else {
|
||||||
|
m.core.log.Warnln("Not multicasting on", iface.Name, "due to error:", err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// An existing listener was found
|
// An existing listener was found
|
||||||
|
Loading…
Reference in New Issue
Block a user