Giter Club home page Giter Club logo

gsocks5's Introduction

gsocks5

Go Report Card License

A simple socks5 server and client implemented in Golang

Feature

  • Support socks5 server and client
  • Support TCP(CONNECT) and UDP(ASSOCIATE)
  • Support No and USERNAME/PASSWORD authentication
  • Support YAML configuration

Installation

Go mod:

go get github.com/josexy/gsocks5

Git clone:

git clone https://github.com/josexy/gsocks5.git
cd gsocks5

Example

You can find all examples in the gsocks5/example directory

server

run socks5 server

go run example/server/main.go -c config.yaml

code example

package main

import (
	"github.com/josexy/gsocks5/socks"
)

func main() {
	svr := socks.NewSocks5Server(":10086")
	defer svr.Close()
	svr.Start()
}

client

run socks5 client

go run example/tcp_client/main.go

or curl command tool

curl -v --socks5 127.0.0.1:10086 -U test:12345678 https://www.google.com
curl -v --socks5 127.0.0.1:10086 https://www.google.com

or Chrome extension Proxy SwitchyOmega

code example

package main

import (
	"context"
	"fmt"
	"io"
	"net"
	"net/http"
	"time"

	"github.com/josexy/gsocks5/socks"
)

func main() {
	proxyCli := socks.NewSocks5Client("127.0.0.1:10086")
	proxyCli.SetSocksAuth("test", "12345678")
	defer proxyCli.Close()

	transport := &http.Transport{
		DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) {
			return proxyCli.Dial(ctx, addr)
		},
	}
	cli := http.Client{
		Transport: transport,
		Timeout:   time.Second * 10,
	}
	resp, err := cli.Get("https://www.google.com")
	if err != nil {
		return
	}
	defer resp.Body.Close()
	data, _ := io.ReadAll(resp.Body)
	fmt.Println(string(data))
}

yaml config

The socks server supports the following authentication methods:

  • username: Username/Password authentication
  • none: No authentication
listen_addr: 0.0.0.0:10086
socks_method:
  - username
  - none
auth:
  - test:12345678
  - test2:123

gsocks5's People

Contributors

josexy avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.