├── ChangeLog ├── README.md ├── .vimrc ├── debian ├── compat ├── patches │ ├── series │ └── debian-config ├── oftc-ircservices.postrm ├── oftc-ircservices.postinst ├── changelog ├── rules ├── control └── oftc-ircservices.init ├── etc ├── ctcpserv.sample.yaml ├── moran.sample.yaml ├── Makefile.am └── bopm.sample.yaml ├── scripts ├── migrate-db.yaml └── dblink-script.rb ├── include ├── nickserv.h ├── chanserv.h ├── groupserv.h ├── conf │ ├── Makefile.am │ ├── mail.h │ ├── connect.h │ ├── database.h │ ├── service.h │ ├── logging.h │ ├── servicesinfo.h │ ├── modules.h │ └── manager.h ├── conf.h ├── dbmail.h ├── python_module.h ├── operserv.h ├── connection.h ├── tor.h ├── ruby_module.h ├── crypt.h ├── packet.h ├── kill.h ├── send.h ├── language.h ├── services.h ├── stdinc.h ├── mqueue.h ├── floodserv.h ├── jupe.h ├── Makefile.am ├── akill.h ├── events.h ├── groupaccess.h ├── akick.h ├── chanaccess.h ├── defines.h ├── hash.h ├── hostmask.h ├── channel.h ├── group.h ├── parse.h └── servicemask.h ├── TODO ├── languages ├── floodserv.en.lang ├── jupeserv.en.lang ├── Makefile.am ├── rubyserv.en.lang ├── bopm.en.lang ├── ctcpserv.en.lang ├── moranserv.en.lang ├── langcheck.c ├── services.en.lang └── ganneffserv.en.lang ├── libio ├── mem │ ├── Makefile.am │ ├── memory.c │ ├── dynlink.h │ ├── dbuf.h │ ├── dynlink.c │ ├── memory.h │ └── dbuf.c ├── misc │ ├── Makefile.am │ ├── libio_getopt.h │ ├── hook.h │ ├── event.h │ ├── log.h │ ├── misc.h │ ├── list.h │ └── libio_getopt.c ├── comm │ ├── Makefile.am │ ├── rlimits.h │ ├── fileio.h │ └── comm.h ├── Makefile.am ├── net │ ├── Makefile.am │ ├── res.h │ ├── irc_getnameinfo.h │ └── irc_getaddrinfo.h ├── string │ ├── README │ ├── Makefile.am │ ├── AUTHORS │ ├── sprintf_irc.h │ ├── pcre_tables.c │ ├── LICENCE │ └── pcre_globals.c ├── libioinc.h └── irc_libio.h ├── sql ├── Makefile.am ├── moranserv-pgsql.sql ├── ganneffserv-pgsql.sql ├── ctcpserv-pgsql.sql ├── groupserv-pgsql.sql ├── operserv-pgsql.sql ├── common-pgsql.sql ├── views-pgsql.sql └── chanserv-pgsql.sql ├── src ├── conf │ ├── Makefile.am │ ├── mail.c │ ├── database.c │ ├── connect.c │ └── service.c ├── python_module │ ├── Makefile.am │ ├── libpython_module.h │ └── python_module.c ├── ruby_module │ ├── Makefile.am │ ├── dbrow.c │ ├── dbresult.c │ └── libruby_module.h ├── dbmail.c ├── Makefile.am ├── m_error.c ├── conf.c ├── tor.c ├── mqueue.c ├── kill.c ├── language.c └── event.c ├── README ├── .gitignore ├── .travis.yml ├── Makefile.am ├── modules ├── XmlRpc.rb ├── PythonServ.py ├── Makefile.am ├── ServiceBase.rb └── JupeServ.rb ├── AUTHORS ├── INSTALL ├── tools └── release ├── autogen.sh ├── testcases └── nickserv.test.plan └── configure.ac /ChangeLog: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | README -------------------------------------------------------------------------------- /.vimrc: -------------------------------------------------------------------------------- 1 | set sw=2 et 2 | -------------------------------------------------------------------------------- /debian/compat: -------------------------------------------------------------------------------- 1 | 9 2 | -------------------------------------------------------------------------------- /debian/patches/series: -------------------------------------------------------------------------------- 1 | debian-config 2 | -------------------------------------------------------------------------------- /etc/ctcpserv.sample.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | verbose: true 3 | channel: "#test" 4 | akill_duration: 2592000 # 30 days in seconds 5 | -------------------------------------------------------------------------------- /etc/moran.sample.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | times: 3 | - time: 30 4 | warn: 10 5 | - time: 300 6 | warn: 100 7 | - time: 3600 8 | warn: 1000 9 | -------------------------------------------------------------------------------- /etc/Makefile.am: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2006 Luca Filipozzi 2 | MAINTAINERCLEANFILES=Makefile.in 3 | dist_sysconf_DATA=example.conf bopm.sample.yaml moran.sample.yaml 4 | -------------------------------------------------------------------------------- /scripts/migrate-db.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | source_str: "dbi:Mysql:dbname=" 3 | source_user: nil 4 | source_pass: nil 5 | dest_str: "dbi:Pg:dbname=" 6 | dest_user: nil 7 | dest_pass: nil 8 | -------------------------------------------------------------------------------- /debian/oftc-ircservices.postrm: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | 3 | case $1 in 4 | purge) 5 | rm -rf /var/log/oftc-ircservices 6 | ;; 7 | esac 8 | 9 | #DEBHELPER# 10 | 11 | exit 0 12 | -------------------------------------------------------------------------------- /include/nickserv.h: -------------------------------------------------------------------------------- 1 | /* TODO: add copyright block */ 2 | 3 | #ifndef INCLUDED_nickserv_h 4 | #define INCLUDED_nickserv_h 5 | #include "nickserv-lang.h" 6 | 7 | #endif /* INCLUDED_nickserv_h */ 8 | -------------------------------------------------------------------------------- /include/chanserv.h: -------------------------------------------------------------------------------- 1 | /* TODO: add copyright block */ 2 | 3 | #ifndef INCLUDED_chanserv_h 4 | #define INCLUDED_chanserv_h 5 | 6 | #include "chanserv-lang.h" 7 | 8 | #endif /* INCLUDED_chanserv_h */ 9 | -------------------------------------------------------------------------------- /include/groupserv.h: -------------------------------------------------------------------------------- 1 | /* TODO: add copyright block */ 2 | 3 | #ifndef INCLUDED_groupserv_h 4 | #define INCLUDED_groupserv_h 5 | #include "groupserv-lang.h" 6 | 7 | #endif /* INCLUDED_groupserv_h */ 8 | -------------------------------------------------------------------------------- /include/conf/Makefile.am: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2006 Luca Filipozzi 2 | MAINTAINERCLEANFILES=Makefile.in 3 | noinst_HEADERS=conf.h connect.h database.h logging.h manager.h modules.h servicesinfo.h service.h mail.h 4 | -------------------------------------------------------------------------------- /include/conf.h: -------------------------------------------------------------------------------- 1 | /* TODO: add copyright block */ 2 | 3 | #ifndef INCLUDED_conf_h 4 | #define INCLUDED_conf_h 5 | 6 | int conf_fbgets(char *, int, FBFILE *); 7 | void read_services_conf(int); 8 | 9 | #endif /* INCLUDED_conf_h */ 10 | -------------------------------------------------------------------------------- /include/dbmail.h: -------------------------------------------------------------------------------- 1 | #ifndef INCLUDED_dbmail_h 2 | #define INCLUDED_dbmail_h 3 | 4 | int dbmail_add_sent(unsigned int, const char*); 5 | int dbmail_is_sent(unsigned int, const char*); 6 | void dbmail_expire_sentmail(void*); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | - Make the yada configure check not suck 2 | - Talk TS6 properly 3 | 4 | Legend: 5 | - Not done 6 | * Top priority 7 | . Partially done 8 | d Deferrable 9 | D Deferred 10 | X Abandoned 11 | -------------------------------------------------------------------------------- /include/python_module.h: -------------------------------------------------------------------------------- 1 | #ifndef PYTHON_MODULE_H 2 | #define PYTHON_MODULE_H 3 | 4 | void init_python(); 5 | void cleanup_python(); 6 | int load_python_module(const char *, const char *, const char *); 7 | int unload_python_module(const char *); 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /languages/floodserv.en.lang: -------------------------------------------------------------------------------- 1 | 0 English 2 | FS_HELP_NOHELP 3 | %s: There is no help for FloodServ 4 | FS_HELP_SHORT 5 | %s: There is no help for FloodServ, see /msg ChanServ HELP SET FloodServ 6 | FS_HELP_LONG 7 | There is no help available for FloodServ, see /msg ChanServ HELP SET FloodServ 8 | -------------------------------------------------------------------------------- /libio/mem/Makefile.am: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2006 Luca Filipozzi 2 | 3 | AM_CPPFLAGS= $(LTDLINCL) 4 | 5 | MAINTAINERCLEANFILES=Makefile.in 6 | noinst_LIBRARIES=libmem.a 7 | libmem_a_SOURCES=balloc.c balloc.h dbuf.c dbuf.h dynlink.c dynlink.h memory.c memory.h 8 | libmem_a_CFLAGS=-I.. -DIN_LIBIO 9 | -------------------------------------------------------------------------------- /include/operserv.h: -------------------------------------------------------------------------------- 1 | /* TODO: add copyright block */ 2 | 3 | #ifndef INCLUDED_operserv_h 4 | #define INCLUDED_operserv_h 5 | 6 | #include "operserv-lang.h" 7 | 8 | #define OPERSERV_AKILL_CHECK_TIME 10 9 | #define OPERSERV_AKILL_CHECK_CNT 100 10 | 11 | #endif /* INCLUDED_operserv_h */ 12 | -------------------------------------------------------------------------------- /libio/misc/Makefile.am: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2006 Luca Filipozzi 2 | MAINTAINERCLEANFILES=Makefile.in 3 | noinst_LIBRARIES=libmisc.a 4 | libmisc_a_SOURCES=crypt.c event.c event.h hook.c hook.h libio_getopt.c libio_getopt.h list.c list.h log.c log.h misc.c misc.h 5 | libmisc_a_CFLAGS=-I.. -DIN_LIBIO 6 | 7 | -------------------------------------------------------------------------------- /libio/comm/Makefile.am: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2006 Luca Filipozzi 2 | MAINTAINERCLEANFILES=Makefile.in 3 | noinst_LIBRARIES=libcomm.a 4 | libcomm_a_SOURCES=comm.c comm.h devpoll.c epoll.c fdlist.c fdlist.h fileio.c fileio.h kqueue.c poll.c rlimits.h select.c sigio.c win32.c 5 | libcomm_a_CFLAGS=-I.. -DIN_LIBIO 6 | -------------------------------------------------------------------------------- /libio/Makefile.am: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2006 Luca Filipozzi 2 | MAINTAINERCLEANFILES=Makefile.in 3 | SUBDIRS=comm mem misc net string 4 | noinst_LIBRARIES=libio.a 5 | libio_a_SOURCES=irc_libio.h libioinc.h 6 | libio_a_LIBADD=$(foreach dir,$(SUBDIRS),$(wildcard $(dir)/*.$(OBJEXT))) 7 | libio_a_CFLAGS=-DIN_LIBIO 8 | -------------------------------------------------------------------------------- /libio/net/Makefile.am: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2006 Luca Filipozzi 2 | MAINTAINERCLEANFILES=Makefile.in 3 | noinst_LIBRARIES=libnet.a 4 | libnet_a_SOURCES=inet_misc.c inet_misc.h irc_getaddrinfo.c irc_getaddrinfo.h irc_getnameinfo.c irc_getnameinfo.h res.c res.h reslib.c reslib.h 5 | libnet_a_CFLAGS=-I.. -DIN_LIBIO 6 | 7 | -------------------------------------------------------------------------------- /debian/oftc-ircservices.postinst: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | 3 | case $1 in 4 | configure) 5 | getent passwd irc > /dev/null 2>&1 || 6 | adduser --system --home /var/run/ircd --no-create-home --gid irc irc 7 | chown irc:irc /var/log/oftc-ircservices 8 | ;; 9 | esac 10 | 11 | #DEBHELPER# 12 | 13 | exit 0 14 | -------------------------------------------------------------------------------- /include/connection.h: -------------------------------------------------------------------------------- 1 | /* TODO: add copyright block */ 2 | 3 | #ifndef INCLUDED_connection_h 4 | #define INCLUDED_connection_h 5 | 6 | extern struct Client me; 7 | extern struct Callback *connected_cb; 8 | 9 | void connect_server(); 10 | CBFUNC server_connected; 11 | 12 | #endif /* INCLUDED_connection_h */ 13 | -------------------------------------------------------------------------------- /include/tor.h: -------------------------------------------------------------------------------- 1 | #ifndef INCLUDED_tor_h 2 | #define INCLUDED_tor_h 3 | 4 | struct TorNode { 5 | /* hash linked list */ 6 | struct TorNode *next; 7 | /* iterable list */ 8 | dlink_node node; 9 | 10 | char host[HOSTLEN+1]; 11 | }; 12 | 13 | void init_tor(); 14 | void cleanup_tor(); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /sql/Makefile.am: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2006 Luca Filipozzi 2 | 3 | MAINTAINERCLEANFILES=Makefile.in 4 | dist_pkgdata_DATA= \ 5 | common-pgsql.sql \ 6 | chanserv-pgsql.sql \ 7 | ganneffserv-pgsql.sql \ 8 | groupserv-pgsql.sql \ 9 | nickserv-pgsql.sql \ 10 | operserv-pgsql.sql \ 11 | views-pgsql.sql 12 | 13 | -------------------------------------------------------------------------------- /libio/string/README: -------------------------------------------------------------------------------- 1 | /* $Id$ */ 2 | 3 | 4 | PCRE (Perl Compatible Regular Expression) library version 6.3 (latest as 5 | of Sep 2, 2005) from http://www.pcre.org hacked up for use in ircd-hybrid. 6 | 7 | Original licensing information and copyright notices can be found in the 8 | LICENCE and AUTHORS files. 9 | 10 | -Michael 11 | -------------------------------------------------------------------------------- /include/ruby_module.h: -------------------------------------------------------------------------------- 1 | /* TODO: add copyright block */ 2 | 3 | #ifndef INCLUDED_ruby_module_h 4 | #define INCLUDED_ruby_module_h 5 | 6 | void init_ruby(); 7 | void cleanup_ruby(); 8 | int load_ruby_module(const char *, const char *, const char *); 9 | int unload_ruby_module(const char *); 10 | 11 | #endif /* INCLUDED_ruby_module_h */ 12 | -------------------------------------------------------------------------------- /src/conf/Makefile.am: -------------------------------------------------------------------------------- 1 | # Copyright (C) Luca Filipozzi 2 | MAINTAINERCLEANFILES=Makefile.in 3 | noinst_LIBRARIES=libconf.a 4 | libconf_a_SOURCES=parser.y lexer.l conf.c connect.c database.c logging.c modules.c servicesinfo.c service.c mail.c 5 | libconf_a_CFLAGS=-I$(top_srcdir)/libio -I$(top_srcdir)/include -I$(top_srcdir)/languages 6 | AM_YFLAGS=-d 7 | -------------------------------------------------------------------------------- /debian/changelog: -------------------------------------------------------------------------------- 1 | oftc-ircservices (1.5.12-1) UNRELEASED; urgency=medium 2 | 3 | * New upstream release. 4 | 5 | -- Christoph Berg Wed, 07 Sep 2016 14:03:09 +0200 6 | 7 | oftc-ircservices (1.2.0-pre4-1) unstable; urgency=low 8 | 9 | * Initial release. 10 | 11 | -- Christoph Berg Fri, 21 Dec 2007 23:34:31 +0100 12 | -------------------------------------------------------------------------------- /include/crypt.h: -------------------------------------------------------------------------------- 1 | /* TODO: add copyright block */ 2 | 3 | #ifndef INCLUDED_crypt_h 4 | #define INCLUDED_crypt_h 5 | 6 | #define DIGEST_FUNCTION "SHA1" 7 | #define DIGEST_LEN 20 8 | 9 | char *generate_md5_salt(char *, int); 10 | char *crypt_pass(char *, int); 11 | void 12 | base16_encode(char *, size_t, const char *, size_t); 13 | 14 | #endif /* INCLUDED_crypt_h */ 15 | -------------------------------------------------------------------------------- /include/packet.h: -------------------------------------------------------------------------------- 1 | /* TODO: add copyright block */ 2 | 3 | #ifndef INCLUDED_packet_h 4 | #define INCLUDED_packet_h 5 | 6 | extern struct Callback *iorecv_cb; 7 | extern struct Callback *iosend_cb; 8 | 9 | void *iorecv_default(va_list args); 10 | void *iosend_default(va_list args); 11 | void read_packet(fde_t *, void *); 12 | 13 | #endif /* INCLUDED_packet_h */ 14 | -------------------------------------------------------------------------------- /src/python_module/Makefile.am: -------------------------------------------------------------------------------- 1 | # Copyright (C) Luca Filipozzi 2 | MAINTAINERCLEANFILES=Makefile.in 3 | noinst_LIBRARIES=libpython_module.a 4 | libpython_module_a_SOURCES= python_module.c \ 5 | servicemodule.c \ 6 | client.c \ 7 | libpython_module.h 8 | 9 | libpython_module_a_CFLAGS=-I$(top_srcdir)/libio -I$(top_srcdir)/include -I$(top_srcdir)/languages @PYTHON_CFLAGS@ 10 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | oftc-ircservices 2 | ================ 3 | 4 | [![Build Status](https://travis-ci.org/oftc/oftc-ircservices.svg?branch=develop)](https://travis-ci.org/oftc/oftc-ircservices) 5 | 6 | IRC services as used by OFTC (https://www.oftc.net) 7 | 8 | See INSTALL for instructions on how to install this package, and once they are 9 | online see /msg ServiceName HELP for help using the services. 10 | -------------------------------------------------------------------------------- /libio/string/Makefile.am: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2006 Luca Filipozzi 2 | MAINTAINERCLEANFILES=Makefile.in 3 | noinst_LIBRARIES=libstring.a 4 | libstring_a_SOURCES=irc_string.h match.c pcre_chartables.c pcre_compile.c pcre_exec.c pcre_fullinfo.c pcre_globals.c pcre.h pcre_internal.h pcre_study.c pcre_tables.c pcre_try_flipped.c snprintf.c sprintf_irc.c sprintf_irc.h string.c 5 | libstring_a_CFLAGS=-I.. -DIN_LIBIO 6 | -------------------------------------------------------------------------------- /sql/moranserv-pgsql.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE IF EXISTS moranserv_track CASCADE; 2 | CREATE TABLE moranserv_track ( 3 | id SERIAL PRIMARY KEY, 4 | setter INTEGER REFERENCES account(id) ON DELETE SET NULL, 5 | time INTEGER NOT NULL, 6 | track VARCHAR(255) NOT NULL, 7 | reason VARCHAR(255) NOT NULL 8 | ); 9 | CREATE UNIQUE INDEX moranserv_track_idx ON moranserv_track ((lower(track))); 10 | -------------------------------------------------------------------------------- /include/kill.h: -------------------------------------------------------------------------------- 1 | #ifndef INCLUDED_kill_h 2 | #define INCLUDED_kill_h 3 | 4 | void init_kill(); 5 | void kill_user(struct Service *, struct Client *, const char *); 6 | void kill_remove_service(struct Service *); 7 | void kill_remove_client(struct Client *); 8 | 9 | struct KillRequest 10 | { 11 | struct Service *service; 12 | struct Client *client; 13 | const char *reason; 14 | }; 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /languages/jupeserv.en.lang: -------------------------------------------------------------------------------- 1 | 0 English 2 | JS_HELP_SHORT 3 | %s: Shows this help message 4 | JS_HELP_LONG 5 | Shows this help message 6 | JS_HELP_JUPE_SHORT 7 | %s: Jupiter a server 8 | JS_HELP_JUPE_LONG 9 | Usage: JUPE  10 | 11 | Jupiter a server 12 | 13 | Example: JUPE jupiter.example.com 14 | JS_HELP_LIST_SHORT 15 | %s: List all jupitered servers 16 | JS_HELP_LIST_LONG 17 | Usage: LIST 18 | List all jupitered servers 19 | -------------------------------------------------------------------------------- /src/ruby_module/Makefile.am: -------------------------------------------------------------------------------- 1 | # Copyright (C) Luca Filipozzi 2 | MAINTAINERCLEANFILES=Makefile.in 3 | noinst_LIBRARIES=libruby_module.a 4 | libruby_module_a_SOURCES= channel.c \ 5 | client.c \ 6 | db.c \ 7 | dbchannel.c \ 8 | dbresult.c \ 9 | dbrow.c \ 10 | libruby_module.h \ 11 | nickname.c \ 12 | servicemodule.c \ 13 | ruby_module.c 14 | libruby_module_a_CFLAGS=-I$(top_srcdir)/libio -I$(top_srcdir)/include -I$(top_srcdir)/languages @RUBY_CFLAGS@ 15 | -------------------------------------------------------------------------------- /include/send.h: -------------------------------------------------------------------------------- 1 | /* TODO: add copyright block */ 2 | 3 | #ifndef INCLUDED_send_h 4 | #define INCLUDED_send_h 5 | 6 | void send_queued_write(struct Client *); 7 | void send_queued_all(void); 8 | void sendto_server(struct Client *, const char *, ...); 9 | 10 | #define ALL_MEMBERS 0 11 | #define NON_CHANOPS 1 12 | #define ONLY_CHANOPS_VOICED 2 13 | #define ONLY_CHANOPS 3 14 | #define ONLY_SERVERS 4 /* for channel_mode.c */ 15 | 16 | #endif /* INCLUDED_send_h */ 17 | -------------------------------------------------------------------------------- /sql/ganneffserv-pgsql.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE IF EXISTS ganneffserv CASCADE; 2 | CREATE TABLE ganneffserv ( 3 | id SERIAL PRIMARY KEY, 4 | setter INTEGER REFERENCES account(id) ON DELETE SET NULL, 5 | time INTEGER NOT NULL, 6 | channel VARCHAR(255) NOT NULL, 7 | reason VARCHAR(255) NOT NULL, 8 | kills INTEGER NOT NULL DEFAULT 0, 9 | monitor_only BOOLEAN NOT NULL DEFAULT 'False' 10 | ); 11 | CREATE UNIQUE INDEX ganneffserv_channel_idx ON ganneffserv (irc_lower(channel)); 12 | -------------------------------------------------------------------------------- /debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | 3 | # ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var 4 | # cd $(CURDIR)/debian/oftc-ircservices/etc && mv example.conf oftc-ircservices/services.conf 5 | # cd $(CURDIR)/debian/oftc-ircservices/usr/bin && mv services oftc-ircservices 6 | 7 | override_dh_auto_configure: 8 | ./autogen.sh 9 | dh_auto_configure 10 | 11 | override_dh_auto_clean: 12 | # ignore errors because libltdl/ might not yet be there 13 | -dh_auto_clean 14 | 15 | %: 16 | dh $@ 17 | -------------------------------------------------------------------------------- /src/python_module/libpython_module.h: -------------------------------------------------------------------------------- 1 | #ifndef LIBPYTHON_MODULE_H 2 | #define LIBPYTHON_MODULE_H 3 | 4 | typedef struct 5 | { 6 | PyObject_HEAD 7 | PyObject *cservice; 8 | PyObject *client; 9 | } Service; 10 | 11 | typedef struct 12 | { 13 | PyObject_HEAD 14 | PyObject *client; 15 | PyObject *nick; 16 | PyObject *from; 17 | } PClient; 18 | 19 | PyObject *init_python_servicemodule(); 20 | void init_python_client(PyObject *); 21 | PClient *PClient_from_client(struct Client *); 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.in 3 | *.la 4 | *.lo 5 | *.a 6 | Makefile 7 | *.deps 8 | *.libs 9 | aclocal.m4 10 | autom4te.cache/ 11 | compile 12 | config.guess 13 | config.h 14 | config.h.in~ 15 | config.log 16 | config.status 17 | config.sub 18 | configure 19 | depcomp 20 | install-sh 21 | languages/*.h 22 | languages/langcheck 23 | libltdl/ 24 | libtool 25 | ltmain.sh 26 | missing 27 | src/conf/lexer.c 28 | src/conf/lex.yylexer.c 29 | src/conf/parser.c 30 | src/conf/parser.h 31 | src/services 32 | stamp-h1 33 | ylwrap 34 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | dist: trusty 2 | sudo: required 3 | language: c 4 | compiler: 5 | - clang 6 | - gcc 7 | 8 | install: 9 | - sudo apt-get install -y debhelper pkg-config zlib1g-dev libbsd-dev libevent-dev autoconf automake libtool libltdl-dev libpq-dev postgresql-server-dev-all libssl-dev ruby ruby-dev flex bison 10 | # Disable travis-provided ruby 11 | - if test -d $HOME/.rvm; then mv $HOME/.rvm $HOME/.rvm.disabled; fi 12 | 13 | before_script: 14 | - ./autogen.sh 15 | 16 | script: 17 | - make 18 | 19 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2006 Luca Filipozzi 2 | MAINTAINERCLEANFILES=aclocal.m4 config.h.in config.h.in~ config.guess config.log config.status config.sub configure install-sh missing mkinstalldirs Makefile.in depcomp compile ltmain.sh COPYING 3 | SUBDIRS=libltdl libio languages modules include src etc sql 4 | 5 | maintainer-clean-local: 6 | rm -f ${PACKAGE}-${VERSION}.tar.gz 7 | rm -rf libltdl 8 | 9 | install-data-local: 10 | $(INSTALL) -d $(DESTDIR)${localstatedir}/log 11 | $(INSTALL) -d $(DESTDIR)${localstatedir}/run 12 | -------------------------------------------------------------------------------- /modules/XmlRpc.rb: -------------------------------------------------------------------------------- 1 | class MyHandler 2 | def sumAndDifference(a, b) 3 | { "sum" => a + b, "difference" => a - b } 4 | end 5 | end 6 | 7 | class XmlRpc < ServiceModule 8 | require "xmlrpc/server" 9 | def initialize 10 | service_name("XmlRpc") 11 | begin 12 | # foo = Thread.new { 13 | 14 | # @s = XMLRPC::Server.new(8080) 15 | # @s.add_handler("sample", MyHandler.new) 16 | # @s.serve 17 | # } 18 | rescue Exception => ex 19 | puts ex 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /include/language.h: -------------------------------------------------------------------------------- 1 | /* TODO: add copyright block */ 2 | 3 | #ifndef INCLUDED_language_h 4 | #define INCLUDED_language_h 5 | 6 | #define LANG_EN 0 7 | #define LANG_NAUGHTY 1 8 | #define LANG_DE 2 9 | #define LANG_LAST 3 10 | 11 | #define LANG_TABLE_SIZE 512 12 | 13 | struct LanguageFile 14 | { 15 | char *name; 16 | char *entries[LANG_TABLE_SIZE]; 17 | }; 18 | 19 | void load_language(struct LanguageFile *, const char *); 20 | void unload_languages(struct LanguageFile *); 21 | 22 | #endif /* INCLUDED_language_h */ 23 | -------------------------------------------------------------------------------- /modules/PythonServ.py: -------------------------------------------------------------------------------- 1 | from ServiceModule import Service 2 | 3 | class PythonServ(Service): 4 | def __init__(self, service): 5 | self.cservice = service 6 | self.register( 7 | ("HELP", 0, 2, 0, 0, 0, 0), 8 | ) 9 | 10 | def HELP(self, client, parv): 11 | print self 12 | print client 13 | print client.name 14 | print client.host 15 | print client.username 16 | print parv 17 | print len(parv) 18 | if len(parv) == 1: 19 | self.do_help(client, "", parv) 20 | else: 21 | self.do_help(client, parv[1], parv) 22 | -------------------------------------------------------------------------------- /libio/string/AUTHORS: -------------------------------------------------------------------------------- 1 | /* $Id$ */ 2 | 3 | THE MAIN PCRE LIBRARY 4 | --------------------- 5 | 6 | Written by: Philip Hazel 7 | Email local part: ph10 8 | Email domain: cam.ac.uk 9 | 10 | University of Cambridge Computing Service, 11 | Cambridge, England. Phone: +44 1223 334714. 12 | 13 | Copyright (c) 1997-2005 University of Cambridge 14 | All rights reserved 15 | 16 | 17 | THE C++ WRAPPER LIBRARY 18 | ----------------------- 19 | 20 | Written by: Google Inc. 21 | 22 | Copyright (c) 2005 Google Inc 23 | All rights reserved 24 | 25 | #### 26 | -------------------------------------------------------------------------------- /sql/ctcpserv-pgsql.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE IF EXISTS ctcpserv_bad_versions CASCADE; 2 | CREATE TABLE ctcpserv_bad_versions ( 3 | id SERIAL PRIMARY KEY, 4 | setter INTEGER REFERENCES account(id) ON DELETE SET NULL, 5 | time INTEGER NOT NULL, 6 | pattern VARCHAR(1024) NOT NULL, 7 | reason VARCHAR(512) NOT NULL, 8 | kills INTEGER NOT NULL DEFAULT 0, 9 | monitor_only BOOLEAN NOT NULL DEFAULT 'False', 10 | active BOOLEAN NOT NULL DEFAULT 'True' 11 | ); 12 | CREATE UNIQUE INDEX ctcpserv_bad_versions_pattern_idx ON ctcpserv_bad_versions (pattern); 13 | -------------------------------------------------------------------------------- /include/services.h: -------------------------------------------------------------------------------- 1 | /* TODO: add copyright block */ 2 | 3 | #ifndef INCLUDED_services_h 4 | #define INCLUDED_services_h 5 | 6 | void services_die(const char *, int); 7 | 8 | #include "services-lang.h" 9 | 10 | struct ServicesState_t 11 | { 12 | char *configfile; 13 | char *logfile; 14 | char *dblogfile; 15 | char *pidfile; 16 | char *namesuffix; 17 | int foreground; 18 | int printversion; 19 | int debugmode; 20 | int keepmodules; 21 | int fully_connected; 22 | }; 23 | 24 | EXTERN struct ServicesState_t ServicesState; 25 | EXTERN int dorehash; 26 | 27 | #endif /* INCLUDED_services_h */ 28 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | oftc-ircservices is a daemon written primary for usage on OFTC but designed 2 | with a few to be as generic a service as possible. The follow people helped 3 | made it happen, in alphabetical order: 4 | 5 | Luca Filipozzi 6 | - converted build system to automake/libtool 7 | TJ Fontaine 8 | - Wrote the ruby bindings and other odd bits like floodserv 9 | Rico Gloeckner 10 | - miscellaneous contributions to both the core and service modules 11 | Stuart Walsh 12 | - Responsible for most of the horrors that befowl this daemon 13 | -------------------------------------------------------------------------------- /languages/Makefile.am: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2006 Luca Filipozzi 2 | MAINTAINERCLEANFILES=Makefile.in 3 | dist_pkgdata_DATA=chanserv.en.lang nickserv.en.lang operserv.en.lang services.en.lang rubyserv.en.lang floodserv.en.lang jupeserv.en.lang ganneffserv.en.lang bopm.en.lang groupserv.en.lang moranserv.en.lang ctcpserv.en.lang 4 | BUILT_SOURCES=chanserv-lang.h nickserv-lang.h operserv-lang.h services-lang.h rubyserv-lang.h floodserv-lang.h bopm-lang.h groupserv-lang.h 5 | bin_PROGRAMS=langcheck 6 | langcheck_SOURCES=langcheck.c 7 | CLEANFILES=$(BUILT_SOURCES) 8 | 9 | %-lang.h: %.en.lang 10 | $(TAIL) -n +2 $< | $(EGREP) -v "^[[:space:]]" | $(AWK) '{print "#define " $$1 " " FNR}' > $@ 11 | -------------------------------------------------------------------------------- /include/stdinc.h: -------------------------------------------------------------------------------- 1 | /* TODO: add copyright block */ 2 | 3 | #ifndef INCLUDED_stdinc_h 4 | #define INCLUDED_stdinc_h 5 | 6 | #ifdef HAVE_CONFIG_H 7 | #include 8 | #endif 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #include "defines.h" 27 | #include "irc_libio.h" 28 | #include "connection.h" 29 | #include "services.h" 30 | 31 | #endif /* INCLUDED_stdinc_h */ 32 | -------------------------------------------------------------------------------- /languages/rubyserv.en.lang: -------------------------------------------------------------------------------- 1 | 0 English 2 | RS_HELP_SHORT 3 | %s: shows this help 4 | RS_HELP_LONG 5 | Shows this help message 6 | RS_HELP_SAY_SHORT 7 | %s: Say something back to the user 8 | RS_HELP_SAY_LONG 9 | Say something back to the user 10 | 11 | Usage: SAY stuff 12 | Example: SAY Hello World! 13 | RS_HELP_COLLECT_SHORT 14 | %s: Execute a ruby gc collection 15 | RS_HELP_COLLECT_LONG 16 | Execute a ruby gc collection 17 | 18 | Use only if you expect something evil in ruby has happened. 19 | RS_HELP_JOIN_SHORT 20 | %s: Cause serv to join a specific channel 21 | RS_HELP_JOIN_LONG 22 | Cause serv to join a specific channel 23 | 24 | Usage: JOIN #foo 25 | RS_HELP_PART_SHORT 26 | %s: Cause serv to part a specific channel 27 | RS_HELP_PART_LONG 28 | Cause serv to part a specific channel 29 | 30 | Usage: PART #foo 31 | -------------------------------------------------------------------------------- /debian/patches/debian-config: -------------------------------------------------------------------------------- 1 | --- a/include/defines.h 2 | +++ b/include/defines.h 3 | @@ -3,15 +3,15 @@ 4 | #ifndef INCLUDED_defines_h 5 | #define INCLUDED_defines_h 6 | 7 | -#define LOGDIR LOCALSTATEDIR "/log/" 8 | +#define LOGDIR LOCALSTATEDIR "/log/" PACKAGE "/" 9 | #define PIDDIR LOCALSTATEDIR "/run/" 10 | #define AUTOMODPATH LIBDIR "/" PACKAGE "/autoload/" 11 | #define MODPATH LIBDIR "/" PACKAGE "/" 12 | #define LANGPATH DATADIR "/" PACKAGE "/" 13 | -#define CPATH SYSCONFDIR "/services.conf" 14 | +#define CPATH SYSCONFDIR "/" PACKAGE "/services.conf" 15 | #define DPATH PREFIX "/" 16 | #define LPATH LOGDIR "services.log" 17 | -#define PPATH PIDDIR "services.pid" 18 | +#define PPATH PIDDIR "oftc-ircservices.pid" 19 | 20 | #define SENDMAIL_PATH "/usr/sbin/sendmail -t" 21 | 22 | -------------------------------------------------------------------------------- /debian/control: -------------------------------------------------------------------------------- 1 | Source: oftc-ircservices 2 | Section: devel 3 | Priority: extra 4 | Maintainer: Christoph Berg 5 | Build-Depends: debhelper (>> 9), 6 | pkg-config, 7 | zlib1g-dev, 8 | libbsd-dev, 9 | libevent-dev, 10 | autoconf, automake, libtool, libltdl-dev, 11 | libpq-dev, postgresql-server-dev-all, 12 | libssl-dev, 13 | ruby, ruby-dev, 14 | flex, bison, 15 | Standards-Version: 3.9.8 16 | Homepage: https://github.com/oftc/oftc-ircservices 17 | 18 | Package: oftc-ircservices 19 | Architecture: any 20 | Depends: ${shlibs:Depends}, ${misc:Depends} 21 | Recommends: oftc-hybrid 22 | Description: IRC services as used by oftc.net 23 | IRC services provide nickname registration (NickServ), channel registration 24 | (ChanServ), flood detection (FloodServ), IRC operator tools (OperServ), and 25 | hooks for various scripting languages for custom services. 26 | -------------------------------------------------------------------------------- /libio/comm/rlimits.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). 3 | * rlimits.h: sidestep configure test for RLIMIT_* values. 4 | * 5 | * This code is in the public domain. 6 | * 7 | * $Id$ 8 | */ 9 | 10 | #ifndef INCLUDED_libio_comm_rlimits_h 11 | #define INCLUDED_libio_comm_rlimits_h 12 | 13 | #ifdef HAVE_SYS_RESOURCE_H 14 | #include 15 | 16 | /* This nest of #ifdefs is because not all 'cpp's support #elif */ 17 | 18 | #ifdef RLIMIT_FDMAX 19 | # define RLIMIT_FD_MAX RLIMIT_FDMAX 20 | #else 21 | # ifdef RLIMIT_NOFILE 22 | # define RLIMIT_FD_MAX RLIMIT_NOFILE 23 | # else 24 | # ifdef RLIMIT_OPEN_MAX 25 | # define RLIMIT_FD_MAX RLIMIT_OPEN_MAX 26 | # else 27 | # warning No file descriptor limit was found 28 | # endif 29 | # endif 30 | #endif 31 | 32 | #endif /* HAVE_SYS_RESOURCE_H */ 33 | 34 | #endif /* INCLUDED_rlimits_h */ 35 | -------------------------------------------------------------------------------- /sql/groupserv-pgsql.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE IF EXISTS "group" CASCADE; 2 | CREATE TABLE "group" ( 3 | id SERIAL PRIMARY KEY, 4 | name VARCHAR(32) NOT NULL, 5 | description VARCHAR(255), 6 | url VARCHAR(255), 7 | email VARCHAR(255), 8 | flag_private BOOLEAN NOT NULL DEFAULT 'False', 9 | reg_time INTEGER NOT NULL 10 | ); 11 | 12 | CREATE UNIQUE INDEX group_lower_name_idx ON "group" (irc_lower(name)); 13 | 14 | DROP TABLE IF EXISTS group_access; 15 | CREATE TABLE group_access( 16 | id SERIAL PRIMARY KEY, 17 | group_id INTEGER NOT NULL REFERENCES "group"(id) ON DELETE CASCADE, 18 | account_id INTEGER NOT NULL REFERENCES account(id), 19 | level INTEGER NOT NULL, 20 | UNIQUE (group_id, account_id) 21 | ); 22 | CREATE INDEX group_access_account_id_idx ON group_access (account_id); 23 | -------------------------------------------------------------------------------- /include/mqueue.h: -------------------------------------------------------------------------------- 1 | /* TODO: add copyright block */ 2 | 3 | #ifndef INCLUDED_mqueue_h 4 | #define INCLUDED_mqueue_h 5 | 6 | struct FloodMsg 7 | { 8 | time_t time; 9 | char *message; 10 | struct FloodMsg *hnext; 11 | struct FloodMsg *next; 12 | dlink_node node; 13 | }; 14 | 15 | struct MessageQueue 16 | { 17 | char *name; 18 | int max; 19 | int msg_enforce_time; 20 | int lne_enforce_time; 21 | dlink_list entries; 22 | unsigned int type; 23 | time_t last_used; 24 | struct MessageQueue *hnext; 25 | struct MessageQueue *next; 26 | dlink_node node; 27 | }; 28 | 29 | struct MessageQueue *mqueue_new(const char *, unsigned int, int, int, 30 | int); 31 | void mqueue_hash_free(struct MessageQueue **, dlink_list *); 32 | void mqueue_free(struct MessageQueue *); 33 | void floodmsg_free(struct FloodMsg *); 34 | struct FloodMsg *floodmsg_new(const char *); 35 | 36 | void init_mqueue(); 37 | void cleanup_mqueue(); 38 | 39 | #endif /* INCLUDED_mqueue_h */ 40 | -------------------------------------------------------------------------------- /languages/bopm.en.lang: -------------------------------------------------------------------------------- 1 | 0 English 2 | BP_HELP_SHORT 3 | %s: shows this help 4 | BP_HELP_LONG 5 | Shows this help message 6 | BP_CHECK_SHORT 7 | %s: Check if a client/host is in DNSBL 8 | BP_CHECK_LONG 9 | Usage: CHECK [nickname|hostname|IP [dnsblacklist]] 10 | 11 | Check if a client, hostname, or IP exists in the configured blacklists or in a 12 | specified blacklist. The result will show the list of blacklists the hostname 13 | are listed in, the return code from the blacklist, and the score of a specific 14 | hit, as well as the total score. 15 | 16 | If no parameters are specified your hostname is checked. 17 | 18 | Examples: 19 | CHECK 20 | CHECK somenick 21 | CHECK sub.example.com 22 | CHECK 1.2.3.4 23 | CHECK 1.2.3.4 evil.doers.dnsbl.example.com 24 | BP_PENDING_SHORT 25 | %s: Return the number of clients left to be checked 26 | BP_PENDING_LONG 27 | Usage: PENDING 28 | 29 | Returns the number of clients left to be checked 30 | -------------------------------------------------------------------------------- /include/floodserv.h: -------------------------------------------------------------------------------- 1 | /* TODO: add copyright block */ 2 | 3 | #ifndef INCLUDED_floodserv_h 4 | #define INCLUDED_floodserv_h 5 | 6 | #include "floodserv-lang.h" 7 | 8 | #define FS_MSG_COUNT 5 9 | #define FS_MSG_TIME 60 10 | #define FS_LNE_TIME 3 11 | 12 | #define FS_GMSG_COUNT 10 13 | #define FS_GMSG_TIME 60 14 | 15 | #define FS_KILL_MSG "This host triggered network flood protection. "\ 16 | "please mail support@oftc.net if you feel this is in error, quoting "\ 17 | "this message." 18 | #define FS_KILL_DUR 2592000 /* 30 Days */ 19 | 20 | /* GC Timer, how often the routine should fire */ 21 | /* Default once every min */ 22 | #define FS_GC_EVENT_TIMER 60 23 | /* The smallest age at which to free a queue */ 24 | /* Default every 10 mins */ 25 | #define FS_GC_EXPIRE_TIME 600 26 | 27 | enum MessageQueueType 28 | { 29 | MQUEUE_CHAN, 30 | MQUEUE_GLOB, 31 | }; 32 | 33 | enum MQueueEnforce 34 | { 35 | MQUEUE_NONE, 36 | MQUEUE_LINE, 37 | MQUEUE_MESG, 38 | }; 39 | 40 | #endif /* INCLUDED_floodserv_h */ 41 | -------------------------------------------------------------------------------- /sql/operserv-pgsql.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE IF EXISTS akill CASCADE; 2 | CREATE TABLE akill ( 3 | id SERIAL PRIMARY KEY, 4 | mask VARCHAR(255) NOT NULL, 5 | reason VARCHAR(255) NOT NULL, 6 | setter INTEGER REFERENCES account(id) ON DELETE SET NULL, 7 | time INTEGER NOT NULL, 8 | duration INTEGER NOT NULL, 9 | UNIQUE (mask) 10 | ); 11 | 12 | DROP TABLE IF EXISTS sent_mail; 13 | CREATE TABLE sent_mail ( 14 | id SERIAL PRIMARY KEY, 15 | account_id INTEGER REFERENCES account(id) ON DELETE SET NULL, 16 | email VARCHAR(255) NOT NULL, 17 | sent INTEGER NOT NULL 18 | ); 19 | 20 | DROP TABLE IF EXISTS jupes CASCADE; 21 | CREATE TABLE jupes ( 22 | id SERIAL PRIMARY KEY, 23 | name VARCHAR(255) NOT NULL, 24 | reason VARCHAR(255) NOT NULL, 25 | setter INTEGER REFERENCES account(id) ON DELETE SET NULL 26 | ); 27 | CREATE UNIQUE INDEX jupes_name_idx ON jupes (lower(name)); 28 | -------------------------------------------------------------------------------- /src/dbmail.c: -------------------------------------------------------------------------------- 1 | #include "stdinc.h" 2 | #include "conf/conf.h" 3 | #include "dbm.h" 4 | #include "dbmail.h" 5 | 6 | int 7 | dbmail_add_sent(unsigned int account, const char *email) 8 | { 9 | if(db_execute_nonquery(INSERT_SENT_MAIL, "isi", &account, email, &CurrentTime) == 1) 10 | return TRUE; 11 | else 12 | return FALSE; 13 | } 14 | 15 | int 16 | dbmail_is_sent(unsigned int account, const char *email) 17 | { 18 | int error, ret; 19 | char *result; 20 | 21 | result = db_execute_scalar(GET_SENT_MAIL, &error, "is", &account, email); 22 | if(result != NULL) 23 | ret = atoi(result); 24 | else 25 | ret = FALSE; 26 | 27 | if(error) 28 | { 29 | ilog(L_CRIT, "dbmail_is_sent: database error %d", error); 30 | return FALSE; 31 | } 32 | 33 | return ret; 34 | } 35 | 36 | void 37 | dbmail_expire_sentmail(void *param) 38 | { 39 | /* TODO XXX FIXME we should probably do some error checking here */ 40 | db_execute_nonquery(DELETE_EXPIRED_SENT_MAIL, "ii", &Mail.expire_time, &CurrentTime); 41 | } 42 | -------------------------------------------------------------------------------- /modules/Makefile.am: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2006 Luca Filipozzi 2 | MAINTAINERCLEANFILES=Makefile.in 3 | AM_CPPFLAGS=-I$(top_srcdir)/libio -I$(top_srcdir)/include -I$(top_srcdir)/languages 4 | if USE_SHARED_MODULES 5 | AM_LDFLAGS=-no-undefined -module -avoid-version 6 | pkglib_LTLIBRARIES=chanserv.la operserv.la nickserv.la groupserv.la floodserv.la irc.la oftc.la pgsql.la nulldb.la 7 | else 8 | AM_LDFLAGS=-static 9 | noinst_LTLIBRARIES=chanserv.la operserv.la nickserv.la groupserv.la floodserv.la irc.la oftc.la pgsql.la nulldb.la 10 | endif 11 | dist_pkgdata_DATA=PythonServ.py RubyServ.rb JupeServ.rb XmlRpc.rb ServiceBase.rb GanneffServ.rb Bopm.rb MoranServ.rb CTCPServ.rb 12 | chanserv_la_SOURCES=chanserv.c 13 | operserv_la_SOURCES=operserv.c 14 | nickserv_la_SOURCES=nickserv.c 15 | floodserv_la_SOURCES=floodserv.c 16 | groupserv_la_SOURCES=groupserv.c 17 | irc_la_SOURCES=irc.c 18 | oftc_la_SOURCES=oftc.c 19 | pgsql_la_SOURCES=pgsql.c 20 | pgsql_la_CFLAGS=@POSTGRESQL_CFLAGS@ 21 | pgsql_la_LIBADD=@POSTGRESQL_LDFLAGS@ 22 | nulldb_la_SOURCES=nulldb.c 23 | 24 | install-exec-local: 25 | rm -f $(DESTDIR)/$(pkglibdir)/*.la $(DESTDIR)/$(pkblibdir)/*.a 26 | -------------------------------------------------------------------------------- /languages/ctcpserv.en.lang: -------------------------------------------------------------------------------- 1 | 0 English 2 | CC_HELP_SHORT 3 | %s: shows this help 4 | CC_HELP_LONG 5 | Shows this help message 6 | CC_HELP_ADD_SHORT 7 | %s: NOTIMP 8 | CC_HELP_ADD_LONG 9 | NOTIMP 10 | CC_HELP_DEL_SHORT 11 | %s: NOTIMP 12 | CC_HELP_DEL_LONG 13 | Usage: DEL 1 14 | 15 | NOTIMP 16 | CC_HELP_LIST_SHORT 17 | %s: List loaded patterns 18 | CC_HELP_LIST_LONG 19 | Usage: LIST 20 | 21 | It really just lists loaded patterns 22 | CC_HELP_VERBOSE_SHORT 23 | %s: Toggle verbose snooping 24 | CC_HELP_VERBOSE_LONG 25 | Usage: VERBOSE 26 | 27 | Toggle verbose snooping to the snoop channel 28 | CC_HELP_ENFORCE_SHORT 29 | %s: NOTIMP Enforces all current active patterns on all known clients 30 | CC_HELP_ENFORCE_LONG 31 | NOTIMP Enforces all current active patterns on all known clients again 32 | CC_HELP_CHECK_SHORT 33 | %s: Show details about a known client 34 | CC_HELP_CHECK_LONG 35 | Usage: CHECK nick 36 | 37 | Show the details of a known client. Only works if we've sent them a query. 38 | CC_HELP_RELOAD_SHORT 39 | %s: Reload config file and patterns from database 40 | CC_HELP_RELOAD_LONG 41 | Usage: RELOAD 42 | 43 | Reload the config file and patterns from the database. Use if you've changed 44 | the config file, or manually added patterns to the database. 45 | -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | oftc-ircservices INSTALL file 2 | 3 | $Id$ 4 | 5 | This document will tell you how to install oftc-ircservices onto your machine 6 | and hopefully get them up and running with minimal fuss. 7 | 8 | Installation of oftc-ircservices is reasonably straight forward. It is 9 | distributed using standard GNU autoconf processes, so should be similar to 10 | most other GNU software you have used. 11 | 12 | To this end, to get started, do: 13 | 14 | ./configure (see ./configure --help for options that you can tune) 15 | make 16 | make install 17 | 18 | This will install the services binary and support files in the location you 19 | have specified(or your default prefix if you havent specified one). 20 | 21 | Once installation if complete you will need to configure services by editing 22 | etc/services.conf. Use example.conf as a guide. 23 | 24 | Now, depending on which database platform you are using, you will need to set 25 | up your database tables. Firstly, create the database you will use, then 26 | import the scripts in sql/ for the database type you are using. E.g. if you 27 | are using postgres, you will need to import sql/nickserv-pgsql.sql 28 | sql/chanserv-pgsql.sqlp and sql/operserv-pgql.sql. Once this is done 29 | services.conf should be updated to the database you created. 30 | -------------------------------------------------------------------------------- /include/jupe.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). 3 | * jupe.h jupe related header file 4 | * 5 | * Copyright (C) 2002 by the past and present ircd coders, and others. 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 20 | * USA 21 | * 22 | * $Id: msg.h 957 2007-05-07 16:52:26Z stu $ 23 | */ 24 | 25 | #ifndef INCLUDED_jupe_h 26 | #define INCLUDED_jupe_h 27 | 28 | int jupe_list(dlink_list *); 29 | void free_jupe_list(dlink_list *); 30 | struct JupeEntry *jupe_find(const char *); 31 | int jupe_delete(const char *); 32 | int jupe_add(struct JupeEntry *); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /libio/net/res.h: -------------------------------------------------------------------------------- 1 | /* 2 | * res.h for referencing functions in libio/net/res.c 3 | * 4 | * $Id$ 5 | */ 6 | 7 | /* TODO: add copyright block */ 8 | 9 | #ifndef INCLUDED_libio_net_res_h 10 | #define INCLUDED_libio_net_res_h 11 | 12 | /* Maximum number of nameservers in /etc/resolv.conf we care about */ 13 | #define IRCD_MAXNS 2 14 | 15 | struct DNSReply 16 | { 17 | char *h_name; 18 | struct irc_ssaddr addr; 19 | }; 20 | 21 | struct DNSQuery 22 | { 23 | #ifdef _WIN32 24 | dlink_node node; 25 | HANDLE handle; 26 | char reply[MAXGETHOSTSTRUCT]; 27 | #endif 28 | void *ptr; /* pointer used by callback to identify request */ 29 | void (*callback)(void* vptr, struct DNSReply *reply); /* callback to call */ 30 | }; 31 | 32 | LIBIO_EXTERN struct irc_ssaddr irc_nsaddr_list[]; 33 | LIBIO_EXTERN int irc_nscount; 34 | 35 | #ifdef IN_MISC_C 36 | extern void init_resolver(void); 37 | #endif 38 | LIBIO_EXTERN void restart_resolver(void); 39 | LIBIO_EXTERN void delete_resolver_queries(const struct DNSQuery *); 40 | LIBIO_EXTERN void gethost_byname_type(const char *, struct DNSQuery *, int); 41 | LIBIO_EXTERN void gethost_byname(const char *, struct DNSQuery *); 42 | LIBIO_EXTERN void gethost_byaddr(const struct irc_ssaddr *, struct DNSQuery *); 43 | LIBIO_EXTERN void add_local_domain(char *, size_t); 44 | 45 | #endif /* INCLUDED_libio_net_res_h */ 46 | -------------------------------------------------------------------------------- /include/conf/mail.h: -------------------------------------------------------------------------------- 1 | /* 2 | * mail.h: Defines mail{} conf section. 3 | * 4 | * Copyright (C) 2005 by the Hybrid Development Team. 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 | * USA 20 | * 21 | * $Id: mail.h 527 2007-01-02 01:35:58Z stu $ 22 | */ 23 | 24 | #ifndef INCLUDED_conf_mail_h 25 | #define INCLUDED_conf_mail_h 26 | 27 | struct MailConf 28 | { 29 | char *command; 30 | char *from_address; 31 | time_t expire_time; 32 | }; 33 | 34 | EXTERN struct MailConf Mail; 35 | 36 | #ifdef IN_CONF_C 37 | void init_mail(void); 38 | void cleanup_mail(void); 39 | #endif 40 | 41 | #endif /* INCLUDED_conf_mail_h */ 42 | -------------------------------------------------------------------------------- /include/conf/connect.h: -------------------------------------------------------------------------------- 1 | /* 2 | * connect.h: Defines connect{} conf section. 3 | * 4 | * Copyright (C) 2005 by the Hybrid Development Team. 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 | * USA 20 | * 21 | * $Id$ 22 | */ 23 | 24 | #ifndef INCLUDED_conf_connect_h 25 | #define INCLUDED_conf_connect_h 26 | 27 | struct ConnectConf 28 | { 29 | char *name; 30 | char *host; 31 | char *protocol; 32 | char *password; 33 | int port; 34 | }; 35 | 36 | EXTERN struct ConnectConf Connect; 37 | 38 | #ifdef IN_CONF_C 39 | void init_connect(void); 40 | void cleanup_connect(void); 41 | #endif 42 | 43 | #endif /* INCLUDED_conf_connect_h */ 44 | -------------------------------------------------------------------------------- /tools/release: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | PACKAGE=oftc-ircservices 6 | VERSION=$(grep AC_INIT configure.ac | sed -r 's#.*([0-9]+\.[0-9]+\.[0-9]+).*#\1#') 7 | DESTDIR=/var/www/wwwiki.oftc.net/htdocs/releases/$PACKAGE 8 | DESTHOST=www.oftc.net 9 | 10 | echo "Preparing to cut release for $VERSION" 11 | 12 | echo 'This is about to run `git clean -fdx` press any key to continue' 13 | read 14 | 15 | echo "Tagging release $PACKAGE-$VERSION" 16 | 17 | git tag -d $PACKAGE-$VERSION || true 18 | 19 | if [ "$OFTC_GPG" != "" ]; then 20 | git tag -u $OFTC_GPG -m "Version $VERSION" -s $PACKAGE-$VERSION 21 | else 22 | git tag -m "Version $VERSION" -s $PACKAGE-$VERSION 23 | fi 24 | 25 | echo "Cleaning directory" 26 | git clean -fdx 27 | 28 | echo -e "\nRunning autogen.sh\n" 29 | ./autogen.sh 30 | 31 | echo -e "\nRunning configure\n" 32 | ./configure 33 | 34 | echo -e "\nRunning make dist\n" 35 | make dist 36 | 37 | md5sum $PACKAGE-$VERSION.tar.gz > $PACKAGE-$VERSION.tar.gz.md5sum 38 | gpg --clearsign $PACKAGE-$VERSION.tar.gz.md5sum 39 | scp $PACKAGE-$VERSION.tar.gz* $DESTHOST:$DESTDIR/ 40 | 41 | perl -pi -e 's/(\d+)\.(\d+)\.(\d+)/$1.".".$2.".".($3 + 1)/e' configure.ac 42 | 43 | VERSION=$(grep AC_INIT configure.ac | sed -r 's#.*([0-9]+\.[0-9]+\.[0-9]+).*#\1#') 44 | 45 | git add configure.ac 46 | git commit -m "Now working $VERSION" 47 | git push --tags origin HEAD:master 48 | -------------------------------------------------------------------------------- /src/ruby_module/dbrow.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "libruby_module.h" 3 | 4 | VALUE cDBRow = Qnil; 5 | 6 | static VALUE initialize(VALUE, VALUE); 7 | static VALUE indexer(VALUE, VALUE); 8 | 9 | void 10 | Init_DBRow(void) 11 | { 12 | cDBRow = rb_define_class("DBRow", rb_cObject); 13 | 14 | rb_define_method(cDBRow, "initialize", initialize, 1); 15 | rb_define_method(cDBRow, "[]", indexer, 1); 16 | } 17 | 18 | static VALUE 19 | initialize(VALUE self, VALUE row) 20 | { 21 | rb_iv_set(self, "@realptr", row); 22 | return self; 23 | } 24 | 25 | static VALUE 26 | indexer(VALUE self, VALUE index) 27 | { 28 | row_t *row = value_to_dbrow(self); 29 | 30 | Check_Type(index, T_FIXNUM); 31 | 32 | if(row->cols[NUM2INT(index)] == NULL) 33 | return Qnil; 34 | else 35 | return rb_str_new2(row->cols[NUM2INT(index)]); 36 | } 37 | 38 | row_t* 39 | value_to_dbrow(VALUE self) 40 | { 41 | row_t *out; 42 | VALUE row = rb_iv_get(self, "@realptr"); 43 | Data_Get_Struct(row, row_t, out); 44 | return out; 45 | } 46 | 47 | VALUE 48 | dbrow_to_value(row_t *row) 49 | { 50 | VALUE tmp, real; 51 | 52 | tmp = Data_Wrap_Struct(rb_cObject, 0, 0, row); 53 | real = do_ruby_ret(cDBRow, rb_intern("new"), 1, tmp); 54 | 55 | if(real == Qnil) 56 | { 57 | ilog(L_CRIT, "RUBY ERROR: Ruby Failed To Create DBRow"); 58 | return Qnil; 59 | } 60 | 61 | return real; 62 | } 63 | -------------------------------------------------------------------------------- /include/Makefile.am: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2006 Luca Filipozzi 2 | MAINTAINERCLEANFILES=Makefile.in setup.h.in setup.h.in~ 3 | SUBDIRS=conf 4 | noinst_HEADERS= akick.h \ 5 | akill.h \ 6 | chanaccess.h \ 7 | channel.h \ 8 | channel_mode.h \ 9 | chanserv.h \ 10 | client.h \ 11 | conf.h \ 12 | connection.h \ 13 | crypt.h \ 14 | dbchannel.h \ 15 | dbm.h \ 16 | dbmail.h \ 17 | defines.h \ 18 | events.h \ 19 | floodserv.h \ 20 | group.h \ 21 | groupaccess.h \ 22 | groupserv.h \ 23 | hash.h \ 24 | hostmask.h \ 25 | interface.h \ 26 | jupe.h \ 27 | kill.h \ 28 | language.h \ 29 | modules.h \ 30 | mqueue.h \ 31 | msg.h \ 32 | nickname.h \ 33 | nickserv.h \ 34 | operserv.h \ 35 | packet.h \ 36 | parse.h \ 37 | python_module.h \ 38 | ruby_module.h \ 39 | send.h \ 40 | servicemask.h \ 41 | services.h \ 42 | stdinc.h \ 43 | tor.h 44 | -------------------------------------------------------------------------------- /sql/common-pgsql.sql: -------------------------------------------------------------------------------- 1 | -- prerequisites for higher-level modules 2 | 3 | CREATE OR REPLACE FUNCTION irc_lower(item text) 4 | RETURNS text CALLED ON NULL INPUT LANGUAGE SQL PARALLEL SAFE 5 | AS $$SELECT translate(lower(item), '[]\^', '{}|~')$$; 6 | 7 | /* migration script for the above function: 8 | CREATE UNIQUE INDEX channel_channel_idx2 ON channel (irc_lower(channel)); 9 | CREATE UNIQUE INDEX forbidden_channel_channel_idx2 ON forbidden_channel (irc_lower(channel)); 10 | CREATE UNIQUE INDEX ganneffserv_channel_idx2 ON ganneffserv (irc_lower(channel)); 11 | CREATE UNIQUE INDEX group_lower_name_idx ON "group" (irc_lower(name)); -- new index 12 | CREATE UNIQUE INDEX nickname_nick_idx2 ON nickname (irc_lower(nick)); 13 | CREATE UNIQUE INDEX forbidden_nickname_nick_idx2 ON forbidden_nickname (irc_lower(nick)); 14 | 15 | DROP INDEX channel_channel_idx; 16 | ALTER INDEX channel_channel_idx2 RENAME TO channel_channel_idx; 17 | DROP INDEX forbidden_channel_channel_idx; 18 | ALTER INDEX forbidden_channel_channel_idx2 RENAME TO forbidden_channel_channel_idx; 19 | DROP INDEX ganneffserv_channel_idx; 20 | ALTER INDEX ganneffserv_channel_idx2 RENAME TO ganneffserv_channel_idx; 21 | DROP INDEX nickname_nick_idx; 22 | ALTER INDEX nickname_nick_idx2 RENAME TO nickname_nick_idx; 23 | DROP INDEX forbidden_nickname_nick_idx; 24 | ALTER INDEX forbidden_nickname_nick_idx2 RENAME TO forbidden_nickname_nick_idx; 25 | */ 26 | -------------------------------------------------------------------------------- /include/conf/database.h: -------------------------------------------------------------------------------- 1 | /* 2 | * database.h: Defines database{} conf section. 3 | * 4 | * Copyright (C) 2005 by the Hybrid Development Team. 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 | * USA 20 | * 21 | * $Id$ 22 | */ 23 | 24 | #ifndef INCLUDED_conf_database_h 25 | #define INCLUDED_conf_database_h 26 | 27 | struct DatabaseConf 28 | { 29 | char *driver; 30 | char *dbname; 31 | char *hostname; 32 | char *username; 33 | char *password; 34 | int port; 35 | }; 36 | 37 | EXTERN struct DatabaseConf Database; 38 | 39 | #ifdef IN_CONF_C 40 | void init_database(void); 41 | void cleanup_database(void); 42 | #endif 43 | 44 | #endif /* INCLUDED_conf_database_h */ 45 | -------------------------------------------------------------------------------- /include/conf/service.h: -------------------------------------------------------------------------------- 1 | /* 2 | * service.h: Defines service{} conf section. 3 | * 4 | * Copyright (C) 2005 by the Hybrid Development Team. 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 | * USA 20 | * 21 | * $Id: /local/oftc-ircservices/trunk/include/conf/database.h 1670 2007-01-02T01:11:52.997970Z stu $ 22 | */ 23 | 24 | #ifndef INCLUDED_conf_service_h 25 | #define INCLUDED_conf_service_h 26 | 27 | struct ServiceConf 28 | { 29 | char *name; 30 | char *module; 31 | dlink_node node; 32 | }; 33 | 34 | EXTERN dlink_list service_confs; 35 | 36 | #ifdef IN_CONF_C 37 | void init_service(void); 38 | void cleanup_service(void); 39 | #endif 40 | 41 | #endif /* INCLUDED_conf_service_h */ 42 | -------------------------------------------------------------------------------- /include/akill.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). 3 | * akill.h akill related header file 4 | * 5 | * Copyright (C) 2002 by the past and present ircd coders, and others. 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 20 | * USA 21 | * 22 | * $Id: msg.h 957 2007-05-07 16:52:26Z stu $ 23 | */ 24 | 25 | #ifndef INCLUDED_akill_h 26 | #define INCLUDED_akill_h 27 | 28 | int akill_add(struct ServiceMask *); 29 | struct ServiceMask *akill_find(const char *); 30 | int akill_check_client(struct Service *, struct Client *); 31 | int akill_list(dlink_list *); 32 | int akill_get_expired(dlink_list *); 33 | int akill_list_free(dlink_list *); 34 | int akill_remove_mask(const char *); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /include/conf/logging.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). 3 | * logging.h: Defines logging{} conf section. 4 | * 5 | * Copyright (C) 2005 by the Hybrid Development Team. 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 20 | * USA 21 | * 22 | * $Id$ 23 | */ 24 | 25 | #ifndef INCLUDED_conf_logging_h 26 | #define INCLUDED_conf_logging_h 27 | 28 | struct LoggingConf 29 | { 30 | char use_logging; 31 | char serviceslog[PATH_MAX+1], debuglog[PATH_MAX+1], sqllog[PATH_MAX+1]; 32 | char parselog[PATH_MAX+1]; 33 | }; 34 | 35 | EXTERN struct LoggingConf Logging; 36 | 37 | #ifdef IN_CONF_C 38 | void init_logging(void); 39 | void cleanup_logging(void); 40 | #endif 41 | 42 | #endif /* INCLUDED_conf_logging_h */ 43 | -------------------------------------------------------------------------------- /libio/mem/memory.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). 3 | * memory.c: Memory utilities. 4 | * 5 | * Copyright (C) 2002 by the past and present ircd coders, and others. 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 20 | * USA 21 | * 22 | * $Id$ 23 | */ 24 | 25 | #include "libioinc.h" 26 | 27 | void (* outofmemory) (void) = abort; 28 | 29 | /* 30 | * frob some memory. debugging time. 31 | * -- adrian 32 | */ 33 | void 34 | mem_frob(void *data, int len) 35 | { 36 | /* correct for Intel only! little endian */ 37 | unsigned char b[4] = { 0xef, 0xbe, 0xad, 0xde }; 38 | int i; 39 | char *cdata = data; 40 | 41 | for (i = 0; i < len; i++) 42 | { 43 | *cdata = b[i % 4]; 44 | cdata++; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /include/events.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2009 Stuart Walsh 3 | 4 | Permission is hereby granted, free of charge, to any person 5 | obtaining a copy of this software and associated documentation 6 | files (the "Software"), to deal in the Software without 7 | restriction, including without limitation the rights to use, 8 | copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the 10 | Software is furnished to do so, subject to the following 11 | conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | #ifndef _EVENT_H_INC 27 | #define _EVENT_H_INC 28 | 29 | int init_events(); 30 | int events_loop(); 31 | struct event *events_add(int, short, void(*)(int, short, void *), void *); 32 | struct event *events_setup(int, short, void(*)(int, short, void *), void *); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /include/groupaccess.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). 3 | * groupaccess.h header file for group access management 4 | * 5 | * Copyright (C) 2002 by the past and present ircd coders, and others. 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 20 | * USA 21 | * 22 | * $Id: msg.h 957 2007-05-07 16:52:26Z stu $ 23 | */ 24 | 25 | #ifndef INCLUDED_groupaccess_h 26 | #define INCLUDED_groupaccess_h 27 | 28 | int groupaccess_add(struct GroupAccess *); 29 | int groupaccess_list(unsigned int, dlink_list *); 30 | void groupaccess_list_free(dlink_list *); 31 | struct GroupAccess *groupaccess_find(unsigned int, unsigned int); 32 | int groupaccess_remove(struct GroupAccess *); 33 | int groupaccess_count(unsigned int); 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /languages/moranserv.en.lang: -------------------------------------------------------------------------------- 1 | 0 English 2 | MS_HELP_DEBUG_SHORT 3 | %s: Toggles debug mode 4 | MS_HELP_DEBUG_LONG 5 | Toggles debug mode 6 | MS_HELP_SHORT 7 | %s: shows this help 8 | MS_HELP_LONG 9 | Shows this help message 10 | MS_HELP_THRESHOLD_SHORT 11 | %s: Changes threshold values 12 | MS_HELP_THRESHOLD_LONG 13 | Usage: THRESHOLD [time] [value] 14 | 15 | Changes the threshold for time to value. 16 | 17 | time must be a registered threshold (you cannot add 18 | or delete them at this point) 19 | 20 | Usage: THRESHOLD LIST 21 | 22 | Lists current time periods and the respective threshold value 23 | MS_HELP_TRACK_SHORT 24 | %s: Track a client, ip, or regular expression, with no parameters list all 25 | MS_HELP_TRACK_LONG 26 | Usage: TRACK [value [:reason]] 27 | 28 | No parameters returns a list of currently tracked items 29 | 30 | If value is a valid client all joins, parts are tracked until 31 | the client quits 32 | 33 | The value can also be a valid ip or cidr range (including ipv6), 34 | any client activity that matches the cidr/ip will be tracked 35 | 36 | Otherwise the value will be interpreted as a regexp which is matched 37 | against host, realhost, and nick 38 | 39 | You should specify a reason you're tracking, you must include the colon 40 | MS_HELP_UNTRACK_SHORT 41 | %s: Remove a currently tracked item 42 | MS_HELP_UNTRACK_LONG 43 | Usage: UNTRACK  44 | 45 | Stop tracking item , if "-" is specified remove all tracking 46 | -------------------------------------------------------------------------------- /languages/langcheck.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #define FALSE 0 5 | #define TRUE 1 6 | 7 | int main(int parc, char *parv[]) 8 | { 9 | FILE *fptr; 10 | char line[1024+1]; 11 | char *ptr = line; 12 | int lineno = 1; 13 | int cleanfile = TRUE; 14 | int tabline = TRUE; 15 | 16 | if(parc < 2) 17 | { 18 | fprintf(stderr, "Usage: %s \n", parv[0]); 19 | exit(1); 20 | } 21 | 22 | if((fptr = fopen(parv[1], "r")) == NULL) 23 | { 24 | fprintf(stderr, "Failed to open: %s\n", parv[1]); 25 | exit(2); 26 | } 27 | 28 | ptr = fgets(line, 1024, fptr); 29 | lineno++; 30 | printf("This language file contains %s", line); 31 | 32 | while((ptr = fgets(line, 1024, fptr)) != NULL) 33 | { 34 | if(line[0] == ' ') 35 | { 36 | printf("ERROR: Line %d: Line starts with a space\n", lineno); 37 | cleanfile = FALSE; 38 | } 39 | else if(line[0] == '\n') 40 | { 41 | printf("ERROR: Line %d: Blank line\n", lineno); 42 | cleanfile = FALSE; 43 | } 44 | 45 | if(line[0] == '\t') 46 | tabline = TRUE; 47 | else 48 | { 49 | if(!tabline) 50 | printf("WARNING: Line %d: Previous section had no definition\n", lineno); 51 | tabline = FALSE; 52 | } 53 | lineno++; 54 | } 55 | 56 | if(cleanfile) 57 | printf("File %s is clear of errors\n", parv[1]); 58 | else 59 | printf("File %s has errors\n", parv[1]); 60 | 61 | fclose(fptr); 62 | 63 | return 0; 64 | } 65 | -------------------------------------------------------------------------------- /include/akick.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). 3 | * akick.h akick related header file 4 | * 5 | * Copyright (C) 2002 by the past and present ircd coders, and others. 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 20 | * USA 21 | * 22 | * $Id: msg.h 957 2007-05-07 16:52:26Z stu $ 23 | */ 24 | 25 | #ifndef INCLUDED_akick_h 26 | #define INCLUDED_akick_h 27 | 28 | int akick_add(struct ServiceMask *); 29 | int akick_check_client(struct Service *, struct Channel *, struct Client *); 30 | int akick_enforce(struct Service *, struct Channel *, struct ServiceMask *); 31 | int akick_list(unsigned int, dlink_list *); 32 | void akick_list_free(dlink_list *); 33 | int akick_remove_mask(unsigned int, const char *); 34 | int akick_remove_account(unsigned int, const char *); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /include/chanaccess.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). 3 | * chanaccess.h chanaccess related header file 4 | * 5 | * Copyright (C) 2002 by the past and present ircd coders, and others. 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 20 | * USA 21 | * 22 | * $Id: msg.h 957 2007-05-07 16:52:26Z stu $ 23 | */ 24 | 25 | #ifndef INCLUDED_chanaccess_h 26 | #define INCLUDED_chanaccess_h 27 | 28 | int chanaccess_add(struct ChanAccess *); 29 | int chanaccess_list(unsigned int, dlink_list *); 30 | void chanaccess_list_free(dlink_list *); 31 | struct ChanAccess * chanaccess_find(unsigned int, unsigned int); 32 | struct ChanAccess * chanaccess_find_exact(unsigned int, unsigned int, unsigned int); 33 | int chanaccess_remove(struct ChanAccess *); 34 | int chanaccess_count(unsigned int); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /modules/ServiceBase.rb: -------------------------------------------------------------------------------- 1 | class ServiceBase 2 | def load_language(langfile) 3 | @sv_langs = {} unless @sv_langs 4 | @lang_map = {} unless @lang_map 5 | lang = File.open(@langpath+'/'+langfile+'.lang') 6 | langid = lang.readline.chomp.split(' ')[0].to_i 7 | @sv_langs[langid] = {} unless @sv_langs[langid] 8 | curr = @sv_langs[langid] 9 | last = nil 10 | count = 1 11 | lang.each_line do |line| 12 | if line[0,1] == "\t" 13 | curr[last] << line[1,line.length-1] 14 | else 15 | line.chomp! 16 | raise "Key Already Included #{line}" if curr.include?(line) 17 | @lang_map[line] = count 18 | count += 1 19 | curr[line] = "" 20 | last = line 21 | end 22 | end 23 | lang.close 24 | chain_language(langfile) 25 | end 26 | 27 | def reply_lang(client, mid, *args) 28 | langid = 0 29 | langid = client.nick.language if client.nick 30 | message = @sv_langs[langid][mid] if @sv_langs.include?(langid) 31 | message = @sv_langs[0][mid] unless message 32 | raise "Message Not Defined #{mid}" unless message 33 | message = message % args 34 | message.each_line { |l| reply_user(client, l) } 35 | end 36 | 37 | def lm(mid) 38 | raise "Lang Message #{mid} Does Not Exist" unless @lang_map.include?(mid) 39 | @lang_map[mid] 40 | end 41 | 42 | def chain_language(langfile) 43 | end 44 | 45 | def reply_user(client, message) 46 | end 47 | 48 | def is_me?(client) 49 | client.name.downcase == @ServiceName.downcase 50 | end 51 | end 52 | -------------------------------------------------------------------------------- /libio/misc/libio_getopt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). 3 | * ircd_getopt.h: A header for the getopt() command line option calls. 4 | * 5 | * Copyright (C) 2002 by the past and present ircd coders, and others. 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 20 | * USA 21 | * 22 | * $Id$ 23 | */ 24 | 25 | #ifndef INCLUDED_libio_misc_ircd_getopt_h 26 | #define INCLUDED_libio_misc_ircd_getopt_h 27 | 28 | struct lgetopt { 29 | const char *opt; /* name of the argument */ 30 | void *argloc; /* where we store the argument to it (-option argument) */ 31 | enum { INTEGER, YESNO, STRING, USAGE, ENDEBUG } argtype; 32 | const char *desc; /* description of the argument, usage for printing help */ 33 | }; 34 | 35 | LIBIO_EXTERN void parseargs(int *, char ***, struct lgetopt *); 36 | 37 | #endif /* INCLUDED_libio_misc_ircd_getopt_h */ 38 | -------------------------------------------------------------------------------- /scripts/dblink-script.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/ruby 2 | 3 | require 'dbi' 4 | require 'yaml' 5 | 6 | start = Time.now 7 | 8 | basenick = ARGV[0] 9 | nickcount = ARGV[1].to_i 10 | regtime = Time.now.to_i 11 | conffile = ARGV[2] 12 | conf = YAML::load(File.open(conffile)) 13 | 14 | dbh = DBI.connect(conf["dest_str"], conf["dest_user"], conf["dest_pass"]) 15 | 16 | puts "Connected to DB, creating #{nickcount} links for nick #{basenick}" 17 | 18 | dbh.execute("BEGIN") 19 | 20 | prinid = dbh.select_one("SELECT nextval(pg_get_serial_sequence('nickname', 'id'))")[0] 21 | accid = dbh.select_one("SELECT nextval(pg_get_serial_sequence('account', 'id'))")[0] 22 | 23 | dbh.execute("INSERT INTO account(id, primary_nick, reg_time, password, salt, email) VALUES(?, ?, ?, ?, ?, ?)", 24 | accid, prinid, regtime, 'password', 'salt', basenick+'@oftc.net') 25 | 26 | puts "INSERTed #{basenick} account with #{accid}" 27 | 28 | dbh.execute("INSERT INTO nickname(id, nick, user_id, reg_time) VALUES(?, ?, ?, ?)", 29 | prinid, basenick, accid, regtime) 30 | 31 | puts "INSERTed #{basenick} with #{prinid}" 32 | 33 | nickid = 0 34 | handle = nil 35 | 36 | nickcount.times do |i| 37 | regtime = Time.now.to_i 38 | nickid = dbh.select_one("SELECT nextval(pg_get_serial_sequence('nickname', 'id'))")[0] 39 | nick = basenick + i.to_s 40 | handle = dbh.prepare("INSERT INTO nickname(id, nick, user_id, reg_time) VALUES(?, ?, ?, ?)") 41 | handle.execute(nickid, nick, accid, regtime) 42 | handle.finish 43 | puts "INSERTed #{nick} with #{nickid}" 44 | end 45 | 46 | dbh.execute("COMMIT") 47 | dbh.disconnect 48 | 49 | tend = Time.now 50 | 51 | puts "Finished in #{tend - start}" 52 | -------------------------------------------------------------------------------- /libio/mem/dynlink.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). 3 | * dynlink.h: Low level interface for module support. 4 | * 5 | * Copyright (C) 2002-2006 by the past and present ircd coders, and others. 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 20 | * USA 21 | * 22 | * $Id$ 23 | */ 24 | 25 | #ifndef INCLUDED_libio_mem_dynlink_h 26 | #define INCLUDED_libio_mem_dynlink_h 27 | 28 | // Loads a module given by name. void ** receives module base address 29 | // (best we can determine). Return value: module handle or NULL. 30 | 31 | void *modload(const char *, void **); 32 | 33 | // Returns symbol address from a loaded module given by handle. 34 | 35 | void *modsym(void *, const char *); 36 | 37 | // Unloads a module specified by handle. 38 | 39 | void modunload(void *); 40 | 41 | // moderror can be called after modload if it failed to get a detailed 42 | // error description. 43 | 44 | const char *moderror(void); 45 | 46 | #endif /* INCLUDED_libio_mem_dynlink_h */ 47 | -------------------------------------------------------------------------------- /include/conf/servicesinfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | * servicesinfo.h: Defines servicesinfo{} conf section. 3 | * 4 | * Copyright (C) 2005 by the Hybrid Development Team. 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 | * USA 20 | * 21 | * $Id$ 22 | */ 23 | 24 | #ifndef INCLUDED_conf_servicesinfo_h 25 | #define INCLUDED_conf_servicesinfo_h 26 | 27 | struct ServicesInfoConf 28 | { 29 | struct irc_ssaddr vhost; 30 | #ifdef IPV6 31 | struct irc_ssaddr vhost6; 32 | #endif 33 | #ifdef HAVE_LIBCRYPTO 34 | char *rsa_private_key_file; 35 | RSA *rsa_private_key; 36 | SSL_CTX *ctx; 37 | #endif 38 | char logfile[PATH_MAX+1]; 39 | char *hmac_secret; 40 | time_t def_akill_dur; 41 | time_t def_forbid_dur; 42 | int min_nonwildcard; 43 | char tor_list_fname[PATH_MAX+1]; 44 | char default_cloak[HOSTLEN+1]; 45 | }; 46 | 47 | EXTERN struct ServicesInfoConf ServicesInfo; 48 | 49 | #ifdef IN_CONF_C 50 | void init_servicesinfo(void); 51 | void cleanup_servicesinfo(void); 52 | #endif 53 | 54 | #endif /* INCLUDED_conf_servicesinfo_h */ 55 | -------------------------------------------------------------------------------- /debian/oftc-ircservices.init: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | ### BEGIN INIT INFO 5 | # Provides: irc-services 6 | # Required-Start: $local_fs $network $remote_fs 7 | # Required-Stop: $local_fs $network $remote_fs 8 | # Default-Start: 2 3 4 5 9 | # Default-Stop: 0 1 6 10 | # Short-Description: start and stop oftc-ircservices 11 | # Description: This is the IRC services package written for use on OFTC 12 | # (irc.oftc.net) and other networks. 13 | ### END INIT INFO 14 | 15 | PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin 16 | DAEMON=/usr/bin/oftc-ircservices 17 | NAME="oftc-ircservices" 18 | DESC="OFTC IRC services" 19 | PIDFILE="/var/run/oftc-ircservices.pid" 20 | ARGS="--quiet --chuid irc:irc --pidfile $PIDFILE --exec $DAEMON" 21 | 22 | test -x $DAEMON || exit 0 23 | 24 | touch_files () { 25 | ( cd /var/log/oftc-ircservices 26 | LOGS=`perl -lne 'print $1 if /^\s*f\w+_\w+log\s*=\s*"(.*)"/' < /etc/oftc-ircservices/services.conf` 27 | for l in $LOGS $PIDFILE ; do 28 | if [ ! -e "$l" ] ; then 29 | touch $l 30 | chown irc.irc $l 31 | fi 32 | done 33 | ) 34 | } 35 | 36 | case "$1" in 37 | start) 38 | echo -n "Starting $DESC: " 39 | touch_files 40 | start-stop-daemon --start $ARGS 41 | ;; 42 | stop) 43 | echo -n "Stopping $DESC: " 44 | start-stop-daemon --stop --oknodo $ARGS 45 | echo "$NAME." 46 | ;; 47 | reload) 48 | echo "Reloading $DESC configuration files." 49 | start-stop-daemon --stop --signal 1 $ARGS 50 | ;; 51 | force-reload) 52 | echo "Reloading $DESC configuration files." 53 | start-stop-daemon --stop --signal 1 $ARGS || $0 restart 54 | ;; 55 | restart) 56 | $0 stop 57 | sleep 2 58 | $0 start 59 | ;; 60 | *) 61 | echo "Usage: $0 {start|stop|restart|reload|force-reload}" >&2 62 | exit 1 63 | ;; 64 | esac 65 | 66 | exit 0 67 | -------------------------------------------------------------------------------- /libio/mem/dbuf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). 3 | * dbuf.h: A header for the dynamic buffers functions. 4 | * 5 | * Copyright (C) 2002 by the past and present ircd coders, and others. 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 20 | * USA 21 | * 22 | * $Id$ 23 | */ 24 | 25 | #ifndef INCLUDED_libio_mem_dbuf_h 26 | #define INCLUDED_libio_mem_dbuf_h 27 | 28 | #define DBUF_BLOCK_SIZE 1024 /* this is also our MTU used for sending */ 29 | 30 | #define dbuf_length(x) ((x)->total_size) 31 | #define dbuf_clear(x) dbuf_delete(x, dbuf_length(x)) 32 | 33 | struct dbuf_block 34 | { 35 | size_t size; 36 | char data[DBUF_BLOCK_SIZE]; 37 | }; 38 | 39 | struct dbuf_queue 40 | { 41 | dlink_list blocks; 42 | size_t total_size; 43 | }; 44 | 45 | #ifdef IN_MISC_C 46 | extern void dbuf_init(void); 47 | extern void dbuf_cleanup(void); 48 | #endif 49 | LIBIO_EXTERN void dbuf_put(struct dbuf_queue *, char *, size_t); 50 | LIBIO_EXTERN void dbuf_delete(struct dbuf_queue *, size_t); 51 | 52 | #endif /* INCLUDED_libio_mem_dbuf_h */ 53 | -------------------------------------------------------------------------------- /libio/libioinc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). 3 | * libioinc.h: libio standard includes. 4 | * 5 | * Copyright (C) 2002 by the past and present ircd coders, and others. 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 20 | * USA 21 | * 22 | * $Id$ 23 | */ 24 | 25 | #ifndef INCLUDED_libioinc_h 26 | #define INCLUDED_libioinc_h 27 | 28 | #ifdef HAVE_CONFIG_H 29 | #include 30 | #endif 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include /* strlcpy */ 48 | 49 | #include "irc_libio.h" 50 | 51 | #define LEAKED_FDS 10 52 | #define INIT_LOG_LEVEL L_NOTICE 53 | #define IRC_MAX(a, b) ((a) > (b) ? (a) : (b)) 54 | #define IRC_MIN(a, b) ((a) < (b) ? (a) : (b)) 55 | 56 | #endif /* INCLUDED_libioinc_h */ 57 | -------------------------------------------------------------------------------- /libio/string/sprintf_irc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). 3 | * sprintf_irc.h: The irc sprintf header. 4 | * 5 | * Copyright (C) 2002 by the past and present ircd coders, and others. 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 20 | * USA 21 | * 22 | * $Id$ 23 | */ 24 | 25 | /*============================================================================= 26 | * Prototypes 27 | */ 28 | 29 | #ifndef INCLUDED_libio_string_sprintf_irc_h 30 | #define INCLUDED_libio_string_sprintf_irc_h 31 | 32 | LIBIO_EXTERN int vsprintf_irc(char *str, const char *format, va_list); 33 | 34 | /* XXX NOT USED AND NOT DEFINED */ 35 | LIBIO_EXTERN int vsnprintf_irc(char *, int, const char*, va_list); 36 | 37 | /* old */ 38 | /* LIBIO_EXTERN int ircsprintf(char *str, char *format, ...); */ 39 | /* */ 40 | 41 | /* 42 | * ircsprintf - optimized sprintf 43 | */ 44 | #ifdef __GNUC__ 45 | LIBIO_EXTERN int ircsprintf(char*, const char*, ...) 46 | __attribute__ ((format(printf, 2, 3))); 47 | #else 48 | LIBIO_EXTERN int ircsprintf(char *str, const char *format, ...); 49 | #endif 50 | 51 | #endif /* INCLUDED_libio_string_sprintf_irc_h */ 52 | -------------------------------------------------------------------------------- /src/Makefile.am: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2006 Luca Filipozzi 2 | MAINTAINERCLEANFILES=Makefile.in 3 | SUBDIRS=conf 4 | if USE_RUBY 5 | SUBDIRS+=ruby_module 6 | endif 7 | if USE_PYTHON 8 | SUBDIRS+=python_module 9 | endif 10 | bin_PROGRAMS=services 11 | services_SOURCES= akick.c \ 12 | akill.c \ 13 | chanaccess.c \ 14 | channel.c \ 15 | channel_mode.c \ 16 | conf.c \ 17 | client.c \ 18 | crypt.c \ 19 | connection.c \ 20 | dbchannel.c \ 21 | dbm.c \ 22 | dbmail.c \ 23 | event.c \ 24 | group.c \ 25 | groupaccess.c \ 26 | hash.c \ 27 | hostmask.c \ 28 | interface.c \ 29 | jupe.c \ 30 | language.c \ 31 | kill.c \ 32 | m_error.c \ 33 | mqueue.c \ 34 | nickname.c \ 35 | packet.c \ 36 | parse.c \ 37 | servicemask.c \ 38 | services.c \ 39 | send.c \ 40 | tor.c 41 | 42 | services_LDADD=conf/libconf.a $(top_srcdir)/libio/libio.a @LIBLTDL@ 43 | services_LDFLAGS=-levent 44 | if USE_RUBY 45 | services_LDFLAGS+=@RUBY_LDFLAGS@ 46 | services_LDADD+=ruby_module/libruby_module.a 47 | endif 48 | if USE_PYTHON 49 | services_LDFLAGS+=@PYTHON_LDFLAGS@ 50 | services_LDADD+=python_module/libpython_module.a 51 | endif 52 | services_LDFLAGS+=-export-dynamic 53 | services_CFLAGS=-I$(top_srcdir)/libio -I$(top_srcdir)/include -I$(top_srcdir)/languages 54 | AM_CPPFLAGS=@INCLTDL@ 55 | if USE_SHARED_MODULES 56 | services_LDADD+= 57 | else 58 | services_LDADD+=$(top_srcdir)/modules/libmodules.la 59 | endif 60 | AM_YFLAGS=-d 61 | top_build_prefix=$(top_srcdir)/ 62 | -------------------------------------------------------------------------------- /src/m_error.c: -------------------------------------------------------------------------------- 1 | /* 2 | * oftc-ircservices: an extensible and flexible IRC Services package 3 | * m_error.c: Handles the ERROR function 4 | * 5 | * Copyright (C) 2006 Stuart Walsh and the OFTC Coding department 6 | * 7 | * Some parts: 8 | * 9 | * Copyright (C) 2002 by the past and present ircd coders, and others. 10 | * 11 | * This program is free software; you can redistribute it and/or modify 12 | * it under the terms of the GNU General Public License as published by 13 | * the Free Software Foundation; either version 2 of the License, or 14 | * (at your option) any later version. 15 | * 16 | * This program is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU General Public License 22 | * along with this program; if not, write to the Free Software 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 24 | * USA 25 | * 26 | * $Id$ 27 | */ 28 | 29 | #include "stdinc.h" 30 | #include "parse.h" 31 | #include "language.h" 32 | #include "dbm.h" 33 | #include "nickname.h" 34 | #include "interface.h" 35 | #include "msg.h" 36 | #include "client.h" 37 | 38 | struct Message error_msgtab = { 39 | "ERROR", 0, 0, 1, 0, 0, 0, 40 | { ms_error, m_ignore } 41 | }; 42 | 43 | void 44 | ms_error(struct Client *client, struct Client *source, int parc, char *parv[]) 45 | { 46 | const char *para; 47 | 48 | para = (parc > 1 && *parv[1] != '\0') ? parv[1] : "<>"; 49 | 50 | ilog(L_DEBUG, "Received ERROR message from %s: %s", source->name, para); 51 | 52 | if (client == source) 53 | ilog(L_DEBUG, "ERROR :from %s -- %s", client->name, para); 54 | else 55 | ilog(L_DEBUG, "ERROR :from %s via %s -- %s", source->name, client->name, para); 56 | } 57 | 58 | -------------------------------------------------------------------------------- /libio/mem/dynlink.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). 3 | * dynlink.c: Low level interface for module support. 4 | * 5 | * Copyright (C) 2002-2006 by the past and present ircd coders, and others. 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 20 | * USA 21 | * 22 | * $Id$ 23 | */ 24 | 25 | #include "libioinc.h" 26 | 27 | #ifdef HAVE_LINK_H 28 | #include 29 | #endif 30 | 31 | #ifdef HAVE_DLFCN_H 32 | #include 33 | #endif 34 | 35 | #include 36 | #ifdef USE_SHARED_MODULES 37 | 38 | void * 39 | modload(const char *name, void **base) 40 | { 41 | void *handle = lt_dlopenext(name); 42 | 43 | if (handle) 44 | { 45 | #ifdef HAVE_DLINFO 46 | struct link_map *map; 47 | 48 | if (!dlinfo(handle, RTLD_DI_LINKMAP, &map)) 49 | *base = (void*)map->l_addr; 50 | else 51 | #endif 52 | *base = NULL; 53 | } 54 | 55 | return handle; 56 | } 57 | 58 | void * 59 | modsym(void *handle, const char *name) 60 | { 61 | return lt_dlsym(handle, name); 62 | } 63 | 64 | void 65 | modunload(void *handle) 66 | { 67 | lt_dlclose(handle); 68 | } 69 | 70 | const char * 71 | moderror(void) 72 | { 73 | return lt_dlerror(); 74 | } 75 | 76 | #endif /* USE_SHARED_MODULES */ 77 | -------------------------------------------------------------------------------- /include/defines.h: -------------------------------------------------------------------------------- 1 | /* TODO: add copyright block */ 2 | 3 | #ifndef INCLUDED_defines_h 4 | #define INCLUDED_defines_h 5 | 6 | #define LOGDIR LOCALSTATEDIR "/log/" 7 | #define PIDDIR LOCALSTATEDIR "/run/" 8 | #define AUTOMODPATH LIBDIR "/" PACKAGE "/autoload/" 9 | #define MODPATH LIBDIR "/" PACKAGE "/" 10 | #define LANGPATH DATADIR "/" PACKAGE "/" 11 | #define CPATH SYSCONFDIR "/services.conf" 12 | #define DPATH PREFIX "/" 13 | #define LPATH LOGDIR "services.log" 14 | #define PPATH PIDDIR "services.pid" 15 | 16 | #define SENDMAIL_PATH "/usr/sbin/sendmail -t" 17 | 18 | #define IRC_BUFSIZE 512 19 | #define CONNECTTIMEOUT 30 20 | #define READBUF_SIZE 16384 21 | #define IRCD_MAXPARA 15 /* Maximum allowed parameters a command may have */ 22 | #define REALLEN 50 23 | #define CHANNELLEN 200 24 | #define GROUPLEN 32 25 | #define KICKLEN 160 26 | #define KEYLEN 24 27 | #define REASONLEN 120 28 | #define PASSLEN 40 29 | #define SALTLEN 16 30 | #define DATALEN 255 31 | #define USERHOSTLEN USERLEN+HOSTLEN+1+1 32 | #define USERHOST_REPLYLEN (NICKLEN+HOSTLEN+USERLEN+5) 33 | 34 | #define TIME_BUFFER 255 35 | 36 | #define IRC_MAXSID 3 37 | #define IRC_MAXUID 6 38 | #define TOTALSIDUID (IRC_MAXSID + IRC_MAXUID) 39 | 40 | #define IRC_MAX(a, b) ((a) > (b) ? (a) : (b)) 41 | #define IRC_MIN(a, b) ((a) < (b) ? (a) : (b)) 42 | 43 | #define TRUE 1 44 | #define FALSE 0 45 | 46 | #ifndef _WIN32 47 | # define EXTERN extern 48 | #else 49 | # ifdef IN_IRCD 50 | # define EXTERN extern __declspec(dllexport) 51 | # else 52 | # define EXTERN extern __declspec(dllimport) 53 | # endif 54 | # define _modinit __declspec(dllexport) _modinit 55 | # define _moddeinit __declspec(dllexport) _moddeinit 56 | # define _version __declspec(dllexport) _version 57 | #endif 58 | 59 | #ifdef HAVE_STRTOK_R 60 | # define strtoken(x, y, z) strtok_r(y, z, x) 61 | #endif 62 | 63 | #endif /* INCLUDED_defines_h */ 64 | -------------------------------------------------------------------------------- /libio/misc/hook.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). 3 | * hook.h: A header for the hooks into parts of ircd. 4 | * 5 | * Copyright (C) 2002 by the past and present ircd coders, and others. 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 20 | * USA 21 | * 22 | * $Id$ 23 | */ 24 | 25 | #ifndef INCLUDED_libio_misc_hook_h 26 | #define INCLUDED_libio_misc_hook_h 27 | 28 | #define HOOK_V2 29 | 30 | typedef void *CBFUNC(va_list); 31 | 32 | struct Callback 33 | { 34 | char *name; 35 | dlink_list chain; 36 | dlink_node node; 37 | unsigned int called; 38 | time_t last; 39 | }; 40 | 41 | LIBIO_EXTERN dlink_list callback_list; /* listing/debugging purposes */ 42 | 43 | LIBIO_EXTERN struct Callback *register_callback(const char *, CBFUNC *); 44 | LIBIO_EXTERN void unregister_callback(struct Callback *); 45 | LIBIO_EXTERN void *execute_callback(struct Callback *, ...); 46 | LIBIO_EXTERN struct Callback *find_callback(const char *); 47 | LIBIO_EXTERN dlink_node *install_hook(struct Callback *, CBFUNC *); 48 | LIBIO_EXTERN void uninstall_hook(struct Callback *, CBFUNC *); 49 | LIBIO_EXTERN void *pass_callback(dlink_node *, ...); 50 | 51 | #define is_callback_present(c) (!!dlink_list_length(&c->chain)) 52 | 53 | #endif /* INCLUDED_libio_misc_hook_h */ 54 | -------------------------------------------------------------------------------- /libio/irc_libio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). 3 | * irc_libio.h: libio interface specification. 4 | * 5 | * Copyright (C) 2002 by the past and present ircd coders, and others. 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 20 | * USA 21 | * 22 | * $Id$ 23 | */ 24 | 25 | #ifndef INCLUDED_irc_libio_h 26 | #define INCLUDED_irc_libio_h 27 | 28 | #ifdef _WIN32 29 | # ifdef IN_LIBIO 30 | # define LIBIO_EXTERN extern __declspec(dllexport) 31 | # else 32 | # define LIBIO_EXTERN extern __declspec(dllimport) 33 | # endif 34 | #else /* not _WIN32 */ 35 | # define LIBIO_EXTERN extern 36 | #endif 37 | 38 | #include "misc/event.h" 39 | #include "misc/list.h" 40 | #include "misc/log.h" 41 | #include "misc/misc.h" 42 | #include "misc/hook.h" 43 | #include "misc/libio_getopt.h" 44 | 45 | #include "net/inet_misc.h" 46 | #include "comm/fdlist.h" 47 | #include "comm/fileio.h" 48 | #include "comm/comm.h" 49 | 50 | #include "mem/balloc.h" 51 | #include "mem/dbuf.h" 52 | #include "mem/memory.h" 53 | #include "mem/dynlink.h" 54 | 55 | #include "net/irc_getaddrinfo.h" 56 | #include "net/irc_getnameinfo.h" 57 | #include "net/res.h" 58 | 59 | #include "string/sprintf_irc.h" 60 | #include "string/pcre.h" 61 | #include "string/irc_string.h" 62 | 63 | #endif /* INCLUDED_irc_libio_h */ 64 | -------------------------------------------------------------------------------- /languages/services.en.lang: -------------------------------------------------------------------------------- 1 | 0 English 2 | SERV_HELP_NOT_AVAIL 3 | HELP for %s is not available. 4 | SERV_SUB_HELP_NOT_AVAIL 5 | HELP for %s %s is not available. 6 | SERV_HELP_SHORT 7 | %s: %s 8 | SERV_HELP_HEADER 9 | *** %s Help *** 10 | SERV_HELP_FOOTER 11 | *** End of %s Help *** 12 | SERV_SUB_HELP_HEADER 13 | *** %s %s Help *** 14 | SERV_SUB_HELP_FOOTER 15 | *** End of %s %s Help *** 16 | SERV_UNKNOWN_CMD 17 | Unknown command %s, /msg %s HELP for help. 18 | SERV_TOOFEW_PARAM 19 | Too few parameters. Expected at least %d. Got %d. 20 | SERV_TOOMANY_PARAM 21 | Too many parameters. Expected no more than %d. Got %d. 22 | SERV_NOT_IDENTIFIED 23 | Nickname %s is not identified to nickname services. 24 | SERV_ACCESS_DENIED 25 | Access to that command is restricted to IRC Operators or services admins. 26 | SERV_UNREG_CHAN 27 | Channel %s is not registered with channel services. 28 | SERV_UNREG_GROUP 29 | Group %s is not registered with group services. 30 | SERV_NO_ACCESS_CHAN 31 | You do not have access to the %s command on channel %s. 32 | SERV_NO_ACCESS_CHAN_ID 33 | You do not have access to the %s command on channel %s. Identifying 34 | to your nickname may give you this access. See nickname services' HELP 35 | IDENTIFY command for more information. 36 | SERV_NO_ACCESS_GROUP 37 | You do not have access to the %s command for the group %s. 38 | SERV_NO_ACCESS_GROUP_ID 39 | You do not have access to the %s command on group %s. Identifying to 40 | your nickname may give you this access. See nickname services' HELP IDENTIFY 41 | command for more information. 42 | SERV_NO_ACCESS 43 | You do not have access to the %s command. 44 | SERV_NO_ACCESS_REGFIRST 45 | You do not have access to the %s command. To access this command the 46 | nickname you are currently using must be REGISTERED and you must be 47 | IDENTIFIED to it. See HELP REGISTER and HELP IDENTIFY for more information. 48 | SERV_UNKNOWN_OPTION 49 | Unknown option %s, /msg %s HELP %s for help. 50 | SERV_DATETIME_FORMAT 51 | %a %d %b %Y %H:%M:%S %z 52 | -------------------------------------------------------------------------------- /libio/misc/event.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). 3 | * event.h: The ircd event header. 4 | * 5 | * Copyright (C) 2002 by the past and present ircd coders, and others. 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 20 | * USA 21 | * 22 | * $Id$ 23 | */ 24 | 25 | #ifndef INCLUDED_libio_misc_event_h 26 | #define INCLUDED_libio_misc_event_h 27 | 28 | /* 29 | * How many event entries we need to allocate at a time in the block 30 | * allocator. 16 should be plenty at a time. 31 | */ 32 | #define MAX_EVENTS 50 33 | 34 | typedef void EVH(void *); 35 | 36 | /* The list of event processes */ 37 | struct ev_entry 38 | { 39 | EVH *func; 40 | void *arg; 41 | const char *name; 42 | time_t frequency; 43 | time_t when; 44 | int active; 45 | }; 46 | 47 | LIBIO_EXTERN const char *last_event_ran; 48 | LIBIO_EXTERN struct ev_entry event_table[]; 49 | 50 | LIBIO_EXTERN void eventAdd(const char *, EVH *, void *, time_t); 51 | LIBIO_EXTERN void eventAddIsh(const char *, EVH *, void *, time_t); 52 | LIBIO_EXTERN void eventRun(void); 53 | LIBIO_EXTERN time_t eventNextTime(void); 54 | #ifdef IN_MISC_C 55 | extern void eventInit(void); 56 | #endif 57 | LIBIO_EXTERN void eventDelete(EVH *, void *); 58 | LIBIO_EXTERN void set_back_events(time_t); 59 | 60 | #endif /* INCLUDED_libio_misc_event_h */ 61 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Run this to generate all the initial makefiles, etc. 3 | # Shamelessly stolen from lighttpd - which is licensed under the GPL 4 | 5 | LIBTOOLIZE_FLAGS="--automake --ltdl --force --install --copy" 6 | AUTOMAKE_FLAGS="--add-missing" 7 | CONFIGURE_FLAGS="--prefix=/home/oftc/ircservices/services --with-nicklen=30 --with-topiclen=390 --disable-python" 8 | 9 | ARGV0=$0 10 | 11 | run() { 12 | echo "$ARGV0: running \`$@'" 13 | "$@" 14 | } 15 | 16 | ## jump out if one of the programs returns 'false' 17 | set -e 18 | 19 | ## on macosx glibtoolize, others have libtool 20 | if test x$LIBTOOLIZE = x; then 21 | if test \! x`which glibtoolize` = x; then 22 | LIBTOOLIZE=glibtoolize 23 | elif test \! x`which libtoolize-1.5` = x; then 24 | LIBTOOLIZE=libtoolize-1.5 25 | elif test \! x`which libtoolize` = x; then 26 | LIBTOOLIZE=libtoolize 27 | fi 28 | fi 29 | 30 | ## suse has aclocal and aclocal-1.9 31 | if test x$ACLOCAL = x; then 32 | if test \! x`which aclocal-1.9` = x; then 33 | ACLOCAL=aclocal-1.9 34 | AUTOMAKE=automake-1.9 35 | elif test \! x`which aclocal` = x; then 36 | ACLOCAL=aclocal 37 | AUTOMAKE=automake 38 | fi 39 | fi 40 | 41 | if test x$AUTOMAKE = x; then 42 | if test \! x`which automake-1.9` = x; then 43 | AUTOMAKE=automake-1.9 44 | elif test \! x`which automake` = x; then 45 | AUTOMAKE=automake 46 | fi 47 | fi 48 | 49 | 50 | ## macosx has autoconf-2.59 and autoconf-2.60 51 | if test x$AUTOCONF = x; then 52 | if test \! x`which autoconf-2.59` = x; then 53 | AUTOCONF=autoconf-2.59 54 | elif test \! x`which autoconf` = x; then 55 | AUTOCONF=autoconf 56 | fi 57 | fi 58 | 59 | if test x$AUTOHEADER = x; then 60 | if test \! x`which autoheader-2.59` = x; then 61 | AUTOHEADER=autoheader-2.59 62 | elif test \! x`which autoheader` = x; then 63 | AUTOHEADER=autoheader 64 | fi 65 | fi 66 | 67 | 68 | run $LIBTOOLIZE $LIBTOOLIZE_FLAGS 69 | run $ACLOCAL $ACLOCAL_FLAGS 70 | sed -i -e 's/install-sh ltmain.sh missing mkinstalldirs/install-sh ltmain.sh missing/' libltdl/Makefile.in 71 | run $AUTOHEADER 72 | run $AUTOMAKE $AUTOMAKE_FLAGS 73 | run $AUTOCONF 74 | run ./configure $CONFIGURE_FLAGS "$@" 75 | -------------------------------------------------------------------------------- /libio/mem/memory.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). 3 | * memory.h: A header for the memory functions. 4 | * 5 | * Copyright (C) 2002 by the past and present ircd coders, and others. 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 20 | * USA 21 | * 22 | * $Id$ 23 | */ 24 | 25 | #ifndef INCLUDED_libio_mem_memory_h 26 | #define INCLUDED_libio_mem_memory_h 27 | LIBIO_EXTERN void (* outofmemory) (void); 28 | 29 | static inline void *MyMalloc(size_t); 30 | static inline void *MyRealloc(void *, size_t); 31 | static inline void MyFree(void *); 32 | static inline void _DupString(char **, const char *); 33 | LIBIO_EXTERN void mem_frob(void *, int); 34 | 35 | static inline void * 36 | MyMalloc(size_t size) 37 | { 38 | void *ret = calloc(1, size); 39 | 40 | if (ret == NULL) 41 | outofmemory(); 42 | return(ret); 43 | } 44 | 45 | static inline void * 46 | MyRealloc(void *x, size_t y) 47 | { 48 | void *ret = realloc(x, y); 49 | 50 | if (ret == NULL) 51 | outofmemory(); 52 | return(ret); 53 | } 54 | 55 | static inline void 56 | MyFree(void *x) 57 | { 58 | if (x != NULL) 59 | free(x); 60 | } 61 | 62 | static inline void 63 | _DupString(char **x, const char *y) 64 | { 65 | if(y == NULL) 66 | return; 67 | 68 | (*x) = malloc(strlen(y) + 1); 69 | 70 | if (x == NULL) 71 | outofmemory(); 72 | strcpy((*x), y); 73 | } 74 | 75 | #define DupString(x,y) _DupString(&(x), (y)) 76 | 77 | #endif /* INCLUDED_libio_mem_memory_h */ 78 | -------------------------------------------------------------------------------- /include/conf/modules.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). 3 | * modules.h: Defines modules{} conf section. 4 | * 5 | * Copyright (C) 2005 by the Hybrid Development Team. 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 20 | * USA 21 | * 22 | * $Id$ 23 | */ 24 | 25 | #ifndef INCLUDED_conf_modules_h 26 | #define INCLUDED_conf_modules_h 27 | 28 | enum ModType 29 | { 30 | MODTYPE_RUBY, 31 | MODTYPE_PYTHON, 32 | MODTYPE_SO 33 | }; 34 | 35 | struct Module 36 | { 37 | char *name; 38 | const char *version; 39 | void *(* modinit) (void); 40 | void (* modremove) (void); 41 | char *fullname; 42 | void *handle; 43 | void *address; 44 | dlink_node node; 45 | enum ModType type; 46 | }; 47 | 48 | #define INIT_MODULE(NAME, REV) \ 49 | static void *_modinit(void); \ 50 | static void _moddeinit(void); \ 51 | struct Module NAME ## _module = {#NAME, REV, _modinit, _moddeinit}; \ 52 | static void *_modinit(void) 53 | 54 | #define CLEANUP_MODULE \ 55 | static void _moddeinit(void) 56 | 57 | #ifdef IN_CONF_C 58 | void init_modules(void); 59 | #endif 60 | 61 | EXTERN dlink_list loaded_modules; 62 | EXTERN const char *core_modules[]; 63 | 64 | EXTERN struct Module *find_module(const char *, int); 65 | EXTERN void * load_module(const char *); 66 | EXTERN void unload_module(struct Module *); 67 | EXTERN void boot_modules(char); 68 | EXTERN void cleanup_modules(); 69 | EXTERN dlink_list* get_modpaths(); 70 | 71 | #endif /* INCLUDED_conf_modules_h */ 72 | -------------------------------------------------------------------------------- /libio/misc/log.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). 3 | * log.h: A header for the logger functions. 4 | * 5 | * Copyright (C) 2002 by the past and present ircd coders, and others. 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 20 | * USA 21 | * 22 | * $Id$ 23 | */ 24 | 25 | #ifndef INCLUDED_libio_misc_log_h 26 | #define INCLUDED_libio_misc_log_h 27 | 28 | #define L_CRIT 0 29 | #define L_ERROR 1 30 | #define L_WARN 2 31 | #define L_NOTICE 3 32 | #define L_INFO 4 33 | #define L_DEBUG 5 34 | #define L_TRACE 6 35 | 36 | #ifndef SYSLOG_USERS 37 | LIBIO_EXTERN void *user_log_fb; 38 | #endif 39 | 40 | LIBIO_EXTERN void init_log(const char *); 41 | LIBIO_EXTERN void cleanup_log(); 42 | LIBIO_EXTERN void reopen_log(const char *); 43 | LIBIO_EXTERN void set_gnotice_log_level(const int); 44 | LIBIO_EXTERN int get_gnotice_log_level(void); 45 | LIBIO_EXTERN void set_file_log_level(const int); 46 | LIBIO_EXTERN int get_file_log_level(void); 47 | #ifdef __GNUC__ 48 | LIBIO_EXTERN void ilog(const int, const char *, ...) 49 | __attribute__((format(printf, 2, 3))); 50 | #else 51 | LIBIO_EXTERN void ilog(const int, const char *, ...); 52 | #endif 53 | LIBIO_EXTERN const char *get_log_level_as_string(int); 54 | 55 | enum { 56 | LOG_OPER_TYPE, 57 | LOG_FAILED_OPER_TYPE, 58 | LOG_KLINE_TYPE, 59 | LOG_RKLINE_TYPE, 60 | LOG_TEMP_KLINE_TYPE, 61 | LOG_DLINE_TYPE, 62 | LOG_TEMP_DLINE_TYPE, 63 | LOG_GLINE_TYPE, 64 | LOG_KILL_TYPE, 65 | LOG_OPERSPY_TYPE, 66 | LOG_IOERR_TYPE 67 | }; 68 | 69 | #endif /* INCLUDED_libio_misc_log_h */ 70 | -------------------------------------------------------------------------------- /libio/net/irc_getnameinfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the project nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * $Id$ 30 | */ 31 | 32 | #ifndef INCLUDED_libio_net_irc_getnameinfo_h 33 | #define INCLUDED_libio_net_irc_getnameinfo_h 34 | 35 | LIBIO_EXTERN int irc_getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host, 36 | size_t hostlen, char *serv, size_t servlen, int flags); 37 | 38 | #ifndef IN_MULTICAST 39 | #define IN_MULTICAST(a) ((((long int) (a)) & 0xf0000000) == 0xe0000000) 40 | #endif 41 | 42 | #ifndef IN_EXPERIMENTAL 43 | #define IN_EXPERIMENTAL(a) ((((long int) (a)) & 0xe0000000) == 0xe0000000) 44 | #endif 45 | 46 | #endif /* INCLUDED_libio_net_irc_getnameinfo_h */ 47 | -------------------------------------------------------------------------------- /sql/views-pgsql.sql: -------------------------------------------------------------------------------- 1 | -- Some extra functions and views useful for looking into the database. 2 | -- These are not used by services itself. 3 | 4 | BEGIN; 5 | 6 | CREATE OR REPLACE FUNCTION mktime(integer) RETURNS timestamp without time zone 7 | AS $_$ SELECT to_timestamp($1)::timestamp without time zone $_$ 8 | LANGUAGE sql IMMUTABLE STRICT; 9 | 10 | CREATE OR REPLACE FUNCTION nick(integer) RETURNS text 11 | AS $_$ SELECT nick FROM nickname JOIN account ON (account.primary_nick = nickname.id) WHERE account.id = $1 $_$ 12 | LANGUAGE sql STABLE STRICT; 13 | 14 | CREATE AGGREGATE array_accum(anyelement) ( 15 | SFUNC = array_append, 16 | STYPE = anyarray, 17 | INITCOND = '{}' 18 | ); 19 | 20 | CREATE OR REPLACE VIEW akick_view AS 21 | SELECT channel.channel, 22 | channel_akick.chmode, 23 | COALESCE(nick(channel_akick.target), channel_akick.mask) AS mask, 24 | mktime(channel_akick."time") AS "time", 25 | channel_akick.duration, 26 | channel_akick.reason 27 | FROM channel 28 | JOIN channel_akick ON (channel.id = channel_akick.channel_id); 29 | 30 | CREATE OR REPLACE VIEW akill_view AS 31 | SELECT nick(akill.setter) AS setter, 32 | mktime(akill."time") AS "time", 33 | justify_hours((akill.duration || ' sec'::text)::interval) AS duration, 34 | akill.mask, 35 | akill.reason 36 | FROM akill; 37 | 38 | CREATE OR REPLACE VIEW cs_view AS 39 | SELECT c.channel, 40 | "substring"((c.description)::text, 1, 50) AS description, 41 | "substring"((c.topic)::text, 1, 50) AS topic, 42 | mktime(c.reg_time) AS reg_time, 43 | mktime(c.last_used) AS last_used, 44 | array_accum(nick(ca.account_id)) AS masters 45 | FROM channel c 46 | LEFT JOIN channel_access ca ON ((c.id = ca.channel_id) AND (ca.level = 4)) 47 | GROUP BY 1, 2, 3, 4, 5; 48 | 49 | CREATE OR REPLACE VIEW ns_view AS 50 | SELECT (SELECT nick FROM nickname 51 | WHERE account.primary_nick = nickname.id), 52 | (SELECT array_agg(nick) FROM nickname 53 | WHERE account.id = nickname.account_id 54 | AND nickname.id <> account.primary_nick) AS nicks, 55 | to_timestamp(reg_time) AS reg_time, 56 | to_timestamp(last_quit_time) AS last_quit_time, 57 | (SELECT to_timestamp(MAX(last_seen)) FROM nickname 58 | WHERE account.id = nickname.account_id) AS last_seen, 59 | last_host, 60 | last_realname, 61 | last_quit_msg, 62 | email, 63 | cloak, 64 | flag_verified, 65 | id 66 | FROM account; 67 | 68 | COMMIT; 69 | -------------------------------------------------------------------------------- /src/ruby_module/dbresult.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "libruby_module.h" 3 | 4 | VALUE cDBResult = Qnil; 5 | 6 | static VALUE initialize(VALUE, VALUE); 7 | static VALUE row_count(VALUE); 8 | static VALUE row_each(VALUE); 9 | static VALUE m_free(VALUE); 10 | static VALUE row_index(VALUE, VALUE); 11 | 12 | void 13 | Init_DBResult(void) 14 | { 15 | cDBResult = rb_define_class("DBResult", rb_cObject); 16 | 17 | rb_define_method(cDBResult, "initialize", initialize, 1); 18 | rb_define_method(cDBResult, "row_count", row_count, 0); 19 | rb_define_method(cDBResult, "row_each", row_each, 0); 20 | rb_define_method(cDBResult, "free", m_free, 0); 21 | rb_define_method(cDBResult, "[]", row_index, 1); 22 | } 23 | 24 | static VALUE 25 | initialize(VALUE self, VALUE result) 26 | { 27 | rb_iv_set(self, "@realptr", result); 28 | return self; 29 | } 30 | 31 | static VALUE 32 | row_count(VALUE self) 33 | { 34 | result_set_t *result = value_to_dbresult(self); 35 | return INT2NUM(result->row_count); 36 | } 37 | 38 | static VALUE 39 | row_each(VALUE self) 40 | { 41 | if(rb_block_given_p()) 42 | { 43 | result_set_t *result = value_to_dbresult(self); 44 | int i = 0; 45 | for(i = 0; i < result->row_count; i++) 46 | { 47 | rb_yield(dbrow_to_value(&result->rows[i])); 48 | } 49 | } 50 | 51 | return self; 52 | } 53 | 54 | static VALUE 55 | m_free(VALUE self) 56 | { 57 | result_set_t *result = value_to_dbresult(self); 58 | db_free_result(result); 59 | return self; 60 | } 61 | 62 | static VALUE 63 | row_index(VALUE self, VALUE index) 64 | { 65 | result_set_t *result = value_to_dbresult(self); 66 | int idx = NUM2INT(index); 67 | if(idx < result->row_count) 68 | return dbrow_to_value(&result->rows[idx]); 69 | else 70 | return Qnil; /* TODO XXX FIXME Throw exception? */ 71 | } 72 | 73 | result_set_t* 74 | value_to_dbresult(VALUE self) 75 | { 76 | result_set_t *out; 77 | VALUE result = rb_iv_get(self, "@realptr"); 78 | Data_Get_Struct(result, result_set_t, out); 79 | return out; 80 | } 81 | 82 | VALUE 83 | dbresult_to_value(result_set_t *result) 84 | { 85 | VALUE tmp, real; 86 | 87 | tmp = Data_Wrap_Struct(rb_cObject, 0, 0, result); 88 | real = do_ruby_ret(cDBResult, rb_intern("new"), 1, tmp); 89 | 90 | if(real == Qnil) 91 | { 92 | ilog(L_CRIT, "RUBY ERROR: Ruby Failed To Create DBResult"); 93 | return Qnil; 94 | } 95 | 96 | return real; 97 | } 98 | -------------------------------------------------------------------------------- /src/conf.c: -------------------------------------------------------------------------------- 1 | /* 2 | * oftc-ircservices: an extensible and flexible IRC Services package 3 | * config.c: Config functions 4 | * 5 | * Copyright (C) 2006 Stuart Walsh and the OFTC Coding department 6 | * 7 | * Some parts: 8 | * 9 | * Copyright (C) 2002 by the past and present ircd coders, and others. 10 | * 11 | * This program is free software; you can redistribute it and/or modify 12 | * it under the terms of the GNU General Public License as published by 13 | * the Free Software Foundation; either version 2 of the License, or 14 | * (at your option) any later version. 15 | * 16 | * This program is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU General Public License 22 | * along with this program; if not, write to the Free Software 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 24 | * USA 25 | * 26 | * $Id$ 27 | */ 28 | 29 | #include "stdinc.h" 30 | #include "conf/conf.h" 31 | 32 | extern struct ConfParserContext conf_curctx; 33 | extern int yyparse(); /* defined in y.tab.c */ 34 | extern int lineno; 35 | int scount = 0; /* used by yyparse(), etc */ 36 | extern int yylex_destroy(void); 37 | 38 | int 39 | conf_fbgets(char *lbuf, int max_size, FBFILE *fb) 40 | { 41 | char *buff; 42 | 43 | if ((buff = fbgets(lbuf, max_size, fb)) == NULL) 44 | return(0); 45 | 46 | return(strlen(lbuf)); 47 | } 48 | 49 | void 50 | read_services_conf(int cold) 51 | { 52 | conf_curctx.f = fbopen(ServicesState.configfile, "r"); 53 | if(!conf_curctx.f) 54 | { 55 | parse_fatal("Cannot open %s", ServicesState.configfile); 56 | return; 57 | } 58 | 59 | conf_cold = cold; 60 | execute_callback(reset_conf); 61 | 62 | conf_pass = 1; 63 | conf_curctx.filename = ServicesState.configfile; 64 | conf_curctx.lineno = 0; 65 | conf_linebuf[0] = 0; 66 | yyparse(); 67 | 68 | conf_pass = 2; 69 | execute_callback(switch_conf_pass); 70 | fbrewind(conf_curctx.f); 71 | conf_curctx.lineno = 0; 72 | conf_linebuf[0] = 0; 73 | yyparse(); 74 | yylex_destroy(); 75 | 76 | execute_callback(verify_conf); 77 | conf_pass = 0; 78 | fbclose(conf_curctx.f); 79 | 80 | execute_callback(on_config_loaded_cb, cold); 81 | } 82 | -------------------------------------------------------------------------------- /languages/ganneffserv.en.lang: -------------------------------------------------------------------------------- 1 | 0 English 2 | GS_HLP_SHORT 3 | %s: shows this help 4 | GS_HLP_LONG 5 | Shows this help message 6 | GS_HLP_CLT_SHORT 7 | %s: Execute a ruby gc collection 8 | GS_HLP_CLT_LONG 9 | Execute a ruby gc collection 10 | 11 | Use only if you expect something evil in ruby has happened. 12 | GS_HLP_ADD_SHORT 13 | %s: Cause GS to monitor a specific channel 14 | GS_HLP_ADD_LONG 15 | Cause GS to monitor a specific channel 16 | 17 | Usage: ADD # : 18 | 19 | # is the channel to monitor. 20 | 21 | is the type of the channel. This is either 22 | J for a channel where every join triggers a kill 23 | CRFJ for a channel where Connect, Register nick, Join channel within 24 | 15 seconds (i.e. fast) triggers a kill 25 | If it is omitted a default J is taken. 26 | 27 | : is the reason to use with the kill. A default contact email 28 | is added if no support@oftc.net is found within reason. Do not 29 | forget the : 30 | 31 | Usage: ADD # : 32 | GS_HLP_DEL_SHORT 33 | %s: Delete monitored channel 34 | GS_HLP_DEL_LONG 35 | Delete a monitored channel 36 | 37 | Usage: DEL #foo 38 | GS_HLP_LST_SHORT 39 | %s: List monitored channels 40 | GS_HLP_LST_LONG 41 | It really just lists monitored channels 42 | GS_HLP_DBG_SHORT 43 | %s: Toggle debug notices 44 | GS_HLP_DBG_LONG 45 | Toggle debug notices on/off (all log entries will be sent as snotes too) 46 | 47 | Usage: DEBUG 48 | GS_HLP_CRP_SHORT 49 | %s: Toggle restricted mode 50 | GS_HLP_CRP_LONG 51 | Toggle restricted mode, where only actions will be done that don't 52 | depend on any other part of services. 53 | 54 | Usage: CRAP 55 | GS_HLP_SAV_SHORT 56 | %s: Saves channel data 57 | GS_HLP_SAV_LONG 58 | Saves channel data 59 | GS_HLP_ENF_SHORT 60 | %s: Enforces all known channels again. Don't run! 61 | GS_HLP_ENF_LONG 62 | Enforces all known channels again. Don't run! 63 | GS_HLP_STS_SHORT 64 | %s: Statistics 65 | GS_HLP_STS_LONG 66 | Don't trust this, you haven't forged the numbers yourself! 67 | GS_HLP_SRV_SHORT 68 | %s: Add a "bad" server on which all connects will be akilled 69 | GS_HLP_SRV_LONG 70 | USAGE: BADSERV [somewhere.example.com|OFF] 71 | 72 | Add a "bad" server on which all connects will be akilled 73 | 74 | BE VERY CAREFUL WHEN USING THIS AND MAKE SURE THE SERVER IS NOT 75 | IN ROTATION. 76 | 77 | EVERY user that connects on this server WILL BE KLINED! 78 | -------------------------------------------------------------------------------- /src/tor.c: -------------------------------------------------------------------------------- 1 | #include "stdinc.h" 2 | #include "conf/conf.h" 3 | #include "conf/servicesinfo.h" 4 | #include "hash.h" 5 | #include "tor.h" 6 | 7 | static dlink_list tornode_list; 8 | 9 | static BlockHeap *tornode_heap = NULL; 10 | 11 | static dlink_node *config_loaded_hook; 12 | 13 | static void tornode_add(const char*); 14 | static void tornode_clear(); 15 | 16 | static void* 17 | config_loaded(va_list args) 18 | { 19 | int cold = va_arg(args, int); 20 | FBFILE *t = NULL; 21 | char buffer[256]; 22 | 23 | if(!EmptyString(ServicesInfo.tor_list_fname)) 24 | { 25 | ilog(L_DEBUG, "Opening tor list: %s", ServicesInfo.tor_list_fname); 26 | t = fbopen(ServicesInfo.tor_list_fname, "r"); 27 | if (t != NULL) 28 | { 29 | tornode_clear(); 30 | while(fbgets(buffer, sizeof(buffer), t) != NULL) 31 | { 32 | tornode_add(buffer); 33 | } 34 | fbclose(t); 35 | } 36 | } 37 | 38 | return pass_callback(config_loaded_hook, cold); 39 | } 40 | 41 | void 42 | init_tor() 43 | { 44 | tornode_heap = BlockHeapCreate("tornode", sizeof(struct TorNode), 45 | TORNODE_HEAP_SIZE); 46 | 47 | config_loaded_hook = install_hook(on_config_loaded_cb, config_loaded); 48 | } 49 | 50 | void 51 | cleanup_tor() 52 | { 53 | tornode_clear(); 54 | BlockHeapDestroy(tornode_heap); 55 | 56 | uninstall_hook(on_config_loaded_cb, config_loaded); 57 | } 58 | 59 | void 60 | tornode_add(const char *host) 61 | { 62 | if (find_tor(host) == NULL) 63 | { 64 | struct TorNode *node = BlockHeapAlloc(tornode_heap); 65 | strlcpy(node->host, host, sizeof(node->host)); 66 | 67 | if (node->host[strlen(node->host)-1] == '\n') 68 | node->host[strlen(node->host)-1] = '\0'; 69 | 70 | hash_add_tor(node); 71 | dlinkAdd(node, &node->node, &tornode_list); 72 | 73 | ilog(L_DEBUG, "Added %s to tor exit node list", node->host); 74 | } 75 | } 76 | 77 | static void 78 | tornode_free(struct TorNode *node) 79 | { 80 | if (node != NULL) 81 | { 82 | hash_del_tor(node); 83 | BlockHeapFree(tornode_heap, node); 84 | } 85 | } 86 | 87 | void 88 | tornode_clear() 89 | { 90 | struct TorNode *node; 91 | dlink_node *this = NULL, *next = NULL; 92 | 93 | DLINK_FOREACH_SAFE(this, next, tornode_list.head) 94 | { 95 | node = this->data; 96 | dlinkDelete(this, &tornode_list); 97 | tornode_free(node); 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /include/hash.h: -------------------------------------------------------------------------------- 1 | /* 2 | * hash.h: A header for the ircd hashtable code. 3 | * 4 | * Copyright (C) 2002 by the past and present ircd coders, and others. 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 | * USA 20 | * 21 | * $Id$ 22 | */ 23 | 24 | #ifndef INCLUDED_hash_h 25 | #define INCLUDED_hash_h 26 | 27 | #define FNV1_32_INIT 0x811c9dc5 28 | #define FNV1_32_BITS 16 29 | #define FNV1_32_SIZE (1 << FNV1_32_BITS) /* 2^16 = 65536 */ 30 | #define HASHSIZE FNV1_32_SIZE 31 | 32 | enum { 33 | HASH_TYPE_ID, 34 | HASH_TYPE_CLIENT, 35 | HASH_TYPE_CHANNEL, 36 | HASH_TYPE_SERVICE, 37 | HASH_TYPE_RESERVED 38 | }; 39 | 40 | struct Channel; 41 | struct Service; 42 | 43 | void init_hash(void); 44 | 45 | void hash_add_client(struct Client *); 46 | void hash_del_client(struct Client *); 47 | void hash_add_channel(struct Channel *); 48 | void hash_del_channel(struct Channel *); 49 | void hash_add_id(struct Client *); 50 | void hash_del_id(struct Client *); 51 | void hash_add_service(struct Service *); 52 | void hash_del_service(struct Service *); 53 | 54 | struct Client *hash_find_id(const char *); 55 | struct Client *find_client(const char *); 56 | struct Client *find_server(const char *); 57 | struct Service *find_service(const char *); 58 | struct Channel *hash_find_channel(const char *); 59 | void *hash_get_bucket(int, unsigned int); 60 | 61 | struct MessageQueue *hash_find_mqueue_host(struct MessageQueue **, 62 | const char *); 63 | void hash_add_mqueue(struct MessageQueue **, struct MessageQueue *); 64 | void hash_del_mqueue(struct MessageQueue **, struct MessageQueue *); 65 | struct MessageQueue **new_mqueue_hash(); 66 | 67 | struct TorNode *find_tor(const char *); 68 | void hash_add_tor(struct TorNode *); 69 | void hash_del_tor(struct TorNode *); 70 | 71 | unsigned int strhash(const char *); 72 | #endif /* INCLUDED_hash_h */ 73 | -------------------------------------------------------------------------------- /src/conf/mail.c: -------------------------------------------------------------------------------- 1 | /* 2 | * mail.c: Defines the mail{} block of services.conf. 3 | * 4 | * Copyright (C) 2005 by the Hybrid Development Team. 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 | * USA 20 | * 21 | * $Id: mail.c 372 2006-12-04 10:07:48Z stu $ 22 | */ 23 | 24 | #include "stdinc.h" 25 | #include "conf/conf.h" 26 | 27 | struct MailConf Mail = {0}; 28 | 29 | static dlink_node *hreset, *hverify; 30 | 31 | /* 32 | * reset_mail() 33 | * 34 | * Sets up default values before a rehash. 35 | * 36 | * inputs: none 37 | * output: none 38 | */ 39 | static void * 40 | reset_mail(va_list args) 41 | { 42 | return pass_callback(hreset); 43 | } 44 | 45 | /* 46 | * verify_mail() 47 | * 48 | * Checks if required settings are defined. 49 | * 50 | * inputs: none 51 | * output: none 52 | */ 53 | static void * 54 | verify_mail(va_list args) 55 | { 56 | if (EmptyString(Mail.command)) 57 | parse_fatal("command= field missing in mail{} section"); 58 | 59 | if (EmptyString(Mail.from_address)) 60 | parse_fatal("from_address= field missing in mail{} section"); 61 | 62 | return pass_callback(hverify); 63 | } 64 | 65 | /* 66 | * init_mail() 67 | * 68 | * Defines the mail{} conf section. 69 | * 70 | * inputs: none 71 | * output: none 72 | */ 73 | void 74 | init_mail(void) 75 | { 76 | struct ConfSection *s = add_conf_section("mail", 2); 77 | 78 | hreset = install_hook(reset_conf, reset_mail); 79 | hverify = install_hook(verify_conf, verify_mail); 80 | 81 | add_conf_field(s, "command", CT_STRING, NULL, &Mail.command); 82 | add_conf_field(s, "from_address", CT_STRING, NULL, &Mail.from_address); 83 | add_conf_field(s, "expire_time", CT_TIME, NULL, &Mail.expire_time); 84 | } 85 | 86 | void 87 | cleanup_mail() 88 | { 89 | struct ConfSection *s = find_conf_section("mail"); 90 | delete_conf_section(s); 91 | MyFree(s); 92 | MyFree(Mail.command); 93 | MyFree(Mail.from_address); 94 | } 95 | -------------------------------------------------------------------------------- /libio/string/pcre_tables.c: -------------------------------------------------------------------------------- 1 | /* $Id$ */ 2 | 3 | /************************************************* 4 | * Perl-Compatible Regular Expressions * 5 | *************************************************/ 6 | 7 | /* PCRE is a library of functions to support regular expressions whose syntax 8 | and semantics are as close as possible to those of the Perl 5 language. 9 | 10 | Written by Philip Hazel 11 | Copyright (c) 1997-2005 University of Cambridge 12 | 13 | ----------------------------------------------------------------------------- 14 | Redistribution and use in source and binary forms, with or without 15 | modification, are permitted provided that the following conditions are met: 16 | 17 | * Redistributions of source code must retain the above copyright notice, 18 | this list of conditions and the following disclaimer. 19 | 20 | * Redistributions in binary form must reproduce the above copyright 21 | notice, this list of conditions and the following disclaimer in the 22 | documentation and/or other materials provided with the distribution. 23 | 24 | * Neither the name of the University of Cambridge nor the names of its 25 | contributors may be used to endorse or promote products derived from 26 | this software without specific prior written permission. 27 | 28 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 29 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 30 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 31 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 32 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 33 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 34 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 35 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 36 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 37 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | POSSIBILITY OF SUCH DAMAGE. 39 | ----------------------------------------------------------------------------- 40 | */ 41 | 42 | 43 | /* This module contains some fixed tables that are used by more than one of the 44 | PCRE code modules. */ 45 | 46 | 47 | #include "pcre_internal.h" 48 | 49 | 50 | /* Table of sizes for the fixed-length opcodes. It's defined in a macro so that 51 | the definition is next to the definition of the opcodes in internal.h. */ 52 | 53 | const uschar _pcre_OP_lengths[] = { OP_LENGTHS }; 54 | 55 | /* End of pcre_tables.c */ 56 | -------------------------------------------------------------------------------- /src/python_module/python_module.c: -------------------------------------------------------------------------------- 1 | #include "Python.h" 2 | #include "stdinc.h" 3 | #include "conf/modules.h" 4 | #include "libpython_module.h" 5 | #include "interface.h" 6 | #include "hash.h" 7 | 8 | void 9 | init_python() 10 | { 11 | dlink_list *modpaths = get_modpaths(); 12 | dlink_node *ptr; 13 | PyObject *module; 14 | 15 | Py_Initialize(); 16 | 17 | PyRun_SimpleString("import sys"); 18 | 19 | DLINK_FOREACH(ptr, modpaths->head) 20 | { 21 | char str[PATH_MAX + 19 + 1]; /* path + "sys.path.append("")" */ 22 | snprintf(str, sizeof(str)-1, "sys.path.append(\"%s\")", (char*)ptr->data); 23 | PyRun_SimpleString(str); 24 | } 25 | 26 | module = init_python_servicemodule(); 27 | if(module == NULL) 28 | { 29 | PyErr_Print(); 30 | return; 31 | } 32 | 33 | init_python_client(module); 34 | } 35 | 36 | void 37 | cleanup_python() 38 | { 39 | Py_Finalize(); 40 | } 41 | 42 | int 43 | load_python_module(const char *name, const char *dir, const char *fname) 44 | { 45 | char path[PATH_MAX+1]; 46 | PyObject *pname, *module, *value, *args; 47 | Service *class; 48 | struct Service *service; 49 | 50 | snprintf(path, PATH_MAX, "%s/%s", dir, fname); 51 | 52 | ilog(L_DEBUG, "PYTHON INFO: Loading python module: %s", path); 53 | pname = PyString_FromString(name); 54 | 55 | module = PyImport_Import(pname); 56 | Py_DECREF(pname); 57 | 58 | chdir(DPATH); 59 | 60 | if(module == NULL) 61 | { 62 | ilog(L_CRIT, "PYTHON ERR: Error Loading python module %s", path); 63 | PyErr_Print(); 64 | return -1; 65 | } 66 | 67 | class = (Service *)PyObject_GetAttrString(module, (char*)name); 68 | if(class == NULL) 69 | { 70 | ilog(L_CRIT, "PYTHON ERR: Unable to find class named %s in module %s", 71 | name, path); 72 | PyErr_Print(); 73 | return -1; 74 | } 75 | 76 | service = make_service((char*)name); 77 | args = PyTuple_New(1); 78 | PyTuple_SetItem(args, 0, PyCObject_FromVoidPtr((void *)service, NULL)); 79 | value = PyObject_CallObject((PyObject*)class, args); 80 | if(value == NULL) 81 | { 82 | ilog(L_CRIT, "PYTHON ERR: Unable to call class %s in module %s", 83 | name, path); 84 | Py_DECREF(class); 85 | PyErr_Print(); 86 | return -1; 87 | } 88 | 89 | ilog(L_DEBUG, "PYTHON INFO: Python module %s loaded.", path); 90 | 91 | dlinkAdd(service, &service->node, &services_list); 92 | hash_add_service(service); 93 | 94 | service->data = value; 95 | return 1; 96 | } 97 | 98 | void 99 | unload_python_module(const char *name) 100 | { 101 | } 102 | -------------------------------------------------------------------------------- /include/hostmask.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). 3 | * hostmask.h: A header for the hostmask code. 4 | * 5 | * Copyright (C) 2005 by the past and present ircd coders, and others. 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 20 | * USA 21 | * 22 | * $Id$ 23 | */ 24 | 25 | #ifndef INCLUDE_hostmask_h 26 | #define INCLUDE_hostmask_h 27 | 28 | enum 29 | { 30 | HM_HOST, 31 | HM_IPV4, 32 | HM_IPV6 33 | }; 34 | 35 | struct HostMaskEntry 36 | { 37 | int type, subtype; 38 | unsigned long precedence; 39 | char *hostmask; 40 | void *data; 41 | struct HostMaskEntry *next, *nexthash; 42 | }; 43 | 44 | void clear_out_address_conf(void); 45 | void init_host_hash(void); 46 | 47 | EXTERN int match_ipv6(const struct irc_ssaddr *, const struct irc_ssaddr *, int); 48 | EXTERN int match_ipv4(const struct irc_ssaddr *, const struct irc_ssaddr *, int); 49 | EXTERN void mask_addr(struct irc_ssaddr *, int); 50 | EXTERN int parse_netmask(const char *, struct irc_ssaddr *, int *); 51 | 52 | /* Hashtable stuff... */ 53 | #define ATABLE_SIZE 0x1000 54 | 55 | EXTERN struct AddressRec *atable[ATABLE_SIZE]; 56 | 57 | struct AddressRec 58 | { 59 | /* masktype: HM_HOST, HM_IPV4, HM_IPV6 -A1kmm */ 60 | int masktype; 61 | 62 | union 63 | { 64 | struct 65 | { 66 | /* Pointer into AccessItem... -A1kmm */ 67 | struct irc_ssaddr addr; 68 | int bits; 69 | } ipa; 70 | 71 | /* Pointer into AccessItem... -A1kmm */ 72 | const char *hostname; 73 | } Mask; 74 | 75 | /* type: CONF_CLIENT, CONF_DLINE, CONF_KILL etc... -A1kmm */ 76 | int type; 77 | 78 | /* Higher precedences overrule lower ones... */ 79 | unsigned long precedence; 80 | 81 | /* Only checked if !(type & 1)... */ 82 | const char *username; 83 | struct AccessItem *aconf; 84 | 85 | /* The next record in this hash bucket. */ 86 | struct AddressRec *next; 87 | }; 88 | #endif /* INCLUDE_hostmask_h */ 89 | -------------------------------------------------------------------------------- /src/mqueue.c: -------------------------------------------------------------------------------- 1 | /* TODO: Add copyright */ 2 | 3 | #include "stdinc.h" 4 | #include "mqueue.h" 5 | #include "hash.h" 6 | 7 | static BlockHeap *mqueue_heap = NULL; 8 | static BlockHeap *fmsg_heap = NULL; 9 | 10 | void 11 | init_mqueue() 12 | { 13 | mqueue_heap = BlockHeapCreate("mqueue", sizeof(struct MessageQueue), MQUEUE_HEAP_SIZE); 14 | fmsg_heap = BlockHeapCreate("fmsg", sizeof(struct FloodMsg), FMSG_HEAP_SIZE); 15 | } 16 | 17 | void 18 | cleanup_mqueue() 19 | { 20 | BlockHeapDestroy(mqueue_heap); 21 | BlockHeapDestroy(fmsg_heap); 22 | } 23 | 24 | struct MessageQueue * 25 | mqueue_new(const char *name, unsigned int type, int max, int msg_time, 26 | int lne_time) 27 | { 28 | struct MessageQueue *queue = BlockHeapAlloc(mqueue_heap); 29 | 30 | DupString(queue->name, name); 31 | assert(queue->name != NULL); 32 | 33 | queue->max = max; 34 | queue->msg_enforce_time = msg_time; 35 | queue->lne_enforce_time = lne_time; 36 | queue->type = type; 37 | 38 | assert(queue->name != NULL); 39 | return queue; 40 | } 41 | 42 | void 43 | mqueue_hash_free(struct MessageQueue **hash, dlink_list *list) 44 | { 45 | dlink_node *ptr = NULL, *next_ptr = NULL; 46 | if(hash != NULL) 47 | { 48 | DLINK_FOREACH_SAFE(ptr, next_ptr, list->head) 49 | { 50 | struct MessageQueue *queue = ptr->data; 51 | if(queue->name == NULL) 52 | { 53 | ilog(L_DEBUG, "Trying to free already free'd MessageQueue"); 54 | abort(); 55 | } 56 | assert(queue->name != NULL); 57 | hash_del_mqueue(hash, queue); 58 | dlinkDelete(ptr, list); 59 | mqueue_free(queue); 60 | } 61 | MyFree(hash); 62 | } 63 | } 64 | 65 | void 66 | mqueue_free(struct MessageQueue *queue) 67 | { 68 | if(queue != NULL) 69 | { 70 | dlink_node *ptr = NULL, *nptr = NULL; 71 | 72 | MyFree(queue->name); 73 | queue->name = NULL; 74 | 75 | DLINK_FOREACH_SAFE(ptr, nptr, queue->entries.head) 76 | { 77 | struct FloodMsg *data = ptr->data; 78 | dlinkDelete(ptr, &queue->entries); 79 | floodmsg_free(data); 80 | } 81 | 82 | BlockHeapFree(mqueue_heap, queue); 83 | } 84 | } 85 | 86 | void 87 | floodmsg_free(struct FloodMsg *entry) 88 | { 89 | if(entry != NULL) 90 | { 91 | MyFree(entry->message); 92 | entry->message = NULL; 93 | BlockHeapFree(fmsg_heap, entry); 94 | entry = NULL; 95 | } 96 | } 97 | 98 | struct FloodMsg * 99 | floodmsg_new(const char *message) 100 | { 101 | struct FloodMsg *entry = BlockHeapAlloc(fmsg_heap); 102 | entry->time = CurrentTime; 103 | DupString(entry->message, message); 104 | return entry; 105 | } 106 | 107 | -------------------------------------------------------------------------------- /include/channel.h: -------------------------------------------------------------------------------- 1 | /* 2 | * oftc-ircservices: an extensible and flexible IRC Services package 3 | * channel.h - IRC channel information 4 | * 5 | * Copyright (C) 2006 Stuart Walsh and the OFTC Coding department 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 20 | * USA 21 | * 22 | * $Id$ 23 | */ 24 | 25 | #ifndef INCLUDED_channel_h 26 | #define INCLUDED_channel_h 27 | 28 | #include "dbchannel.h" 29 | 30 | struct Channel *make_channel(const char *); 31 | void init_channel(); 32 | void cleanup_channel(); 33 | void remove_ban(struct Ban *bptr, dlink_list *list); 34 | struct Membership *find_channel_link(struct Client *, struct Channel *); 35 | void add_user_to_channel(struct Channel *, struct Client *, unsigned int, int); 36 | void destroy_channel(struct Channel *); 37 | void remove_user_from_channel(struct Membership *); 38 | struct Ban *find_bmask(const struct Client *, const dlink_list *const); 39 | void set_channel_topic(struct Channel *, const char *,const char *, time_t); 40 | 41 | struct Channel 42 | { 43 | struct Channel *hnextch; 44 | 45 | dlink_node node; 46 | 47 | struct Mode mode; 48 | 49 | char *topic; 50 | char *topic_info; 51 | 52 | dlink_list members; 53 | dlink_list invites; 54 | dlink_list banlist; 55 | dlink_list exceptlist; 56 | dlink_list invexlist; 57 | dlink_list quietlist; 58 | 59 | time_t channelts; 60 | time_t limit_time; 61 | 62 | char chname[CHANNELLEN + 1]; 63 | 64 | DBChannel *regchan; 65 | }; 66 | 67 | struct Membership 68 | { 69 | dlink_node channode; /*!< link to chptr->members */ 70 | dlink_node usernode; /*!< link to source_p->channel */ 71 | struct Channel *chptr; /*!< Channel pointer */ 72 | struct Client *client_p; /*!< Client pointer */ 73 | unsigned int flags; /*!< user/channel flags, e.g. CHFL_CHANOP */ 74 | }; 75 | 76 | #define IsMember(who, chan) ((find_channel_link(who, chan)) ? 1 : 0) 77 | #define AddMemberFlag(x, y) ((x)->flags |= (y)) 78 | #define DelMemberFlag(x, y) ((x)->flags &= ~(y)) 79 | 80 | extern dlink_list global_channel_list; 81 | 82 | #endif /* INCLUDED_channel_h */ 83 | -------------------------------------------------------------------------------- /libio/string/LICENCE: -------------------------------------------------------------------------------- 1 | /* $Id$ */ 2 | 3 | PCRE LICENCE 4 | ------------ 5 | 6 | PCRE is a library of functions to support regular expressions whose syntax 7 | and semantics are as close as possible to those of the Perl 5 language. 8 | 9 | Release 6 of PCRE is distributed under the terms of the "BSD" licence, as 10 | specified below. The documentation for PCRE, supplied in the "doc" 11 | directory, is distributed under the same terms as the software itself. 12 | 13 | The basic library functions are written in C and are freestanding. Also 14 | included in the distribution is a set of C++ wrapper functions. 15 | 16 | 17 | THE BASIC LIBRARY FUNCTIONS 18 | --------------------------- 19 | 20 | Written by: Philip Hazel 21 | Email local part: ph10 22 | Email domain: cam.ac.uk 23 | 24 | University of Cambridge Computing Service, 25 | Cambridge, England. Phone: +44 1223 334714. 26 | 27 | Copyright (c) 1997-2005 University of Cambridge 28 | All rights reserved. 29 | 30 | 31 | THE C++ WRAPPER FUNCTIONS 32 | ------------------------- 33 | 34 | Contributed by: Google Inc. 35 | 36 | Copyright (c) 2005, Google Inc. 37 | All rights reserved. 38 | 39 | 40 | THE "BSD" LICENCE 41 | ----------------- 42 | 43 | Redistribution and use in source and binary forms, with or without 44 | modification, are permitted provided that the following conditions are met: 45 | 46 | * Redistributions of source code must retain the above copyright notice, 47 | this list of conditions and the following disclaimer. 48 | 49 | * Redistributions in binary form must reproduce the above copyright 50 | notice, this list of conditions and the following disclaimer in the 51 | documentation and/or other materials provided with the distribution. 52 | 53 | * Neither the name of the University of Cambridge nor the name of Google 54 | Inc. nor the names of their contributors may be used to endorse or 55 | promote products derived from this software without specific prior 56 | written permission. 57 | 58 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 59 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 60 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 61 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 62 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 63 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 64 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 65 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 66 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 67 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 68 | POSSIBILITY OF SUCH DAMAGE. 69 | 70 | End 71 | -------------------------------------------------------------------------------- /modules/JupeServ.rb: -------------------------------------------------------------------------------- 1 | class JupeServ < ServiceModule 2 | def initialize 3 | service_name("JupeServ") 4 | load_language("jupeserv.en") 5 | register([ 6 | ["HELP", 0, 2, SFLG_NOMAXPARAM, ADMIN_FLAG, lm('JS_HELP_SHORT'), lm('JS_HELP_LONG')], 7 | ["JUPE", 1, 2, SFLG_NOMAXPARAM, ADMIN_FLAG, lm('JS_HELP_JUPE_SHORT'), lm('JS_HELP_JUPE_LONG')], 8 | ["LIST", 0, 0, 0, ADMIN_FLAG, lm('JS_HELP_LIST_SHORT'), lm('JS_HELP_LIST_LONG')], 9 | ]) 10 | add_hook([ 11 | [QUIT_HOOK, 'squit'] 12 | ]) 13 | @jupes = Jupes.new 14 | end 15 | 16 | def squit(client, reason) 17 | log(LOG_DEBUG, "JupeServ SQUIT #{client.name} #{reason}") 18 | cjupe = @jupes.find(client.name) 19 | if cjupe != nil 20 | @jupes.remove(client.name) 21 | log(LOG_INFO, "Removed Jupiter on #{client.name}") 22 | end 23 | end 24 | 25 | def HELP(client, parv = []) 26 | do_help(client, parv[1], parv) 27 | end 28 | def JUPE(client, parv = []) 29 | reason = "" 30 | parv.shift #left over client name 31 | sname = parv.shift #server name 32 | 33 | if @jupes.find(sname) 34 | reply_user(client, "Server #{sname} already juped") 35 | return 36 | end 37 | 38 | if(parv.length < 1) 39 | server = introduce_server(sname, "Jupitered") 40 | else 41 | reason = parv.join(' ') 42 | server = introduce_server(sname, "Jupitered: #{reason}") 43 | end 44 | 45 | if server 46 | log(LOG_INFO, "Jupitered Server #{sname} #{reason}") 47 | @jupes.jupe(client, server, reason) 48 | reply_user(client, "Jupitered #{sname}") 49 | else 50 | log(LOG_INFO, "Failed to Jupiter #{sname}") 51 | end 52 | end 53 | 54 | def LIST(client, parv = []) 55 | if @jupes.size == 0 56 | reply_user(client, "No Jupe currently installed.") 57 | return 58 | end 59 | 60 | reply_user(client, "Currently #{@jupes.size} Jupes active:") 61 | @jupes.each do |jupe| 62 | reply_user(client, " - #{jupe.server.name} by #{jupe.client.name} on #{jupe.datetime}") 63 | end 64 | reply_user(client, "End of List.") 65 | end 66 | end 67 | 68 | class Jupe 69 | attr_accessor :server, :client, :datetime, :reason 70 | end 71 | 72 | class Jupes 73 | def initialize 74 | @jupes = Hash.new 75 | end 76 | def find(s) 77 | return @jupes[s] 78 | end 79 | 80 | def remove(s) 81 | @jupes.delete(s) 82 | end 83 | 84 | def jupe(c,s, r) 85 | jupe = Jupe.new 86 | jupe.server = s 87 | jupe.client = c 88 | jupe.datetime = Time.new 89 | jupe.reason = r 90 | @jupes[s.name] = jupe 91 | end 92 | 93 | def each 94 | @jupes.each do |k,v| 95 | yield v 96 | end 97 | end 98 | 99 | def size 100 | return @jupes.size 101 | end 102 | end 103 | 104 | -------------------------------------------------------------------------------- /include/group.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). 3 | * group.h group related header file 4 | * 5 | * Copyright (C) 2002 by the past and present ircd coders, and others. 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 20 | * USA 21 | * 22 | * $Id: msg.h 957 2007-05-07 16:52:26Z stu $ 23 | */ 24 | 25 | #ifndef INCLUDED_group_h 26 | #define INCLUDED_group_h 27 | 28 | typedef struct 29 | { 30 | dlink_node node; 31 | 32 | unsigned int id; 33 | char name[GROUPLEN+1]; 34 | char *desc; 35 | char *email; 36 | char *url; 37 | unsigned char priv; 38 | time_t reg_time; 39 | } Group; 40 | 41 | Group* group_find(const char *); 42 | int group_register(Group *, Nickname *); 43 | int group_delete(Group *); 44 | 45 | char *group_name_from_id(int); 46 | int group_id_from_name(const char *); 47 | 48 | int group_save(Group *); 49 | 50 | int group_link_list(unsigned int, dlink_list *); 51 | void group_link_list_free(dlink_list *); 52 | 53 | int group_chan_list(unsigned int, dlink_list *); 54 | void group_chan_list_free(dlink_list *); 55 | 56 | int group_masters_list(unsigned int, dlink_list *); 57 | void group_masters_list_free(dlink_list *); 58 | int group_masters_count(unsigned int, int *); 59 | 60 | int group_list_all(dlink_list *); 61 | void group_list_all_free(dlink_list *); 62 | 63 | int group_list_regular(dlink_list *); 64 | void group_list_regular_free(dlink_list *); 65 | 66 | Group *group_new(); 67 | void group_free(Group *); 68 | 69 | /* Group getters */ 70 | 71 | unsigned int group_get_id(Group *); 72 | const char *group_get_name(Group *); 73 | const char *group_get_email(Group *); 74 | const char *group_get_url(Group *); 75 | const char *group_get_desc(Group *); 76 | unsigned char group_get_priv(Group *); 77 | time_t group_get_regtime(Group *); 78 | 79 | /* Group setters */ 80 | int group_set_id(Group *, unsigned int); 81 | int group_set_name(Group *, const char *); 82 | int group_set_desc(Group *, const char *); 83 | int group_set_url(Group *, const char *); 84 | int group_set_email(Group *, const char *); 85 | int group_set_priv(Group *, unsigned char); 86 | int group_set_regime(Group *, time_t); 87 | #endif 88 | -------------------------------------------------------------------------------- /libio/comm/fileio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). 3 | * fileio.h: The file input/output header. 4 | * 5 | * Copyright (C) 2002 by the past and present ircd coders, and others. 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 20 | * USA 21 | * 22 | * $Id$ 23 | */ 24 | 25 | #ifndef INCLUDED_libio_comm_fileio_h 26 | #define INCLUDED_libio_comm_fileio_h 27 | 28 | #define FB_EOF 0x01 29 | #define FB_FAIL 0x02 30 | 31 | /* 32 | * FileBuf is a mirror of the ANSI FILE struct, but it works for any 33 | * file descriptor. FileBufs are allocated when a file is opened with 34 | * fbopen, and they are freed when the file is closed using fbclose. 35 | */ 36 | typedef struct FileBuf { 37 | fde_t F; /* file descriptor */ 38 | char *endp; /* one past the end */ 39 | char *ptr; /* current read pos */ 40 | char *pbptr; /* pointer to push back char */ 41 | int flags; /* file state */ 42 | char buf[BUFSIZ]; /* buffer */ 43 | char pbuf[BUFSIZ+1]; /* push back buffer */ 44 | } FBFILE; 45 | 46 | /* open a file and return a FBFILE*, see fopen(3) */ 47 | LIBIO_EXTERN FBFILE *fbopen(const char *, const char *); 48 | 49 | /* Positions the file pointer at the beginning of the file */ 50 | LIBIO_EXTERN int fbrewind(FBFILE *); 51 | 52 | /* close a file opened with fbopen, see fclose(3) */ 53 | LIBIO_EXTERN void fbclose(FBFILE *); 54 | 55 | /* 56 | * return the next character from the file, EOF on end of file 57 | * see fgetc(3) 58 | */ 59 | LIBIO_EXTERN int fbgetc(FBFILE *); 60 | 61 | /* 62 | * return next string in a file up to and including the newline character 63 | * see fgets(3) 64 | */ 65 | LIBIO_EXTERN char *fbgets(char *, size_t, FBFILE *); 66 | 67 | /* ungets c to fb see ungetc(3) */ 68 | LIBIO_EXTERN void fbungetc(char, FBFILE *); 69 | 70 | /* write a null terminated string to a file, see fputs(3) */ 71 | LIBIO_EXTERN int fbputs(const char *, FBFILE *, size_t); 72 | 73 | LIBIO_EXTERN int file_open(fde_t *, const char *, int, int); 74 | LIBIO_EXTERN void file_close(fde_t *); 75 | LIBIO_EXTERN int save_spare_fd(const char *); 76 | 77 | #endif /* INCLUDED_libio_comm_fileio_h */ 78 | -------------------------------------------------------------------------------- /include/parse.h: -------------------------------------------------------------------------------- 1 | /* TODO: add copyright block */ 2 | 3 | #ifndef INCLUDED_parse_h 4 | #define INCLUDED_parse_h 5 | 6 | struct MessageTree; 7 | struct ServiceMessageTree; 8 | struct ServiceMessage; 9 | struct Service; 10 | 11 | struct Message *find_command(const char *, struct MessageTree*); 12 | struct ServiceMessage *find_services_command(const char *cmd, struct ServiceMessageTree *msg_tree); 13 | void parse(struct Client *, char *, char *); 14 | extern void m_ignore(struct Client *, struct Client *, int, char *[]); 15 | extern void m_servignore(struct Service *, struct Client *, int, char *[]); 16 | extern void m_notid(struct Service *, struct Client *, int, char *[]); 17 | extern void m_alreadyreg(struct Service *, struct Client *, int, char *[]); 18 | extern void m_notadmin(struct Service *, struct Client *, int, char *[]); 19 | 20 | void mod_add_cmd(struct Message *); 21 | void mod_del_cmd(struct Message *); 22 | void mod_add_servcmd(struct ServiceMessageTree *, struct ServiceMessage *); 23 | void mod_del_servcmd(struct ServiceMessageTree *, struct ServiceMessage *); 24 | void process_privmsg(int, struct Client *, struct Client *, int, char *[]); 25 | void clear_tree_parse(struct MessageTree *); 26 | void clear_serv_tree_parse(struct ServiceMessageTree *); 27 | void init_parser(); 28 | void do_serv_help_messages(struct Service *service, struct Client *client); 29 | size_t join_params(char *target, int parc, char *parv[]); 30 | void serv_clear_messages(struct Service *service); 31 | 32 | void parse_reopen_log(); 33 | 34 | #define MAXPTRLEN 32 35 | /* Must be a power of 2, and 36 | * larger than 26 [a-z]|[A-Z] 37 | * its used to allocate the set 38 | * of pointers at each node of the tree 39 | * There are MAXPTRLEN pointers at each node. 40 | * Obviously, there have to be more pointers 41 | * Than ASCII letters. 32 is a nice number 42 | * since there is then no need to shift 43 | * 'A'/'a' to base 0 index, at the expense 44 | * of a few never used pointers. For a small 45 | * parser like this, this is a good compromise 46 | * and does make it somewhat faster. 47 | * 48 | * - Dianora 49 | */ 50 | 51 | struct MessageTree 52 | { 53 | int links; /* Count of all pointers (including msg) at this node 54 | * used as reference count for deletion of 55 | * _this_ node. 56 | * */ 57 | struct Message *msg; 58 | struct MessageTree *pointers[MAXPTRLEN]; 59 | }; 60 | 61 | struct ServiceMessageTree 62 | { 63 | int links; /* Count of all pointers (including msg) at this node 64 | * used as reference count for deletion of 65 | *_this_ node. 66 | */ 67 | struct ServiceMessage *msg; 68 | struct ServiceMessageTree *pointers[MAXPTRLEN]; 69 | }; 70 | 71 | 72 | #endif /* INCLUDED_parse_h */ 73 | -------------------------------------------------------------------------------- /libio/misc/misc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). 3 | * misc.h: A header for the miscellaneous functions. 4 | * 5 | * Copyright (C) 2002 by the past and present ircd coders, and others. 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 20 | * USA 21 | * 22 | * $Id$ 23 | */ 24 | 25 | #ifndef INCLUDED_libio_misc_misc_h 26 | #define INCLUDED_libio_misc_misc_h 27 | 28 | #define MAX_DATE_STRING 32 /* maximum string length for a date string */ 29 | 30 | #ifdef _WIN32 31 | #define _UTSNAME_LENGTH 65 32 | #define _UTSNAME_NODENAME_LENGTH _UTSNAME_LENGTH 33 | #define _UTSNAME_DOMAIN_LENGTH _UTSNAME_LENGTH 34 | 35 | struct utsname 36 | { 37 | char sysname[_UTSNAME_LENGTH]; 38 | char nodename[_UTSNAME_NODENAME_LENGTH]; 39 | char release[_UTSNAME_LENGTH]; 40 | char version[_UTSNAME_LENGTH]; 41 | char machine[_UTSNAME_LENGTH]; 42 | char domainname[_UTSNAME_DOMAIN_LENGTH]; 43 | }; 44 | 45 | LIBIO_EXTERN int uname(struct utsname *); 46 | #endif 47 | 48 | LIBIO_EXTERN struct timeval SystemTime; 49 | #define CurrentTime SystemTime.tv_sec 50 | 51 | LIBIO_EXTERN char *date(time_t); 52 | LIBIO_EXTERN char *small_file_date(time_t); 53 | LIBIO_EXTERN const char *smalldate(time_t); 54 | LIBIO_EXTERN void date_diff(time_t, time_t, struct tm *); 55 | #ifdef HAVE_LIBCRYPTO 56 | LIBIO_EXTERN char *ssl_get_cipher(SSL *); 57 | #endif 58 | LIBIO_EXTERN void set_time(void); 59 | LIBIO_EXTERN void libio_init(int); 60 | LIBIO_EXTERN void libio_cleanup(); 61 | LIBIO_EXTERN void setup_corefile(void); 62 | 63 | LIBIO_EXTERN char *servcrypt(const char *, const char *); 64 | 65 | #define LIBIO_MAX(a, b) ((a) > (b) ? (a) : (b)) 66 | #define LIBIO_MIN(a, b) ((a) < (b) ? (a) : (b)) 67 | 68 | #define _1MEG (1024.0) 69 | #define _1GIG (1024.0*1024.0) 70 | #define _1TER (1024.0*1024.0*1024.0) 71 | #define _GMKs(x) (((x) > _1TER) ? "Terabytes" : (((x) > _1GIG) ? "Gigabytes" :\ 72 | (((x) > _1MEG) ? "Megabytes" : "Kilobytes"))) 73 | #define _GMKv(x) (((x) > _1TER) ? (float)((x)/_1TER) : (((x) > _1GIG) ? \ 74 | (float)((x)/_1GIG) : (((x) > _1MEG) ? (float)((x)/_1MEG) : \ 75 | (float)(x)))) 76 | 77 | #endif /* INCLUDED_libio_misc_misc_h */ 78 | -------------------------------------------------------------------------------- /libio/comm/comm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). 3 | * comm.h: A header for the network subsystem. 4 | * 5 | * Copyright (C) 2002 by the past and present ircd coders, and others. 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 20 | * USA 21 | * 22 | * $Id$ 23 | */ 24 | 25 | #ifndef INCLUDED_libio_comm_comm_h 26 | #define INCLUDED_libio_comm_comm_h 27 | 28 | /* Type of IO */ 29 | #define COMM_SELECT_READ 1 30 | #define COMM_SELECT_WRITE 2 31 | 32 | /* How long can comm_select() wait for network events [milliseconds] */ 33 | #define SELECT_DELAY 500 34 | 35 | /* sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255.ipv6") */ 36 | #define HOSTIPLEN 53 37 | #define PORTNAMELEN 6 /* ":31337" */ 38 | 39 | #ifdef _WIN32 40 | #define EAFNOSUPPORT WSAEAFNOSUPPORT 41 | #define EALREADY WSAEALREADY 42 | #define EINPROGRESS WSAEINPROGRESS 43 | #define EISCONN WSAEISCONN 44 | #define EMSGSIZE WSAEMSGSIZE 45 | #define EWOULDBLOCK WSAEWOULDBLOCK 46 | #endif 47 | 48 | LIBIO_EXTERN struct Callback *setup_socket_cb; 49 | #ifdef _WIN32 50 | LIBIO_EXTERN void (* dispatch_wm_signal) (int); 51 | #endif 52 | 53 | LIBIO_EXTERN int get_sockerr(int); 54 | LIBIO_EXTERN int ignoreErrno(int); 55 | 56 | LIBIO_EXTERN void comm_settimeout(fde_t *, time_t, PF *, void *); 57 | LIBIO_EXTERN void comm_setflush(fde_t *, time_t, PF *, void *); 58 | LIBIO_EXTERN void comm_checktimeouts(void *); 59 | LIBIO_EXTERN void comm_connect_tcp(fde_t *, const char *, u_short, 60 | struct sockaddr *, int, CNCB *, void *, int, int); 61 | LIBIO_EXTERN const char *comm_errstr(int status); 62 | LIBIO_EXTERN int comm_open(fde_t *, int, int, int, const char *); 63 | LIBIO_EXTERN int comm_accept(fde_t *, struct irc_ssaddr *); 64 | 65 | /* These must be defined in the network IO loop code of your choice */ 66 | LIBIO_EXTERN void comm_setselect(fde_t *, unsigned int, PF *, void *, time_t); 67 | #ifdef IN_MISC_C 68 | extern void init_comm(void); 69 | extern void cleanup_comm(void); 70 | #endif 71 | LIBIO_EXTERN void comm_select(void); 72 | LIBIO_EXTERN int check_can_use_v6(void); 73 | #ifdef IPV6 74 | LIBIO_EXTERN void remove_ipv6_mapping(struct irc_ssaddr *); 75 | #endif 76 | 77 | #endif /* INCLUDED_libio_comm_comm_h */ 78 | -------------------------------------------------------------------------------- /src/kill.c: -------------------------------------------------------------------------------- 1 | /* 2 | * oftc-ircservices: an extensible and flexible IRC Services package 3 | * kill.c - functions for killing clients 4 | * 5 | * Copyright (C) 2012 Stuart Walsh and the OFTC Coding department 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 20 | * USA 21 | * 22 | */ 23 | 24 | #include "stdinc.h" 25 | #include "interface.h" 26 | #include "kill.h" 27 | #include "client.h" 28 | 29 | static dlink_list kill_list = { 0 }; 30 | 31 | static void 32 | check_kills(void *param) 33 | { 34 | dlink_node *ptr, *nptr; 35 | 36 | DLINK_FOREACH_SAFE(ptr, nptr, kill_list.head) 37 | { 38 | struct KillRequest *request = (struct KillRequest *)ptr->data; 39 | 40 | /* This will exit_one_client which calls kill_remove_client and frees 41 | associated ptrs */ 42 | send_kill(request->service, request->client, request->reason); 43 | } 44 | } 45 | 46 | void 47 | init_kill() 48 | { 49 | eventAdd("Check kills", check_kills, NULL, 1); 50 | } 51 | 52 | void 53 | kill_user(struct Service *service, struct Client *client, const char *reason) 54 | { 55 | struct KillRequest *request; 56 | 57 | if (client->kill_node == NULL) 58 | { 59 | request = MyMalloc(sizeof(struct KillRequest)); 60 | 61 | request->service = service; 62 | request->client = client; 63 | request->reason = reason; 64 | 65 | client->kill_node = make_dlink_node(); 66 | dlinkAdd(request, client->kill_node, &kill_list); 67 | } 68 | } 69 | 70 | void 71 | kill_remove_service(struct Service *service) 72 | { 73 | dlink_node *ptr, *nptr; 74 | 75 | DLINK_FOREACH_SAFE(ptr, nptr, kill_list.head) 76 | { 77 | struct KillRequest *request = (struct KillRequest *)ptr->data; 78 | 79 | if(request->service == service) 80 | { 81 | dlinkDelete(ptr, &kill_list); 82 | free_dlink_node(ptr); 83 | MyFree(request); 84 | } 85 | } 86 | } 87 | 88 | void 89 | kill_remove_client(struct Client *client) 90 | { 91 | if (client->kill_node != NULL) 92 | { 93 | dlink_node *ptr = client->kill_node; 94 | struct KillRequest *request = (struct KillRequest *)ptr->data; 95 | dlinkDelete(ptr, &kill_list); 96 | free_dlink_node(ptr); 97 | client->kill_node = NULL; 98 | MyFree(request); 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /include/servicemask.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). 3 | * 4 | * Copyright (C) 2002 by the past and present ircd coders, and others. 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 | * USA 20 | * 21 | */ 22 | 23 | #ifndef INCLUDED_servicemask_h 24 | #define INCLUDED_servicemask_h 25 | 26 | #include "stdinc.h" 27 | 28 | enum ServiceMaskType 29 | { 30 | AKICK_MASK = 0, 31 | AKILL_MASK, 32 | INVEX_MASK, 33 | EXCPT_MASK, 34 | QUIET_MASK, 35 | }; 36 | 37 | struct ServiceMask 38 | { 39 | unsigned int id; 40 | unsigned int type; 41 | unsigned int channel; 42 | unsigned int target; 43 | unsigned int setter; 44 | char *mask; 45 | char *reason; 46 | time_t time_set; 47 | time_t duration; 48 | }; 49 | 50 | void free_servicemask(struct ServiceMask *); 51 | 52 | int servicemask_add_akick_target(unsigned int, unsigned int, unsigned int, unsigned int, 53 | unsigned int, const char *); 54 | int servicemask_add_akick(const char *, unsigned int, unsigned int, unsigned int, 55 | unsigned int, const char *); 56 | int servicemask_add_invex(const char *, unsigned int, unsigned int, unsigned int, 57 | unsigned int, const char *); 58 | int servicemask_add_quiet(const char *, unsigned int, unsigned int, unsigned int, 59 | unsigned int, const char *); 60 | int servicemask_add_excpt(const char *, unsigned int, unsigned int, unsigned int, 61 | unsigned int, const char *); 62 | 63 | int servicemask_remove_akick_target(unsigned int, const char *); 64 | int servicemask_remove_akick(unsigned int, const char *); 65 | int servicemask_remove_invex(unsigned int, const char *); 66 | int servicemask_remove_quiet(unsigned int, const char *); 67 | int servicemask_remove_excpt(unsigned int, const char *); 68 | 69 | void servicemask_list_free(dlink_list *); 70 | int servicemask_list_akick(unsigned int, dlink_list *); 71 | int servicemask_list_invex(unsigned int, dlink_list *); 72 | int servicemask_list_excpt(unsigned int, dlink_list *); 73 | int servicemask_list_quiet(unsigned int, dlink_list *); 74 | 75 | void servicemask_list_masks_free(dlink_list *); 76 | int servicemask_list_akick_masks(unsigned int, dlink_list *); 77 | int servicemask_list_invex_masks(unsigned int, dlink_list *); 78 | int servicemask_list_excpt_masks(unsigned int, dlink_list *); 79 | int servicemask_list_quiet_masks(unsigned int, dlink_list *); 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /libio/misc/list.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). 3 | * list.h: A header for the code in list.c. 4 | * 5 | * Copyright (C) 2002 by the past and present ircd coders, and others. 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 20 | * USA 21 | * 22 | * $Id$ 23 | */ 24 | 25 | #ifndef INCLUDED_libio_misc_list_h 26 | #define INCLUDED_libio_misc_list_h 27 | 28 | /* 29 | * double-linked-list stuff 30 | */ 31 | typedef struct _dlink_node dlink_node; 32 | typedef struct _dlink_list dlink_list; 33 | 34 | #ifdef IN_MISC_C 35 | extern void init_dlink_nodes(void); 36 | extern void cleanup_dlink_nodes(void); 37 | #endif 38 | LIBIO_EXTERN void free_dlink_node(dlink_node *); 39 | LIBIO_EXTERN dlink_node *make_dlink_node(void); 40 | 41 | struct _dlink_node 42 | { 43 | void *data; 44 | dlink_node *prev; 45 | dlink_node *next; 46 | }; 47 | 48 | struct _dlink_list 49 | { 50 | dlink_node *head; 51 | dlink_node *tail; 52 | unsigned long length; 53 | }; 54 | 55 | LIBIO_EXTERN void dlinkAdd(void *, dlink_node *, dlink_list *); 56 | LIBIO_EXTERN void dlinkAddBefore(dlink_node *, void *, dlink_node *, dlink_list *); 57 | LIBIO_EXTERN void dlinkAddTail(void *, dlink_node *, dlink_list *); 58 | LIBIO_EXTERN void dlinkDelete(dlink_node *, dlink_list *); 59 | LIBIO_EXTERN void dlinkMoveList(dlink_list *, dlink_list *); 60 | LIBIO_EXTERN dlink_node *dlinkFind(dlink_list *, void *); 61 | LIBIO_EXTERN dlink_node *dlinkFindDelete(dlink_list *, void *); 62 | 63 | /* 64 | * These macros are basically swiped from the linux kernel 65 | * they are simple yet effective 66 | */ 67 | 68 | /* 69 | * Walks forward of a list. 70 | * pos is your node 71 | * head is your list head 72 | */ 73 | #define DLINK_FOREACH(pos, head) for (pos = (head); pos != NULL; pos = pos->next) 74 | 75 | /* 76 | * Walks forward of a list safely while removing nodes 77 | * pos is your node 78 | * n is another list head for temporary storage 79 | * head is your list head 80 | */ 81 | #define DLINK_FOREACH_SAFE(pos, n, head) for (pos = (head), n = pos ? pos->next : NULL; pos != NULL; pos = n, n = pos ? pos->next : NULL) 82 | #define DLINK_FOREACH_PREV(pos, head) for (pos = (head); pos != NULL; pos = pos->prev) 83 | 84 | /* Returns the list length */ 85 | #define dlink_list_length(list) (list)->length 86 | 87 | #endif /* INCLUDED_libio_misc_list_h */ 88 | -------------------------------------------------------------------------------- /src/ruby_module/libruby_module.h: -------------------------------------------------------------------------------- 1 | #ifndef INCLUDED_libruby_module_h 2 | #define INCLUDED_libruby_module_h 3 | 4 | /* Umm, it sucks but ruby defines these and so do we */ 5 | #undef PACKAGE_BUGREPORT 6 | #undef PACKAGE_NAME 7 | #undef PACKAGE_STRING 8 | #undef PACKAGE_TARNAME 9 | #undef PACKAGE_VERSION 10 | #undef EXTERN 11 | 12 | #include "stdinc.h" 13 | #include "ruby_module.h" 14 | #include "nickname.h" 15 | #include "chanserv.h" 16 | #include "nickserv.h" 17 | #include "channel_mode.h" 18 | #include "channel.h" 19 | #include "dbm.h" 20 | #include "language.h" 21 | #include "hash.h" 22 | #include "parse.h" 23 | #include "client.h" 24 | #include "interface.h" 25 | #include "msg.h" 26 | 27 | VALUE rb_carray2rbarray(int, char **); 28 | 29 | struct Service* get_service(VALUE); 30 | 31 | struct Client* value_to_client(VALUE); 32 | VALUE client_to_value(struct Client*); 33 | 34 | struct Channel* value_to_channel(VALUE); 35 | VALUE channel_to_value(struct Channel*); 36 | 37 | DBChannel* value_to_dbchannel(VALUE); 38 | VALUE dbchannel_to_value(DBChannel*); 39 | 40 | Nickname* value_to_nickname(VALUE); 41 | VALUE nickname_to_value(Nickname*); 42 | 43 | result_set_t* value_to_dbresult(VALUE); 44 | VALUE dbresult_to_value(result_set_t*); 45 | 46 | row_t* value_to_dbrow(VALUE); 47 | VALUE dbrow_to_value(row_t*); 48 | 49 | void Init_Channel(void); 50 | void Init_DBChannel(void); 51 | void Init_Client(void); 52 | void Init_Nickname(void); 53 | void Init_ServiceModule(void); 54 | 55 | void Init_DB(void); 56 | void Init_DBResult(void); 57 | void Init_DBRow(void); 58 | 59 | enum Ruby_Hooks 60 | { 61 | RB_HOOKS_CMODE, 62 | RB_HOOKS_UMODE, 63 | RB_HOOKS_NEWUSR, 64 | RB_HOOKS_PRIVMSG, 65 | RB_HOOKS_JOIN, 66 | RB_HOOKS_PART, 67 | RB_HOOKS_QUIT, 68 | RB_HOOKS_NICK, 69 | RB_HOOKS_NOTICE, 70 | RB_HOOKS_CHAN_CREATED, 71 | RB_HOOKS_CHAN_DELETED, 72 | RB_HOOKS_CTCP_REQUEST, 73 | RB_HOOKS_CTCP_REPLY, 74 | RB_HOOKS_NICK_REG, 75 | RB_HOOKS_CHAN_REG, 76 | RB_HOOKS_DB_INIT, 77 | RB_HOOKS_EOB, 78 | RB_HOOKS_COUNT 79 | }; 80 | 81 | #define RB_CALLBACK(x) (VALUE (*)())(x) 82 | 83 | VALUE rb_singleton_call(VALUE); 84 | 85 | void rb_do_hook_cb(VALUE, VALUE); 86 | void rb_add_hook(VALUE, VALUE, int); 87 | VALUE rb_add_event(VALUE, VALUE, VALUE, VALUE); 88 | VALUE rb_delete_event(VALUE, VALUE); 89 | 90 | int ruby_handle_error(int); 91 | VALUE do_ruby(VALUE, ID, int, ...); 92 | VALUE do_ruby_ret(VALUE, ID, int, ...); 93 | 94 | struct ruby_args 95 | { 96 | VALUE recv; 97 | ID id; 98 | int parc; 99 | VALUE *parv; 100 | }; 101 | 102 | struct rhook_args 103 | { 104 | int parc; 105 | VALUE *parv; 106 | }; 107 | 108 | void check_our_type(VALUE obj, VALUE type); 109 | 110 | extern VALUE cServiceModule; 111 | extern VALUE cNickname; 112 | extern VALUE cClient; 113 | extern VALUE cDBChannel; 114 | extern VALUE cChannel; 115 | 116 | extern VALUE cDB; 117 | extern VALUE cDBResult; 118 | extern VALUE cDBRow; 119 | 120 | #define Check_OurType(x, v) check_our_type((VALUE)(x), (VALUE)(v)) 121 | 122 | #endif /* INCLUDED_ruby_module_h */ 123 | -------------------------------------------------------------------------------- /src/conf/database.c: -------------------------------------------------------------------------------- 1 | /* 2 | * database.c: Defines the database{} block of services.conf. 3 | * 4 | * Copyright (C) 2005 by the Hybrid Development Team. 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 | * USA 20 | * 21 | * $Id$ 22 | */ 23 | 24 | #include "stdinc.h" 25 | #include "conf/conf.h" 26 | 27 | struct DatabaseConf Database = {0}; 28 | 29 | static dlink_node *hreset, *hverify; 30 | 31 | /* 32 | * reset_database() 33 | * 34 | * Sets up default values before a rehash. 35 | * 36 | * inputs: none 37 | * output: none 38 | */ 39 | static void * 40 | reset_database(va_list args) 41 | { 42 | return pass_callback(hreset); 43 | } 44 | 45 | /* 46 | * verify_database() 47 | * 48 | * Checks if required settings are defined. 49 | * 50 | * inputs: none 51 | * output: none 52 | */ 53 | static void * 54 | verify_database(va_list args) 55 | { 56 | if (EmptyString(Database.driver)) 57 | parse_fatal("driver= field missing in database{} section"); 58 | 59 | if (EmptyString(Database.dbname)) 60 | parse_fatal("dbname= field missing in database{} section"); 61 | 62 | if (EmptyString(Database.username)) 63 | parse_fatal("username= field missing in database{} section"); 64 | 65 | return pass_callback(hverify); 66 | } 67 | 68 | /* 69 | * init_database() 70 | * 71 | * Defines the serverhide{} conf section. 72 | * 73 | * inputs: none 74 | * output: none 75 | */ 76 | void 77 | init_database(void) 78 | { 79 | struct ConfSection *s = add_conf_section("database", 2); 80 | 81 | hreset = install_hook(reset_conf, reset_database); 82 | hverify = install_hook(verify_conf, verify_database); 83 | 84 | add_conf_field(s, "driver", CT_STRING, NULL, &Database.driver); 85 | add_conf_field(s, "dbname", CT_STRING, NULL, &Database.dbname); 86 | add_conf_field(s, "username", CT_STRING, NULL, &Database.username); 87 | add_conf_field(s, "password", CT_STRING, NULL, &Database.password); 88 | add_conf_field(s, "hostname", CT_STRING, NULL, &Database.hostname); 89 | add_conf_field(s, "port", CT_NUMBER, NULL, &Database.port); 90 | } 91 | 92 | void 93 | cleanup_database() 94 | { 95 | struct ConfSection *s = find_conf_section("database"); 96 | 97 | delete_conf_section(s); 98 | MyFree(s); 99 | MyFree(Database.driver); 100 | MyFree(Database.dbname); 101 | MyFree(Database.username); 102 | MyFree(Database.password); 103 | MyFree(Database.hostname); 104 | } 105 | -------------------------------------------------------------------------------- /src/conf/connect.c: -------------------------------------------------------------------------------- 1 | /* 2 | * connect.c: Defines the connect{} block of services.conf. 3 | * 4 | * Copyright (C) 2005 by the Hybrid Development Team. 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 | * USA 20 | * 21 | * $Id$ 22 | */ 23 | 24 | #include "stdinc.h" 25 | #include "conf/conf.h" 26 | 27 | struct ConnectConf Connect = {0}; 28 | 29 | static dlink_node *hreset, *hverify; 30 | 31 | /* 32 | * reset_connect() 33 | * 34 | * Sets up default values before a rehash. 35 | * 36 | * inputs: none 37 | * output: none 38 | */ 39 | static void * 40 | reset_connect(va_list args) 41 | { 42 | return pass_callback(hreset); 43 | } 44 | 45 | /* 46 | * verify_connect() 47 | * 48 | * Checks if required settings are defined. 49 | * 50 | * inputs: none 51 | * output: none 52 | */ 53 | static void * 54 | verify_connect(va_list args) 55 | { 56 | if (Connect.name == NULL) 57 | parse_fatal("name= field missing in connect{} section"); 58 | 59 | if (Connect.host == NULL) 60 | parse_fatal("host= field missing in connect{} section"); 61 | 62 | if(Connect.port == 0) 63 | parse_fatal("port= field missing in connect{} section"); 64 | 65 | if(Connect.protocol == NULL) 66 | parse_fatal("protocol= field missing in connect{} section"); 67 | 68 | if(Connect.password == NULL) 69 | parse_fatal("password= field missing in connect{} section"); 70 | 71 | return pass_callback(hverify); 72 | } 73 | 74 | /* 75 | * init_connect() 76 | * 77 | * Defines the serverhide{} conf section. 78 | * 79 | * inputs: none 80 | * output: none 81 | */ 82 | void 83 | init_connect(void) 84 | { 85 | struct ConfSection *s = add_conf_section("connect", 2); 86 | 87 | hreset = install_hook(reset_conf, reset_connect); 88 | hverify = install_hook(verify_conf, verify_connect); 89 | 90 | add_conf_field(s, "host", CT_STRING, NULL, &Connect.host); 91 | add_conf_field(s, "name", CT_STRING, NULL, &Connect.name); 92 | add_conf_field(s, "port", CT_NUMBER, NULL, &Connect.port); 93 | add_conf_field(s, "protocol", CT_STRING, NULL, &Connect.protocol); 94 | add_conf_field(s, "password", CT_STRING, NULL, &Connect.password); 95 | } 96 | 97 | void 98 | cleanup_connect() 99 | { 100 | struct ConfSection *s = find_conf_section("connect"); 101 | delete_conf_section(s); 102 | MyFree(s); 103 | MyFree(Connect.host); 104 | MyFree(Connect.name); 105 | MyFree(Connect.password); 106 | MyFree(Connect.protocol); 107 | } 108 | -------------------------------------------------------------------------------- /libio/mem/dbuf.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). 3 | * dbuf.c: Supports dynamic data buffers. 4 | * 5 | * Copyright (C) 2002 by the past and present ircd coders, and others. 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 20 | * USA 21 | * 22 | * $Id$ 23 | */ 24 | 25 | #include "libioinc.h" 26 | 27 | static BlockHeap *dbuf_heap; 28 | 29 | void 30 | dbuf_init(void) 31 | { 32 | dbuf_heap = BlockHeapCreate("dbuf", sizeof(struct dbuf_block), DBUF_HEAP_SIZE); 33 | } 34 | 35 | void 36 | dbuf_cleanup() 37 | { 38 | BlockHeapDestroy(dbuf_heap); 39 | } 40 | 41 | static struct dbuf_block * 42 | dbuf_alloc(struct dbuf_queue *qptr) 43 | { 44 | struct dbuf_block *block = BlockHeapAlloc(dbuf_heap); 45 | 46 | dlinkAddTail(block, make_dlink_node(), &qptr->blocks); 47 | return block; 48 | } 49 | 50 | void 51 | dbuf_put(struct dbuf_queue *qptr, char *data, size_t count) 52 | { 53 | struct dbuf_block *last; 54 | size_t amount; 55 | 56 | assert(count > 0); 57 | if (qptr->blocks.tail == NULL) 58 | dbuf_alloc(qptr); 59 | 60 | do { 61 | last = qptr->blocks.tail->data; 62 | 63 | amount = DBUF_BLOCK_SIZE - last->size; 64 | if (!amount) 65 | { 66 | last = dbuf_alloc(qptr); 67 | amount = DBUF_BLOCK_SIZE; 68 | } 69 | if (amount > count) 70 | amount = count; 71 | 72 | memcpy((void *) &last->data[last->size], data, amount); 73 | count -= amount; 74 | last->size += amount; 75 | qptr->total_size += amount; 76 | 77 | data += amount; 78 | 79 | } while (count > 0); 80 | } 81 | 82 | void 83 | dbuf_delete(struct dbuf_queue *qptr, size_t count) 84 | { 85 | dlink_node *ptr; 86 | struct dbuf_block *first; 87 | 88 | assert(qptr->total_size >= count); 89 | if (count == 0) 90 | return; 91 | 92 | /* free whole blocks first.. */ 93 | while (1) 94 | { 95 | if (!count) 96 | return; 97 | ptr = qptr->blocks.head; 98 | first = ptr->data; 99 | if (count < first->size) 100 | break; 101 | 102 | qptr->total_size -= first->size; 103 | count -= first->size; 104 | dlinkDelete(ptr, &qptr->blocks); 105 | free_dlink_node(ptr); 106 | BlockHeapFree(dbuf_heap, first); 107 | } 108 | 109 | /* ..then remove data from the beginning of the queue */ 110 | first->size -= count; 111 | qptr->total_size -= count; 112 | memmove((void *) &first->data, (void *) &first->data[count], first->size); 113 | } 114 | -------------------------------------------------------------------------------- /testcases/nickserv.test.plan: -------------------------------------------------------------------------------- 1 | NickServ Test Plan 2 | ------------------ 3 | 4 | REGISTER 5 | -------- 6 | 7 | HELP REGISTER -> Register help long version 8 | HELP REGISTER -> Too many params message 9 | REGISTER -> Not enough params message 10 | REGISTER -> Not enough params message 11 | REGISTER -> Invalid email address 12 | REGISTER -> Too many params 13 | REGISTER -> Invalid email address 14 | REGISTER -> Already registered 15 | REGISTER -> May not register 16 | REGISTER -> Cant register guest nick 17 | REGISTER -> Register success, umode +R set, account added to db, 18 | nickname added to db, primary_nick set to new nickname, user_id of nickname 19 | set to account, gnotice sent. 20 | SUDO REGISTER -> Nick doesnt exist 21 | SUDO REGISTER -> Already registered 22 | SUDO REGISTER -> May not be registered 23 | 24 | After registering INFO nick should show nick online message, time registered, 25 | last quick message and last quit time should be unknown, utl and cloakstring 26 | should be 'not set', email address should be whatever was specified language 27 | should be 0 and all settings should be OFF. 28 | 29 | IDENTIFY 30 | -------- 31 | 32 | HELP IDENTIFY -> Identify help long version 33 | HELP IDENTIFY -> Too many params 34 | IDENTIFY -> Not enough params 35 | IDENTIFY (when nick they are coming from is not registered) -> Nick not reg 36 | IDENTIFY -> Identify failed 37 | IDENTIFY -> Identify failed 38 | (if either of the previous two happen more than 5 times, kill the client) 39 | IDENTIFY -> Identify success, set +R, removed from enforce 40 | list 41 | IDENTIFY -> Identify success, 42 | set +R, removed from enforce list, user changed to master nickname specified 43 | IDENTIFY -> Identify success, 44 | set +R, removed from enforce list, user changed to linked nickname specified 45 | IDENTIFY -> Identify success, 46 | set +R, removed from enforce list, user using this nick guested, user changed 47 | to master nickname specified 48 | IDENTIFY -> Identify success, 49 | set +R, removed from enforce list, user using this nick guested, user changed 50 | to linked nickname specified 51 | IDENTIFY -> Identify 52 | success, set +R, removed from enforce list, enforcer exited, nick removed from 53 | enforce list, user changed to master nickname specified 54 | IDENTIFY -> Identify 55 | success, set +R, removed from enforce list, enforcer exited, nick removed from 56 | enforce list, user changed to linked nickname specified 57 | IDENTIFY -> Same as 58 | IDENTIFY 59 | IDENTIFY -> 60 | Same as IDENTIFY 61 | IDENTIFY -> Too many args 62 | -------------------------------------------------------------------------------- /include/conf/manager.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). 3 | * manager.h: A header for the configuration manager. 4 | * 5 | * Copyright (C) 2003 by Piotr Nizynski, Advanced IRC Services Project 6 | * Copyright (C) 2005 by the Hybrid Development Team. 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 21 | * USA 22 | * 23 | * $Id$ 24 | */ 25 | 26 | #ifndef INCLUDED_conf_manager_h 27 | #define INCLUDED_conf_manager_h 28 | 29 | #define CONF_BUFSIZE 512 30 | 31 | #define CT_NUMBER 0 32 | #define CT_BOOL 1 33 | #define CT_TIME 2 34 | #define CT_SIZE 3 35 | #define CT_STRING 4 36 | #define CT_LIST 5 37 | #define CT_NLIST 6 38 | 39 | typedef void CONFS_HANDLER(void); 40 | typedef void CONFF_HANDLER(void *, void *); 41 | 42 | struct ConfParserContext { 43 | FBFILE *f; 44 | char *filename; 45 | int lineno; 46 | }; 47 | 48 | struct ConfField { 49 | const char *name; 50 | int type; 51 | CONFF_HANDLER *handler; 52 | void *param; 53 | dlink_node node; 54 | }; 55 | 56 | struct ConfSection { 57 | const char *name; 58 | CONFS_HANDLER *before; 59 | CONFS_HANDLER *after; 60 | struct ConfField *def_field; 61 | int pass; 62 | dlink_list fields; 63 | dlink_node node; 64 | }; 65 | 66 | void init_conf(void); 67 | void cleanup_conf(void); 68 | void yyerror(const char *); 69 | int yylex(void); 70 | int conf_yy_input(char *, int); 71 | void conf_clear_ident_list(void); 72 | 73 | EXTERN int conf_pass, conf_cold; 74 | EXTERN struct ConfParserContext conf_curctx; 75 | EXTERN char conf_linebuf[]; 76 | EXTERN int conf_include_sptr; 77 | EXTERN struct Callback *reset_conf; 78 | EXTERN struct Callback *verify_conf; 79 | EXTERN struct Callback *switch_conf_pass; 80 | EXTERN struct Callback *on_config_loaded_cb; 81 | 82 | EXTERN void parse_error(const char *, ...); 83 | EXTERN void parse_fatal(const char *, ...); 84 | EXTERN struct ConfSection *find_conf_section(const char *); 85 | EXTERN struct ConfSection *add_conf_section(const char *, int); 86 | EXTERN void delete_conf_section(struct ConfSection *); 87 | EXTERN struct ConfField *find_conf_field(struct ConfSection *, char *); 88 | EXTERN void conf_assign(int, struct ConfField *, void *); 89 | EXTERN CONFF_HANDLER conf_assign_bool; 90 | EXTERN CONFF_HANDLER conf_assign_number; 91 | EXTERN CONFF_HANDLER conf_assign_string; 92 | EXTERN struct ConfField *add_conf_field(struct ConfSection *, const char *, 93 | int, CONFF_HANDLER *, void *); 94 | EXTERN void delete_conf_field(struct ConfSection *, struct ConfField *); 95 | 96 | #endif /* INCLUDED_conf_manager_h */ 97 | -------------------------------------------------------------------------------- /src/language.c: -------------------------------------------------------------------------------- 1 | /* 2 | * oftc-ircservices: an extensible and flexible IRC Services package 3 | * language.c: Language file functions 4 | * 5 | * Copyright (C) 2006 Stuart Walsh and the OFTC Coding department 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 20 | * USA 21 | * 22 | * $Id$ 23 | */ 24 | 25 | #include "stdinc.h" 26 | #include "language.h" 27 | 28 | void 29 | load_language(struct LanguageFile *language, const char *langfile) 30 | { 31 | FBFILE *file; 32 | char buffer[256]; 33 | char *s; 34 | int lang, i = 0; 35 | 36 | snprintf(buffer, sizeof(buffer), "%s/%s.lang", LANGPATH, langfile); 37 | 38 | if((file = fbopen(buffer, "r")) == NULL) 39 | { 40 | ilog(L_DEBUG, "Failed to open language file %s (%s)", langfile, buffer); 41 | return; 42 | } 43 | 44 | /* Read the first line which tells us which language this is */ 45 | fbgets(buffer, sizeof(buffer), file); 46 | if((s = strchr(buffer, ' ')) == NULL) 47 | { 48 | ilog(L_DEBUG, "Language file %s is invalid", langfile); 49 | return; 50 | } 51 | 52 | *s++ = '\0'; 53 | lang = atoi(buffer); 54 | 55 | if(s[strlen(s) - 1] == '\n') 56 | s[strlen(s) - 1] = '\0'; 57 | 58 | DupString(language[lang].name, s); 59 | 60 | ilog(L_DEBUG, "Loading language %d(%s)", lang, langfile); 61 | 62 | while(fbgets(buffer, sizeof(buffer), file) != NULL) 63 | { 64 | char *ptr; 65 | 66 | if(buffer[0] != '\t') 67 | { 68 | i++; 69 | continue; 70 | } 71 | 72 | s = buffer; 73 | s++; 74 | 75 | if(language[lang].entries[i] != NULL) 76 | { 77 | ptr = MyMalloc(strlen(language[lang].entries[i]) + strlen(s) + 2); 78 | sprintf(ptr, "%s\n%s", language[lang].entries[i], s); 79 | 80 | if(ptr[strlen(ptr)-1] == '\n') 81 | ptr[strlen(ptr)-1] = '\0'; 82 | 83 | MyFree(language[lang].entries[i]); 84 | } 85 | else 86 | { 87 | DupString(ptr, s); 88 | if(ptr[strlen(ptr)-1] == '\n') 89 | ptr[strlen(ptr)-1] = '\0'; 90 | } 91 | language[lang].entries[i] = ptr; 92 | } 93 | fbclose(file); 94 | } 95 | 96 | void 97 | unload_languages(struct LanguageFile *languages) 98 | { 99 | int i, j = 1; 100 | 101 | for(i = 0; i < LANG_LAST; i++) 102 | { 103 | ilog(L_DEBUG, "Unloading language %s", languages[i].name); 104 | if(languages[i].name == NULL) 105 | continue; 106 | 107 | MyFree(languages[i].name); 108 | while(languages[i].entries[j] != NULL) 109 | { 110 | MyFree(languages[i].entries[j]); 111 | j++; 112 | } 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /libio/string/pcre_globals.c: -------------------------------------------------------------------------------- 1 | /* $Id$ */ 2 | 3 | /************************************************* 4 | * Perl-Compatible Regular Expressions * 5 | *************************************************/ 6 | 7 | /* PCRE is a library of functions to support regular expressions whose syntax 8 | and semantics are as close as possible to those of the Perl 5 language. 9 | 10 | Written by Philip Hazel 11 | Copyright (c) 1997-2005 University of Cambridge 12 | 13 | ----------------------------------------------------------------------------- 14 | Redistribution and use in source and binary forms, with or without 15 | modification, are permitted provided that the following conditions are met: 16 | 17 | * Redistributions of source code must retain the above copyright notice, 18 | this list of conditions and the following disclaimer. 19 | 20 | * Redistributions in binary form must reproduce the above copyright 21 | notice, this list of conditions and the following disclaimer in the 22 | documentation and/or other materials provided with the distribution. 23 | 24 | * Neither the name of the University of Cambridge nor the names of its 25 | contributors may be used to endorse or promote products derived from 26 | this software without specific prior written permission. 27 | 28 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 29 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 30 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 31 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 32 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 33 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 34 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 35 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 36 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 37 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 38 | POSSIBILITY OF SUCH DAMAGE. 39 | ----------------------------------------------------------------------------- 40 | */ 41 | 42 | 43 | /* This module contains global variables that are exported by the PCRE library. 44 | PCRE is thread-clean and doesn't use any global variables in the normal sense. 45 | However, it calls memory allocation and freeing functions via the four 46 | indirections below, and it can optionally do callouts, using the fifth 47 | indirection. These values can be changed by the caller, but are shared between 48 | all threads. However, when compiling for Virtual Pascal, things are done 49 | differently, and global variables are not used (see pcre.in). */ 50 | 51 | 52 | #include "pcre_internal.h" 53 | 54 | 55 | #ifdef __cplusplus 56 | extern "C" void *(*pcre_malloc)(size_t) = malloc; 57 | extern "C" void (*pcre_free)(void *) = free; 58 | extern "C" void *(*pcre_stack_malloc)(size_t) = malloc; 59 | extern "C" void (*pcre_stack_free)(void *) = free; 60 | extern "C" int (*pcre_callout)(pcre_callout_block *) = NULL; 61 | #else 62 | void *(*pcre_malloc)(size_t) = malloc; 63 | void (*pcre_free)(void *) = free; 64 | void *(*pcre_stack_malloc)(size_t) = malloc; 65 | void (*pcre_stack_free)(void *) = free; 66 | int (*pcre_callout)(pcre_callout_block *) = NULL; 67 | #endif 68 | 69 | /* End of pcre_globals.c */ 70 | -------------------------------------------------------------------------------- /libio/net/irc_getaddrinfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the project nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * $Id$ 30 | */ 31 | 32 | #ifndef INCLUDED_libio_net_irc_getaddrinfo_h 33 | #define INCLUDED_libio_net_irc_getaddrinfo_h 34 | 35 | LIBIO_EXTERN int irc_getaddrinfo(const char *hostname, const char *servname, 36 | const struct addrinfo *hints, struct addrinfo **res); 37 | LIBIO_EXTERN void irc_freeaddrinfo(struct addrinfo *ai); 38 | 39 | #define SUCCESS 0 40 | #define ANY 0 41 | #define YES 1 42 | #define NO 0 43 | 44 | #undef EAI_ADDRFAMILY 45 | #undef EAI_AGAIN 46 | #undef EAI_BADFLAGS 47 | #undef EAI_FAIL 48 | #undef EAI_FAMILY 49 | #undef EAI_MEMORY 50 | #undef EAI_NODATA 51 | #undef EAI_NONAME 52 | #undef EAI_SERVICE 53 | #undef EAI_SOCKTYPE 54 | #undef EAI_SYSTEM 55 | #undef EAI_BADHINTS 56 | #undef EAI_PROTOCOL 57 | #undef EAI_MAX 58 | #undef AI_MASK 59 | 60 | #define EAI_ADDRFAMILY 1 /* address family for hostname not supported */ 61 | #define EAI_AGAIN 2 /* temporary failure in name resolution */ 62 | #define EAI_BADFLAGS 3 /* invalid value for ai_flags */ 63 | #define EAI_FAIL 4 /* non-recoverable failure in name resolution */ 64 | #define EAI_FAMILY 5 /* ai_family not supported */ 65 | #define EAI_MEMORY 6 /* memory allocation failure */ 66 | #define EAI_NODATA 7 /* no address associated with hostname */ 67 | #define EAI_NONAME 8 /* hostname nor servname provided, or not known */ 68 | #define EAI_SERVICE 9 /* servname not supported for ai_socktype */ 69 | #define EAI_SOCKTYPE 10 /* ai_socktype not supported */ 70 | #define EAI_SYSTEM 11 /* system error returned in errno */ 71 | #define EAI_BADHINTS 12 72 | #define EAI_PROTOCOL 13 73 | #define EAI_MAX 14 74 | #define AI_MASK (AI_PASSIVE | AI_NUMERICHOST) 75 | 76 | #endif /* INCLUDED_libio_net_irc_getaddrinfo_h */ 77 | -------------------------------------------------------------------------------- /src/event.c: -------------------------------------------------------------------------------- 1 | /* 2 | * oftc-ircservices: an extensible and flexible IRC Services package 3 | * events.c: event processing 4 | * 5 | * Copyright (C) 2010 Stuart Walsh and the OFTC Coding department 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 20 | * USA 21 | * 22 | * $Id: services.c 1442 2008-04-13 20:28:24Z swalsh $ 23 | */ 24 | 25 | #include "stdinc.h" 26 | #include "conf.h" 27 | #include "conf/conf.h" 28 | #include 29 | #include 30 | #include 31 | 32 | struct event_base *ev_base = NULL; 33 | 34 | /*static void 35 | sigint_callback(int signal, short event, void *arg) 36 | { 37 | // struct event *sigint = (struct event *)arg; 38 | 39 | exit(EXIT_SUCCESS); 40 | }*/ 41 | 42 | static void 43 | timer_callback(int fd, short event, void *arg) 44 | { 45 | } 46 | 47 | static void 48 | libevent_log_cb(int severity, const char *msg) 49 | { 50 | ilog(L_DEBUG, "{libevent} %d: %s", severity, msg); 51 | } 52 | 53 | int 54 | init_events() 55 | { 56 | struct timeval tv; 57 | struct event *timer = MyMalloc(sizeof(struct event)); 58 | // struct event *sigint = MyMalloc(sizeof(struct event)); 59 | 60 | ev_base = event_init(); 61 | 62 | event_set_log_callback(&libevent_log_cb); 63 | 64 | if(evdns_init() == -1) 65 | { 66 | ilog(L_ERROR, "libevent dns init failed"); 67 | return FALSE; 68 | } 69 | 70 | ilog(L_DEBUG, "libevent init %p", ev_base); 71 | 72 | memset(&tv, 0, sizeof(tv)); 73 | 74 | tv.tv_usec = 100; 75 | event_set(timer, -1, EV_PERSIST, timer_callback, timer); 76 | event_base_set(ev_base, timer); 77 | evtimer_add(timer, &tv); 78 | 79 | /* event_set(sigint, SIGINT, EV_SIGNAL|EV_PERSIST, sigint_callback, sigint); 80 | event_add(sigint, NULL);*/ 81 | 82 | return TRUE; 83 | } 84 | 85 | int 86 | events_loop() 87 | { 88 | //ilog(L_DEBUG, "ev_base %p", ev_base); 89 | return event_base_loop(ev_base, EVLOOP_NONBLOCK); 90 | } 91 | 92 | struct event * 93 | events_setup(int fd, short events, void(*cb)(int, short, void *), void *arg) 94 | { 95 | struct event *ev; 96 | 97 | ilog(L_DEBUG, "Adding event for %d (%d %p %p)", fd, events, cb, arg); 98 | ev = MyMalloc(sizeof(struct event)); 99 | if(ev == NULL) 100 | return NULL; 101 | 102 | event_set(ev, fd, events, cb, arg); 103 | event_base_set(ev_base, ev); 104 | 105 | return ev; 106 | } 107 | 108 | struct event * 109 | events_add(int fd, short events, void(*cb)(int, short, void *), void *arg) 110 | { 111 | struct event *ev; 112 | 113 | ev = events_setup(fd, events, cb, arg); 114 | if(ev == NULL) 115 | return NULL; 116 | 117 | event_add(ev, NULL); 118 | return ev; 119 | } 120 | 121 | -------------------------------------------------------------------------------- /sql/chanserv-pgsql.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE IF EXISTS channel CASCADE; 2 | CREATE TABLE channel( 3 | id SERIAL PRIMARY KEY, 4 | channel VARCHAR(255) NOT NULL, 5 | flag_private BOOLEAN NOT NULL DEFAULT 'False', -- do not show up in list of channels 6 | flag_restricted BOOLEAN NOT NULL DEFAULT 'False', -- only people on the access list can hold channel operator status 7 | flag_topic_lock BOOLEAN NOT NULL DEFAULT 'False', -- topics can only be changed via chanserv 8 | flag_verbose BOOLEAN NOT NULL DEFAULT 'False', -- notice all chanserv actions to the channel 9 | flag_autolimit BOOLEAN NOT NULL DEFAULT 'False', -- sets limit just above the current user count 10 | flag_expirebans BOOLEAN NOT NULL DEFAULT 'False', -- Expire old bans 11 | flag_floodserv BOOLEAN NOT NULL DEFAULT 'False', -- floodserv should monitor channel 12 | flag_autoop BOOLEAN NOT NULL DEFAULT 'False', -- CHANOP or above get op on join 13 | flag_autovoice BOOLEAN NOT NULL DEFAULT 'False', -- MEMBER or above get voice on join 14 | flag_leaveops BOOLEAN NOT NULL DEFAULT 'False', -- Don't deop people who get chanop but shouldnt 15 | flag_autosave BOOLEAN NOT NULL DEFAULT 'False', -- Manually issued CMODEs are persisted in the DB 16 | description VARCHAR(512) NOT NULL, 17 | url VARCHAR(255), 18 | email VARCHAR(255), 19 | entrymsg VARCHAR(512), 20 | topic VARCHAR(512), 21 | mlock VARCHAR(255), 22 | expirebans_lifetime INTEGER NOT NULL DEFAULT 300, 23 | reg_time INTEGER NOT NULL, 24 | last_used INTEGER NOT NULL 25 | ); 26 | CREATE UNIQUE INDEX channel_channel_idx ON channel (irc_lower(channel)); 27 | 28 | DROP TABLE IF EXISTS channel_access; 29 | CREATE TABLE channel_access( 30 | id SERIAL PRIMARY KEY, 31 | channel_id INTEGER NOT NULL REFERENCES channel(id) ON DELETE CASCADE, 32 | account_id INTEGER REFERENCES account(id), 33 | group_id INTEGER REFERENCES "group"(id), 34 | level INTEGER NOT NULL, 35 | UNIQUE (channel_id, account_id) 36 | ); 37 | CREATE INDEX channel_access_account_id_idx ON channel_access (account_id); 38 | 39 | DROP TABLE IF EXISTS channel_akick; 40 | CREATE TABLE channel_akick( 41 | id SERIAL PRIMARY KEY, 42 | channel_id INTEGER NOT NULL REFERENCES channel(id) ON DELETE CASCADE, 43 | setter INTEGER REFERENCES account(id) ON DELETE SET NULL, 44 | target INTEGER REFERENCES account(id) ON DELETE CASCADE, -- If a nickname akick 45 | mask VARCHAR(255), -- If a mask akick 46 | reason VARCHAR(512) NOT NULL, 47 | time INTEGER NOT NULL, 48 | duration INTEGER NOT NULL, 49 | chmode INTEGER NOT NULL DEFAULT 0 50 | CHECK (((target IS NULL) OR (mask IS NULL)) AND NOT ((target IS NULL) AND 51 | (mask IS NULL))) 52 | ); 53 | 54 | DROP TABLE IF EXISTS forbidden_channel; 55 | CREATE TABLE forbidden_channel ( 56 | channel VARCHAR(255) PRIMARY KEY 57 | ); 58 | -- this is not so much for performance as for unique constraint reasons: 59 | CREATE UNIQUE INDEX forbidden_channel_channel_idx ON forbidden_channel (irc_lower(channel)); 60 | CREATE UNIQUE INDEX channel_akick_mode_mask_idx ON channel_akick(channel_id, chmode, mask); 61 | CREATE UNIQUE INDEX channel_akick_mode_target_idx ON channel_akick(channel_id, chmode, target); 62 | -------------------------------------------------------------------------------- /configure.ac: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2006 Luca Filipozzi 2 | # vim: set fdm=marker ts=2 sw=2 et: 3 | 4 | AC_PREREQ(2.59) 5 | AC_INIT([oftc-ircservices],[1.5.12]) 6 | AM_INIT_AUTOMAKE 7 | AC_CONFIG_HEADERS([config.h]) 8 | AM_MAINTAINER_MODE 9 | AM_PROG_CC_C_O 10 | 11 | #ltdl stuff 12 | AC_LIBTOOL_DLOPEN 13 | AC_LIBLTDL_CONVENIENCE 14 | AC_SUBST(LTDLINCL) 15 | AC_SUBST(LIBLTDL) 16 | 17 | # Checks for programs. 18 | AC_PROG_INSTALL 19 | AC_GNU_SOURCE 20 | AC_PROG_RANLIB 21 | AC_PROG_LIBTOOL 22 | LIBTOOL="$LIBTOOL --silent" 23 | AM_PROG_LEX 24 | AC_PROG_YACC 25 | AC_PROG_AWK 26 | AC_PROG_EGREP 27 | AC_PATH_PROG([TAIL],[tail]) 28 | 29 | # Checks for libraries. 30 | AX_CHECK_LIB_RUBY 31 | AX_CHECK_LIB_PYTHON 32 | AX_CHECK_LIB_OPENSSL 33 | AX_CHECK_LIB_PGSQL(8.3) 34 | AX_CHECK_LIB_IPV4 35 | AX_CHECK_LIB_IPV6 36 | AX_CHECK_LIB_EVENT 37 | 38 | # Checks for header files. 39 | AC_CHECK_HEADERS([sys/resource.h]) # ick 40 | 41 | # Checks for typedefs, structures, and compiler characteristics. 42 | AC_C_CONST 43 | AC_C_INLINE 44 | AC_C_VOLATILE 45 | AC_C_BIGENDIAN 46 | 47 | # Checks for library functions. 48 | AC_CHECK_FUNC([snprintf],[AC_DEFINE([HAVE_SNPRINTF],[1],[Define to 1 if you have the snprintf() function.])]) 49 | AC_CHECK_FUNC([vsnprintf],[AC_DEFINE([HAVE_VSNPRINTF],[1],[Define to 1 if you have the vsnprintf() function.])]) 50 | AC_CHECK_FUNC([lrand48],[AC_DEFINE([HAVE_LRAND48],[1],[Define to 1 if you have the lrand48() function.])]) 51 | AC_CHECK_FUNC([srand48],[AC_DEFINE([HAVE_LRAND48],[1],[Define to 1 if you have the srand48() function.])]) 52 | AC_CHECK_FUNC([mmap],[AC_DEFINE([HAVE_MMAP],[1],[Define to 1 if you have the mmap() function.])]) 53 | AC_CHECK_FUNC([strtok_r],[AC_DEFINE([HAVE_STRTOK_R],[1],[Define to 1 if you have the strtok_r() function.])]) 54 | AC_CHECK_FUNC([usleep],[AC_DEFINE([HAVE_USLEEP],[1],[Define to 1 if you have the usleep() function.])]) 55 | AC_CHECK_FUNC([strlcat],[AC_DEFINE([HAVE_STRLCAT],[1],[Define to 1 if you have the strlcat() function.])]) 56 | AC_CHECK_FUNC([strlcpy],[AC_DEFINE([HAVE_STRLCPY],[1],[Define to 1 if you have the strlcpy() function.])]) 57 | 58 | # Argument processing. 59 | AX_ARG_ENABLE_IOLOOP_MECHANISM 60 | AX_ARG_DISABLE_BLOCK_ALLOC 61 | AX_ARG_DISABLE_SHARED_MODULES 62 | AX_ARG_WITH_NICKLEN 63 | AX_ARG_WITH_USERLEN 64 | AX_ARG_WITH_HOSTLEN 65 | AX_ARG_WITH_TOPICLEN 66 | AX_ARG_WITH_CLIENT_HEAP_SIZE 67 | AX_ARG_WITH_CHANNEL_HEAP_SIZE 68 | AX_ARG_WITH_DBUF_HEAP_SIZE 69 | AX_ARG_WITH_DNODE_HEAP_SIZE 70 | AX_ARG_WITH_BAN_HEAP_SIZE 71 | AX_ARG_WITH_TOPIC_HEAP_SIZE 72 | AX_ARG_WITH_SERVICES_HEAP_SIZE 73 | AX_ARG_WITH_MQUEUE_HEAP_SIZE 74 | AX_ARG_WITH_FMSG_HEAP_SIZE 75 | AX_ARG_WITH_TORNODE_HEAP_SIZE 76 | AX_ARG_WITH_SYSLOG 77 | AX_ARG_ENABLE_HALFOPS 78 | AX_ARG_ENABLE_DEBUGGING 79 | AX_ARG_ENABLE_WARNINGS 80 | AX_ARG_ENABLE_EFENCE 81 | AX_ARG_ENABLE_SYSLOG 82 | 83 | AC_DEFINE_DIR([PREFIX],[prefix],[Set to prefix.]) 84 | AC_DEFINE_DIR([SYSCONFDIR],[sysconfdir],[Set to sysconfdir.]) 85 | AC_DEFINE_DIR([LIBDIR],[libdir],[Set to libdir.]) 86 | AC_DEFINE_DIR([DATADIR],[datadir],[Set to datadir.]) 87 | AC_DEFINE_DIR([LOCALSTATEDIR],[localstatedir],[Set to localstatedir.]) 88 | AC_DEFINE([SHARED_SUFFIX],[".so"],[Suffix for shared libraries on this platform.]) # wtf is this needed? replace libdl with libltdl to correct 89 | AC_CONFIG_FILES([Makefile libio/Makefile libio/comm/Makefile libio/mem/Makefile libio/misc/Makefile libio/net/Makefile libio/string/Makefile etc/Makefile modules/Makefile src/Makefile src/conf/Makefile src/ruby_module/Makefile src/python_module/Makefile languages/Makefile include/Makefile include/conf/Makefile sql/Makefile]) 90 | AC_CONFIG_SUBDIRS(libltdl) 91 | AC_OUTPUT 92 | -------------------------------------------------------------------------------- /src/conf/service.c: -------------------------------------------------------------------------------- 1 | /* 2 | * service.c: Defines the service{} block of services.conf. 3 | * 4 | * Copyright (C) 2005 by the Hybrid Development Team. 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 19 | * USA 20 | * 21 | * $Id: /local/oftc-ircservices/branches/ootest/src/conf/connect.cc 1630 2006-12-28T00:33:26.643840Z stu $ 22 | */ 23 | 24 | #include "stdinc.h" 25 | #include "conf/conf.h" 26 | #include "conf/service.h" 27 | #include "conf/manager.h" 28 | 29 | static struct ServiceConf tmpservice = {0}; 30 | dlink_list service_confs = {0}; 31 | static dlink_node *hreset; 32 | 33 | /* 34 | * reset_service() 35 | * 36 | * Sets up default values before a rehash. 37 | * 38 | * inputs: none 39 | * output: none 40 | */ 41 | static void * 42 | reset_service() 43 | { 44 | while(service_confs.head) 45 | { 46 | struct ServiceConf *conf = service_confs.head->data; 47 | dlinkDelete(&conf->node, &service_confs); 48 | } 49 | 50 | return pass_callback(hreset); 51 | } 52 | 53 | static void 54 | before_service() 55 | { 56 | MyFree(tmpservice.name); 57 | MyFree(tmpservice.module); 58 | 59 | memset(&tmpservice, 0, sizeof(tmpservice)); 60 | } 61 | 62 | static void 63 | after_service() 64 | { 65 | struct ServiceConf *service; 66 | 67 | if(tmpservice.name == NULL) 68 | parse_fatal("name= field missing in service{} section"); 69 | 70 | if(tmpservice.module == NULL) 71 | parse_fatal("module= field missing in service{} section"); 72 | 73 | service = (struct ServiceConf *)MyMalloc(sizeof(struct ServiceConf)); 74 | DupString(service->name, tmpservice.name); 75 | DupString(service->module, tmpservice.module); 76 | MyFree(tmpservice.name); 77 | MyFree(tmpservice.module); 78 | tmpservice.name = tmpservice.module = NULL; 79 | dlinkAdd(service, &service->node, &service_confs); 80 | } 81 | 82 | /* 83 | * init_service() 84 | * 85 | * Defines the serverhide{} conf section. 86 | * 87 | * inputs: none 88 | * output: none 89 | */ 90 | void 91 | init_service(void) 92 | { 93 | struct ConfSection *s = add_conf_section("service", 1); 94 | 95 | hreset = install_hook(reset_conf, reset_service); 96 | s->before = before_service; 97 | 98 | add_conf_field(s, "name", CT_STRING, NULL, &tmpservice.name); 99 | add_conf_field(s, "module", CT_STRING, NULL, &tmpservice.module); 100 | 101 | s->after = after_service; 102 | } 103 | 104 | void 105 | cleanup_service() 106 | { 107 | dlink_node *ptr, *nptr; 108 | struct ConfSection *s = find_conf_section("service"); 109 | 110 | DLINK_FOREACH_SAFE(ptr, nptr, service_confs.head) 111 | { 112 | struct ServiceConf *service = (struct ServiceConf *)ptr->data; 113 | 114 | MyFree(service->name); 115 | MyFree(service->module); 116 | dlinkDelete(ptr, &service_confs); 117 | MyFree(service); 118 | } 119 | 120 | delete_conf_section(s); 121 | MyFree(s); 122 | } 123 | -------------------------------------------------------------------------------- /etc/bopm.sample.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | # 3 | # kill_score: (int) [required] 4 | # If a connection is greater than or equal to this number they will be killed 5 | kill_score: 2 6 | # 7 | # kill_reason: (string) [required] 8 | # The message set for kill for connections that reach the killscore 9 | kill_reason: This host may be infected. 10 | # 11 | # kill_duration: (int) [required] 12 | # The number of seconds a kill will last for 13 | kill_duration: 1209600 14 | # 15 | # store_kill_directly: (bool) [required] 16 | # Set this to Yes if Bopm is part of the core services, false if it's separate 17 | store_kill_directly: False 18 | # 19 | # kill_command: (string) [optional] 20 | # If you're not storing kills directly this is the raw irc command that will 21 | # be sent. 22 | # Arguments that may be expanded 23 | # $HOSTNAME$ $REASON$ $DURATION$ $SCORE$ $CLOAK$ 24 | kill_command: "PRIVMSG OperServ :AKILL ADD +$DURATION$ *@$HOSTNAME$ $REASON$ ($SCORE$)" 25 | # dnsbl_max_requests: (int) [optional] 26 | # Number of maximum users to check at any given time 27 | dnsbl_max_requests: 100 28 | # recloak_users: (bool) [required] 29 | # Users with existing cloaks, or the same cloak will have their cloaks reset 30 | recloak_users: False 31 | # dnsbl_request_timeout: (int) [optional] 32 | # How long in seconds before an entire request is aborted, that is all results 33 | # after this time will be ignored 34 | dnsbl_request_timeout: 300 35 | # exempt_hosts: (list) [optional] 36 | # Users whose hostname ends with one of the following will not be recloaked 37 | # unless recloak_users is True 38 | exempt_hosts: 39 | - example.com 40 | # default_tor_cloak: (string) [optional] 41 | # If the client matches the tor list, don't perform dnsbl and apply this cloak 42 | default_tor_cloak: "tor-irc.dnsbl.example.com" 43 | # 44 | # List of DNSBLs to check against 45 | dnsbls: 46 | # The outer portion is a list of hashes 47 | # 48 | # name: (string) [required] 49 | # The actual dns name of the bl you're checking 50 | - name: sample.dnsbl.example.com 51 | # 52 | # shortname: (string) [required] 53 | # The name that will be displayed in the snotes regarding scores 54 | shortname: smpl 55 | # 56 | # cloak: (string) [required] 57 | # if a client is found in this block it will receive this cloak (required) 58 | cloak: sample.mynetwork.net 59 | # 60 | # withid: (bool) [optional] 61 | # if a client is found in this block it will receive the cloak with their tsid 62 | # appended at the beginning (i.e. 1ZZAAAAAA.sample.mynetwork.net) 63 | withid: Yes 64 | # 65 | # hexip: (bool) [optional] 66 | # if a client is found in this block it will append the hexencoded ip to the 67 | # defined cloak (5bc6e331.cloak.example.com) 68 | hexip: Yes 69 | # 70 | # score: (integer) [optional] 71 | # a positive or negative value, applied to a result if a specific result if no 72 | # score is defined for the result, or the result is not found in the list of 73 | # codes 74 | score: 1 75 | # 76 | # stoplookups: (bool) [optional] 77 | # if a record is found in this blacklist stop processing checks 78 | stoplookups: No 79 | # 80 | # codes: (hash) [optional] 81 | # a series of keys that map to dnsbl results, if not provided any result is valid 82 | codes: 83 | 127.0.0.2: 84 | # 85 | # reason: (string) [optional] 86 | # a descriptive tag for the reason this result is returned 87 | reason: Some bad drone 88 | # 89 | # score: (int) [optional] 90 | # a positive or negative value that ranks this result 91 | score: 10 92 | # 93 | # stoplookups: (bool) [optional] 94 | # if a record has this result stop processing blacklists 95 | stoplookups: Yes 96 | -------------------------------------------------------------------------------- /libio/misc/libio_getopt.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). 3 | * getopt.c: Uses getopt to fetch the command line options. 4 | * 5 | * Copyright (C) 2002 by the past and present ircd coders, and others. 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 20 | * USA 21 | * 22 | * $Id$ 23 | */ 24 | 25 | #include "libioinc.h" 26 | #include "libio_getopt.h" 27 | 28 | #define OPTCHAR '-' 29 | 30 | static void 31 | libio_getopt_usage(const char *name, const struct lgetopt *myopts) 32 | { 33 | int i; 34 | 35 | fprintf(stderr, "Usage: %s [options]\n", name); 36 | fprintf(stderr, "Where valid options are:\n"); 37 | 38 | for (i = 0; myopts[i].opt; i++) 39 | fprintf(stderr, "\t%c%-10s %-20s%s\n", OPTCHAR, myopts[i].opt, 40 | (myopts[i].argtype == YESNO || myopts[i].argtype == USAGE) ? "" : 41 | myopts[i].argtype == INTEGER ? "" : "", 42 | myopts[i].desc); 43 | 44 | exit(EXIT_FAILURE); 45 | } 46 | 47 | void 48 | parseargs(int *argc, char ***argv, struct lgetopt *opts) 49 | { 50 | int i; 51 | char *progname = (*argv)[0]; 52 | 53 | /* loop through each argument */ 54 | for (;;) 55 | { 56 | int found = 0; 57 | 58 | (*argc)--; 59 | (*argv)++; 60 | 61 | if (*argc < 1) 62 | return; 63 | 64 | /* check if it *is* an arg.. */ 65 | if ((*argv)[0][0] != OPTCHAR) 66 | return; 67 | 68 | (*argv)[0]++; 69 | 70 | /* search through our argument list, and see if it matches */ 71 | for (i = 0; opts[i].opt; i++) 72 | { 73 | if (!strcmp(opts[i].opt, (*argv)[0])) 74 | { 75 | /* found our argument */ 76 | found = 1; 77 | 78 | switch (opts[i].argtype) 79 | { 80 | case YESNO: 81 | *((int *)opts[i].argloc) = 1; 82 | break; 83 | case INTEGER: 84 | if (*argc < 2) 85 | { 86 | fprintf(stderr, "Error: option '%c%s' requires an argument\n", 87 | OPTCHAR, opts[i].opt); 88 | libio_getopt_usage(progname, opts); 89 | } 90 | 91 | *((int *)opts[i].argloc) = atoi((*argv)[1]); 92 | (*argc)--; 93 | (*argv)++; 94 | break; 95 | case STRING: 96 | if (*argc < 2) 97 | { 98 | fprintf(stderr, "error: option '%c%s' requires an argument\n", 99 | OPTCHAR, opts[i].opt); 100 | libio_getopt_usage(progname, opts); 101 | } 102 | 103 | *((char**)opts[i].argloc) = malloc(strlen((*argv)[1]) + 1); 104 | strcpy(*((char**)opts[i].argloc), (*argv)[1]); 105 | (*argc)--; 106 | (*argv)++; 107 | break; 108 | 109 | case USAGE: 110 | libio_getopt_usage(progname, opts); 111 | /*NOTREACHED*/ 112 | 113 | default: 114 | fprintf(stderr, "Error: internal error in parseargs() at %s:%d\n", 115 | __FILE__, __LINE__); 116 | exit(EXIT_FAILURE); 117 | } 118 | } 119 | } 120 | if (!found) 121 | { 122 | fprintf(stderr, "error: unknown argument '%c%s'\n", OPTCHAR, (*argv)[0]); 123 | libio_getopt_usage(progname, opts); 124 | } 125 | } 126 | } 127 | --------------------------------------------------------------------------------