socksauth

package module
v2.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2025 License: MIT Imports: 12 Imported by: 0

README

SocksAuth

This project forwards your TCP connection through a SOCKS5 proxy, especially it can be used to forward it through a SOCKS5 proxy with authentication.

I tried to keep it minimal. It has 0 depencencies,

Why?

Because I needed a way to use a propietery SOCKS5 server with an automated browser, which does not allow to pass authentification to proxies.

As executable

You can install it as executable

git clone https://https://github.com/FrauElster/SocksAuth.git && cd ./SocksAuth
go build -o socksauth ./cmd/socksauth

And run it with

./socksauth -remoteUser <username> -remotePass <password> -remoteHost <host:port> [-port <localport>]

If the port is omitted, 1080 will be used.

As module

This is pretty much just the main.go of the server

package main

import (
	"log"

	"github.com/FrauElster/socksauth/v2"
)

func main() {
	proxy, err := NewProxy(
		os.Getenv("SOCKS_USER"),
		os.Getenv("SOCKS_PASSWORD"),
		os.Getenv("SOCKS_HOST"),
	)
	if err != nil {
		log.Fatalf("Failed to create proxy: %v", err)
	}

	// Start proxy in a goroutine
	socksPort := 1080
	go func() {
		log.Printf("Starting SOCKS proxy on port %d", socksPort)
		if err := proxy.Start(*localPort); err != nil {
			if err.Error() != "use of closed network connection" {
				log.Printf("Proxy error: %v", err)
			}
		}
	}()

	// runs now on localhost:1080
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetNordVpnServers added in v2.0.4

func GetNordVpnServers(ctx context.Context, nordvpnUser, nordvpnPassword string) ([]nordServer, error)

Types

type Proxy

type Proxy struct {
	Username string
	Password string
	NextHost string
	// contains filtered or unexported fields
}

func NewProxy

func NewProxy(username, password, nextHost string) (*Proxy, error)

func (*Proxy) Shutdown added in v2.0.1

func (p *Proxy) Shutdown(ctx context.Context) error

Shutdown gracefully shuts down the proxy server

func (*Proxy) Start

func (p *Proxy) Start(listenPort int) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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