Documentation
¶
Overview ¶
Optional, removable backup feed. Keep this file isolated from the rest of the web package so deleting it (plus the routes / clear-cache wiring in web.go and the BEGIN/END telemirror block in static/index.html) is enough to drop the feature.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckPasscode ¶ added in v0.42.0
CheckPasscode compares a passcode with its stored form. It returns "" when they do not match, otherwise what to store from now on: the same value, or a fresh hash when the stored one is the older SHA-256 hex form.
func HashPasscode ¶ added in v0.42.0
HashPasscode returns the stored form of a passcode, or "" if no random salt could be read.
Types ¶
type ActiveList ¶ added in v0.14.0
type ActiveList struct {
Name string `json:"name"`
Resolvers []string `json:"resolvers"`
LastUsed int64 `json:"lastUsed,omitempty"`
}
ActiveList is a named subset of the resolver bank that the user can switch between — e.g., "Home", "Office", "Mobile". The currently selected list is what the fetcher uses; switching to a different list hot-swaps the active resolvers without rescanning.
type Config ¶
type Config struct {
Domain string `json:"domain"`
// ExtraDomains are additional sub-domains the server also answers feed
// queries on; the client spreads block fetches across the main domain +
// these (main stays canonical for relay paths). From the d= URI field.
ExtraDomains []string `json:"extraDomains,omitempty"`
Key string `json:"key"`
Resolvers []string `json:"resolvers"`
// ServerKey is the pinned server signing public key (base64url, the sk=
// field of a thefeed:// URI). When set, the client verifies feed content
// against the server's signed ExtraBlocks. Empty = unverified (old config).
ServerKey string `json:"serverKey,omitempty"`
QueryMode string `json:"queryMode"`
RateLimit float64 `json:"rateLimit"`
// Timeout is the per-query DNS timeout in seconds (0 = default 15 s).
// Also used as the resolver health-check probe timeout.
Timeout float64 `json:"timeout,omitempty"`
// Scatter is the number of resolvers queried simultaneously per DNS block request
// (0 or 1 = sequential, 4 = default parallel pair).
Scatter int `json:"scatter,omitempty"`
// AutoScan enables hourly automatic resolver health-check scans.
// nil means enabled (default); set to a false pointer to disable.
AutoScan *bool `json:"autoScan,omitempty"`
}
Config holds the client configuration saved in the data directory.
type Profile ¶ added in v0.2.0
type Profile struct {
ID string `json:"id"`
Nickname string `json:"nickname"`
Config Config `json:"config"`
AutoUpdate []string `json:"autoUpdate,omitempty"`
AutoUpdateInterval int `json:"autoUpdateInterval,omitempty"`
// PinnedChannels stores the user's pinned channel names (stripped of @).
// Pinned channels render at the top of each section in the sidebar.
PinnedChannels []string `json:"pinnedChannels,omitempty"`
}
Profile wraps a Config with a user-chosen nickname and a unique ID.
type ProfileList ¶ added in v0.2.0
type ProfileList struct {
Active string `json:"active"` // ID of active profile
Profiles []Profile `json:"profiles"`
// FontSize stores user's preferred font size (0 = default 14).
FontSize int `json:"fontSize,omitempty"`
Debug bool `json:"debug,omitempty"`
Theme string `json:"theme,omitempty"`
Lang string `json:"lang,omitempty"`
// SkipUpdateVersion is the latest release the user dismissed.
SkipUpdateVersion string `json:"skipUpdateVersion,omitempty"`
// DownloadedVersion is the latest release saved but not necessarily
// installed. Kept apart from SkipUpdateVersion so a download never
// silently suppresses the prompt for good.
DownloadedVersion string `json:"downloadedVersion,omitempty"`
// MigrationVersion is the highest one-time migration applied here. The
// frontend owns the list (some touch localStorage) and reports its level;
// storing it server-side stops replays when the loopback port changes.
MigrationVersion int `json:"migrationVersion,omitempty"`
// TelAPIID / TelAPIHash let a user substitute their own Telegram app
// credentials for the bridge. Empty means the app's bundled default.
TelAPIID int `json:"telApiId,omitempty"`
TelAPIHash string `json:"telApiHash,omitempty"`
// TelWatch keeps checking Telegram for new messages while the app is in
// the background, so the platform can raise a notification. ON by default:
// a messenger that only notices messages while you are looking at it is
// not doing its job.
//
// A pointer, not a bool: nil means the user has never chosen, and only then
// does the default apply. A plain bool could not tell "turned it off" from
// "never touched it", since omitempty drops a false entirely.
TelWatch *bool `json:"telWatch,omitempty"`
// TelLastServer is the config the Telegram session was last connected on,
// so opening the app can go straight back to it. In memory it would be lost
// on every client restart, which is exactly when getting back on matters.
TelLastServer string `json:"telLastServer,omitempty"`
// TelAuthorized remembers that Telegram CONFIRMED this session belongs to
// an account. The session file existing proves nothing: connecting without
// one makes gotd generate a fresh auth key and save it, so a file is there
// while Telegram answers AUTH_KEY_UNREGISTERED. Only a confirmation sets
// this, and only a logout or Telegram rejecting the key clears it.
TelAuthorized bool `json:"telAuthorized,omitempty"`
// ResolverBank is the shared pool of DNS resolvers used by all profiles.
ResolverBank []string `json:"resolverBank,omitempty"`
// ResolverScores stores accumulated performance data for bank resolvers.
ResolverScores map[string]*SavedResolverScore `json:"resolverScores,omitempty"`
// ActiveLists holds named resolver subsets so the user can keep one
// list per situation (home, office, mobile data) and switch by name
// instead of rescanning. The currently-selected list is named in
// SelectedList; its resolvers are what the fetcher uses.
//
// Migration: legacy installs without ActiveLists are upgraded on
// first load — their last_scan.json (or current bank) becomes a
// single list named "Default".
ActiveLists []ActiveList `json:"activeLists,omitempty"`
SelectedList string `json:"selectedList,omitempty"`
// ScanPromptOff suppresses the startup "scan resolvers?" prompt.
// Persisted server-side so it survives Android's per-launch port
// changes (each launch picks a fresh port → different localStorage
// origin → flag was lost on every restart).
ScanPromptOff bool `json:"scanPromptOff,omitempty"`
// MirrorNoteOff suppresses the Mirror (Telemirror) disclaimer note once the
// user dismisses it. Persisted server-side for the same reason as
// ScanPromptOff: a fresh client port has empty localStorage and would
// otherwise re-show the note on every launch.
MirrorNoteOff bool `json:"mirrorNoteOff,omitempty"`
// TelIntroSeen: the Telegram section's intro was read. Server-side for the
// same reason as ScanPromptOff.
TelIntroSeen bool `json:"telIntroSeen,omitempty"`
// ProfilePicsEnabled enables fetching avatars over DNS when the
// GitHub relay can't serve them. Off by default.
ProfilePicsEnabled bool `json:"profilePicsEnabled,omitempty"`
// Connection settings (formerly per-profile). 0 = use default.
QueryMode string `json:"queryMode,omitempty"` // "single" or "double"
RateLimit float64 `json:"rateLimit,omitempty"` // parallel block fetches
Scatter int `json:"scatter,omitempty"` // resolvers per block
Timeout float64 `json:"timeout,omitempty"` // DNS query timeout (s)
// CacheBudgetMB is the disk-cache byte budget in megabytes (0 = default 1024).
// Applies to media-cache and telemirror images combined. saved-media is exempt.
CacheBudgetMB int `json:"cacheBudgetMB,omitempty"`
// (not plain bool) so we can tell "user never set it" (nil → default
// on) apart from "user explicitly disabled" (false). New installs and
// upgrades from before this field existed get the feature on; an
// explicit opt-out persists across restarts.
ResolverCacheShare *bool `json:"resolverCacheShare,omitempty"`
// SeenIDs maps channel name → last-seen message ID. It's the baseline
// for the per-channel unread-count badge. Persisted server-side so the
// counts survive the client's loopback port changing (which wipes the
// WebView localStorage these markers used to live in).
SeenIDs map[string]int64 `json:"seenIds,omitempty"`
// SeenHashes maps channel name → last-seen content hash, used for the
// X/Twitter "NEW" badge where message IDs aren't sequential.
SeenHashes map[string]int64 `json:"seenHashes,omitempty"`
}
ProfileList is the on-disk structure for profiles.json.
func (*ProfileList) ShareEnabled ¶ added in v0.19.0
func (pl *ProfileList) ShareEnabled() bool
ShareEnabled returns whether the shared-resolver-cache feature is on. Default is on; only an explicit *false disables it.
type SavedItem ¶ added in v0.27.0
type SavedItem struct {
ID string `json:"id"` // <domain>__<channelId>__<messageId> for bookmarks
// Kind discriminates the self-chat timeline: "bookmark" (Telemirror channel
// post), "note" (typed to self), "file" (uploaded), "chat" (forwarded from
// the E2E messenger). Empty in legacy records -> backfilled to "bookmark".
Kind string `json:"kind"`
Domain string `json:"domain"`
Nickname string `json:"nickname"` // snapshot of the config (or contact) name at save time
ChannelID string `json:"channelId"`
ChannelNum int `json:"channelNum"`
MessageID uint32 `json:"messageId"`
Text string `json:"text"`
Timestamp uint32 `json:"timestamp"`
SavedAt int64 `json:"savedAt"` // unix millis
Media []SavedMedia `json:"media"`
FileName string `json:"fileName,omitempty"` // kind:"file"
MimeType string `json:"mimeType,omitempty"` // kind:"file"
Pinned bool `json:"pinned,omitempty"`
// TmSource locates the originating Telemirror post for items saved from the
// Telemirror browser ("<channel>/<msgNum>", e.g. "VahidOnline/12345"). When
// set, the UI shows a "jump to post" action that reopens that channel.
TmSource string `json:"tmSource,omitempty"`
}
SavedItem is one bookmarked message, scoped to a config's domain (the stable identity of a config, unlike the random profile ID).
type SavedMedia ¶ added in v0.27.0
type SavedMedia struct {
Tag string `json:"tag"`
Size int64 `json:"size"`
CRC uint32 `json:"crc"`
Persisted bool `json:"persisted"`
Fname string `json:"fname,omitempty"`
}
SavedMedia is one media item referenced by a saved message. Bytes live in the saved-media store, content-addressed by (Size, CRC). Persisted is true once the bytes have been copied into saved-media/.
type SavedResolverScore ¶ added in v0.10.0
type SavedResolverScore struct {
Success int64 `json:"success"`
Failure int64 `json:"failure"`
TotalMs int64 `json:"totalMs"`
}
SavedResolverScore stores persistent resolver performance data.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the web UI server for thefeed client.
func (*Server) Serve ¶ added in v0.17.4
Serve runs the web server on an already-bound listener. Used by the mobile entry where the listener is opened first to discover the kernel-assigned port.
func (*Server) SetNewMessageHandler ¶ added in v0.25.9
SetNewMessageHandler registers a callback invoked (off the UI path) whenever the background chat poll loop discovers new messages. Pass nil to clear.
func (*Server) SetSharedBackend ¶ added in v0.22.0
SetSharedBackend toggles multi-user mode. When on, /api/seen reports shared:true and refuses writes, so the client falls back to per-browser localStorage and connected users don't share (and clobber) seen markers.
func (*Server) Shutdown ¶ added in v0.30.3
func (s *Server) Shutdown()
Shutdown stops the server's background goroutines and closes the HTTP listener. It is the clean counterpart to serve() for embedders that reuse the process — notably the iOS/Android bind layer, which calls Shutdown when the app is backgrounded so the fetcher/checker/chat goroutines stop touching profiles.json while suspended. Without this the goroutines leak across every background→foreground cycle and a scan suspended mid-flight can corrupt shared state.
Source Files
¶
- autoupdate.go
- backup.go
- cache.go
- chatbudget.go
- config_store.go
- defaultconfigs.go
- fetch.go
- handlers_chat.go
- handlers_feed.go
- handlers_lists.go
- handlers_profiles.go
- handlers_resolvers.go
- handlers_saved.go
- handlers_saved_lock.go
- handlers_saved_upload.go
- handlers_settings.go
- handlers_tel.go
- handlers_tel_api.go
- handlers_tel_direct.go
- handlers_tel_lock.go
- handlers_tel_moderation.go
- handlers_tel_msgactions.go
- handlers_tel_presence.go
- handlers_tel_sponsored.go
- handlers_update.go
- iranresolvers.go
- media.go
- media_cache.go
- passcode.go
- profile_pics.go
- relay_info.go
- resolver_bank.go
- saved_crypto.go
- saved_media.go
- saved_profile.go
- saved_store.go
- scanner.go
- seen.go
- sse.go
- tel_cache.go
- tel_cache_deletes.go
- tel_crypto.go
- telemirror.go
- web.go