remote

package
v0.0.0-...-957db32 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultPort = 22
)

Variables

This section is empty.

Functions

func IsURL

func IsURL(raw string) bool

func KnownHostsPath

func KnownHostsPath() string

func URL

func URL(srv Server, remotePath string) string

URL renders the ssh:// address for a path on a server.

Types

type ChangedHostKeyError

type ChangedHostKeyError struct {
	Host        string
	Fingerprint string
	KeyType     string
}

ChangedHostKeyError is never offered as a prompt: it is what interception looks like, and is resolved by editing known_hosts.

func (*ChangedHostKeyError) Error

func (e *ChangedHostKeyError) Error() string

type Conn

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

Conn is a live SSH session and its filesystem. Panels share one, so it is reference counted.

func (*Conn) FS

func (c *Conn) FS() *sftpfs.FS

func (*Conn) Server

func (c *Conn) Server() Server

type Credentials

type Credentials struct {
	Passphrase string

	// AcceptFingerprint is the fingerprint the user confirmed after an
	// UnknownHostError. Any other key is then refused.
	AcceptFingerprint string
}

Credentials carries what an earlier attempt asked the user for.

type PassphraseRequiredError

type PassphraseRequiredError struct {
	KeyPath string
}

PassphraseRequiredError asks the UI to prompt and retry.

func (*PassphraseRequiredError) Error

func (e *PassphraseRequiredError) Error() string

type Registry

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

Registry shares one connection per server, so opening the same host in the second panel is instant.

func NewRegistry

func NewRegistry() *Registry

func (*Registry) Acquire

func (r *Registry) Acquire(ctx context.Context, srv Server, creds Credentials) (*Conn, error)

Acquire dials only when no connection is open. The caller must Release it.

func (*Registry) CloseAll

func (r *Registry) CloseAll()

CloseAll tears down every connection at shutdown.

func (*Registry) Release

func (r *Registry) Release(c *Conn)

Release closes the connection once nothing holds it.

func (*Registry) Retain

func (r *Registry) Retain(c *Conn)

Retain records another holder, such as a tab copied from one showing a server. The copy gives the reference back with Release when it closes.

type SavedServer

type SavedServer struct {
	Server
	Count    int       `json:"count"`
	LastUsed time.Time `json:"last_used"`
}

SavedServer adds the usage counters that order the list.

type Server

type Server struct {
	Name    string `json:"name"`
	Host    string `json:"host"`
	Port    int    `json:"port,omitempty"`
	User    string `json:"user,omitempty"`
	KeyPath string `json:"key_path,omitempty"`
	Dir     string `json:"dir,omitempty"`

	// Alias is the ~/.ssh/config name Host came from, shown in the panel
	// header because it is what the user typed. Resolved at connect, not saved.
	Alias string `json:"-"`
}

Server describes how to reach a host.

func ParseURL

func ParseURL(raw string) (Server, string, error)

ParseURL reads an ssh://[user@]host[:port][/path] address.

func (Server) Addr

func (s Server) Addr() string

func (Server) DisplayName

func (s Server) DisplayName() string

func (Server) Label

func (s Server) Label() string

Label is the panel header, e.g. "ssh://kk@host", with a non-default port appended. An aliased host shows under its alias.

func (Server) Resolve

func (s Server) Resolve() Server

Resolve fills unset fields from the matching Host block. Values already on the server win.

type Store

type Store struct {
	Servers []SavedServer `json:"servers"`
	// contains filtered or unexported fields
}

Store persists the saved servers to ~/.config/mdc/servers.json. It holds no passwords: authentication is by agent or key file.

func LoadStore

func LoadStore() *Store

LoadStore returns an empty store when the file does not exist yet.

func (*Store) Add

func (s *Store) Add(srv Server)

Add replaces any server already saved under the same name.

func (*Store) Find

func (s *Store) Find(name string) (Server, bool)

func (*Store) Remove

func (s *Store) Remove(name string)

func (*Store) Save

func (s *Store) Save() error

func (*Store) Sorted

func (s *Store) Sorted() []SavedServer

Sorted returns the most-used and most-recent first, as bookmarks are.

func (*Store) Touch

func (s *Store) Touch(name string)

type UnknownHostError

type UnknownHostError struct {
	Host        string
	Fingerprint string
	KeyType     string
}

UnknownHostError means the user must confirm the fingerprint first.

func (*UnknownHostError) Error

func (e *UnknownHostError) Error() string

Directories

Path Synopsis
Package testserver runs an SSH server with an SFTP subsystem in the test process, so the remote code paths need no Docker and no real host.
Package testserver runs an SSH server with an SFTP subsystem in the test process, so the remote code paths need no Docker and no real host.

Jump to

Keyboard shortcuts

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