remote

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package remote provides SSH/SFTP remote file access for fur. It implements a sync/cache model: files are downloaded from the remote host to a local cache directory, and a background goroutine polls for changes periodically.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsRemotePath

func IsRemotePath(s string) bool

IsRemotePath returns true if the string looks like a remote path spec.

func NewSFTPFs

func NewSFTPFs(client *sftp.Client) afero.Fs

NewSFTPFs creates a read-only afero.Fs backed by an SFTP connection.

Types

type Conn

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

Conn manages an SSH connection and SFTP client to a remote host.

func NewConn

func NewConn(target Target) *Conn

NewConn creates a new remote connection manager.

func (*Conn) Close

func (c *Conn) Close() error

Close shuts down the connection.

func (*Conn) Connect

func (c *Conn) Connect() error

Connect establishes the SSH and SFTP connections.

func (*Conn) LastError

func (c *Conn) LastError() error

LastError returns the most recent connection error.

func (*Conn) Reconnect

func (c *Conn) Reconnect() error

Reconnect attempts to re-establish the connection with exponential backoff.

func (*Conn) SFTP

func (c *Conn) SFTP() *sftp.Client

SFTP returns the SFTP client. Returns nil if not connected.

func (*Conn) State

func (c *Conn) State() ConnState

State returns the current connection state.

func (*Conn) Target

func (c *Conn) Target() Target

Target returns the connection target.

type ConnState

type ConnState int

ConnState represents the connection lifecycle state.

const (
	ConnDisconnected ConnState = iota
	ConnConnecting
	ConnConnected
	ConnReconnecting
)

func (ConnState) String

func (s ConnState) String() string

String returns a human-readable state label.

type SFTPFs

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

SFTPFs implements afero.Fs backed by an SFTP client. Only read operations are supported; write operations return errReadOnly.

func (*SFTPFs) Chmod

func (s *SFTPFs) Chmod(name string, mode os.FileMode) error

func (*SFTPFs) Chown

func (s *SFTPFs) Chown(name string, uid, gid int) error

func (*SFTPFs) Chtimes

func (s *SFTPFs) Chtimes(name string, atime, mtime time.Time) error

func (*SFTPFs) Create

func (s *SFTPFs) Create(name string) (afero.File, error)

func (*SFTPFs) Mkdir

func (s *SFTPFs) Mkdir(name string, perm os.FileMode) error

func (*SFTPFs) MkdirAll

func (s *SFTPFs) MkdirAll(path string, perm os.FileMode) error

func (*SFTPFs) Name

func (s *SFTPFs) Name() string

func (*SFTPFs) Open

func (s *SFTPFs) Open(name string) (afero.File, error)

func (*SFTPFs) OpenFile

func (s *SFTPFs) OpenFile(name string, flag int, perm os.FileMode) (afero.File, error)

func (*SFTPFs) Remove

func (s *SFTPFs) Remove(name string) error

func (*SFTPFs) RemoveAll

func (s *SFTPFs) RemoveAll(path string) error

func (*SFTPFs) Rename

func (s *SFTPFs) Rename(oldname, newname string) error

func (*SFTPFs) Stat

func (s *SFTPFs) Stat(name string) (os.FileInfo, error)

func (*SFTPFs) Walk

func (s *SFTPFs) Walk(root string, fn WalkFunc) error

Walk traverses the directory tree rooted at root using SFTP ReadDir (one round trip per directory) instead of individual Stat calls.

type Target

type Target struct {
	User string // SSH username (empty = use ~/.ssh/config or current user)
	Host string // hostname or SSH config alias
	Port int    // SSH port (0 = use default 22 or ~/.ssh/config)
	Path string // remote directory path
}

Target represents a parsed remote path specification.

func ParseTarget

func ParseTarget(s string) *Target

ParseTarget parses an SCP-style remote path specification. Supported formats:

  • host:/path
  • user@host:/path
  • user@host:port:/path

Returns nil if the input is not a remote path (no ':' separator or looks like a Windows drive letter).

func (Target) Display

func (t Target) Display() string

Display returns a short display string for the status bar.

func (Target) String

func (t Target) String() string

String returns the SCP-style representation.

type WalkFunc

type WalkFunc func(path string, info os.FileInfo, err error) error

WalkFunc is the callback for Walk.

Jump to

Keyboard shortcuts

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