@@ -73,16 +73,16 @@ func main() {
73
73
}
74
74
75
75
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 )
78
77
return string (b ), err
79
78
}
80
79
81
80
func configureWireguard (peers []api.Peer , privateKey string ) error {
82
81
// 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 )
86
86
87
87
//exec.Command("wg", "syncconf", "wg0", "/etc/wireguard/wg0.conf")
88
88
@@ -92,6 +92,7 @@ func configureWireguard(peers []api.Peer, privateKey string) error {
92
92
func generateWGConfig (peers []api.Peer , privateKey string ) []byte {
93
93
wgConfig := "[Interface]\n "
94
94
wgConfig += fmt .Sprintf ("PrivateKey = %s\n " , privateKey )
95
+ wgConfig += "ListenPort = 51820\n "
95
96
for _ , peer := range peers {
96
97
wgConfig += "[Peer]\n "
97
98
wgConfig += fmt .Sprintf ("PublicKey = %s\n " , peer .PublicKey )
0 commit comments