Class BlockList
- All Implemented Interfaces:
HttpFiltersSource
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).
URL rules see the normalized URL (FlowFilter). A rule also blocks when it matches the
URL with its query fully percent-decoded, with + kept or read as a space (FlowFilter.queryDecoded(org.microproxy.extras.FlowFilter.Flow)), since origins decode query values: |~u [?&]file=/files/x|403
blocks ?file=%2Ffiles%2Fx, and an allow written as |!~u ^https://example\.com/dl\?file=/ok$|403 still blocks
/dl?file=%2Fok: decoding never lets more through. Write query rules in decoded form; an
allow for a query that clients escape must accept both spellings (next=(/|%2F)home).
A decoded form holding a line break is tried with . crossing it and stopping at it, so
an allow whose . must span one writes (?s).
-
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
-