Highly-opinionated (ex-bullshit-free) MTPROTO proxy for Telegram. If you use v1.0 or upgrade broke you proxy, please read the chapter Version 2
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

raw_config.go 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package main
  2. import (
  3. "fmt"
  4. "io"
  5. "github.com/pelletier/go-toml"
  6. )
  7. type rawConfig struct {
  8. Debug bool `toml:"debug"`
  9. Secret string `toml:"secret"`
  10. BindTo string `toml:"bind-to"`
  11. TCPBuffer string `toml:"tcp-buffer"`
  12. PreferIP string `toml:"prefer-ip"`
  13. CloakPort uint `toml:"cloak-port"`
  14. Probes struct {
  15. Time struct {
  16. Enabled bool `toml:"enabled"`
  17. AllowSkewness string `toml:"allow-skewness"`
  18. } `toml:"time"`
  19. AntiReplay struct {
  20. Enabled bool `toml:"enabled"`
  21. MaxSize string `toml:"max-size"`
  22. TTL string `toml:"ttl"`
  23. } `toml:"anti-replay"`
  24. } `toml:"probes"`
  25. Network struct {
  26. PublicIP struct {
  27. IPv4 string `toml:"ipv4"`
  28. IPv6 string `toml:"ipv6"`
  29. } `toml:"public-ip"`
  30. Dialers struct {
  31. Telegram string `toml:"telegram"`
  32. Default string `toml:"default"`
  33. } `toml:"dialers"`
  34. DOHHostname string `toml:"doh-hostname"`
  35. Proxies []string `toml:"proxies"`
  36. } `toml:"network"`
  37. Stats struct {
  38. StatsD struct {
  39. Enabled bool `toml:"enabled"`
  40. Address string `toml:"address"`
  41. MetricPrefix string `toml:"metric-prefix"`
  42. } `toml:"statsd"`
  43. Prometheus struct {
  44. Enabled bool `toml:"enabled"`
  45. BindTo string `toml:"bind-to"`
  46. HttpPath string `toml:"http-path"`
  47. MetricPrefix string `toml:"metric-prefix"`
  48. } `toml:"prometheus"`
  49. } `toml:"stats"`
  50. }
  51. func parseRawConfig(reader io.Reader) (*rawConfig, error) {
  52. conf := &rawConfig{}
  53. if err := toml.NewDecoder(reader).Decode(conf); err != nil {
  54. return nil, fmt.Errorf("cannot parse config: %w", err)
  55. }
  56. return conf, nil
  57. }