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
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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. AccessFile string `toml:"access-file"`
  15. Probes struct {
  16. Time struct {
  17. Enabled bool `toml:"enabled"`
  18. AllowSkewness string `toml:"allow-skewness"`
  19. } `toml:"time"`
  20. AntiReplay struct {
  21. Enabled bool `toml:"enabled"`
  22. MaxSize string `toml:"max-size"`
  23. TTL string `toml:"ttl"`
  24. } `toml:"anti-replay"`
  25. } `toml:"probes"`
  26. Network struct {
  27. PublicIP struct {
  28. IPv4 string `toml:"ipv4"`
  29. IPv6 string `toml:"ipv6"`
  30. } `toml:"public-ip"`
  31. Dialers struct {
  32. Telegram string `toml:"telegram"`
  33. Default string `toml:"default"`
  34. } `toml:"dialers"`
  35. DOHHostname string `toml:"doh-hostname"`
  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. }