Documentation
¶
Overview ¶
Package tgun provides a TCP/http(s) client with common options
Index ¶
- Variables
- func Join(s ...string) string
- type Client
- func (c *Client) Dial(network string, addr string) (net.Conn, error)
- func (c *Client) DialTCP(addr string) (net.Conn, error)
- func (c *Client) Do(req *http.Request) (*http.Response, error)
- func (c *Client) Get(url string) (*http.Response, error)
- func (c *Client) GetBytes(url string) ([]byte, error)
- func (c Client) HTTPClient() (*http.Client, error)
- func (c *Client) Join(s ...string) string
- func (c *Client) Unmarshal(url string, ptr interface{}) error
- func (c *Client) UnmarshalPost(url string, ptr interface{}, body io.Reader) error
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultProxy = "socks5://127.0.0.1:1080"
DefaultProxy is used when c.Proxy is "1080" or "socks" or "proxy" or "true" or "1"
View Source
var DefaultTimeout = time.Second * 30
DefaultTimeout is used if c.Timeout is not set
View Source
var DefaultTor = func() string { if runtime.GOOS == "windows" { return "socks5://127.0.0.1:9150" } return "socks5://127.0.0.1:9050" }()
DefaultTor proxy is used when c.Proxy is set to "tor"
View Source
var DefaultUserAgent = fmt.Sprintf("tgun/%s", version)
DefaultUserAgent is used when c.UserAgent is empty
Functions ¶
Types ¶
type Client ¶
type Client struct { DirectConnect bool // Set to true to bypass proxy Proxy string // In the format: socks5://localhost:1080 UserAgent string // In the format: "MyThing/0.1" or "MyThing/0.1 (http://example.org)" Timeout time.Duration // If unset, DefaultTimeout is used. AuthUser string AuthPassword string Headers map[string]string // contains filtered or unexported fields }
Client holds connection options
func (*Client) Do ¶
Do returns an http response. The request's config is *fortified* with http.Client, proxy, headers, authentication, and user agent.
func (Client) HTTPClient ¶
HTTPClient returns a http.Client with proxy (but no headers, auth, user-agent)
Click to show internal directories.
Click to hide internal directories.