enhttp

package module
v0.0.0-...-6f89d45 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2021 License: Apache-2.0 Imports: 12 Imported by: 6

Documentation

Overview

Package enhttp provides an implementation of net.Conn that encapsulates traffic in one or more HTTP requests. It is conceptually similar to the older https://github.com/getlantern/enproxy but differs in that it supports HTTP servers which don't support Transfer-Encoding: Chunked on uploads.

enhttp was created to facilitate domain-fronting within Lantern.

enhttp creates virtual connections that are identified by a unique GUID. Every write to the connection is implemented as an HTTP POST. The first POST establishes the virtual connection and subsequent HTTP POSTs are tied to that connection by the X-En-Conn-Id header.

To support load-balancing, servers can optionally return an X-Server-URL header that uniquely identifies the server that handled the initial POST. If present, enhttp clients send all subsequent POSTs to that URL.

Index

Constants

View Source
const (
	// ConnectionIDHeader identifies a virtual connection.
	ConnectionIDHeader = "X-En-Conn-Id"

	// OriginHeader identifies the origin server to which we're trying to tunnel.
	OriginHeader = "X-Origin"

	// ServerURL optionally specifies the URL to the server that handled the first
	// POST.
	ServerURL = "X-Server-URL"

	// Close indicates that the connection has been closed.
	Close = "X-Close"
)

Variables

This section is empty.

Functions

func IsENHTTP

func IsENHTTP(candidate net.Conn) bool

IsENHTTP indicates whether the given candidate is an ENHTTP client connection or a wrapper around one.

func NewDialer

func NewDialer(client *http.Client, serverURL string) func(string, string) (net.Conn, error)

NewDialer creates a new dialer that dials out using the enhttp protocol, tunneling via the server specified by serverURL. An http.Client must be specified to configure the underlying HTTP behavior.

func NewServerHandler

func NewServerHandler(reapIdleTime time.Duration, serverURL string) http.Handler

NewServerHandler creates an http.Handler that performs the server-side processing of enhttp. reapIdleTime specifies the amount of time a connection is allowed to remain idle before being forcibly closed. serverURL optionally specifies the unique URL at which this server can be reached (used for sticky routing).

func OriginHost

func OriginHost(req *http.Request) string

OriginHost extracts the origin from the given request, using X-Origin header if available otherwise using the Host header.

Types

This section is empty.

Jump to

Keyboard shortcuts

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