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
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

init.go 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. package telegram
  2. import (
  3. "context"
  4. "errors"
  5. "time"
  6. "github.com/9seconds/mtg/v2/essentials"
  7. )
  8. var errNoAddresses = errors.New("no addresses")
  9. type preferIP uint8
  10. const (
  11. preferIPOnlyIPv4 preferIP = iota
  12. preferIPOnlyIPv6
  13. preferIPPreferIPv4
  14. preferIPPreferIPv6
  15. )
  16. const (
  17. defaultDC = 2
  18. defaultUpdateDCAddressesEach = time.Hour
  19. defaultAppID = 123456
  20. defaultAppHash = ""
  21. )
  22. type loggerInterface interface {
  23. Info(msg string)
  24. WarningError(msg string, err error)
  25. }
  26. type tgAddr struct {
  27. network string
  28. address string
  29. }
  30. // https://github.com/telegramdesktop/tdesktop/blob/master/Telegram/SourceFiles/mtproto/mtproto_dc_options.cpp#L30
  31. var (
  32. defaultV4Addresses = map[int][]tgAddr{
  33. 1: {
  34. {network: "tcp4", address: "149.154.175.50:443"},
  35. },
  36. 2: {
  37. {network: "tcp4", address: "149.154.167.51:443"},
  38. {network: "tcp4", address: "95.161.76.100:443"},
  39. },
  40. 3: {
  41. {network: "tcp4", address: "149.154.175.100:443"},
  42. },
  43. 4: {
  44. {network: "tcp4", address: "149.154.167.91:443"},
  45. },
  46. 5: {
  47. {network: "tcp4", address: "149.154.171.5:443"},
  48. },
  49. }
  50. defaultV6Addresses = map[int][]tgAddr{
  51. 1: {
  52. {network: "tcp6", address: "[2001:b28:f23d:f001::a]:443"},
  53. },
  54. 2: {
  55. {network: "tcp6", address: "[2001:67c:04e8:f002::a]:443"},
  56. },
  57. 3: {
  58. {network: "tcp6", address: "[2001:b28:f23d:f003::a]:443"},
  59. },
  60. 4: {
  61. {network: "tcp6", address: "[2001:67c:04e8:f004::a]:443"},
  62. },
  63. 5: {
  64. {network: "tcp6", address: "[2001:b28:f23f:f005::a]:443"},
  65. },
  66. }
  67. )
  68. type Dialer interface {
  69. DialContext(ctx context.Context, network, address string) (essentials.Conn, error)
  70. }