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

socks4

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2021 License: MIT Imports: 7 Imported by: 0

README

go-socks4

Socks4 implementation for Go, compatible with net/proxy

Usage

package main

import (
	"errors"
	"net/url"

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

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

	dialer, err := proxy.FromURL(addr, proxy.Direct)
	// check error
	// and use your dialer as you with 
	c, err := dialer.Dial("tcp", "google.com:80")
	if err != nil && errors.As(err, &socksErr) {
		// handle error
	}
}

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

This section is empty.

Variables

View Source
var (
	ErrWrongURL      = Error{"wrong server url", nil}
	ErrWrongConnType = Error{"no support for connections of type", nil}
	ErrConnFailed    = Error{"connection failed to socks4 server", nil}
	ErrHostUnknown   = Error{"unable to find IP address of host", nil}
	ErrSocksServer   = Error{"socks4 server error", nil}
	ErrConnRejected  = Error{"connection rejected", nil}
	ErrIdentRequired = Error{"socks4 server require valid identd", nil}
)

Functions

This section is empty.

Types

type Error

type Error struct {
	// contains filtered or unexported fields
}

Error is custom error type for better error handling

func (Error) Equal

func (e Error) Equal(err Error) bool

Equal compares two custom errors if they same origin

func (Error) Error

func (e Error) Error() string

Error implements error interface

func (Error) Unwrap

func (e Error) Unwrap() error

Unwrap implements errors.Unwrap interface

func (Error) Wrap

func (e Error) Wrap(err error) Error

Wrap wraps an error to custom error type and returns copy

Jump to

Keyboard shortcuts

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