Documentation
¶
Index ¶
- func BuildFakeTLSSecret(rawSecret, domain string, maskingEnabled bool) string
- func BuildProxyLink(serverIP string, port int, secret string) string
- func BuildWebLink(serverIP string, port int, secret string) string
- func DomainToHex(domain string) string
- func GenerateSecret() (string, error)
- func ValidateSecretKey(key string) bool
- func WriteConfigTOML(cfg *TelemtConfig, path string) error
- type AccessConfig
- type CensorshipConfig
- type ConfigParams
- type GeneralConfig
- type InstanceConfigParams
- type LinksConfig
- type ModesConfig
- type RateLimit
- type SecretEntry
- type ServerConfig
- type TelegramConfig
- type TelemtConfig
- type TimeoutsConfig
- type UpstreamConfig
- type UpstreamEntry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildFakeTLSSecret ¶
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 ¶
BuildProxyLink generates a tg://proxy link.
func BuildWebLink ¶
BuildWebLink generates a https://t.me proxy link.
func DomainToHex ¶
DomainToHex converts a domain string to its hex representation.
func GenerateSecret ¶
GenerateSecret creates a random 32-character hex secret.
func ValidateSecretKey ¶
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"`
UserRateLimits map[string]RateLimit `toml:"user_rate_limits,omitempty"`
UserEnabled map[string]bool `toml:"user_enabled,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"`
ExclusiveMask map[string]string `toml:"exclusive_mask,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
UseMiddleProxy bool
AdTag string
ProxyProtocol bool
ProxyProtocolCIDRs []string
Telegram TelegramConfig
Secrets []SecretEntry
Upstreams []UpstreamEntry
ExtraMetricsWhitelist []string
// SYN limiter (opt-in). Empty Backend = disabled.
SynlimitBackend string
SynlimitSeconds int
SynlimitHitcount int
SynlimitBurst int
}
InstanceConfigParams holds per-instance parameters for config generation.
type LinksConfig ¶
type LinksConfig struct {
Show []string `toml:"show"`
}
type ModesConfig ¶
type RateLimit ¶ added in v0.7.0
RateLimit holds per-user up/down rate limits in bits per second (0 = unlimited).
type SecretEntry ¶
type SecretEntry struct {
Label string
SecretKey string
Enabled bool
MaxConns int
MaxIPs int
QuotaBytes int64
RateLimitUpBps int64
RateLimitDownBps 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"`
ClientMSS int `toml:"client_mss,omitempty"`
ClientMSSBulk int `toml:"client_mss_bulk,omitempty"`
// SYN limiter (netfilter). Empty backend = disabled (not rendered).
Synlimit string `toml:"synlimit,omitempty"` // "nftables" | "iptables"
SynlimitSeconds int `toml:"synlimit_seconds,omitempty"`
SynlimitHitcount int `toml:"synlimit_hitcount,omitempty"`
SynlimitBurst int `toml:"synlimit_burst,omitempty"`
// Control-plane API ([server.api]). APIPort 0 = disabled (rendered enabled=false
// to override the engine's on-by-default 0.0.0.0:9091 listener). Bound to loopback.
APIPort int `toml:"-"`
}
type TelegramConfig ¶ added in v0.0.10
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 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"`
URL string `toml:"url,omitempty"`
Interface string `toml:"interface,omitempty"`
IPv4 *bool `toml:"ipv4,omitempty"`
IPv6 *bool `toml:"ipv6,omitempty"`
Prefer int `toml:"prefer,omitempty"`
BindToDevice string `toml:"bindtodevice,omitempty"`
}
type UpstreamEntry ¶
type UpstreamEntry struct {
Type model.UpstreamType
Address string
Username string
Password string
URL string // shadowsocks ss:// URL (shadowsocks type only)
Weight int
Iface string
Enabled bool
IPv4 *bool
IPv6 *bool
Prefer int
BindToDevice string
}
UpstreamEntry represents an upstream for TOML generation.