devices

package
v0.0.0-...-b35749e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 28, 2023 License: GPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Type     string `yaml:"type"`
	Protocol string `yaml:"protocol"`
}

type ConnectionPuller

type ConnectionPuller struct {
	Username string `yaml:"username"`
	Password string `yaml:"password"`
	Port     uint16 `yaml:"port"`
	Endpoint string `yaml:"endpoint"`
}

type ConnectionRest

type ConnectionRest struct {
	Username           string `yaml:"username"`
	Password           string `yaml:"password"`
	Endpoint           string `yaml:"endpoint"`
	InsecureSkipVerify bool   `yaml:"insecure-skip-verify"`
}

type ConnectionRouterOsApi

type ConnectionRouterOsApi struct {
	Username string `yaml:"username"`
	Password string `yaml:"password"`
	Host     string `yaml:"host"`
	Port     uint16 `yaml:"port"`
	Tls      bool   `yaml:"tls"`
}

type ConnectionSSHCfg

type ConnectionSSHCfg struct {
	Username                   string                 `yaml:"username"`
	Password                   string                 `yaml:"password"`
	Host                       string                 `yaml:"host"`
	Port                       uint16                 `yaml:"port"`
	KnownHosts                 string                 `yaml:"knownHosts"`
	PrivateKeyPath             string                 `yaml:"private-key"`
	PrivateKeyPassphrase       string                 `yaml:"private-key-passphrase"`
	ConnectionKeepAliveTimeout common.DurationSeconds `yaml:"connection-keep-alive"`
}

type DeviceConstructor

type DeviceConstructor interface {
	Construct(*yaml.Node, firewallProtocol.IFirewallProtocol) (IDevice, error)
}

type DeviceController

type DeviceController struct {
	Device IDevice
	Config Config
	// contains filtered or unexported fields
}

func DeviceControllerNew

func DeviceControllerNew(device IDevice) *DeviceController

func (*DeviceController) CleanupTrashRules

func (ctx *DeviceController) CleanupTrashRules(comment comment.IRuleComment) error

func (*DeviceController) FindRuleIdByComment

func (ctx *DeviceController) FindRuleIdByComment(comment string, forceRefresh bool) (uint64, error)

func (*DeviceController) GetRules

func (ctx *DeviceController) GetRules(forceRefresh bool) ([]firewallCommon.FirewallRule, error)

func (*DeviceController) GetRulesFiltered

func (ctx *DeviceController) GetRulesFiltered(filter comment.IRuleComment, forceRefresh bool) ([]firewallCommon.FirewallRule, error)

func (*DeviceController) RemoveBatch

func (ctx *DeviceController) RemoveBatch(ids []uint64) error

func (*DeviceController) RunCommandWithReply

func (ctx *DeviceController) RunCommandWithReply(cmd device.IDeviceCommand) (device.IDeviceResponse, error)

func (*DeviceController) Start

func (ctx *DeviceController) Start() error

func (*DeviceController) Stop

func (ctx *DeviceController) Stop() error

func (*DeviceController) UnmarshalYAML

func (ctx *DeviceController) UnmarshalYAML(value *yaml.Node) error

type DevicePuller

type DevicePuller struct {
	// contains filtered or unexported fields
}

func DevicePullerNew

func DevicePullerNew(cfg ConnectionPuller) *DevicePuller

func (*DevicePuller) RunCommandWithReply

func (ctx *DevicePuller) RunCommandWithReply(
	cmd device.IDeviceCommand,
) (device.IDeviceResponse, error)

func (*DevicePuller) SetProtocol

func (ctx *DevicePuller) SetProtocol(protocol firewallProtocol.IFirewallProtocol)

func (*DevicePuller) Start

func (ctx *DevicePuller) Start() error

func (*DevicePuller) Stop

func (ctx *DevicePuller) Stop() error

type DeviceRest

type DeviceRest struct {
	// contains filtered or unexported fields
}

func DeviceRestNew

func DeviceRestNew(cfg ConnectionRest) *DeviceRest

func (*DeviceRest) RunCommandWithReply

func (ctx *DeviceRest) RunCommandWithReply(command device.IDeviceCommand) (device.IDeviceResponse, error)

func (*DeviceRest) SetProtocol

func (ctx *DeviceRest) SetProtocol(protocol firewallProtocol.IFirewallProtocol)

func (*DeviceRest) Start

func (ctx *DeviceRest) Start() error

