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.

socks5.go 505B

1234567891011121314151617181920212223
  1. package network
  2. import (
  3. "fmt"
  4. "net/url"
  5. "time"
  6. "golang.org/x/net/proxy"
  7. )
  8. func NewSocks5Dialer(proxyUrl *url.URL, timeout time.Duration, bufferSize int) (Dialer, error) {
  9. dialer, err := NewDefaultDialer(timeout, bufferSize)
  10. if err != nil {
  11. return nil, fmt.Errorf("cannot initialize base dialer: %w", err)
  12. }
  13. rv, err := proxy.FromURL(proxyUrl, dialer.(*defaultDialer))
  14. if err != nil {
  15. return nil, fmt.Errorf("cannot initialize socks5 proxy dialer: %w", err)
  16. }
  17. return rv.(Dialer), nil
  18. }