telemt

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 13, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildFakeTLSSecret

func BuildFakeTLSSecret(rawSecret, domain string, maskingEnabled bool) string

BuildFakeTLSSecret constructs the full FakeTLS secret for sharing. Format: ee + raw_secret + domain_hex (when masking enabled) Format: dd + raw_secret (when masking disabled)

func BuildProxyLink(serverIP string, port int, secret string) string

BuildProxyLink generates a tg://proxy link.

func BuildWebLink(serverIP string, port int, secret string) string

BuildWebLink generates a https://t.me proxy link.

func DomainToHex

func DomainToHex(domain string) string

DomainToHex converts a domain string to its hex representation.

func GenerateSecret

func GenerateSecret() (string, error)

GenerateSecret creates a random 32-character hex secret.

func ValidateSecretKey

func ValidateSecretKey(key string) bool

ValidateSecretKey checks if a secret key is valid (32 hex chars).

func WriteConfigTOML

func WriteConfigTOML(cfg *TelemtConfig, path string) error

WriteConfigTOML writes the TOML configuration to a file atomically.

Types

type AccessConfig

type AccessConfig struct {
	ReplayCheckLen   int               `toml:"replay_check_len"`
	ReplayWindowSecs int               `toml:"replay_window_secs"`
	IgnoreTimeSkew   bool              `toml:"ignore_time_skew"`
	Users            map[string]string `toml:"users"`
	UserMaxTCPConns  map[string]int    `toml:"user_max_tcp_conns,omitempty"`
	UserMaxUniqueIPs map[string]int    `toml:"user_max_unique_ips,omitempty"`
	UserDataQuota    map[string]int64  `toml:"user_data_quota,omitempty"`
	UserExpirations  map[string]string `toml:"user_expirations,omitempty"`
}

type CensorshipConfig

type CensorshipConfig struct {
	TLSDomain         string   `toml:"tls_domain"`
	TLSDomains        []string `toml:"tls_domains,omitempty"`
	UnknownSNIAction  string   `toml:"unknown_sni_action"`
	Mask              bool     `toml:"mask"`
	MaskPort          int      `toml:"mask_port"`
	MaskHost          string   `toml:"mask_host,omitempty"`
	MaskRelayMaxBytes int64    `toml:"mask_relay_max_bytes,omitempty"`
	FakeCertLen       int      `toml:"fake_cert_len"`
	TLSEmulation      bool     `toml:"tls_emulation"`
	TLSFrontDir       string   `toml:"tls_front_dir,omitempty"`
}

type ConfigParams

type ConfigParams struct {
	Settings              *model.Settings
	Secrets               []SecretEntry
	Upstreams             []UpstreamEntry
	ExtraMetricsWhitelist []string
}

ConfigParams holds the parameters needed to generate a telemt config.

type GeneralConfig

type GeneralConfig struct {
	PreferIPv6     bool        `toml:"prefer_ipv6"`
	FastMode       bool        `toml:"fast_mode"`
	UseMiddleProxy bool        `toml:"use_middle_proxy"`
	LogLevel       string      `toml:"log_level"`
	AdTag          string      `toml:"ad_tag,omitempty"`
	Modes          ModesConfig `toml:"modes"`
	Links          LinksConfig `toml:"links"`
}

type InstanceConfigParams added in v0.1.0

type InstanceConfigParams struct {
	Instance              *model.Instance
	DockerImage           string
	FakeCertLen           int
	AdTag                 string
	ProxyProtocol         bool
	ProxyProtocolCIDRs    []string
	Telegram              TelegramConfig
	Secrets               []SecretEntry
	Upstreams             []UpstreamEntry
	ExtraMetricsWhitelist []string
}

InstanceConfigParams holds per-instance parameters for config generation.

type LinksConfig

type LinksConfig struct {
	Show []string `toml:"show"`
}

type ModesConfig

type ModesConfig struct {
	Classic bool `toml:"classic"`
	Secure  bool `toml:"secure"`
	TLS     bool `toml:"tls"`
}

type SecretEntry

type SecretEntry struct {
	Label      string
	SecretKey  string
	Enabled    bool
	MaxConns   int
	MaxIPs     int
	QuotaBytes int64
	ExpiresAt  string
}

SecretEntry represents a secret for TOML generation.

type ServerConfig

type ServerConfig struct {
	Port                      int      `toml:"port"`
	ListenAddrIPv4            string   `toml:"listen_addr_ipv4"`
	ListenAddrIPv6            string   `toml:"listen_addr_ipv6"`
	ProxyProtocol             bool     `toml:"proxy_protocol"`
	ProxyProtocolTrustedCIDRs []string `toml:"proxy_protocol_trusted_cidrs,omitempty"`
	MetricsListen             string   `toml:"metrics_listen"`
	MetricsWhitelist          []string `toml:"metrics_whitelist"`
}

type TelegramConfig added in v0.0.10

type TelegramConfig struct {
	ProxySecretURL   string `toml:"proxy_secret_url,omitempty"`
	ProxyConfigV4URL string `toml:"proxy_config_v4_url,omitempty"`
	ProxyConfigV6URL string `toml:"proxy_config_v6_url,omitempty"`
}

type TelemtConfig

type TelemtConfig struct {
	General    GeneralConfig    `toml:"general"`
	Server     ServerConfig     `toml:"server"`
	Timeouts   TimeoutsConfig   `toml:"timeouts"`
	Censorship CensorshipConfig `toml:"censorship"`
	Access     AccessConfig     `toml:"access"`
	Upstreams  []UpstreamConfig `toml:"upstreams,omitempty"`
	Telegram   TelegramConfig   `toml:"telegram,omitempty"`
}

TelemtConfig represents the full TOML configuration for the telemt engine.

func BuildConfig

func BuildConfig(params *ConfigParams) *TelemtConfig

BuildConfig constructs the telemt TOML configuration (legacy: from global settings).

func BuildInstanceConfig added in v0.1.0

func BuildInstanceConfig(params *InstanceConfigParams) *TelemtConfig

BuildInstanceConfig constructs a telemt TOML config for a specific instance.

type TimeoutsConfig

type TimeoutsConfig struct {
	ClientHandshake int `toml:"client_handshake"`
	TGConnect       int `toml:"tg_connect"`
	ClientKeepalive int `toml:"client_keepalive"`
	ClientAck       int `toml:"client_ack"`
}

type UpstreamConfig

type UpstreamConfig struct {
	Type      string `toml:"type"`
	Weight    int    `toml:"weight"`
	Address   string `toml:"address,omitempty"`
	Username  string `toml:"username,omitempty"`
	Password  string `toml:"password,omitempty"`
	UserID    string `toml:"user_id,omitempty"`
	Interface string `toml:"interface,omitempty"`
}

type UpstreamEntry

type UpstreamEntry struct {
	Type     model.UpstreamType
	Address  string
	Username string
	Password string
	Weight   int
	Iface    string
	Enabled  bool
}

UpstreamEntry represents an upstream for TOML generation.

Jump to

Keyboard shortcuts

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