Documentation ¶
Index ¶
- Variables
- func NewSFTPServer()
- type Agent
- func (a *Agent) CheckUpdate() (*semver.Version, error)
- func (a *Agent) GetInfo() (*models.Info, error)
- func (a *Agent) Initialize() error
- func (a *Agent) Listen(listining chan bool) error
- func (a *Agent) NewReverseListener() (*revdial.Listener, error)
- func (a *Agent) Ping(ticker *time.Ticker, ping chan Ping)
- type Config
- type Ping
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ( AgentVersion string AgentPlatform string )
AgentVersion store the version to be embed inside the binary. This is injected using `-ldflags` build option (e.g: `go build -ldflags "-X main.AgentVersion=1.2.3"`).
If set to `latest`, the auto-updating mechanism is disabled. This is intended to be used during development only.
Functions ¶
func NewSFTPServer ¶
func NewSFTPServer()
NewSFTPServer creates a new SFTP server when a new session is created between the agent and the server.
Types ¶
type Agent ¶
type Agent struct { Identity *models.DeviceIdentity Info *models.DeviceInfo // contains filtered or unexported fields }
func NewAgent ¶
NewAgent creates a new agent instance.
Example ¶
ag, err := NewAgent("http://localhost:80", "00000000-0000-4000-0000-000000000000", "./shellhub.key") if err != nil { panic(err) } // Initializes agent, generating device identity, loading device information, generating private key, // reading public key, probing server information and authorizing device on ShellHub server. if err := ag.Initialize(); err != nil { panic(err) } listing := make(chan bool) go func() { <-listing log.Println("listing") }() ag.Listen(listing) //nolint:errcheck
Output:
func NewAgentWithConfig ¶
NewAgentWithConfig creates a new agent instance with a custom configuration.
Example ¶
// Creates the agent configuration with the minimum required fields. cfg := Config{ ServerAddress: "http://localhost:80", TenantID: "00000000-0000-4000-0000-000000000000", PrivateKey: "./shellhub.key", } ag, err := NewAgentWithConfig(&cfg) if err != nil { panic(err) } // Initializes agent, generating device identity, loading device information, generating private key, // reading public key, probing server information and authorizing device on ShellHub server. if err := ag.Initialize(); err != nil { panic(err) } listing := make(chan bool) go func() { <-listing log.Println("listing") }() ag.Listen(listing) //nolint:errcheck
Output:
func (*Agent) CheckUpdate ¶
CheckUpdate check for agent updates.
func (*Agent) Initialize ¶
Initialize initializes agent, generating device identity, loading device information, generating private key, reading public key, probing server information and authorizing device on ShellHub server.
type Config ¶
type Config struct { // Set the ShellHub Cloud server address the agent will use to connect. // This is required. ServerAddress string `envconfig:"server_address" required:"true"` // Specify the path to the device private key. // If not provided, the agent will generate a new one. // This is required. PrivateKey string `envconfig:"private_key" required:"true"` // Sets the account tenant id used during communication to associate the // device to a specific tenant. // This is required. TenantID string `envconfig:"tenant_id" required:"true"` // Determine the interval to send the keep alive message to the server. This // has a direct impact of the bandwidth used by the device when in idle // state. Default is 30 seconds. KeepAliveInterval int `envconfig:"keepalive_interval" default:"30"` // Set the device preferred hostname. This provides a hint to the server to // use this as hostname if it is available. PreferredHostname string `envconfig:"preferred_hostname"` // Set the device preferred identity. This provides a hint to the server to // use this identity if it is available. PreferredIdentity string `envconfig:"preferred_identity" default:""` // Set password for single-user mode (without root privileges). If not provided, // multi-user mode (with root privileges) is enabled by default. // NOTE: The password hash could be generated by “`openssl passwd“`. SingleUserPassword string `envconfig:"simple_user_password"` }
Config provides the configuration for the agent service.