|
@@ -23,7 +23,7 @@ Ovidiu Sas
|
|
|
|
|
|
<[email protected]>
|
|
|
|
|
|
- Copyright © 2008-2011 http://www.asipto.com
|
|
|
+ Copyright © 2008-2011 http://www.asipto.com
|
|
|
__________________________________________________________________
|
|
|
|
|
|
Table of Contents
|
|
@@ -199,7 +199,7 @@ Chapter 1. Admin Guide
|
|
|
You can read more about hash tables at:
|
|
|
http://en.wikipedia.org/wiki/Hash_table.
|
|
|
|
|
|
- The "name" can be a static string or can include pseudo- variables that
|
|
|
+ The “name� can be a static string or can include pseudo- variables that
|
|
|
will be replaced at runtime.
|
|
|
|
|
|
Example 1.1. Accessing $sht(htname=>key)
|
|
@@ -213,7 +213,7 @@ $sht(a=>$ci::srcip) = $si;
|
|
|
Next example shows a way to protect against dictionary attacks. If
|
|
|
someone fails to authenticate 3 times, it is forbidden for 15min.
|
|
|
Authenticatiion against database is expensive as it does a select on
|
|
|
- the "subscriberthe" table. By disabling the DB auth for 15min,
|
|
|
+ the “subscriberthe� table. By disabling the DB auth for 15min,
|
|
|
resources on the server are saved and time to discover the password is
|
|
|
increased substantially. Additional alerting can be done by writing a
|
|
|
message to syslog or sending email, etc.
|
|
@@ -222,7 +222,7 @@ $sht(a=>$ci::srcip) = $si;
|
|
|
the failed authentications per user and one for storing the time of
|
|
|
last authentication attempt. To ensure a unique name per user, the hash
|
|
|
table uses a combination of authentication username and text
|
|
|
- "::auth_count" and "::last_auth".
|
|
|
+ “::auth_count� and “::last_auth�.
|
|
|
|
|
|
Example 1.2. Dictionary attack limitation
|
|
|
...
|
|
@@ -447,7 +447,7 @@ $ kamcmd htable.dump htable
|
|
|
however, in which case this attribute can be set to 0.
|
|
|
* dmqreplicate - if set to 1, any actions (set, update, delete etc.)
|
|
|
performed upon entries in this table will be replicated to other
|
|
|
- nodes (htable peers). Please note, module parameter "enable_dmq"
|
|
|
+ nodes (htable peers). Please note, module parameter “enable_dmq�
|
|
|
must also be set in order for this to apply (see below). Default is
|
|
|
0 (no replication).
|
|
|
|
|
@@ -596,6 +596,9 @@ modparam("htable", "db_expires", 1)
|
|
|
table definition (size, autoexpire etc.) is identical across all
|
|
|
instances.
|
|
|
|
|
|
+ Important: If this parameter is enabled, the DMQ module must be loaded
|
|
|
+ first - otherwise, startup will fail.
|
|
|
+
|
|
|
Currently, values are not replicated on load from DB as it is expected
|
|
|
that in these cases, all servers will load their values from the same
|
|
|
DB.
|
|
@@ -619,7 +622,7 @@ modparam("htable", "enable_dmq", 1)
|
|
|
4.8. sht_iterator_end(iname)
|
|
|
4.9. sht_iterator_next(iname)
|
|
|
|
|
|
-4.1. sht_print()
|
|
|
+4.1. sht_print()
|
|
|
|
|
|
Dump content of hash table to L_ERR log level. Intended for debug
|
|
|
purposes.
|
|
@@ -632,7 +635,7 @@ modparam("htable", "enable_dmq", 1)
|
|
|
sht_print();
|
|
|
...
|
|
|
|
|
|
-4.2. sht_rm_name_re(htable=>regexp)
|
|
|
+4.2. sht_rm_name_re(htable=>regexp)
|
|
|
|
|
|
Delete all entries in the htable that match the name against regular
|
|
|
expression.
|
|
@@ -645,7 +648,7 @@ sht_print();
|
|
|
sht_rm_name_re("ha=>.*");
|
|
|
...
|
|
|
|
|
|
-4.3. sht_rm_value_re(htable=>regexp)
|
|
|
+4.3. sht_rm_value_re(htable=>regexp)
|
|
|
|
|
|
Delete all entries in the htable that match the value against regular
|
|
|
expression.
|
|
@@ -658,7 +661,7 @@ sht_rm_name_re("ha=>.*");
|
|
|
sht_rm_value_re("ha=>.*");
|
|
|
...
|
|
|
|
|
|
-4.4. sht_reset(htable)
|
|
|
+4.4. sht_reset(htable)
|
|
|
|
|
|
Delete all entries in the htable. The name of the hash table can be a
|
|
|
dynamic string with variables.
|
|
@@ -670,7 +673,7 @@ sht_rm_value_re("ha=>.*");
|
|
|
sht_reset("ha$var(x)");
|
|
|
...
|
|
|
|
|
|
-4.5. sht_lock(htable=>key)
|
|
|
+4.5. sht_lock(htable=>key)
|
|
|
|
|
|
Lock the slot in htable corespoding to the key item. Note that the
|
|
|
locking is re-entrant for the process, therefore the lock and unlock
|
|
@@ -683,7 +686,7 @@ sht_reset("ha$var(x)");
|
|
|
sht_lock("ha=>test");
|
|
|
...
|
|
|
|
|
|
-4.6. sht_unlock(htable=>key)
|
|
|
+4.6. sht_unlock(htable=>key)
|
|
|
|
|
|
Unlock the slot in htable corespoding to the key item. Note that the
|
|
|
locking is re-entrant for the process, therefore the lock and unlock
|
|
@@ -698,7 +701,7 @@ $sht(ha=>test) = $sht(ha=>test) + 10;
|
|
|
sht_unlock("ha=>test");
|
|
|
...
|
|
|
|
|
|
-4.7. sht_iterator_start(iname, hname)
|
|
|
+4.7. sht_iterator_start(iname, hname)
|
|
|
|
|
|
Start an iterator for hash table named by the value of parameter hname.
|
|
|
The parameter iname is used to identify the iterator. There can be up
|
|
@@ -718,7 +721,7 @@ sht_unlock("ha=>test");
|
|
|
sht_iterator_start("i1", "h1");
|
|
|
...
|
|
|
|
|
|
-4.8. sht_iterator_end(iname)
|
|
|
+4.8. sht_iterator_end(iname)
|
|
|
|
|
|
Close the iterator identified by iname parameter and release the hash
|
|
|
table slot aquired by the iterator. The iname value must be the same
|
|
@@ -733,7 +736,7 @@ sht_iterator_start("i1", "h1");
|
|
|
sht_iterator_end("i1");
|
|
|
...
|
|
|
|
|
|
-4.9. sht_iterator_next(iname)
|
|
|
+4.9. sht_iterator_next(iname)
|
|
|
|
|
|
Move the iterator to the next item in hash table. It must be called
|
|
|
also after sht_iterator_start() to get the first item in the hash
|
|
@@ -778,7 +781,7 @@ sht_iterator_end("i1");
|
|
|
6.2. sht_dump
|
|
|
6.3. sht_delete
|
|
|
|
|
|
-6.1. sht_reload
|
|
|
+6.1. sht_reload
|
|
|
|
|
|
Reload a hash table from database.
|
|
|
|
|
@@ -791,7 +794,7 @@ sht_iterator_end("i1");
|
|
|
_hash_table_name_
|
|
|
_empty_line_
|
|
|
|
|
|
-6.2. sht_dump
|
|
|
+6.2. sht_dump
|
|
|
|
|
|
Dump content of a hash table via MI.
|
|
|
|
|
@@ -804,7 +807,7 @@ sht_iterator_end("i1");
|
|
|
_hash_table_name_
|
|
|
_empty_line_
|
|
|
|
|
|
-6.3. sht_delete
|
|
|
+6.3. sht_delete
|
|
|
|
|
|
Delete a key from a hash table via MI.
|
|
|
|
|
@@ -834,7 +837,7 @@ sht_iterator_end("i1");
|
|
|
7.7. htable.listTables
|
|
|
7.8. htable.stats
|
|
|
|
|
|
-7.1. htable.get htable key
|
|
|
+7.1. htable.get htable key
|
|
|
|
|
|
Lists one value in a hash table
|
|
|
|
|
@@ -853,7 +856,7 @@ kamcmd htable.get students daniel
|
|
|
kamcmd htable.get students course[0]
|
|
|
...
|
|
|
|
|
|
-7.2. htable.delete htable key
|
|
|
+7.2. htable.delete htable key
|
|
|
|
|
|
Delete one value in a hash table
|
|
|
|
|
@@ -872,7 +875,7 @@ kamcmd htable.delete students anna
|
|
|
kamcmd htable.delete students course[0]
|
|
|
...
|
|
|
|
|
|
-7.3. htable.sets htable key value
|
|
|
+7.3. htable.sets htable key value
|
|
|
|
|
|
Set an item in hash table to string value.
|
|
|
|
|
@@ -892,7 +895,7 @@ kamcmd htable.sets test x abc
|
|
|
kamcmd htable.sets test x[0] abc
|
|
|
...
|
|
|
|
|
|
-7.4. htable.seti htable key value
|
|
|
+7.4. htable.seti htable key value
|
|
|
|
|
|
Set an item in hash table to integer value.
|
|
|
|
|
@@ -912,7 +915,7 @@ kamcmd htable.seti test x 123
|
|
|
kamcmd htable.sets test x[0] 123
|
|
|
...
|
|
|
|
|
|
-7.5. htable.dump htable
|
|
|
+7.5. htable.dump htable
|
|
|
|
|
|
Lists all the values in a hash table
|
|
|
|
|
@@ -926,7 +929,7 @@ kamcmd htable.sets test x[0] 123
|
|
|
kamcmd htable.dump ipban
|
|
|
...
|
|
|
|
|
|
-7.6. htable.reload htable
|
|
|
+7.6. htable.reload htable
|
|
|
|
|
|
Reload hash table from database.
|
|
|
|
|
@@ -940,7 +943,7 @@ kamcmd htable.dump ipban
|
|
|
kamcmd htable.reload ipban
|
|
|
...
|
|
|
|
|
|
-7.7. htable.listTables
|
|
|
+7.7. htable.listTables
|
|
|
|
|
|
Lists all defined tables
|
|
|
|
|
@@ -954,7 +957,7 @@ kamcmd htable.reload ipban
|
|
|
kamcmd htable.listTables
|
|
|
...
|
|
|
|
|
|
-7.8. htable.stats
|
|
|
+7.8. htable.stats
|
|
|
|
|
|
Get statistics for hash tables - name, number of slots, number of
|
|
|
items, max number of items per slot, min number of items per slot.
|
|
@@ -974,7 +977,7 @@ kamcmd htable.stats
|
|
|
8.1. htable:mod-init
|
|
|
8.2. htable:expired:<table>
|
|
|
|
|
|
-8.1. htable:mod-init
|
|
|
+8.1. htable:mod-init
|
|
|
|
|
|
When defined, the module calls event_route[htable:mod-init] after all
|
|
|
modules have been initialized. A typical use case is to initialise
|
|
@@ -987,7 +990,7 @@ event_route[htable:mod-init] {
|
|
|
}
|
|
|
...
|
|
|
|
|
|
-8.2. htable:expired:<table>
|
|
|
+8.2. htable:expired:<table>
|
|
|
|
|
|
When defined, the module calls event_route[htable:expired:<table>] when
|
|
|
an entry in the given table expires. In this event route, the key and
|