proxyline

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2024 License: BSD-2-Clause, Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Packet proxyProtocol implements Proxy Protocol parser and writer.

Index

Constants

View Source
const (
	TCP4    = "TCP4"    // TCP over IPv4
	TCP6    = "TCP6"    // TCP over IPv6
	UNKNOWN = "UNKNOWN" // Unsupported or unknown protocols
)

INET protocol and family

Variables

View Source
var (
	InvalidProxyLine   = errors.New("Invalid proxy line")
	UnmatchedIPAddress = errors.New("IP address(es) unmatched with protocol")
	InvalidPortNum     = errors.New(fmt.Sprintf("Invalid port number parsed. (expected [%d..%d])", _port_lower, _port_upper))
)

Functions

This section is empty.

Types

type ProxyLine

type ProxyLine struct {
	Protocol string
	SrcAddr  *net.IPAddr
	DstAddr  *net.IPAddr
	SrcPort  int
	DstPort  int
}

func ConsumeProxyLine

func ConsumeProxyLine(reader *bufio.Reader) (*ProxyLine, error)

ConsumeProxyLine looks for PROXY line in the reader and try to parse it if found.

If first 5 bytes in reader is "PROXY", the function reads one line (until first '\n') from reader and try to parse it as ProxyLine. A newly allocated ProxyLine is returned if parsing secceeds. If parsing fails, a nil and an error is returned;

If first 5 bytes in reader is not "PROXY", the function simply returns (nil, nil), leaving reader intact (nothing from reader is consumed).

If the being parsed PROXY line is using an unknown protocol, ConsumeProxyLine parses remaining fields as same syntax as a supported protocol assuming IP is used in layer 3, and reports error if failed.

func (*ProxyLine) WriteProxyLine

func (p *ProxyLine) WriteProxyLine(w io.Writer) (err error)

WriteProxyLine formats p as valid PROXY line into w

Jump to

Keyboard shortcuts

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