mirror of
https://github.com/postmannen/ctrl.git
synced 2025-03-15 10:57:42 +00:00
added struct types for signatures and keys
This commit is contained in:
parent
52fff1a225
commit
e8b1064161
1 changed files with 37 additions and 6 deletions
|
@ -17,9 +17,11 @@ type signature string
|
||||||
// the signatures map. It holds a mutex to use when interacting with
|
// the signatures map. It holds a mutex to use when interacting with
|
||||||
// the map.
|
// the map.
|
||||||
type signatures struct {
|
type signatures struct {
|
||||||
// allowed is a map for holding all the allowed signatures.
|
// All the allowed signatures a node is allowed to recive from.
|
||||||
allowed map[signature]struct{}
|
allowedSignatures *allowedSignatures
|
||||||
mu sync.Mutex
|
|
||||||
|
// All the public keys for nodes a node is allowed to receive from.
|
||||||
|
publicKeys *publicKeys
|
||||||
|
|
||||||
// Full path to the signing keys folder
|
// Full path to the signing keys folder
|
||||||
SignKeyFolder string
|
SignKeyFolder string
|
||||||
|
@ -40,9 +42,10 @@ type signatures struct {
|
||||||
|
|
||||||
func newSignatures(configuration *Configuration, errorKernel *errorKernel) *signatures {
|
func newSignatures(configuration *Configuration, errorKernel *errorKernel) *signatures {
|
||||||
s := signatures{
|
s := signatures{
|
||||||
allowed: make(map[signature]struct{}),
|
allowedSignatures: newAllowedSignatures(),
|
||||||
configuration: configuration,
|
publicKeys: newPublicKeys(),
|
||||||
errorKernel: errorKernel,
|
configuration: configuration,
|
||||||
|
errorKernel: errorKernel,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the signing key paths.
|
// Set the signing key paths.
|
||||||
|
@ -59,6 +62,34 @@ func newSignatures(configuration *Configuration, errorKernel *errorKernel) *sign
|
||||||
return &s
|
return &s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type allowedSignatures struct {
|
||||||
|
// allowed is a map for holding all the allowed signatures.
|
||||||
|
allowed map[signature]Node
|
||||||
|
mu sync.Mutex
|
||||||
|
}
|
||||||
|
|
||||||
|
func newAllowedSignatures() *allowedSignatures {
|
||||||
|
a := allowedSignatures{
|
||||||
|
allowed: make(map[signature]Node),
|
||||||
|
}
|
||||||
|
|
||||||
|
return &a
|
||||||
|
}
|
||||||
|
|
||||||
|
type publicKeys struct {
|
||||||
|
// nodesKey is a map who holds all the public keys for nodes.
|
||||||
|
nodeKeys map[Node][]byte
|
||||||
|
mu sync.Mutex
|
||||||
|
}
|
||||||
|
|
||||||
|
func newPublicKeys() *publicKeys {
|
||||||
|
p := publicKeys{
|
||||||
|
nodeKeys: make(map[Node][]byte),
|
||||||
|
}
|
||||||
|
|
||||||
|
return &p
|
||||||
|
}
|
||||||
|
|
||||||
// loadSigningKeys will try to load the ed25519 signing keys. If the
|
// loadSigningKeys will try to load the ed25519 signing keys. If the
|
||||||
// files are not found new keys will be generated and written to disk.
|
// files are not found new keys will be generated and written to disk.
|
||||||
func (s *signatures) loadSigningKeys() error {
|
func (s *signatures) loadSigningKeys() error {
|
||||||
|
|
Loading…
Add table
Reference in a new issue