Documentation ¶
Index ¶
- Constants
- func AddNodeClient(conn *grpc.ClientConn) error
- func GRPCDialerMaster() (*grpc.ClientConn, error)
- func GRPCDialerNode(nodeID, nodeType string) error
- func HostConfigToModel(hc *HostConfigInput) (*HostConfigModel, *MasterConfigModel, error)
- func HostConfigToNodeConfig(hcM *HostConfigModel) *pb.NodeConfig
- func InitNodeConfigDB(s Store)
- func UpdateNodeConfigClient() (*pb.AllNodeConfig, error)
- type BadgerDB
- func (badgerDB BadgerDB) AddHostConfigEntry(id string, inModel *HostConfigModel) error
- func (badgerDB BadgerDB) AddMasterConfigEntry(entry *MasterConfigModel) error
- func (badgerDB BadgerDB) AddNodeConfigEntry(id string, entry *pb.NodeConfig) error
- func (badgerDB BadgerDB) CloseDB() error
- func (badgerDB BadgerDB) GetAllNodeConfigEntries(prefix string) ([]*pb.NodeConfig, error)
- func (badgerDB BadgerDB) GetHostConfigEntry(id string) (*HostConfigModel, error)
- func (badgerDB BadgerDB) GetMasterConfigEntry() (*MasterConfigModel, error)
- func (badgerDB BadgerDB) GetNodeConfigEntry(id string) (*pb.NodeConfig, error)
- type ConfigInput
- type DataStore
- type GRPCAuth
- type GRPCAuthModel
- type HostConfigInput
- type HostConfigModel
- type Input
- type MasterConfigInput
- type MasterConfigModel
- type SFTPAuth
- type SFTPAuthModel
- type Server
- func (ncs *Server) AddNode(ctx context.Context, req *pb.NodeConfig) (*pb.AllNodeConfig, error)
- func (ncs *Server) AddNodeConfig(ctx context.Context, in *pb.NodeConfig) (*pb.AddNodeConfigResponse, error)
- func (ncs *Server) GetNodeConfigByID(ctx context.Context, in *pb.GetNodeRequest) (*pb.NodeConfig, error)
- func (ncs *Server) ListNodeConfig(ctx context.Context, in *pb.NodeConfigRequest) (*pb.AllNodeConfig, error)
- func (ncs *Server) UpdateAllNodeConfig(ctx context.Context, in *pb.NodeConfigRequest) (*pb.AllNodeConfig, error)
- type Store
Constants ¶
const DBSeparator = "|"
DBSeparator is pipe
const HostConfigKey = "hostconfig"
HostConfigKey is the key name for the hostconfig in the DB
const NodeConfigPrefixKey = "nodeconfig"
NodeConfigPrefixKey is the prefix for storing all the nodeconfigs in db
Variables ¶
This section is empty.
Functions ¶
func AddNodeClient ¶
func AddNodeClient(conn *grpc.ClientConn) error
AddNodeClient send the calling nodes config to the server and gets all the config from the server
func GRPCDialerMaster ¶
func GRPCDialerMaster() (*grpc.ClientConn, error)
GRPCDialerMaster returns a grpc connection to the master
func GRPCDialerNode ¶
GRPCDialerNode returns a grpc connection to the nodeid and type specified
func HostConfigToModel ¶
func HostConfigToModel(hc *HostConfigInput) (*HostConfigModel, *MasterConfigModel, error)
HostConfigToModel converts HostConfigInput to the Model
func HostConfigToNodeConfig ¶
func HostConfigToNodeConfig(hcM *HostConfigModel) *pb.NodeConfig
HostConfigToNodeConfig takes a HostConfig and returns a NodeConfig
func InitNodeConfigDB ¶
func InitNodeConfigDB(s Store)
InitNodeConfigDB initializes the NodeConfigDB
func UpdateNodeConfigClient ¶
func UpdateNodeConfigClient() (*pb.AllNodeConfig, error)
UpdateNodeConfigClient gets the list of nodeconfigs from the master and updates the db
Types ¶
type BadgerDB ¶
type BadgerDB struct {
NodeConfigDB *badger.DB
}
BadgerDB is the DB instance for BadgerDB
func (BadgerDB) AddHostConfigEntry ¶
func (badgerDB BadgerDB) AddHostConfigEntry(id string, inModel *HostConfigModel) error
AddHostConfigEntry adds the HostConfigModel to DB
func (BadgerDB) AddMasterConfigEntry ¶
func (badgerDB BadgerDB) AddMasterConfigEntry(entry *MasterConfigModel) error
AddMasterConfigEntry adds a single nodeconfig entry to badgerDB
func (BadgerDB) AddNodeConfigEntry ¶
func (badgerDB BadgerDB) AddNodeConfigEntry(id string, entry *pb.NodeConfig) error
AddNodeConfigEntry adds a single nodeconfig entry to badgerDB
func (BadgerDB) GetAllNodeConfigEntries ¶
func (badgerDB BadgerDB) GetAllNodeConfigEntries(prefix string) ([]*pb.NodeConfig, error)
GetAllNodeConfigEntries returns all the NodeConfig entrys for the prefix
func (BadgerDB) GetHostConfigEntry ¶
func (badgerDB BadgerDB) GetHostConfigEntry(id string) (*HostConfigModel, error)
GetHostConfigEntry gets HostConfigModel by id Returns entry and error
func (BadgerDB) GetMasterConfigEntry ¶
func (badgerDB BadgerDB) GetMasterConfigEntry() (*MasterConfigModel, error)
GetMasterConfigEntry returns a masterconfig entry
func (BadgerDB) GetNodeConfigEntry ¶
func (badgerDB BadgerDB) GetNodeConfigEntry(id string) (*pb.NodeConfig, error)
GetNodeConfigEntry returns a nodeconfig entry for the key
type ConfigInput ¶
type ConfigInput struct { HostConfig *HostConfigInput `json:"host_config,omitempty"` MasterConfig *MasterConfigInput `json:"master_config,omitempty"` }
ConfigInput is the main struct for all configuration
func ConfigFromYAML ¶
func ConfigFromYAML(inputYaml io.Reader) (*ConfigInput, error)
ConfigFromYAML returns a Config from yaml
func ConfigFromYAMLFile ¶
func ConfigFromYAMLFile(filename string) (*ConfigInput, error)
ConfigFromYAMLFile returns a ConfigInput from a Yaml File
func (*ConfigInput) GetInputFromConfig ¶
func (ci *ConfigInput) GetInputFromConfig(filename string) error
GetInputFromConfig retrieves the config from a config file
type DataStore ¶
type DataStore struct {
NodeConfig Store
}
DataStore is the struct containing the NodeConfigStore interface
var Data DataStore
Data is the instance of DataStore
type GRPCAuth ¶
type GRPCAuth struct { TLSCertFile string `json:"tls_cert_file,omitempty"` TLSCertData string `json:"tls_cert_data,omitempty"` TLSCertBinData []byte `json:"tls_cert_bin_data,omitempty"` TLSKeyFile string `json:"tls_key_file,omitempty"` TLSKeyData string `json:"tls_key_data,omitempty"` TLSKeyBinData []byte `json:"tls_key_bin_data,omitempty"` Token string `json:"token,omitempty"` }
GRPCAuth is sub config for GRPC Auth details
type GRPCAuthModel ¶
type GRPCAuthModel struct { TLSCertFile string TLSCertData string TLSCertBinData []byte TLSKeyFile string TLSKeyData string TLSKeyBinData []byte Token string }
GRPCAuthModel is sub config for GRPC Auth details
type HostConfigInput ¶
type HostConfigInput struct { NodeID string `json:"node_id"` // NodeID is unique identifier for a styxnode NodeType string `json:"node_type,omitempty"` // NodeType indicates if it's a internal/external node IPAddress string `json:"ip_address,omitempty"` GRPCPort int `json:"grpc_port,omitempty"` SFTPPort int `json:"sftp_port,omitempty"` SZ string `json:"sz,omitempty"` // SZ indicates the security zone, eg: dmz or control plane GRPCAuth GRPCAuth `json:"grpc_auth,omitempty"` SFTPAuth SFTPAuth `json:"sftp_auth,omitempty"` ExternalAccess bool `json:"external_access,omitempty"` // ExternalAccess indicates the styxnode is allowed to send files outside, eg: external sftp server //Overwrite bool `json:"overwrite"` EncryptionKey string `json:"encryption_key"` MasterConfig MasterConfigInput `json:"master_config,omitempty"` }
HostConfigInput holds the yaml configuration of the styxnode from user input/config file this includes data the other styxnodes do not require for peer to peer communication
func HostConfigFromYAML ¶
func HostConfigFromYAML(inputYaml io.Reader) (*HostConfigInput, error)
HostConfigFromYAML returns a HostConfig from yaml
func HostConfigFromYAMLFile ¶
func HostConfigFromYAMLFile(filename string) (*HostConfigInput, error)
HostConfigFromYAMLFile returns a HostConfigInput from a Yaml File
type HostConfigModel ¶
type HostConfigModel struct { NodeID string // NodeID is unique identifier for a styxnode NodeType string // NodeType indicates if it's a internal/external node IPAddress string GRPCPort int SFTPPort int SZ string // SZ indicates the security zone, eg: dmz or control plane GRPCAuth *GRPCAuthModel SFTPAuth *SFTPAuthModel ExternalAccess bool // ExternalAccess indicates the styxnode is allowed to send files outside, eg: external sftp server GRPCAddress string SFTPAddress string }
HostConfigModel holds the configuration of the styxnode as stored in the db this includes data the other styxnodes do not require for peer to peer communication
type Input ¶
type Input interface {
GetInputFromConfig(string)
}
Input is an interface for Config/Cli Input
type MasterConfigInput ¶
type MasterConfigInput struct { Master bool `json:master,omitempty` MasterIP string `json:"master_ip,omitempty"` MasterPort int `json:"master_port,omitempty"` }
MasterConfigInput is the
type MasterConfigModel ¶
MasterConfigModel holds the configuration of the styx master
type SFTPAuth ¶
type SFTPAuth struct { SFTPAuthType string `json:"sftp_auth_type,omitempty"` // SFTPAuthType is the type of authentication: password, key or key & passphrase Username string `json:"username,omitempty"` Password string `json:"password,omitempty"` KeyFile string `json:"key_file,omitempty"` KeyData string `json:"key_data,omitempty"` KeyBinData []byte `json:"key_bin_data,omitempty"` HostkeyFile string `json:"hostkey_file,omitempty"` HostkeyData string `json:"hostkey_data,omitempty"` HostkeyBinData []byte `json:"hostkey_bin_data,omitempty"` }
SFTPAuth is the sub config for SFTP Auth details
type SFTPAuthModel ¶
type SFTPAuthModel struct { SFTPAuthType string // SFTPAuthType is the type of authentication: password, key or key & passphrase Username string Password string KeyFile string KeyData string KeyBinData []byte HostkeyFile string HostkeyData string HostkeyBinData []byte }
SFTPAuthModel is the sub config for SFTP Auth details
type Server ¶
type Server struct{}
Server implements the methods for the GRPC NodeConfigService
func (*Server) AddNode ¶
func (ncs *Server) AddNode(ctx context.Context, req *pb.NodeConfig) (*pb.AllNodeConfig, error)
AddNode sends a request from a new node with the nodeconfig of itself it returns a list of all the nodeconfigs present on the server node
func (*Server) AddNodeConfig ¶
func (ncs *Server) AddNodeConfig(ctx context.Context, in *pb.NodeConfig) (*pb.AddNodeConfigResponse, error)
AddNodeConfig takes a config entry and adds it to the database on all the nodes
func (*Server) GetNodeConfigByID ¶
func (ncs *Server) GetNodeConfigByID(ctx context.Context, in *pb.GetNodeRequest) (*pb.NodeConfig, error)
GetNodeConfigByID fetches NodeConfig based on node id passed.
func (*Server) ListNodeConfig ¶
func (ncs *Server) ListNodeConfig(ctx context.Context, in *pb.NodeConfigRequest) (*pb.AllNodeConfig, error)
ListNodeConfig fetches all the NodeConfigs
func (*Server) UpdateAllNodeConfig ¶
func (ncs *Server) UpdateAllNodeConfig(ctx context.Context, in *pb.NodeConfigRequest) (*pb.AllNodeConfig, error)
UpdateAllNodeConfig reads the list of NodeConfigs from the master and updates the local node. returns all the configuration added in the database
type Store ¶
type Store interface { AddHostConfigEntry(string, *HostConfigModel) error GetHostConfigEntry(string) (*HostConfigModel, error) AddMasterConfigEntry(*MasterConfigModel) error GetMasterConfigEntry() (*MasterConfigModel, error) AddNodeConfigEntry(string, *pb.NodeConfig) error GetNodeConfigEntry(string) (*pb.NodeConfig, error) GetAllNodeConfigEntries(string) ([]*pb.NodeConfig, error) CloseDB() error }
Store is the interface for all NodeConfig DB Actions