mirror of
https://github.com/juanfont/headscale.git
synced 2025-11-02 22:17:44 +09:00
Add back privatekey, but automatically generate it if it does not exist
This commit is contained in:
11
utils.go
11
utils.go
@@ -46,6 +46,9 @@ const (
|
||||
// This prefix is used in the control protocol, so cannot be
|
||||
// changed.
|
||||
discoPublicHexPrefix = "discokey:"
|
||||
|
||||
// privateKey prefix.
|
||||
privateHexPrefix = "privkey:"
|
||||
)
|
||||
|
||||
func MachinePublicKeyStripPrefix(machineKey key.MachinePublic) string {
|
||||
@@ -84,6 +87,14 @@ func DiscoPublicKeyEnsurePrefix(discoKey string) string {
|
||||
return discoKey
|
||||
}
|
||||
|
||||
func PrivateKeyEnsurePrefix(privateKey string) string {
|
||||
if !strings.HasPrefix(privateKey, privateHexPrefix) {
|
||||
return privateHexPrefix + privateKey
|
||||
}
|
||||
|
||||
return privateKey
|
||||
}
|
||||
|
||||
// Error is used to compare errors as per https://dave.cheney.net/2016/04/07/constant-errors
|
||||
type Error string
|
||||
|
||||
|
||||
Reference in New Issue
Block a user