Help us shape the future of Go! Take the 2026 Go Developer Survey

socks4

package module
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2021 License: MIT Imports: 8 Imported by: 0

README

go-socks4

Socks4 implementation for Go, compatible with net/proxy

Features

  • socks4
  • socks4a

Usage

package main

import (
	"errors"
	"log"
	"net/url"

	"github.com/Bogdan-D/go-socks4"
	"golang.org/x/net/proxy"
)

func main() {
	addr, _ := url.Parse("socks4://ip:port")

	dialer, err := proxy.FromURL(addr, proxy.Direct)
	conn, err := dialer.Dial("tcp", "google.com:80")
	if err != nil {
		// handle error
		if errors.Is(err, socks4.ErrDialFailed) {
			log.Printf("invalid proxy server %s", addr)
			return
		}
		if errors.Is(err, socks4.ErrConnRejected) {
			log.Printf("google.com:80: %s", err)
			return
		}
	}
	// use opened network connection
	_ = conn
}

Tests

If you know proxy server to connect to tests should be running like this go test -socks4.url=socks4://localhost:8080

Documentation

Index

Constants

View Source
const (
	ErrWrongConnType = typedErrors.String("no support for connections of type")
	ErrDialFailed    = typedErrors.String("socks4 dial")
	ErrConnRejected  = typedErrors.String("connection to remote host was rejected")
	ErrIdentRequired = typedErrors.String("valid ident required")
	ErrIO            = typedErrors.String("i\\o error")
	ErrWrongURL      = typedErrors.String("wrong server url: %s")
	ErrHostUnknown   = typedErrors.String("unable to find IP address of host %s")
	ErrUnknown       = typedErrors.String("unknown socks4 server response %v")
)

Variables

View Source
var Ident = "nobody@0.0.0.0"

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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