proxyclient

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2024 License: LGPL-3.0 Imports: 18 Imported by: 0

README

Supported

  • HTTP
  • HTTPS
  • SOCKS4
  • SOCKS4A
  • SOCKS5
  • SSH
  • ShadowSocks
  • VMess

Example

package main

import (
	"fmt"
	"github.com/dneht/proxyclient"
	"io"
	"net/http"
)

func main() {
	//http://localhost:1800
	//socks://localhost:1800
	//ss://localhost:1800
	//vmess://localhost:1800
	proxy, err := proxyclient.New("ssh://localhost:22", &proxyclient.Option{
		User: &proxyclient.UserOption{},
		SSH: &proxyclient.SSHOption{
			Name: "user",
		},
		SS: &proxyclient.SSOption{
			Method:   "cipher",
			Password: "pwd",
		},
		VMess: &proxyclient.VMessOption{
			UUID:     "uuid",
			Security: "auto",
			AlterId:  0,
		},
	})
	if err != nil {
		panic(err)
	}
	client := &http.Client{
		Transport: &http.Transport{
			DialContext: proxy.DialContext,
		},
	}
	request, err := client.Get("https://httpbin.org/get")
	if err != nil {
		panic(err)
	}
	content, err := io.ReadAll(request.Body)
	if err != nil {
		panic(err)
	}
	fmt.Println(string(content))
}

Documentation

Index

Constants

View Source
const (
	SchemeHTTP    = "http"
	SchemeHTTPS   = "https"
	SchemeSocks   = "socks"
	SchemeSocks4  = "socks4"
	SchemeSocks4a = "socks4a"
	SchemeSocks5  = "socks5"
	SchemeSSH     = "ssh"
	SchemeSS      = "ss"
	SchemeVMess   = "vmess"
)
View Source
const MbpsToBps = 125000

Variables

This section is empty.

Functions

func NewMux

func NewMux(dialer N.Dialer, logger L.Logger, option *MuxOption) (*mux.Client, error)

func NewUot

func NewUot(dialer N.Dialer, version int) *uot.Client

Types

type BrutalOptions

type BrutalOptions struct {
	Enabled  bool `json:"enabled,omitempty"`
	UpMbps   int  `json:"up_mbps,omitempty"`
	DownMbps int  `json:"down_mbps,omitempty"`
}

type MuxOption

type MuxOption struct {
	Enabled        bool           `json:"enabled"`
	Protocol       string         `json:"protocol,omitempty"`
	MaxConnections int            `json:"max_connections,omitempty"`
	MinStreams     int            `json:"min_streams,omitempty"`
	MaxStreams     int            `json:"max_streams,omitempty"`
	Padding        bool           `json:"padding,omitempty"`
	Brutal         *BrutalOptions `json:"brutal,omitempty"`
}

type Option

type Option struct {
	Mux   *MuxOption
	User  *UserOption
	SSH   *SSHOption
	SS    *SSOption
	VMess *VMessOption
}

type Proxy

type Proxy struct {
	// contains filtered or unexported fields
}

func New

func New(url string, option *Option) (*Proxy, error)

func NewWithLogger

func NewWithLogger(url string, log L.Logger, option *Option) (*Proxy, error)

func (*Proxy) DialContext

func (p *Proxy) DialContext(ctx context.Context, network, addr string) (net.Conn, error)

type ProxyDialer

type ProxyDialer struct {
	// contains filtered or unexported fields
}

func (*ProxyDialer) DialContext

func (d *ProxyDialer) DialContext(ctx context.Context, network string, dest M.Socksaddr) (net.Conn, error)

func (*ProxyDialer) ListenPacket

func (d *ProxyDialer) ListenPacket(ctx context.Context, dest M.Socksaddr) (net.PacketConn, error)

type SSHOption

type SSHOption struct {
	Name     string `json:"name"`
	Passwd   string `json:"passwd,omitempty"`
	PkFile   string `json:"pk_file,omitempty"`
	PkPasswd string `json:"pk_passwd,omitempty"`
}

type SSOption

type SSOption struct {
	Method   string `json:"method"`
	Password string `json:"password"`
}

type UserOption

type UserOption struct {
	Name   string `json:"name,omitempty"`
	Passwd string `json:"passwd,omitempty"`
}

type VMessOption

type VMessOption struct {
	UUID                string `json:"uuid"`
	Security            string `json:"security"`
	AlterId             int    `json:"alter_id,omitempty"`
	GlobalPadding       bool   `json:"global_padding,omitempty"`
	AuthenticatedLength bool   `json:"authenticated_length,omitempty"`
}

Jump to

Keyboard shortcuts

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