Documentation ¶
Index ¶
- func ExecuteCommands(ctx context.Context, d Service, commands []schema.Command) (err error)
- func GenerateCA(config *schema.GeneralConfig) error
- func GenerateCerts(config *schema.GeneralConfig, subject string) error
- type ApplicationStatus
- type CopyFiler
- type GenericDevice
- type HandlerFunc
- type MTAPI
- func (d *MTAPI) Close() error
- func (d MTAPI) GetDevice() *GenericDevice
- func (d *MTAPI) GetPasswords() []string
- func (d *MTAPI) GetPort() string
- func (d *MTAPI) GetUser() string
- func (d *MTAPI) HandleSequence(ctx context.Context, handler HandlerFunc) error
- func (d MTAPI) RunCmd(body string, expect *regexp.Regexp) (result string, err error)
- type NewServiceFunc
- type SSH
- func (d *SSH) Close() error
- func (d *SSH) CopyFile(ctx context.Context, local, remote string) error
- func (d *SSH) GetDevice() *GenericDevice
- func (d *SSH) GetPasswords() []string
- func (d *SSH) GetPort() string
- func (d *SSH) GetUser() string
- func (d *SSH) HandleSequence(ctx context.Context, handler HandlerFunc) (err error)
- func (d *SSH) RunCmd(body string, expect *regexp.Regexp) (result string, err error)
- type Service
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExecuteCommands ¶
ExecuteCommands executes provided list of commands using specified service.
func GenerateCA ¶
func GenerateCA(config *schema.GeneralConfig) error
GenerateCA generates CA key and certificate needed for sign device/client certificates.
func GenerateCerts ¶
func GenerateCerts(config *schema.GeneralConfig, subject string) error
GenerateCerts generates and sign using CA certificate generic key and certificate.
Types ¶
type ApplicationStatus ¶
ApplicationStatus stores final execution status that should be returned to OS.
func (*ApplicationStatus) Get ¶
func (app *ApplicationStatus) Get() int
Get returns application status code.
func (*ApplicationStatus) SetCode ¶
func (app *ApplicationStatus) SetCode(status int)
SetCode sets application status code.
type GenericDevice ¶
type GenericDevice struct { AppConfig *schema.GeneralConfig Host schema.Host // contains filtered or unexported fields }
GenericDevice defines basic setup for device instance.
func (*GenericDevice) SetConfig ¶
func (d *GenericDevice) SetConfig(config *schema.GeneralConfig)
func (*GenericDevice) SetHost ¶
func (d *GenericDevice) SetHost(host schema.Host)
type HandlerFunc ¶
HandlerFunc executes sequence of operations in context of service using established already connection and passed by context into handler.
type MTAPI ¶
type MTAPI struct { GenericDevice // contains filtered or unexported fields }
MTAPI defines Mikrotik secure API service by extending generic device with Routeros connection.
func (MTAPI) GetDevice ¶
func (d MTAPI) GetDevice() *GenericDevice
func (*MTAPI) GetPasswords ¶
func (*MTAPI) HandleSequence ¶
func (d *MTAPI) HandleSequence(ctx context.Context, handler HandlerFunc) error
type NewServiceFunc ¶
type NewServiceFunc func(config *schema.GeneralConfig, host schema.Host) Service
NewServiceFunc creates new service for handle given host and configuration.
type SSH ¶
type SSH struct { GenericDevice // contains filtered or unexported fields }
SSH defines SSH service by extending generic device with ssh specific client connection details.
func (*SSH) GetDevice ¶
func (d *SSH) GetDevice() *GenericDevice
func (*SSH) GetPasswords ¶
func (*SSH) HandleSequence ¶
func (d *SSH) HandleSequence(ctx context.Context, handler HandlerFunc) (err error)
HandleSequence establish connection and executes handler function with sequence of tasks/commands to do.
type Service ¶
type Service interface { GetUser() string GetPasswords() []string GetPort() string GetDevice() *GenericDevice SetHost(schema.Host) SetConfig(*schema.GeneralConfig) HandleSequence(ctx context.Context, handler HandlerFunc) error RunCmd(string, *regexp.Regexp) (string, error) Close() error }
Service represents common interface for all supported services.
func NewMTAPIService ¶
func NewMTAPIService(config *schema.GeneralConfig, host schema.Host) Service
func NewSSHService ¶
func NewSSHService(config *schema.GeneralConfig, host schema.Host) Service