Skip to content
Snippets Groups Projects
config.go 3.25 KiB
Newer Older
  • Learn to ignore specific revisions
  • package config
    
    import "github.com/google/uuid"
    
    
    const (
    	DefaultGRPCTimeoutInSeconds = 10
    )
    
    
    type Config struct {
    
    	Id                   string             `yaml:"Id"`
    	Name                 string             `yaml:"Name"`
    	InterComAddr         string             `yaml:"InterComAddr"`
    	QuantumAddr          string             `yaml:"QuantumAddr"`
    	AkmsURL              string             `yaml:"AkmsURL"`
    	AkmsCkmsServerPort   string             `yaml:"AkmsCkmsServerPort"`
    	GnmiBindAddress      string             `yaml:"GnmiBindAddress"`
    
    	KmsTLS               TLSConfig          `yaml:"KmsTLS"`
    
    	Peers                []Peer             `yaml:"Peers"`
    	GnmiTLS              TLSConfig          `yaml:"GnmiTLS"`
    	AkmsCkmsTLS          TLSConfig          `yaml:"AkmsCkmsTLS"`
    	ETSI14Server         *ETSI14Server      `yaml:"ETSI14Server,omitempty"`
    	QkdnManagerServer    *QkdnManagerServer `yaml:"QkdnManagerServer,omitempty"`
    	GRPCTimeoutInSeconds int                `yaml:"GRPCTimeoutInSeconds"`
    
    Fabian Seidl's avatar
    Fabian Seidl committed
    }
    
    type Peer struct {
    	PeerId           string        `yaml:"PeerId"`
    	PeerInterComAddr string        `yaml:"PeerInterComAddr"`
    	Type             string        `yaml:"Type"`
    	QuantumModule    QuantumModule `yaml:"QuantumModule"`
    
    	Active             bool   `yaml:"Active"`
    	InsecureSkipVerify bool   `yaml:"InsecureSkipVerify"`
    	CAFile             string `yaml:"CAFile"`
    	CertFile           string `yaml:"CertFile"`
    	KeyFile            string `yaml:"KeyFile"`
    
    }
    
    type QuantumModule struct {
    
    	QmType           string    `yaml:"Type"`
    	TLS              TLSConfig `yaml:"TLS"`
    	Address          string    `yaml:"Address"`
    	Hostname         string    `yaml:"Hostname"`
    	LocalSAEID       string    `yaml:"LocalSAEID"`
    	TargetSAEID      string    `yaml:"TargetSAEID"`
    	MasterMode       bool      `yaml:"MasterMode"`
    	KeyFetchInterval int       `yaml:"KeyFetchInterval"`
    	KeyFetchAmount   int       `yaml:"KeyFetchAmount"`
    	MaxKeyFillLevel  int       `yaml:"MaxKeyFillLevel"`
    
    type ETSI14Server struct {
    	Address      string `yaml:"Address"`
    	RemoteCKMSID string `yaml:"RemoteCKMSID"`
    }
    
    
    type QkdnManagerServer struct {
    	Address string `yaml:"Address"`
    }
    
    
    func NewKMSInfo(id uuid.UUID, version *kmsVersionInformation, channel chan string) *KMSInfo {
    	return &KMSInfo{
    
    		id:                   id,
    		version:              version,
    		KmsPeerUpdateChannel: channel,
    	}
    }
    
    
    type KMSInfo struct {
    
    	// Information used to fill the ETSI GS QKD 15 yang model
    	id                   uuid.UUID
    
    	version              *kmsVersionInformation
    
    	KmsPeerUpdateChannel chan string // used to get updates from KmsPeer part
    }
    
    
    func NewKMSVersionInformation(firmware string, swVersion string, hwVersion string) *kmsVersionInformation {
    	return &kmsVersionInformation{
    
    		firmware:  firmware,
    		swVersion: swVersion,
    		hwVersion: hwVersion,
    	}
    }
    
    
    type kmsVersionInformation struct {
    
    	firmware  string
    	swVersion string
    	hwVersion string
    }
    
    
    func (kvi *kmsVersionInformation) Firmware() string {
    	return kvi.firmware
    
    func (kvi *kmsVersionInformation) SoftwareVersion() string {
    	return kvi.swVersion
    
    func (kvi *kmsVersionInformation) HardwareVersion() string {
    	return kvi.hwVersion
    
    func (qkdnInfo *KMSInfo) Version() *kmsVersionInformation {
    
    	return qkdnInfo.version
    }
    
    
    func (qkdnInfo *KMSInfo) ID() uuid.UUID {
    
    	return qkdnInfo.id
    }