-
-
Notifications
You must be signed in to change notification settings - Fork 391
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added reading wireguard secrets from files
* secrets\wireguard.go follows openvpn.go closely in style and is able to set the private key, preshared key as well as the addresses * helpers.go received the readWireguardAddress function from env\wireguard.go to be used from the original file as well as the new secrets\wireguard.go * vpn.go now also calls readWireguard()
- Loading branch information
1 parent
168f621
commit 1246326
Showing
4 changed files
with
63 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package secrets | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/qdm12/gluetun/internal/configuration/settings" | ||
) | ||
|
||
func readWireguard() ( | ||
wireguard settings.Wireguard, err error) { | ||
wireguard.PrivateKey, err = readSecretFileAsStringPtr( | ||
"WIREGUARD_PRIVATE_KEY_SECRETFILE", | ||
"/run/secrets/wireguard_private_key", | ||
) | ||
if err != nil { | ||
return wireguard, fmt.Errorf("cannot read Wireguard private key file: %w", err) | ||
} | ||
|
||
wireguard.PreSharedKey, err = readSecretFileAsStringPtr( | ||
"WIREGUARD_PRESHARED_KEY_SECRETFILE", | ||
"/run/secrets/wireguard_preshared_key", | ||
) | ||
if err != nil { | ||
return wireguard, fmt.Errorf("cannot read Wireguard preshared key file: %w", err) | ||
} | ||
|
||
wireguard.Addresses, err = readWireguardAddresses(readSecretFileAsStringPtr( | ||
"WIREGUARD_ADDRESSES_SECRETFILE", | ||
"/run/secrets/wireguard_addresses", | ||
)) | ||
if err != nil { | ||
return wireguard, fmt.Errorf("cannot read Wireguard addresses file: %w", err) | ||
} | ||
|
||
return wireguard, nil | ||
} |