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
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

init.go 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Network contains a default implementation of the network.
  2. //
  3. // Please see [mtglib.Network] interface to get some basic idea behind this
  4. // abstraction.
  5. //
  6. // This implementation is more simple that v1 because life shows that all
  7. // this complexity, especially around circuit breakers and DoH is not really
  8. // required. There is no chance that if DNS address is spoofed, that real
  9. // IP would work as expected.
  10. package network
  11. import (
  12. "errors"
  13. "net"
  14. "time"
  15. "github.com/9seconds/mtg/v2/mtglib"
  16. )
  17. const (
  18. // DefaultTimeout is a default timeout for establishing TCP connection.
  19. DefaultTimeout = 10 * time.Second
  20. // DefaultHTTPTimeout defines a default timeout for making HTTP request.
  21. DefaultHTTPTimeout = 10 * time.Second
  22. // DefaultIdleTimeout defines a timeout for idle HTTP connections
  23. DefaultIdleTimeout = time.Minute
  24. // DefaultTCPKeepAlivePeriod defines a time period between 2 consecuitive
  25. // probes.
  26. DefaultTCPKeepAlivePeriod = 10 * time.Second
  27. // tcpLingerTimeout defines a number of seconds to wait for sending
  28. // unacknowledged data.
  29. tcpLingerTimeout = 1
  30. )
  31. var ErrCannotDial = errors.New("cannot dial to any address")
  32. type Network interface {
  33. mtglib.Network
  34. NativeDialer() *net.Dialer
  35. }