socks

A SOCKS (SOCKS4, SOCKS4A and SOCKS5) Proxy Package for Go

Github stars Tracking Chart

SOCKS

GoDoc

SOCKS is a SOCKS4, SOCKS4A and SOCKS5 proxy package for Go.

Quick Start

Get the package

go get -u "h12.io/socks"

Import the package

import "h12.io/socks"

Create a SOCKS proxy dialing function

dialSocksProxy := socks.Dial("socks5://127.0.0.1:1080?timeout=5s")
tr := &http.Transport{Dial: dialSocksProxy}
httpClient := &http.Client{Transport: tr}

Example

package main

import (
	"fmt"
	"io/ioutil"
	"log"
	"net/http"

	"h12.io/socks"
)

func main() {
	dialSocksProxy := socks.Dial("socks5://127.0.0.1:1080?timeout=5s")
	tr := &http.Transport{Dial: dialSocksProxy}
	httpClient := &http.Client{Transport: tr}
	resp, err := httpClient.Get("http://www.google.com")
	if err != nil {
		log.Fatal(err)
	}
	defer resp.Body.Close()
	if resp.StatusCode != http.StatusOK {
		log.Fatal(resp.StatusCode)
	}
	buf, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(string(buf))
}

Main metrics

Overview
Name With Ownerh12w/socks
Primary LanguageGo
Program languageGo (Language Count: 1)
Platform
License:BSD 2-Clause "Simplified" License
所有者活动
Created At2012-07-31 09:10:22
Pushed At2022-10-17 09:28:32
Last Commit At2022-10-17 10:28:32
Release Count4
Last Release Namev1.0.3 (Posted on 2021-08-06 16:28:25)
First Release Namev1.0.0 (Posted on )
用户参与
Stargazers Count520
Watchers Count25
Fork Count107
Commits Count39
Has Issues Enabled
Issues Count14
Issue Open Count1
Pull Requests Count4
Pull Requests Open Count0
Pull Requests Close Count3
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private