func (*DeviceRest) Stop

func (ctx *DeviceRest) Stop() error

type DeviceRouterOsApi

type DeviceRouterOsApi struct {
	// contains filtered or unexported fields
}

func DeviceRouterOsNew

func DeviceRouterOsNew(cfg ConnectionRouterOsApi) *DeviceRouterOsApi

func (*DeviceRouterOsApi) Connect

func (ctx *DeviceRouterOsApi) Connect()

func (*DeviceRouterOsApi) Disconnect

func (ctx *DeviceRouterOsApi) Disconnect()

func (*DeviceRouterOsApi) IsConnected

func (ctx *DeviceRouterOsApi) IsConnected() bool

func (*DeviceRouterOsApi) RunCommandWithReply

func (ctx *DeviceRouterOsApi) RunCommandWithReply(command device.IDeviceCommand) (device.IDeviceResponse, error)

func (*DeviceRouterOsApi) SetProtocol

func (ctx *DeviceRouterOsApi) SetProtocol(protocol firewallProtocol.IFirewallProtocol)

func (*DeviceRouterOsApi) Start

func (ctx *DeviceRouterOsApi) Start() error

func (*DeviceRouterOsApi) Stop

func (ctx *DeviceRouterOsApi) Stop() error

type DeviceSsh

type DeviceSsh struct {
	// contains filtered or unexported fields
}

func DeviceSshNew

func DeviceSshNew(cfg ConnectionSSHCfg) *DeviceSsh

func (*DeviceSsh) RunCommandWithReply

func (ctx *DeviceSsh) RunCommandWithReply(command device.IDeviceCommand) (device.IDeviceResponse, error)

func (*DeviceSsh) RunSSHCommandWithReply

func (ctx *DeviceSsh) RunSSHCommandWithReply(cmd string) (string, error)

func (*DeviceSsh) SetProtocol

func (ctx *DeviceSsh) SetProtocol(protocol firewallProtocol.IFirewallProtocol)

func (*DeviceSsh) Start

func (ctx *DeviceSsh) Start() error

func (*DeviceSsh) Stop

func (ctx *DeviceSsh) Stop() error

type DeviceStorage

type DeviceStorage struct {
	// contains filtered or unexported fields
}

func GetDeviceStorage

func GetDeviceStorage() *DeviceStorage

func (*DeviceStorage) GetDevice

func (ctx *DeviceStorage) GetDevice(name string, node *yaml.Node) (IDevice, error)

func (*DeviceStorage) Init

func (ctx *DeviceStorage) Init()

type IDevice

type IDevice interface {
	SetProtocol(protocol firewallProtocol.IFirewallProtocol)
	Start() error
	Stop() error
	RunCommandWithReply(cmd device.IDeviceCommand) (device.IDeviceResponse, error)
}

func DevicePullerNewFromYaml

func DevicePullerNewFromYaml(value *yaml.Node) (IDevice, error)

func DeviceRestNewFromYaml

func DeviceRestNewFromYaml(value *yaml.Node) (IDevice, error)

func DeviceRouterOsNewFromYaml

func DeviceRouterOsNewFromYaml(value *yaml.Node) (IDevice, error)

func DeviceSshNewFromYaml

func DeviceSshNewFromYaml(value *yaml.Node) (IDevice, error)

type IFirewallRestProtocol

type IFirewallRestProtocol interface {
	firewallProtocol.IFirewallProtocol
	To(cmd device.IDeviceCommand, baseUrl string) (*http.Request, error)
	From(httpResponse *http.Response, cmdType device.DeviceCommandType) (device.IDeviceResponse, error)
}

type IFirewallSshProtocol

type IFirewallSshProtocol interface {
	firewallProtocol.IFirewallProtocol
	To(cmd device.IDeviceCommand) (string, error)
	From(responseData string, cmdType device.DeviceCommandType) (device.IDeviceResponse, error)
}

type VirtualFirewall

type VirtualFirewall struct {
	// contains filtered or unexported fields
}

func (*VirtualFirewall) Add

func (ctx *VirtualFirewall) Add(cmd command.Add) (*response.Add, error)

func (*VirtualFirewall) Get

func (ctx *VirtualFirewall) Get(cmd command.Get) (*response.Get, error)

func (*VirtualFirewall) Remove

func (ctx *VirtualFirewall) Remove(cmd command.Remove) (*response.Remove, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL