mirror of
https://github.com/slackhq/nebula.git
synced 2026-11-15 19:46:52 +01:00
lighthouse: Recompute relays for me when relay.am_relay changes (#1917)
This commit is contained in:
1 parent
5f26c1a7e5
commit
94be454f4f
2 files changed
+23
-1
No files matched your search
+2
-1
@@ -359,7 +359,8 @@ func (lh *LightHouse) reload(c *config.C, initial bool) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if initial || c.HasChanged("relay.relays") {
|
// am_relay decides whether relay.relays applies to us at all
|
||||||
|
if initial || c.HasChanged("relay.relays") || c.HasChanged("relay.am_relay") {
|
||||||
var before []netip.Addr
|
var before []netip.Addr
|
||||||
if !initial {
|
if !initial {
|
||||||
before = lh.GetRelaysForMe()
|
before = lh.GetRelaysForMe()
|
||||||
|
|||||||
@@ -976,3 +976,24 @@ func TestLighthouse_reloadRelaysTriggersUpdate(t *testing.T) {
|
|||||||
assert.Equal(t, []netip.Addr{netip.MustParseAddr("10.128.0.6")}, lh.GetRelaysForMe())
|
assert.Equal(t, []netip.Addr{netip.MustParseAddr("10.128.0.6")}, lh.GetRelaysForMe())
|
||||||
assert.Empty(t, lh.updateTrigger)
|
assert.Empty(t, lh.updateTrigger)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestLighthouse_reloadAmRelayAlone(t *testing.T) {
|
||||||
|
l := test.NewLogger()
|
||||||
|
c := config.NewC(l)
|
||||||
|
base := "lighthouse:\n am_lighthouse: true\nlisten:\n port: 4242\nrelay:\n relays: [10.128.0.5]\n"
|
||||||
|
require.NoError(t, c.LoadString(base+" am_relay: false\n"))
|
||||||
|
|
||||||
|
lh, err := NewLightHouseFromConfig(t.Context(), l, c, testCertState(netip.MustParsePrefix("10.128.0.1/24")), nil, nil)
|
||||||
|
require.NoError(t, err)
|
||||||
|
assert.Equal(t, []netip.Addr{netip.MustParseAddr("10.128.0.5")}, lh.GetRelaysForMe())
|
||||||
|
|
||||||
|
// Relays aren't allowed to have relays, flipping am_relay alone must drop them and tell the lighthouses
|
||||||
|
require.NoError(t, c.ReloadConfigString(base+" am_relay: true\n"))
|
||||||
|
assert.Empty(t, lh.GetRelaysForMe())
|
||||||
|
require.Len(t, lh.updateTrigger, 1)
|
||||||
|
<-lh.updateTrigger
|
||||||
|
|
||||||
|
require.NoError(t, c.ReloadConfigString(base+" am_relay: false\n"))
|
||||||
|
assert.Equal(t, []netip.Addr{netip.MustParseAddr("10.128.0.5")}, lh.GetRelaysForMe())
|
||||||
|
require.Len(t, lh.updateTrigger, 1)
|
||||||
|
}
|
||||||
Reference in new issue
Block a user