]> jfr.im git - irc/freenode/syn.git/commitdiff
Add help, initially for the facilities module
authorStephen Bennett <redacted>
Sun, 3 May 2009 19:18:10 +0000 (20:18 +0100)
committerStephen Bennett <redacted>
Sun, 3 May 2009 19:18:16 +0000 (20:18 +0100)
Makefile
facilities.c
help.c [new file with mode: 0644]
help/facility [new file with mode: 0644]
help/facility_add [new file with mode: 0644]
help/facility_addbl [new file with mode: 0644]
help/facility_del [new file with mode: 0644]
help/facility_list [new file with mode: 0644]
help/facility_rmbl [new file with mode: 0644]
help/facility_set [new file with mode: 0644]

index baf7674696943f6f31a48355684dcfd000bd7494..cf2d10a372e23e277ff036ce0088c7460d390b80 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -19,6 +19,8 @@ clean:
 install: $(MODULES)
        install -d $(PREFIX)/modules/syn
        install -t $(PREFIX)/modules/syn $(MODULES)
+       install -d $(PREFIX)/help/syn
+       install -t $(PREFIX)/help/syn help/*
 
 
 
index 7201d715c24597134e89a7b6878e9489b6d5689b..eac1f93621a234c64ab414ba9ee21807cbb8534b 100644 (file)
@@ -252,6 +252,14 @@ void _modinit(module_t *m)
     command_add(&syn_facility_rmbl, &syn_facility_cmds);
     command_add(&syn_facility_show, &syn_facility_cmds);
 
+    help_addentry(syn_helptree, "FACILITY", "help/syn/facility", NULL);
+    help_addentry(syn_helptree, "FACILITY ADD", "help/syn/facility_add", NULL);
+    help_addentry(syn_helptree, "FACILITY DEL", "help/syn/facility_del", NULL);
+    help_addentry(syn_helptree, "FACILITY SET", "help/syn/facility_set", NULL);
+    help_addentry(syn_helptree, "FACILITY ADDBL", "help/syn/facility_addbl", NULL);
+    help_addentry(syn_helptree, "FACILITY RMBL", "help/syn/facility_rmbl", NULL);
+    help_addentry(syn_helptree, "FACILITY LIST", "help/syn/facility_list", NULL);
+
     facility_heap = BlockHeapCreate(sizeof(facility_t), HEAP_USER);
     blacklist_heap = BlockHeapCreate(sizeof(bl_entry_t), HEAP_USER);
     facilities = mowgli_dictionary_create(strcasecmp);
@@ -263,6 +271,13 @@ void _moddeinit()
 {
     save_facilities();
 
+    help_delentry(syn_helptree, "FACILITY");
+    help_delentry(syn_helptree, "FACILITY ADD");
+    help_delentry(syn_helptree, "FACILITY DEL");
+    help_delentry(syn_helptree, "FACILITY SET");
+    help_delentry(syn_helptree, "FACILITY ADDBL");
+    help_delentry(syn_helptree, "FACILITY RMBL");
+    help_delentry(syn_helptree, "FACILITY LIST");
     hook_del_hook("user_add", facility_newuser);
     command_delete(&syn_facility, syn_cmdtree);
     mowgli_dictionary_destroy(facilities, free_facility, NULL);
diff --git a/help.c b/help.c
new file mode 100644 (file)
index 0000000..3462084
--- /dev/null
+++ b/help.c
@@ -0,0 +1,51 @@
+#include "atheme.h"
+
+#include "syn.h"
+
+DECLARE_MODULE_V1
+(
+        "syn/help", false, _modinit, _moddeinit,
+        "$Revision$",
+        "Stephen Bennett <stephen -at- freenode.net>"
+);
+
+static void syn_cmd_help(sourceinfo_t *si, int parc, char *parv[]);
+
+command_t syn_help = { "HELP", N_("Displays contextual help information."), "syn:general", 1, syn_cmd_help };
+
+void _modinit(module_t *m)
+{
+    use_syn_main_symbols(m);
+
+    command_add(&syn_help, syn_cmdtree);
+    help_addentry(syn_helptree, "HELP", "help/help", NULL);
+}
+
+void _moddeinit()
+{
+    command_delete(&syn_help, syn_cmdtree);
+    help_delentry(syn_helptree, "HELP");
+}
+
+/* HELP <command> [params] */
+void syn_cmd_help(sourceinfo_t *si, int parc, char *parv[])
+{
+    char *command = parv[0];
+
+    if (!command)
+    {
+        command_success_nodata(si, "***** \2%s Help\2 *****", syn->nick);
+
+        command_success_nodata(si, "\2%s\2 is a utility service to control access to the network.", syn->nick);
+        command_success_nodata(si, " ");
+
+        command_help(si, syn_cmdtree);
+
+        command_success_nodata(si, _("***** \2End of Help\2 *****"));
+
+        return;
+    }
+
+    /* take the command through the hash table */
+    help_display(si, command, syn_helptree);
+}
diff --git a/help/facility b/help/facility
new file mode 100644 (file)
index 0000000..6d6a4f5
--- /dev/null
@@ -0,0 +1,56 @@
+Help for \ 2FACILITY\ 2:
+
+The FACILITY command displays and manipulates facility
+definitions.
+
+A facility is roughly a related group of gateways, defined
+by a host prefix. Any new client connecting is checked
+against the list of facilities, and various actions may be
+taken based on this.
+
+Each facility has some or all of the following information
+defined:
+
+ - The hostname prefix
+ - Whether this facility is currently blocked
+ - The message to send to clients blocked by this facility.
+ - A throttle limit. This is of the form x,y and translates
+   rougly to y clients per x*y seconds.
+ - The message to send to clients denied because of this
+   facility's throttle.
+ - The cloaking scheme applied to matching clients.
+ - A blacklist of regular expressions. If any of these match
+   a client that matches this facility, it will be denied.
+
+Facilities are checked in order from least specific to most
+specific. If any facility is blocked, the client is killed,
+with the exception that a negative block value can override
+a positive one from a more general facility. If the client
+is determined to be blocked, the most specific configured
+block message is used.
+
+The throttle settings for every matching facility are
+checked and updated, even if the client is blocked. If the
+client is denied due to throttling, the most specific
+configured throttle message is used.
+
+For every matching facility, the client is checked against
+that facility's blacklist. If any of those regular
+expressions matches, then the client is denied, and the most
+specific block message so far encountered is used.
+
+If the client is allowed to connect, then the cloaking
+setting is used to determine whether to modify the client's
+visible host name. Again the most specific configured value
+is used. Possible values are:
+
+ - none. Leave the client's host alone.
+ - random. A 'session' marker in the client's host is
+   replaced by a random text string.
+ - hexip. The user's ident is treated as a hex-encoded IP
+   address, as used by several web gateways. A 'session'
+   marker in the user's host is replaced by 
+   'ip.<decoded ip>'. If the ident cannot be decoded this
+   way, it falls back to the random method.
+
+Valid subcommands are: \ 2FACILITY <LIST|ADD|DEL|SET|ADDBL|RMBL|SHOW>\ 2
diff --git a/help/facility_add b/help/facility_add
new file mode 100644 (file)
index 0000000..d0100db
--- /dev/null
@@ -0,0 +1,15 @@
+Help for \ 2FACILITY ADD\ 2:
+
+This command will add a new facility definition. The
+hostpart is a hostname prefix used to identify this gateway,
+and matched against connecting users. The optional cloaking
+argument determines the cloaking scheme used for users
+matching this gateway -- the default is \ 2undefined\ 2. See
+\ 2/msg &nick& HELP FACILITY\ 2 for valid cloaking values.
+
+Syntax: FACILITY ADD <hostpart> [cloaking]
+
+Examples:
+    /msg &nick& FACILITY ADD gateway/web/ajax/mibbit.com hexip
+    /msg &nick& FACILITY ADD gateway/tor random
+    /msg &nick& FACILITY ADD gateway/web
diff --git a/help/facility_addbl b/help/facility_addbl
new file mode 100644 (file)
index 0000000..9cc8693
--- /dev/null
@@ -0,0 +1,13 @@
+Help for \ 2FACILITY ADDBL\ 2:
+
+This adds a blacklist entry to a facility. Clients that
+match a given facility are checked against all blacklist
+entries for that facility, and any that match are denied.
+
+The regex is a PCRE expression, matched against
+"<nick>!<user>@<host> <gecos>".
+
+Syntax: /msg &nick& FACILITY ADDBL <hostpart> <regex>
+
+Examples:
+    /msg &nick& FACILITY ADDBL gateway/web !~?576a466a@
diff --git a/help/facility_del b/help/facility_del
new file mode 100644 (file)
index 0000000..ebcc83a
--- /dev/null
@@ -0,0 +1,9 @@
+Help for \ 2FACILITY DEL\ 2
+
+This permanently removes a facility definition, and all
+information associated with it. Use with caution.
+
+Syntax: FACILITY DEL <hostpart>
+
+Examples:
+    /msg &nick& FACILITY DEL gateway/web/cgiirc/defunct.site
diff --git a/help/facility_list b/help/facility_list
new file mode 100644 (file)
index 0000000..b86501c
--- /dev/null
@@ -0,0 +1,6 @@
+Help for \ 2FACILITY LIST\ 2:
+
+This displays the list of currently configured facilities,
+with brief information about settings.
+
+Syntax: /msg &nick& FACILITY LIST
diff --git a/help/facility_rmbl b/help/facility_rmbl
new file mode 100644 (file)
index 0000000..c6ace19
--- /dev/null
@@ -0,0 +1,12 @@
+Help for \ 2FACILITY RMBL\ 2:
+
+This removes a blacklist entry from a facility.
+
+See also: /msg &nick& HELP FACILITY ADDBL
+          /msg &nick& HELP FACILITY
+
+Syntax: /msg &nick& FACILITY RMBL <hostpart> <regex>
+
+Examples:
+    /msg &nick& FACILITY RMBL gateway/web !~?576a466a@
+
diff --git a/help/facility_set b/help/facility_set
new file mode 100644 (file)
index 0000000..4405863
--- /dev/null
@@ -0,0 +1,21 @@
+Help for \ 2FACILITY SET\ 2:
+
+Modifies a facility definition.
+
+Possible settings are:
+
+ - cloaking
+ - blocked
+ - throttle
+ - blockmessage
+ - throttlemessage
+
+See \ 2/msg &nick& HELP FACILITY\ 2 for the meaning of each
+setting.
+
+Syntax: /msg &nick& FACILITY SET <hostpart> <setting> <value>
+
+Examples:
+    /msg &nick& FACILITY SET gateway/web/ajax/mibbit.com blocked 1
+    /msg &nick& FACILITY SET gateway/tor throttle 5,3
+    /msg &nick& FACILITY SET gateway/web/cgiirc/site.com cloaking hexip