{"modulePath":"github.com/WinPooh32/git","version":"v1.24.5","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package proxyprotocol\n\n## Functions\n\n```go\nfunc WriteLocalHeader(w io.Writer) error\n```\nWriteLocalHeader will write the ProxyProtocol Header for a local connection to the provided writer\n\n## Types\n\n```go\ntype Conn struct {\n\t// contains filtered or unexported fields\n}\n```\nConn is used to wrap and underlying connection which is speaking the Proxy Protocol. RemoteAddr() will return the address of the client instead of the proxy address.\n\n```go\nfunc NewConn(conn net.Conn, timeout time.Duration) *Conn\n```\nNewConn is used to wrap a net.Conn speaking the proxy protocol into a proxyprotocol.Conn\n\n```go\nfunc (p *Conn) Close() error\n```\nClose closes the connection. Any blocked Read or Write operations will be unblocked and return errors.\n\n```go\nfunc (p *Conn) LocalAddr() net.Addr\n```\nLocalAddr returns the local network address.\n\n```go\nfunc (p *Conn) Read(b []byte) (int, error)\n```\nRead reads data from the connection. It will initially read the proxy protocol header. If there is an error parsing the header, it is returned and the socket is closed.\n\n```go\nfunc (p *Conn) ReadFrom(r io.Reader) (int64, error)\n```\nReadFrom reads data from a provided reader and copies it to the connection.\n\n```go\nfunc (p *Conn) RemoteAddr() net.Addr\n```\nRemoteAddr returns the address of the client if the proxy protocol is being used, otherwise just returns the address of the socket peer. If there is an error parsing the header, the address of the client is not returned, and the socket is closed. One implication of this is that the call could block if the client is slow. Using a Deadline is recommended if this is called before Read()\n\n```go\nfunc (p *Conn) SetDeadline(t time.Time) error\n```\nSetDeadline sets the read and write deadlines associated with the connection. It is equivalent to calling both SetReadDeadline and SetWriteDeadline.\n\nA deadline is an absolute time after which I/O operations fail instead of blocking. The deadline applies to all future and pending I/O, not just the immediately following call to Read or Write. After a deadline has been exceeded, the connection can be refreshed by setting a deadline in the future.\n\nIf the deadline is exceeded a call to Read or Write or to other I/O methods will return an error that wraps os.ErrDeadlineExceeded. This can be tested using errors.Is(err, os.ErrDeadlineExceeded). The error's Timeout method will return true, but note that there are other possible errors for which the Timeout method will return true even if the deadline has not been exceeded.\n\nAn idle timeout can be implemented by repeatedly extending the deadline after successful Read or Write calls.\n\nA zero value for t means I/O operations will not time out.\n\n```go\nfunc (p *Conn) SetReadDeadline(t time.Time) error\n```\nSetReadDeadline sets the deadline for future Read calls and any currently-blocked Read call. A zero value for t means Read will not time out.\n\n```go\nfunc (p *Conn) SetWriteDeadline(t time.Time) error\n```\nSetWriteDeadline sets the deadline for future Write calls and any currently-blocked Write call. Even if write times out, it may return n \u003e 0, indicating that some of the data was successfully written. A zero value for t means Write will not time out.\n\n```go\nfunc (p *Conn) Write(b []byte) (int, error)\n```\nWrite writes data to the connection. Write can be made to time out and return an error after a fixed time limit; see SetDeadline and SetWriteDeadline.\n\n```go\nfunc (p *Conn) WriteTo(w io.Writer) (int64, error)\n```\nWriteTo reads data from the connection and writes it to the writer. It will initially read the proxy protocol header. If there is an error parsing the header, it is returned and the socket is closed.\n\n```go\ntype ErrBadAddressType struct {\n\tAddress string\n}\n```\nErrBadAddressType is an error demonstrating a bad proxy header with bad Address type\n\n```go\nfunc (e *ErrBadAddressType) Error() string\n```\n\n```go\ntype ErrBadHeader struct {\n\tHeader []byte\n}\n```\nErrBadHeader is an error demonstrating a bad proxy header\n\n```go\nfunc (e *ErrBadHeader) Error() string\n```\n\n```go\ntype ErrBadLocal struct {\n\tIP   string\n\tPort string\n}\n```\nErrBadLocal is an error demonstrating a bad proxy header with bad Local\n\n```go\nfunc (e *ErrBadLocal) Error() string\n```\n\n```go\ntype ErrBadRemote struct {\n\tIP   string\n\tPort string\n}\n```\nErrBadRemote is an error demonstrating a bad proxy header with bad Remote\n\n```go\nfunc (e *ErrBadRemote) Error() string\n```\n\n```go\ntype Listener struct {\n\tListener           net.Listener\n\tProxyHeaderTimeout time.Duration\n\tAcceptUnknown      bool // allow PROXY UNKNOWN\n}\n```\nListener is used to wrap an underlying listener, whose connections may be using the HAProxy Proxy Protocol (version 1 or 2). If the connection is using the protocol, the RemoteAddr() will return the correct client address.\n\nOptionally define ProxyHeaderTimeout to set a maximum time to receive the Proxy Protocol Header. Zero means no timeout.\n\n```go\nfunc (p *Listener) Accept() (net.Conn, error)\n```\nAccept implements the Accept method in the Listener interface it waits for the next call and returns a wrapped Conn.\n\n```go\nfunc (p *Listener) Addr() net.Addr\n```\nAddr returns the underlying listener's network address.\n\n```go\nfunc (p *Listener) Close() error\n```\nClose closes the underlying listener.\n\n","path":"github.com/WinPooh32/git/proxyprotocol","name":"proxyprotocol","synopsis":"","isRedistributable":true}
