Documentation
¶
Overview ¶
Package api manages saved SSH hosts and opens terminals on them, as a JSON API with relative routes plus a WebSocket terminal.
Index ¶
- Constants
- type ConnectError
- type Input
- type Service
- func (s *Service) Connect(ctx context.Context, id int64) (*hosts.Conn, error)
- func (s *Service) Create(ctx context.Context, in Input) (hosts.View, error)
- func (s *Service) Delete(ctx context.Context, id int64) error
- func (s *Service) ForgetHostKey(ctx context.Context, id int64) error
- func (s *Service) Get(ctx context.Context, id int64) (hosts.View, error)
- func (s *Service) Handler() http.Handler
- func (s *Service) List(ctx context.Context) ([]hosts.View, error)
- func (s *Service) PublicKey() string
- func (s *Service) Summary(ctx context.Context) (Summary, error)
- func (s *Service) Test(ctx context.Context, id int64, in Input) (TestResult, error)
- func (s *Service) Update(ctx context.Context, id int64, in Input) (hosts.View, error)
- type Summary
- type TestResult
Constants ¶
const ( StatusConnectFailed websocket.StatusCode = 4000 // reason: the error StatusHostKeyChanged websocket.StatusCode = 4001 // forget the pinned key to continue )
Close codes of the terminal socket beyond the standard ones, so the UI can offer the right next step.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConnectError ¶
type ConnectError struct{ Err error }
ConnectError wraps a failure to reach or authenticate to a host.
func (*ConnectError) Error ¶
func (e *ConnectError) Error() string
func (*ConnectError) Unwrap ¶
func (e *ConnectError) Unwrap() error
type Input ¶
type Input struct {
Name string `json:"name"`
Address string `json:"address"`
Port int `json:"port"`
User string `json:"user"`
Auth string `json:"auth"`
Password string `json:"password"`
PrivateKey string `json:"private_key"`
Passphrase string `json:"passphrase"`
Description string `json:"description"`
}
Input creates or updates a host. On update, empty secrets keep the stored ones.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service manages hosts.
func NewService ¶
NewService returns the service, generating the panel key on first use.
func (*Service) Connect ¶
Connect opens an authenticated connection to a stored host, pinning its key on first use.
func (*Service) ForgetHostKey ¶
ForgetHostKey clears the pinned key, e.g. after a server was reinstalled.
func (*Service) Handler ¶
Handler serves the API. Successful responses are {"data": ...}; failures are {"error": {"code": ..., "message": ...}} with a matching status.
func (*Service) PublicKey ¶
PublicKey returns the panel's public key in authorized_keys format: add it to ~/.ssh/authorized_keys on hosts that use the "panel" method.
type TestResult ¶
type TestResult struct {
HostKeyType string `json:"host_key_type"`
HostKeySHA256 string `json:"host_key_sha256"`
Pinned bool `json:"pinned"` // the key was already pinned
}
TestResult reports a successful test connection.