telemt

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: May 1, 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"`
	UnknownSNIAction string `toml:"unknown_sni_action"`
	Mask             bool   `toml:"mask"`
	MaskPort         int    `toml:"mask_port"`
	MaskHost         string `toml:"mask_host,omitempty"`
	FakeCertLen      int    `toml:"fake_cert_len"`
}

type ConfigParams

type ConfigParams struct {
	Settings              *model.Settings
	Secrets               []SecretEntry
	Upstreams             []UpstreamEntry
	ExtraMetricsWhitelist []string // Additional IPs to allow in metrics_whitelist (e.g. Docker bridge IPs)
}

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 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"`
	MetricsPort               int      `toml:"metrics_port"`
	MetricsWhitelist          []string `toml:"metrics_whitelist"`
}

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"`
}

TelemtConfig represents the full TOML configuration for the telemt engine.

func BuildConfig

func BuildConfig(params *ConfigParams) *TelemtConfig

BuildConfig constructs the telemt TOML configuration.

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