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ů.

main.go 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package main
  2. import (
  3. "math/rand"
  4. "time"
  5. "github.com/alecthomas/kong"
  6. )
  7. var version = "dev" // has to be set by ldflags
  8. type CLI struct {
  9. GenerateSecret struct { // nolint: govet
  10. HostName string `arg optional help:"Hostname to use for domain fronting. Default is '${domain_front}'." name:"hostname" default:"${domain_front}"` // nolint: lll, govet
  11. Hex bool `help:"Print secret in hex encoding."`
  12. } `cmd help:"Generate new proxy secret."`
  13. Access struct { // nolint: govet
  14. ConfigPath string `arg required type:"existingfile" help:"Path to the configuration file." name:"config-path"` // nolint: lll, govet
  15. Hex bool `help:"Print secret in hex encoding."`
  16. } `cmd help:"Print access information."`
  17. Run struct { // nolint: govet
  18. ConfigPath string `arg required type:"existingfile" help:"Path to the configuration file." name:"config-path"` // nolint: lll, govet
  19. } `cmd help:"Run proxy."`
  20. Version kong.VersionFlag `help:"Print version."`
  21. }
  22. func main() {
  23. rand.Seed(time.Now().UTC().UnixNano())
  24. cli := &CLI{}
  25. ctx := kong.Parse(cli, kong.Vars{
  26. "domain_front": "amazonaws.com",
  27. "config_path": "/etc/mtg.toml",
  28. "version": version,
  29. })
  30. switch ctx.Command() {
  31. case "generate-secret":
  32. runGenerateSecret(cli)
  33. case "access <config-path>":
  34. runAccess(cli)
  35. case "run <config-path>":
  36. panic("not implemented yet")
  37. default:
  38. panic(ctx.Command())
  39. }
  40. }