Documentation
¶
Overview ¶
Package nodeinfo provides /nodeinfo/* endpoints.
Index ¶
- Constants
- type Handler
- func (h *Handler) DropLocal()
- func (h *Handler) InvalidateCache()
- func (h *Handler) SetCacheTTL(d time.Duration)
- func (h *Handler) SetClock(now func() time.Time)
- func (h *Handler) SetMetaRepo(r repository.MetaRepository)
- func (h *Handler) SetPeeredPlugins(names []string)
- func (h *Handler) SetProxyAccountResolver(r func() (string, bool))
- func (h *Handler) SetUsageRepos(userRepo repository.UserRepository, noteRepo repository.NoteRepository)
- func (h *Handler) Version2_0(c *echo.Context) error
- func (h *Handler) Version2_1(c *echo.Context) error
Constants ¶
const CacheTTL = 10 * time.Minute
CacheTTL mirrors upstream NodeinfoServerService の `new MemorySingleCache<...>(1000 * 60 * 10)` (10 分)。
**サーバー側キャッシュが無いと未認証の 1 リクエストごとに全表 COUNT が 2 本走る** (`CountLocalUsers` + `CountLocalNotes`)。`/nodeinfo/*` は `s.echo.GET` 直付けで rate limiter (`/api` グループ専用) も掛からないので、 外部から無制限に回せる。Cache-Control: max-age=600 は返していたが、 それは中継キャッシュ任せで origin には効かない。
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler handles nodeinfo endpoints.
func (*Handler) DropLocal ¶
func (h *Handler) DropLocal()
DropLocal drops the cached documents of this process (#3721). It is what the cache list of internal/server calls (docs/architecture.md 4.4). No other process is told. The caller drops the meta row cache first, as for InvalidateCache.
func (*Handler) InvalidateCache ¶
func (h *Handler) InvalidateCache()
InvalidateCache drops the cached documents, so the next request rebuilds them from the current meta.
internal:metaUpdated で呼ぶ (#3663)。呼ばないと、管理画面でサーバーの名前や 登録の可否を変えても、最大 CacheTTL (10 分) 古い document を配り続ける。 **meta 行のキャッシュを先に捨ててから呼ぶこと** (逆だと、捨てた直後の 組み立てが古い meta 行を読む)。本家はここを捨てず、TTL まで古いまま。
func (*Handler) SetCacheTTL ¶
SetCacheTTL overrides the server-side cache TTL. Intended for tests; in production the default (CacheTTL) matches the Cache-Control header so clients and the origin see the same freshness window.
0 以下を渡すとキャッシュを無効化する (毎回 build し直す)。
func (*Handler) SetMetaRepo ¶
func (h *Handler) SetMetaRepo(r repository.MetaRepository)
SetMetaRepo injects a MetaRepository so that the nodeName / nodeDescription fields reflect the live admin settings instead of the config default. 未配線のまま呼ばれると cfg.Host fallback になる (#348)。
func (*Handler) SetPeeredPlugins ¶
SetPeeredPlugins declares the plugins that accept the mk-go-only plugin channel (#2537), so other instances can tell whether sending is worthwhile.
**宣言したものだけを渡すこと。** 入れているプラグインを全部並べると、 運営者がどんな拡張を使っているかが攻撃面の情報になる。
func (*Handler) SetProxyAccountResolver ¶
SetProxyAccountResolver wires the resolver used to populate the metadata.proxyAccountName field (#1777)。未配線なら proxyAccountName は null。
func (*Handler) SetUsageRepos ¶
func (h *Handler) SetUsageRepos(userRepo repository.UserRepository, noteRepo repository.NoteRepository)
SetUsageRepos injects repositories used to populate the usage statistics (users.total / activeMonth / activeHalfyear / localPosts / localComments). 未配線のまま呼ばれると対応 field は 0 のままになる (#403)。
func (*Handler) Version2_0 ¶
Version2_0 handles GET /nodeinfo/2.0. /.well-known/nodeinfo が 2.0 リンクも advertise するため、upstream NodeinfoServerService と同じく 2.0 も配信する (#1777)。schema 2.0 には software.repository が無いので省略する (upstream は version 2.0 で software.repository を delete する)。