proxyprotocol

package
v0.24.5 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2017 License: Apache-2.0 Imports: 9 Imported by: 1

Documentation

Overview

Package proxyprotocol is adapted from: https://github.com/armon/go-proxyproto

The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddForwardedFor added in v0.14.0

func AddForwardedFor(req *http.Request)

func AddHeaders

func AddHeaders(req *http.Request, httpsPorts map[int]bool)

func StateCleanup

func StateCleanup(conn net.Conn, connState http.ConnState)

Types

type Conn

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

Conn is used to wrap an underlying connection which may be speaking the Proxy Protocol. If it is, when Read() is called, the Proxy protocol header will be stripped and added to the context.

func NewConn

func NewConn(conn net.Conn) *Conn

NewConn is used to wrap a net.Conn that may be speaking the proxy protocol into a proxyproto.Conn

func (*Conn) Close

func (p *Conn) Close() error

func (*Conn) LocalAddr

func (p *Conn) LocalAddr() net.Addr

func (*Conn) Read

func (p *Conn) Read(b []byte) (int, error)

Read checks for the proxy protocol header when doing the initial scan. If there is an error parsing the header, it is returned and the socket is closed.

func (*Conn) RemoteAddr

func (p *Conn) RemoteAddr() net.Addr

func (*Conn) SetDeadline

func (p *Conn) SetDeadline(t time.Time) error

func (*Conn) SetReadDeadline

func (p *Conn) SetReadDeadline(t time.Time) error

func (*Conn) SetWriteDeadline

func (p *Conn) SetWriteDeadline(t time.Time) error

func (*Conn) Write

func (p *Conn) Write(b []byte) (int, error)

type Listener

type Listener struct {
	Listener net.Listener
}

Listener is used to wrap an underlying listener, whose connections may be using the HAProxy Proxy Protocol (version 1). If the connection is using the protocol, the RemoteAddr() will return the correct client address.

func (*Listener) Accept

func (p *Listener) Accept() (net.Conn, error)

Accept waits for and returns the next connection to the listener.

func (*Listener) Addr

func (p *Listener) Addr() net.Addr

Addr returns the underlying listener's network address.

func (*Listener) Close

func (p *Listener) Close() error

Close closes the underlying listener.

type ProxyProtoInfo

type ProxyProtoInfo struct {
	Protocol   string
	ClientAddr *net.TCPAddr
	ProxyAddr  *net.TCPAddr
}

Jump to

Keyboard shortcuts

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