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
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

raw_config.go 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. 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. Stats struct {
  35. StatsD struct {
  36. Enabled bool `toml:"enabled"`
  37. Address string `toml:"address"`
  38. MetricPrefix string `toml:"metric-prefix"`
  39. } `toml:"statsd"`
  40. Prometheus struct {
  41. Enabled bool `toml:"enabled"`
  42. BindTo string `toml:"bind-to"`
  43. HttpPath string `toml:"http-path"`
  44. MetricPrefix string `toml:"metric-prefix"`
  45. } `toml:"prometheus"`
  46. } `toml:"stats"`
  47. }
  48. func parseRawConfig(reader io.Reader) (*rawConfig, error) {
  49. conf := &rawConfig{}
  50. if err := toml.NewDecoder(reader).Decode(conf); err != nil {
  51. return nil, fmt.Errorf("cannot parse config: %w", err)
  52. }
  53. return conf, nil
  54. }