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
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

main.go 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 {
  10. HostName string `arg optional help:"Hostname to use for domain fronting. Default is '${domain_front}'." name:"hostname" default:"${domain_front}"`
  11. Hex bool `help:"Print secret in hex encoding."`
  12. } `cmd help:"Generate new proxy secret."`
  13. Access struct {
  14. ConfigPath string `arg required type:"existingfile" help:"Path to the configuration file." name:"config-path"`
  15. Hex bool `help:"Print secret in hex encoding."`
  16. } `cmd help:"Print access information."`
  17. Run struct {
  18. ConfigPath string `arg required type:"existingfile" help:"Path to the configuration file." name:"config-path"`
  19. } `cmd help:"Run proxy."`
  20. }
  21. func main() {
  22. rand.Seed(time.Now().UTC().UnixNano())
  23. cli := &CLI{}
  24. ctx := kong.Parse(cli, kong.Vars{
  25. "domain_front": "amazonaws.com",
  26. "config_path": "/etc/mtg.toml",
  27. })
  28. switch ctx.Command() {
  29. case "generate-secret":
  30. runGenerateSecret(cli)
  31. case "access <config-path>":
  32. runAccess(cli)
  33. case "run <config-path>":
  34. panic("not implemented yet")
  35. default:
  36. panic(ctx.Command())
  37. }
  38. }