Package org.microproxy.extras
Class BlockList
java.lang.Object
org.microproxy.extras.BlockList
- All Implemented Interfaces:
HttpFiltersSource
Blocks requests, as mitmproxy's
block_list: the first rule whose filter matches answers
the request with an empty response of its status, without contacting the server. Status NO_RESPONSE (444) closes the connection without any response instead (on HTTP/2, the
stream is reset).
BlockList.of("|~d ads\\.example\\.com|404", "|~u /tracking/|444")
Specs are |flow-filter|status, the separator being the first character. Only heads
are read, unless a filter looks at the request body (~bq).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuildsBlockList.static final recordOne rule: requests the filter matches get an empty response withstatus, or none. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe status that means "close the connection without a response", as in mitmproxy and nginx. -
Method Summary
Modifier and TypeMethodDescriptionstatic BlockList.Builderbuilder()Starts a builder with no rules.filterRequest(HttpRequest originalRequest, FlowContext flowContext) Returns the filters for a request, ornullto proxy it unfiltered.static BlockListBlock rules from specs.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
-
Field Details
-
NO_RESPONSE
public static final int NO_RESPONSEThe status that means "close the connection without a response", as in mitmproxy and nginx.- See Also:
-
-
Method Details
-
of
Block rules from specs.- Parameters:
specs- specs of the form|flow-filter|status- 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
-