Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("credentials not found")
Functions ¶
func LooksLikeCookie ¶
LooksLikeCookie reports whether s looks like a Cookie header (vs API key).
func ReadFileContent ¶
ReadFileContent reads a whole file and trims whitespace (for cookie/UA files).
func Save ¶
func Save(c *Credentials) error
Save writes:
- cookie → cookie.txt
- user-agent → user-agent.txt
- api key / username → credentials.json (no cookie/ua fields)
Types ¶
type BrowserResult ¶
BrowserResult is captured after the user passes Cloudflare in a real browser.
func CaptureViaBrowser ¶
func CaptureViaBrowser(ctx context.Context, onStatus func(string)) (*BrowserResult, error)
CaptureViaBrowser opens a visible Chrome/Chromium window on linux.do, waits until cf_clearance (or a non-challenge page) appears, then returns Cookie header + User-Agent.
cf_clearance is HttpOnly — only CDP/browser automation can read it, not page JS.
type Credentials ¶
type Credentials struct {
UserAPIKey string `json:"user_api_key,omitempty"`
UserAPIClientID string `json:"user_api_client_id,omitempty"`
Username string `json:"username,omitempty"`
// Cookie / UserAgent live only in sidecar .txt files on disk.
// JSON tags are kept for one-time migration of older configs.
Cookie string `json:"cookie,omitempty"`
UserAgent string `json:"user_agent,omitempty"`
}
Credentials is the in-memory session material.
On disk layout (no field duplication):
cookie.txt — Cookie only (hand-edit / browser login) user-agent.txt — User-Agent only credentials.json — API key + username only (optional)
func Load ¶
func Load() (*Credentials, error)
Load reads:
- credentials.json → API key / username only
- cookie.txt / user-agent.txt → Cookie / UA (source of truth)
- one-time migrate legacy cookie/ua from JSON into .txt if txt empty
- env LDO_* overrides
func (*Credentials) Empty ¶
func (c *Credentials) Empty() bool
Empty reports whether no usable secrets are stored.
type EnsureResult ¶
type EnsureResult struct {
Dir string
CreatedDir bool
CreatedFiles []string // basenames only
AlreadyPresent []string
}
EnsureResult describes what was created on first run.
func EnsureFiles ¶
func EnsureFiles() (*EnsureResult, error)
EnsureFiles creates ~/.config/ldo-tui and template config files if missing. Existing files are never overwritten.
Layout (no field duplication):
- cookie.txt — Cookie only
- user-agent.txt — User-Agent only
- credentials.json — optional API key / username only
- README.txt — short guide