doxyproxy

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

README

DoxyProxy Client Lib

Go report card Build Status GoDoc Maintenance License GitHub release GitHub issues PRs Welcome

This is a client lib for DoxyProxy.

DoxyProxy is a fast layer 4 reverse proxy supporting both; UDP and TCP. The key features of DoxyProxy is the built in API which allows the remote origin to access the clients true IP address, instead of the proxy's IP.

  • Enhance security
  • Hide your origin
  • Protect your self origin for DDOS attacks

DoxyProxy is built for flexibility and speed, not just in raw performance but also in setup. Use a simple json file to configure a ProxiedHost. Features include:

  • Limit connections per IP
  • DualStack lookup
  • Domain support
  • IPv4, IPv6
  • Configurable IP version switching handled by the proxy
  • Force IPv6 or IPv4 (or allow all)
  • Fail over IP
  • Blacklist IP addresses
  • Blacklist CIDRs (ip ranges)
  • Whitelist IP addresses
  • Whitelist CIDRs (ip ranges)

Install

go get github.com/syrinsecurity/doxyproxy

Examples

package main

import (
	"fmt"
	"net"

	"github.com/syrinsecurity/doxyproxy"
)

var proxy = doxyproxy.New("http://example.com:port/", "appName", "key goes here")

func main() {

	//Standard server, could be anything; http, RTC, gRPC, tcp/udp etc
	l, err := net.Listen("tcp", ":80")
	...
	conn, err := l.Accept()
	...
	//This will remove the IP from the cache once this function closes
	defer proxy.Purge(conn.RemoteAddr())

	//This will resolve the proxies address and obtain the true visitors IP address
	realIP, err := proxy.Resolve(conn.RemoteAddr())
	if err != nil {
		fmt.Println(err)
		realIP = conn.RemoteAddr().String()
	}

	fmt.Println(realIP)
	...
}

Kill the connection from the remote proxy

package main

import (
	"fmt"
	"net"
	
	"github.com/syrinsecurity/doxyproxy"
)

var proxy = doxyproxy.New("http://example.com:port/", "appName", "key goes here")

func main() {

	//Standard server, could be anything; http, RTC, gRPC, tcp/udp etc
	l, err := net.Listen("tcp", ":80")
	...
	conn, err := l.Accept()
	...
	//This will remove the IP from the cache once this function closes
	defer proxy.Purge(conn.RemoteAddr())


	//This will kill the connection from the proxy
	err := proxy.Kill(conn.RemoteAddr())
	if err != nil {
		fmt.Println(err)
	}

	//It is good practise to still close the connection straight after
	conn.Close()

	...
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	//ErrAPIResponseSuccessFalse is returned when the response was false
	ErrAPIResponseSuccessFalse = errors.New("api response success false")
	//ErrClientNotFound is returned when the client was not found on the proxy server
	ErrClientNotFound = errors.New("client not found")
)

Functions

This section is empty.

Types

type IPEntry

type IPEntry struct {
	ID string

	IP     string
	Expire int64
	// contains filtered or unexported fields
}

IPEntry holds the true IP address of a client

func (IPEntry) Fetch

func (entry IPEntry) Fetch() (string, error)

Fetch will query the proxy API for the real IP

func (IPEntry) Kill

func (entry IPEntry) Kill() error

Kill will disconnect the user from the proxy

type Proxy

type Proxy struct {
	API string
	App string
	Key string

	CacheTTL time.Duration

	Client *http.Client
	// contains filtered or unexported fields
}

Proxy is a doxyproxy config

func New

func New(api string, app string, key string) *Proxy

New creates a new DoxyProxy

func (*Proxy) Kill

func (p *Proxy) Kill(addr net.Addr) error

Kill will disconnect the user from the proxy

func (*Proxy) Purge added in v1.0.1

func (p *Proxy) Purge(addr net.Addr) error

Purge will remove the IP from the cache

func (*Proxy) Resolve

func (p *Proxy) Resolve(addr net.Addr) (string, error)

Resolve will return the true IP address of the client

type Response

type Response struct {
	Success bool   `json:"success"`
	Message string `json:"message"`
}

Response holds a response from the API server

Jump to

Keyboard shortcuts

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