mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 17:54:01 +03:00
Rename dialers into network
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
package network
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
"time"
|
||||
|
||||
"golang.org/x/net/proxy"
|
||||
)
|
||||
|
||||
func NewSocks5Dialer(proxyUrl *url.URL, timeout time.Duration, bufferSize int) (Dialer, error) {
|
||||
dialer, err := NewDefaultDialer(timeout, bufferSize)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot initialize base dialer: %w", err)
|
||||
}
|
||||
|
||||
rv, err := proxy.FromURL(proxyUrl, dialer.(*defaultDialer))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot initialize socks5 proxy dialer: %w", err)
|
||||
}
|
||||
|
||||
return rv.(Dialer), nil
|
||||
}
|
||||
Reference in New Issue
Block a user