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.

urls.go 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package config
  2. import (
  3. "encoding/hex"
  4. "net"
  5. "net/url"
  6. "strconv"
  7. )
  8. func getURLs(addr net.IP, port uint16, secret []byte) (urls URLs) {
  9. values := url.Values{}
  10. values.Set("server", addr.String())
  11. values.Set("port", strconv.Itoa(int(port)))
  12. values.Set("secret", hex.EncodeToString(secret))
  13. urls.TG = makeTGURL(values)
  14. urls.TMe = makeTMeURL(values)
  15. urls.TGQRCode = makeQRCodeURL(urls.TG)
  16. urls.TMeQRCode = makeQRCodeURL(urls.TG)
  17. return
  18. }
  19. func makeTGURL(values url.Values) string {
  20. tgURL := url.URL{
  21. Scheme: "tg",
  22. Host: "proxy",
  23. RawQuery: values.Encode(),
  24. }
  25. return tgURL.String()
  26. }
  27. func makeTMeURL(values url.Values) string {
  28. tMeURL := url.URL{
  29. Scheme: "https",
  30. Host: "t.me",
  31. Path: "proxy",
  32. RawQuery: values.Encode(),
  33. }
  34. return tMeURL.String()
  35. }
  36. func makeQRCodeURL(data string) string {
  37. QRURL := url.URL{
  38. Scheme: "https",
  39. Host: "api.qrserver.com",
  40. Path: "v1/create-qr-code",
  41. }
  42. values := url.Values{}
  43. values.Set("qzone", "4")
  44. values.Set("format", "svg")
  45. values.Set("data", data)
  46. QRURL.RawQuery = values.Encode()
  47. return QRURL.String()
  48. }