DEFINITION MODULE HammerCheck;

        (********************************************************)
        (*                                                      *)
        (*           Defence against password attacks           *)
        (*                                                      *)
        (*  Programmer:         P. Moylan                       *)
        (*  Started:            6 November 2017                 *)
        (*  Last edited:        17 July May 2023                *)
        (*  Status:             OK                              *)
        (*                                                      *)
        (********************************************************)


FROM TransLog IMPORT            (* WHILE DEBUGGING *)
    (* type *)  TransactionLogID;


PROCEDURE ResetHammerList;

    (* Clears the entire hammer list. *)

PROCEDURE NotePasswordError (IPAddress: CARDINAL);

    (* Records this IP address as one that, because of undesirable      *)
    (* behaviour, should be locked out for a short time.  For a         *)
    (* persistent attacker, that "short time" will increase.            *)

PROCEDURE ClearPasswordError (IPAddress: CARDINAL);

    (* Removes this IP address from the list, if it is present.         *)

PROCEDURE Throttle (IPAddress: CARDINAL;  ID: TransactionLogID): CARDINAL;

    (* If this IP address is on the list of addresses to be blocked     *)
    (* because of recent suspect behaviour, returns the blocking time   *)
    (* in seconds.  Otherwise, returns 0.                               *)

END HammerCheck.

