1
0
mirror of https://github.com/netbirdio/netbird.git synced 2025-08-13 08:57:28 +02:00
Files
.devcontainer
.github
base62
client
dns
docs
encryption
formatter
infrastructure_files
management
relay
auth
client
cmd
healthcheck
messages
address
auth
auth.go
doc.go
id.go
id_test.go
message.go
message_test.go
metrics
server
test
testec2
tls
Dockerfile
doc.go
main.go
release_files
route
sharedsock
signal
util
version
.editorconfig
.gitattributes
.gitignore
.golangci.yaml
.goreleaser.yaml
.goreleaser_ui.yaml
.goreleaser_ui_darwin.yaml
AUTHORS
CODE_OF_CONDUCT.md
CONTRIBUTING.md
CONTRIBUTOR_LICENSE_AGREEMENT.md
LICENSE
README.md
SECURITY.md
funding.json
go.mod
go.sum
versioninfo.json
netbird/relay/messages/auth/auth.go
Viktor Liu 2d1bf3982d [relay] Improve relay messages ()
Co-authored-by: Zoltán Papp <zoltan.pmail@gmail.com>
2024-09-11 16:20:30 +02:00

44 lines
710 B
Go

// Deprecated: This package is deprecated and will be removed in a future release.
package auth
import (
"bytes"
"encoding/gob"
"fmt"
)
type Algorithm int
const (
AlgoUnknown Algorithm = iota
AlgoHMACSHA256
AlgoHMACSHA512
)
func (a Algorithm) String() string {
switch a {
case AlgoHMACSHA256:
return "HMAC-SHA256"
case AlgoHMACSHA512:
return "HMAC-SHA512"
default:
return "Unknown"
}
}
type Msg struct {
AuthAlgorithm Algorithm
AdditionalData []byte
}
func UnmarshalMsg(data []byte) (*Msg, error) {
var msg *Msg
buf := bytes.NewBuffer(data)
dec := gob.NewDecoder(buf)
if err := dec.Decode(&msg); err != nil {
return nil, fmt.Errorf("decode Msg: %w", err)
}
return msg, nil
}