mirror of
https://github.com/juanfont/headscale.git
synced 2024-12-24 16:58:05 +00:00
Make private key errors constants
This commit is contained in:
parent
3e8f0e9984
commit
014e7abc68
10
app.go
10
app.go
@ -51,6 +51,10 @@ const (
|
|||||||
errUnsupportedLetsEncryptChallengeType = Error(
|
errUnsupportedLetsEncryptChallengeType = Error(
|
||||||
"unknown value for Lets Encrypt challenge type",
|
"unknown value for Lets Encrypt challenge type",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
ErrFailedPrivateKey = Error("failed to read or create private key")
|
||||||
|
ErrFailedNoisePrivateKey = Error("failed to read or create Noise protocol private key")
|
||||||
|
ErrSamePrivateKeys = Error("private key and noise private key are the same")
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -123,16 +127,16 @@ func LookupTLSClientAuthMode(mode string) (tls.ClientAuthType, bool) {
|
|||||||
func NewHeadscale(cfg *Config) (*Headscale, error) {
|
func NewHeadscale(cfg *Config) (*Headscale, error) {
|
||||||
privateKey, err := readOrCreatePrivateKey(cfg.PrivateKeyPath)
|
privateKey, err := readOrCreatePrivateKey(cfg.PrivateKeyPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to read or create private key: %w", err)
|
return nil, ErrFailedPrivateKey
|
||||||
}
|
}
|
||||||
|
|
||||||
noisePrivateKey, err := readOrCreatePrivateKey(cfg.NoisePrivateKeyPath)
|
noisePrivateKey, err := readOrCreatePrivateKey(cfg.NoisePrivateKeyPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to read or create noise private key: %w", err)
|
return nil, ErrFailedNoisePrivateKey
|
||||||
}
|
}
|
||||||
|
|
||||||
if privateKey.Equal(*noisePrivateKey) {
|
if privateKey.Equal(*noisePrivateKey) {
|
||||||
return nil, fmt.Errorf("private key and noise private key are the same")
|
return nil, ErrSamePrivateKeys
|
||||||
}
|
}
|
||||||
|
|
||||||
var dbString string
|
var dbString string
|
||||||
|
Loading…
x
Reference in New Issue
Block a user