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.

123456789101112131415161718192021222324252627282930313233343536373839
  1. package proxyprotocol
  2. import (
  3. "errors"
  4. "syscall"
  5. "github.com/pires/go-proxyproto"
  6. )
  7. type connWrapper struct {
  8. *proxyproto.Conn
  9. }
  10. func (c connWrapper) CloseRead() error {
  11. tcpConn, ok := c.TCPConn()
  12. if !ok {
  13. panic("we support only tcp connections")
  14. }
  15. return tcpConn.CloseRead()
  16. }
  17. func (c connWrapper) CloseWrite() error {
  18. tcpConn, ok := c.TCPConn()
  19. if !ok {
  20. panic("we support only tcp connections")
  21. }
  22. return tcpConn.CloseWrite()
  23. }
  24. func (c connWrapper) SyscallConn() (syscall.RawConn, error) {
  25. tcpConn, ok := c.TCPConn()
  26. if !ok {
  27. return nil, errors.New("proxy protocol connection is not TCP")
  28. }
  29. return tcpConn.SyscallConn()
  30. }