Documentation
¶
Index ¶
- Constants
- func CheckConsistency(api, cookie *time.Time) string
- func TimeFromUnix(sec int64) *time.Time
- type CloakTransport
- type Clock
- type FakeClock
- type HTTPTransport
- type ProbeResult
- func Probe(ctx context.Context, def *v2.SiteDefinition, site v2.Site, clock Clock) (*ProbeResult, error)
- func ProbeGazelle(ctx context.Context, site sitev2.Site, clock Clock) (*ProbeResult, error)
- func ProbeMTorrent(ctx context.Context, site v2.Site, clock Clock) (*ProbeResult, error)
- func ProbeNexusPHP(ctx context.Context, site v2.Site, clock Clock, source ProbeSource) (*ProbeResult, error)
- func ProbeUnit3D(ctx context.Context, site v2.Site, clock Clock) (*ProbeResult, error)
- func ProbeWithFallback(ctx context.Context, def *v2.SiteDefinition, site v2.Site, clock Clock, ...) (*ProbeResult, error)
- type ProbeSource
- type ProbeStatus
- type RealClock
- type Transport
Constants ¶
const ConsistencyDrift = "drift"
ConsistencyDrift is the sentinel string written into SiteLoginState.LastConsistencyCheck when the API and cookie last-login timestamps disagree by more than the threshold.
Variables ¶
This section is empty.
Functions ¶
func CheckConsistency ¶
CheckConsistency compares two last-login timestamps after UTC normalization. Returns "drift" only when both pointers are non-nil and the absolute delta exceeds 24h; returns "" in all other cases (including either side being nil).
func TimeFromUnix ¶
TimeFromUnix converts a positive Unix timestamp to a UTC-normalized time pointer. UTC normalization prevents timezone drift bugs (Metis EC-9).
Types ¶
type CloakTransport ¶
type CloakTransport struct{}
CloakTransport is a placeholder for T11-T14, when concrete CloakBrowser schema drivers are wired under internal/cloakdriver/<schema>/.
func (CloakTransport) FetchUserInfo ¶
func (CloakTransport) FetchUserInfo(context.Context, *v2.SiteDefinition, v2.Site, Clock) (*ProbeResult, error)
func (CloakTransport) Name ¶
func (CloakTransport) Name() string
type FakeClock ¶
type FakeClock struct {
// contains filtered or unexported fields
}
func NewFakeClock ¶
type HTTPTransport ¶
type HTTPTransport struct{}
HTTPTransport delegates to the existing schema-specific probe functions.
func (HTTPTransport) FetchUserInfo ¶
func (HTTPTransport) FetchUserInfo(ctx context.Context, def *v2.SiteDefinition, site v2.Site, clock Clock) (*ProbeResult, error)
func (HTTPTransport) Name ¶
func (HTTPTransport) Name() string
type ProbeResult ¶
type ProbeResult struct {
Status ProbeStatus
LastLoginAt *time.Time
LastAccessAt *time.Time
Source ProbeSource
RawError error
Diagnostic string
}
func Probe ¶
func Probe(ctx context.Context, def *v2.SiteDefinition, site v2.Site, clock Clock) (*ProbeResult, error)
Probe routes the request to the schema-specific probe function based on def.Schema. All I/O is performed through site.GetUserInfo, which inherits the project's circuit breaker and rate limiter from site/v2/http_client.go; dispatcher.go itself MUST NOT issue raw HTTP requests.
Panics raised by individual probes are recovered and surfaced as a ProbeResult with Status=UNKNOWN so that a single misbehaving probe cannot crash the LoginReminderMonitor goroutine and stop progress for other sites.
HDDolby and Rousi schemas share the NexusPHP probe implementation because their drivers expose the same UserInfo shape (LastAccess + LastLogin).
func ProbeGazelle ¶
func ProbeMTorrent ¶
func ProbeNexusPHP ¶
func ProbeNexusPHP(ctx context.Context, site v2.Site, clock Clock, source ProbeSource) (*ProbeResult, error)
ProbeNexusPHP wraps Site.GetUserInfo() for NexusPHP-schema sites. All I/O is delegated to the driver; this function performs only classification.
func ProbeUnit3D ¶
ProbeUnit3D wraps a Unit3D Site.GetUserInfo call and classifies any error into the 8-status ProbeStatus taxonomy. It never issues raw HTTP requests; all transport flows through the underlying driver (which inherits circuit breaking and rate limiting from site/v2/http_client.go).
func ProbeWithFallback ¶
func ProbeWithFallback(ctx context.Context, def *v2.SiteDefinition, site v2.Site, clock Clock, primary, fallback Transport) (*ProbeResult, error)
ProbeWithFallback runs the primary transport first and invokes fallback only for statuses that indicate transport-level blocking rather than invalid user credentials. It never runs both transports concurrently.
type ProbeSource ¶
type ProbeSource string
ProbeSource identifies which authentication path produced a probe's last-login timestamp. The caller (LoginReminderMonitor) uses this to dispatch the timestamp into either ApiLastLoginAt (API key) or CookieLastLoginAt (cookie session).
const ( ProbeSourceHTTPCookie ProbeSource = "http_cookie" ProbeSourceHTTPAPIKey ProbeSource = "http_api_key" ProbeSourceCloak ProbeSource = "cloak" )
type ProbeStatus ¶
type ProbeStatus string
const ( OK ProbeStatus = "OK" SESSION_EXPIRED ProbeStatus = "SESSION_EXPIRED" CHALLENGE ProbeStatus = "CHALLENGE" RATE_LIMITED ProbeStatus = "RATE_LIMITED" NETWORK_ERROR ProbeStatus = "NETWORK_ERROR" PARSE_ERROR ProbeStatus = "PARSE_ERROR" KEY_ERROR ProbeStatus = "KEY_ERROR" UNKNOWN ProbeStatus = "UNKNOWN" // NOT_APPLICABLE marks a probe path that was deliberately skipped // (e.g. mTorrent CloakBrowser cookie path when no cookie is configured). // No Manager call is made and no error is recorded. NOT_APPLICABLE ProbeStatus = "NOT_APPLICABLE" )
func (ProbeStatus) String ¶
func (s ProbeStatus) String() string
type Transport ¶
type Transport interface {
Name() string
FetchUserInfo(ctx context.Context, def *v2.SiteDefinition, site v2.Site, clock Clock) (*ProbeResult, error)
}
Transport abstracts how a probe fetches user info from a PT site.
Metis AP-3: dispatcher uses a transport-pluggable single probe, not parallel dual probes. ProbeWithFallback selects at most one fallback after the primary result is classified as fallback-eligible.