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.

cli.go 633B

123456789101112131415161718192021222324252627282930313233343536
  1. package main
  2. import (
  3. "fmt"
  4. "io/ioutil"
  5. "github.com/9seconds/mtg/v2/config"
  6. "github.com/9seconds/mtg/v2/mtglib/network"
  7. )
  8. type cli struct {
  9. network network.Network
  10. conf *config.Config
  11. }
  12. func (c *cli) ReadConfig(path string) error {
  13. content, err := ioutil.ReadFile(path)
  14. if err != nil {
  15. return fmt.Errorf("cannot read config file: %w", err)
  16. }
  17. conf, err := config.Parse(content)
  18. if err != nil {
  19. return fmt.Errorf("cannot parse config: %w", err)
  20. }
  21. ntw, err := makeNetwork(conf)
  22. if err != nil {
  23. return fmt.Errorf("cannot build a network: %w", err)
  24. }
  25. c.conf = conf
  26. c.network = ntw
  27. return nil
  28. }