Package org.microproxy.extras
Class MapRemote
java.lang.Object
org.microproxy.extras.MapRemote
- All Implemented Interfaces:
HttpFiltersSource
Sends requests to another URL, as mitmproxy's
map_remote: each rule replaces every match
of a regular expression in the request's absolute URL, and the request goes to the result. The
Host header follows the new URL. Inside an intercepted session the request leaves the
session's server for the new one, over TLS for https://.
MapRemote.of("|https://api\\.example\\.com/v1/|http://localhost:8000/v1/",
"|~m GET|example\\.org|example.net")
Specs are [|flow-filter]|url-regex|replacement, the separator being the first
character. Every matching rule applies, in order, each to the URL the previous ones left.
Replacements may use groups as Python does (\1, \g<name>) or as Java does
($1). Only heads are read, unless a rule's filter looks at the request body (
~bq), which is then buffered (see MapRemote.Builder.maxBodySize).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuildsMapRemote.static final recordOne rule: requests the filter matches have every match ofpatternin their URL replaced. -
Method Summary
Modifier and TypeMethodDescriptionstatic MapRemote.Builderbuilder()Starts a builder with no rules.filterRequest(HttpRequest originalRequest, FlowContext flowContext) Returns the filters for a request, ornullto proxy it unfiltered.static MapRemoteMap remote rules from specs, with default settings.rules()Returns the rules, in order.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.microproxy.HttpFiltersSource
getMaximumRequestBufferSizeInBytes, getMaximumResponseBufferSizeInBytes
-
Method Details
-
of
Map remote rules from specs, with default settings.- Parameters:
specs- specs of the form[|flow-filter]|url-regex|replacement- Returns:
- the addon
- Throws:
IllegalArgumentException- if a spec is invalid
-
builder
Starts a builder with no rules.- Returns:
- a new builder
-
rules
Returns the rules, in order.- Returns:
- the rules, in order
-
filterRequest
Description copied from interface:HttpFiltersSourceReturns the filters for a request, ornullto proxy it unfiltered.- Specified by:
filterRequestin interfaceHttpFiltersSource- Parameters:
originalRequest- a copy of the request as received from the clientflowContext- the client connection the request arrived on- Returns:
- the per-request filters, or
nullto leave the request unfiltered
-