MCPcopy Create free account
hub / github.com/tailscale/tailscale / loadConfig

Function loadConfig

cmd/derper/derper.go:115–141  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

113}
114
115func loadConfig() config {
116 if *dev {
117 return config{PrivateKey: key.NewNode()}
118 }
119 if *configPath == "" {
120 if os.Getuid() == 0 {
121 *configPath = "/var/lib/derper/derper.key"
122 } else {
123 log.Fatalf("derper: -c <config path> not specified")
124 }
125 log.Printf("no config path specified; using %s", *configPath)
126 }
127 b, err := os.ReadFile(*configPath)
128 switch {
129 case errors.Is(err, os.ErrNotExist):
130 return writeNewConfig()
131 case err != nil:
132 log.Fatal(err)
133 panic("unreachable")
134 default:
135 var cfg config
136 if err := json.Unmarshal(b, &cfg); err != nil {
137 log.Fatalf("derper: config: %v", err)
138 }
139 return cfg
140 }
141}
142
143func writeNewConfig() config {
144 k := key.NewNode()

Callers 1

mainFunction · 0.85

Calls 7

NewNodeFunction · 0.92
writeNewConfigFunction · 0.85
PrintfMethod · 0.80
FatalfMethod · 0.65
ReadFileMethod · 0.65
FatalMethod · 0.65
IsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…