Skip to content

Commit 2423fc8

Browse files
committed
fixed defaults for privatekey and configpath
1 parent 041f5bd commit 2423fc8

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

cmd/gateway-agent/main.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,16 @@ func main() {
7373
}
7474

7575
func readPrivateKey() (string, error) {
76-
privateKeyPath := filepath.Join(cfg.TunnelConfigDir, cfg.TunnelInterfaceName+".conf")
77-
b, err := ioutil.ReadFile(privateKeyPath)
76+
b, err := ioutil.ReadFile(cfg.PrivateKey)
7877
return string(b), err
7978
}
8079

8180
func configureWireguard(peers []api.Peer, privateKey string) error {
8281
// transform peers into wg0.conf
83-
wg0conf := generateWGConfig(peers, privateKey)
84-
fmt.Println(string(wg0conf))
85-
ioutil.WriteFile("/etc/wireguard/wg0.conf", wg0conf, 0600)
82+
wgConfigContent := generateWGConfig(peers, privateKey)
83+
fmt.Println(string(wgConfigContent))
84+
wgConfigFilePath := filepath.Join(cfg.TunnelConfigDir, cfg.TunnelInterfaceName+".conf")
85+
ioutil.WriteFile(wgConfigFilePath, wgConfigContent, 0600)
8686

8787
//exec.Command("wg", "syncconf", "wg0", "/etc/wireguard/wg0.conf")
8888

@@ -92,6 +92,7 @@ func configureWireguard(peers []api.Peer, privateKey string) error {
9292
func generateWGConfig(peers []api.Peer, privateKey string) []byte {
9393
wgConfig := "[Interface]\n"
9494
wgConfig += fmt.Sprintf("PrivateKey = %s\n", privateKey)
95+
wgConfig += "ListenPort = 51820\n"
9596
for _, peer := range peers {
9697
wgConfig += "[Peer]\n"
9798
wgConfig += fmt.Sprintf("PublicKey = %s\n", peer.PublicKey)

0 commit comments

Comments
 (0)