Documentation
¶
Overview ¶
Package localsrv implements the "Local Services" tool: a set of small built-in servers (HTTP, TFTP, SSH/SFTP, FTP) that let other machines on the network reach files on this host. Each server runs in its own goroutine and streams log lines back to the frontend as Wails events.
Index ¶
- Constants
- type Emitter
- type FTPConfig
- type HTTPConfig
- type Manager
- func (m *Manager) SetEventEmitter(fn Emitter)
- func (m *Manager) StartFTPServer(cfg FTPConfig) (string, error)
- func (m *Manager) StartHTTPServer(cfg HTTPConfig) (string, error)
- func (m *Manager) StartNFSServer(cfg NFSConfig) (string, error)
- func (m *Manager) StartS3Server(cfg S3Config) (string, error)
- func (m *Manager) StartSSHServer(cfg SSHConfig) (string, error)
- func (m *Manager) StartTFTPServer(cfg TFTPConfig) (string, error)
- func (m *Manager) StartTelnetServer(cfg TelnetConfig) (string, error)
- func (m *Manager) Stop(id string)
- func (m *Manager) StopAll()
- type NFSConfig
- type S3Config
- type SSHConfig
- type Service
- type TFTPConfig
- type TelnetConfig
Constants ¶
const ( EventLog = "localsrv:log" // {service, id, message} EventState = "localsrv:state" // {service, id, running} )
Event names emitted by local servers. Every payload carries "service" and "id".
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FTPConfig ¶
type FTPConfig struct {
RootDir string `json:"rootDir"`
Port int `json:"port"`
Username string `json:"username"`
Password string `json:"password"`
Anonymous bool `json:"anonymous"`
UTF8 bool `json:"utf8"`
TimeoutSeconds int `json:"timeoutSeconds"` // 0 = no auto-stop
}
FTPConfig holds the parameters for the FTP server.
type HTTPConfig ¶
type HTTPConfig struct {
RootDir string `json:"rootDir"`
Port int `json:"port"`
ListDir bool `json:"listDir"`
TimeoutSeconds int `json:"timeoutSeconds"` // 0 = no auto-stop
}
HTTPConfig holds the parameters for the HTTP file server.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager owns the lifecycle of all running local servers (HTTP, TFTP, SSH, FTP). Each started server gets a unique id and a cancellable context; Stop/StopAll cancel the workers so no goroutines leak when the dialog closes or the app exits.
func NewManager ¶
func NewManager() *Manager
func (*Manager) SetEventEmitter ¶
SetEventEmitter wires the manager to the frontend event bus.
func (*Manager) StartFTPServer ¶
StartFTPServer starts an FTP server serving rootDir on the given port. Authentication is by username/password; when anonymous is true, any login is accepted. Returns the server id.
func (*Manager) StartHTTPServer ¶
func (m *Manager) StartHTTPServer(cfg HTTPConfig) (string, error)
StartHTTPServer starts an HTTP file server serving rootDir on the given port. With listDir enabled, directory requests render the directory listing (index.html stays reachable under its explicit name). With listDir disabled, directory requests serve index.html when one is present and 404 when not. Returns the server id.
func (*Manager) StartNFSServer ¶
StartNFSServer starts an experimental NFSv4 server backed by an in-memory filesystem. Any data written to the mount is lost when the server stops — real OS file-system support is tracked as a future enhancement. Returns the server id.
func (*Manager) StartS3Server ¶
StartS3Server starts an experimental S3-compatible server that exposes the local directory cfg.RootDir as an object store over the Amazon S3 REST API.
Buckets map to sub-directories of RootDir and objects map to files (the object key is the path relative to the bucket directory). Only a practical subset of S3 is implemented — enough for standard S3 clients (e.g. `mc --no-sign-request`, `aws s3 --no-sign-request`) to create buckets and upload / download / list / delete objects. Returns the server id.
The access/secret keys are accepted for compatibility with clients that send them, but signatures are not cryptographically verified (experimental).
func (*Manager) StartSSHServer ¶
StartSSHServer starts an SSH server on the given port serving an interactive local shell, TCP forwarding and an SFTP subsystem restricted to rootDir. Authentication is by username/password; both are required — the shell grants full access to this machine. Returns the server id.
func (*Manager) StartTFTPServer ¶
func (m *Manager) StartTFTPServer(cfg TFTPConfig) (string, error)
StartTFTPServer starts a TFTP server serving rootDir on the given UDP port. blockSize overrides the default 512-byte block size when the client requests option negotiation. Returns the server id.
func (*Manager) StartTelnetServer ¶
func (m *Manager) StartTelnetServer(cfg TelnetConfig) (string, error)
StartTelnetServer starts a Telnet server listening on the given TCP port. Each incoming connection is authenticated with cfg.Password, then bridged to a local cmd.exe shell (Windows) or the default shell on other platforms. The password is required: the shell grants full access to this machine. Returns the server id.
type NFSConfig ¶
type NFSConfig struct {
Port int `json:"port"`
TimeoutSeconds int `json:"timeoutSeconds"` // 0 = no auto-stop
}
NFSConfig holds the parameters for the NFS server.
type S3Config ¶
type S3Config struct {
RootDir string `json:"rootDir"`
Port int `json:"port"`
AccessKey string `json:"accessKey"`
SecretKey string `json:"secretKey"`
TimeoutSeconds int `json:"timeoutSeconds"` // 0 = no auto-stop
}
S3Config holds the parameters for the S3-compatible server.
type SSHConfig ¶
type SSHConfig struct {
RootDir string `json:"rootDir"`
Port int `json:"port"`
Username string `json:"username"`
Password string `json:"password"`
TimeoutSeconds int `json:"timeoutSeconds"` // 0 = no auto-stop
}
SSHConfig holds the parameters for the SSH server (interactive shell + SFTP). Username and password are required: the shell grants full access to this machine.
type TFTPConfig ¶
type TFTPConfig struct {
RootDir string `json:"rootDir"`
Port int `json:"port"`
BlockSize int `json:"blockSize"`
TimeoutSeconds int `json:"timeoutSeconds"` // 0 = no auto-stop
}
TFTPConfig holds the parameters for the TFTP server.
type TelnetConfig ¶
type TelnetConfig struct {
Port int `json:"port"`
Password string `json:"password"`
TimeoutSeconds int `json:"timeoutSeconds"` // 0 = no auto-stop
}
TelnetConfig holds the parameters for the Telnet server. The password is required: the shell grants full access to this machine.