Documentation ¶
Overview ¶
Package gomitmproxy implements a configurable mitm proxy wring purely in go.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { ListenAddr *net.TCPAddr // Address to listen to // TLSConfig is a config to use for the HTTP over TLS proxy // If not set, gomitmproxy will work as a simple plain HTTP proxy TLSConfig *tls.Config // Username for Proxy-Authorization Username string // Password for Proxy-Authorization Password string MITMConfig *mitm.Config // If not nil, MITM is enabled for the proxy MITMExceptions []string // A list of hostnames for which MITM will be disabled // APIHost is a name of the gomitmproxy API // If it is set to "", there will be no API // Here are the methods exposed: // 1. apihost/cert.crt -- serves the authority cert (if MITMConfig is configured) APIHost string // OnConnect is called when the proxy tries to open a net.Conn. // It allows you to hijack the remote connection and replace it with your own. // // 1. When the proxy handles the HTTP CONNECT. // IMPORTANT: In this case we don't actually use the remote connections. // It is only used to check if the remote endpoint is available // 2. When the proxy bypasses data from the client to the remote endpoint. // For instance, it could happen when there's a WebSocket connection. OnConnect func(session *Session, proto string, addr string) net.Conn // OnRequest is called when the request has been just received, // but has not been sent to the remote server. // // At this stage, it is possible to do the following things: // 1. Modify or even replace the request // 2. Supply an HTTP response to be written to the client // // Return nil instead of *http.Request or *http.Response to keep // the original request / response // // Note that even if you supply your own HTTP response here, // the OnResponse handler will be called anyway! OnRequest func(session *Session) (*http.Request, *http.Response) // OnResponse is called when the response has been just received, // but has not been sent to the local client. // // At this stage you can either keep the original response, // or you can replace it with a new one. OnResponse func(session *Session) *http.Response // OnError is called if there's an issue with retrieving // the response from the remote server. OnError func(session *Session, err error) }
Config is the configuration of the Proxy
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context contains all the necessary information about the connection that is currently processing by the proxy
func (*Context) SetDeadline ¶
SetDeadline sets the read and write deadlines associated with the connection. See net.Conn.SetDeadline for more details.
The difference is that our contexts can be nested, so we search for the topmost parent context recursively and call SetDeadline for its connection only as this is the real underlying network connection.
type Proxy ¶
type Proxy struct { Config // Proxy configuration // contains filtered or unexported fields }
Proxy is a structure with the proxy server configuration and current state
func (*Proxy) Close ¶
func (p *Proxy) Close()
Close sets the proxy to the closing state so it stops receiving new connections, finishes processing any inflight requests, and closes existing connections without reading anymore requests from them.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session contains all the necessary information about the request-response pair that is currently being processed
func (*Session) RemoteAddr ¶
RemoteAddr returns this session's remote address
Directories ¶
Path | Synopsis |
---|---|
examples
|
|
Package mitm implements methods for working with certificates and TLS configurations that are used for mitming connections.
|
Package mitm implements methods for working with certificates and TLS configurations that are used for mitming connections. |
Package proxyutil contains different utility methods that will be helpful to gomitmproxy users
|
Package proxyutil contains different utility methods that will be helpful to gomitmproxy users |