chained

package module
v0.0.0-...-333b0f1 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2016 License: Apache-2.0 Imports: 10 Imported by: 10

README

chained Travis CI Status Coverage Status GoDoc

To install:

go get github.com/getlantern/chained

For docs:

godoc github.com/getlantern/chained

Documentation

Overview

Package chained provides a chained proxy that can proxy any tcp traffic over any underlying transport through a remote proxy. The downstream (client) side of the chained setup is just a dial function. The upstream (server) side is just an http.Handler. The client tells the server where to connect using an HTTP CONNECT request.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDialer

func NewDialer(cfg Config) func(network, addr string) (net.Conn, error)

NewDialer returns an implementation of net.Dial() based on the given Config.

Types

type Config

type Config struct {
	// DialServer: function that dials the upstream server proxy
	DialServer func() (net.Conn, error)

	// OnRequest: optional function that gets called on every CONNECT request to
	// the server and is allowed to modify the http.Request before it passes to
	// the server.
	OnRequest func(req *http.Request)

	// Label: a optional label for debugging.
	Label string
}

Config is a configuration for a Dialer.

type Server

type Server struct {
	// Dial: function for dialing destination
	Dial func(network, address string) (net.Conn, error)
}

Server provides the upstream side of a chained proxy setup. It can be run as a standalone HTTP server using Serve() or plugged into an existing HTTP server as an http.Handler.

func (*Server) Serve

func (s *Server) Serve(l net.Listener) error

Serve provides a convenience function for starting an HTTP server using this Server as the Handler.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(resp http.ResponseWriter, req *http.Request)

ServeHTTP implements the method from http.Handler.

Jump to

Keyboard shortcuts

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