Documentation
¶
Index ¶
- Constants
- Variables
- func ConfigDir() string
- func DefaultSSHKeyPath() string
- func DefaultSSHLogPath() string
- func TelemtCommit() string
- func TelemtRepo() string
- func TelemtVersion() string
- func ValidateLabel(label string) error
- func VersionURL() string
- type GlobalTraffic
- type Instance
- type InstanceStatus
- type LiveMetrics
- type ProxyStatus
- type Secret
- type SecretWithLink
- type Settings
- type Slave
- type SlaveTestResult
- type TrafficReport
- type TrafficSnapshot
- type Upstream
- type UpstreamTestResult
- type UpstreamType
- type UserLiveMetrics
- type UserTraffic
Constants ¶
const ( ContainerName = "popugate" DockerImageBase = "popugate-telemt" DefaultTelemtVer = "3.3.39" DefaultTelemtRef = "bc69153" DefaultTelemtURL = "https://github.com/telemt/telemt.git" RegistryImage = "ghcr.io/fussraider/popugate-telemt" GitHubRepo = "fussraider/PopuGate" MaxSecrets = 1000 SecretKeyLen = 32 // hex chars )
Constants for the application.
Variables ¶
var Commit = "unknown"
Commit is the full git SHA, overridden at build time via -ldflags "-X main.commit=..."
var InstallDir = "/opt/popugate"
InstallDir is the base data directory. Overridden at startup from the POPUGATE_DATA_DIR env var or the binary's directory.
var Version = "dev"
Version is overridden at build time via -ldflags "-X main.version=..."
Functions ¶
func DefaultSSHKeyPath ¶
func DefaultSSHKeyPath() string
DefaultSSHKeyPath returns the default SSH key location.
func DefaultSSHLogPath ¶
func DefaultSSHLogPath() string
DefaultSSHLogPath returns the default replication log location.
func TelemtCommit ¶
func TelemtCommit() string
TelemtCommit returns the telemt commit/ref from env or default.
func TelemtRepo ¶
func TelemtRepo() string
TelemtRepo returns the telemt repository URL from env or default.
func TelemtVersion ¶
func TelemtVersion() string
TelemtVersion returns the telemt version from env or default.
func ValidateLabel ¶
ValidateLabel checks that a label is valid.
func VersionURL ¶ added in v0.0.2
func VersionURL() string
VersionURL returns a GitHub URL for the current version: release page for tags, commit page for SHAs, or the repo root as fallback.
Types ¶
type GlobalTraffic ¶
GlobalTraffic holds cumulative global traffic.
type Instance ¶
type Instance struct {
ID int64 `json:"id" db:"id"`
Port int `json:"port" db:"port"`
MetricsPort int `json:"metrics_port" db:"metrics_port"`
Enabled bool `json:"enabled" db:"enabled"`
Label string `json:"label" db:"label"`
}
Instance represents a multi-port proxy instance.
func (*Instance) ConfigPath ¶
ConfigPath returns the TOML config file path for this instance.
func (*Instance) ContainerName ¶
ContainerName returns the Docker container name for this instance.
type InstanceStatus ¶
type InstanceStatus struct {
Port int `json:"port"`
Running bool `json:"running"`
Label string `json:"label"`
}
InstanceStatus for multi-port instances.
type LiveMetrics ¶
type LiveMetrics struct {
UptimeSeconds float64 `json:"uptime_seconds"`
ConnsCurrent float64 `json:"conns_current"`
ConnsTotal float64 `json:"conns_total"`
ConnsBadTotal float64 `json:"conns_bad_total"`
ConnsMECurrent float64 `json:"conns_me_current"`
ConnsDirectCurrent float64 `json:"conns_direct_current"`
UpstreamAttemptTotal float64 `json:"upstream_attempt_total"`
UpstreamSuccessTotal float64 `json:"upstream_success_total"`
UpstreamFailTotal float64 `json:"upstream_fail_total"`
MEWritersActive float64 `json:"me_writers_active"`
MEWritersWarm float64 `json:"me_writers_warm"`
UserMetrics map[string]*UserLiveMetrics `json:"users"`
}
LiveMetrics holds parsed Prometheus metrics from the telemt engine.
type ProxyStatus ¶
type ProxyStatus struct {
Running bool `json:"running"`
Port int `json:"port"`
Uptime string `json:"uptime,omitempty"`
UptimeSeconds int64 `json:"uptime_seconds,omitempty"`
ContainerID string `json:"container_id,omitempty"`
StartedAt time.Time `json:"started_at,omitempty"`
ConnsCurrent int `json:"conns_current,omitempty"`
ConnsTotal int64 `json:"conns_total,omitempty"`
TrafficIn int64 `json:"traffic_in,omitempty"`
TrafficOut int64 `json:"traffic_out,omitempty"`
Instances []InstanceStatus `json:"instances,omitempty"`
}
ProxyStatus represents the current state of the proxy.
type Secret ¶
type Secret struct {
ID int64 `json:"id" db:"id"`
Label string `json:"label" db:"label"`
SecretKey string `json:"secret_key" db:"secret_key"`
CreatedAt int64 `json:"created_at" db:"created_at"`
Enabled bool `json:"enabled" db:"enabled"`
MaxConns int `json:"max_conns" db:"max_conns"`
MaxIPs int `json:"max_ips" db:"max_ips"`
QuotaBytes int64 `json:"quota_bytes" db:"quota_bytes"`
ExpiresAt string `json:"expires_at" db:"expires_at"`
Notes string `json:"notes" db:"notes"`
// Computed fields (not in DB)
TrafficIn int64 `json:"traffic_in,omitempty" db:"-"`
TrafficOut int64 `json:"traffic_out,omitempty" db:"-"`
}
Secret represents an MTProto proxy secret key with per-user limits.
func (*Secret) ExpiryWarning ¶
ExpiryWarning returns true if the secret expires within the given duration.
func (*Secret) QuotaExceeded ¶
QuotaExceeded returns true if traffic exceeds the quota.
func (*Secret) QuotaPercent ¶
QuotaPercent returns used quota as percentage (0 if no quota set).
func (*Secret) QuotaWarning ¶
QuotaWarning returns true if traffic is at or above 80% of quota.
type SecretWithLink ¶
type SecretWithLink struct {
Secret
TGLink string `json:"tg_link,omitempty"`
WebLink string `json:"web_link,omitempty"`
}
SecretWithLink extends Secret with proxy link info.
type Settings ¶
type Settings struct {
// Proxy
ProxyPort int `json:"proxy_port"`
ProxyMetricsPort int `json:"proxy_metrics_port"`
ProxyDomain string `json:"proxy_domain"`
ProxyConcurrency int `json:"proxy_concurrency"`
ProxyCPUs string `json:"proxy_cpus"`
ProxyMemory string `json:"proxy_memory"`
CustomIP string `json:"custom_ip"`
FakeCertLen int `json:"fake_cert_len"`
ProxyProtocol bool `json:"proxy_protocol"`
ProxyProtocolTrustedCIDRs string `json:"proxy_protocol_trusted_cidrs"`
// Ad tag
AdTag string `json:"ad_tag"`
// Geo-blocking
GeoblockMode string `json:"geoblock_mode"`
BlocklistCountries string `json:"blocklist_countries"`
// Traffic masking
MaskingEnabled bool `json:"masking_enabled"`
MaskingHost string `json:"masking_host"`
MaskingPort int `json:"masking_port"`
UnknownSNIAction string `json:"unknown_sni_action"`
// Telegram
TelegramEnabled bool `json:"telegram_enabled"`
TelegramBotToken string `json:"telegram_bot_token"`
TelegramChatID string `json:"telegram_chat_id"`
TelegramInterval int `json:"telegram_interval"`
TelegramAlertsEnabled bool `json:"telegram_alerts_enabled"`
TelegramServerLabel string `json:"telegram_server_label"`
// Auto-update
AutoUpdateEnabled bool `json:"auto_update_enabled"`
// Replication
ReplicationEnabled bool `json:"replication_enabled"`
ReplicationRole string `json:"replication_role"`
ReplicationSyncInterval int `json:"replication_sync_interval"`
ReplicationSSHPort int `json:"replication_ssh_port"`
ReplicationSSHUser string `json:"replication_ssh_user"`
ReplicationDeleteExtra bool `json:"replication_delete_extra"`
ReplicationSSHKeyPath string `json:"replication_ssh_key_path"`
ReplicationExclude string `json:"replication_exclude"`
ReplicationRestartOnChange bool `json:"replication_restart_on_change"`
ReplicationLog string `json:"replication_log"`
Debug bool `json:"debug"`
// telemt engine
TelemtVersion string `json:"telemt_version"`
TelemtCommit string `json:"telemt_commit"`
TelemtRepo string `json:"telemt_repo"`
}
Settings holds all application configuration. Maps to the key-value settings table in SQLite.
func DefaultSettings ¶
func DefaultSettings() Settings
Defaults returns a Settings struct populated with default values.
func (*Settings) SSHKeyPath ¶
SSHKeyPath returns current SSH key path or default if empty.
func (*Settings) SSHLogPath ¶
SSHLogPath returns current replication log path or default if empty.
type Slave ¶
type Slave struct {
ID int64 `json:"id" db:"id"`
Host string `json:"host" db:"host"`
Port int `json:"port" db:"port"`
Label string `json:"label" db:"label"`
Enabled bool `json:"enabled" db:"enabled"`
LastSync int64 `json:"last_sync" db:"last_sync"`
Status string `json:"status" db:"status"`
}
Slave represents a replication slave server.
type SlaveTestResult ¶
type SlaveTestResult struct {
Host string `json:"host"`
SSHOK bool `json:"ssh_ok"`
DockerStatus string `json:"docker_status,omitempty"`
Error string `json:"error,omitempty"`
}
SlaveTestResult holds the result of an SSH connectivity test.
type TrafficReport ¶
type TrafficReport struct {
Global GlobalTraffic `json:"global"`
Users []UserTraffic `json:"users"`
}
TrafficReport combines global and per-user traffic.
type TrafficSnapshot ¶
type TrafficSnapshot struct {
BytesIn int64 `json:"bytes_in"`
BytesOut int64 `json:"bytes_out"`
SnapIn int64 `json:"snap_in"`
SnapOut int64 `json:"snap_out"`
}
TrafficSnapshot represents a point-in-time traffic reading.
type Upstream ¶
type Upstream struct {
ID int64 `json:"id" db:"id"`
Name string `json:"name" db:"name"`
Type UpstreamType `json:"type" db:"type"`
Address string `json:"address" db:"address"`
Username string `json:"username" db:"username"`
Password string `json:"password" db:"password"`
Weight int `json:"weight" db:"weight"`
Iface string `json:"iface" db:"iface"`
Enabled bool `json:"enabled" db:"enabled"`
}
Upstream represents a proxy upstream configuration.
type UpstreamTestResult ¶
type UpstreamTestResult struct {
OK bool `json:"ok"`
ExitIP string `json:"exit_ip,omitempty"`
LatencyMs int64 `json:"latency_ms,omitempty"`
Error string `json:"error,omitempty"`
}
UpstreamTestResult holds the result of a connectivity test.
type UpstreamType ¶
type UpstreamType string
UpstreamType defines the proxy upstream type.
const ( UpstreamDirect UpstreamType = "direct" UpstreamSOCKS5 UpstreamType = "socks5" UpstreamSOCKS4 UpstreamType = "socks4" )
type UserLiveMetrics ¶
type UserLiveMetrics struct {
OctetsFromClient float64 `json:"octets_from_client"`
OctetsToClient float64 `json:"octets_to_client"`
Connections float64 `json:"connections"`
UniqueIPs float64 `json:"unique_ips"`
}
UserLiveMetrics holds per-user live Prometheus metrics.
type UserTraffic ¶
type UserTraffic struct {
Label string `json:"label"`
BytesIn int64 `json:"bytes_in"`
BytesOut int64 `json:"bytes_out"`
}
UserTraffic holds per-user traffic stats.