mirror of
https://github.com/tailscale/tailscale.git
synced 2025-04-16 03:31:39 +00:00
ipn: add AdvertiseRoutes to Prefs.
This is a prelude to supporting relaynode's --routes in tailscaled. The daemon needs to remembers routes to advertise, and the CLI needs to be able to change the set of advertised routes. Prefs is the thing used for both of these. Signed-off-by: David Anderson <dave@natulte.net>
This commit is contained in:
parent
769e25e37b
commit
a5b84fa921
@ -10,6 +10,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
@ -24,6 +25,7 @@ type Prefs struct {
|
|||||||
WantRunning bool
|
WantRunning bool
|
||||||
NotepadURLs bool
|
NotepadURLs bool
|
||||||
UsePacketFilter bool
|
UsePacketFilter bool
|
||||||
|
AdvertiseRoutes []*net.IPNet
|
||||||
|
|
||||||
// The Persist field is named 'Config' in the file for backward
|
// The Persist field is named 'Config' in the file for backward
|
||||||
// compatibility with earlier versions.
|
// compatibility with earlier versions.
|
||||||
@ -34,7 +36,7 @@ type Prefs struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// IsEmpty reports whether p is nil or pointing to a Prefs zero value.
|
// IsEmpty reports whether p is nil or pointing to a Prefs zero value.
|
||||||
func (uc *Prefs) IsEmpty() bool { return uc == nil || *uc == Prefs{} }
|
func (uc *Prefs) IsEmpty() bool { return uc == nil || uc.Equals(&Prefs{}) }
|
||||||
|
|
||||||
func (uc *Prefs) Pretty() string {
|
func (uc *Prefs) Pretty() string {
|
||||||
var ucp string
|
var ucp string
|
||||||
@ -43,9 +45,9 @@ func (uc *Prefs) Pretty() string {
|
|||||||
} else {
|
} else {
|
||||||
ucp = "Persist=nil"
|
ucp = "Persist=nil"
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("Prefs{ra=%v mesh=%v dns=%v want=%v notepad=%v pf=%v %v}",
|
return fmt.Sprintf("Prefs{ra=%v mesh=%v dns=%v want=%v notepad=%v pf=%v routes=%v %v}",
|
||||||
uc.RouteAll, uc.AllowSingleHosts, uc.CorpDNS, uc.WantRunning,
|
uc.RouteAll, uc.AllowSingleHosts, uc.CorpDNS, uc.WantRunning,
|
||||||
uc.NotepadURLs, uc.UsePacketFilter, ucp)
|
uc.NotepadURLs, uc.UsePacketFilter, uc.AdvertiseRoutes, ucp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (uc *Prefs) ToBytes() []byte {
|
func (uc *Prefs) ToBytes() []byte {
|
||||||
|
@ -29,7 +29,7 @@ func checkPrefs(t *testing.T, p Prefs) {
|
|||||||
}
|
}
|
||||||
p2 = p
|
p2 = p
|
||||||
p2.RouteAll = true
|
p2.RouteAll = true
|
||||||
if p == p2 {
|
if p.Equals(&p2) {
|
||||||
t.Fatalf("p == p2\n")
|
t.Fatalf("p == p2\n")
|
||||||
}
|
}
|
||||||
p2b, err = PrefsFromBytes(p2.ToBytes(), false)
|
p2b, err = PrefsFromBytes(p2.ToBytes(), false)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user