#  -*- text -*-
#
#
#  $Id: 8e0777eede9fe130b99f0c4500a1f6e554c48db8 $

#######################################################################
#
#  = REDISWho Module
#
#  The `rediswho` module tracks the last set of login sessions for a user.
#

#
#  ## Configuration Settings
#
rediswho {
	#
	#  server::
	#
	#  If using Redis cluster, multiple 'bootstrap' servers may be
	#  listed here (as separate config items). These will be contacted
	#  in turn until one provides us with a valid map for the cluster.
	#  Server strings may contain unique ports e.g.:
	#
	#    server = '127.0.0.1:30001'
	#    server = '[::1]:30002'
	#
	#  NOTE: Instantiation failure behaviour is controlled by
	#  `pool.start` as with other modules. With clustering
	#  however, the `pool { ... }` section determines limits for
	#  each node we access in the cluster, and not the cluster as
	#  a whole.
	#
	server = 127.0.0.1

	#
	#  database:: Select the Redis logical database having the specified zero-based numeric index.
	#
#	database = 0

	#
	#  port:: Port to connect to
	#  The default port is 6379.
	#
	port = 6379

	#  password:: The password used to authenticate to the server.
	#
	#  We recommend using a strong password.
	#
#	password = thisisreallysecretandhardtoguess

	#
	#  trim_count:: How many sessions to keep track of per user.
	#
	#  If there are more than this number, older sessions are deleted.
	#
	trim_count = 15

	#
	#  expire_time:: Expiry time in seconds.
	#
	#  Any sessions which have not received an update in this time will be
	#  automatically expired.
	#
	expire_time = 86400

	#
	#  ## Queries by Acct-Status-Type
	#
	#  Each subsection contains insert / trim / expire queries.
	#
	#  The subsections are named after the contents of the `Acct-Status-Type` attribute.
	#
	#  See `dictionary.rfc2866` for the names of the various Acct-Status-Type values,
	#  or look at the output of debug mode.
	#
	#  This module supports *any* `Acct-Status-Type`.  Just add a subsection
	#  of the appropriate name, along with insert / trim / expire queries.
	#

	#
	#  ### Start
	#
	Start {
		insert = "LPUSH %{User-Name} %l,%{Acct-Session-Id},%{&NAS-IP-Address || &NAS-IPv6-Address},%{Acct-Session-Time},%{Framed-IP-Address},%{&Acct-Input-Gigawords || 0},%{&Acct-Output-Gigawords || 0},%{&Acct-Input-Octets || 0},%{&Acct-Output-Octets || 0}"
		trim =   "LTRIM %{User-Name} 0 ${..trim_count}"
		expire = "EXPIRE %{User-Name} ${..expire_time}"
	}

	#
	#  ### Interim-Update
	#
	Interim-Update {
		insert = "LPUSH %{User-Name} %l,%{Acct-Session-Id},%{&NAS-IP-Address || &NAS-IPv6-Address},%{Acct-Session-Time},%{Framed-IP-Address},%{&Acct-Input-Gigawords || 0},%{&Acct-Output-Gigawords || 0},%{&Acct-Input-Octets || 0},%{&Acct-Output-Octets || 0}"
		trim =   "LTRIM %{User-Name} 0 ${..trim_count}"
		expire = "EXPIRE %{User-Name} ${..expire_time}"
	}

	#
	#  ### Stop
	#
	Stop {
		insert = "LPUSH %{User-Name} %l,%{Acct-Session-Id},%{&NAS-IP-Address || &NAS-IPv6-Address},%{Acct-Session-Time},%{Framed-IP-Address},%{&Acct-Input-Gigawords || 0},%{&Acct-Output-Gigawords || 0},%{&Acct-Input-Octets || 0},%{&Acct-Output-Octets || 0}"
		trim =   "LTRIM %{User-Name} 0 ${..trim_count}"
		expire = "EXPIRE %{User-Name} ${..expire_time}"
	}

	#
	#  ### Accounting-On
	#
#	Accounting-On {
#		insert = ""
#		trim =   ""
#		expire = ""
#	}

	#
	#  ### Accounting-Off
	#
#	Accounting-Off {
#		insert = ""
#		trim =   ""
#		expire = ""
#	}

	#
	#  ### Failed
	#
#	Failed {
#		insert = ""
#		trim =   ""
#		expire = ""
#	}
}
