publicinfo

package
v1.21.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2026 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Overview

Package publicinfo implements the public-info subdomain of the platform module: the unauthenticated site-level reads (global configuration, terms of service and privacy policy, aggregate statistics, client downloads, liveness). Only the module facade may reach it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountStats added in v1.21.0

type AccountStats interface {
	AuthMethodLister
	CountEnabledUsers(ctx context.Context) (int64, error)
}

AccountStats is the read port onto the identity domain: the configured authentication methods and the number of enabled accounts.

type AuthMethodLister added in v1.21.0

type AuthMethodLister interface {
	ListAuthMethods(ctx context.Context) ([]readmodel.AuthMethod, error)
}

AuthMethodLister lists the authentication methods the identity domain has configured, as the platform's read model; the composition root adapts the identity facade to it.

type ClientApplication added in v1.21.0

type ClientApplication struct {
	Id          int64
	Name        string
	Description string
	Icon        string
	Scheme      string
	IsDefault   bool
	// DownloadLink is the JSON-encoded download link per platform.
	DownloadLink string
}

ClientApplication is a client application the public download page lists. The subscription module owns the rows; the composition root copies the fields the page shows into this platform-owned type.

type ClientApplicationLister added in v1.21.0

type ClientApplicationLister interface {
	ListClientApplications(ctx context.Context) ([]ClientApplication, error)
}

ClientApplicationLister lists the client applications in their stored order.

type Deps

type Deps struct {
	// Settings reads the stored public settings.
	Settings SettingsReader
	// Accounts and Nodes read the identity and network domains' figures.
	Accounts AccountStats
	Nodes    NodeStats
	Redis    *redis.Client
	// Config snapshots the runtime-mutable public configuration per request.
	Config func() GlobalConfigSnapshot
	// GeoIP returns the local GeoIP (City) database the node countries are
	// looked up in, or nil when none is loaded.
	GeoIP func() *geoip2.Reader
	// Resolver looks up node hostnames; nil means net.DefaultResolver.
	Resolver HostResolver
	// Clients lists the client applications of the public download page.
	Clients ClientApplicationLister
}

Deps declares the subdomain's dependencies; the module facade forwards them from the composition root.

type GlobalConfigSnapshot

type GlobalConfigSnapshot struct {
	Site      config.SiteConfig
	Subscribe config.SubscribeConfig
	Email     config.EmailConfig
	Mobile    config.MobileConfig
	Register  config.RegisterConfig
	Verify    config.Verify
	Invite    config.InviteConfig
}

GlobalConfigSnapshot is the public runtime configuration consumed when assembling the global configuration response.

type HostResolver added in v1.21.0

type HostResolver interface {
	LookupIPAddr(ctx context.Context, host string) ([]net.IPAddr, error)
}

HostResolver resolves a hostname; *net.Resolver satisfies it.

type NodeStats added in v1.21.0

type NodeStats interface {
	CountEnabledNodes(ctx context.Context) (int64, error)
	QueryServerAddresses(ctx context.Context) ([]string, error)
	QueryEnabledNodeProtocols(ctx context.Context) ([]string, error)
}

NodeStats is the read port onto the network domain: the enabled nodes, the server addresses and the protocols the nodes offer.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service is the public-info subdomain entry point used by the platform facade.

func NewService

func NewService(deps Deps) *Service

NewService builds the public-info service.

func (*Service) GetClient

GetClient lists the client applications of the public download page in their stored order. A download link that does not decode is left empty.

func (*Service) GetGlobalConfig

func (s *Service) GetGlobalConfig(ctx context.Context) (*dto.GetGlobalConfigResponse, error)

GetGlobalConfig assembles the public site configuration from the running configuration, the stored currency and verification code settings, the enabled login methods and the web ads switch. The login methods are best effort: when they cannot be read, none is listed.

func (*Service) GetPrivacyPolicy

func (s *Service) GetPrivacyPolicy(ctx context.Context) (*dto.PrivacyPolicyConfig, error)

GetPrivacyPolicy returns the privacy policy, which is stored with the terms of service.

func (*Service) GetStat

func (s *Service) GetStat(ctx context.Context) (*dto.GetStatResponse, error)

GetStat returns the public site statistics: the enabled users (rounded down), the enabled nodes, the number of countries the nodes are in and the protocols they offer. The statistics are cached for an hour in Redis and remembered in the process: while Redis is unreachable the process serves its own copy for as long as the cache would have, and a refresh that failed is not tried again for statFailureBackoff. Concurrent cache misses share one refresh, and a caller may stop waiting for it without cancelling it for the others.

func (*Service) GetTos

func (s *Service) GetTos(ctx context.Context) (*dto.GetTosResponse, error)

GetTos returns the terms of service.

func (*Service) Heartbeat

func (s *Service) Heartbeat(_ context.Context) (*dto.HeartbeatResponse, error)

Heartbeat reports that the service is alive.

type SettingsReader added in v1.21.0

type SettingsReader interface {
	GetCurrencyConfig(ctx context.Context) ([]*system.System, error)
	GetVerifyCodeConfig(ctx context.Context) ([]*system.System, error)
	// GetTosConfig reads the terms of service and the privacy policy.
	GetTosConfig(ctx context.Context) ([]*system.System, error)
	// FindOneByKey reads a single setting, such as the web ads switch.
	FindOneByKey(ctx context.Context, key string) (*system.System, error)
}

SettingsReader reads the stored settings the public pages show; the system settings repository satisfies it.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL