Skip to content

Commit aa7adb9

Browse files
author
Piotr Kucharski
committed
add mod_pgsql iauth module
it allows logging connections to pgsql table, and querying another pgsql table for ip-based klines.
1 parent 9be2fb0 commit aa7adb9

10 files changed

+677
-41
lines changed

Diff for: doc/iauth.conf.5

+41-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
.\" @(#)$Id: iauth.conf.5,v 1.24 2014/08/25 14:08:57 bif Exp $
2-
.TH IAUTH.CONF 5 "$Date: 2014/08/25 14:08:57 $"
1+
.\" @(#)$Id: iauth.conf.5,v 1.25 2014/09/03 10:50:01 bif Exp $
2+
.TH IAUTH.CONF 5 "$Date: 2014/09/03 10:50:01 $"
33
.SH NAME
44
iauth.conf \- The Internet Relay Chat Authentication Configuration File
55
.SH DESCRIPTION
@@ -165,22 +165,50 @@ This module checks client IP against DNS BL.
165165

166166
This module understands three options:
167167
.B log
168-
to log IP and connect date
168+
to log IP and connect date;
169169
.B reject
170-
to reject connections based on DNS BL
170+
to reject connections based on DNS BL;
171171
.B servers
172172
comma separated list of DNS BL servers to query
173-
against for rejecting connecting hosts
173+
against for rejecting connecting hosts.
174+
175+
.TP
176+
.B pgsql
177+
This module performs a basic logging of IPs to a PostgreSQL database and
178+
can reject clients based on their IP. This module will not create tables
179+
for you, you have to create them like this:
180+
.RS
181+
.RS
182+
.nf
183+
CREATE TABLE ircd_conn (ip cidr, date timestamp);
184+
CREATE TABLE ircd_kline (ip cidr);
185+
.fi
186+
.RE
187+
Also, you have to populate ircd_kline with IPs by other means, this module
188+
will not do it for you. For performance sake, put the database on localhost.
189+
190+
This module understands three options:
191+
.B log
192+
to log IP and connect date to database (into ircd_conn table);
193+
.B reject
194+
to reject connections based on IP (searching ircd_kline table);
195+
.B conn
196+
is the database connection string; it is taken verbatim and as such must be the
197+
last option.
198+
199+
Queries are not configurable. If you need different tables, field names
200+
or queries, you have to edit the source.
174201

175202
.SH EXAMPLE
176203
The following file will cause the IRC daemon to reject all connections
177204
originating from a system where an open proxy is running for hosts within
178205
*.fr and *.enserb.u-bordeaux.fr but not for other hosts matching
179206
*.u-bordeaux.fr. For all connections, an ident lookup (RFC 1413) will be
180-
performed as well as checking for WWW proxy on port 8080 and 3128.
181-
In addition, every connection is authenticated with the LHEx
182-
server at IP-address 127.0.0.1. Client will be let in after ident and
183-
lhex are done but if socks or webproxy finds an open proxy, client will
207+
performed, inserting connection logs to postgres, querying postgres for
208+
banned IPs, as well as checking for WWW proxy on port 8080 and 3128 and
209+
querying DNSBL. In addition, every connection is authenticated with the LHEx
210+
server at IP-address 127.0.0.1. Client will be let in after ident, lhex and
211+
pgsql are done but if socks, webproxy or dnsbl finds an open proxy, client will
184212
be removed asap.
185213

186214
.RS
@@ -190,6 +218,10 @@ module rfc931
190218
module lhex
191219
option = 127.0.0.1
192220

221+
module pgsql
222+
option = log,reject,conn=dbname=ircd password=secret host=localhost
223+
reason = Denied access (SQL)
224+
193225
delayed
194226

195227
module socks

Diff for: doc/iauth.conf.example

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#
22
# Default iauth configuration file
33
#
4-
# $Id: iauth.conf.example,v 1.5 2014/08/25 14:08:57 bif Exp $
4+
# $Id: iauth.conf.example,v 1.6 2014/09/03 10:50:01 bif Exp $
55
#
66

77
# Important note: there must be one tab only before modules options.
@@ -15,6 +15,11 @@ notimeout
1515
# in order for a new user connection to be accepted
1616
required
1717

18+
# Log connection to database and reject based on IP.
19+
#module pgsql
20+
# option = log,reject,conn=dbname=ircd password=sikret
21+
# reason = Denied access (SQL)
22+
1823
# Perform ident lookups
1924
module rfc931
2025

Diff for: iauth/a_conf.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
#ifndef lint
21-
static const volatile char rcsid[] = "@(#)$Id: a_conf.c,v 1.40 2014/08/25 14:08:57 bif Exp $";
21+
static const volatile char rcsid[] = "@(#)$Id: a_conf.c,v 1.41 2014/09/03 10:50:02 bif Exp $";
2222
#endif
2323

2424
#include "os.h"
@@ -83,6 +83,9 @@ char *conf_read(char *cfile)
8383
Mlist[Mcnt++] = &Module_lhex;
8484
Mlist[Mcnt++] = &Module_webproxy;
8585
Mlist[Mcnt++] = &Module_dnsbl;
86+
#ifdef USE_PGSQL
87+
Mlist[Mcnt++] = &Module_pgsql;
88+
#endif
8689
Mlist[Mcnt] = NULL;
8790

8891
cfh = fopen((cfile) ? cfile : IAUTHCONF_PATH, "r");

Diff for: iauth/a_externs.h

+3
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,6 @@
3434
#include "mod_lhex_ext.h"
3535
#include "mod_webproxy_ext.h"
3636
#include "mod_dnsbl_ext.h"
37+
#ifdef USE_PGSQL
38+
# include "mod_pgsql_ext.h"
39+
#endif

0 commit comments

Comments
 (0)