proxyclient

package module
v0.0.0-...-7130883 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 11, 2024 License: GPL-3.0 Imports: 15 Imported by: 6

README

ProxyClient

the proxy client library

supported SOCKS4, SOCKS4A, SOCKS5, HTTP, HTTPS etc proxy protocols

Supported Schemes

  • Direct
  • Reject
  • Blackhole
  • HTTP
  • HTTPS
  • SOCKS4
  • SOCKS4A
  • SOCKS5
  • SOCKS5 with TLS
  • ShadowSocks
  • SSH Agent
  • VMess

Documentation

The full documentation is available on Godoc.

Example

package main

import (
	"fmt"
	"io/ioutil"
	"net/http"
	"net/url"
	"github.com/RouterScript/ProxyClient"
)

func main() {
	proxy, _ := url.Parse("http://localhost:8080")
	dial, _ := proxyclient.NewClient(proxy)
	client := &http.Client{
		Transport: &http.Transport{
			DialContext: dial.Context,
		},
	}
	request, err := client.Get("http://www.example.com")
	if err != nil {
		panic(err)
	}
	content, err := ioutil.ReadAll(request.Body)
	if err != nil {
		panic(err)
	}
	fmt.Println(string(content))
}

Reference

see http://github.com/GameXG/ProxyClient

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterScheme

func RegisterScheme(schemeName string, factory DialFactory)

func SupportedSchemes

func SupportedSchemes() []string

Types

type Dial

type Dial func(network, address string) (net.Conn, error)

func DialWithTimeout

func DialWithTimeout(timeout time.Duration) Dial

func NewClient

func NewClient(proxy *url.URL) (Dial, error)

func NewClientChain

func NewClientChain(proxies []*url.URL) (Dial, error)

func NewClientChainWithDial

func NewClientChainWithDial(proxies []*url.URL, upstreamDial Dial) (dial Dial, err error)

func NewClientWithDial

func NewClientWithDial(proxy *url.URL, upstreamDial Dial) (_ Dial, err error)

func (Dial) Context

func (dial Dial) Context(ctx context.Context, network, address string) (net.Conn, error)

func (Dial) Dial

func (dial Dial) Dial(network, address string) (net.Conn, error)

func (Dial) TCPOnly

func (dial Dial) TCPOnly(network, address string) (net.Conn, error)

type DialFactory

type DialFactory func(*url.URL, Dial) (Dial, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL