Support G-line lifetimes.
authorMichael Poole <mdpoole@troilus.org>
Thu, 18 Mar 2010 02:11:00 +0000 (22:11 -0400)
committerMichael Poole <mdpoole@troilus.org>
Thu, 18 Mar 2010 02:11:00 +0000 (22:11 -0400)
commit9904260b83596e5e9a8a15eeaa31a0c9007625f9
tree9b39af2bd251e25846915dfc498aac914a86b90c
parentdb23d3d138fdf2eca1c78028767715fc9068b02b
Support G-line lifetimes.

This involves using the old "expiration" as when the G-line becomes
inactive, and adding a new "lifetime" that is the latest of all the
expiration times that the G-line has ever had.  For convenience,
gline_add() will compare its new "lifetime" argument with its calculated
expiration time -- so callers can safely pass 0 as the lifetime.

src/gline.h (struct gline): Add the lifetime field.  Add Doxygen comments
    for future reference.
  (struct gline_discrim): Add bounds for the lifetime field.
  (gline_add): Add lifetime argument.

src/gline.c (KEY_LIFETIME): New database key.
  (delete_gline_for_p): Delete.
  (gline_expire): Use lifetime to determine whether a G-line expired.
  (gline_remove): Simplify greatly, because we don't actually remove
    G-lines any more (we just mark them immediately expired).
  (gline_add): Add parameter for lifetime, and use it.
  (gline_add_record): Parse lifetime field if it is present.  Simplify
    the parsing of the issued field.
  (gline_write_entry): Write the lifetime.
  (gline_discrim_create): Use ULONG_MAX rather than INT_MAX for
    maximum timestamps.  Parse "lifetime" arguments.
  (gline_discrim_match): Check the lifetime bounds.

src/mod-blacklist.c (dnsbl_hit): Pass 0 lifetime for gline_add().
  (blacklist_check_user): Likewise.

src/mod-sockcheck.c (sockcheck_issue_gline): Likewise.

src/opserv.c (OSMSG_GTRACE_FORMAT): Add lifetime field.
  (opserv_block): Pass 0 lifetime for gline_add().
  (cmd_gline): Likewise.
  (opserv_new_user_check): Likewise.
  (gtrace_print_func): Format the lifetime.

src/proto-p10.c (irc_gline): Include the lifetime in the correct place.
  (irc_ungline): Include the current timestamp (last modified time).
  (cmd_num_gline): When the lifetime argument is given, parse it.
  (cmd_gline): Likewise.  Also implement the normal ircu check for
    expiration as an absolute versus relative time.
src/gline.c
src/gline.h
src/mod-blacklist.c
src/mod-sockcheck.c
src/opserv.c
src/proto-p10.c