Contents · Forum Home · StreamSec Tools 4.1.5.363 documentation

StreamSec.Mobile.AsyncTLSFilter

Feature notes: TLS implementation notes (RFC map) · Async TLS socket server architecture

Classes, interfaces and records

classePeerFilter

inherits from Exception

Raised by tPeerFilter when a rule string cannot be parsed as a peer range. A rule that does not parse is a configuration mistake, and silently dropping it would leave the filter more permissive than the operator believes, so it is reported rather than ignored.

(no public members)

recordtPeerRange

One address or range, compiled from text.

fAddr: array [0..15] of Byte;
network order; v4 occupies 0..3
fPrefix: Integer;
significant bits
fIsV6: Boolean; function Matches(const aOther: tPeerRange): Boolean;

interfaceiPeerFilter

function ScreenPeer(const aPeer: string; out aReason: tPeerRefusal): tPeerVerdict;
Accept-time screen. aReason says which rule answered, for the log.
function PermitsToken(const aPeer, aToken: string): Boolean;
True if aPeer may be OFFERED aToken. A token with no source rule is offered to everyone; a token with rules is offered only to peers that match one, so adding a rule is what restricts it.
procedure ReportActivity(const aPeer: string; aUnits: Integer);
Adds aUnits of work to this peer's rate window. Called once per accepted connection by the server, and once per request by any protocol that chooses to report. Cheap and non-blocking by contract: it is on the request path.
procedure Sweep;
Drops rate state for peers that have gone quiet. Call periodically.
function BlockedCount: Integer;

classtPeerFilter

inherits from TInterfacedObject

implements iPeerFilter

The default implementation.

RULE ORDER, and it is the only order that is safe: DENY wins over ALLOW, and both are decided before the rate limiter is consulted. A peer on the deny list is refused even if it is also allow-listed, because the narrower, more deliberate statement has to be the one that holds.

constructor Create; destructor Destroy; override; procedure Deny(const aRange: string);
Adds a range to the deny list. Raises on a malformed rule: a deny rule that does not parse is a hole, and coming up with it silently ignored is strictly worse than not coming up.
procedure Allow(const aRange: string);
Adds a range to the allow list. A NON-EMPTY allow list makes the server exclusive: a peer matching nothing on it is refused.
procedure RestrictToken(const aToken, aRange: string);
Restricts aToken to peers matching aRange. The FIRST call for a token is what restricts it - before that the token is offered to everyone - so a typo in the token name leaves it wide open rather than closing it. Callers that care should assert on TokenIsRestricted.
function TokenIsRestricted(const aToken: string): Boolean; procedure SetRateLimit(aLimit, aWindowMs, aBlockMs: Integer);
aLimit units within aWindowMs blocks the peer for aBlockMs. aLimit <= 0 disables rate blocking entirely, which is the default: a limit guessed by the library would be wrong for every deployment.
function ScreenPeer(const aPeer: string; out aReason: tPeerRefusal): tPeerVerdict; function PermitsToken(const aPeer, aToken: string): Boolean; procedure ReportActivity(const aPeer: string; aUnits: Integer); procedure Sweep; function BlockedCount: Integer;

Types (enumerations, sets, aliases)

enumtPeerVerdict

What the filter says about a peer at accept time.

  tPeerVerdict = (pvAdmit, pvRefuse);

enumtPeerRefusal

WHY a peer was refused. For the log and for a test to assert on - never for the wire: telling a peer which rule stopped it maps the policy for them.

  tPeerRefusal = (prNone, prDenied, prNotAllowed, prRateLimited,
                  { Not a filter's answer: TsmAsyncTLSServer.MaxConnectionsPerPeer. }
                  prTooManyConnections);

arraytPeerRanges

  tPeerRanges = array of tPeerRange;

Routines