Documentation ¶
Overview ¶
This is a modification of net.http.internal.chunked to also receive chunks line. The purpose is to have a raw header which understand chunks, but does not convert it. ALl changes are marked with "CHANGED" comment.
Index ¶
- Constants
- Variables
- func ConfigureConn(conn net.Conn)
- func Main()
- func NewBasicCACertConfig(cn string, serial int64) *x509.Certificate
- func NewBasicHttpsCertConfig(cn string, names []string, serial int64) *x509.Certificate
- func NewChunkedReader(r io.Reader) io.Reader
- func NewChunkedWriter(w io.Writer) io.WriteCloser
- type Cert
- func NewCert(cert *x509.Certificate, bits int, ca *Cert) (*Cert, error)
- func NewCertFromFiles(public, private string) (*Cert, error)
- func NewCertFromPEM(public, private string) (*Cert, error)
- func NewPbkdfCert(cert *x509.Certificate, bits int, ca *Cert, password []byte, salt []byte, ...) (*Cert, error)
- type CertsManager
- type CloseAwareConn
- func (cc *CloseAwareConn) Close() error
- func (cc *CloseAwareConn) LocalAddr() net.Addr
- func (cc *CloseAwareConn) ReOpen() error
- func (cc *CloseAwareConn) Read(b []byte) (n int, err error)
- func (cc *CloseAwareConn) RemoteAddr() net.Addr
- func (cc *CloseAwareConn) Reset(reqId int32)
- func (cc *CloseAwareConn) SetDeadline(t time.Time) error
- func (cc *CloseAwareConn) SetReadDeadline(t time.Time) error
- func (cc *CloseAwareConn) SetWriteDeadline(t time.Time) error
- func (cc *CloseAwareConn) Write(b []byte) (n int, err error)
- type Conf
- type ConfCred
- type ConfProxy
- type ConfRegex
- type ConfRule
- type Config
- type FlushAfterChunkWriter
- type HostCache
- type HttpVersion
- type Kdc
- type Kerberos
- type KerberosClient
- type KerberosStore
- type LinuxKerberos
- type ManualResetEvent
- type Options
- type PacExecutor
- type PacResult
- type PooledConnection
- type PooledConnectionInfo
- type Process
- type Proxy
- type ProxyRequest
- type ProxyType
- type RandomReader
- type RequestHeader
- type TimedConn
- func (tc *TimedConn) Close() error
- func (tc *TimedConn) LocalAddr() net.Addr
- func (tc *TimedConn) Read(b []byte) (n int, err error)
- func (tc *TimedConn) RemoteAddr() net.Addr
- func (tc *TimedConn) SetDeadline(_ time.Time) error
- func (tc *TimedConn) SetReadDeadline(_ time.Time) error
- func (tc *TimedConn) SetWriteDeadline(_ time.Time) error
- func (tc *TimedConn) Write(b []byte) (n int, err error)
Constants ¶
const CREDENTIAL_KERBEROS = "kerberos"
const CT_PLAIN_UTF8 = "text/plain; charset=UTF-8"
const DEFAULT_CLOSE_TIMEOUT = 10
timeout in seconds for closing infinite pipes once one peer has closed it's connection
const DEFAULT_CONNECT_TIMEOUT = 10
timeout in seconds for dialing to peer
const DEFAULT_IDLE_TIMOUT = 0
timeout in seconds for read/write operations, before automatically closing connections
const ENCRYPTED = "encrypted:"
encrypted password
const EXPERIMENTAL_CONNETION_POOLS = "connection-pools"
const EXPERIMENTAL_HOSTS_CACHE = "hosts-cache"
const HEADER_MAX_SIZE = 32 * 1024
max header size, to buffer request headers
const KDC_TEST_TIMEOUT = 10
const POOL_CLOSE_TIMEOUT = 30
timeout in seconds for a connection to stay in pool before closing
const POOL_CLOSE_TIMEOUT_ADD = 5
const RELOAD_FORCE_TIMEOUT = 60 * 60
const RELOAD_TEST_TIMEOUT = 10
config automatic reloading
Variables ¶
var AppDefaultDomain = ".EXAMPLE.COM"
var AppDefaultKrb5 = `` /* 464-byte string literal not displayed */
var AppName = "kpx"
var AppUpdateUrl = "https://api.github.com/repos/momiji/kpx/releases/latest"
var AppUrl = "https://github.com/momiji/kpx"
var AppVersion = "dev"
program global settings
var ConfProxyContinue = ConfProxy{}
var ErrLineTooLong = errors.New("header line too long")
var HelpTemplate = `` /* 4319-byte string literal not displayed */
var HelpValue = ""
var HttpVersions = [...]HttpVersion{Http10, Http11, Http2}
var NativeKerberos = &LinuxKerberos{}
var UsageTemplate = `` /* 2449-byte string literal not displayed */
var UsageValue = ""
var VersionTemplate = "{{.AppName}} {{.AppVersion}} - {{.AppUrl}}"
var VersionValue = ""
Functions ¶
func ConfigureConn ¶ added in v1.5.1
func NewBasicCACertConfig ¶
func NewBasicCACertConfig(cn string, serial int64) *x509.Certificate
func NewBasicHttpsCertConfig ¶
func NewBasicHttpsCertConfig(cn string, names []string, serial int64) *x509.Certificate
func NewChunkedReader ¶
NewChunkedReader returns a new chunkedReader that translates the data read from r out of HTTP "chunked" format before returning it. The chunkedReader returns io.EOF when the final 0-length chunk is read.
NewChunkedReader is not needed by normal applications. The http package automatically decodes chunking when reading response bodies.
func NewChunkedWriter ¶
func NewChunkedWriter(w io.Writer) io.WriteCloser
NewChunkedWriter returns a new chunkedWriter that translates writes into HTTP "chunked" format before writing them to w. Closing the returned chunkedWriter sends the final 0-length chunk that marks the end of the stream but does not send the final CRLF that appears after trailers; trailers and the last CRLF must be written separately.
NewChunkedWriter is not needed by normal applications. The http package adds chunking automatically if handlers don't set a Content-Length header. Using newChunkedWriter inside a handler would result in double chunking or chunking with a Content-Length length, both of which are wrong.
Types ¶
type Cert ¶
type Cert struct { Priv *rsa.PrivateKey Pub *x509.Certificate }
func NewCertFromFiles ¶
func NewCertFromPEM ¶
func NewPbkdfCert ¶
func (*Cert) SaveToFiles ¶
type CertsManager ¶
type CertsManager struct {
// contains filtered or unexported fields
}
func NewCertsManager ¶
func NewCertsManager(ca *Cert, prefix string, names []string) (*CertsManager, error)
func (*CertsManager) GetCertificate ¶
func (c *CertsManager) GetCertificate(dns string) (*tls.Certificate, error)
type CloseAwareConn ¶ added in v1.5.1
type CloseAwareConn struct {
// contains filtered or unexported fields
}
CloseAwareConn is a connection that can detect if underlying connection is closed, but only on first Write() after Reset() has been called. This way, we can choose when the closed connection can be replaced by a new one, ensuring connection closed is only handled when expected.
This allows to detect a restart of a remote proxy, for example.
On linux and Windows (and MacOS?), a double .Write() allows to detect a closed connection, but this trick does not work all the time.
func NewCloseAwareConn ¶ added in v1.5.1
func (*CloseAwareConn) Close ¶ added in v1.5.1
func (cc *CloseAwareConn) Close() error
func (*CloseAwareConn) LocalAddr ¶ added in v1.5.1
func (cc *CloseAwareConn) LocalAddr() net.Addr
func (*CloseAwareConn) ReOpen ¶ added in v1.5.1
func (cc *CloseAwareConn) ReOpen() error
func (*CloseAwareConn) Read ¶ added in v1.5.1
func (cc *CloseAwareConn) Read(b []byte) (n int, err error)
func (*CloseAwareConn) RemoteAddr ¶ added in v1.5.1
func (cc *CloseAwareConn) RemoteAddr() net.Addr
func (*CloseAwareConn) Reset ¶ added in v1.5.1
func (cc *CloseAwareConn) Reset(reqId int32)
func (*CloseAwareConn) SetDeadline ¶ added in v1.5.1
func (cc *CloseAwareConn) SetDeadline(t time.Time) error
func (*CloseAwareConn) SetReadDeadline ¶ added in v1.5.1
func (cc *CloseAwareConn) SetReadDeadline(t time.Time) error
func (*CloseAwareConn) SetWriteDeadline ¶ added in v1.5.1
func (cc *CloseAwareConn) SetWriteDeadline(t time.Time) error
type Conf ¶
type Conf struct { Bind string Port int SocksPort int `yaml:"socksPort"` Verbose bool Debug bool Trace bool Proxies map[string]*ConfProxy Credentials map[string]*ConfCred Domains map[string]*string Rules []*ConfRule SocksRules []*ConfRule `yaml:"socksRules"` Krb5 string ConnectTimeout int `yaml:"connectTimeout"` IdleTimeout int `yaml:"idleTimeout"` CloseTimeout int `yaml:"closeTimeout"` Check *bool Update bool Restart bool Experimental string // space/comma separated list of features // contains filtered or unexported fields }
type FlushAfterChunkWriter ¶
FlushAfterChunkWriter signals from the caller of NewChunkedWriter that each chunk should be followed by a flush. It is used by the http.Transport code to keep the buffering behavior for headers and trailers, but flush out chunks aggressively in the middle for request bodies which may be generated slowly. See Issue 6574.
type HostCache ¶ added in v1.6.0
type HostCache struct {
// contains filtered or unexported fields
}
type HttpVersion ¶
type HttpVersion string
const ( Http10 HttpVersion = "1.0" Http11 HttpVersion = "1.1" Http2 HttpVersion = "2" )
func GetHttpVersion ¶
func GetHttpVersion(version string) HttpVersion
func (HttpVersion) Order ¶
func (hv HttpVersion) Order() int
func (HttpVersion) Version ¶
func (hv HttpVersion) Version() string
type Kerberos ¶
type Kerberos struct {
// contains filtered or unexported fields
}
func NewKerberos ¶
type KerberosClient ¶
type KerberosClient struct {
// contains filtered or unexported fields
}
func NewKerberosClient ¶
func NewKerberosClient(krbClient *client.Client) *KerberosClient
type KerberosStore ¶
type KerberosStore struct {
// contains filtered or unexported fields
}
func NewKerberosStore ¶
func NewKerberosStore(config *Config) (*KerberosStore, error)
type LinuxKerberos ¶ added in v1.7.0
type LinuxKerberos struct {
// contains filtered or unexported fields
}
func (*LinuxKerberos) SafeGetToken ¶ added in v1.7.0
func (k *LinuxKerberos) SafeGetToken(protocol string, host string) (*string, error)
func (*LinuxKerberos) SafeTryLogin ¶ added in v1.7.0
func (k *LinuxKerberos) SafeTryLogin() error
type ManualResetEvent ¶
type ManualResetEvent struct {
// contains filtered or unexported fields
}
ManualResetEvent notifies one or more waiting goroutines that an event has occurred.
Once it has been signaled, ManualResetEvent remains signaled until it is manually reset. When signaled, all waiting goroutines are released, and all calls to Wait return immediately.
func NewManualResetEvent ¶
func NewManualResetEvent(s bool) *ManualResetEvent
NewManualResetEvent returns a new ManualResetEvent with initial state s
func (*ManualResetEvent) Channel ¶
func (e *ManualResetEvent) Channel() chan struct{}
func (*ManualResetEvent) IsSignaled ¶
func (e *ManualResetEvent) IsSignaled() bool
func (*ManualResetEvent) Reset ¶
func (e *ManualResetEvent) Reset()
Reset sets the state of e to nonsignaled.
func (*ManualResetEvent) Signal ¶
func (e *ManualResetEvent) Signal()
Signal sets the state of e to signaled, waking one or more waiting goroutines.
func (*ManualResetEvent) Wait ¶
func (e *ManualResetEvent) Wait()
Wait suspends execution of the calling goroutine until e receives a signal.
func (*ManualResetEvent) WaitContext ¶
func (e *ManualResetEvent) WaitContext(ctx context.Context) error
WaitContext suspends execution of the calling goroutine until e receives a signal, or until the context is cancelled. The returned error is nil if e received a signal, or ctx.Err()
type PacExecutor ¶
type PacExecutor struct {
// contains filtered or unexported fields
}
func NewPac ¶
func NewPac(pacJs string) (*PacExecutor, error)
type PooledConnection ¶
type PooledConnection struct {
// contains filtered or unexported fields
}
type PooledConnectionInfo ¶
type PooledConnectionInfo struct {
// contains filtered or unexported fields
}
type Proxy ¶
type Proxy struct {
// contains filtered or unexported fields
}
type ProxyRequest ¶
type ProxyRequest struct {
// contains filtered or unexported fields
}
type RandomReader ¶
type RandomReader struct {
// contains filtered or unexported fields
}
type RequestHeader ¶
type RequestHeader struct {
// contains filtered or unexported fields
}
type TimedConn ¶
type TimedConn struct {
// contains filtered or unexported fields
}
TimedConn is a wrapper around net.Conn which provides automatic read/write timeouts: - if timeout > 0, set an absolute timeout on first read - if timeout = 0, do not set timeout - if timeout < 0, set a sliding timeout, which automatically increases each min( 30s , timeout/2 ).