Documentation
¶
Index ¶
- Constants
- type Config
- type Source
- func (s *Source) FilePath() string
- func (s *Source) Get(key string) any
- func (s *Source) GetInt(key string) int
- func (s *Source) GetString(key string) string
- func (s *Source) GetStringSlice(key string) []string
- func (s *Source) InFile(key string) bool
- func (s *Source) IsSet(key string) bool
- func (s *Source) Save() error
- func (s *Source) Set(key string, val any)
- func (s *Source) SetConfigFile(path string)
- func (s *Source) SetDefault(key string, val any)
- func (s *Source) Unset(key string)
Constants ¶
const ( DefaultPort = 53317 DefaultMulticastGroup = "224.0.0.167" ProtocolVersion = "2.1" DefaultSecurityDir = ".localgo_security" DefaultSecurityFile = "context.json" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Alias string `json:"alias"`
Port int `json:"port"`
HttpsEnabled bool `json:"https_enabled"`
MulticastGroup string `json:"multicast_group"`
DeviceModel *string `json:"deviceModel"`
DeviceType model.DeviceType `json:"deviceType"`
SecurityContext *crypto.StoredSecurityContext `json:"-"`
SecurityPath string `json:"-"`
PIN string `json:"-"`
DownloadDir string `json:"-"`
AutoAccept bool `json:"-"`
RandomFingerprint string `json:"-"`
MaxBodySize int64 `json:"-"`
NoClipboard bool `json:"-"` // skip clipboard; save text as a file instead
HistoryFile string `json:"-"` // path to transfer history jsonl file
Quiet bool `json:"-"` // quiet mode - minimal output
ExecHook string `json:"-"` // shell command to run after receiving file
OpenDir bool `json:"-"` // open download directory after transfer
Concurrency int `json:"-"` // max parallel uploads (0 = use default)
MulticastInterface string `json:"-"` // multicast network interface name
Private bool `json:"-"` // anonymize device identities
DiscoveryStrategy string `json:"-"` // discovery strategy: "full" (default) or "fast" (skip subnet scan)
FileConflictResolve string `json:"-"` // conflict resolution: "rename" (default), "overwrite", "skip"
BindAddress string `json:"-"` // bind to specific interface/IP for listening
StaticPeers []string `json:"-"` // statically defined peer addresses for Tier 1 cache probe
TrustedFingerprints []string `json:"-"` // fingerprints that bypass the transfer acceptance prompt
Shell string `json:"-"` // shell command prefix for exec hooks (default: "sh -c" or "cmd /c")
ClipboardWriteCmd string `json:"-"` // custom clipboard write command
ClipboardReadCmd string `json:"-"` // custom clipboard read command
CustomTLSCertPath string `json:"-"` // path to custom TLS certificate file
CustomTLSKeyPath string `json:"-"` // path to custom TLS private key file
NotificationCmd string `json:"-"` // custom notification command
// contains filtered or unexported fields
}
func (*Config) GetFingerprint ¶ added in v0.4.0
GetFingerprint returns the appropriate fingerprint (certificate hash if HTTPS, random otherwise).
func (*Config) Protocol ¶ added in v0.4.0
func (c *Config) Protocol() model.ProtocolType
Protocol returns the protocol type based on HttpsEnabled.
func (*Config) SetCustomFingerprint ¶ added in v0.6.4
SetCustomFingerprint overrides the advertised fingerprint with one computed from a user-supplied TLS certificate.
func (*Config) ToMulticastDto ¶ added in v0.4.0
func (c *Config) ToMulticastDto(download bool) model.MulticastDto
ToMulticastDto creates a MulticastDto from the current configuration.
func (*Config) ToRegisterDto ¶
func (c *Config) ToRegisterDto() model.RegisterDto
ToRegisterDto converts Config to model.RegisterDto for discovery requests
type Source ¶ added in v0.6.6
type Source struct {
// contains filtered or unexported fields
}
Source is a lightweight replacement for viper. It resolves config values with the precedence: programmatic overrides > environment > file > defaults.
Environment variables are named LOCALSEND_<KEY> with '-' replaced by '_'.
func LoadSource ¶ added in v0.6.6
func LoadSource() *Source
LoadSource searches the standard config directories for a config file and returns a Source bound to it. Returns an empty Source if no file is found.
func LoadSourceFile ¶ added in v0.6.6
LoadSourceFile returns a Source bound to an explicitly selected config file.
func NewSourceFromMap ¶ added in v0.6.6
NewSourceFromMap returns a Source initialised with the given programmatic overrides (used for tests and callers that supply values directly).
func (*Source) FilePath ¶ added in v0.6.6
FilePath returns the resolved config file path, or the default location when no file has been found or selected.
func (*Source) GetStringSlice ¶ added in v0.6.6
GetStringSlice returns the resolved value as a list of strings. A comma-separated environment variable or a YAML scalar yields a single item.
func (*Source) InFile ¶ added in v0.6.6
InFile reports whether the key is present in the config file.
func (*Source) Save ¶ added in v0.6.6
Save writes the file entries merged with programmatic overrides to the resolved config path, creating parent directories as needed.
func (*Source) SetConfigFile ¶ added in v0.6.6
SetConfigFile overrides the config file path used by FilePath and Save.
func (*Source) SetDefault ¶ added in v0.6.6
SetDefault registers a fallback value used when no other source has the key.