Giter VIP home page Giter VIP logo

go-socks5's Introduction

go-socks5 Build Status

Provides the socks5 package that implements a SOCKS5 server. SOCKS (Secure Sockets) is used to route traffic between a client and server through an intermediate proxy layer. This can be used to bypass firewalls or NATs.

Feature

The package has the following features:

  • "No Auth" mode
  • User/Password authentication
  • Support for the CONNECT command
  • Rules to do granular filtering of commands
  • Custom DNS resolution
  • Unit tests

TODO

The package still needs the following:

  • Support for the BIND command
  • Support for the ASSOCIATE command

Example

Below is a simple example of usage

// Create a SOCKS5 server
conf := &socks5.Config{}
server, err := socks5.New(conf)
if err != nil {
  panic(err)
}

// Create SOCKS5 proxy on localhost port 8000
if err := server.ListenAndServe("tcp", "127.0.0.1:8000"); err != nil {
  panic(err)
}

go-socks5's People

Contributors

armon avatar bigmartha avatar oxtoacart avatar svent avatar ymmt2005 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

go-socks5's Issues

Help wanted?

Hi,

I love this library, but it looks like you did not have the time to maintain it the last couple of years... there are a few open pull requests and a lot of forks where people fix smaller issues.

Do you need help? I'd be willing to clean this up and consolidate everything, please let me know!

Thanks for your work!

Failed to handle request

2|socket5 | 2020/08/18 21:23:00 [ERR] socks: Failed to handle request: readfrom tcp 16.24.177.51:59642->172.67.80.44:80: splice: connection reset by peer
2|socket5 | 2020/08/18 21:23:01 [ERR] socks: Failed to handle request: readfrom tcp 16.24.177.51:39608->172.67.80.44:443: splice: connection reset by peer

with readme demo

Crashes when using custom net.conn

It crashes when using custom net.conn implementation that does not return net.TCPAddr when con.LocalAddr()

Crash example

panic: interface conversion: net.Addr is net.pipeAddr, not *net.TCPAddr

goroutine 7 [running]:
github.com/armon/go-socks5.(*Server).handleConnect(0xc00019a320, {0xfe4fd0, 0xc00009e0d0}, {0x1aae30650d8, 0xc000006020}, 0xc0002d2040)
	C:/Users/aymerici/go/pkg/mod/github.com/armon/[email protected]/request.go:194 +0x950

The problem is in this Line

	local := target.LocalAddr().(*net.TCPAddr)

Proxied traffic hook

Would you like to add support for intercepting proxied traffic, for example, for getting statistics, creating limits and so one.

I can create pull request with this changes or I should to create my own fork?

Thanks.

Socket leak

This library has socket leaks. When running it for a long time with real human traffic, it will end-up like this:

2020/09/21 08:40:19 [ERR] socks: Failed to handle request: Connect to xxx.xxx.xxx.xxx:443 failed: dial tcp xxx.xxx.xxx.xxx:443: socket: too many open files
panic: accept tcp [::]:4080: accept4: too many open files

Debug output written to stdout

I am currently testing your libary in a project and it works great so far, thanks for your work!

I noticed that it writes to stdout (via log in request.go/proxy(), see here), breaking the output of programs using it.

Is it possible to remove that or to make it configurable?

Add socks4 support

when i try use it as socks4 server it gives me that error: Unsupported SOCKS version: [4]
Will that be added in the future updates?

multiple public ips

Is there a way to have a client connecting to a public ip on the server browse the internet using the same ip?

For example I have a server with a public /24 attached to it. and I want client1 to only have access to 23.8.22.3 and also browse the internet using that ip.

client1 connects to the socks using host 23.8.22.3 and checks his ip on a website which also shows 23.8.22.3.

User/Pass authentication not working, can you give example code?

When trying to use the socks5 proxy (with Chrome on a Mac), it fails with this error message:

[ERR] socks: Failed to authenticate: No supported authentication mechanism

I had set the System Preferences on the Mac to use the SOCKS Proxy, and I provided the user and password. The proxy was clearly being contacted, but the authentication step was failing.

Here is the code that attempts to configure socks5 to use the UserPassAuthenticator.

package main

import socks5 "github.com/armon/go-socks5"

func main() {
	cred := socks5.StaticCredentials{"user": "pass"}
	conf := &socks5.Config{Credentials: cred}
	server, err := socks5.New(conf)
	if err != nil {
		panic(err)
	}
	err = server.ListenAndServe("tcp", "127.0.0.1:8000")
	if err != nil {
		panic(err)
	}
}

Can anyone give a simple example showing how UserPassAuthenticator can be used with Chrome/Safari browsers on a Mac?

custom dns resolution?

there is mention of Custom DNS resolution in the readme but there is no documentation on using this.

FR: Allow the proxy to hijack some net.Conn's to be serviced internally

In short, I want to make it possible for the proxy to hand off the connection to some go code to handle, rather than always proxy it out.

I know server.Dial exists, but I think thats a little messy + lots of wrapping+unwrapping layers of abstraction (for this use case).

  1. The client connects to the proxy and issues a connect for a specific endpoint.
  2. The connect request matches some internal state indicating it should be hijacked.
  3. The server proceeds as normal, except instead of opening the remote connection and proxying the data, it passes off the net.Conn to a callback.

In my use case, I pass the net.Conn to a http.Server and serve proxy status pages.

I am happy to code this and send a PR, just wanted to make sure this is okay with you.

Could use a way to stop it

It would be nice if there was a channel to send a message to stop the server.

e.g. I want to run it as part of a larger app that occasionally and intermittently needs to offer a socks server. When the need is gone, I would like to shit it down.

I suppose I can pull and modify it...

unix socket support

I've been looking at how to create a replacement of ocproxy which sets up a socks5 proxy in front of openconnect. Openconnect talks to ocproxy via a unix socket. Are there any plans to support a unix socket for the local address?

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.