Compare commits

..

2 Commits

Author SHA1 Message Date
Sam Dodrill 3d74da6cbc Add HTTP parser from https://github.com/joyent/http-parser 2013-11-24 13:45:53 -08:00
Sam Dodrill 1553d3c136 Add first parts of websocket support
This commit adapted from:
    2703ca0b42
2013-11-24 13:41:39 -08:00
299 changed files with 52101 additions and 48667 deletions

View File

@ -1,2 +0,0 @@
au BufWritePost *.c execute 'silent !astyle --style=linux --mode=c -n' shellescape(expand('%'), 1) ' >/dev/null'
au BufWritePost *.h execute 'silent !astyle --style=linux --mode=c -n' shellescape(expand('%'), 1) ' >/dev/null'

View File

@ -1,12 +0,0 @@
language: c
compiler:
- gcc
before-install:
- sudo apt-get update
install:
- sudo apt-get install build-essential libssl-dev flex bison
script: "./configure && make"
notifications:
irc: "irc.yolo-swag.com#elemental-ircd"

View File

@ -1,20 +0,0 @@
# Contribution guidelines
Please open contributions as either issue reports or pull requests. We will ask
that anything that requires testing outside our normally supported platforms be
marked as such.
As ircd is such an ancient project with varying code styles, please try to
follow the current coding style of the file you are in. If all else fails,
please use the [Linux Kernel](https://www.kernel.org/doc/Documentation/CodingStyle)
coding style.
Please run all code against the following `astyle` command before sending in
a pull request:
```console
$ astyle --style=linux --mode=c -n $file
```
It should be trivial to set up your text editor to do this for you.

15
CREDITS
View File

@ -1,23 +1,14 @@
$Id: CREDITS 3133 2007-01-21 15:38:16Z jilles $
Elemental-IRCd is a fork of the now-defunct ShadowIRCD project.
The Elemental-IRCd team is listed below in nick-alphabetical order:
Xena, Sam Dodrill <shadowh511 -at- gmail.com>
Some Elemental-IRCd features are modeled after or direct ports of
code from Charybdis.
ponychat-ircd is a fork of the ShadowIRCD project created to meet
elemental-ircd is a fork of the ShadowIRCD project created to meet
PonyChat's needs and keep the now-defunct ShadowIRCD project's goals
alive.
The ponychat-ircd team is listed in nick-alphabetical order:
The elemental-ircd team is listed in nick-alphabetical order:
aji, Alex Iadicico <alex -at- ajitek.net>
lyska, Sam Dodrill <shadowh511 -at- gmail.com>>
Kabaka, Kyle Johnson <kabaka -at- ponychat.net>
Xe, Sam Dodrill <shadowh511 -at- gmail.com>
ShadowIRCd 6 is a modern restart of the old ShadowIRCd project
based on Charybdis with a few additional features to make it appeal

99
Config
View File

@ -1,99 +0,0 @@
#!/usr/bin/env python
"""
Copyright 2014 Sam Dodrill <shadowh511@gmail.com>
This software is under GPL.
"""
from os import system
try:
raw_input = raw_input
except NameError:
raw_input = input
art = """
_______ __ __ __ _______ ______ ______ __
| ___| |.-----.--------.-----.-----.| |_.---.-.| |_____|_ _| __ \ |.--| |
| ___| || -__| | -__| || _| _ || |______|| |_| < ---|| _ |
|_______|__||_____|__|__|__|_____|__|__||____|___._||__| |_______|___|__|______||_____|"""
welcome ="""
Welcome to the Elemental-IRCd Configuration script. This script will help you choose the
best compile flags for your installation of Elemental-IRCd.
"""
class Configure():
def promptUser(self, prompt, default):
inp = raw_input("%s [%s]> " % (prompt, default))
if inp == "":
return default
return inp
def promptYesNo(self, prompt, defult=True):
inp = False if self.promptUser(prompt, "Y") == "N" else True
return inp
def go(self):
configflags = ["./configure"]
print(art)
print(welcome)
print("Please specify where you would like to install Elemental-IRCd.")
installloc = self.promptUser("Install location?", "$HOME/ircd")
print("")
print("Please specify the maximum nickname length. This must be the same across")
print("all servers in your network or you risk desyncs. The maximum is 50.")
nicklen = 0
nicklen_valid = False
while not nicklen_valid:
try:
nicklen = int(self.promptUser("Maximum nickname length?", "31"))
if nicklen < 51:
nicklen_valid = True
except ValueError:
nicklen_valid = False
if not nicklen_valid:
print("Error: you must choose an integer value under 50.")
print("")
print("Would you like to disable small network support? This increases the size")
print("of a few buffers in the code and can increase performance on large networks.")
smallnet = self.promptYesNo("Small network? (Y/N)")
configflags.append("--prefix=%s" % installloc)
configflags.append("--with-nicklen=%s" % nicklen)
if not smallnet:
configflags.append("--enable-small-net")
else:
configflags.append("--disable-small-net")
print("\nThat should be it for now. Running %s" % " ".join(configflags))
raw_input("Press enter to continue... ")
system(" ".join(configflags))
print(art)
print("""
Next, run `make` and `make install`. Then copy %s/etc/example.conf to
%s/etc/ircd.conf and read through the example configuration completely to make
sure your install is tailored to your needs. After that, run %s/bin/ircd
and start to connect clients and servers as you need.
If you have any problems, please check the documentation in the doc/ folder
of the source repository. If problems persist please stop by #elemental-ircd
on irc.yolo-swag.com and ask. Running Elemental-IRCd in insane conditions may
make support either very difficult or at most impossible.""" % (installloc, installloc, installloc))
system("clear")
c = Configure()
try:
c.go()
except (KeyboardInterrupt, EOFError):
print("\nInterrupted, exiting!")
# vim: set ts=4 sw=4 tw=0 et

View File

@ -1,22 +0,0 @@
FROM flitter/init
MAINTAINER Xena <xena@yolo-swag.com>
# Update base system
RUN apt-get update && apt-get upgrade -yq && \
apt-get -yq install build-essential autoconf libssl-dev flex bison && \
adduser --system --home /home/ircd ircd && \
mkdir /home/ircd/src && \
chmod 777 /home/ircd/src
ADD . /home/ircd/src
RUN cd /home/ircd/src; ./configure --prefix=/home/ircd/run ; make ; make install
ADD doc/example.conf /home/ircd/run/etc/ircd.conf
ADD extra/runit/ /etc/service/ircd/
RUN chmod -R 777 /home/ircd/run
EXPOSE 6667
ENTRYPOINT /sbin/my_init

37
FAQ Normal file
View File

@ -0,0 +1,37 @@
ShadowIRCd FAQ
--------------
Q: Why does ShadowIRCd not have remote includes?
A: Remote Includes are a possible security risk due to possible MITM attacks
and such and do not prevent server owners making changes that you do not
want them to so they have little point. It is recommended to use rsync or
a git/hg cron job to pull in remote configuration files.
Q: Does ShadowIRCd support Windows?
A: No. There is no point in running IRCd on windows, aside perhaps as a quick
testnet. If you feel like doing it anyway, the best thing to try would be
some form of VM. We've heard that it doesn't compile on cygwin. We also
have no interest in supporting windows in the future. If you're looking
to start up an IRC network, you should really look into buying a VPS or
shell from a decent provider.
Q: I want shun, m_invisible, unreal-style m_spy, saquit, etc!
A: ShadowIRCd does not intend to ever implement such features. They have
little to no legitimate use, amazing abuse potential, and are inferior to
other methods. If for some reason you cannot live without such features,
you should probably use another ircd.
Q: What services should I run with ShadowIRCd?
A: The ShadowIRCd team highly recommends Atheme IRC Services (www.atheme.net),
which is known to support ShadowIRCd properly and is a great services
package overall. ShadowIRCd may work with Anope 1.8.x using the charybdis
protocol module and 1.9.x using the ratbox protocol module, but it is not
recommended and it has not been tested by the ShadowIRCd developers.
Q: I've got two servers linked and users on one are getting constant flood notices
when trying to send to channels. HELP!!!!
A: Has your server's clock gone backwards massively recently? (probably due to it
being incorrect). If so, you have two options. You can either wait for the real
time to be what the incorrect time was, or you can restart the affected server.
If that does not fix the problem, please file a bug at:
http://jira.atheme.org/browse/SHAD

6
GIT-Access Normal file
View File

@ -0,0 +1,6 @@
The ShadowIRCd Stable GIT repository can be checked out using the following command:
git clone git://git.atheme.org/unofficial/shadowircd-stable.git shadowircd-stable
ShadowIRCd's GIT repository depot can be browsed over the internet at
the following address:
http://git.atheme.org/unofficial/shadowircd-stable/

56
NEWS
View File

@ -1,60 +1,6 @@
This is elemental-ircd 6.6.1, Copyright (c) 2014 elemental-ircd team.
This is elemental-ircd 6.5, Copyright (c) 2013 elemental-ircd team.
See LICENSE for licensing details (GPL v2).
-- elemental-ircd 6.6.1
All code is now in the linux kernel coding style. Patches that do not
follow this coding style are at risk of being rejected. It is suggested
that your editor be set up to automatically style your code in the
desired format. A vim resource file is provided in the repository root.
additions
- automatic code styling for vim
- Dockerfile and nightly docker builds
- show cloaked I:Line vhost IP address remotely
bugfixes
- all channel lists have their own limit instead of sharing one.
5ba9c76d224afac877d9500d6ac1eb8f2bddd076
- fix potential undefined behavior with m_away
7d3966bc9bd9e9ab7833b4ecb0751671bdd085e7
- fix Anope 2.0 protocol module
79a3bf79ae66c43470c4bed25c33053b13a032d1
-- elemental-ircd 6.6
additions
- add OWNER=y to 005
- add autoconfigure script like unrealircd
- add channel mode +u to hide banlists unless users have halfop or up
- add modules for services packages
- add quotes around PART reason
- add umode +I to hide channels line from WHOIS
- make end-user /OPER failures much more generic
- make flooding SNOTEs global
- show own modes in whois
- show remote server IP addresses
- update helpfiles to have much more up to date information
bugfixes
- don't strip unicode in strip_unprintable
- fix extended-join for remote users
- fix null reference in away-notify
- make genssl.sh generate ten year certs
- merge some upstream charybdis patches
removals
- remove away-notify
- remove AHBL from default configs
- remove m_post SNOTEs because of an upstream change
The official channel for Elemental-IRCd is now #elemental-ircd on
irc.yolo-swag.com.
-- elemental-ircd 6.5.1
Rename to Elemental-IRCd
-- ponychat-ircd 6.5
additions

100
README.FIRST Normal file
View File

@ -0,0 +1,100 @@
If you don't read this first, we won't help you.
:-)
******************************* IMPORTANT *************************************
*********** Note for those who dont bother reading docs *****************
* - Reading INSTALL is now a must, as the old DPATH is now specified *
* when configure is run. *
* You now need to ./configure --prefix="/path/to/install/it" *
* will be installed with your ircd! *
*************************************************************************
ALSO, IF YOU ARE UPGRADING YOUR CURRENT SOURCE TREE, AND YOU TRY TO BUILD
IN IT WITHOUT PERFORMING AT LEAST 'make clean', THINGS _WILL_ BREAK. IT IS
RECOMMENDED THAT YOU RUN 'make distclean' AND THEN RERUN './configure'!
******************************* REQUIREMENTS **********************************
New Features - A short introduction:
- Please see NEWS for more detailed changes.
Necessary Requirements:
- A supported platform (look below)
- A working dynamic load library, unless
compiling as static, without module
support.
- A working lex. Solaris /usr/ccs/bin/lex
appears to be broken, on this system flex
should be used.
- A working parser/generator. bison is
recommended on most platforms.
Feature Specific Requirements:
- For SSL Clients, SSL Challenge controlled OPER feature, and encrypted server links,
a working OpenSSL library
- For encrypted oper and (optional) server passwords, a working DES, MD5, or SHA library.
*******************************************************************************
- To report bugs in ShadowIRCd, visit us at irc.thinstack.net #shadowircd
- See the INSTALL document for info on configuring and compiling
ShadowIRCd.
- Please read doc/index.txt to get an overview of the current documentation.
- The files, /etc/services, /etc/protocols, and /etc/resolv.conf, MUST be
readable by the user running the server in order for ircd to start.
Errors from adns causing the ircd to refuse to start up are often related
to permission problems on these files.
- FREEBSD USERS: if you are compiling with ipv6 you may experience
problems with ipv4 due to the way the socket code is written. To
fix this you must: "sysctl net.inet6.ip6.v6only=0"
- SOLARIS USERS: this code appears to tickle a bug in older gcc and
egcs ONLY on 64-bit Solaris7. gcc-2.95 and SunPro C on 64bit should
work fine, and any gcc or SunPro compiled on 32bit.
- DARWIN AND MACOS X USERS: You must be using at least the December 2001
Development Tools from Apple to build charybdis with shared modules.
Before then you MUST disable shared modules, as we do not have the proper
flags for cc(1) prior to that point to produce shared modules.
- SUPPORTED PLATFORMS: this code should compile without any warnings on:
FreeBSD 6.x/7.x/8.x,
Gentoo & Gentoo Hardened ~x86/~amd64/~fbsd
Fedora 8/9 / CentOS 4/5 / Redhat Enterprise 5
Debian Etch/Lenny/Squeeze,
OpenSuSE 10/11,
ArchLinux,
OpenSolaris 2008.x?
Solaris 10 sparc.
Please let us know if you find otherwise.
It probably does not compile on AIX, IRIX or libc5 Linux.
- TESTED PLATFORMS: The code has been tested on the following platforms, and
is known to run properly.
FreeBSD 6.x/7.x/8.x
Linux glibc-2.6, glibc-2.7, glibc-2.8, glibc-2.10, glibc-2.11
Solaris 2.6/7/8
OpenBSD 2.8
NetBSD 1.4
OpenVMS/Alpha 7.2 (static modules, no ssld)
- Please read NEWS for information about what is in this release
- Other files recommended for reading: INSTALL
--------------------------------------------------------------------------------
$Id$

View File

@ -1,35 +1,18 @@
# Elemental-IRCd
# elemental-ircd
**Elemental-IRCd** is a high performance, lightweight, and scalable
IRC daemon. It is a fork of the now-defunct ShadowIRCD and seeks to continue in
the direction ShadowIRCD was headed.
**elemental-ircd** is a high performance, lightweight, and scalable
IRC daemon. It is a fork of the now-defunct ShadowIRCD created to meet
PonyChat's needs, and seeks to continue in the direction ShadowIRCD
was headed.
## Supported Platforms
All modern \*NIX systems should work. You need the equivalent of the following
Debian packages:
- `libssl-dev`
- `flex`
- `bison`
- `build-essential`
```
Cassy | If you put something on a platform which cannot support it
| it may tip and fall and become broken. Simple physics.
```
Read the included documentation for detailed compilation and install
directions.
<Cassy> If you put something on a platform which cannot support it
it may tip and fall and become broken. Simple physics.
## Support
The official channel for Elemental-IRCd is `#elemental-ircd` on
`irc.yolo-swag.com`. Anyone with push access to the repository will have halfop
(`+h`, `%`) or higher.
Atheme and Anope (1.8 and 2.0) modules are included in the source tree of
Elemental-IRCd. For most cases the default `protocol/elemental-ircd` module in
Atheme should be fine, but this version will always be more up-to-date.
Our support channel is `#rainbow-factory` on `irc.ponychat.net`. Poke
**aji**, **lyska**, or **Kabaka** for help.
To report bugs, please use the GitHub issue tracker.

61
TODO Normal file
View File

@ -0,0 +1,61 @@
/ = in progress, x = done, ? = to be discussed, F = charybdis3.1 or next releases
[/] finish legacy code removal
[x] remove 2.8 report_error() in ratbox imported stuff
[F] client.c, channel.c is very 2.8 style still. it'd be nice to pack them into their own
namespace and such. moreover, the other 2.8 code needs similar rewriting/reworking too...
[x] merge m_join.c and m_sjoin.c in one module (same functions, done in ratbox3)
[ ] rewrite s_auth.c
[ ] authentication state/lock manager
[ ] move resolver/auth checker code into separated modules
[x] port to libratbox
[x] get it running
[x] clean up maxconnections kludges &c
[x] in-process SSL
[x] port and use ratbox ssld for server links
[x] merge with libratbox SVN
[x] ssl stuff
[x] client-to-client ssl
[x] server-to-server ssl
[x] ssl usermode (+Z)
[x] ssl channelmode (done by extban and chm_compat)
[x] tool for generating ssl certificates and other stuff
[x] gnutls backend for at least SSL connections (replacing libcrypto use in m_challenge would be nice too)
[x] merge some stuff from ircd-seven directly (to be determined what)
[x] remote d:lines support
[x] PASS selector:password for auth{} (useful for dynamic IPs)
[ ] kline/xline/resv sync (what about spb's extension?)
[x] drop non-TS6 (legacy protocol) support
[?] Patch or core-feature - libguess on-fly any-charset-to-utf8 translation
[x] module engine rework
[?] MODULE_DEPEND and MODULE_CONFLICT for building extension dependencies (backport from shadowircd)
[x] more beautiful way of adding new channel modes by module
[x] basic functionality
[x] some example modules
[x] another idea is too make that work with privilege groups, like "serveradmins" or "ircops"
[ ] make nick/user/host validation functions/match tables able to work in separated modules,
this will help us making support for native characters sets/slashes in host etc
[ ] auth checker module
[ ] resolver module
[x] privilege system for privilege groups, something like
in .conf: helper { kill_global, rehash, kline_local }
in modules: privilege_add("kill_global"), has_privilege(source_p, "kill_global") etc, should work the way dynamic cflags/umodes done
-- this is done kinda like this, but not really. See HasPrivilege() calls. privilege_add() was not needed ~nenolod
[x] Remove glines entirely
[/] test suite as in ircu
[?] win32
[?] mingw support
[R] win32 native support - VS doesn't follow C99, this will require us switching back to C89 with libratbox and (future) core
[x] Bug fixes
[x] Compilation without zlib headers fails - fixed
[x] Compilation date and time in server welcome message is in OS locale - looks ugly 'cause often it's not match user's codepage
[ ] Improvments
[ ] ircd shouldn't need bison/byacc/yacc or flex for compilation
--- other stuff
[?] internally split out +o/+v "ranks" into a series of permissions. this could allow for configure-defined
special access levels, halfops, etc. (would need to match globally, somehow. extra SVINFO param?)
might be backported from shadowircd in future (chanroles planned)
[?] somehow hide channel operators like ircnet can do?
couldn't be done via extension currently - compilation-time option acceptable?
[x] create chmode.h and put there all declarations of chm_* - this will make some modules clean
[?] Move oper override server WALLOPS to global server notices?

5
TODO-SHADOW Normal file
View File

@ -0,0 +1,5 @@
TODO list for ShadowIRCd 7.0
----------------------------
* evaluate some of the more inane cmodes (D, E, N, etc) for possible removal.
* move umode +B to extensions
* evaluate old code and clean up / improve where improvement can be made

View File

@ -1,23 +0,0 @@
# TODO
## elemental-ircd 6.7
- [ ] Finish websocket support
- [x] Configuration for websocket ports
- [x] HTTP parsing of websocket data
- [ ] Client connections via websockets
- [x] Send cloaked host as METADATA
- [x] Fix a flaw in the kick permission logic
- [x] Fix segfault on `autojoin_opers`
- [x] Update many of the helpfiles with the proper permissions
- [ ] extban by certfp
### Services Modules
- [ ] Support METADATA for the cloaked host
- [ ] Anope 2.0
- [ ] Atheme
- [ ] Have /hs off re-set the cloaked host instead of the user's real hostmask
- [ ] Anope 2.0
- [ ] Atheme

View File

@ -40,20 +40,21 @@
#define COMMIT_INTERVAL 3 /* seconds */
typedef enum {
BANDB_KLINE,
BANDB_DLINE,
BANDB_XLINE,
BANDB_RESV,
LAST_BANDB_TYPE
typedef enum
{
BANDB_KLINE,
BANDB_DLINE,
BANDB_XLINE,
BANDB_RESV,
LAST_BANDB_TYPE
} bandb_type;
static char bandb_letter[LAST_BANDB_TYPE] = {
'K', 'D', 'X', 'R'
'K', 'D', 'X', 'R'
};
static const char *bandb_table[LAST_BANDB_TYPE] = {
"kline", "dline", "xline", "resv"
"kline", "dline", "xline", "resv"
};
@ -65,181 +66,191 @@ static void check_schema(void);
static void
bandb_commit(void *unused)
{
rsdb_transaction(RSDB_TRANS_END);
in_transaction = 0;
rsdb_transaction(RSDB_TRANS_END);
in_transaction = 0;
}
static void
parse_ban(bandb_type type, char *parv[], int parc)
{
const char *mask1 = NULL;
const char *mask2 = NULL;
const char *oper = NULL;
const char *curtime = NULL;
const char *reason = NULL;
const char *perm = NULL;
int para = 1;
const char *mask1 = NULL;
const char *mask2 = NULL;
const char *oper = NULL;
const char *curtime = NULL;
const char *reason = NULL;
const char *perm = NULL;
int para = 1;
if(type == BANDB_KLINE) {
if(parc != 7)
return;
} else if(parc != 6)
return;
if(type == BANDB_KLINE)
{
if(parc != 7)
return;
}
else if(parc != 6)
return;
mask1 = parv[para++];
mask1 = parv[para++];
if(type == BANDB_KLINE)
mask2 = parv[para++];
if(type == BANDB_KLINE)
mask2 = parv[para++];
oper = parv[para++];
curtime = parv[para++];
perm = parv[para++];
reason = parv[para++];
oper = parv[para++];
curtime = parv[para++];
perm = parv[para++];
reason = parv[para++];
if(!in_transaction) {
rsdb_transaction(RSDB_TRANS_START);
in_transaction = 1;
rb_event_addonce("bandb_commit", bandb_commit, NULL,
COMMIT_INTERVAL);
}
if(!in_transaction)
{
rsdb_transaction(RSDB_TRANS_START);
in_transaction = 1;
rb_event_addonce("bandb_commit", bandb_commit, NULL,
COMMIT_INTERVAL);
}
rsdb_exec(NULL,
"INSERT INTO %s (mask1, mask2, oper, time, perm, reason) VALUES('%Q', '%Q', '%Q', %s, %s, '%Q')",
bandb_table[type], mask1, mask2 ? mask2 : "", oper, curtime, perm, reason);
rsdb_exec(NULL,
"INSERT INTO %s (mask1, mask2, oper, time, perm, reason) VALUES('%Q', '%Q', '%Q', %s, %s, '%Q')",
bandb_table[type], mask1, mask2 ? mask2 : "", oper, curtime, perm, reason);
}
static void
parse_unban(bandb_type type, char *parv[], int parc)
{
const char *mask1 = NULL;
const char *mask2 = NULL;
const char *mask1 = NULL;
const char *mask2 = NULL;
if(type == BANDB_KLINE) {
if(parc != 3)
return;
} else if(parc != 2)
return;
if(type == BANDB_KLINE)
{
if(parc != 3)
return;
}
else if(parc != 2)
return;
mask1 = parv[1];
mask1 = parv[1];
if(type == BANDB_KLINE)
mask2 = parv[2];
if(type == BANDB_KLINE)
mask2 = parv[2];
if(!in_transaction) {
rsdb_transaction(RSDB_TRANS_START);
in_transaction = 1;
rb_event_addonce("bandb_commit", bandb_commit, NULL,
COMMIT_INTERVAL);
}
if(!in_transaction)
{
rsdb_transaction(RSDB_TRANS_START);
in_transaction = 1;
rb_event_addonce("bandb_commit", bandb_commit, NULL,
COMMIT_INTERVAL);
}
rsdb_exec(NULL, "DELETE FROM %s WHERE mask1='%Q' AND mask2='%Q'",
bandb_table[type], mask1, mask2 ? mask2 : "");
rsdb_exec(NULL, "DELETE FROM %s WHERE mask1='%Q' AND mask2='%Q'",
bandb_table[type], mask1, mask2 ? mask2 : "");
}
static void
list_bans(void)
{
static char buf[512];
struct rsdb_table table;
int i, j;
static char buf[512];
struct rsdb_table table;
int i, j;
/* schedule a clear of anything already pending */
rb_helper_write_queue(bandb_helper, "C");
/* schedule a clear of anything already pending */
rb_helper_write_queue(bandb_helper, "C");
for(i = 0; i < LAST_BANDB_TYPE; i++) {
rsdb_exec_fetch(&table, "SELECT mask1,mask2,oper,reason FROM %s WHERE 1",
bandb_table[i]);
for(i = 0; i < LAST_BANDB_TYPE; i++)
{
rsdb_exec_fetch(&table, "SELECT mask1,mask2,oper,reason FROM %s WHERE 1",
bandb_table[i]);
for(j = 0; j < table.row_count; j++) {
if(i == BANDB_KLINE)
snprintf(buf, sizeof(buf), "%c %s %s %s :%s",
bandb_letter[i], table.row[j][0],
table.row[j][1], table.row[j][2], table.row[j][3]);
else
snprintf(buf, sizeof(buf), "%c %s %s :%s",
bandb_letter[i], table.row[j][0],
table.row[j][2], table.row[j][3]);
for(j = 0; j < table.row_count; j++)
{
if(i == BANDB_KLINE)
rb_snprintf(buf, sizeof(buf), "%c %s %s %s :%s",
bandb_letter[i], table.row[j][0],
table.row[j][1], table.row[j][2], table.row[j][3]);
else
rb_snprintf(buf, sizeof(buf), "%c %s %s :%s",
bandb_letter[i], table.row[j][0],
table.row[j][2], table.row[j][3]);
rb_helper_write_queue(bandb_helper, "%s", buf);
}
rb_helper_write_queue(bandb_helper, "%s", buf);
}
rsdb_exec_fetch_end(&table);
}
rsdb_exec_fetch_end(&table);
}
rb_helper_write(bandb_helper, "F");
rb_helper_write(bandb_helper, "F");
}
static void
parse_request(rb_helper *helper)
{
static char *parv[MAXPARA + 1];
static char readbuf[READBUF_SIZE];
int parc;
int len;
static char *parv[MAXPARA + 1];
static char readbuf[READBUF_SIZE];
int parc;
int len;
while((len = rb_helper_read(helper, readbuf, sizeof(readbuf))) > 0) {
parc = rb_string_to_array(readbuf, parv, MAXPARA);
while((len = rb_helper_read(helper, readbuf, sizeof(readbuf))) > 0)
{
parc = rb_string_to_array(readbuf, parv, MAXPARA);
if(parc < 1)
continue;
if(parc < 1)
continue;
switch (parv[0][0]) {
case 'K':
parse_ban(BANDB_KLINE, parv, parc);
break;
switch (parv[0][0])
{
case 'K':
parse_ban(BANDB_KLINE, parv, parc);
break;
case 'D':
parse_ban(BANDB_DLINE, parv, parc);
break;
case 'D':
parse_ban(BANDB_DLINE, parv, parc);
break;
case 'X':
parse_ban(BANDB_XLINE, parv, parc);
break;
case 'X':
parse_ban(BANDB_XLINE, parv, parc);
break;
case 'R':
parse_ban(BANDB_RESV, parv, parc);
break;
case 'R':
parse_ban(BANDB_RESV, parv, parc);
break;
case 'k':
parse_unban(BANDB_KLINE, parv, parc);
break;
case 'k':
parse_unban(BANDB_KLINE, parv, parc);
break;
case 'd':
parse_unban(BANDB_DLINE, parv, parc);
break;
case 'd':
parse_unban(BANDB_DLINE, parv, parc);
break;
case 'x':
parse_unban(BANDB_XLINE, parv, parc);
break;
case 'x':
parse_unban(BANDB_XLINE, parv, parc);
break;
case 'r':
parse_unban(BANDB_RESV, parv, parc);
break;
case 'r':
parse_unban(BANDB_RESV, parv, parc);
break;
case 'L':
list_bans();
break;
default:
break;
}
}
case 'L':
list_bans();
break;
default:
break;
}
}
}
static void
error_cb(rb_helper *helper)
{
if(in_transaction)
rsdb_transaction(RSDB_TRANS_END);
exit(1);
if(in_transaction)
rsdb_transaction(RSDB_TRANS_END);
exit(1);
}
#ifndef WINDOWS
static void
dummy_handler(int sig)
{
return;
return;
}
#endif
@ -247,28 +258,28 @@ static void
setup_signals()
{
#ifndef WINDOWS
struct sigaction act;
struct sigaction act;
act.sa_flags = 0;
act.sa_handler = SIG_IGN;
sigemptyset(&act.sa_mask);
sigaddset(&act.sa_mask, SIGPIPE);
sigaddset(&act.sa_mask, SIGALRM);
act.sa_flags = 0;
act.sa_handler = SIG_IGN;
sigemptyset(&act.sa_mask);
sigaddset(&act.sa_mask, SIGPIPE);
sigaddset(&act.sa_mask, SIGALRM);
#ifdef SIGTRAP
sigaddset(&act.sa_mask, SIGTRAP);
sigaddset(&act.sa_mask, SIGTRAP);
#endif
#ifdef SIGWINCH
sigaddset(&act.sa_mask, SIGWINCH);
sigaction(SIGWINCH, &act, 0);
sigaddset(&act.sa_mask, SIGWINCH);
sigaction(SIGWINCH, &act, 0);
#endif
sigaction(SIGPIPE, &act, 0);
sigaction(SIGPIPE, &act, 0);
#ifdef SIGTRAP
sigaction(SIGTRAP, &act, 0);
sigaction(SIGTRAP, &act, 0);
#endif
act.sa_handler = dummy_handler;
sigaction(SIGALRM, &act, 0);
act.sa_handler = dummy_handler;
sigaction(SIGALRM, &act, 0);
#endif
}
@ -276,49 +287,51 @@ setup_signals()
static void
db_error_cb(const char *errstr)
{
char buf[256];
snprintf(buf, sizeof(buf), "! :%s", errstr);
rb_helper_write(bandb_helper, buf);
rb_sleep(2 << 30, 0);
exit(1);
char buf[256];
rb_snprintf(buf, sizeof(buf), "! :%s", errstr);
rb_helper_write(bandb_helper, buf);
rb_sleep(2 << 30, 0);
exit(1);
}
int
main(int argc, char *argv[])
{
setup_signals();
bandb_helper = rb_helper_child(parse_request, error_cb, NULL, NULL, NULL, 256, 256, 256, 256); /* XXX fix me */
if(bandb_helper == NULL) {
fprintf(stderr,
"This is ircd-ratbox bandb. You aren't supposed to run me directly. Maybe you want bantool?\n");
fprintf(stderr,
"However I will print my Id tag $Id: bandb.c 26094 2008-09-19 15:33:46Z androsyn $\n");
fprintf(stderr, "Have a nice day\n");
exit(1);
}
rsdb_init(db_error_cb);
check_schema();
rb_helper_loop(bandb_helper, 0);
setup_signals();
bandb_helper = rb_helper_child(parse_request, error_cb, NULL, NULL, NULL, 256, 256, 256, 256); /* XXX fix me */
if(bandb_helper == NULL)
{
fprintf(stderr,
"This is ircd-ratbox bandb. You aren't supposed to run me directly. Maybe you want bantool?\n");
fprintf(stderr,
"However I will print my Id tag $Id: bandb.c 26094 2008-09-19 15:33:46Z androsyn $\n");
fprintf(stderr, "Have a nice day\n");
exit(1);
}
rsdb_init(db_error_cb);
check_schema();
rb_helper_loop(bandb_helper, 0);
return 0;
return 0;
}
static void
check_schema(void)
{
struct rsdb_table table;
int i;
struct rsdb_table table;
int i;
for(i = 0; i < LAST_BANDB_TYPE; i++) {
rsdb_exec_fetch(&table,
"SELECT name FROM sqlite_master WHERE type='table' AND name='%s'",
bandb_table[i]);
for(i = 0; i < LAST_BANDB_TYPE; i++)
{
rsdb_exec_fetch(&table,
"SELECT name FROM sqlite_master WHERE type='table' AND name='%s'",
bandb_table[i]);
rsdb_exec_fetch_end(&table);
rsdb_exec_fetch_end(&table);
if(!table.row_count)
rsdb_exec(NULL,
"CREATE TABLE %s (mask1 TEXT, mask2 TEXT, oper TEXT, time INTEGER, perm INTEGER, reason TEXT)",
bandb_table[i]);
}
if(!table.row_count)
rsdb_exec(NULL,
"CREATE TABLE %s (mask1 TEXT, mask2 TEXT, oper TEXT, time INTEGER, perm INTEGER, reason TEXT)",
bandb_table[i]);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -6,17 +6,19 @@ typedef void rsdb_error_cb(const char *);
typedef int (*rsdb_callback) (int, const char **);
typedef enum rsdb_transtype {
RSDB_TRANS_START,
RSDB_TRANS_END
typedef enum rsdb_transtype
{
RSDB_TRANS_START,
RSDB_TRANS_END
}
rsdb_transtype;
struct rsdb_table {
char ***row;
int row_count;
int col_count;
void *arg;
struct rsdb_table
{
char ***row;
int row_count;
int col_count;
void *arg;
};
int rsdb_init(rsdb_error_cb *);

View File

@ -39,206 +39,206 @@
#define TABLE_MAX 1000
static const char *IntTable[] = {
"000", "100", "200", "300", "400",
"500", "600", "700", "800", "900",
"010", "110", "210", "310", "410",
"510", "610", "710", "810", "910",
"020", "120", "220", "320", "420",
"520", "620", "720", "820", "920",
"030", "130", "230", "330", "430",
"530", "630", "730", "830", "930",
"040", "140", "240", "340", "440",
"540", "640", "740", "840", "940",
"050", "150", "250", "350", "450",
"550", "650", "750", "850", "950",
"060", "160", "260", "360", "460",
"560", "660", "760", "860", "960",
"070", "170", "270", "370", "470",
"570", "670", "770", "870", "970",
"080", "180", "280", "380", "480",
"580", "680", "780", "880", "980",
"090", "190", "290", "390", "490",
"590", "690", "790", "890", "990",
"001", "101", "201", "301", "401",
"501", "601", "701", "801", "901",
"011", "111", "211", "311", "411",
"511", "611", "711", "811", "911",
"021", "121", "221", "321", "421",
"521", "621", "721", "821", "921",
"031", "131", "231", "331", "431",
"531", "631", "731", "831", "931",
"041", "141", "241", "341", "441",
"541", "641", "741", "841", "941",
"051", "151", "251", "351", "451",
"551", "651", "751", "851", "951",
"061", "161", "261", "361", "461",
"561", "661", "761", "861", "961",
"071", "171", "271", "371", "471",
"571", "671", "771", "871", "971",
"081", "181", "281", "381", "481",
"581", "681", "781", "881", "981",
"091", "191", "291", "391", "491",
"591", "691", "791", "891", "991",
"002", "102", "202", "302", "402",
"502", "602", "702", "802", "902",
"012", "112", "212", "312", "412",
"512", "612", "712", "812", "912",
"022", "122", "222", "322", "422",
"522", "622", "722", "822", "922",
"032", "132", "232", "332", "432",
"532", "632", "732", "832", "932",
"042", "142", "242", "342", "442",
"542", "642", "742", "842", "942",
"052", "152", "252", "352", "452",
"552", "652", "752", "852", "952",
"062", "162", "262", "362", "462",
"562", "662", "762", "862", "962",
"072", "172", "272", "372", "472",
"572", "672", "772", "872", "972",
"082", "182", "282", "382", "482",
"582", "682", "782", "882", "982",
"092", "192", "292", "392", "492",
"592", "692", "792", "892", "992",
"003", "103", "203", "303", "403",
"503", "603", "703", "803", "903",
"013", "113", "213", "313", "413",
"513", "613", "713", "813", "913",
"023", "123", "223", "323", "423",
"523", "623", "723", "823", "923",
"033", "133", "233", "333", "433",
"533", "633", "733", "833", "933",
"043", "143", "243", "343", "443",
"543", "643", "743", "843", "943",
"053", "153", "253", "353", "453",
"553", "653", "753", "853", "953",
"063", "163", "263", "363", "463",
"563", "663", "763", "863", "963",
"073", "173", "273", "373", "473",
"573", "673", "773", "873", "973",
"083", "183", "283", "383", "483",
"583", "683", "783", "883", "983",
"093", "193", "293", "393", "493",
"593", "693", "793", "893", "993",
"004", "104", "204", "304", "404",
"504", "604", "704", "804", "904",
"014", "114", "214", "314", "414",
"514", "614", "714", "814", "914",
"024", "124", "224", "324", "424",
"524", "624", "724", "824", "924",
"034", "134", "234", "334", "434",
"534", "634", "734", "834", "934",
"044", "144", "244", "344", "444",
"544", "644", "744", "844", "944",
"054", "154", "254", "354", "454",
"554", "654", "754", "854", "954",
"064", "164", "264", "364", "464",
"564", "664", "764", "864", "964",
"074", "174", "274", "374", "474",
"574", "674", "774", "874", "974",
"084", "184", "284", "384", "484",
"584", "684", "784", "884", "984",
"094", "194", "294", "394", "494",
"594", "694", "794", "894", "994",
"005", "105", "205", "305", "405",
"505", "605", "705", "805", "905",
"015", "115", "215", "315", "415",
"515", "615", "715", "815", "915",
"025", "125", "225", "325", "425",
"525", "625", "725", "825", "925",
"035", "135", "235", "335", "435",
"535", "635", "735", "835", "935",
"045", "145", "245", "345", "445",
"545", "645", "745", "845", "945",
"055", "155", "255", "355", "455",
"555", "655", "755", "855", "955",
"065", "165", "265", "365", "465",
"565", "665", "765", "865", "965",
"075", "175", "275", "375", "475",
"575", "675", "775", "875", "975",
"085", "185", "285", "385", "485",
"585", "685", "785", "885", "985",
"095", "195", "295", "395", "495",
"595", "695", "795", "895", "995",
"006", "106", "206", "306", "406",
"506", "606", "706", "806", "906",
"016", "116", "216", "316", "416",
"516", "616", "716", "816", "916",
"026", "126", "226", "326", "426",
"526", "626", "726", "826", "926",
"036", "136", "236", "336", "436",
"536", "636", "736", "836", "936",
"046", "146", "246", "346", "446",
"546", "646", "746", "846", "946",
"056", "156", "256", "356", "456",
"556", "656", "756", "856", "956",
"066", "166", "266", "366", "466",
"566", "666", "766", "866", "966",
"076", "176", "276", "376", "476",
"576", "676", "776", "876", "976",
"086", "186", "286", "386", "486",
"586", "686", "786", "886", "986",
"096", "196", "296", "396", "496",
"596", "696", "796", "896", "996",
"007", "107", "207", "307", "407",
"507", "607", "707", "807", "907",
"017", "117", "217", "317", "417",
"517", "617", "717", "817", "917",
"027", "127", "227", "327", "427",
"527", "627", "727", "827", "927",
"037", "137", "237", "337", "437",
"537", "637", "737", "837", "937",
"047", "147", "247", "347", "447",
"547", "647", "747", "847", "947",
"057", "157", "257", "357", "457",
"557", "657", "757", "857", "957",
"067", "167", "267", "367", "467",
"567", "667", "767", "867", "967",
"077", "177", "277", "377", "477",
"577", "677", "777", "877", "977",
"087", "187", "287", "387", "487",
"587", "687", "787", "887", "987",
"097", "197", "297", "397", "497",
"597", "697", "797", "897", "997",
"008", "108", "208", "308", "408",
"508", "608", "708", "808", "908",
"018", "118", "218", "318", "418",
"518", "618", "718", "818", "918",
"028", "128", "228", "328", "428",
"528", "628", "728", "828", "928",
"038", "138", "238", "338", "438",
"538", "638", "738", "838", "938",
"048", "148", "248", "348", "448",
"548", "648", "748", "848", "948",
"058", "158", "258", "358", "458",
"558", "658", "758", "858", "958",
"068", "168", "268", "368", "468",
"568", "668", "768", "868", "968",
"078", "178", "278", "378", "478",
"578", "678", "778", "878", "978",
"088", "188", "288", "388", "488",
"588", "688", "788", "888", "988",
"098", "198", "298", "398", "498",
"598", "698", "798", "898", "998",
"009", "109", "209", "309", "409",
"509", "609", "709", "809", "909",
"019", "119", "219", "319", "419",
"519", "619", "719", "819", "919",
"029", "129", "229", "329", "429",
"529", "629", "729", "829", "929",
"039", "139", "239", "339", "439",
"539", "639", "739", "839", "939",
"049", "149", "249", "349", "449",
"549", "649", "749", "849", "949",
"059", "159", "259", "359", "459",
"559", "659", "759", "859", "959",
"069", "169", "269", "369", "469",
"569", "669", "769", "869", "969",
"079", "179", "279", "379", "479",
"579", "679", "779", "879", "979",
"089", "189", "289", "389", "489",
"589", "689", "789", "889", "989",
"099", "199", "299", "399", "499",
"599", "699", "799", "899", "999"
"000", "100", "200", "300", "400",
"500", "600", "700", "800", "900",
"010", "110", "210", "310", "410",
"510", "610", "710", "810", "910",
"020", "120", "220", "320", "420",
"520", "620", "720", "820", "920",
"030", "130", "230", "330", "430",
"530", "630", "730", "830", "930",
"040", "140", "240", "340", "440",
"540", "640", "740", "840", "940",
"050", "150", "250", "350", "450",
"550", "650", "750", "850", "950",
"060", "160", "260", "360", "460",
"560", "660", "760", "860", "960",
"070", "170", "270", "370", "470",
"570", "670", "770", "870", "970",
"080", "180", "280", "380", "480",
"580", "680", "780", "880", "980",
"090", "190", "290", "390", "490",
"590", "690", "790", "890", "990",
"001", "101", "201", "301", "401",
"501", "601", "701", "801", "901",
"011", "111", "211", "311", "411",
"511", "611", "711", "811", "911",
"021", "121", "221", "321", "421",
"521", "621", "721", "821", "921",
"031", "131", "231", "331", "431",
"531", "631", "731", "831", "931",
"041", "141", "241", "341", "441",
"541", "641", "741", "841", "941",
"051", "151", "251", "351", "451",
"551", "651", "751", "851", "951",
"061", "161", "261", "361", "461",
"561", "661", "761", "861", "961",
"071", "171", "271", "371", "471",
"571", "671", "771", "871", "971",
"081", "181", "281", "381", "481",
"581", "681", "781", "881", "981",
"091", "191", "291", "391", "491",
"591", "691", "791", "891", "991",
"002", "102", "202", "302", "402",
"502", "602", "702", "802", "902",
"012", "112", "212", "312", "412",
"512", "612", "712", "812", "912",
"022", "122", "222", "322", "422",
"522", "622", "722", "822", "922",
"032", "132", "232", "332", "432",
"532", "632", "732", "832", "932",
"042", "142", "242", "342", "442",
"542", "642", "742", "842", "942",
"052", "152", "252", "352", "452",
"552", "652", "752", "852", "952",
"062", "162", "262", "362", "462",
"562", "662", "762", "862", "962",
"072", "172", "272", "372", "472",
"572", "672", "772", "872", "972",
"082", "182", "282", "382", "482",
"582", "682", "782", "882", "982",
"092", "192", "292", "392", "492",
"592", "692", "792", "892", "992",
"003", "103", "203", "303", "403",
"503", "603", "703", "803", "903",
"013", "113", "213", "313", "413",
"513", "613", "713", "813", "913",
"023", "123", "223", "323", "423",
"523", "623", "723", "823", "923",
"033", "133", "233", "333", "433",
"533", "633", "733", "833", "933",
"043", "143", "243", "343", "443",
"543", "643", "743", "843", "943",
"053", "153", "253", "353", "453",
"553", "653", "753", "853", "953",
"063", "163", "263", "363", "463",
"563", "663", "763", "863", "963",
"073", "173", "273", "373", "473",
"573", "673", "773", "873", "973",
"083", "183", "283", "383", "483",
"583", "683", "783", "883", "983",
"093", "193", "293", "393", "493",
"593", "693", "793", "893", "993",
"004", "104", "204", "304", "404",
"504", "604", "704", "804", "904",
"014", "114", "214", "314", "414",
"514", "614", "714", "814", "914",
"024", "124", "224", "324", "424",
"524", "624", "724", "824", "924",
"034", "134", "234", "334", "434",
"534", "634", "734", "834", "934",
"044", "144", "244", "344", "444",
"544", "644", "744", "844", "944",
"054", "154", "254", "354", "454",
"554", "654", "754", "854", "954",
"064", "164", "264", "364", "464",
"564", "664", "764", "864", "964",
"074", "174", "274", "374", "474",
"574", "674", "774", "874", "974",
"084", "184", "284", "384", "484",
"584", "684", "784", "884", "984",
"094", "194", "294", "394", "494",
"594", "694", "794", "894", "994",
"005", "105", "205", "305", "405",
"505", "605", "705", "805", "905",
"015", "115", "215", "315", "415",
"515", "615", "715", "815", "915",
"025", "125", "225", "325", "425",
"525", "625", "725", "825", "925",
"035", "135", "235", "335", "435",
"535", "635", "735", "835", "935",
"045", "145", "245", "345", "445",
"545", "645", "745", "845", "945",
"055", "155", "255", "355", "455",
"555", "655", "755", "855", "955",
"065", "165", "265", "365", "465",
"565", "665", "765", "865", "965",
"075", "175", "275", "375", "475",
"575", "675", "775", "875", "975",
"085", "185", "285", "385", "485",
"585", "685", "785", "885", "985",
"095", "195", "295", "395", "495",
"595", "695", "795", "895", "995",
"006", "106", "206", "306", "406",
"506", "606", "706", "806", "906",
"016", "116", "216", "316", "416",
"516", "616", "716", "816", "916",
"026", "126", "226", "326", "426",
"526", "626", "726", "826", "926",
"036", "136", "236", "336", "436",
"536", "636", "736", "836", "936",
"046", "146", "246", "346", "446",
"546", "646", "746", "846", "946",
"056", "156", "256", "356", "456",
"556", "656", "756", "856", "956",
"066", "166", "266", "366", "466",
"566", "666", "766", "866", "966",
"076", "176", "276", "376", "476",
"576", "676", "776", "876", "976",
"086", "186", "286", "386", "486",
"586", "686", "786", "886", "986",
"096", "196", "296", "396", "496",
"596", "696", "796", "896", "996",
"007", "107", "207", "307", "407",
"507", "607", "707", "807", "907",
"017", "117", "217", "317", "417",
"517", "617", "717", "817", "917",
"027", "127", "227", "327", "427",
"527", "627", "727", "827", "927",
"037", "137", "237", "337", "437",
"537", "637", "737", "837", "937",
"047", "147", "247", "347", "447",
"547", "647", "747", "847", "947",
"057", "157", "257", "357", "457",
"557", "657", "757", "857", "957",
"067", "167", "267", "367", "467",
"567", "667", "767", "867", "967",
"077", "177", "277", "377", "477",
"577", "677", "777", "877", "977",
"087", "187", "287", "387", "487",
"587", "687", "787", "887", "987",
"097", "197", "297", "397", "497",
"597", "697", "797", "897", "997",
"008", "108", "208", "308", "408",
"508", "608", "708", "808", "908",
"018", "118", "218", "318", "418",
"518", "618", "718", "818", "918",
"028", "128", "228", "328", "428",
"528", "628", "728", "828", "928",
"038", "138", "238", "338", "438",
"538", "638", "738", "838", "938",
"048", "148", "248", "348", "448",
"548", "648", "748", "848", "948",
"058", "158", "258", "358", "458",
"558", "658", "758", "858", "958",
"068", "168", "268", "368", "468",
"568", "668", "768", "868", "968",
"078", "178", "278", "378", "478",
"578", "678", "778", "878", "978",
"088", "188", "288", "388", "488",
"588", "688", "788", "888", "988",
"098", "198", "298", "398", "498",
"598", "698", "798", "898", "998",
"009", "109", "209", "309", "409",
"509", "609", "709", "809", "909",
"019", "119", "219", "319", "419",
"519", "619", "719", "819", "919",
"029", "129", "229", "329", "429",
"529", "629", "729", "829", "929",
"039", "139", "239", "339", "439",
"539", "639", "739", "839", "939",
"049", "149", "249", "349", "449",
"549", "649", "749", "849", "949",
"059", "159", "259", "359", "459",
"559", "659", "759", "859", "959",
"069", "169", "269", "369", "469",
"569", "669", "769", "869", "969",
"079", "179", "279", "379", "479",
"579", "679", "779", "879", "979",
"089", "189", "289", "389", "489",
"589", "689", "789", "889", "989",
"099", "199", "299", "399", "499",
"599", "699", "799", "899", "999"
};
/*
@ -274,290 +274,328 @@ NOTE: This function handles the following flags only:
int
rs_vsnprintf(char *dest, const size_t bytes, const char *format, va_list args)
{
char ch;
int written = 0; /* bytes written so far */
int maxbytes = bytes - 1;
char ch;
int written = 0; /* bytes written so far */
int maxbytes = bytes - 1;
while((ch = *format++) && (written < maxbytes)) {
if(ch == '%') {
/*
* Advance past the %
*/
ch = *format++;
while((ch = *format++) && (written < maxbytes))
{
if(ch == '%')
{
/*
* Advance past the %
*/
ch = *format++;
/*
* Put the most common cases first - %s %d etc
*/
/*
* Put the most common cases first - %s %d etc
*/
if(ch == 's') {
const char *str = va_arg(args, const char *);
if(ch == 's')
{
const char *str = va_arg(args, const char *);
while((*dest = *str)) {
++dest;
++str;
while((*dest = *str))
{
++dest;
++str;
if(++written >= maxbytes)
break;
}
if(++written >= maxbytes)
break;
}
continue;
}
continue;
}
if(ch == 'd') {
int num = va_arg(args, int);
int quotient;
const char *str;
char *digitptr = TempBuffer;
if(ch == 'd')
{
int num = va_arg(args, int);
int quotient;
const char *str;
char *digitptr = TempBuffer;
/*
* We have to special-case "0" unfortunately
*/
if(num == 0) {
*dest++ = '0';
++written;
continue;
}
/*
* We have to special-case "0" unfortunately
*/
if(num == 0)
{
*dest++ = '0';
++written;
continue;
}
if(num < 0) {
*dest++ = '-';
if(++written >= maxbytes)
continue;
if(num < 0)
{
*dest++ = '-';
if(++written >= maxbytes)
continue;
num = -num;
}
num = -num;
}
do {
quotient = num / TABLE_MAX;
do
{
quotient = num / TABLE_MAX;
/*
* We'll start with the right-most digits of 'num'.
* Dividing by TABLE_MAX cuts off all but the X
* right-most digits, where X is such that:
*
* 10^X = TABLE_MAX
*
* For example, if num = 1200, and TABLE_MAX = 1000,
* quotient will be 1. Multiplying this by 1000 and
* subtracting from 1200 gives: 1200 - (1 * 1000) = 200.
* We then go right to slot 200 in our array and behold!
* The string "002" (200 backwards) is conveniently
* waiting for us. Then repeat the process with the
* digits left.
*
* The reason we need to have the integers written
* backwards, is because we don't know how many digits
* there are. If we want to express the number 12130
* for example, our first pass would leave us with 130,
* whose slot in the array yields "031", which we
* plug into our TempBuffer[]. The next pass gives us
* 12, whose slot yields "21" which we append to
* TempBuffer[], leaving us with "03121". This is the
* exact number we want, only backwards, so it is
* a simple matter to reverse the string. If we used
* straightfoward numbers, we would have a TempBuffer
* looking like this: "13012" which would be a nightmare
* to deal with.
*/
/*
* We'll start with the right-most digits of 'num'.
* Dividing by TABLE_MAX cuts off all but the X
* right-most digits, where X is such that:
*
* 10^X = TABLE_MAX
*
* For example, if num = 1200, and TABLE_MAX = 1000,
* quotient will be 1. Multiplying this by 1000 and
* subtracting from 1200 gives: 1200 - (1 * 1000) = 200.
* We then go right to slot 200 in our array and behold!
* The string "002" (200 backwards) is conveniently
* waiting for us. Then repeat the process with the
* digits left.
*
* The reason we need to have the integers written
* backwards, is because we don't know how many digits
* there are. If we want to express the number 12130
* for example, our first pass would leave us with 130,
* whose slot in the array yields "031", which we
* plug into our TempBuffer[]. The next pass gives us
* 12, whose slot yields "21" which we append to
* TempBuffer[], leaving us with "03121". This is the
* exact number we want, only backwards, so it is
* a simple matter to reverse the string. If we used
* straightfoward numbers, we would have a TempBuffer
* looking like this: "13012" which would be a nightmare
* to deal with.
*/
str = IntTable[num - (quotient * TABLE_MAX)];
str = IntTable[num - (quotient * TABLE_MAX)];
while((*digitptr = *str)) {
++digitptr;
++str;
}
} while((num = quotient) != 0);
while((*digitptr = *str))
{
++digitptr;
++str;
}
}
while((num = quotient) != 0);
/*
* If the last quotient was a 1 or 2 digit number, there
* will be one or more leading zeroes in TempBuffer[] -
* get rid of them.
*/
while(*(digitptr - 1) == '0')
--digitptr;
/*
* If the last quotient was a 1 or 2 digit number, there
* will be one or more leading zeroes in TempBuffer[] -
* get rid of them.
*/
while(*(digitptr - 1) == '0')
--digitptr;
while(digitptr != TempBuffer) {
*dest++ = *--digitptr;
if(++written >= maxbytes)
break;
}
while(digitptr != TempBuffer)
{
*dest++ = *--digitptr;
if(++written >= maxbytes)
break;
}
continue;
} /* if (ch == 'd') */
continue;
} /* if (ch == 'd') */
if(ch == 'c') {
*dest++ = va_arg(args, int);
if(ch == 'c')
{
*dest++ = va_arg(args, int);
++written;
++written;
continue;
} /* if (ch == 'c') */
continue;
} /* if (ch == 'c') */
if(ch == 'u') {
unsigned int num = va_arg(args, unsigned int);
unsigned int quotient;
const char *str;
char *digitptr = TempBuffer;
if(ch == 'u')
{
unsigned int num = va_arg(args, unsigned int);
unsigned int quotient;
const char *str;
char *digitptr = TempBuffer;
if(num == 0) {
*dest++ = '0';
++written;
continue;
}
if(num == 0)
{
*dest++ = '0';
++written;
continue;
}
do {
quotient = num / TABLE_MAX;
do
{
quotient = num / TABLE_MAX;
/*
* Very similar to case 'd'
*/
/*
* Very similar to case 'd'
*/
str = IntTable[num - (quotient * TABLE_MAX)];
str = IntTable[num - (quotient * TABLE_MAX)];
while((*digitptr = *str)) {
++digitptr;
++str;
}
} while((num = quotient) != 0);
while((*digitptr = *str))
{
++digitptr;
++str;
}
}
while((num = quotient) != 0);
while(*(digitptr - 1) == '0')
--digitptr;
while(*(digitptr - 1) == '0')
--digitptr;
while(digitptr != TempBuffer) {
*dest++ = *--digitptr;
if(++written >= maxbytes)
break;
}
while(digitptr != TempBuffer)
{
*dest++ = *--digitptr;
if(++written >= maxbytes)
break;
}
continue;
} /* if (ch == 'u') */
continue;
} /* if (ch == 'u') */
if(ch == 'Q') {
const char *arg = va_arg(args, const char *);
if(ch == 'Q')
{
const char *arg = va_arg(args, const char *);
if(arg == NULL)
continue;
if(arg == NULL)
continue;
const char *str = rsdb_quote(arg);
const char *str = rsdb_quote(arg);
while((*dest = *str)) {
++dest;
++str;
while((*dest = *str))
{
++dest;
++str;
if(++written >= maxbytes)
break;
}
if(++written >= maxbytes)
break;
}
continue;
}
continue;
}
if(ch == 'l') {
if(*format == 'u') {
unsigned long num = va_arg(args, unsigned long);
unsigned long quotient;
const char *str;
char *digitptr = TempBuffer;
if(ch == 'l')
{
if(*format == 'u')
{
unsigned long num = va_arg(args, unsigned long);
unsigned long quotient;
const char *str;
char *digitptr = TempBuffer;
++format;
++format;
if(num == 0) {
*dest++ = '0';
++written;
continue;
}
if(num == 0)
{
*dest++ = '0';
++written;
continue;
}
do {
quotient = num / TABLE_MAX;
do
{
quotient = num / TABLE_MAX;
/*
* Very similar to case 'u'
*/
/*
* Very similar to case 'u'
*/
str = IntTable[num - (quotient * TABLE_MAX)];
str = IntTable[num - (quotient * TABLE_MAX)];
while((*digitptr = *str)) {
++digitptr;
++str;
}
} while((num = quotient) != 0);
while((*digitptr = *str))
{
++digitptr;
++str;
}
}
while((num = quotient) != 0);
while(*(digitptr - 1) == '0')
--digitptr;
while(*(digitptr - 1) == '0')
--digitptr;
while(digitptr != TempBuffer) {
*dest++ = *--digitptr;
if(++written >= maxbytes)
break;
}
while(digitptr != TempBuffer)
{
*dest++ = *--digitptr;
if(++written >= maxbytes)
break;
}
continue;
} else
/* if (*format == 'u') */ if(*format == 'd') {
long num = va_arg(args, long);
long quotient;
const char *str;
char *digitptr = TempBuffer;
continue;
}
else
/* if (*format == 'u') */ if(*format == 'd')
{
long num = va_arg(args, long);
long quotient;
const char *str;
char *digitptr = TempBuffer;
++format;
++format;
if(num == 0) {
*dest++ = '0';
++written;
continue;
}
if(num == 0)
{
*dest++ = '0';
++written;
continue;
}
if(num < 0) {
*dest++ = '-';
if(++written >= maxbytes)
continue;
if(num < 0)
{
*dest++ = '-';
if(++written >= maxbytes)
continue;
num = -num;
}
num = -num;
}
do {
quotient = num / TABLE_MAX;
do
{
quotient = num / TABLE_MAX;
str = IntTable[num - (quotient * TABLE_MAX)];
str = IntTable[num - (quotient * TABLE_MAX)];
while((*digitptr = *str)) {
++digitptr;
++str;
}
} while((num = quotient) != 0);
while((*digitptr = *str))
{
++digitptr;
++str;
}
}
while((num = quotient) != 0);
while(*(digitptr - 1) == '0')
--digitptr;
while(*(digitptr - 1) == '0')
--digitptr;
while(digitptr != TempBuffer) {
*dest++ = *--digitptr;
if(++written >= maxbytes)
break;
}
while(digitptr != TempBuffer)
{
*dest++ = *--digitptr;
if(++written >= maxbytes)
break;
}
continue;
} else { /* if (*format == 'd') */
/* XXX error */
exit(1);
}
continue;
}
else /* if (*format == 'd') */
{
/* XXX error */
exit(1);
}
} /* if (ch == 'l') */
} /* if (ch == 'l') */
if(ch != '%') {
/* XXX error */
exit(1);
} /* if (ch != '%') */
} /* if (ch == '%') */
if(ch != '%')
{
/* XXX error */
exit(1);
} /* if (ch != '%') */
} /* if (ch == '%') */
*dest++ = ch;
++written;
} /* while ((ch = *format++) && (written < maxbytes)) */
*dest++ = ch;
++written;
} /* while ((ch = *format++) && (written < maxbytes)) */
/*
* Terminate the destination buffer with a \0
*/
*dest = '\0';
/*
* Terminate the destination buffer with a \0
*/
*dest = '\0';
return (written);
return (written);
} /* vSnprintf() */
/*
@ -576,14 +614,14 @@ Return: number of characters copied, NOT including the terminating
int
rs_snprintf(char *dest, const size_t bytes, const char *format, ...)
{
va_list args;
int count;
va_list args;
int count;
va_start(args, format);
va_start(args, format);
count = rs_vsnprintf(dest, bytes, format, args);
count = rs_vsnprintf(dest, bytes, format, args);
va_end(args);
va_end(args);
return (count);
return (count);
} /* Snprintf() */

View File

@ -3,7 +3,7 @@
*
* Copyright (C) 2003-2006 Lee Hardy <leeh@leeh.co.uk>
* Copyright (C) 2003-2006 ircd-ratbox development team
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
@ -27,7 +27,7 @@
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*
*/
#include "stdinc.h"
#include "rsdb.h"
@ -41,206 +41,224 @@ rsdb_error_cb *error_cb;
static void
mlog(const char *errstr, ...)
{
if(error_cb != NULL) {
char buf[256];
va_list ap;
va_start(ap, errstr);
vsnprintf(buf, sizeof(buf), errstr, ap);
va_end(ap);
error_cb(buf);
} else
exit(1);
if(error_cb != NULL)
{
char buf[256];
va_list ap;
va_start(ap, errstr);
rb_vsnprintf(buf, sizeof(buf), errstr, ap);
va_end(ap);
error_cb(buf);
}
else
exit(1);
}
int
rsdb_init(rsdb_error_cb * ecb)
{
const char *bandb_dbpath_env;
char dbpath[PATH_MAX];
char errbuf[128];
error_cb = ecb;
const char *bandb_dbpath_env;
char dbpath[PATH_MAX];
char errbuf[128];
error_cb = ecb;
/* try a path from the environment first, useful for basedir overrides */
bandb_dbpath_env = getenv("BANDB_DBPATH");
/* try a path from the environment first, useful for basedir overrides */
bandb_dbpath_env = getenv("BANDB_DBPATH");
if(bandb_dbpath_env != NULL)
rb_strlcpy(dbpath, bandb_dbpath_env, sizeof(dbpath));
else
rb_strlcpy(dbpath, DBPATH, sizeof(dbpath));
if(bandb_dbpath_env != NULL)
rb_strlcpy(dbpath, bandb_dbpath_env, sizeof(dbpath));
else
rb_strlcpy(dbpath, DBPATH, sizeof(dbpath));
if(sqlite3_open(dbpath, &rb_bandb) != SQLITE_OK) {
snprintf(errbuf, sizeof(errbuf), "Unable to open sqlite database: %s",
sqlite3_errmsg(rb_bandb));
mlog(errbuf);
return -1;
}
if(access(dbpath, W_OK)) {
snprintf(errbuf, sizeof(errbuf), "Unable to open sqlite database for write: %s", strerror(errno));
mlog(errbuf);
return -1;
}
return 0;
if(sqlite3_open(dbpath, &rb_bandb) != SQLITE_OK)
{
rb_snprintf(errbuf, sizeof(errbuf), "Unable to open sqlite database: %s",
sqlite3_errmsg(rb_bandb));
mlog(errbuf);
return -1;
}
if(access(dbpath, W_OK))
{
rb_snprintf(errbuf, sizeof(errbuf), "Unable to open sqlite database for write: %s", strerror(errno));
mlog(errbuf);
return -1;
}
return 0;
}
void
rsdb_shutdown(void)
{
if(rb_bandb)
sqlite3_close(rb_bandb);
if(rb_bandb)
sqlite3_close(rb_bandb);
}
const char *
rsdb_quote(const char *src)
{
static char buf[BUFSIZE * 4];
char *p = buf;
static char buf[BUFSIZE * 4];
char *p = buf;
/* cheap and dirty length check.. */
if(strlen(src) >= (sizeof(buf) / 2))
return NULL;
/* cheap and dirty length check.. */
if(strlen(src) >= (sizeof(buf) / 2))
return NULL;
while(*src) {
if(*src == '\'')
*p++ = '\'';
while(*src)
{
if(*src == '\'')
*p++ = '\'';
*p++ = *src++;
}
*p++ = *src++;
}
*p = '\0';
return buf;
*p = '\0';
return buf;
}
static int
rsdb_callback_func(void *cbfunc, int argc, char **argv, char **colnames)
{
rsdb_callback cb = (rsdb_callback)((uintptr_t)cbfunc);
(cb) (argc, (const char **)argv);
return 0;
rsdb_callback cb = (rsdb_callback)((uintptr_t)cbfunc);
(cb) (argc, (const char **)argv);
return 0;
}
void
rsdb_exec(rsdb_callback cb, const char *format, ...)
{
static char buf[BUFSIZE * 4];
va_list args;
char *errmsg;
unsigned int i;
int j;
static char buf[BUFSIZE * 4];
va_list args;
char *errmsg;
unsigned int i;
int j;
va_start(args, format);
i = rs_vsnprintf(buf, sizeof(buf), format, args);
va_end(args);
va_start(args, format);
i = rs_vsnprintf(buf, sizeof(buf), format, args);
va_end(args);
if(i >= sizeof(buf)) {
mlog("fatal error: length problem with compiling sql");
}
if(i >= sizeof(buf))
{
mlog("fatal error: length problem with compiling sql");
}
if((i = sqlite3_exec(rb_bandb, buf, (cb ? rsdb_callback_func : NULL), (void *)((uintptr_t)cb), &errmsg))) {
switch (i) {
case SQLITE_BUSY:
for(j = 0; j < 5; j++) {
rb_sleep(0, 500000);
if(!sqlite3_exec
(rb_bandb, buf, (cb ? rsdb_callback_func : NULL), (void *)((uintptr_t)cb), &errmsg))
return;
}
if((i = sqlite3_exec(rb_bandb, buf, (cb ? rsdb_callback_func : NULL), (void *)((uintptr_t)cb), &errmsg)))
{
switch (i)
{
case SQLITE_BUSY:
for(j = 0; j < 5; j++)
{
rb_sleep(0, 500000);
if(!sqlite3_exec
(rb_bandb, buf, (cb ? rsdb_callback_func : NULL), (void *)((uintptr_t)cb), &errmsg))
return;
}
/* failed, fall through to default */
mlog("fatal error: problem with db file: %s", errmsg);
break;
/* failed, fall through to default */
mlog("fatal error: problem with db file: %s", errmsg);
break;
default:
mlog("fatal error: problem with db file: %s", errmsg);
break;
}
}
default:
mlog("fatal error: problem with db file: %s", errmsg);
break;
}
}
}
void
rsdb_exec_fetch(struct rsdb_table *table, const char *format, ...)
{
static char buf[BUFSIZE * 4];
va_list args;
char *errmsg;
char **data;
int pos;
unsigned int retval;
int i, j;
static char buf[BUFSIZE * 4];
va_list args;
char *errmsg;
char **data;
int pos;
unsigned int retval;
int i, j;
va_start(args, format);
retval = rs_vsnprintf(buf, sizeof(buf), format, args);
va_end(args);
va_start(args, format);
retval = rs_vsnprintf(buf, sizeof(buf), format, args);
va_end(args);
if(retval >= sizeof(buf)) {
mlog("fatal error: length problem with compiling sql");
}
if(retval >= sizeof(buf))
{
mlog("fatal error: length problem with compiling sql");
}
if((retval =
sqlite3_get_table(rb_bandb, buf, &data, &table->row_count, &table->col_count, &errmsg))) {
int success = 0;
if((retval =
sqlite3_get_table(rb_bandb, buf, &data, &table->row_count, &table->col_count, &errmsg)))
{
int success = 0;
switch (retval) {
case SQLITE_BUSY:
for(i = 0; i < 5; i++) {
rb_sleep(0, 500000);
if(!sqlite3_get_table
(rb_bandb, buf, &data, &table->row_count, &table->col_count,
&errmsg)) {
success++;
break;
}
}
switch (retval)
{
case SQLITE_BUSY:
for(i = 0; i < 5; i++)
{
rb_sleep(0, 500000);
if(!sqlite3_get_table
(rb_bandb, buf, &data, &table->row_count, &table->col_count,
&errmsg))
{
success++;
break;
}
}
if(success)
break;
if(success)
break;
mlog("fatal error: problem with db file: %s", errmsg);
break;
mlog("fatal error: problem with db file: %s", errmsg);
break;
default:
mlog("fatal error: problem with db file: %s", errmsg);
break;
}
}
default:
mlog("fatal error: problem with db file: %s", errmsg);
break;
}
}
/* we need to be able to free data afterward */
table->arg = data;
/* we need to be able to free data afterward */
table->arg = data;
if(table->row_count == 0) {
table->row = NULL;
return;
}
if(table->row_count == 0)
{
table->row = NULL;
return;
}
/* sqlite puts the column names as the first row */
pos = table->col_count;
table->row = rb_malloc(sizeof(char **) * table->row_count);
for(i = 0; i < table->row_count; i++) {
table->row[i] = rb_malloc(sizeof(char *) * table->col_count);
/* sqlite puts the column names as the first row */
pos = table->col_count;
table->row = rb_malloc(sizeof(char **) * table->row_count);
for(i = 0; i < table->row_count; i++)
{
table->row[i] = rb_malloc(sizeof(char *) * table->col_count);
for(j = 0; j < table->col_count; j++) {
table->row[i][j] = data[pos++];
}
}
for(j = 0; j < table->col_count; j++)
{
table->row[i][j] = data[pos++];
}
}
}
void
rsdb_exec_fetch_end(struct rsdb_table *table)
{
int i;
int i;
for(i = 0; i < table->row_count; i++) {
rb_free(table->row[i]);
}
rb_free(table->row);
for(i = 0; i < table->row_count; i++)
{
rb_free(table->row[i]);
}
rb_free(table->row);
sqlite3_free_table((char **)table->arg);
sqlite3_free_table((char **)table->arg);
}
void
rsdb_transaction(rsdb_transtype type)
{
if(type == RSDB_TRANS_START)
rsdb_exec(NULL, "BEGIN TRANSACTION");
else if(type == RSDB_TRANS_END)
rsdb_exec(NULL, "COMMIT TRANSACTION");
if(type == RSDB_TRANS_START)
rsdb_exec(NULL, "BEGIN TRANSACTION");
else if(type == RSDB_TRANS_END)
rsdb_exec(NULL, "COMMIT TRANSACTION");
}

22
configure vendored
View File

@ -1,8 +1,8 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for elemental-ircd 6.6.1.
# Generated by GNU Autoconf 2.69 for elemental-ircd 6.5.1.
#
# 2014 elemental-ircd Team
# $Id: configure.ac 3516 2007-06-10 16:14:03Z jilles $
#
#
# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
@ -579,8 +579,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='elemental-ircd'
PACKAGE_TARNAME='elemental-ircd'
PACKAGE_VERSION='6.6.1'
PACKAGE_STRING='elemental-ircd 6.6.1'
PACKAGE_VERSION='6.5.1'
PACKAGE_STRING='elemental-ircd 6.5.1'
PACKAGE_BUGREPORT=''
PACKAGE_URL=''
@ -1303,7 +1303,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures elemental-ircd 6.6.1 to adapt to many kinds of systems.
\`configure' configures elemental-ircd 6.5.1 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@ -1364,7 +1364,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of elemental-ircd 6.6.1:";;
short | recursive ) echo "Configuration of elemental-ircd 6.5.1:";;
esac
cat <<\_ACEOF
@ -1488,14 +1488,14 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
elemental-ircd configure 6.6.1
elemental-ircd configure 6.5.1
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
This configure script is free software; the Free Software Foundation
gives unlimited permission to copy, distribute and modify it.
2014 elemental-ircd Team
$Id: configure.ac 3516 2007-06-10 16:14:03Z jilles $
_ACEOF
exit
fi
@ -2092,7 +2092,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by elemental-ircd $as_me 6.6.1, which was
It was created by elemental-ircd $as_me 6.5.1, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@ -10100,7 +10100,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by elemental-ircd $as_me 6.6.1, which was
This file was extended by elemental-ircd $as_me 6.5.1, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@ -10166,7 +10166,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
elemental-ircd config.status 6.6.1
elemental-ircd config.status 6.5.1
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"

View File

@ -8,9 +8,9 @@ dnl said functions need to be just about as complex as they already are.
AC_PREREQ(2.57)
dnl Sneaky way to get an Id tag into the configure script
AC_COPYRIGHT([2014 elemental-ircd Team])
AC_COPYRIGHT([$Id: configure.ac 3516 2007-06-10 16:14:03Z jilles $])
AC_INIT([elemental-ircd],[6.6.1])
AC_INIT([elemental-ircd],[6.5.1])
AC_CONFIG_HEADER(include/setup.h)
@ -253,7 +253,7 @@ AC_SUBST([pkglibdir])
AC_SUBST([rundir])
AC_SUBST([pkgrundir])
AC_SUBST([pkglocalstatedir])
AC_DEFINE_DIR([PKGLOCALSTATEDIR], [pkglocalstatedir], [[Directory in which to store state, such as ban database]])
AC_DEFINE_DIR([PKGLOCALSTATEDIR], [pkglocalstatedir], [[Directory in which to store state, such as band database]])
AC_SUBST([pkglibexecdir])
AC_DEFINE_DIR([PKGLIBEXECDIR], [pkglibexecdir], [Directory where binaries the IRCd itself spawns live])

View File

@ -3,7 +3,6 @@
* Copyright (C) 2000-2002 Hybrid Development Team
* Copyright (C) 2002-2005 ircd-ratbox development team
* Copyright (C) 2005-2006 charybdis development team
* Copyright (C) 2014 Elemental-IRCd development team
*
* $Id: example.conf 3582 2007-11-17 21:55:48Z jilles $
*
@ -48,10 +47,10 @@ loadmodule "extensions/sno_globaloper.so";
#loadmodule "extensions/sno_whois.so";
serverinfo {
name = "hostname.domain.tld";
name = "hades.arpa";
sid = "42X";
description = "elemental-ircd test server";
network_name = "ShadowNET";
description = "shadowircd test server";
network_name = "AthemeNET";
network_desc = "Your IRC network.";
helpchan = "#help";
helpurl = "http://www.mynet.net/help";
@ -63,7 +62,7 @@ serverinfo {
#vhost = "192.169.0.1";
/* for IPv6 */
#vhost6 = "3ffe:80e8:546::2";
/* ssl_private_key: our ssl private key */
ssl_private_key = "etc/ssl.key";
@ -91,7 +90,7 @@ serverinfo {
admin {
name = "Lazy admin (lazya)";
description = "ShadowNET client server";
description = "AthemeNET client server";
email = "nobody@127.0.0.1";
};
@ -140,8 +139,7 @@ listen {
/* defer_accept: wait for clients to send IRC handshake data before
* accepting them. if you intend to use software which depends on the
* server replying first, such as BOPM, you should disable this feature.
* otherwise, you probably want to leave it on. Disabling this will not
* update on a rehash.
* otherwise, you probably want to leave it on.
*/
defer_accept = yes;
@ -154,8 +152,8 @@ listen {
/* Listen on IPv6 (if you used host= above). */
#host = "3ffe:1234:a:b:c::d";
#port = 5000, 6665 .. 6669;
#sslport = 9999;
#port = 5000, 6665 .. 6669;
#sslport = 9999;
};
/* auth {}: allow users to connect to the ircd (OLD I:)
@ -187,7 +185,7 @@ auth {
* flags = ...; below if it is.
*/
password = "letmein";
/* spoof: fake the users user@host to be be this. You may either
* specify a host or a user@host to spoof to. This is free-form,
* just do everyone a favour and dont abuse it. (OLD I: = flag)
@ -200,8 +198,13 @@ auth {
*/
autojoin = "#shadowircd,#test";
/* autojoin_opers : Channel (or channels, comma-seperated) to join
* opers to on oper-up.
*/
autojoin_opers = "#opers,#help";
/* Possible flags in auth:
*
*
* encrypted | password is encrypted with mkpasswd
* spoof_notice | give a notice when spoofing hosts
* exceed_limit (old > flag) | allow user to exceed class user limits
@ -212,15 +215,15 @@ auth {
* jupe_exempt | exempt this user from generating
* warnings joining juped channels
* resv_exempt | exempt this user from resvs
* flood_exempt | exempt this user from flood limits
* USE WITH CAUTION.
* flood_exempt | exempt this user from flood limits
* USE WITH CAUTION.
* no_tilde (old - flag) | don't prefix ~ to username if no ident
* need_ident (old + flag) | require ident for user in this class
* need_ssl | require SSL/TLS for user in this class
* need_sasl | require SASL id for user in this class
*/
flags = kline_exempt, exceed_limit;
/* class: the class the user is placed in */
class = "opers";
};
@ -281,13 +284,13 @@ operator "god" {
user = "*god@127.0.0.1";
/* password: the password required to oper. Unless ~encrypted is
* contained in flags = ...; this will need to be encrypted using
* contained in flags = ...; this will need to be encrypted using
* mkpasswd, MD5 is supported
*/
password = "etcnjl8juSU1E";
/* rsa key: the public key for this oper when using Challenge.
* A password should not be defined when this is used, see
* A password should not be defined when this is used, see
* doc/challenge.txt for more information.
*/
#rsa_public_key_file = "/usr/local/ircd/etc/oper.pub";
@ -394,14 +397,14 @@ channel {
exemptchanops = "NT";
use_halfop = yes;
use_admin = yes;
use_owner = yes;
use_owner = yes;
use_knock = yes;
use_local_channels = yes;
knock_delay = 5 minutes;
knock_delay_channel = 1 minute;
max_chans_per_user = 15;
max_bans = 100;
max_bans_large = 500;
max_bans = 100;
max_bans_large = 500;
default_split_user_count = 0;
default_split_server_count = 0;
no_create_on_split = no;
@ -427,7 +430,7 @@ serverhide {
* They are used in pairs of one host/rejection reason.
*
* These settings should be adequate for most networks, and are (presently)
* required for use on ShadowNet.
* required for use on AthemeNet.
*
* Word to the wise: Do not use blacklists like SPEWS for blocking IRC
* connections.
@ -441,6 +444,9 @@ serverhide {
* ${nick} - the user's nickname
* ${network-name} - the name of the network
*
* Note: AHBL (the providers of the below *.ahbl.org BLs) request that they be
* contacted, via email, at admins@2mbit.com before using these BLs.
* See <http://www.ahbl.org/services.php> for more information.
*/
blacklist {
host = "rbl.efnetrbl.org";
@ -449,8 +455,11 @@ blacklist {
host = "dnsbl.dronebl.org";
reject_reason = "${nick}, your IP (${ip}) is listed in DroneBL. For assistance, see http://dronebl.org/lookup_branded.do?ip=${ip}&network=${network-name}";
host = "torexit.dan.me.uk";
reject_reason = "${nick}, your IP (${ip}) is listed as a TOR exit node. In order to protect ${network-name} from TOR-based abuse, we are not allowing TOR exit nodes to connect to our network.";
# host = "ircbl.ahbl.org";
# reject_reason = "${nick}, your IP (${ip}) is listed in ${dnsbl-host} for having an open proxy. In order to protect ${network-name} from abuse, we are not allowing connections with open proxies to connect.";
#
# host = "tor.ahbl.org";
# reject_reason = "${nick}, your IP (${ip}) is listed as a TOR exit node. In order to protect ${network-name} from tor-based abuse, we are not allowing TOR exit nodes to connect to our network.";
};
alias "NickServ" {
@ -531,23 +540,23 @@ general {
default_operstring = "is an IRC Operator";
default_adminstring = "is a Server Administrator";
#default_operhost = "staff.testnet.net";
default_operhost = "staff.testnet.net";
#static_quit = "I like turtles!";
servicestring = "is a Network Service";
disable_fake_channels = no;
hide_channel_below_users = 3;
tkline_expire_notices = no;
default_floodcount = 10;
tkline_expire_notices = no;
default_floodcount = 10;
failed_oper_notice = yes;
dots_in_ident=2;
min_nonwildcard = 4;
min_nonwildcard_simple = 3;
max_accept = 100;
max_accept = 100;
max_monitor = 100;
anti_nick_flood = yes;
max_nick_time = 20 seconds;
max_nick_changes = 5;
anti_spam_exit_message_time = 5 minutes;
anti_spam_exit_message_time = 5 minutes;
use_part_messages = yes;
ts_warn_delta = 30 seconds;
ts_max_delta = 5 minutes;
@ -571,7 +580,7 @@ general {
stats_P_oper_only=no;
stats_i_oper_only=masked;
stats_k_oper_only=masked;
map_oper_only = no;
map_oper_only = no;
operspy_admin_only = no;
operspy_dont_care_user_info = no;
secret_channels_in_whois = no;
@ -587,11 +596,11 @@ general {
true_no_oper_flood = no;
max_targets = 4;
client_flood = 20;
use_whois_actually = no;
use_whois_actually = no;
oper_only_umodes = operwall, locops, servnotice;
oper_umodes = locops, servnotice, operwall, wallop;
oper_snomask = "+s";
burst_away = yes;
burst_away = yes;
nick_delay = 0 seconds; # 15 minutes if you want to enable this
reject_ban_time = 1 minute;
reject_after_count = 3;
@ -599,7 +608,7 @@ general {
throttle_duration = 60;
throttle_count = 4;
expire_override_time = 5 minutes;
away_interval = 30;
away_interval = 30;
};
modules {

View File

@ -1,2 +1,2 @@
This is the Elemental-IRCd MOTD. You can use this if you like;
but if you do, your teacher may send you to magic kindergarten.
This is ShadowIRCd MOTD. You might replace it, but if not, your friends will
laugh at you.

View File

@ -373,6 +373,11 @@ auth {
*/
autojoin = "#shadowircd,#test";
/* autojoin_opers : Channel (or channels, comma-seperated) to join
* opers to on oper-up.
*/
autojoin_opers = "#opers,#help";
/* Possible flags in auth:
*
* encrypted | password is encrypted with mkpasswd
@ -962,6 +967,9 @@ serverhide {
* ${nick} - the user's nickname
* ${network-name} - the name of the network
*
* Note: AHBL (the providers of the below *.ahbl.org BLs) request that they be
* contacted, via email, at admins@2mbit.com before using these BLs.
* See <http://www.ahbl.org/services.php> for more information.
*/
blacklist {
host = "rbl.efnetrbl.org";
@ -969,6 +977,12 @@ blacklist {
host = "dnsbl.dronebl.org";
reject_reason = "${nick}, your IP (${ip}) is listed in DroneBL. For assistance, see http://dronebl.org/lookup_branded.do?ip=${ip}&network=${network-name}";
# host = "ircbl.ahbl.org";
# reject_reason = "${nick}, your IP (${ip}) is listed in ${dnsbl-host} for having an open proxy. In order to protect ${network-name} from abuse, we are not allowing connections with open proxies to connect.";
#
# host = "tor.ahbl.org";
# reject_reason = "${nick}, your IP (${ip}) is listed as a TOR exit node. In order to protect ${network-name} from tor-based abuse, we are not allowing TOR exit nodes to connect to our network.";
};
/*

View File

@ -376,6 +376,11 @@ auth {
*/
autojoin = "#shadowircd,#test";
/* autojoin_opers : Channel (or channels, comma-seperated) to join
* opers to on oper-up.
*/
autojoin_opers = "#opers,#help";
/* Possible flags in auth:
*
* encrypted | password is encrypted with mkpasswd
@ -965,6 +970,9 @@ serverhide {
* ${nick} - the user's nickname
* ${network-name} - the name of the network
*
* Note: AHBL (the providers of the below *.ahbl.org BLs) request that they be
* contacted, via email, at admins@2mbit.com before using these BLs.
* See <http://www.ahbl.org/services.php> for more information.
*/
blacklist {
host = "rbl.efnetrbl.org";
@ -972,6 +980,12 @@ blacklist {
host = "dnsbl.dronebl.org";
reject_reason = "${nick}, your IP (${ip}) is listed in DroneBL. For assistance, see http://dronebl.org/lookup_branded.do?ip=${ip}&network=${network-name}";
# host = "ircbl.ahbl.org";
# reject_reason = "${nick}, your IP (${ip}) is listed in ${dnsbl-host} for having an open proxy. In order to protect ${network-name} from abuse, we are not allowing connections with open proxies to connect.";
#
# host = "tor.ahbl.org";
# reject_reason = "${nick}, your IP (${ip}) is listed as a TOR exit node. In order to protect ${network-name} from tor-based abuse, we are not allowing TOR exit nodes to connect to our network.";
};
/*

View File

@ -52,17 +52,3 @@ servers and check. Bots or pseudoservices may also uses these lines to perform
additional actions (such as `AKILL`s or logging to channels) as needed by the
bot author.
#### METADATA
The old ShadowIRCD implementation of METADATA used `ADD` and `DELETE` verbs for
adding and deleting metadata to channels and clients. This, in practice looks
something like:
<<< :45X ENCAP * METADATA ADD 1NRAAAABR OPERSTRING :is an IRC Administrator
<<< :45X ENCAP * METADATA DELETE 1NRAAAABR OPERSTRING
Functionality is identical to the new `SET` and `CLEAR` verbs, but this deviates
from the spec by being **only** a server to server command. Support for client
to server and server to client metadata setting/getting will come in a future
version of elemental-ircd.

View File

@ -53,7 +53,6 @@ SRCS = \
force_user_invis.c \
hurt.c \
ip_cloaking.c \
ip_cloaking-5.c \
sno_farconnect.c \
sno_globalkline.c \
sno_globaloper.c \

View File

@ -13,8 +13,8 @@
static void h_can_join(hook_data_channel *);
mapi_hfn_list_av1 adminonly_hfnlist[] = {
{ "can_join", (hookfn) h_can_join },
{ NULL, NULL }
{ "can_join", (hookfn) h_can_join },
{ NULL, NULL }
};
static unsigned int mymode;
@ -22,17 +22,17 @@ static unsigned int mymode;
static int
_modinit(void)
{
mymode = cflag_add('A', chm_staff);
if (mymode == 0)
return -1;
mymode = cflag_add('A', chm_staff);
if (mymode == 0)
return -1;
return 0;
return 0;
}
static void
_moddeinit(void)
{
cflag_orphan('A');
cflag_orphan('A');
}
DECLARE_MODULE_AV1(chm_adminonly, _modinit, _moddeinit, NULL, NULL, adminonly_hfnlist, "$Revision$");
@ -40,12 +40,12 @@ DECLARE_MODULE_AV1(chm_adminonly, _modinit, _moddeinit, NULL, NULL, adminonly_hf
static void
h_can_join(hook_data_channel *data)
{
struct Client *source_p = data->client;
struct Channel *chptr = data->chptr;
struct Client *source_p = data->client;
struct Channel *chptr = data->chptr;
if((chptr->mode.mode & mymode) && !IsAdmin(source_p)) {
sendto_one_numeric(source_p, 519, "%s :Cannot join channel (+A) - you are not an IRC server administrator", chptr->chname);
data->approved = ERR_CUSTOM;
}
if((chptr->mode.mode & mymode) && !IsAdmin(source_p)) {
sendto_one_numeric(source_p, 519, "%s :Cannot join channel (+A) - you are not an IRC server administrator", chptr->chname);
data->approved = ERR_CUSTOM;
}
}

View File

@ -13,8 +13,8 @@
static void h_can_join(hook_data_channel *);
mapi_hfn_list_av1 operonly_hfnlist[] = {
{ "can_join", (hookfn) h_can_join },
{ NULL, NULL }
{ "can_join", (hookfn) h_can_join },
{ NULL, NULL }
};
static unsigned int mymode;
@ -26,18 +26,18 @@ static unsigned int mymode;
static int
_modinit(void)
{
mymode = cflag_add('O', chm_staff);
if (mymode == 0)
return -1;
mymode = cflag_add('O', chm_staff);
if (mymode == 0)
return -1;
return 0;
return 0;
}
static void
_moddeinit(void)
{
cflag_orphan('O');
cflag_orphan('O');
}
DECLARE_MODULE_AV1(chm_operonly, _modinit, _moddeinit, NULL, NULL, operonly_hfnlist, "$Revision$");
@ -45,12 +45,12 @@ DECLARE_MODULE_AV1(chm_operonly, _modinit, _moddeinit, NULL, NULL, operonly_hfnl
static void
h_can_join(hook_data_channel *data)
{
struct Client *source_p = data->client;
struct Channel *chptr = data->chptr;
struct Client *source_p = data->client;
struct Channel *chptr = data->chptr;
if((chptr->mode.mode & mymode) && !IsOper(source_p)) {
sendto_one_numeric(source_p, 520, "%s :Cannot join channel (+O) - you are not an IRC operator", chptr->chname);
data->approved = ERR_CUSTOM;
}
if((chptr->mode.mode & mymode) && !IsOper(source_p)) {
sendto_one_numeric(source_p, 520, "%s :Cannot join channel (+O) - you are not an IRC operator", chptr->chname);
data->approved = ERR_CUSTOM;
}
}

View File

@ -12,41 +12,41 @@
static int _modinit(void);
static void _moddeinit(void);
static void chm_operonly(struct Client *source_p, struct Channel *chptr,
int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type);
int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type);
DECLARE_MODULE_AV1(chm_operonly_compat, _modinit, _moddeinit, NULL, NULL, NULL, "$Revision$");
static int
_modinit(void)
{
chmode_table['O'].set_func = chm_operonly;
chmode_table['O'].mode_type = 0;
chmode_table['O'].set_func = chm_operonly;
chmode_table['O'].mode_type = 0;
return 0;
return 0;
}
static void
_moddeinit(void)
{
chmode_table['O'].set_func = chm_nosuch;
chmode_table['O'].mode_type = 0;
chmode_table['O'].set_func = chm_nosuch;
chmode_table['O'].mode_type = 0;
}
static void
chm_operonly(struct Client *source_p, struct Channel *chptr,
int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type)
int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type)
{
int newparn = 0;
const char *newparv[] = { "$o" };
int newparn = 0;
const char *newparv[] = { "$o" };
if (MyClient(source_p)) {
chm_simple(source_p, chptr, alevel, parc, parn, parv,
errors, dir, 'i', MODE_INVITEONLY);
chm_ban(source_p, chptr, alevel, 1, &newparn, newparv,
errors, dir, 'I', CHFL_INVEX);
} else
chm_nosuch(source_p, chptr, alevel, parc, parn, parv,
errors, dir, c, mode_type);
if (MyClient(source_p)) {
chm_simple(source_p, chptr, alevel, parc, parn, parv,
errors, dir, 'i', MODE_INVITEONLY);
chm_ban(source_p, chptr, alevel, 1, &newparn, newparv,
errors, dir, 'I', CHFL_INVEX);
} else
chm_nosuch(source_p, chptr, alevel, parc, parn, parv,
errors, dir, c, mode_type);
}

View File

@ -13,39 +13,39 @@
static int _modinit(void);
static void _moddeinit(void);
static void chm_quietunreg(struct Client *source_p, struct Channel *chptr,
int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type);
int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type);
DECLARE_MODULE_AV1(chm_quietunreg_compat, _modinit, _moddeinit, NULL, NULL, NULL, "$Revision$");
static int
_modinit(void)
{
chmode_table['R'].set_func = chm_quietunreg;
chmode_table['R'].mode_type = 0;
chmode_table['R'].set_func = chm_quietunreg;
chmode_table['R'].mode_type = 0;
return 0;
return 0;
}
static void
_moddeinit(void)
{
chmode_table['R'].set_func = chm_nosuch;
chmode_table['R'].mode_type = 0;
chmode_table['R'].set_func = chm_nosuch;
chmode_table['R'].mode_type = 0;
}
static void
chm_quietunreg(struct Client *source_p, struct Channel *chptr,
int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type)
int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type)
{
int newparn = 0;
const char *newparv[] = { "$~a" };
int newparn = 0;
const char *newparv[] = { "$~a" };
if (MyClient(source_p))
chm_ban(source_p, chptr, alevel, 1, &newparn, newparv,
errors, dir, 'q', CHFL_QUIET);
else
chm_nosuch(source_p, chptr, alevel, parc, parn, parv,
errors, dir, c, mode_type);
if (MyClient(source_p))
chm_ban(source_p, chptr, alevel, 1, &newparn, newparv,
errors, dir, 'q', CHFL_QUIET);
else
chm_nosuch(source_p, chptr, alevel, parc, parn, parv,
errors, dir, c, mode_type);
}

View File

@ -13,8 +13,8 @@
static void h_can_join(hook_data_channel *);
mapi_hfn_list_av1 sslonly_hfnlist[] = {
{ "can_join", (hookfn) h_can_join },
{ NULL, NULL }
{ "can_join", (hookfn) h_can_join },
{ NULL, NULL }
};
static unsigned int mymode;
@ -22,18 +22,18 @@ static unsigned int mymode;
static int
_modinit(void)
{
mymode = cflag_add('S', chm_simple);
if (mymode == 0)
return -1;
mymode = cflag_add('S', chm_simple);
if (mymode == 0)
return -1;
return 0;
return 0;
}
static void
_moddeinit(void)
{
cflag_orphan('S');
cflag_orphan('S');
}
DECLARE_MODULE_AV1(chm_sslonly, _modinit, _moddeinit, NULL, NULL, sslonly_hfnlist, "$Revision$");
@ -41,12 +41,12 @@ DECLARE_MODULE_AV1(chm_sslonly, _modinit, _moddeinit, NULL, NULL, sslonly_hfnlis
static void
h_can_join(hook_data_channel *data)
{
struct Client *source_p = data->client;
struct Channel *chptr = data->chptr;
struct Client *source_p = data->client;
struct Channel *chptr = data->chptr;
if((chptr->mode.mode & mymode) && !IsSSLClient(source_p)) {
sendto_one_notice(source_p, ":Only users using SSL can join this channel!");
data->approved = ERR_CUSTOM;
}
if((chptr->mode.mode & mymode) && !IsSSLClient(source_p)) {
sendto_one_notice(source_p, ":Only users using SSL could join this channel!");
data->approved = ERR_CUSTOM;
}
}

View File

@ -12,39 +12,39 @@
static int _modinit(void);
static void _moddeinit(void);
static void chm_sslonly(struct Client *source_p, struct Channel *chptr,
int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type);
int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type);
DECLARE_MODULE_AV1(chm_sslonly_compat, _modinit, _moddeinit, NULL, NULL, NULL, "$Revision$");
static int
_modinit(void)
{
chmode_table['S'].set_func = chm_sslonly;
chmode_table['S'].mode_type = 0;
chmode_table['S'].set_func = chm_sslonly;
chmode_table['S'].mode_type = 0;
return 0;
return 0;
}
static void
_moddeinit(void)
{
chmode_table['S'].set_func = chm_nosuch;
chmode_table['S'].mode_type = 0;
chmode_table['S'].set_func = chm_nosuch;
chmode_table['S'].mode_type = 0;
}
static void
chm_sslonly(struct Client *source_p, struct Channel *chptr,
int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type)
int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type)
{
int newparn = 0;
const char *newparv[] = { "$~z" };
int newparn = 0;
const char *newparv[] = { "$~z" };
if (MyClient(source_p))
chm_ban(source_p, chptr, alevel, 1, &newparn, newparv,
errors, dir, 'b', CHFL_BAN);
else
chm_nosuch(source_p, chptr, alevel, parc, parn, parv,
errors, dir, c, mode_type);
if (MyClient(source_p))
chm_ban(source_p, chptr, alevel, 1, &newparn, newparv,
errors, dir, 'b', CHFL_BAN);
else
chm_nosuch(source_p, chptr, alevel, parc, parn, parv,
errors, dir, c, mode_type);
}

View File

@ -20,8 +20,8 @@
static void h_can_create_channel_authenticated(hook_data_client_approval *);
mapi_hfn_list_av1 restrict_hfnlist[] = {
{ "can_create_channel", (hookfn) h_can_create_channel_authenticated },
{ NULL, NULL }
{ "can_create_channel", (hookfn) h_can_create_channel_authenticated },
{ NULL, NULL }
};
DECLARE_MODULE_AV1(createauthonly, NULL, NULL, NULL, NULL, restrict_hfnlist, "$Revision: 833 $");
@ -29,8 +29,8 @@ DECLARE_MODULE_AV1(createauthonly, NULL, NULL, NULL, NULL, restrict_hfnlist, "$R
static void
h_can_create_channel_authenticated(hook_data_client_approval *data)
{
struct Client *source_p = data->client;
struct Client *source_p = data->client;
if (*source_p->user->suser == '\0' && !IsOper(source_p))
data->approved = ERR_NEEDREGGEDNICK;
if (*source_p->user->suser == '\0' && !IsOper(source_p))
data->approved = ERR_NEEDREGGEDNICK;
}

View File

@ -20,8 +20,8 @@
static void h_can_create_channel_authenticated(hook_data_client_approval *);
mapi_hfn_list_av1 restrict_hfnlist[] = {
{ "can_create_channel", (hookfn) h_can_create_channel_authenticated },
{ NULL, NULL }
{ "can_create_channel", (hookfn) h_can_create_channel_authenticated },
{ NULL, NULL }
};
DECLARE_MODULE_AV1(createoperonly, NULL, NULL, NULL, NULL, restrict_hfnlist, "$Revision: 3476 $");
@ -29,10 +29,11 @@ DECLARE_MODULE_AV1(createoperonly, NULL, NULL, NULL, NULL, restrict_hfnlist, "$R
static void
h_can_create_channel_authenticated(hook_data_client_approval *data)
{
struct Client *source_p = data->client;
struct Client *source_p = data->client;
if (!IsOper(source_p)) {
sendto_one_notice(source_p, ":*** Channel creation is restricted to network staff only.");
data->approved = ERR_NEEDREGGEDNICK;
}
if (!IsOper(source_p))
{
sendto_one_notice(source_p, ":*** Channel creation is restricted to network staff only.");
data->approved = ERR_NEEDREGGEDNICK;
}
}

View File

@ -47,25 +47,25 @@ static int moper_test(struct Client *client_p, struct Client *source_p, int parc
*/
struct Message test_msgtab = {
"TEST", /* the /COMMAND you want */
0, /* SET TO ZERO -- number of times command used by clients */
0, /* SET TO ZERO -- number of times command used by clients */
0, /* SET TO ZERO -- number of times command used by clients */
MFLG_SLOW, /* ALWAYS SET TO MFLG_SLOW */
"TEST", /* the /COMMAND you want */
0, /* SET TO ZERO -- number of times command used by clients */
0, /* SET TO ZERO -- number of times command used by clients */
0, /* SET TO ZERO -- number of times command used by clients */
MFLG_SLOW, /* ALWAYS SET TO MFLG_SLOW */
/* the functions to call for each handler. If not using the generic
* handlers, the first param is the function to call, the second is the
* required number of parameters. NOTE: If you specify a min para of 2,
* then parv[1] must *also* be non-empty.
*/
{
{munreg_test, 0}, /* function call for unregistered clients, 0 parms required */
{mclient_test, 0}, /* function call for local clients, 0 parms required */
{mrclient_test, 0}, /* function call for remote clients, 0 parms required */
{mserver_test, 0}, /* function call for servers, 0 parms required */
mg_ignore, /* function call for ENCAP, unused in this test */
{moper_test, 0} /* function call for operators, 0 parms required */
}
/* the functions to call for each handler. If not using the generic
* handlers, the first param is the function to call, the second is the
* required number of parameters. NOTE: If you specify a min para of 2,
* then parv[1] must *also* be non-empty.
*/
{
{munreg_test, 0}, /* function call for unregistered clients, 0 parms required */
{mclient_test, 0}, /* function call for local clients, 0 parms required */
{mrclient_test, 0}, /* function call for remote clients, 0 parms required */
{mserver_test, 0}, /* function call for servers, 0 parms required */
mg_ignore, /* function call for ENCAP, unused in this test */
{moper_test, 0} /* function call for operators, 0 parms required */
}
};
/*
* There are also some macros for the above function calls and parameter counts.
@ -93,9 +93,9 @@ mapi_clist_av1 test_clist[] = { &test_msgtab, NULL };
* terminated with NULLs.
*/
int doing_example_hook;
mapi_hlist_av1 test_hlist[] = {
{ "doing_example_hook", &doing_example_hook, },
{ NULL, NULL }
mapi_hlist_av1 test_hlist[] = {
{ "doing_example_hook", &doing_example_hook, },
{ NULL, NULL }
};
/* The mapi_hfn_list_av1 declares the hook functions which other modules can
@ -106,44 +106,44 @@ mapi_hlist_av1 test_hlist[] = {
static void show_example_hook(void *unused);
mapi_hfn_list_av1 test_hfnlist[] = {
{ "doing_example_hook", (hookfn) show_example_hook },
{ NULL, NULL }
{ "doing_example_hook", (hookfn) show_example_hook },
{ NULL, NULL }
};
/* Here we tell it what to do when the module is loaded */
static int
modinit(void)
{
/* Nothing to do for the example module. */
/* The init function should return -1 on failure,
which will cause the module to be unloaded,
otherwise 0 to indicate success. */
return 0;
/* Nothing to do for the example module. */
/* The init function should return -1 on failure,
which will cause the module to be unloaded,
otherwise 0 to indicate success. */
return 0;
}
/* here we tell it what to do when the module is unloaded */
static void
moddeinit(void)
{
/* Again, nothing to do. */
/* Again, nothing to do. */
}
/* DECLARE_MODULE_AV1() actually declare the MAPI header. */
DECLARE_MODULE_AV1(
/* The first argument is the name */
example,
/* The second argument is the function to call on load */
modinit,
/* And the function to call on unload */
moddeinit,
/* Then the MAPI command list */
test_clist,
/* Next the hook list, if we have one. */
test_hlist,
/* Then the hook function list, if we have one */
test_hfnlist,
/* And finally the version number of this module. */
"$Revision: 3161 $");
/* The first argument is the name */
example,
/* The second argument is the function to call on load */
modinit,
/* And the function to call on unload */
moddeinit,
/* Then the MAPI command list */
test_clist,
/* Next the hook list, if we have one. */
test_hlist,
/* Then the hook function list, if we have one */
test_hfnlist,
/* And finally the version number of this module. */
"$Revision: 3161 $");
/* Any of the above arguments can be NULL to indicate they aren't used. */
@ -159,16 +159,19 @@ DECLARE_MODULE_AV1(
static int
munreg_test(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
if(parc < 2) {
sendto_one_notice(source_p, ":You are unregistered and sent no parameters");
} else {
sendto_one_notice(source_p, ":You are unregistered and sent parameter: %s", parv[1]);
}
if(parc < 2)
{
sendto_one_notice(source_p, ":You are unregistered and sent no parameters");
}
else
{
sendto_one_notice(source_p, ":You are unregistered and sent parameter: %s", parv[1]);
}
/* illustration of how to call a hook function */
call_hook(doing_example_hook, NULL);
/* illustration of how to call a hook function */
call_hook(doing_example_hook, NULL);
return 0;
return 0;
}
/*
@ -178,16 +181,19 @@ munreg_test(struct Client *client_p, struct Client *source_p, int parc, const ch
static int
mclient_test(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
if(parc < 2) {
sendto_one_notice(source_p, ":You are a normal user, and sent no parameters");
} else {
sendto_one_notice(source_p, ":You are a normal user, and send parameters: %s", parv[1]);
}
if(parc < 2)
{
sendto_one_notice(source_p, ":You are a normal user, and sent no parameters");
}
else
{
sendto_one_notice(source_p, ":You are a normal user, and send parameters: %s", parv[1]);
}
/* illustration of how to call a hook function */
call_hook(doing_example_hook, NULL);
/* illustration of how to call a hook function */
call_hook(doing_example_hook, NULL);
return 0;
return 0;
}
/*
@ -197,12 +203,15 @@ mclient_test(struct Client *client_p, struct Client *source_p, int parc, const c
static int
mrclient_test(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
if(parc < 2) {
sendto_one_notice(source_p, ":You are a remote client, and sent no parameters");
} else {
sendto_one_notice(source_p, ":You are a remote client, and sent parameters: %s", parv[1]);
}
return 0;
if(parc < 2)
{
sendto_one_notice(source_p, ":You are a remote client, and sent no parameters");
}
else
{
sendto_one_notice(source_p, ":You are a remote client, and sent parameters: %s", parv[1]);
}
return 0;
}
/*
@ -212,12 +221,15 @@ mrclient_test(struct Client *client_p, struct Client *source_p, int parc, const
static int
mserver_test(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
if(parc < 2) {
sendto_one_notice(source_p, ":You are a server, and sent no parameters");
} else {
sendto_one_notice(source_p, ":You are a server, and sent parameters: %s", parv[1]);
}
return 0;
if(parc < 2)
{
sendto_one_notice(source_p, ":You are a server, and sent no parameters");
}
else
{
sendto_one_notice(source_p, ":You are a server, and sent parameters: %s", parv[1]);
}
return 0;
}
/*
@ -227,18 +239,21 @@ mserver_test(struct Client *client_p, struct Client *source_p, int parc, const c
static int
moper_test(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
if(parc < 2) {
sendto_one_notice(source_p, ":You are an operator, and sent no parameters");
} else {
sendto_one_notice(source_p, ":You are an operator, and sent parameters: %s", parv[1]);
}
return 0;
if(parc < 2)
{
sendto_one_notice(source_p, ":You are an operator, and sent no parameters");
}
else
{
sendto_one_notice(source_p, ":You are an operator, and sent parameters: %s", parv[1]);
}
return 0;
}
static void
show_example_hook(void *unused)
{
sendto_realops_snomask(SNO_GENERAL, L_ALL, "Called example hook!");
sendto_realops_snomask(SNO_GENERAL, L_ALL, "Called example hook!");
}
/* END OF EXAMPLE MODULE */

View File

@ -18,25 +18,25 @@ DECLARE_MODULE_AV1(extb_account, _modinit, _moddeinit, NULL, NULL, NULL, "$Revis
static int
_modinit(void)
{
extban_table['a'] = eb_account;
extban_table['a'] = eb_account;
return 0;
return 0;
}
static void
_moddeinit(void)
{
extban_table['a'] = NULL;
extban_table['a'] = NULL;
}
static int eb_account(const char *data, struct Client *client_p,
struct Channel *chptr, long mode_type)
struct Channel *chptr, long mode_type)
{
(void)chptr;
/* $a alone matches any logged in user */
if (data == NULL)
return EmptyString(client_p->user->suser) ? EXTBAN_NOMATCH : EXTBAN_MATCH;
/* $a:MASK matches users logged in under matching account */
return match(data, client_p->user->suser) ? EXTBAN_MATCH : EXTBAN_NOMATCH;
(void)chptr;
/* $a alone matches any logged in user */
if (data == NULL)
return EmptyString(client_p->user->suser) ? EXTBAN_NOMATCH : EXTBAN_MATCH;
/* $a:MASK matches users logged in under matching account */
return match(data, client_p->user->suser) ? EXTBAN_MATCH : EXTBAN_NOMATCH;
}

View File

@ -21,46 +21,46 @@ DECLARE_MODULE_AV1(extb_canjoin, _modinit, _moddeinit, NULL, NULL, NULL, "$Revis
static int
_modinit(void)
{
extban_table['j'] = eb_canjoin;
extban_table['j'] = eb_canjoin;
return 0;
return 0;
}
static void
_moddeinit(void)
{
extban_table['j'] = NULL;
extban_table['j'] = NULL;
}
static int eb_canjoin(const char *data, struct Client *client_p,
struct Channel *chptr, long mode_type)
struct Channel *chptr, long mode_type)
{
struct Channel *chptr2;
int ret;
static int recurse = 0;
struct Channel *chptr2;
int ret;
static int recurse = 0;
(void)mode_type;
/* don't process a $j in a $j'ed list */
if (recurse)
return EXTBAN_INVALID;
if (data == NULL)
return EXTBAN_INVALID;
chptr2 = find_channel(data);
/* must exist, and no point doing this with the same channel */
if (chptr2 == NULL || chptr2 == chptr)
return EXTBAN_INVALID;
/* require consistent target */
if (chptr->chname[0] == '#' && data[0] == '&')
return EXTBAN_INVALID;
/* this allows getting some information about ban exceptions
* but +s/+p doesn't seem the right criterion */
(void)mode_type;
/* don't process a $j in a $j'ed list */
if (recurse)
return EXTBAN_INVALID;
if (data == NULL)
return EXTBAN_INVALID;
chptr2 = find_channel(data);
/* must exist, and no point doing this with the same channel */
if (chptr2 == NULL || chptr2 == chptr)
return EXTBAN_INVALID;
/* require consistent target */
if (chptr->chname[0] == '#' && data[0] == '&')
return EXTBAN_INVALID;
/* this allows getting some information about ban exceptions
* but +s/+p doesn't seem the right criterion */
#if 0
/* privacy! don't allow +s/+p channels to influence another channel */
if (!PubChannel(chptr2))
return EXTBAN_INVALID;
/* privacy! don't allow +s/+p channels to influence another channel */
if (!PubChannel(chptr2))
return EXTBAN_INVALID;
#endif
recurse = 1;
ret = is_banned(chptr2, client_p, NULL, NULL, NULL) == CHFL_BAN ? EXTBAN_MATCH : EXTBAN_NOMATCH;
recurse = 0;
return ret;
recurse = 1;
ret = is_banned(chptr2, client_p, NULL, NULL, NULL) == CHFL_BAN ? EXTBAN_MATCH : EXTBAN_NOMATCH;
recurse = 0;
return ret;
}

View File

@ -20,34 +20,34 @@ DECLARE_MODULE_AV1(extb_channel, _modinit, _moddeinit, NULL, NULL, NULL, "$Revis
static int
_modinit(void)
{
extban_table['c'] = eb_channel;
extban_table['c'] = eb_channel;
return 0;
return 0;
}
static void
_moddeinit(void)
{
extban_table['c'] = NULL;
extban_table['c'] = NULL;
}
static int eb_channel(const char *data, struct Client *client_p,
struct Channel *chptr, long mode_type)
struct Channel *chptr, long mode_type)
{
struct Channel *chptr2;
struct Channel *chptr2;
(void)chptr;
(void)mode_type;
if (data == NULL)
return EXTBAN_INVALID;
chptr2 = find_channel(data);
if (chptr2 == NULL)
return EXTBAN_INVALID;
/* require consistent target */
if (chptr->chname[0] == '#' && data[0] == '&')
return EXTBAN_INVALID;
/* privacy! don't allow +s/+p channels to influence another channel */
if (!PubChannel(chptr2))
return EXTBAN_INVALID;
return IsMember(client_p, chptr2) ? EXTBAN_MATCH : EXTBAN_NOMATCH;
(void)chptr;
(void)mode_type;
if (data == NULL)
return EXTBAN_INVALID;
chptr2 = find_channel(data);
if (chptr2 == NULL)
return EXTBAN_INVALID;
/* require consistent target */
if (chptr->chname[0] == '#' && data[0] == '&')
return EXTBAN_INVALID;
/* privacy! don't allow +s/+p channels to influence another channel */
if (!PubChannel(chptr2))
return EXTBAN_INVALID;
return IsMember(client_p, chptr2) ? EXTBAN_MATCH : EXTBAN_NOMATCH;
}

View File

@ -19,39 +19,40 @@ DECLARE_MODULE_AV1(extb_extended, _modinit, _moddeinit, NULL, NULL, NULL, "$Revi
static int
_modinit(void)
{
extban_table['x'] = eb_extended;
extban_table['x'] = eb_extended;
return 0;
return 0;
}
static void
_moddeinit(void)
{
extban_table['x'] = NULL;
extban_table['x'] = NULL;
}
static int eb_extended(const char *data, struct Client *client_p,
struct Channel *chptr, long mode_type)
struct Channel *chptr, long mode_type)
{
char buf[BUFSIZE];
int ret;
char buf[BUFSIZE];
int ret;
(void)chptr;
(void)chptr;
if (data == NULL)
return EXTBAN_INVALID;
if (data == NULL)
return EXTBAN_INVALID;
snprintf(buf, BUFSIZE, "%s!%s@%s#%s",
client_p->name, client_p->username, client_p->host, client_p->info);
rb_snprintf(buf, BUFSIZE, "%s!%s@%s#%s",
client_p->name, client_p->username, client_p->host, client_p->info);
ret = match(data, buf) ? EXTBAN_MATCH : EXTBAN_NOMATCH;
ret = match(data, buf) ? EXTBAN_MATCH : EXTBAN_NOMATCH;
if (ret == EXTBAN_NOMATCH && IsDynSpoof(client_p)) {
snprintf(buf, BUFSIZE, "%s!%s@%s#%s",
client_p->name, client_p->username, client_p->orighost, client_p->info);
if (ret == EXTBAN_NOMATCH && IsDynSpoof(client_p))
{
rb_snprintf(buf, BUFSIZE, "%s!%s@%s#%s",
client_p->name, client_p->username, client_p->orighost, client_p->info);
ret = match(data, buf) ? EXTBAN_MATCH : EXTBAN_NOMATCH;
}
ret = match(data, buf) ? EXTBAN_MATCH : EXTBAN_NOMATCH;
}
return ret;
return ret;
}

View File

@ -18,26 +18,26 @@ DECLARE_MODULE_AV1(extb_oper, _modinit, _moddeinit, NULL, NULL, NULL, "$Revision
static int
_modinit(void)
{
extban_table['o'] = eb_oper;
extban_table['o'] = eb_oper;
return 0;
return 0;
}
static void
_moddeinit(void)
{
extban_table['o'] = NULL;
extban_table['o'] = NULL;
}
static int eb_oper(const char *data, struct Client *client_p,
struct Channel *chptr, long mode_type)
struct Channel *chptr, long mode_type)
{
(void)chptr;
(void)mode_type;
/* perhaps use data somehow? (opernick/flags?) */
/* so deny any bans with data for now */
if (data != NULL)
return EXTBAN_INVALID;
return IsOper(client_p) ? EXTBAN_MATCH : EXTBAN_NOMATCH;
(void)chptr;
(void)mode_type;
/* perhaps use data somehow? (opernick/flags?) */
/* so deny any bans with data for now */
if (data != NULL)
return EXTBAN_INVALID;
return IsOper(client_p) ? EXTBAN_MATCH : EXTBAN_NOMATCH;
}

View File

@ -18,26 +18,26 @@ DECLARE_MODULE_AV1(extb_realname, _modinit, _moddeinit, NULL, NULL, NULL, "$Revi
static int
_modinit(void)
{
extban_table['r'] = eb_realname;
extban_table['r'] = eb_realname;
return 0;
return 0;
}
static void
_moddeinit(void)
{
extban_table['r'] = NULL;
extban_table['r'] = NULL;
}
static int eb_realname(const char *data, struct Client *client_p,
struct Channel *chptr, long mode_type)
struct Channel *chptr, long mode_type)
{
(void)chptr;
/* This type is not safe for exceptions */
if (mode_type == CHFL_EXCEPTION || mode_type == CHFL_INVEX)
return EXTBAN_INVALID;
if (data == NULL)
return EXTBAN_INVALID;
return match(data, client_p->info) ? EXTBAN_MATCH : EXTBAN_NOMATCH;
(void)chptr;
/* This type is not safe for exceptions */
if (mode_type == CHFL_EXCEPTION || mode_type == CHFL_INVEX)
return EXTBAN_INVALID;
if (data == NULL)
return EXTBAN_INVALID;
return match(data, client_p->info) ? EXTBAN_MATCH : EXTBAN_NOMATCH;
}

View File

@ -18,26 +18,26 @@ DECLARE_MODULE_AV1(extb_server, _modinit, _moddeinit, NULL, NULL, NULL, "$Revisi
static int
_modinit(void)
{
extban_table['s'] = eb_server;
extban_table['s'] = eb_server;
return 0;
return 0;
}
static void
_moddeinit(void)
{
extban_table['s'] = NULL;
extban_table['s'] = NULL;
}
static int eb_server(const char *data, struct Client *client_p,
struct Channel *chptr, long mode_type)
struct Channel *chptr, long mode_type)
{
(void)chptr;
/* This type is not safe for exceptions */
if (mode_type == CHFL_EXCEPTION || mode_type == CHFL_INVEX)
return EXTBAN_INVALID;
if (data == NULL)
return EXTBAN_INVALID;
return match(data, me.name) ? EXTBAN_MATCH : EXTBAN_NOMATCH;
(void)chptr;
/* This type is not safe for exceptions */
if (mode_type == CHFL_EXCEPTION || mode_type == CHFL_INVEX)
return EXTBAN_INVALID;
if (data == NULL)
return EXTBAN_INVALID;
return match(data, me.name) ? EXTBAN_MATCH : EXTBAN_NOMATCH;
}

View File

@ -14,24 +14,24 @@ DECLARE_MODULE_AV1(extb_ssl, _modinit, _moddeinit, NULL, NULL, NULL, "$Revision$
static int
_modinit(void)
{
extban_table['z'] = eb_ssl;
extban_table['z'] = eb_ssl;
return 0;
return 0;
}
static void
_moddeinit(void)
{
extban_table['z'] = NULL;
extban_table['z'] = NULL;
}
static int eb_ssl(const char *data, struct Client *client_p,
struct Channel *chptr, long mode_type)
struct Channel *chptr, long mode_type)
{
(void)chptr;
(void)mode_type;
if (data != NULL)
return EXTBAN_INVALID;
return IsSSLClient(client_p) ? EXTBAN_MATCH : EXTBAN_NOMATCH;
(void)chptr;
(void)mode_type;
if (data != NULL)
return EXTBAN_INVALID;
return IsSSLClient(client_p) ? EXTBAN_MATCH : EXTBAN_NOMATCH;
}

View File

@ -18,8 +18,8 @@
static void h_noi_umode_changed(hook_data_umode_changed *);
mapi_hfn_list_av1 noi_hfnlist[] = {
{ "umode_changed", (hookfn) h_noi_umode_changed },
{ NULL, NULL }
{ "umode_changed", (hookfn) h_noi_umode_changed },
{ NULL, NULL }
};
DECLARE_MODULE_AV1(force_user_invis, NULL, NULL, NULL, NULL, noi_hfnlist, "1.0.0");
@ -27,9 +27,9 @@ DECLARE_MODULE_AV1(force_user_invis, NULL, NULL, NULL, NULL, noi_hfnlist, "1.0.0
static void
h_noi_umode_changed(hook_data_umode_changed *hdata)
{
struct Client *source_p = hdata->client;
struct Client *source_p = hdata->client;
if (MyClient(source_p) && !IsOper(source_p) && !IsInvisible(source_p)) {
SetInvisible(source_p);
}
if (MyClient(source_p) && !IsOper(source_p) && !IsInvisible(source_p)) {
SetInvisible(source_p);
}
}

View File

@ -23,25 +23,25 @@
#define HURT_EXIT_REASON "Hurt: Failed to identify to services"
enum {
HEAL_NICK = 0,
HEAL_IP
HEAL_NICK = 0,
HEAL_IP
};
typedef struct _hurt_state {
time_t start_time;
uint32_t n_hurts;
rb_dlink_list hurt_clients;
uint16_t cutoff;
time_t default_expire;
const char *exit_reason;
time_t start_time;
uint32_t n_hurts;
rb_dlink_list hurt_clients;
uint16_t cutoff;
time_t default_expire;
const char *exit_reason;
} hurt_state_t;
typedef struct _hurt {
char *ip;
struct sockaddr *saddr;
int saddr_bits;
char *reason;
time_t expire;
char *ip;
struct sockaddr *saddr;
int saddr_bits;
char *reason;
time_t expire;
} hurt_t;
/* }}} */
@ -82,45 +82,45 @@ rb_dlink_list hurt_confs = { NULL, NULL, 0 };
/* {{{ Messages */
struct Message hurt_msgtab = {
"HURT", 0, 0, 0, MFLG_SLOW, {
mg_ignore, mg_ignore, mg_ignore,
mg_ignore, {me_hurt, 0}, {mo_hurt, 3}
}
"HURT", 0, 0, 0, MFLG_SLOW, {
mg_ignore, mg_ignore, mg_ignore,
mg_ignore, {me_hurt, 0}, {mo_hurt, 3}
}
};
struct Message heal_msgtab = {
"HEAL", 0, 0, 0, MFLG_SLOW, {
mg_ignore, mg_ignore, mg_ignore,
mg_ignore, {me_heal, 0}, {mo_heal, 2}
}
"HEAL", 0, 0, 0, MFLG_SLOW, {
mg_ignore, mg_ignore, mg_ignore,
mg_ignore, {me_heal, 0}, {mo_heal, 2}
}
};
/* }}} */
/* {{{ Misc module stuff */
mapi_hfn_list_av1 hurt_hfnlist[] = {
{"client_exit", (hookfn) client_exit_hook},
{"new_local_user", (hookfn) new_local_user_hook},
{"doing_stats", (hookfn) doing_stats_hook},
{NULL, NULL},
{"client_exit", (hookfn) client_exit_hook},
{"new_local_user", (hookfn) new_local_user_hook},
{"doing_stats", (hookfn) doing_stats_hook},
{NULL, NULL},
};
mapi_clist_av1 hurt_clist[] = { &hurt_msgtab, &heal_msgtab, NULL };
DECLARE_MODULE_AV1(
hurt,
modinit,
modfini,
hurt_clist,
NULL,
hurt_hfnlist,
"$Revision: 3161 $"
hurt,
modinit,
modfini,
hurt_clist,
NULL,
hurt_hfnlist,
"$Revision: 3161 $"
);
/* }}} */
hurt_state_t hurt_state = {
.cutoff = HURT_CUTOFF,
.default_expire = HURT_DEFAULT_EXPIRE,
.exit_reason = HURT_EXIT_REASON,
.cutoff = HURT_CUTOFF,
.default_expire = HURT_DEFAULT_EXPIRE,
.exit_reason = HURT_EXIT_REASON,
};
/*
@ -135,14 +135,14 @@ struct ev_entry *hurt_check_ev = NULL;
static int
modinit(void)
{
/* set-up hurt_state. */
hurt_state.start_time = rb_current_time();
/* set-up hurt_state. */
hurt_state.start_time = rb_current_time();
/* add our event handlers. */
hurt_expire_ev = rb_event_add("hurt_expire", hurt_expire_event, NULL, 60);
hurt_check_ev = rb_event_add("hurt_check", hurt_check_event, NULL, 5);
/* add our event handlers. */
hurt_expire_ev = rb_event_add("hurt_expire", hurt_expire_event, NULL, 60);
hurt_check_ev = rb_event_add("hurt_check", hurt_check_event, NULL, 5);
return 0;
return 0;
}
/* }}} */
@ -150,15 +150,16 @@ modinit(void)
static void
modfini(void)
{
rb_dlink_node *ptr, *next_ptr;
rb_dlink_node *ptr, *next_ptr;
/* and delete our events. */
rb_event_delete(hurt_expire_ev);
rb_event_delete(hurt_check_ev);
/* and delete our events. */
rb_event_delete(hurt_expire_ev);
rb_event_delete(hurt_check_ev);
RB_DLINK_FOREACH_SAFE (ptr, next_ptr, hurt_state.hurt_clients.head) {
rb_dlinkDestroy(ptr, &hurt_state.hurt_clients);
}
RB_DLINK_FOREACH_SAFE (ptr, next_ptr, hurt_state.hurt_clients.head)
{
rb_dlinkDestroy(ptr, &hurt_state.hurt_clients);
}
}
/* }}} */
@ -169,79 +170,84 @@ modfini(void)
/* {{{ static int mo_hurt()
*
* HURT [<expire>] <ip> <reason>
*
*
* parv[1] - expire or ip
* parv[2] - ip or reason
* parv[3] - reason or NULL
*/
static int
mo_hurt(struct Client *client_p, struct Client *source_p,
int parc, const char **parv)
int parc, const char **parv)
{
const char *ip, *expire, *reason;
int expire_time;
hurt_t *hurt;
struct Client *target_p;
const char *ip, *expire, *reason;
int expire_time;
hurt_t *hurt;
struct Client *target_p;
if (!IsOperK(source_p)) {
sendto_one(source_p, form_str(ERR_NOPRIVS), me.name,
source_p->name, "kline");
return 0;
}
if (!IsOperK(source_p)) {
sendto_one(source_p, form_str(ERR_NOPRIVS), me.name,
source_p->name, "kline");
return 0;
}
if (parc == 3)
expire = NULL, ip = parv[1], reason = parv[2];
else
expire = parv[1], ip = parv[2], reason = parv[3];
if (parc == 3)
expire = NULL, ip = parv[1], reason = parv[2];
else
expire = parv[1], ip = parv[2], reason = parv[3];
if (!expire)
expire_time = HURT_DEFAULT_EXPIRE;
if (expire && (expire_time = valid_temp_time(expire)) < 1) {
sendto_one_notice(source_p, ":Permanent HURTs are not supported");
return 0;
}
if (EmptyString(reason)) {
sendto_one_notice(source_p, ":Empty HURT reasons are bad for business");
return 0;
}
if (!expire)
expire_time = HURT_DEFAULT_EXPIRE;
if (expire && (expire_time = valid_temp_time(expire)) < 1) {
sendto_one_notice(source_p, ":Permanent HURTs are not supported");
return 0;
}
if (EmptyString(reason)) {
sendto_one_notice(source_p, ":Empty HURT reasons are bad for business");
return 0;
}
/* Is this a client? */
if (strchr(ip, '.') == NULL && strchr(ip, ':') == NULL) {
target_p = find_named_person(ip);
if (target_p == NULL) {
sendto_one_numeric(source_p, ERR_NOSUCHNICK,
form_str(ERR_NOSUCHNICK), ip);
return 0;
}
ip = target_p->orighost;
} else {
if (!strncmp(ip, "*@", 2))
ip += 2;
if (strchr(ip, '!') || strchr(ip, '@')) {
sendto_one_notice(source_p, ":Invalid HURT mask [%s]",
ip);
return 0;
}
}
/* Is this a client? */
if (strchr(ip, '.') == NULL && strchr(ip, ':') == NULL)
{
target_p = find_named_person(ip);
if (target_p == NULL)
{
sendto_one_numeric(source_p, ERR_NOSUCHNICK,
form_str(ERR_NOSUCHNICK), ip);
return 0;
}
ip = target_p->orighost;
}
else
{
if (!strncmp(ip, "*@", 2))
ip += 2;
if (strchr(ip, '!') || strchr(ip, '@'))
{
sendto_one_notice(source_p, ":Invalid HURT mask [%s]",
ip);
return 0;
}
}
if (hurt_find(ip) != NULL) {
sendto_one(source_p, ":[%s] already HURT", ip);
return 0;
}
if (hurt_find(ip) != NULL) {
sendto_one(source_p, ":[%s] already HURT", ip);
return 0;
}
/*
* okay, we've got this far, now it's time to add the the HURT locally
* and propagate it to other servers on the network.
*/
sendto_realops_snomask(SNO_GENERAL, L_ALL,
"%s added HURT on [%s] for %ld minutes with reason [%s]",
get_oper_name(source_p), ip, (long) expire_time / 60, reason);
/*
* okay, we've got this far, now it's time to add the the HURT locally
* and propagate it to other servers on the network.
*/
sendto_realops_snomask(SNO_GENERAL, L_ALL,
"%s added HURT on [%s] for %ld minutes with reason [%s]",
get_oper_name(source_p), ip, (long) expire_time / 60, reason);
hurt = hurt_new(expire_time, ip, reason);
hurt_add(hurt);
hurt_propagate(NULL, source_p, hurt);
hurt = hurt_new(expire_time, ip, reason);
hurt_add(hurt);
hurt_propagate(NULL, source_p, hurt);
return 0;
return 0;
}
/* }}} */
@ -255,32 +261,32 @@ mo_hurt(struct Client *client_p, struct Client *source_p,
*/
static int
me_hurt(struct Client *client_p, struct Client *source_p,
int parc, const char **parv)
int parc, const char **parv)
{
time_t expire_time;
hurt_t *hurt;
time_t expire_time;
hurt_t *hurt;
/*
* right... if we don't get enough arguments, or if we get any invalid
* arguments, just ignore this request - shit happens, and it's not worth
* dropping a server over.
*/
if (parc < 4 || !IsPerson(source_p))
return 0;
if ((expire_time = atoi(parv[1])) < 1)
return 0;
if (hurt_find(parv[2]) != NULL)
return 0;
if (EmptyString(parv[3]))
return 0;
/*
* right... if we don't get enough arguments, or if we get any invalid
* arguments, just ignore this request - shit happens, and it's not worth
* dropping a server over.
*/
if (parc < 4 || !IsPerson(source_p))
return 0;
if ((expire_time = atoi(parv[1])) < 1)
return 0;
if (hurt_find(parv[2]) != NULL)
return 0;
if (EmptyString(parv[3]))
return 0;
sendto_realops_snomask(SNO_GENERAL, L_ALL,
"%s added HURT on [%s] for %ld minutes with reason [%s]",
get_oper_name(source_p), parv[2], (long) expire_time / 60, parv[3]);
hurt = hurt_new(expire_time, parv[2], parv[3]);
hurt_add(hurt);
sendto_realops_snomask(SNO_GENERAL, L_ALL,
"%s added HURT on [%s] for %ld minutes with reason [%s]",
get_oper_name(source_p), parv[2], (long) expire_time / 60, parv[3]);
hurt = hurt_new(expire_time, parv[2], parv[3]);
hurt_add(hurt);
return 0;
return 0;
}
/* }}} */
@ -292,76 +298,88 @@ me_hurt(struct Client *client_p, struct Client *source_p,
*/
static int
mo_heal(struct Client *client_p, struct Client *source_p,
int parc, const char **parv)
int parc, const char **parv)
{
struct Client *target_p;
struct Client *target_p;
if (!IsOperUnkline(source_p)) {
sendto_one(source_p, form_str(ERR_NOPRIVS),
me.name, source_p->name, "unkline");
return 0;
}
if (!IsOperUnkline(source_p))
{
sendto_one(source_p, form_str(ERR_NOPRIVS),
me.name, source_p->name, "unkline");
return 0;
}
if (nick_is_valid(parv[1])) {
target_p = find_named_person(parv[1]);
if (target_p == NULL) {
sendto_one_numeric(source_p, ERR_NOSUCHNICK,
form_str(ERR_NOSUCHNICK), parv[1]);
return 0;
}
if (MyConnect(target_p))
heal_nick(source_p, target_p);
else
sendto_one(target_p, ":%s ENCAP %s HEAL %s",
get_id(source_p, target_p),
target_p->servptr->name,
get_id(target_p, target_p));
} else if (strchr(parv[1], '.')) {
if (hurt_find_exact(parv[1]) == NULL) {
sendto_one_notice(source_p, ":Mask [%s] is not HURT", parv[1]);
return 0;
}
hurt_remove(parv[1]);
sendto_realops_snomask(SNO_GENERAL, L_ALL, "%s removed HURT on %s",
get_oper_name(source_p), parv[1]);
sendto_server(NULL, NULL, NOCAPS, NOCAPS, ":%s ENCAP * HEAL %s",
source_p->name, parv[1]);
} else {
sendto_one(source_p, ":[%s] is not a valid IP address/nick", parv[1]);
return 0;
}
if (nick_is_valid(parv[1]))
{
target_p = find_named_person(parv[1]);
if (target_p == NULL)
{
sendto_one_numeric(source_p, ERR_NOSUCHNICK,
form_str(ERR_NOSUCHNICK), parv[1]);
return 0;
}
if (MyConnect(target_p))
heal_nick(source_p, target_p);
else
sendto_one(target_p, ":%s ENCAP %s HEAL %s",
get_id(source_p, target_p),
target_p->servptr->name,
get_id(target_p, target_p));
}
else if (strchr(parv[1], '.'))
{
if (hurt_find_exact(parv[1]) == NULL)
{
sendto_one_notice(source_p, ":Mask [%s] is not HURT", parv[1]);
return 0;
}
hurt_remove(parv[1]);
sendto_realops_snomask(SNO_GENERAL, L_ALL, "%s removed HURT on %s",
get_oper_name(source_p), parv[1]);
sendto_server(NULL, NULL, NOCAPS, NOCAPS, ":%s ENCAP * HEAL %s",
source_p->name, parv[1]);
}
else
{
sendto_one(source_p, ":[%s] is not a valid IP address/nick", parv[1]);
return 0;
}
return 0;
return 0;
}
/* }}} */
static int
me_heal(struct Client *client_p, struct Client *source_p,
int parc, const char **parv)
int parc, const char **parv)
{
struct Client *target_p;
struct Client *target_p;
/* as noted in me_hurt(), if we don't get sufficient arguments...
* *poof*, it's dropped...
*/
if (parc < 2)
return 0;
/* as noted in me_hurt(), if we don't get sufficient arguments...
* *poof*, it's dropped...
*/
if (parc < 2)
return 0;
if (nick_is_valid(parv[1])) {
target_p = find_person(parv[1]);
if (target_p != NULL && MyConnect(target_p))
heal_nick(source_p, target_p);
} else if (strchr(parv[1], '.')) { /* host or mask to remove ban for */
if (hurt_find_exact(parv[1]) == NULL)
return 0;
if (nick_is_valid(parv[1]))
{
target_p = find_person(parv[1]);
if (target_p != NULL && MyConnect(target_p))
heal_nick(source_p, target_p);
}
else if (strchr(parv[1], '.')) /* host or mask to remove ban for */
{
if (hurt_find_exact(parv[1]) == NULL)
return 0;
hurt_remove(parv[1]);
sendto_realops_snomask(SNO_GENERAL, L_ALL, "%s removed HURT on %s",
get_oper_name(source_p), parv[1]);
} else
return 0;
hurt_remove(parv[1]);
sendto_realops_snomask(SNO_GENERAL, L_ALL, "%s removed HURT on %s",
get_oper_name(source_p), parv[1]);
}
else
return 0;
return 0;
return 0;
}
/*
@ -372,18 +390,20 @@ me_heal(struct Client *client_p, struct Client *source_p,
static void
hurt_check_event(void *arg)
{
rb_dlink_node *ptr, *next_ptr;
struct Client *client_p;
rb_dlink_node *ptr, *next_ptr;
struct Client *client_p;
RB_DLINK_FOREACH_SAFE (ptr, next_ptr, hurt_state.hurt_clients.head) {
client_p = ptr->data;
if (!EmptyString(client_p->user->suser)) {
rb_dlinkDestroy(ptr, &hurt_state.hurt_clients);
sendto_one_notice(client_p, ":HURT restriction removed for this session");
client_p->localClient->target_last = rb_current_time(); /* don't ask --nenolod */
} else if (client_p->localClient->receiveM > hurt_state.cutoff)
exit_client(NULL, client_p, &me, hurt_state.exit_reason);
}
RB_DLINK_FOREACH_SAFE (ptr, next_ptr, hurt_state.hurt_clients.head) {
client_p = ptr->data;
if (!EmptyString(client_p->user->suser))
{
rb_dlinkDestroy(ptr, &hurt_state.hurt_clients);
sendto_one_notice(client_p, ":HURT restriction removed for this session");
client_p->localClient->target_last = rb_current_time(); /* don't ask --nenolod */
}
else if (client_p->localClient->receiveM > hurt_state.cutoff)
exit_client(NULL, client_p, &me, hurt_state.exit_reason);
}
}
/* }}} */
@ -391,17 +411,19 @@ hurt_check_event(void *arg)
static void
hurt_expire_event(void *unused)
{
rb_dlink_node *ptr, *next_ptr;
hurt_t *hurt;
rb_dlink_node *ptr, *next_ptr;
hurt_t *hurt;
RB_DLINK_FOREACH_SAFE (ptr, next_ptr, hurt_confs.head) {
hurt = (hurt_t *) ptr->data;
RB_DLINK_FOREACH_SAFE (ptr, next_ptr, hurt_confs.head)
{
hurt = (hurt_t *) ptr->data;
if (hurt->expire <= rb_current_time()) {
rb_dlinkFindDestroy(hurt, &hurt_confs);
hurt_destroy(hurt);
}
}
if (hurt->expire <= rb_current_time())
{
rb_dlinkFindDestroy(hurt, &hurt_confs);
hurt_destroy(hurt);
}
}
}
/* }}} */
@ -413,10 +435,10 @@ hurt_expire_event(void *unused)
static void
client_exit_hook(hook_data_client_exit *data)
{
s_assert(data != NULL);
s_assert(data->target != NULL);
s_assert(data != NULL);
s_assert(data->target != NULL);
rb_dlinkFindDestroy(data->target, &hurt_state.hurt_clients);
rb_dlinkFindDestroy(data->target, &hurt_state.hurt_clients);
}
/* }}} */
@ -424,16 +446,17 @@ client_exit_hook(hook_data_client_exit *data)
static void
new_local_user_hook(struct Client *source_p)
{
if (IsAnyDead(source_p) || !EmptyString(source_p->user->suser) ||
IsExemptKline(source_p))
return;
if (IsAnyDead(source_p) || !EmptyString(source_p->user->suser) ||
IsExemptKline(source_p))
return;
if (hurt_find(source_p->sockhost) || hurt_find(source_p->orighost)) {
source_p->localClient->target_last = rb_current_time() + 600; /* don't ask --nenolod */
SetTGChange(source_p);
rb_dlinkAddAlloc(source_p, &hurt_state.hurt_clients);
sendto_one_notice(source_p, ":You are hurt. Please identify to services immediately, or use /stats p for assistance.");
}
if (hurt_find(source_p->sockhost) || hurt_find(source_p->orighost))
{
source_p->localClient->target_last = rb_current_time() + 600; /* don't ask --nenolod */
SetTGChange(source_p);
rb_dlinkAddAlloc(source_p, &hurt_state.hurt_clients);
sendto_one_notice(source_p, ":You are hurt. Please identify to services immediately, or use /stats p for assistance.");
}
}
/* }}} */
@ -441,43 +464,47 @@ new_local_user_hook(struct Client *source_p)
static void
doing_stats_hook(hook_data_int *hdata)
{
rb_dlink_node *ptr;
hurt_t *hurt;
struct Client *source_p;
rb_dlink_node *ptr;
hurt_t *hurt;
struct Client *source_p;
s_assert(hdata);
s_assert(hdata->client);
s_assert(hdata);
s_assert(hdata->client);
source_p = hdata->client;
if(hdata->arg2 != (int) 's')
return;
if((ConfigFileEntry.stats_k_oper_only == 2) && !IsOper(source_p))
return;
if ((ConfigFileEntry.stats_k_oper_only == 1) && !IsOper(source_p)) {
hurt = hurt_find(source_p->sockhost);
if (hurt != NULL) {
sendto_one_numeric(source_p, RPL_STATSKLINE,
form_str(RPL_STATSKLINE), 's',
"*", hurt->ip, hurt->reason, "", "");
return;
}
source_p = hdata->client;
if(hdata->arg2 != (int) 's')
return;
if((ConfigFileEntry.stats_k_oper_only == 2) && !IsOper(source_p))
return;
if ((ConfigFileEntry.stats_k_oper_only == 1) && !IsOper(source_p))
{
hurt = hurt_find(source_p->sockhost);
if (hurt != NULL)
{
sendto_one_numeric(source_p, RPL_STATSKLINE,
form_str(RPL_STATSKLINE), 's',
"*", hurt->ip, hurt->reason, "", "");
return;
}
hurt = hurt_find(source_p->orighost);
if (hurt != NULL) {
sendto_one_numeric(source_p, RPL_STATSKLINE,
form_str(RPL_STATSKLINE), 's',
"*", hurt->ip, hurt->reason, "", "");
return;
}
return;
}
hurt = hurt_find(source_p->orighost);
if (hurt != NULL)
{
sendto_one_numeric(source_p, RPL_STATSKLINE,
form_str(RPL_STATSKLINE), 's',
"*", hurt->ip, hurt->reason, "", "");
return;
}
return;
}
RB_DLINK_FOREACH(ptr, hurt_confs.head) {
hurt = (hurt_t *) ptr->data;
sendto_one_numeric(source_p, RPL_STATSKLINE,
form_str(RPL_STATSKLINE), 's',
"*", hurt->ip, hurt->reason, "", "");
}
RB_DLINK_FOREACH(ptr, hurt_confs.head)
{
hurt = (hurt_t *) ptr->data;
sendto_one_numeric(source_p, RPL_STATSKLINE,
form_str(RPL_STATSKLINE), 's',
"*", hurt->ip, hurt->reason, "", "");
}
}
/* }}} */
@ -491,18 +518,18 @@ doing_stats_hook(hook_data_int *hdata)
static void
hurt_propagate(struct Client *client_p, struct Client *source_p, hurt_t *hurt)
{
if (client_p)
sendto_one(client_p,
":%s ENCAP %s HURT %ld %s :%s",
source_p->name, client_p->name,
(long)(hurt->expire - rb_current_time()),
hurt->ip, hurt->reason);
else
sendto_server(&me, NULL, NOCAPS, NOCAPS,
":%s ENCAP * HURT %ld %s :%s",
source_p->name,
(long)(hurt->expire - rb_current_time()),
hurt->ip, hurt->reason);
if (client_p)
sendto_one(client_p,
":%s ENCAP %s HURT %ld %s :%s",
source_p->name, client_p->name,
(long)(hurt->expire - rb_current_time()),
hurt->ip, hurt->reason);
else
sendto_server(&me, NULL, NOCAPS, NOCAPS,
":%s ENCAP * HURT %ld %s :%s",
source_p->name,
(long)(hurt->expire - rb_current_time()),
hurt->ip, hurt->reason);
}
/* }}} */
@ -510,15 +537,15 @@ hurt_propagate(struct Client *client_p, struct Client *source_p, hurt_t *hurt)
static hurt_t *
hurt_new(time_t expire, const char *ip, const char *reason)
{
hurt_t *hurt;
hurt_t *hurt;
hurt = rb_malloc(sizeof(hurt_t));
hurt = rb_malloc(sizeof(hurt_t));
hurt->ip = rb_strdup(ip);
hurt->reason = rb_strdup(reason);
hurt->expire = rb_current_time() + expire;
hurt->ip = rb_strdup(ip);
hurt->reason = rb_strdup(reason);
hurt->expire = rb_current_time() + expire;
return hurt;
return hurt;
}
/* }}} */
@ -526,80 +553,85 @@ hurt_new(time_t expire, const char *ip, const char *reason)
static void
hurt_destroy(void *hurt)
{
hurt_t *h;
hurt_t *h;
if (!hurt)
return;
if (!hurt)
return;
h = (hurt_t *) hurt;
rb_free(h->ip);
rb_free(h->reason);
rb_free(h);
h = (hurt_t *) hurt;
rb_free(h->ip);
rb_free(h->reason);
rb_free(h);
}
/* }}} */
static void
hurt_add(hurt_t *hurt)
{
rb_dlinkAddAlloc(hurt, &hurt_confs);
rb_dlinkAddAlloc(hurt, &hurt_confs);
}
static hurt_t *
hurt_find_exact(const char *ip)
{
rb_dlink_node *ptr;
hurt_t *hurt;
rb_dlink_node *ptr;
hurt_t *hurt;
RB_DLINK_FOREACH(ptr, hurt_confs.head) {
hurt = (hurt_t *) ptr->data;
RB_DLINK_FOREACH(ptr, hurt_confs.head)
{
hurt = (hurt_t *) ptr->data;
if (!strcasecmp(ip, hurt->ip))
return hurt;
}
if (!strcasecmp(ip, hurt->ip))
return hurt;
}
return NULL;
return NULL;
}
static hurt_t *
hurt_find(const char *ip)
{
rb_dlink_node *ptr;
hurt_t *hurt;
rb_dlink_node *ptr;
hurt_t *hurt;
RB_DLINK_FOREACH(ptr, hurt_confs.head) {
hurt = (hurt_t *) ptr->data;
RB_DLINK_FOREACH(ptr, hurt_confs.head)
{
hurt = (hurt_t *) ptr->data;
if (match(hurt->ip, ip))
return hurt;
}
if (match(hurt->ip, ip))
return hurt;
}
return NULL;
return NULL;
}
static void
hurt_remove(const char *ip)
{
hurt_t *hurt = hurt_find_exact(ip);
hurt_t *hurt = hurt_find_exact(ip);
rb_dlinkFindDestroy(hurt, &hurt_confs);
hurt_destroy(hurt);
rb_dlinkFindDestroy(hurt, &hurt_confs);
hurt_destroy(hurt);
}
/* {{{ static int heal_nick() */
static int
heal_nick(struct Client *source_p, struct Client *target_p)
{
if (rb_dlinkFindDestroy(target_p, &hurt_state.hurt_clients)) {
sendto_realops_snomask(SNO_GENERAL, L_ALL, "%s used HEAL on %s",
get_oper_name(source_p), get_client_name(target_p, HIDE_IP));
sendto_one_notice(target_p, ":HURT restriction temporarily removed by operator");
sendto_one_notice(source_p, ":HURT restriction on %s temporarily removed", target_p->name);
target_p->localClient->target_last = rb_current_time(); /* don't ask --nenolod */
return 1;
} else {
sendto_one_notice(source_p, ":%s was not hurt", target_p->name);
return 0;
}
if (rb_dlinkFindDestroy(target_p, &hurt_state.hurt_clients))
{
sendto_realops_snomask(SNO_GENERAL, L_ALL, "%s used HEAL on %s",
get_oper_name(source_p), get_client_name(target_p, HIDE_IP));
sendto_one_notice(target_p, ":HURT restriction temporarily removed by operator");
sendto_one_notice(source_p, ":HURT restriction on %s temporarily removed", target_p->name);
target_p->localClient->target_last = rb_current_time(); /* don't ask --nenolod */
return 1;
}
else
{
sendto_one_notice(source_p, ":%s was not hurt", target_p->name);
return 0;
}
}
/* }}} */
@ -611,14 +643,14 @@ heal_nick(struct Client *source_p, struct Client *target_p)
static int
nick_is_valid(const char *nick)
{
const char *s = nick;
const char *s = nick;
for (; *s != '\0'; s++) {
if (!IsNickChar(*s))
return 0;
}
for (; *s != '\0'; s++) {
if (!IsNickChar(*s))
return 0;
}
return 1;
return 1;
}
/* }}} */

View File

@ -1,160 +0,0 @@
/*
* Charybdis: an advanced ircd
* ip_cloaking.c: provide user hostname cloaking
*
* Written originally by nenolod, altered to use FNV by Elizabeth in 2008
* altered some more by groente
*/
#include <openssl/hmac.h>
#include "stdinc.h"
#include "modules.h"
#include "hook.h"
#include "client.h"
#include "ircd.h"
#include "send.h"
#include "hash.h"
#include "s_conf.h"
#include "s_user.h"
#include "s_serv.h"
#include "numeric.h"
#include "newconf.h"
char *secretsalt = "32qwnqoWI@DpMd&w";
static void
conf_set_secretsalt(void *data)
{
secretsalt = rb_strdup(data);
}
static int
_modinit(void)
{
/* add the usermode to the available slot */
user_modes['x'] = find_umode_slot();
construct_umodebuf();
add_top_conf("cloaking", NULL, NULL, NULL);
add_conf_item("cloaking", "secretsalt", CF_QSTRING, conf_set_secretsalt);
return 0;
}
static void
_moddeinit(void)
{
/* disable the umode and remove it from the available list */
user_modes['x'] = 0;
construct_umodebuf();
add_top_conf("cloaking", NULL, NULL, NULL);
add_conf_item("cloaking", "secretsalt", CF_QSTRING, conf_set_secretsalt);
}
static void check_umode_change(void *data);
static void check_new_user(void *data);
mapi_hfn_list_av1 ip_cloaking_hfnlist[] = {
{ "umode_changed", (hookfn) check_umode_change },
{ "new_local_user", (hookfn) check_new_user },
{ NULL, NULL }
};
DECLARE_MODULE_AV1(ip_cloaking, _modinit, _moddeinit, NULL, NULL,
ip_cloaking_hfnlist, "$Revision: 3526 $");
static void
distribute_hostchange(struct Client *client_p, char *newhost)
{
if (newhost != client_p->orighost)
sendto_one_numeric(client_p, RPL_HOSTHIDDEN, "%s :is now your hidden host",
newhost);
else
sendto_one_numeric(client_p, RPL_HOSTHIDDEN, "%s :hostname reset",
newhost);
sendto_server(NULL, NULL,
CAP_EUID | CAP_TS6, NOCAPS, ":%s CHGHOST %s :%s",
use_id(&me), use_id(client_p), newhost);
sendto_server(NULL, NULL,
CAP_TS6, CAP_EUID, ":%s ENCAP * CHGHOST %s :%s",
use_id(&me), use_id(client_p), newhost);
change_nick_user_host(client_p, client_p->name, client_p->username, newhost, 0, "Changing host");
if (newhost != client_p->orighost)
SetDynSpoof(client_p);
else
ClearDynSpoof(client_p);
}
static void
do_host_cloak(const char *inbuf, char *outbuf)
{
unsigned char *hash;
char buf[3];
char output[HOSTLEN+1];
int i;
hash = HMAC(EVP_sha256(), secretsalt, strlen(secretsalt), (unsigned char*)inbuf, strlen(inbuf), NULL, NULL);
output[0]=0;
for (i = 0; i < 32; i++) {
sprintf(buf, "%.2x", hash[i]);
strcat(output,buf);
}
rb_strlcpy(outbuf,output,HOSTLEN+1);
}
static void
check_umode_change(void *vdata)
{
hook_data_umode_changed *data = (hook_data_umode_changed *)vdata;
struct Client *source_p = data->client;
if (!MyClient(source_p))
return;
/* didn't change +h umode, we don't need to do anything */
if (!((data->oldumodes ^ source_p->umodes) & user_modes['x']))
return;
if (source_p->umodes & user_modes['h']) {
if (IsIPSpoof(source_p) || source_p->localClient->mangledhost == NULL || (IsDynSpoof(source_p) && strcmp(source_p->host, source_p->localClient->mangledhost))) {
source_p->umodes &= ~user_modes['x'];
return;
}
if (strcmp(source_p->host, source_p->localClient->mangledhost)) {
distribute_hostchange(source_p, source_p->localClient->mangledhost);
} else /* not really nice, but we need to send this numeric here */
sendto_one_numeric(source_p, RPL_HOSTHIDDEN, "%s :is now your hidden host",
source_p->host);
} else if (!(source_p->umodes & user_modes['x'])) {
if (source_p->localClient->mangledhost != NULL &&
!strcmp(source_p->host, source_p->localClient->mangledhost)) {
distribute_hostchange(source_p, source_p->orighost);
}
}
}
static void
check_new_user(void *vdata)
{
struct Client *source_p = (void *)vdata;
if (IsIPSpoof(source_p)) {
source_p->umodes &= ~user_modes['x'];
return;
}
source_p->localClient->mangledhost = rb_malloc(HOSTLEN + 1);
do_host_cloak(source_p->orighost, source_p->localClient->mangledhost);
if (IsDynSpoof(source_p))
source_p->umodes &= ~user_modes['x'];
if (source_p->umodes & user_modes['x']) {
rb_strlcpy(source_p->host, source_p->localClient->mangledhost, sizeof(source_p->host));
if (irccmp(source_p->host, source_p->orighost))
SetDynSpoof(source_p);
}
}

View File

@ -1,4 +1,4 @@
/*
/*
* Charybdis: an advanced ircd
* ip_cloaking.c: provide user hostname cloaking
*
@ -20,191 +20,206 @@
static int
_modinit(void)
{
/* add the usermode to the available slot */
user_modes['x'] = find_umode_slot();
construct_umodebuf();
/* add the usermode to the available slot */
user_modes['x'] = find_umode_slot();
construct_umodebuf();
return 0;
return 0;
}
static void
_moddeinit(void)
{
/* disable the umode and remove it from the available list */
user_modes['x'] = 0;
construct_umodebuf();
/* disable the umode and remove it from the available list */
user_modes['x'] = 0;
construct_umodebuf();
}
static void check_umode_change(void *data);
static void check_new_user(void *data);
mapi_hfn_list_av1 ip_cloaking_hfnlist[] = {
{ "umode_changed", (hookfn) check_umode_change },
{ "new_local_user", (hookfn) check_new_user },
{ NULL, NULL }
{ "umode_changed", (hookfn) check_umode_change },
{ "new_local_user", (hookfn) check_new_user },
{ NULL, NULL }
};
DECLARE_MODULE_AV1(ip_cloaking, _modinit, _moddeinit, NULL, NULL,
ip_cloaking_hfnlist, "$Revision: 3526 $");
ip_cloaking_hfnlist, "$Revision: 3526 $");
static void
distribute_hostchange(struct Client *client_p, char *newhost)
{
if (newhost != client_p->orighost)
sendto_one_numeric(client_p, RPL_HOSTHIDDEN, "%s :is now your hidden host",
newhost);
else
sendto_one_numeric(client_p, RPL_HOSTHIDDEN, "%s :hostname reset",
newhost);
if (newhost != client_p->orighost)
sendto_one_numeric(client_p, RPL_HOSTHIDDEN, "%s :is now your hidden host",
newhost);
else
sendto_one_numeric(client_p, RPL_HOSTHIDDEN, "%s :hostname reset",
newhost);
sendto_server(NULL, NULL,
CAP_EUID | CAP_TS6, NOCAPS, ":%s CHGHOST %s :%s",
use_id(&me), use_id(client_p), newhost);
sendto_server(NULL, NULL,
CAP_TS6, CAP_EUID, ":%s ENCAP * CHGHOST %s :%s",
use_id(&me), use_id(client_p), newhost);
sendto_server(NULL, NULL,
CAP_EUID | CAP_TS6, NOCAPS, ":%s CHGHOST %s :%s",
use_id(&me), use_id(client_p), newhost);
sendto_server(NULL, NULL,
CAP_TS6, CAP_EUID, ":%s ENCAP * CHGHOST %s :%s",
use_id(&me), use_id(client_p), newhost);
change_nick_user_host(client_p, client_p->name, client_p->username, newhost, 0, "Changing host");
change_nick_user_host(client_p, client_p->name, client_p->username, newhost, 0, "Changing host");
if (newhost != client_p->orighost)
SetDynSpoof(client_p);
else
ClearDynSpoof(client_p);
if (newhost != client_p->orighost)
SetDynSpoof(client_p);
else
ClearDynSpoof(client_p);
}
static void
do_host_cloak_ip(const char *inbuf, char *outbuf)
{
/* None of the characters in this table can be valid in an IP */
char chartable[] = "ghijklmnopqrstuvwxyz";
char *tptr;
uint32_t accum = fnv_hash((const unsigned char*) inbuf, 32);
int sepcount = 0;
int totalcount = 0;
int ipv6 = 0;
/* None of the characters in this table can be valid in an IP */
char chartable[] = "ghijklmnopqrstuvwxyz";
char *tptr;
uint32_t accum = fnv_hash((const unsigned char*) inbuf, 32);
int sepcount = 0;
int totalcount = 0;
int ipv6 = 0;
rb_strlcpy(outbuf, inbuf, HOSTLEN + 1);
rb_strlcpy(outbuf, inbuf, HOSTLEN + 1);
if (strchr(outbuf, ':')) {
ipv6 = 1;
if (strchr(outbuf, ':'))
{
ipv6 = 1;
/* Damn you IPv6...
* We count the number of colons so we can calculate how much
* of the host to cloak. This is because some hostmasks may not
* have as many octets as we'd like.
*
* We have to do this ahead of time because doing this during
* the actual cloaking would get ugly
*/
for (tptr = outbuf; *tptr != '\0'; tptr++)
if (*tptr == ':')
totalcount++;
} else if (!strchr(outbuf, '.'))
return;
/* Damn you IPv6...
* We count the number of colons so we can calculate how much
* of the host to cloak. This is because some hostmasks may not
* have as many octets as we'd like.
*
* We have to do this ahead of time because doing this during
* the actual cloaking would get ugly
*/
for (tptr = outbuf; *tptr != '\0'; tptr++)
if (*tptr == ':')
totalcount++;
}
else if (!strchr(outbuf, '.'))
return;
for (tptr = outbuf; *tptr != '\0'; tptr++) {
if (*tptr == ':' || *tptr == '.') {
sepcount++;
continue;
}
for (tptr = outbuf; *tptr != '\0'; tptr++)
{
if (*tptr == ':' || *tptr == '.')
{
sepcount++;
continue;
}
if (ipv6 && sepcount < totalcount / 2)
continue;
if (ipv6 && sepcount < totalcount / 2)
continue;
if (!ipv6 && sepcount < 2)
continue;
if (!ipv6 && sepcount < 2)
continue;
*tptr = chartable[(*tptr + accum) % 20];
accum = (accum << 1) | (accum >> 31);
}
*tptr = chartable[(*tptr + accum) % 20];
accum = (accum << 1) | (accum >> 31);
}
}
static void
do_host_cloak_host(const char *inbuf, char *outbuf)
{
char b26_alphabet[] = "abcdefghijklmnopqrstuvwxyz";
char *tptr;
uint32_t accum = fnv_hash((const unsigned char*) inbuf, 32);
char b26_alphabet[] = "abcdefghijklmnopqrstuvwxyz";
char *tptr;
uint32_t accum = fnv_hash((const unsigned char*) inbuf, 32);
rb_strlcpy(outbuf, inbuf, HOSTLEN + 1);
rb_strlcpy(outbuf, inbuf, HOSTLEN + 1);
/* pass 1: scramble first section of hostname using base26
* alphabet toasted against the FNV hash of the string.
*
* numbers are not changed at this time, only letters.
*/
for (tptr = outbuf; *tptr != '\0'; tptr++) {
if (*tptr == '.')
break;
/* pass 1: scramble first section of hostname using base26
* alphabet toasted against the FNV hash of the string.
*
* numbers are not changed at this time, only letters.
*/
for (tptr = outbuf; *tptr != '\0'; tptr++)
{
if (*tptr == '.')
break;
if (isdigit(*tptr) || *tptr == '-')
continue;
if (isdigit(*tptr) || *tptr == '-')
continue;
*tptr = b26_alphabet[(*tptr + accum) % 26];
*tptr = b26_alphabet[(*tptr + accum) % 26];
/* Rotate one bit to avoid all digits being turned odd or even */
accum = (accum << 1) | (accum >> 31);
}
/* Rotate one bit to avoid all digits being turned odd or even */
accum = (accum << 1) | (accum >> 31);
}
/* pass 2: scramble each number in the address */
for (tptr = outbuf; *tptr != '\0'; tptr++) {
if (isdigit(*tptr))
*tptr = '0' + (*tptr + accum) % 10;
/* pass 2: scramble each number in the address */
for (tptr = outbuf; *tptr != '\0'; tptr++)
{
if (isdigit(*tptr))
*tptr = '0' + (*tptr + accum) % 10;
accum = (accum << 1) | (accum >> 31);
}
accum = (accum << 1) | (accum >> 31);
}
}
static void
check_umode_change(void *vdata)
{
hook_data_umode_changed *data = (hook_data_umode_changed *)vdata;
struct Client *source_p = data->client;
hook_data_umode_changed *data = (hook_data_umode_changed *)vdata;
struct Client *source_p = data->client;
if (!MyClient(source_p))
return;
if (!MyClient(source_p))
return;
/* didn't change +h umode, we don't need to do anything */
if (!((data->oldumodes ^ source_p->umodes) & user_modes['x']))
return;
/* didn't change +h umode, we don't need to do anything */
if (!((data->oldumodes ^ source_p->umodes) & user_modes['x']))
return;
if (source_p->umodes & user_modes['x']) {
if (IsIPSpoof(source_p) || source_p->localClient->mangledhost == NULL || (IsDynSpoof(source_p) && strcmp(source_p->host, source_p->localClient->mangledhost))) {
source_p->umodes &= ~user_modes['x'];
return;
}
if (strcmp(source_p->host, source_p->localClient->mangledhost)) {
distribute_hostchange(source_p, source_p->localClient->mangledhost);
} else /* not really nice, but we need to send this numeric here */
sendto_one_numeric(source_p, RPL_HOSTHIDDEN, "%s :is now your hidden host",
source_p->host);
} else if (!(source_p->umodes & user_modes['x'])) {
if (source_p->localClient->mangledhost != NULL &&
!strcmp(source_p->host, source_p->localClient->mangledhost)) {
distribute_hostchange(source_p, source_p->orighost);
}
}
if (source_p->umodes & user_modes['x'])
{
if (IsIPSpoof(source_p) || source_p->localClient->mangledhost == NULL || (IsDynSpoof(source_p) && strcmp(source_p->host, source_p->localClient->mangledhost)))
{
source_p->umodes &= ~user_modes['x'];
return;
}
if (strcmp(source_p->host, source_p->localClient->mangledhost))
{
distribute_hostchange(source_p, source_p->localClient->mangledhost);
}
else /* not really nice, but we need to send this numeric here */
sendto_one_numeric(source_p, RPL_HOSTHIDDEN, "%s :is now your hidden host",
source_p->host);
}
else if (!(source_p->umodes & user_modes['x']))
{
if (source_p->localClient->mangledhost != NULL &&
!strcmp(source_p->host, source_p->localClient->mangledhost))
{
distribute_hostchange(source_p, source_p->orighost);
}
}
}
static void
check_new_user(void *vdata)
{
struct Client *source_p = (void *)vdata;
struct Client *source_p = (void *)vdata;
if (IsIPSpoof(source_p)) {
source_p->umodes &= ~user_modes['x'];
return;
}
source_p->localClient->mangledhost = rb_malloc(HOSTLEN + 1);
if (!irccmp(source_p->orighost, source_p->sockhost))
do_host_cloak_ip(source_p->orighost, source_p->localClient->mangledhost);
else
do_host_cloak_host(source_p->orighost, source_p->localClient->mangledhost);
if (IsDynSpoof(source_p))
source_p->umodes &= ~user_modes['x'];
if (source_p->umodes & user_modes['x']) {
rb_strlcpy(source_p->host, source_p->localClient->mangledhost, sizeof(source_p->host));
if (irccmp(source_p->host, source_p->orighost))
SetDynSpoof(source_p);
}
if (IsIPSpoof(source_p))
{
source_p->umodes &= ~user_modes['x'];
return;
}
source_p->localClient->mangledhost = rb_malloc(HOSTLEN + 1);
if (!irccmp(source_p->orighost, source_p->sockhost))
do_host_cloak_ip(source_p->orighost, source_p->localClient->mangledhost);
else
do_host_cloak_host(source_p->orighost, source_p->localClient->mangledhost);
if (IsDynSpoof(source_p))
source_p->umodes &= ~user_modes['x'];
if (source_p->umodes & user_modes['x'])
{
rb_strlcpy(source_p->host, source_p->localClient->mangledhost, sizeof(source_p->host));
if (irccmp(source_p->host, source_p->orighost))
SetDynSpoof(source_p);
}
}

View File

@ -1,7 +1,7 @@
/*
* Copyright (C) infinity-infinity God <God@Heaven>
*
* Bob was here
* Bob was here
*/
#include "stdinc.h"
@ -13,10 +13,9 @@
static int mclient_42(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
struct Message hgtg_msgtab = {
"42", 0, 0, 0, MFLG_SLOW,
{
mg_ignore, {mclient_42, 0}, mg_ignore, mg_ignore, mg_ignore, {mclient_42, 0}
}
"42", 0, 0, 0, MFLG_SLOW,
{ mg_ignore, {mclient_42, 0}, mg_ignore, mg_ignore, mg_ignore, {mclient_42, 0}
}
};
mapi_clist_av1 hgtg_clist[] = { &hgtg_msgtab, NULL };
@ -28,8 +27,8 @@ DECLARE_MODULE_AV1(42, NULL, NULL, hgtg_clist, NULL, NULL, "Revision 0.42");
static int
mclient_42(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
sendto_one_notice(source_p, ":The Answer to Life, the Universe, and Everything.");
return 0;
sendto_one_notice(source_p, ":The Answer to Life, the Universe, and Everything.");
return 0;
}

View File

@ -41,10 +41,10 @@ static int mo_adminwall(struct Client *, struct Client *, int, const char **);
static int me_adminwall(struct Client *, struct Client *, int, const char **);
struct Message adminwall_msgtab = {
"ADMINWALL", 0, 0, 0, MFLG_SLOW,
{mg_unreg, mg_not_oper, mg_ignore, mg_ignore, {me_adminwall, 2}, {mo_adminwall, 2}}
"ADMINWALL", 0, 0, 0, MFLG_SLOW,
{mg_unreg, mg_not_oper, mg_ignore, mg_ignore, {me_adminwall, 2}, {mo_adminwall, 2}}
};
mapi_clist_av1 adminwall_clist[] = { &adminwall_msgtab, NULL };
DECLARE_MODULE_AV1(adminwall, NULL, NULL, adminwall_clist, NULL, NULL, "$Revision: 20702 $");
@ -56,21 +56,22 @@ DECLARE_MODULE_AV1(adminwall, NULL, NULL, adminwall_clist, NULL, NULL, "$Revisio
*/
static int
mo_adminwall(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
if(!IsAdmin(source_p)) {
sendto_one(source_p, form_str(ERR_NOPRIVS),
me.name, source_p->name, "adminwall");
mo_adminwall(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
if(!IsAdmin(source_p))
{
sendto_one(source_p, form_str(ERR_NOPRIVS),
me.name, source_p->name, "adminwall");
return 0;
}
sendto_wallops_flags(UMODE_ADMIN, source_p, "ADMINWALL - %s", parv[1]);
sendto_match_servs(source_p, "*", CAP_ENCAP, NOCAPS, "ENCAP * ADMINWALL :%s", parv[1]);
return 0;
}
sendto_wallops_flags(UMODE_ADMIN, source_p, "ADMINWALL - %s", parv[1]);
sendto_match_servs(source_p, "*", CAP_ENCAP, NOCAPS, "ENCAP * ADMINWALL :%s", parv[1]);
return 0;
}
}
static int
me_adminwall(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
sendto_wallops_flags(UMODE_ADMIN, source_p, "ADMINWALL - %s", parv[1]);
return 0;
me_adminwall(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
sendto_wallops_flags(UMODE_ADMIN, source_p, "ADMINWALL - %s", parv[1]);
return 0;
}

View File

@ -25,8 +25,8 @@ extern struct module **modlist;
static int m_cycle(struct Client *, struct Client *, int, const char **);
struct Message cycle_msgtab = {
"CYCLE", 0, 0, 0, MFLG_SLOW,
{mg_unreg, {m_cycle, 2}, {m_cycle, 2}, mg_ignore, mg_ignore, {m_cycle, 2}}
"CYCLE", 0, 0, 0, MFLG_SLOW,
{mg_unreg, {m_cycle, 2}, {m_cycle, 2}, mg_ignore, mg_ignore, {m_cycle, 2}}
};
mapi_clist_av1 cycle_clist[] = { &cycle_msgtab, NULL };
@ -35,58 +35,64 @@ DECLARE_MODULE_AV1(cycle, NULL, NULL, cycle_clist, NULL, NULL, "$Revision$");
static int
m_cycle(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
char *p, *name;
char *s = LOCAL_COPY(parv[1]);
struct Channel *chptr;
struct membership *msptr;
char *p, *name;
char *s = LOCAL_COPY(parv[1]);
struct Channel *chptr;
struct membership *msptr;
name = rb_strtok_r(s, ",", &p);
name = rb_strtok_r(s, ",", &p);
/* Finish the flood grace period... */
if(MyClient(source_p) && !IsFloodDone(source_p))
flood_endgrace(source_p);
/* Finish the flood grace period... */
if(MyClient(source_p) && !IsFloodDone(source_p))
flood_endgrace(source_p);
while(name) {
if((chptr = find_channel(name)) == NULL) {
sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL, form_str(ERR_NOSUCHCHANNEL), name);
return 0;
}
while(name)
{
if((chptr = find_channel(name)) == NULL)
{
sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL, form_str(ERR_NOSUCHCHANNEL), name);
return 0;
}
msptr = find_channel_membership(chptr, source_p);
if(msptr == NULL) {
sendto_one_numeric(source_p, ERR_NOTONCHANNEL, form_str(ERR_NOTONCHANNEL), name);
return 0;
}
msptr = find_channel_membership(chptr, source_p);
if(msptr == NULL)
{
sendto_one_numeric(source_p, ERR_NOTONCHANNEL, form_str(ERR_NOTONCHANNEL), name);
return 0;
}
if(MyConnect(source_p) && !IsOper(source_p) && !IsExemptSpambot(source_p))
check_spambot_warning(source_p, NULL);
if(MyConnect(source_p) && !IsOper(source_p) && !IsExemptSpambot(source_p))
check_spambot_warning(source_p, NULL);
if((is_any_op(msptr) || !MyConnect(source_p) ||
((can_send(chptr, source_p, msptr) > 0 &&
(source_p->localClient->firsttime +
ConfigFileEntry.anti_spam_exit_message_time) < rb_current_time()))))
{
sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
":%s PART %s :Cycling", use_id(source_p), chptr->chname);
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s PART %s :Cycling",
source_p->name, source_p->username,
source_p->host, chptr->chname);
}
else
{
sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
":%s PART %s", use_id(source_p), chptr->chname);
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s PART %s",
source_p->name, source_p->username,
source_p->host, chptr->chname);
}
remove_user_from_channel(msptr);
chptr = NULL;
msptr = NULL;
name = rb_strtok_r(NULL, ",", &p);
}
user_join(client_p, source_p, parv[1], parc > 2 ? parv[2] : NULL);
if((is_any_op(msptr) || !MyConnect(source_p) ||
((can_send(chptr, source_p, msptr) > 0 &&
(source_p->localClient->firsttime +
ConfigFileEntry.anti_spam_exit_message_time) < rb_current_time())))) {
sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
":%s PART %s :Cycling", use_id(source_p), chptr->chname);
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s PART %s :Cycling",
source_p->name, source_p->username,
source_p->host, chptr->chname);
} else {
sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
":%s PART %s", use_id(source_p), chptr->chname);
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s PART %s",
source_p->name, source_p->username,
source_p->host, chptr->chname);
}
remove_user_from_channel(msptr);
chptr = NULL;
msptr = NULL;
name = rb_strtok_r(NULL, ",", &p);
}
user_join(client_p, source_p, parv[1], parc > 2 ? parv[2] : NULL);
return 0;
return 0;
}

View File

@ -35,11 +35,11 @@
#include "packet.h"
static int m_findforwards(struct Client *client_p, struct Client *source_p,
int parc, const char *parv[]);
int parc, const char *parv[]);
struct Message findforwards_msgtab = {
"FINDFORWARDS", 0, 0, 0, MFLG_SLOW,
{mg_unreg, {m_findforwards, 2}, mg_ignore, mg_ignore, mg_ignore, {m_findforwards, 2}}
"FINDFORWARDS", 0, 0, 0, MFLG_SLOW,
{mg_unreg, {m_findforwards, 2}, mg_ignore, mg_ignore, mg_ignore, {m_findforwards, 2}}
};
mapi_clist_av1 findforwards_clist[] = { &findforwards_msgtab, NULL };
@ -53,54 +53,62 @@ DECLARE_MODULE_AV1(findforwards, NULL, NULL, findforwards_clist, NULL, NULL, "$R
static int
m_findforwards(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
static time_t last_used = 0;
struct Channel *chptr;
struct membership *msptr;
rb_dlink_node *ptr;
char buf[414];
char *p = buf, *end = buf + sizeof buf - 1;
*p = '\0';
static time_t last_used = 0;
struct Channel *chptr;
struct membership *msptr;
rb_dlink_node *ptr;
char buf[414];
char *p = buf, *end = buf + sizeof buf - 1;
*p = '\0';
/* Allow ircops to search for forwards to nonexistent channels */
if(!IsOper(source_p)) {
if((chptr = find_channel(parv[1])) == NULL || (msptr = find_channel_membership(chptr, source_p)) == NULL) {
sendto_one_numeric(source_p, ERR_NOTONCHANNEL,
form_str(ERR_NOTONCHANNEL), parv[1]);
return 0;
}
/* Allow ircops to search for forwards to nonexistent channels */
if(!IsOper(source_p))
{
if((chptr = find_channel(parv[1])) == NULL || (msptr = find_channel_membership(chptr, source_p)) == NULL)
{
sendto_one_numeric(source_p, ERR_NOTONCHANNEL,
form_str(ERR_NOTONCHANNEL), parv[1]);
return 0;
}
if(!is_any_op(msptr)) {
sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
me.name, source_p->name, parv[1]);
return 0;
}
if(!is_any_op(msptr))
{
sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
me.name, source_p->name, parv[1]);
return 0;
}
if((last_used + ConfigFileEntry.pace_wait) > rb_current_time()) {
sendto_one(source_p, form_str(RPL_LOAD2HI),
me.name, source_p->name, "FINDFORWARDS");
return 0;
} else
last_used = rb_current_time();
}
if((last_used + ConfigFileEntry.pace_wait) > rb_current_time())
{
sendto_one(source_p, form_str(RPL_LOAD2HI),
me.name, source_p->name, "FINDFORWARDS");
return 0;
}
else
last_used = rb_current_time();
}
RB_DLINK_FOREACH(ptr, global_channel_list.head)
{
chptr = ptr->data;
if(chptr->mode.forward && !irccmp(chptr->mode.forward, parv[1]))
{
if(p + strlen(chptr->chname) >= end - 13)
{
strcpy(p, "<truncated> ");
p += 12;
break;
}
strcpy(p, chptr->chname);
p += strlen(chptr->chname);
*p++ = ' ';
}
}
RB_DLINK_FOREACH(ptr, global_channel_list.head) {
chptr = ptr->data;
if(chptr->mode.forward && !irccmp(chptr->mode.forward, parv[1])) {
if(p + strlen(chptr->chname) >= end - 13) {
strcpy(p, "<truncated> ");
p += 12;
break;
}
strcpy(p, chptr->chname);
p += strlen(chptr->chname);
*p++ = ' ';
}
}
if(buf[0])
*(--p) = '\0';
if(buf[0])
*(--p) = '\0';
sendto_one_notice(source_p, ":Forwards for %s: %s", parv[1], buf);
sendto_one_notice(source_p, ":Forwards for %s: %s", parv[1], buf);
return 0;
return 0;
}

View File

@ -48,11 +48,11 @@
#include "modules.h"
static int mo_forcejoin(struct Client *client_p, struct Client *source_p,
int parc, const char *parv[]);
int parc, const char *parv[]);
struct Message forcejoin_msgtab = {
"FORCEJOIN", 0, 0, 0, MFLG_SLOW,
{mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_forcejoin, 3}}
"FORCEJOIN", 0, 0, 0, MFLG_SLOW,
{mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_forcejoin, 3}}
};
mapi_clist_av1 force_clist[] = { &forcejoin_msgtab, NULL };
@ -67,137 +67,152 @@ DECLARE_MODULE_AV1(force, NULL, NULL, force_clist, NULL, NULL, "$Revision: 3297
static int
mo_forcejoin(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
struct Client *target_p;
struct Channel *chptr;
int type;
char mode;
char sjmode;
char *newch;
struct Client *target_p;
struct Channel *chptr;
int type;
char mode;
char sjmode;
char *newch;
if(!IsOperAdmin(source_p)) {
sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "admin");
return 0;
}
if(!IsOperAdmin(source_p))
{
sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "admin");
return 0;
}
if((hunt_server(client_p, source_p, ":%s FORCEJOIN %s %s", 1, parc, parv)) != HUNTED_ISME)
return 0;
if((hunt_server(client_p, source_p, ":%s FORCEJOIN %s %s", 1, parc, parv)) != HUNTED_ISME)
return 0;
/* if target_p is not existant, print message
* to source_p and bail - scuzzy
*/
if((target_p = find_client(parv[1])) == NULL) {
sendto_one(source_p, form_str(ERR_NOSUCHNICK), me.name, source_p->name, parv[1]);
return 0;
}
/* if target_p is not existant, print message
* to source_p and bail - scuzzy
*/
if((target_p = find_client(parv[1])) == NULL)
{
sendto_one(source_p, form_str(ERR_NOSUCHNICK), me.name, source_p->name, parv[1]);
return 0;
}
if(!IsPerson(target_p))
return 0;
if(!IsPerson(target_p))
return 0;
sendto_wallops_flags(UMODE_WALLOP, &me,
"FORCEJOIN called for %s %s by %s!%s@%s",
parv[1], parv[2], source_p->name, source_p->username, source_p->host);
ilog(L_MAIN, "FORCEJOIN called for %s %s by %s!%s@%s",
parv[1], parv[2], source_p->name, source_p->username, source_p->host);
sendto_server(NULL, NULL, NOCAPS, NOCAPS,
":%s WALLOPS :FORCEJOIN called for %s %s by %s!%s@%s",
me.name, parv[1], parv[2],
source_p->name, source_p->username, source_p->host);
sendto_wallops_flags(UMODE_WALLOP, &me,
"FORCEJOIN called for %s %s by %s!%s@%s",
parv[1], parv[2], source_p->name, source_p->username, source_p->host);
ilog(L_MAIN, "FORCEJOIN called for %s %s by %s!%s@%s",
parv[1], parv[2], source_p->name, source_p->username, source_p->host);
sendto_server(NULL, NULL, NOCAPS, NOCAPS,
":%s WALLOPS :FORCEJOIN called for %s %s by %s!%s@%s",
me.name, parv[1], parv[2],
source_p->name, source_p->username, source_p->host);
/* select our modes from parv[2] if they exist... (chanop) */
if(*parv[2] == '@') {
type = CHFL_CHANOP;
mode = 'o';
sjmode = '@';
} else if(*parv[2] == '+') {
type = CHFL_VOICE;
mode = 'v';
sjmode = '+';
} else {
type = CHFL_PEON;
mode = sjmode = '\0';
}
/* select our modes from parv[2] if they exist... (chanop) */
if(*parv[2] == '@')
{
type = CHFL_CHANOP;
mode = 'o';
sjmode = '@';
}
else if(*parv[2] == '+')
{
type = CHFL_VOICE;
mode = 'v';
sjmode = '+';
}
else
{
type = CHFL_PEON;
mode = sjmode = '\0';
}
if(mode != '\0')
parv[2]++;
if(mode != '\0')
parv[2]++;
if((chptr = find_channel(parv[2])) != NULL) {
if(IsMember(target_p, chptr)) {
/* debugging is fun... */
sendto_one_notice(source_p, ":*** Notice -- %s is already in %s",
target_p->name, chptr->chname);
return 0;
}
if((chptr = find_channel(parv[2])) != NULL)
{
if(IsMember(target_p, chptr))
{
/* debugging is fun... */
sendto_one_notice(source_p, ":*** Notice -- %s is already in %s",
target_p->name, chptr->chname);
return 0;
}
add_user_to_channel(chptr, target_p, type);
add_user_to_channel(chptr, target_p, type);
sendto_server(target_p, chptr, NOCAPS, NOCAPS,
":%s SJOIN %ld %s + :%c%s",
me.name, (long) chptr->channelts,
chptr->chname, type ? sjmode : ' ', target_p->name);
sendto_server(target_p, chptr, NOCAPS, NOCAPS,
":%s SJOIN %ld %s + :%c%s",
me.name, (long) chptr->channelts,
chptr->chname, type ? sjmode : ' ', target_p->name);
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN :%s",
target_p->name, target_p->username,
target_p->host, chptr->chname);
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN :%s",
target_p->name, target_p->username,
target_p->host, chptr->chname);
if(type)
sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +%c %s",
me.name, chptr->chname, mode, target_p->name);
if(type)
sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +%c %s",
me.name, chptr->chname, mode, target_p->name);
if(chptr->topic != NULL) {
sendto_one(target_p, form_str(RPL_TOPIC), me.name,
target_p->name, chptr->chname, chptr->topic);
sendto_one(target_p, form_str(RPL_TOPICWHOTIME),
me.name, source_p->name, chptr->chname,
chptr->topic_info, chptr->topic_time);
}
if(chptr->topic != NULL)
{
sendto_one(target_p, form_str(RPL_TOPIC), me.name,
target_p->name, chptr->chname, chptr->topic);
sendto_one(target_p, form_str(RPL_TOPICWHOTIME),
me.name, source_p->name, chptr->chname,
chptr->topic_info, chptr->topic_time);
}
channel_member_names(chptr, target_p, 1);
} else {
newch = LOCAL_COPY(parv[2]);
if(!check_channel_name(newch)) {
sendto_one(source_p, form_str(ERR_BADCHANNAME), me.name,
source_p->name, (unsigned char *) newch);
return 0;
}
channel_member_names(chptr, target_p, 1);
}
else
{
newch = LOCAL_COPY(parv[2]);
if(!check_channel_name(newch))
{
sendto_one(source_p, form_str(ERR_BADCHANNAME), me.name,
source_p->name, (unsigned char *) newch);
return 0;
}
/* channel name must begin with & or # */
if(!IsChannelName(newch)) {
sendto_one(source_p, form_str(ERR_BADCHANNAME), me.name,
source_p->name, (unsigned char *) newch);
return 0;
}
/* channel name must begin with & or # */
if(!IsChannelName(newch))
{
sendto_one(source_p, form_str(ERR_BADCHANNAME), me.name,
source_p->name, (unsigned char *) newch);
return 0;
}
/* newch can't be longer than CHANNELLEN */
if(strlen(newch) > CHANNELLEN) {
sendto_one_notice(source_p, ":Channel name is too long");
return 0;
}
/* newch can't be longer than CHANNELLEN */
if(strlen(newch) > CHANNELLEN)
{
sendto_one_notice(source_p, ":Channel name is too long");
return 0;
}
chptr = get_or_create_channel(target_p, newch, NULL);
add_user_to_channel(chptr, target_p, CHFL_CHANOP);
chptr = get_or_create_channel(target_p, newch, NULL);
add_user_to_channel(chptr, target_p, CHFL_CHANOP);
/* send out a join, make target_p join chptr */
sendto_server(target_p, chptr, NOCAPS, NOCAPS,
":%s SJOIN %ld %s +nt :@%s", me.name,
(long) chptr->channelts, chptr->chname, target_p->name);
/* send out a join, make target_p join chptr */
sendto_server(target_p, chptr, NOCAPS, NOCAPS,
":%s SJOIN %ld %s +nt :@%s", me.name,
(long) chptr->channelts, chptr->chname, target_p->name);
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN :%s",
target_p->name, target_p->username,
target_p->host, chptr->chname);
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN :%s",
target_p->name, target_p->username,
target_p->host, chptr->chname);
chptr->mode.mode |= MODE_TOPICLIMIT;
chptr->mode.mode |= MODE_NOPRIVMSGS;
chptr->mode.mode |= MODE_TOPICLIMIT;
chptr->mode.mode |= MODE_NOPRIVMSGS;
sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +nt", me.name, chptr->chname);
sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +nt", me.name, chptr->chname);
target_p->localClient->last_join_time = rb_current_time();
channel_member_names(chptr, target_p, 1);
target_p->localClient->last_join_time = rb_current_time();
channel_member_names(chptr, target_p, 1);
/* we do this to let the oper know that a channel was created, this will be
* seen from the server handling the command instead of the server that
* the oper is on.
*/
sendto_one_notice(source_p, ":*** Notice -- Creating channel %s", chptr->chname);
}
return 0;
/* we do this to let the oper know that a channel was created, this will be
* seen from the server handling the command instead of the server that
* the oper is on.
*/
sendto_one_notice(source_p, ":*** Notice -- Creating channel %s", chptr->chname);
}
return 0;
}

View File

@ -52,45 +52,49 @@ char *reconstruct_parv(int parc, const char *parv[]);
static int m_identify(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
struct Message identify_msgtab = {
"IDENTIFY", 0, 0, 0, MFLG_SLOW,
{mg_unreg, {m_identify, 0}, mg_ignore, mg_ignore, mg_ignore, {m_identify, 0}}
"IDENTIFY", 0, 0, 0, MFLG_SLOW,
{mg_unreg, {m_identify, 0}, mg_ignore, mg_ignore, mg_ignore, {m_identify, 0}}
};
mapi_clist_av1 identify_clist[] = {
&identify_msgtab,
NULL
&identify_msgtab,
NULL
};
DECLARE_MODULE_AV1(identify, NULL, NULL, identify_clist, NULL, NULL, "$Revision: 2729 $");
char *reconstruct_parv(int parc, const char *parv[])
{
static char tmpbuf[BUFSIZE];
int i;
static char tmpbuf[BUFSIZE]; int i;
rb_strlcpy(tmpbuf, parv[0], BUFSIZE);
for (i = 1; i < parc; i++) {
rb_strlcat(tmpbuf, " ", BUFSIZE);
rb_strlcat(tmpbuf, parv[i], BUFSIZE);
}
return tmpbuf;
rb_strlcpy(tmpbuf, parv[0], BUFSIZE);
for (i = 1; i < parc; i++)
{
rb_strlcat(tmpbuf, " ", BUFSIZE);
rb_strlcat(tmpbuf, parv[i], BUFSIZE);
}
return tmpbuf;
}
static int m_identify(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
const char *nick;
struct Client *target_p;
const char *nick;
struct Client *target_p;
if (parc < 2 || EmptyString(parv[1])) {
sendto_one(source_p, form_str(ERR_NOTEXTTOSEND), me.name, source_p->name);
return 0;
}
if (parc < 2 || EmptyString(parv[1]))
{
sendto_one(source_p, form_str(ERR_NOTEXTTOSEND), me.name, source_p->name);
return 0;
}
nick = parv[1][0] == '#' ? SVS_chanserv_NICK : SVS_nickserv_NICK;
if ((target_p = find_named_person(nick)) && IsService(target_p)) {
sendto_one(target_p, ":%s PRIVMSG %s :IDENTIFY %s", get_id(source_p, target_p), get_id(target_p, target_p), reconstruct_parv(parc - 1, &parv[1]));
} else {
sendto_one_numeric(source_p, ERR_SERVICESDOWN, form_str(ERR_SERVICESDOWN), nick);
}
return 0;
nick = parv[1][0] == '#' ? SVS_chanserv_NICK : SVS_nickserv_NICK;
if ((target_p = find_named_person(nick)) && IsService(target_p))
{
sendto_one(target_p, ":%s PRIVMSG %s :IDENTIFY %s", get_id(source_p, target_p), get_id(target_p, target_p), reconstruct_parv(parc - 1, &parv[1]));
}
else
{
sendto_one_numeric(source_p, ERR_SERVICESDOWN, form_str(ERR_SERVICESDOWN), nick);
}
return 0;
}

View File

@ -15,9 +15,9 @@
#include <string.h>
static int m_mkpasswd(struct Client *client_p, struct Client *source_p,
int parc, const char *parv[]);
int parc, const char *parv[]);
static int mo_mkpasswd(struct Client *client_p, struct Client *source_p,
int parc, const char *parv[]);
int parc, const char *parv[]);
static char *make_md5_salt(int);
static char *make_sha256_salt(int);
@ -26,11 +26,11 @@ static char *generate_random_salt(char *, int);
static char *generate_poor_salt(char *, int);
static char saltChars[] = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
/* 0 .. 63, ascii - 64 */
/* 0 .. 63, ascii - 64 */
struct Message mkpasswd_msgtab = {
"MKPASSWD", 0, 0, 0, MFLG_SLOW,
{mg_unreg, {m_mkpasswd, 2}, mg_ignore, mg_ignore, mg_ignore, {mo_mkpasswd, 2}}
"MKPASSWD", 0, 0, 0, MFLG_SLOW,
{mg_unreg, {m_mkpasswd, 2}, mg_ignore, mg_ignore, mg_ignore, {mo_mkpasswd, 2}}
};
mapi_clist_av1 mkpasswd_clist[] = { &mkpasswd_msgtab, NULL };
@ -45,42 +45,46 @@ DECLARE_MODULE_AV1(mkpasswd, NULL, NULL, mkpasswd_clist, NULL, NULL, "$Revision$
static int
m_mkpasswd(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
static time_t last_used = 0;
char *salt;
const char *hashtype;
const char hashdefault[] = "SHA512";
static time_t last_used = 0;
char *salt;
const char *hashtype;
const char hashdefault[] = "SHA512";
if(EmptyString(parv[1])) {
sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), me.name, source_p->name, "MKPASSWD");
return 0;
}
if(EmptyString(parv[1]))
{
sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), me.name, source_p->name, "MKPASSWD");
return 0;
}
if(parc < 3)
hashtype = hashdefault;
else
hashtype = parv[2];
if(parc < 3)
hashtype = hashdefault;
else
hashtype = parv[2];
if((last_used + ConfigFileEntry.pace_wait) > rb_current_time()) {
/* safe enough to give this on a local connect only */
sendto_one(source_p, form_str(RPL_LOAD2HI), me.name, source_p->name, "MKPASSWD");
return 0;
} else
last_used = rb_current_time();
if((last_used + ConfigFileEntry.pace_wait) > rb_current_time())
{
/* safe enough to give this on a local connect only */
sendto_one(source_p, form_str(RPL_LOAD2HI), me.name, source_p->name, "MKPASSWD");
return 0;
}
else
last_used = rb_current_time();
if(!irccmp(hashtype, "SHA256"))
salt = make_sha256_salt(16);
else if(!irccmp(hashtype, "SHA512"))
salt = make_sha512_salt(16);
else if(!irccmp(hashtype, "MD5"))
salt = make_md5_salt(8);
else {
sendto_one_notice(source_p,
":MKPASSWD syntax error: MKPASSWD pass [SHA256|SHA512|MD5]");
return 0;
}
if(!irccmp(hashtype, "SHA256"))
salt = make_sha256_salt(16);
else if(!irccmp(hashtype, "SHA512"))
salt = make_sha512_salt(16);
else if(!irccmp(hashtype, "MD5"))
salt = make_md5_salt(8);
else
{
sendto_one_notice(source_p,
":MKPASSWD syntax error: MKPASSWD pass [SHA256|SHA512|MD5]");
return 0;
}
sendto_one_notice(source_p, ":Hash [%s] for %s: %s", hashtype, parv[1], rb_crypt(parv[1], salt));
return 0;
sendto_one_notice(source_p, ":Hash [%s] for %s: %s", hashtype, parv[1], rb_crypt(parv[1], salt));
return 0;
}
/* mo_mkpasswd - mkpasswd message handler
@ -90,115 +94,124 @@ m_mkpasswd(struct Client *client_p, struct Client *source_p, int parc, const cha
static int
mo_mkpasswd(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
char *salt;
const char *hashtype;
const char hashdefault[] = "SHA512";
char *salt;
const char *hashtype;
const char hashdefault[] = "SHA512";
if(EmptyString(parv[1])) {
sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), me.name, source_p->name, "MKPASSWD");
return 0;
}
if(EmptyString(parv[1]))
{
sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), me.name, source_p->name, "MKPASSWD");
return 0;
}
if(parc < 3)
hashtype = hashdefault;
else
hashtype = parv[2];
if(parc < 3)
hashtype = hashdefault;
else
hashtype = parv[2];
if(!irccmp(hashtype, "SHA256"))
salt = make_sha256_salt(16);
else if(!irccmp(hashtype, "SHA512"))
salt = make_sha512_salt(16);
else if(!irccmp(hashtype, "MD5"))
salt = make_md5_salt(8);
else {
sendto_one_notice(source_p,
":MKPASSWD syntax error: MKPASSWD pass [SHA256|SHA512|MD5]");
return 0;
}
if(!irccmp(hashtype, "SHA256"))
salt = make_sha256_salt(16);
else if(!irccmp(hashtype, "SHA512"))
salt = make_sha512_salt(16);
else if(!irccmp(hashtype, "MD5"))
salt = make_md5_salt(8);
else
{
sendto_one_notice(source_p,
":MKPASSWD syntax error: MKPASSWD pass [SHA256|SHA512|MD5]");
return 0;
}
sendto_one_notice(source_p, ":Hash [%s] for %s: %s", hashtype, parv[1], rb_crypt(parv[1], salt));
return 0;
sendto_one_notice(source_p, ":Hash [%s] for %s: %s", hashtype, parv[1], rb_crypt(parv[1], salt));
return 0;
}
char *
make_md5_salt(int length)
{
static char salt[21];
if(length > 16) {
printf("MD5 salt length too long\n");
exit(0);
}
salt[0] = '$';
salt[1] = '1';
salt[2] = '$';
generate_random_salt(&salt[3], length);
salt[length + 3] = '$';
salt[length + 4] = '\0';
return salt;
static char salt[21];
if(length > 16)
{
printf("MD5 salt length too long\n");
exit(0);
}
salt[0] = '$';
salt[1] = '1';
salt[2] = '$';
generate_random_salt(&salt[3], length);
salt[length + 3] = '$';
salt[length + 4] = '\0';
return salt;
}
char *
make_sha256_salt(int length)
{
static char salt[21];
if(length > 16) {
printf("SHA256 salt length too long\n");
exit(0);
}
salt[0] = '$';
salt[1] = '5';
salt[2] = '$';
generate_random_salt(&salt[3], length);
salt[length + 3] = '$';
salt[length + 4] = '\0';
return salt;
static char salt[21];
if(length > 16)
{
printf("SHA256 salt length too long\n");
exit(0);
}
salt[0] = '$';
salt[1] = '5';
salt[2] = '$';
generate_random_salt(&salt[3], length);
salt[length + 3] = '$';
salt[length + 4] = '\0';
return salt;
}
char *
make_sha512_salt(int length)
{
static char salt[21];
if(length > 16) {
printf("SHA512 salt length too long\n");
exit(0);
}
salt[0] = '$';
salt[1] = '6';
salt[2] = '$';
generate_random_salt(&salt[3], length);
salt[length + 3] = '$';
salt[length + 4] = '\0';
return salt;
static char salt[21];
if(length > 16)
{
printf("SHA512 salt length too long\n");
exit(0);
}
salt[0] = '$';
salt[1] = '6';
salt[2] = '$';
generate_random_salt(&salt[3], length);
salt[length + 3] = '$';
salt[length + 4] = '\0';
return salt;
}
char *
generate_poor_salt(char *salt, int length)
{
int i;
srand(time(NULL));
for(i = 0; i < length; i++) {
salt[i] = saltChars[rand() % 64];
}
return (salt);
int i;
srand(time(NULL));
for(i = 0; i < length; i++)
{
salt[i] = saltChars[rand() % 64];
}
return (salt);
}
char *
generate_random_salt(char *salt, int length)
{
char *buf;
int fd, i;
if((fd = open("/dev/random", O_RDONLY)) < 0) {
return (generate_poor_salt(salt, length));
}
buf = calloc(1, length);
if(read(fd, buf, length) != length) {
free(buf);
return (generate_poor_salt(salt, length));
}
char *buf;
int fd, i;
if((fd = open("/dev/random", O_RDONLY)) < 0)
{
return (generate_poor_salt(salt, length));
}
buf = calloc(1, length);
if(read(fd, buf, length) != length)
{
free(buf);
return (generate_poor_salt(salt, length));
}
for(i = 0; i < length; i++) {
salt[i] = saltChars[abs(buf[i]) % 64];
}
free(buf);
return (salt);
for(i = 0; i < length; i++)
{
salt[i] = saltChars[abs(buf[i]) % 64];
}
free(buf);
return (salt);
}

View File

@ -9,9 +9,9 @@
static int mo_oaccept(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
struct Message oaccept_msgtab = {
"OACCEPT", 0, 0, 0, MFLG_SLOW,
{mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_oaccept, 2}}
};
"OACCEPT", 0, 0, 0, MFLG_SLOW,
{mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_oaccept, 2}}
};
mapi_clist_av1 oaccept_clist[] = { &oaccept_msgtab, NULL };
@ -20,42 +20,46 @@ DECLARE_MODULE_AV1(oaccept, NULL, NULL, oaccept_clist, NULL, NULL, "$Id $");
static int
mo_oaccept(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
struct Metadata *md;
struct DictionaryIter iter;
struct Client *target_p;
char text[10];
struct Metadata *md;
struct DictionaryIter iter;
struct Client *target_p;
char text[10];
if(!(target_p = find_client(parv[1]))) {
sendto_one(source_p, form_str(ERR_NOSUCHNICK), parv[1]);
return 0;
}
if(!(target_p = find_client(parv[1])))
{
sendto_one(source_p, form_str(ERR_NOSUCHNICK), parv[1]);
return 0;
}
/* If we don't check for this, and some idiot tries to OACCEPT a server... */
if(!IsPerson(target_p)) {
sendto_one_notice(source_p, ":That is a server, not a user. What are you doing?");
return 0;
}
/* If we don't check for this, and some idiot tries to OACCEPT a server... */
if(!IsPerson(target_p))
{
sendto_one_notice(source_p, ":That is a server, not a user. What are you doing?");
return 0;
}
snprintf(text, sizeof(text), "O%s", source_p->id);
rb_snprintf(text, sizeof(text), "O%s", source_p->id);
/* Provide a nice error message if you try to OACCEPT someone
* who you've already OACCEPTed. */
DICTIONARY_FOREACH(md, &iter, target_p->user->metadata) {
if(!strcmp(md->value, "OACCEPT") && !strcmp(md->name, text)) {
sendto_one_notice(source_p, ":You're already on %s's OACCEPT list", target_p->name);
return 0;
}
}
/* Provide a nice error message if you try to OACCEPT someone
* who you've already OACCEPTed. */
DICTIONARY_FOREACH(md, &iter, target_p->user->metadata)
{
if(!strcmp(md->value, "OACCEPT") && !strcmp(md->name, text))
{
sendto_one_notice(source_p, ":You're already on %s's OACCEPT list", target_p->name);
return 0;
}
}
user_metadata_add(target_p, text, "OACCEPT", 1);
user_metadata_add(target_p, text, "OACCEPT", 1);
sendto_wallops_flags(UMODE_WALLOP, &me,
"OACCEPT called for %s by %s!%s@%s",
target_p->name,
source_p->name, source_p->username, source_p->host);
sendto_server(NULL, NULL, NOCAPS, NOCAPS,
":%s WALLOPS :OACCEPT called for %s by %s!%s@%s",
me.name, target_p->name, source_p->name, source_p->username,
source_p->host);
return 0;
sendto_wallops_flags(UMODE_WALLOP, &me,
"OACCEPT called for %s by %s!%s@%s",
target_p->name,
source_p->name, source_p->username, source_p->host);
sendto_server(NULL, NULL, NOCAPS, NOCAPS,
":%s WALLOPS :OACCEPT called for %s by %s!%s@%s",
me.name, target_p->name, source_p->name, source_p->username,
source_p->host);
return 0;
}

View File

@ -20,17 +20,17 @@
#include "stdinc.h"
#include "channel.h"
#include "client.h"
#include "client.h"
#include "ircd.h"
#include "numeric.h"
#include "logger.h"
#include "s_serv.h"
#include "s_conf.h"
#include "s_newconf.h"
#include "s_newconf.h"
#include "send.h"
#include "whowas.h"
#include "match.h"
#include "hash.h"
#include "hash.h"
#include "msg.h"
#include "parse.h"
#include "modules.h"
@ -39,8 +39,8 @@ static int mo_ojoin(struct Client *client_p, struct Client *source_p, int parc,
struct Message ojoin_msgtab = {
"OJOIN", 0, 0, 0, MFLG_SLOW,
{mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_ojoin, 2}}
"OJOIN", 0, 0, 0, MFLG_SLOW,
{mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_ojoin, 2}}
};
mapi_clist_av1 ojoin_clist[] = { &ojoin_msgtab, NULL };
@ -54,117 +54,133 @@ DECLARE_MODULE_AV1(ojoin, NULL, NULL, ojoin_clist, NULL, NULL, "$Revision: 3554
static int
mo_ojoin(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
struct Channel *chptr;
int move_me = 0;
struct Channel *chptr;
int move_me = 0;
/* admins only */
if(!IsOperAdmin(source_p)) {
sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "admin");
return 0;
}
/* admins only */
if(!IsOperAdmin(source_p))
{
sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "admin");
return 0;
}
if(*parv[1] == '@' || *parv[1] == '%' || *parv[1] == '+' || *parv[1] == '!' || *parv[1] == '~') {
parv[1]++;
move_me = 1;
}
if(*parv[1] == '@' || *parv[1] == '%' || *parv[1] == '+' || *parv[1] == '!' || *parv[1] == '~')
{
parv[1]++;
move_me = 1;
}
if((chptr = find_channel(parv[1])) == NULL) {
sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL,
form_str(ERR_NOSUCHCHANNEL), parv[1]);
return 0;
}
if((chptr = find_channel(parv[1])) == NULL)
{
sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL,
form_str(ERR_NOSUCHCHANNEL), parv[1]);
return 0;
}
if(IsMember(source_p, chptr)) {
sendto_one_notice(source_p, ":Please part %s before using OJOIN", parv[1]);
return 0;
}
if(IsMember(source_p, chptr))
{
sendto_one_notice(source_p, ":Please part %s before using OJOIN", parv[1]);
return 0;
}
if(move_me == 1)
parv[1]--;
if(move_me == 1)
parv[1]--;
sendto_wallops_flags(UMODE_WALLOP, &me,
"OJOIN called for %s by %s!%s@%s",
parv[1], source_p->name, source_p->username, source_p->host);
ilog(L_MAIN, "OJOIN called for %s by %s",
parv[1], get_oper_name(source_p));
/* only sends stuff for #channels remotely */
sendto_server(NULL, chptr, NOCAPS, NOCAPS,
":%s WALLOPS :OJOIN called for %s by %s!%s@%s",
me.name, parv[1],
source_p->name, source_p->username, source_p->host);
sendto_wallops_flags(UMODE_WALLOP, &me,
"OJOIN called for %s by %s!%s@%s",
parv[1], source_p->name, source_p->username, source_p->host);
ilog(L_MAIN, "OJOIN called for %s by %s",
parv[1], get_oper_name(source_p));
/* only sends stuff for #channels remotely */
sendto_server(NULL, chptr, NOCAPS, NOCAPS,
":%s WALLOPS :OJOIN called for %s by %s!%s@%s",
me.name, parv[1],
source_p->name, source_p->username, source_p->host);
if(*parv[1] == '~' && ConfigChannel.use_owner) {
add_user_to_channel(chptr, source_p, CHFL_OWNER);
sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
":%s SJOIN %ld %s + :~%s",
me.id, (long) chptr->channelts, chptr->chname, source_p->id);
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN %s",
source_p->name,
source_p->username, source_p->host, chptr->chname);
sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +y %s",
me.name, chptr->chname, source_p->name);
} else if(*parv[1] == '!' && ConfigChannel.use_admin) {
add_user_to_channel(chptr, source_p, CHFL_ADMIN);
sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
":%s SJOIN %ld %s + :!%s",
me.id, (long) chptr->channelts, chptr->chname, source_p->id);
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN %s",
source_p->name,
source_p->username, source_p->host, chptr->chname);
sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +a %s",
me.name, chptr->chname, source_p->name);
if(*parv[1] == '~' && ConfigChannel.use_owner)
{
add_user_to_channel(chptr, source_p, CHFL_OWNER);
sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
":%s SJOIN %ld %s + :~%s",
me.id, (long) chptr->channelts, chptr->chname, source_p->id);
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN %s",
source_p->name,
source_p->username, source_p->host, chptr->chname);
sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +y %s",
me.name, chptr->chname, source_p->name);
}
else if(*parv[1] == '!' && ConfigChannel.use_admin)
{
add_user_to_channel(chptr, source_p, CHFL_ADMIN);
sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
":%s SJOIN %ld %s + :!%s",
me.id, (long) chptr->channelts, chptr->chname, source_p->id);
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN %s",
source_p->name,
source_p->username, source_p->host, chptr->chname);
sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +a %s",
me.name, chptr->chname, source_p->name);
} else if(*parv[1] == '@') {
add_user_to_channel(chptr, source_p, CHFL_CHANOP);
sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
":%s SJOIN %ld %s + :@%s",
me.id, (long) chptr->channelts, chptr->chname, source_p->id);
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN %s",
source_p->name,
source_p->username, source_p->host, chptr->chname);
sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +o %s",
me.name, chptr->chname, source_p->name);
}
else if(*parv[1] == '@')
{
add_user_to_channel(chptr, source_p, CHFL_CHANOP);
sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
":%s SJOIN %ld %s + :@%s",
me.id, (long) chptr->channelts, chptr->chname, source_p->id);
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN %s",
source_p->name,
source_p->username, source_p->host, chptr->chname);
sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +o %s",
me.name, chptr->chname, source_p->name);
} else if(*parv[1] == '%' && ConfigChannel.use_halfop) {
add_user_to_channel(chptr, source_p, CHFL_HALFOP);
sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
":%s SJOIN %ld %s + :%s%s",
me.id, (long) chptr->channelts, chptr->chname, "%", source_p->id);
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN %s",
source_p->name,
source_p->username, source_p->host, chptr->chname);
sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +h %s",
me.name, chptr->chname, source_p->name);
} else if(*parv[1] == '+') {
add_user_to_channel(chptr, source_p, CHFL_VOICE);
sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
":%s SJOIN %ld %s + :+%s",
me.id, (long) chptr->channelts, chptr->chname, source_p->id);
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN %s",
source_p->name,
source_p->username, source_p->host, chptr->chname);
sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +v %s",
me.name, chptr->chname, source_p->name);
} else {
add_user_to_channel(chptr, source_p, CHFL_PEON);
sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
":%s JOIN %ld %s +",
source_p->id, (long) chptr->channelts, chptr->chname);
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN %s",
source_p->name,
source_p->username, source_p->host, chptr->chname);
}
}
else if(*parv[1] == '%' && ConfigChannel.use_halfop)
{
add_user_to_channel(chptr, source_p, CHFL_HALFOP);
sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
":%s SJOIN %ld %s + :%s%s",
me.id, (long) chptr->channelts, chptr->chname, "%", source_p->id);
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN %s",
source_p->name,
source_p->username, source_p->host, chptr->chname);
sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +h %s",
me.name, chptr->chname, source_p->name);
}
else if(*parv[1] == '+')
{
add_user_to_channel(chptr, source_p, CHFL_VOICE);
sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
":%s SJOIN %ld %s + :+%s",
me.id, (long) chptr->channelts, chptr->chname, source_p->id);
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN %s",
source_p->name,
source_p->username, source_p->host, chptr->chname);
sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +v %s",
me.name, chptr->chname, source_p->name);
}
else
{
add_user_to_channel(chptr, source_p, CHFL_PEON);
sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
":%s JOIN %ld %s +",
source_p->id, (long) chptr->channelts, chptr->chname);
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN %s",
source_p->name,
source_p->username, source_p->host, chptr->chname);
}
/* send the topic... */
if(chptr->topic != NULL) {
sendto_one(source_p, form_str(RPL_TOPIC), me.name,
source_p->name, chptr->chname, chptr->topic);
sendto_one(source_p, form_str(RPL_TOPICWHOTIME), me.name,
source_p->name, chptr->chname, chptr->topic_info, chptr->topic_time);
}
/* send the topic... */
if(chptr->topic != NULL)
{
sendto_one(source_p, form_str(RPL_TOPIC), me.name,
source_p->name, chptr->chname, chptr->topic);
sendto_one(source_p, form_str(RPL_TOPICWHOTIME), me.name,
source_p->name, chptr->chname, chptr->topic_info, chptr->topic_time);
}
source_p->localClient->last_join_time = rb_current_time();
channel_member_names(chptr, source_p, 1);
source_p->localClient->last_join_time = rb_current_time();
channel_member_names(chptr, source_p, 1);
return 0;
return 0;
}

View File

@ -41,8 +41,8 @@ static int mo_okick(struct Client *client_p, struct Client *source_p, int parc,
struct Message okick_msgtab = {
"OKICK", 0, 0, 0, MFLG_SLOW,
{mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_okick, 4}}
"OKICK", 0, 0, 0, MFLG_SLOW,
{mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_okick, 4}}
};
mapi_clist_av1 okick_clist[] = { &okick_msgtab, NULL };
@ -58,84 +58,89 @@ DECLARE_MODULE_AV1(okick, NULL, NULL, okick_clist, NULL, NULL, "$Revision: 3554
static int
mo_okick(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
struct Client *who;
struct Client *target_p;
struct Channel *chptr;
struct membership *msptr;
int chasing = 0;
char *comment;
char *name;
char *p = NULL;
char *user;
char text[10];
static char buf[BUFSIZE];
struct Client *who;
struct Client *target_p;
struct Channel *chptr;
struct membership *msptr;
int chasing = 0;
char *comment;
char *name;
char *p = NULL;
char *user;
char text[10];
static char buf[BUFSIZE];
if(*parv[2] == '\0') {
sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), me.name, source_p->name, "KICK");
return 0;
}
if(*parv[2] == '\0')
{
sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), me.name, source_p->name, "KICK");
return 0;
}
if(MyClient(source_p) && !IsFloodDone(source_p))
flood_endgrace(source_p);
if(MyClient(source_p) && !IsFloodDone(source_p))
flood_endgrace(source_p);
comment = (EmptyString(LOCAL_COPY(parv[3]))) ? LOCAL_COPY(parv[2]) : LOCAL_COPY(parv[3]);
if(strlen(comment) > (size_t) TOPICLEN)
comment[TOPICLEN] = '\0';
comment = (EmptyString(LOCAL_COPY(parv[3]))) ? LOCAL_COPY(parv[2]) : LOCAL_COPY(parv[3]);
if(strlen(comment) > (size_t) TOPICLEN)
comment[TOPICLEN] = '\0';
*buf = '\0';
if((p = strchr(parv[1], ',')))
*p = '\0';
*buf = '\0';
if((p = strchr(parv[1], ',')))
*p = '\0';
name = LOCAL_COPY(parv[1]);
name = LOCAL_COPY(parv[1]);
chptr = find_channel(name);
if(!chptr) {
sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL, form_str(ERR_NOSUCHCHANNEL), name);
return 0;
}
chptr = find_channel(name);
if(!chptr)
{
sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL, form_str(ERR_NOSUCHCHANNEL), name);
return 0;
}
if((p = strchr(parv[2], ',')))
*p = '\0';
user = LOCAL_COPY(parv[2]); // strtoken(&p2, parv[2], ",");
if(!(who = find_chasing(source_p, user, &chasing))) {
return 0;
}
if((p = strchr(parv[2], ',')))
*p = '\0';
user = LOCAL_COPY(parv[2]); // strtoken(&p2, parv[2], ",");
if(!(who = find_chasing(source_p, user, &chasing)))
{
return 0;
}
if((target_p = find_client(user)) == NULL) {
sendto_one(source_p, form_str(ERR_NOSUCHNICK), me.name, source_p->name, user);
return 0;
}
if((target_p = find_client(user)) == NULL)
{
sendto_one(source_p, form_str(ERR_NOSUCHNICK), me.name, source_p->name, user);
return 0;
}
if((msptr = find_channel_membership(chptr, target_p)) == NULL) {
sendto_one(source_p, form_str(ERR_USERNOTINCHANNEL),
me.name, source_p->name, parv[1], parv[2]);
return 0;
}
if((msptr = find_channel_membership(chptr, target_p)) == NULL)
{
sendto_one(source_p, form_str(ERR_USERNOTINCHANNEL),
me.name, source_p->name, parv[1], parv[2]);
return 0;
}
sendto_wallops_flags(UMODE_WALLOP, &me,
"OKICK called for %s %s by %s!%s@%s",
chptr->chname, target_p->name,
source_p->name, source_p->username, source_p->host);
ilog(L_MAIN, "OKICK called for %s %s by %s",
chptr->chname, target_p->name,
get_oper_name(source_p));
/* only sends stuff for #channels remotely */
sendto_server(NULL, chptr, NOCAPS, NOCAPS,
":%s WALLOPS :OKICK called for %s %s by %s!%s@%s",
me.name, chptr->chname, target_p->name,
source_p->name, source_p->username, source_p->host);
sendto_wallops_flags(UMODE_WALLOP, &me,
"OKICK called for %s %s by %s!%s@%s",
chptr->chname, target_p->name,
source_p->name, source_p->username, source_p->host);
ilog(L_MAIN, "OKICK called for %s %s by %s",
chptr->chname, target_p->name,
get_oper_name(source_p));
/* only sends stuff for #channels remotely */
sendto_server(NULL, chptr, NOCAPS, NOCAPS,
":%s WALLOPS :OKICK called for %s %s by %s!%s@%s",
me.name, chptr->chname, target_p->name,
source_p->name, source_p->username, source_p->host);
sendto_channel_local(ALL_MEMBERS, chptr, ":%s KICK %s %s :%s",
me.name, chptr->chname, who->name, comment);
sendto_server(&me, chptr, CAP_TS6, NOCAPS,
":%s KICK %s %s :%s", me.id, chptr->chname, who->id, comment);
remove_user_from_channel(msptr);
sendto_channel_local(ALL_MEMBERS, chptr, ":%s KICK %s %s :%s",
me.name, chptr->chname, who->name, comment);
sendto_server(&me, chptr, CAP_TS6, NOCAPS,
":%s KICK %s %s :%s", me.id, chptr->chname, who->id, comment);
remove_user_from_channel(msptr);
snprintf(text, sizeof(text), "K%s", who->id);
rb_snprintf(text, sizeof(text), "K%s", who->id);
/* we don't need to track NOREJOIN stuff unless it's our client being kicked */
if(MyClient(who) && chptr->mode.mode & MODE_NOREJOIN)
channel_metadata_time_add(chptr, text, rb_current_time(), "KICKNOREJOIN");
return 0;
/* we don't need to track NOREJOIN stuff unless it's our client being kicked */
if(MyClient(who) && chptr->mode.mode & MODE_NOREJOIN)
channel_metadata_time_add(chptr, text, rb_current_time(), "KICKNOREJOIN");
return 0;
}

View File

@ -46,8 +46,8 @@ static int mo_olist(struct Client *, struct Client *, int parc, const char *parv
#ifndef STATIC_MODULES
struct Message olist_msgtab = {
"OLIST", 0, 0, 0, MFLG_SLOW,
{mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_olist, 1}}
"OLIST", 0, 0, 0, MFLG_SLOW,
{mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_olist, 1}}
};
mapi_clist_av1 olist_clist[] = { &olist_msgtab, NULL };
@ -66,22 +66,23 @@ static void list_named_channel(struct Client *source_p, const char *name);
static int
mo_olist(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
if(!IsOperSpy(source_p)) {
sendto_one(source_p, form_str(ERR_NOPRIVS),
me.name, source_p->name, "oper_spy");
sendto_one(source_p, form_str(RPL_LISTEND),
me.name, source_p->name);
return 0;
}
if(!IsOperSpy(source_p))
{
sendto_one(source_p, form_str(ERR_NOPRIVS),
me.name, source_p->name, "oper_spy");
sendto_one(source_p, form_str(RPL_LISTEND),
me.name, source_p->name);
return 0;
}
/* If no arg, do all channels *whee*, else just one channel */
if(parc < 2 || EmptyString(parv[1]))
list_all_channels(source_p);
else
list_named_channel(source_p, parv[1]);
/* If no arg, do all channels *whee*, else just one channel */
if(parc < 2 || EmptyString(parv[1]))
list_all_channels(source_p);
else
list_named_channel(source_p, parv[1]);
sendto_one(source_p, form_str(RPL_LISTEND), me.name, source_p->name);
return 0;
sendto_one(source_p, form_str(RPL_LISTEND), me.name, source_p->name);
return 0;
}
@ -94,23 +95,24 @@ mo_olist(struct Client *client_p, struct Client *source_p, int parc, const char
static void
list_all_channels(struct Client *source_p)
{
struct Channel *chptr;
rb_dlink_node *ptr;
struct Channel *chptr;
rb_dlink_node *ptr;
report_operspy(source_p, "LIST", NULL);
sendto_one(source_p, form_str(RPL_LISTSTART), me.name, source_p->name);
report_operspy(source_p, "LIST", NULL);
sendto_one(source_p, form_str(RPL_LISTSTART), me.name, source_p->name);
RB_DLINK_FOREACH(ptr, global_channel_list.head) {
chptr = ptr->data;
RB_DLINK_FOREACH(ptr, global_channel_list.head)
{
chptr = ptr->data;
sendto_one(source_p, ":%s 322 %s %s %lu :[%s] %s",
me.name, source_p->name, chptr->chname,
rb_dlink_list_length(&chptr->members),
channel_modes(chptr, &me),
chptr->topic == NULL ? "" : chptr->topic);
}
sendto_one(source_p, ":%s 322 %s %s %lu :[%s] %s",
me.name, source_p->name, chptr->chname,
rb_dlink_list_length(&chptr->members),
channel_modes(chptr, &me),
chptr->topic == NULL ? "" : chptr->topic);
}
return;
return;
}
/*
@ -122,28 +124,28 @@ list_all_channels(struct Client *source_p)
static void
list_named_channel(struct Client *source_p, const char *name)
{
struct Channel *chptr;
char *p;
char *n = LOCAL_COPY(name);
struct Channel *chptr;
char *p;
char *n = LOCAL_COPY(name);
if((p = strchr(n, ',')))
*p = '\0';
if((p = strchr(n, ',')))
*p = '\0';
/* Put operspy notice before any output, but only if channel exists */
chptr = EmptyString(n) ? NULL : find_channel(n);
if(chptr != NULL)
report_operspy(source_p, "LIST", chptr->chname);
/* Put operspy notice before any output, but only if channel exists */
chptr = EmptyString(n) ? NULL : find_channel(n);
if(chptr != NULL)
report_operspy(source_p, "LIST", chptr->chname);
sendto_one(source_p, form_str(RPL_LISTSTART), me.name, source_p->name);
sendto_one(source_p, form_str(RPL_LISTSTART), me.name, source_p->name);
if(EmptyString(n))
return;
if(EmptyString(n))
return;
if(chptr == NULL)
sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL,
form_str(ERR_NOSUCHCHANNEL), n);
else
sendto_one(source_p, ":%s 322 %s %s %lu :[%s] %s", me.name, source_p->name,
chptr->chname, rb_dlink_list_length(&chptr->members),
channel_modes(chptr, &me), chptr->topic ? chptr->topic : "");
if(chptr == NULL)
sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL,
form_str(ERR_NOSUCHCHANNEL), n);
else
sendto_one(source_p, ":%s 322 %s %s %lu :[%s] %s", me.name, source_p->name,
chptr->chname, rb_dlink_list_length(&chptr->members),
channel_modes(chptr, &me), chptr->topic ? chptr->topic : "");
}

View File

@ -44,8 +44,8 @@
static int mo_omode(struct Client *, struct Client *, int, const char **);
struct Message omode_msgtab = {
"OMODE", 0, 0, 0, MFLG_SLOW,
{mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_omode, 3}}
"OMODE", 0, 0, 0, MFLG_SLOW,
{mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_omode, 3}}
};
mapi_clist_av1 omode_clist[] = { &omode_msgtab, NULL };
@ -59,174 +59,199 @@ DECLARE_MODULE_AV1(omode, NULL, NULL, omode_clist, NULL, NULL, "$Revision: 3121
static int
mo_omode(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
struct Channel *chptr = NULL;
struct membership *msptr;
char params[512];
int i;
int wasonchannel;
struct Channel *chptr = NULL;
struct membership *msptr;
char params[512];
int i;
int wasonchannel;
/* admins only */
if(!IsOperAdmin(source_p)) {
sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "admin");
return 0;
}
/* admins only */
if(!IsOperAdmin(source_p))
{
sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "admin");
return 0;
}
/* Now, try to find the channel in question */
if(!IsChanPrefix(parv[1][0]) || !check_channel_name(parv[1])) {
sendto_one_numeric(source_p, ERR_BADCHANNAME,
form_str(ERR_BADCHANNAME), parv[1]);
return 0;
}
/* Now, try to find the channel in question */
if(!IsChanPrefix(parv[1][0]) || !check_channel_name(parv[1]))
{
sendto_one_numeric(source_p, ERR_BADCHANNAME,
form_str(ERR_BADCHANNAME), parv[1]);
return 0;
}
chptr = find_channel(parv[1]);
chptr = find_channel(parv[1]);
if(chptr == NULL) {
sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL,
form_str(ERR_NOSUCHCHANNEL), parv[1]);
return 0;
}
if(chptr == NULL)
{
sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL,
form_str(ERR_NOSUCHCHANNEL), parv[1]);
return 0;
}
/* Now know the channel exists */
msptr = find_channel_membership(chptr, source_p);
wasonchannel = msptr != NULL;
/* Now know the channel exists */
msptr = find_channel_membership(chptr, source_p);
wasonchannel = msptr != NULL;
if (is_any_op(msptr)) {
sendto_one_notice(source_p, ":Use a normal MODE you idiot");
return 0;
}
if (is_any_op(msptr))
{
sendto_one_notice(source_p, ":Use a normal MODE you idiot");
return 0;
}
params[0] = '\0';
for (i = 2; i < parc; i++) {
if (i != 2)
rb_strlcat(params, " ", sizeof params);
rb_strlcat(params, parv[i], sizeof params);
}
params[0] = '\0';
for (i = 2; i < parc; i++)
{
if (i != 2)
rb_strlcat(params, " ", sizeof params);
rb_strlcat(params, parv[i], sizeof params);
}
sendto_wallops_flags(UMODE_WALLOP, &me,
"OMODE called for [%s] [%s] by %s!%s@%s",
parv[1], params, source_p->name, source_p->username, source_p->host);
ilog(L_MAIN, "OMODE called for [%s] [%s] by %s",
parv[1], params, get_oper_name(source_p));
sendto_wallops_flags(UMODE_WALLOP, &me,
"OMODE called for [%s] [%s] by %s!%s@%s",
parv[1], params, source_p->name, source_p->username, source_p->host);
ilog(L_MAIN, "OMODE called for [%s] [%s] by %s",
parv[1], params, get_oper_name(source_p));
if(*chptr->chname != '&')
sendto_server(NULL, NULL, NOCAPS, NOCAPS,
":%s WALLOPS :OMODE called for [%s] [%s] by %s!%s@%s",
me.name, parv[1], params, source_p->name, source_p->username,
source_p->host);
if(*chptr->chname != '&')
sendto_server(NULL, NULL, NOCAPS, NOCAPS,
":%s WALLOPS :OMODE called for [%s] [%s] by %s!%s@%s",
me.name, parv[1], params, source_p->name, source_p->username,
source_p->host);
#if 0
set_channel_mode(client_p, source_p->servptr, chptr, msptr,
parc - 2, parv + 2);
set_channel_mode(client_p, source_p->servptr, chptr, msptr,
parc - 2, parv + 2);
#else
if (parc == 4 && !strcmp(parv[2], "+y") && !irccmp(parv[3], source_p->name)) {
/* Ownering themselves */
if (!wasonchannel) {
sendto_one_numeric(source_p, ERR_USERNOTINCHANNEL,
form_str(ERR_USERNOTINCHANNEL), parv[3], chptr->chname);
return 0;
if (parc == 4 && !strcmp(parv[2], "+y") && !irccmp(parv[3], source_p->name))
{
/* Ownering themselves */
if (!wasonchannel)
{
sendto_one_numeric(source_p, ERR_USERNOTINCHANNEL,
form_str(ERR_USERNOTINCHANNEL), parv[3], chptr->chname);
return 0;
}
sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +y %s",
me.name, parv[1], source_p->name);
sendto_server(NULL, chptr, CAP_TS6, NOCAPS,
":%s TMODE %ld %s +y %s",
me.id, (long) chptr->channelts, parv[1],
source_p->id);
msptr->flags |= CHFL_OWNER;
}
sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +y %s",
me.name, parv[1], source_p->name);
sendto_server(NULL, chptr, CAP_TS6, NOCAPS,
":%s TMODE %ld %s +y %s",
me.id, (long) chptr->channelts, parv[1],
source_p->id);
msptr->flags |= CHFL_OWNER;
} else if (parc == 4 && !strcmp(parv[2], "+a") && !irccmp(parv[3], source_p->name)) {
/* Admining themselves */
if (!wasonchannel) {
sendto_one_numeric(source_p, ERR_USERNOTINCHANNEL,
form_str(ERR_USERNOTINCHANNEL), parv[3], chptr->chname);
return 0;
}
sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +a %s",
me.name, parv[1], source_p->name);
sendto_server(NULL, chptr, CAP_TS6, NOCAPS,
":%s TMODE %ld %s +a %s",
me.id, (long) chptr->channelts, parv[1],
source_p->id);
msptr->flags |= CHFL_ADMIN;
} else if (parc == 4 && !strcmp(parv[2], "+o") && !irccmp(parv[3], source_p->name)) {
/* Opping themselves */
if (!wasonchannel) {
sendto_one_numeric(source_p, ERR_USERNOTINCHANNEL,
form_str(ERR_USERNOTINCHANNEL), parv[3], chptr->chname);
return 0;
}
sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +o %s",
me.name, parv[1], source_p->name);
sendto_server(NULL, chptr, CAP_TS6, NOCAPS,
":%s TMODE %ld %s +o %s",
me.id, (long) chptr->channelts, parv[1],
source_p->id);
msptr->flags |= CHFL_CHANOP;
} else if (parc == 4 && !strcmp(parv[2], "+h") && !irccmp(parv[3], source_p->name)) {
/* Halfopping themselves */
if (!wasonchannel) {
sendto_one_numeric(source_p, ERR_USERNOTINCHANNEL,
form_str(ERR_USERNOTINCHANNEL), parv[3], chptr->chname);
return 0;
}
sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +h %s",
me.name, parv[1], source_p->name);
sendto_server(NULL, chptr, CAP_TS6, NOCAPS,
":%s TMODE %ld %s +h %s",
me.id, (long) chptr->channelts, parv[1],
source_p->id);
msptr->flags |= CHFL_HALFOP;
} else if (ConfigChannel.use_owner) {
/* I hope this is correct.
* -- Kabaka */
else if (parc == 4 && !strcmp(parv[2], "+a") && !irccmp(parv[3], source_p->name))
{
/* Admining themselves */
if (!wasonchannel)
{
sendto_one_numeric(source_p, ERR_USERNOTINCHANNEL,
form_str(ERR_USERNOTINCHANNEL), parv[3], chptr->chname);
return 0;
}
sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +a %s",
me.name, parv[1], source_p->name);
sendto_server(NULL, chptr, CAP_TS6, NOCAPS,
":%s TMODE %ld %s +a %s",
me.id, (long) chptr->channelts, parv[1],
source_p->id);
msptr->flags |= CHFL_ADMIN;
}
else if (parc == 4 && !strcmp(parv[2], "+o") && !irccmp(parv[3], source_p->name))
{
/* Opping themselves */
if (!wasonchannel)
{
sendto_one_numeric(source_p, ERR_USERNOTINCHANNEL,
form_str(ERR_USERNOTINCHANNEL), parv[3], chptr->chname);
return 0;
}
sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +o %s",
me.name, parv[1], source_p->name);
sendto_server(NULL, chptr, CAP_TS6, NOCAPS,
":%s TMODE %ld %s +o %s",
me.id, (long) chptr->channelts, parv[1],
source_p->id);
msptr->flags |= CHFL_CHANOP;
}
else if (parc == 4 && !strcmp(parv[2], "+h") && !irccmp(parv[3], source_p->name))
{
/* Halfopping themselves */
if (!wasonchannel)
{
sendto_one_numeric(source_p, ERR_USERNOTINCHANNEL,
form_str(ERR_USERNOTINCHANNEL), parv[3], chptr->chname);
return 0;
}
sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +h %s",
me.name, parv[1], source_p->name);
sendto_server(NULL, chptr, CAP_TS6, NOCAPS,
":%s TMODE %ld %s +h %s",
me.id, (long) chptr->channelts, parv[1],
source_p->id);
msptr->flags |= CHFL_HALFOP;
}
else if (ConfigChannel.use_owner)
{
/* I hope this is correct.
* -- Kabaka */
/* Hack it so set_channel_mode() will accept */
if (wasonchannel)
msptr->flags |= CHFL_OWNER;
else {
add_user_to_channel(chptr, source_p, CHFL_CHANOP);
msptr = find_channel_membership(chptr, source_p);
/* Hack it so set_channel_mode() will accept */
if (wasonchannel)
msptr->flags |= CHFL_OWNER;
else
{
add_user_to_channel(chptr, source_p, CHFL_CHANOP);
msptr = find_channel_membership(chptr, source_p);
}
set_channel_mode(client_p, source_p, chptr, msptr,
parc - 2, parv + 2);
if (wasonchannel)
msptr->flags &= ~CHFL_OWNER;
else
remove_user_from_channel(msptr);
}
set_channel_mode(client_p, source_p, chptr, msptr,
parc - 2, parv + 2);
if (wasonchannel)
msptr->flags &= ~CHFL_OWNER;
else
remove_user_from_channel(msptr);
} else if (ConfigChannel.use_admin) {
/* Hack it so set_channel_mode() will accept */
if (wasonchannel)
msptr->flags |= CHFL_ADMIN;
else {
add_user_to_channel(chptr, source_p, CHFL_CHANOP);
msptr = find_channel_membership(chptr, source_p);
}
set_channel_mode(client_p, source_p, chptr, msptr,
parc - 2, parv + 2);
/* We know they were not opped before and they can't have opped
* themselves as set_channel_mode() does not allow that
* -- jilles */
if (wasonchannel)
msptr->flags &= ~CHFL_ADMIN;
else
remove_user_from_channel(msptr);
} else {
/* CHFL_ADMIN is only useful if admin is enabled
* so hack it with op if it is not. */
if (wasonchannel)
msptr->flags |= CHFL_CHANOP;
else {
add_user_to_channel(chptr, source_p, CHFL_CHANOP);
msptr = find_channel_membership(chptr, source_p);
}
set_channel_mode(client_p, source_p, chptr, msptr,
parc - 2, parv + 2);
/* We know they were not opped before and they can't have opped
* themselves as set_channel_mode() does not allow that
* -- jilles */
if (wasonchannel)
msptr->flags &= ~CHFL_CHANOP;
else
remove_user_from_channel(msptr);
}
else if (ConfigChannel.use_admin)
{
/* Hack it so set_channel_mode() will accept */
if (wasonchannel)
msptr->flags |= CHFL_ADMIN;
else
{
add_user_to_channel(chptr, source_p, CHFL_CHANOP);
msptr = find_channel_membership(chptr, source_p);
}
set_channel_mode(client_p, source_p, chptr, msptr,
parc - 2, parv + 2);
/* We know they were not opped before and they can't have opped
* themselves as set_channel_mode() does not allow that
* -- jilles */
if (wasonchannel)
msptr->flags &= ~CHFL_ADMIN;
else
remove_user_from_channel(msptr);
}
else
{
/* CHFL_ADMIN is only useful if admin is enabled
* so hack it with op if it is not. */
if (wasonchannel)
msptr->flags |= CHFL_CHANOP;
else
{
add_user_to_channel(chptr, source_p, CHFL_CHANOP);
msptr = find_channel_membership(chptr, source_p);
}
set_channel_mode(client_p, source_p, chptr, msptr,
parc - 2, parv + 2);
/* We know they were not opped before and they can't have opped
* themselves as set_channel_mode() does not allow that
* -- jilles */
if (wasonchannel)
msptr->flags &= ~CHFL_CHANOP;
else
remove_user_from_channel(msptr);
}
#endif
return 0;
return 0;
}

View File

@ -37,8 +37,8 @@
static int mo_opme(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
struct Message opme_msgtab = {
"OPME", 0, 0, 0, MFLG_SLOW,
{mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_opme, 2}}
"OPME", 0, 0, 0, MFLG_SLOW,
{mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_opme, 2}}
};
mapi_clist_av1 opme_clist[] = { &opme_msgtab, NULL };
@ -53,57 +53,62 @@ DECLARE_MODULE_AV1(opme, NULL, NULL, opme_clist, NULL, NULL, "$Revision: 3554 $"
static int
mo_opme(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
struct Channel *chptr;
struct membership *msptr;
rb_dlink_node *ptr;
struct Channel *chptr;
struct membership *msptr;
rb_dlink_node *ptr;
/* admins only */
if(!IsOperAdmin(source_p)) {
sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "admin");
return 0;
}
/* admins only */
if(!IsOperAdmin(source_p))
{
sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "admin");
return 0;
}
if((chptr = find_channel(parv[1])) == NULL) {
sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL,
form_str(ERR_NOSUCHCHANNEL), parv[1]);
return 0;
}
if((chptr = find_channel(parv[1])) == NULL)
{
sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL,
form_str(ERR_NOSUCHCHANNEL), parv[1]);
return 0;
}
RB_DLINK_FOREACH(ptr, chptr->members.head) {
msptr = ptr->data;
RB_DLINK_FOREACH(ptr, chptr->members.head)
{
msptr = ptr->data;
if(is_chanop(msptr) || is_admin(msptr) || is_owner(msptr)) {
sendto_one_notice(source_p, ":%s Channel is not opless", parv[1]);
return 0;
}
}
if(is_chanop(msptr) || is_admin(msptr) || is_owner(msptr))
{
sendto_one_notice(source_p, ":%s Channel is not opless", parv[1]);
return 0;
}
}
msptr = find_channel_membership(chptr, source_p);
msptr = find_channel_membership(chptr, source_p);
if(msptr == NULL)
return 0;
if(msptr == NULL)
return 0;
msptr->flags |= CHFL_CHANOP;
msptr->flags |= CHFL_CHANOP;
sendto_wallops_flags(UMODE_WALLOP, &me,
"OPME called for [%s] by %s!%s@%s",
parv[1], source_p->name, source_p->username, source_p->host);
ilog(L_MAIN, "OPME called for [%s] by %s",
parv[1], get_oper_name(source_p));
sendto_wallops_flags(UMODE_WALLOP, &me,
"OPME called for [%s] by %s!%s@%s",
parv[1], source_p->name, source_p->username, source_p->host);
ilog(L_MAIN, "OPME called for [%s] by %s",
parv[1], get_oper_name(source_p));
/* dont send stuff for local channels remotely. */
if(*chptr->chname != '&') {
sendto_server(NULL, NULL, NOCAPS, NOCAPS,
":%s WALLOPS :OPME called for [%s] by %s!%s@%s",
me.name, parv[1], source_p->name, source_p->username, source_p->host);
sendto_server(NULL, chptr, CAP_TS6, NOCAPS, ":%s PART %s", source_p->id, parv[1]);
sendto_server(NULL, chptr, CAP_TS6, NOCAPS,
":%s SJOIN %ld %s + :@%s",
me.id, (long) chptr->channelts, parv[1], source_p->id);
}
/* dont send stuff for local channels remotely. */
if(*chptr->chname != '&')
{
sendto_server(NULL, NULL, NOCAPS, NOCAPS,
":%s WALLOPS :OPME called for [%s] by %s!%s@%s",
me.name, parv[1], source_p->name, source_p->username, source_p->host);
sendto_server(NULL, chptr, CAP_TS6, NOCAPS, ":%s PART %s", source_p->id, parv[1]);
sendto_server(NULL, chptr, CAP_TS6, NOCAPS,
":%s SJOIN %ld %s + :@%s",
me.id, (long) chptr->channelts, parv[1], source_p->id);
}
sendto_channel_local(ALL_MEMBERS, chptr,
":%s MODE %s +o %s", me.name, parv[1], source_p->name);
sendto_channel_local(ALL_MEMBERS, chptr,
":%s MODE %s +o %s", me.name, parv[1], source_p->name);
return 0;
return 0;
}

View File

@ -6,9 +6,9 @@
* to clearly show that it is fake. SCENE is a special case and not underlined.
* these commands only work on channels set +N
*
* also adds oper commands FSAY and FACTION, which are like NPC and NPCA
* also adds oper commands FSAY and FACTION, which are like NPC and NPCA
* except without the underline.
*
*
* all of these messages have the hostmask npc.fakeuser.invalid, and their ident
* is the nickname of the user running the commands.
*/
@ -39,57 +39,57 @@ static unsigned int mymode;
static int
_modinit(void)
{
/* initalize the +N cmode */
mymode = cflag_add('N', chm_simple);
if (mymode == 0)
return -1;
/* initalize the +N cmode */
mymode = cflag_add('N', chm_simple);
if (mymode == 0)
return -1;
return 0;
return 0;
}
static void
_moddeinit(void)
{
/* orphan the +N cmode on modunload */
cflag_orphan('N');
/* orphan the +N cmode on modunload */
cflag_orphan('N');
}
struct Message scene_msgtab = {
"SCENE", 0, 0, 0, MFLG_SLOW,
{mg_unreg, {m_scene, 3}, mg_ignore, mg_ignore, mg_ignore, {m_scene, 3}}
"SCENE", 0, 0, 0, MFLG_SLOW,
{mg_unreg, {m_scene, 3}, mg_ignore, mg_ignore, mg_ignore, {m_scene, 3}}
};
/* this serves as an alias for people who are used to inspircd/unreal m_roleplay */
struct Message ambiance_msgtab = {
"AMBIANCE", 0, 0, 0, MFLG_SLOW,
{mg_unreg, {m_scene, 3}, mg_ignore, mg_ignore, mg_ignore, {m_scene, 3}}
};
"AMBIANCE", 0, 0, 0, MFLG_SLOW,
{mg_unreg, {m_scene, 3}, mg_ignore, mg_ignore, mg_ignore, {m_scene, 3}}
};
struct Message fsay_msgtab = {
"FSAY", 0, 0, 0, MFLG_SLOW,
{mg_unreg, {m_npc, 4}, mg_ignore, mg_ignore, mg_ignore, {m_fsay, 4}}
};
"FSAY", 0, 0, 0, MFLG_SLOW,
{mg_unreg, {m_npc, 4}, mg_ignore, mg_ignore, mg_ignore, {m_fsay, 4}}
};
struct Message faction_msgtab = {
"FACTION", 0, 0, 0, MFLG_SLOW,
{mg_unreg, {m_npca, 4}, mg_ignore, mg_ignore, mg_ignore, {m_faction, 4}}
};
"FACTION", 0, 0, 0, MFLG_SLOW,
{mg_unreg, {m_npca, 4}, mg_ignore, mg_ignore, mg_ignore, {m_faction, 4}}
};
struct Message npc_msgtab = {
"NPC", 0, 0, 0, MFLG_SLOW,
{mg_unreg, {m_npc, 4}, mg_ignore, mg_ignore, mg_ignore, {m_npc, 4}}
};
"NPC", 0, 0, 0, MFLG_SLOW,
{mg_unreg, {m_npc, 4}, mg_ignore, mg_ignore, mg_ignore, {m_npc, 4}}
};
struct Message npca_msgtab = {
"NPCA", 0, 0, 0, MFLG_SLOW,
{mg_unreg, {m_npca, 4}, mg_ignore, mg_ignore, mg_ignore, {m_npca, 4}}
};
"NPCA", 0, 0, 0, MFLG_SLOW,
{mg_unreg, {m_npca, 4}, mg_ignore, mg_ignore, mg_ignore, {m_npca, 4}}
};
struct Message roleplay_msgtab = {
"ROLEPLAY", 0, 0, 0, MFLG_SLOW,
{mg_ignore, mg_ignore, mg_ignore, mg_ignore, {me_roleplay, 4}, mg_ignore}
};
"ROLEPLAY", 0, 0, 0, MFLG_SLOW,
{mg_ignore, mg_ignore, mg_ignore, mg_ignore, {me_roleplay, 4}, mg_ignore}
};
mapi_clist_av1 roleplay_clist[] = { &scene_msgtab, &ambiance_msgtab, &fsay_msgtab, &faction_msgtab, &npc_msgtab, &npca_msgtab, &roleplay_msgtab, NULL };
@ -98,112 +98,118 @@ DECLARE_MODULE_AV1(roleplay, _modinit, _moddeinit, roleplay_clist, NULL, NULL, "
static int
m_scene(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
m_displaymsg(source_p, parv[1], 0, 0, "=Scene=", parv[2]);
return 0;
m_displaymsg(source_p, parv[1], 0, 0, "=Scene=", parv[2]);
return 0;
}
static int
m_fsay(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
m_displaymsg(source_p, parv[1], 0, 0, parv[2], parv[3]);
return 0;
m_displaymsg(source_p, parv[1], 0, 0, parv[2], parv[3]);
return 0;
}
static int
m_faction(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
m_displaymsg(source_p, parv[1], 0, 1, parv[2], parv[3]);
return 0;
m_displaymsg(source_p, parv[1], 0, 1, parv[2], parv[3]);
return 0;
}
static int
m_npc(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
m_displaymsg(source_p, parv[1], 1, 0, parv[2], parv[3]);
return 0;
m_displaymsg(source_p, parv[1], 1, 0, parv[2], parv[3]);
return 0;
}
static int
m_npca(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
m_displaymsg(source_p, parv[1], 1, 1, parv[2], parv[3]);
return 0;
m_displaymsg(source_p, parv[1], 1, 1, parv[2], parv[3]);
return 0;
}
static int
m_displaymsg(struct Client *source_p, const char *channel, int underline, int action, const char *nick, const char *text)
{
struct Channel *chptr;
struct membership *msptr;
char nick2[NICKLEN+1];
char *nick3 = rb_strdup(nick);
char text2[BUFSIZE];
struct Channel *chptr;
struct membership *msptr;
char nick2[NICKLEN+1];
char *nick3 = rb_strdup(nick);
char text2[BUFSIZE];
if((chptr = find_channel(channel)) == NULL) {
sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL), channel);
return 0;
}
if((chptr = find_channel(channel)) == NULL)
{
sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL), channel);
return 0;
}
if(!(msptr = find_channel_membership(chptr, source_p))) {
sendto_one_numeric(source_p, ERR_NOTONCHANNEL,
form_str(ERR_NOTONCHANNEL), chptr->chname);
return 0;
}
if(!(msptr = find_channel_membership(chptr, source_p)))
{
sendto_one_numeric(source_p, ERR_NOTONCHANNEL,
form_str(ERR_NOTONCHANNEL), chptr->chname);
return 0;
}
if(!(chptr->mode.mode & chmode_flags['N'])) {
sendto_one_numeric(source_p, 573, "%s :Roleplay commands are not enabled on this channel.", chptr->chname);
return 0;
}
if(!(chptr->mode.mode & chmode_flags['N']))
{
sendto_one_numeric(source_p, 573, "%s :Roleplay commands are not enabled on this channel.", chptr->chname);
return 0;
}
if(!can_send(chptr, source_p, msptr)) {
sendto_one_numeric(source_p, 573, "%s :Cannot send to channel.", chptr->chname);
return 0;
}
if(!can_send(chptr, source_p, msptr))
{
sendto_one_numeric(source_p, 573, "%s :Cannot send to channel.", chptr->chname);
return 0;
}
/* enforce flood stuff on roleplay commands */
if(flood_attack_channel(0, source_p, chptr, chptr->chname))
return 0;
/* enforce flood stuff on roleplay commands */
if(flood_attack_channel(0, source_p, chptr, chptr->chname))
return 0;
/* enforce target change on roleplay commands */
if(!is_chanop_voiced(msptr) && !IsOper(source_p) && !add_channel_target(source_p, chptr)) {
sendto_one(source_p, form_str(ERR_TARGCHANGE),
me.name, source_p->name, chptr->chname);
return 0;
}
/* enforce target change on roleplay commands */
if(!is_chanop_voiced(msptr) && !IsOper(source_p) && !add_channel_target(source_p, chptr))
{
sendto_one(source_p, form_str(ERR_TARGCHANGE),
me.name, source_p->name, chptr->chname);
return 0;
}
if(underline)
snprintf(nick2, sizeof(nick2), "\x1F%s\x1F", strip_unprintable(nick3));
else
snprintf(nick2, sizeof(nick2), "%s", strip_unprintable(nick3));
if(underline)
rb_snprintf(nick2, sizeof(nick2), "\x1F%s\x1F", strip_unprintable(nick3));
else
rb_snprintf(nick2, sizeof(nick2), "%s", strip_unprintable(nick3));
/* don't allow nicks to be empty after stripping
* this prevents nastiness like fake factions, etc. */
if(EmptyString(nick3)) {
sendto_one_numeric(source_p, 573, "%s :No visible non-stripped characters in nick.", chptr->chname);
return 0;
}
/* don't allow nicks to be empty after stripping
* this prevents nastiness like fake factions, etc. */
if(EmptyString(nick3))
{
sendto_one_numeric(source_p, 573, "%s :No visible non-stripped characters in nick.", chptr->chname);
return 0;
}
if(action)
snprintf(text2, sizeof(text2), "\1ACTION %s\1", text);
else
snprintf(text2, sizeof(text2), "%s", text);
if(action)
rb_snprintf(text2, sizeof(text2), "\1ACTION %s\1", text);
else
rb_snprintf(text2, sizeof(text2), "%s", text);
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@npc.fakeuser.invalid PRIVMSG %s :%s (%s)", nick2, source_p->name, channel, text2, source_p->name);
sendto_match_servs(source_p, "*", CAP_ENCAP, NOCAPS, "ENCAP * ROLEPLAY %s %s :%s",
channel, nick2, text2);
return 0;
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@npc.fakeuser.invalid PRIVMSG %s :%s", nick2, source_p->name, channel, text2);
sendto_match_servs(source_p, "*", CAP_ENCAP, NOCAPS, "ENCAP * ROLEPLAY %s %s :%s",
channel, nick2, text2);
return 0;
}
static int
me_roleplay(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
struct Channel *chptr;
struct Channel *chptr;
/* Don't segfault if we get ROLEPLAY with an invalid channel.
* This shouldn't happen but it's best to be on the safe side. */
if((chptr = find_channel(parv[1])) == NULL)
return 0;
/* Don't segfault if we get ROLEPLAY with an invalid channel.
* This shouldn't happen but it's best to be on the safe side. */
if((chptr = find_channel(parv[1])) == NULL)
return 0;
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@npc.fakeuser.invalid PRIVMSG %s :%s (%s)", parv[2], source_p->name, parv[1], parv[3], source_p->name);
return 0;
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@npc.fakeuser.invalid PRIVMSG %s :%s", parv[2], source_p->name, parv[1], parv[3]);
return 0;
}

View File

@ -46,120 +46,130 @@
static int mo_sendbans(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
struct Message sendbans_msgtab = {
"SENDBANS", 0, 0, 0, MFLG_SLOW,
{mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_sendbans, 2}}
"SENDBANS", 0, 0, 0, MFLG_SLOW,
{mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_sendbans, 2}}
};
mapi_clist_av1 sendbans_clist[] = {
&sendbans_msgtab,
NULL
&sendbans_msgtab,
NULL
};
DECLARE_MODULE_AV1(sendbans, NULL, NULL, sendbans_clist, NULL, NULL, "$Revision$");
static const char *expand_xline(const char *mask)
{
static char buf[512];
const char *p;
char *q;
static char buf[512];
const char *p;
char *q;
if (!strchr(mask, ' '))
return mask;
if (strlen(mask) > 250)
return NULL;
p = mask;
q = buf;
while (*p != '\0') {
if (*p == ' ')
*q++ = '\\', *q++ = 's';
else
*q++ = *p;
p++;
}
*q = '\0';
return buf;
if (!strchr(mask, ' '))
return mask;
if (strlen(mask) > 250)
return NULL;
p = mask;
q = buf;
while (*p != '\0')
{
if (*p == ' ')
*q++ = '\\', *q++ = 's';
else
*q++ = *p;
p++;
}
*q = '\0';
return buf;
}
static int mo_sendbans(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
struct ConfItem *aconf;
rb_dlink_node *ptr;
int i, count;
const char *target, *mask2;
struct Client *server_p;
struct ConfItem *aconf;
rb_dlink_node *ptr;
int i, count;
const char *target, *mask2;
struct Client *server_p;
if (!IsOperRemoteBan(source_p)) {
sendto_one(source_p, form_str(ERR_NOPRIVS),
me.name, source_p->name, "remoteban");
return 0;
}
if (!IsOperXline(source_p)) {
sendto_one(source_p, form_str(ERR_NOPRIVS),
me.name, source_p->name, "xline");
return 0;
}
if (!IsOperResv(source_p)) {
sendto_one(source_p, form_str(ERR_NOPRIVS),
me.name, source_p->name, "resv");
return 0;
}
if (!IsOperRemoteBan(source_p))
{
sendto_one(source_p, form_str(ERR_NOPRIVS),
me.name, source_p->name, "remoteban");
return 0;
}
if (!IsOperXline(source_p))
{
sendto_one(source_p, form_str(ERR_NOPRIVS),
me.name, source_p->name, "xline");
return 0;
}
if (!IsOperResv(source_p))
{
sendto_one(source_p, form_str(ERR_NOPRIVS),
me.name, source_p->name, "resv");
return 0;
}
target = parv[1];
count = 0;
RB_DLINK_FOREACH(ptr, global_serv_list.head) {
server_p = ptr->data;
if (IsMe(server_p))
continue;
if (match(target, server_p->name))
count++;
}
if (count == 0) {
sendto_one_numeric(source_p, ERR_NOSUCHSERVER,
form_str(ERR_NOSUCHSERVER), target);
return 0;
}
target = parv[1];
count = 0;
RB_DLINK_FOREACH(ptr, global_serv_list.head)
{
server_p = ptr->data;
if (IsMe(server_p))
continue;
if (match(target, server_p->name))
count++;
}
if (count == 0)
{
sendto_one_numeric(source_p, ERR_NOSUCHSERVER,
form_str(ERR_NOSUCHSERVER), target);
return 0;
}
sendto_realops_snomask(SNO_GENERAL, L_NETWIDE,
"%s!%s@%s is sending resvs and xlines to %s",
source_p->name, source_p->username, source_p->host,
target);
sendto_realops_snomask(SNO_GENERAL, L_NETWIDE,
"%s!%s@%s is sending resvs and xlines to %s",
source_p->name, source_p->username, source_p->host,
target);
RB_DLINK_FOREACH(ptr, resv_conf_list.head) {
aconf = ptr->data;
if (aconf->hold)
continue;
sendto_match_servs(source_p, target,
CAP_ENCAP, NOCAPS,
"ENCAP %s RESV 0 %s 0 :%s",
target, aconf->host, aconf->passwd);
}
RB_DLINK_FOREACH(ptr, resv_conf_list.head)
{
aconf = ptr->data;
if (aconf->hold)
continue;
sendto_match_servs(source_p, target,
CAP_ENCAP, NOCAPS,
"ENCAP %s RESV 0 %s 0 :%s",
target, aconf->host, aconf->passwd);
}
HASH_WALK(i, R_MAX, ptr, resvTable) {
aconf = ptr->data;
if (aconf->hold)
continue;
sendto_match_servs(source_p, target,
CAP_ENCAP, NOCAPS,
"ENCAP %s RESV 0 %s 0 :%s",
target, aconf->host, aconf->passwd);
}
HASH_WALK_END
HASH_WALK(i, R_MAX, ptr, resvTable)
{
aconf = ptr->data;
if (aconf->hold)
continue;
sendto_match_servs(source_p, target,
CAP_ENCAP, NOCAPS,
"ENCAP %s RESV 0 %s 0 :%s",
target, aconf->host, aconf->passwd);
}
HASH_WALK_END
RB_DLINK_FOREACH(ptr, xline_conf_list.head) {
aconf = ptr->data;
if (aconf->hold)
continue;
mask2 = expand_xline(aconf->host);
if (mask2 == NULL) {
sendto_one_notice(source_p, ":Skipping xline [%s]",
aconf->host);
continue;
}
sendto_match_servs(source_p, target,
CAP_ENCAP, NOCAPS,
"ENCAP %s XLINE 0 %s 2 :%s",
target, mask2, aconf->passwd);
}
RB_DLINK_FOREACH(ptr, xline_conf_list.head)
{
aconf = ptr->data;
if (aconf->hold)
continue;
mask2 = expand_xline(aconf->host);
if (mask2 == NULL)
{
sendto_one_notice(source_p, ":Skipping xline [%s]",
aconf->host);
continue;
}
sendto_match_servs(source_p, target,
CAP_ENCAP, NOCAPS,
"ENCAP %s XLINE 0 %s 2 :%s",
target, mask2, aconf->passwd);
}
return 0;
return 0;
}

View File

@ -57,8 +57,8 @@
static int mr_webirc(struct Client *, struct Client *, int, const char **);
struct Message webirc_msgtab = {
"WEBIRC", 0, 0, 0, MFLG_SLOW | MFLG_UNREG,
{{mr_webirc, 5}, mg_reg, mg_ignore, mg_ignore, mg_ignore, mg_reg}
"WEBIRC", 0, 0, 0, MFLG_SLOW | MFLG_UNREG,
{{mr_webirc, 5}, mg_reg, mg_ignore, mg_ignore, mg_ignore, mg_reg}
};
mapi_clist_av1 webirc_clist[] = { &webirc_msgtab, NULL };
@ -68,68 +68,74 @@ DECLARE_MODULE_AV1(webirc, NULL, NULL, webirc_clist, NULL, NULL, "$Revision: 207
* mr_webirc - webirc message handler
* parv[1] = password
* parv[2] = fake username (we ignore this)
* parv[3] = fake hostname
* parv[3] = fake hostname
* parv[4] = fake ip
*/
static int
mr_webirc(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
struct ConfItem *aconf;
const char *encr;
struct ConfItem *aconf;
const char *encr;
if (!strchr(parv[4], '.') && !strchr(parv[4], ':')) {
sendto_one(source_p, "NOTICE * :Invalid IP");
return 0;
}
if (!strchr(parv[4], '.') && !strchr(parv[4], ':'))
{
sendto_one(source_p, "NOTICE * :Invalid IP");
return 0;
}
aconf = find_address_conf(client_p->host, client_p->sockhost,
IsGotId(client_p) ? client_p->username : "webirc",
IsGotId(client_p) ? client_p->username : "webirc",
(struct sockaddr *) &client_p->localClient->ip,
client_p->localClient->ip.ss_family, NULL);
if (aconf == NULL || !(aconf->status & CONF_CLIENT))
return 0;
if (!IsConfDoSpoofIp(aconf) || irccmp(aconf->info.name, "webirc.")) {
/* XXX */
sendto_one(source_p, "NOTICE * :Not a CGI:IRC auth block");
return 0;
}
if (EmptyString(aconf->passwd)) {
sendto_one(source_p, "NOTICE * :CGI:IRC auth blocks must have a password");
return 0;
}
aconf = find_address_conf(client_p->host, client_p->sockhost,
IsGotId(client_p) ? client_p->username : "webirc",
IsGotId(client_p) ? client_p->username : "webirc",
(struct sockaddr *) &client_p->localClient->ip,
client_p->localClient->ip.ss_family, NULL);
if (aconf == NULL || !(aconf->status & CONF_CLIENT))
return 0;
if (!IsConfDoSpoofIp(aconf) || irccmp(aconf->info.name, "webirc."))
{
/* XXX */
sendto_one(source_p, "NOTICE * :Not a CGI:IRC auth block");
return 0;
}
if (EmptyString(aconf->passwd))
{
sendto_one(source_p, "NOTICE * :CGI:IRC auth blocks must have a password");
return 0;
}
if (EmptyString(parv[1]))
encr = "";
else if (IsConfEncrypted(aconf))
encr = rb_crypt(parv[1], aconf->passwd);
else
encr = parv[1];
if (EmptyString(parv[1]))
encr = "";
else if (IsConfEncrypted(aconf))
encr = rb_crypt(parv[1], aconf->passwd);
else
encr = parv[1];
if (strcmp(encr, aconf->passwd)) {
sendto_one(source_p, "NOTICE * :CGI:IRC password incorrect");
return 0;
}
if (strcmp(encr, aconf->passwd))
{
sendto_one(source_p, "NOTICE * :CGI:IRC password incorrect");
return 0;
}
rb_strlcpy(source_p->sockhost, parv[4], sizeof(source_p->sockhost));
rb_strlcpy(source_p->sockhost, parv[4], sizeof(source_p->sockhost));
if(strlen(parv[3]) <= HOSTLEN)
rb_strlcpy(source_p->host, parv[3], sizeof(source_p->host));
else
rb_strlcpy(source_p->host, source_p->sockhost, sizeof(source_p->host));
if(strlen(parv[3]) <= HOSTLEN)
rb_strlcpy(source_p->host, parv[3], sizeof(source_p->host));
else
rb_strlcpy(source_p->host, source_p->sockhost, sizeof(source_p->host));
rb_inet_pton_sock(parv[4], (struct sockaddr *)&source_p->localClient->ip);
rb_inet_pton_sock(parv[4], (struct sockaddr *)&source_p->localClient->ip);
/* Check dlines now, klines will be checked on registration */
if((aconf = find_dline((struct sockaddr *)&source_p->localClient->ip,
source_p->localClient->ip.ss_family)))
{
if(!(aconf->status & CONF_EXEMPTDLINE))
{
exit_client(client_p, source_p, &me, "D-lined");
return 0;
}
}
/* Check dlines now, klines will be checked on registration */
if((aconf = find_dline((struct sockaddr *)&source_p->localClient->ip,
source_p->localClient->ip.ss_family))) {
if(!(aconf->status & CONF_EXEMPTDLINE)) {
exit_client(client_p, source_p, &me, "D-lined");
return 0;
}
}
sendto_one(source_p, "NOTICE * :CGI:IRC host/IP set to %s %s", parv[3], parv[4]);
return 0;
sendto_one(source_p, "NOTICE * :CGI:IRC host/IP set to %s %s", parv[3], parv[4]);
return 0;
}

View File

@ -15,8 +15,8 @@
static void h_nl_umode_changed(hook_data_umode_changed *);
mapi_hfn_list_av1 nl_hfnlist[] = {
{ "umode_changed", (hookfn) h_nl_umode_changed },
{ NULL, NULL }
{ "umode_changed", (hookfn) h_nl_umode_changed },
{ NULL, NULL }
};
DECLARE_MODULE_AV1(no_locops, NULL, NULL, NULL, NULL, nl_hfnlist, "$Revision: 3219 $");
@ -24,9 +24,10 @@ DECLARE_MODULE_AV1(no_locops, NULL, NULL, NULL, NULL, nl_hfnlist, "$Revision: 32
static void
h_nl_umode_changed(hook_data_umode_changed *hdata)
{
struct Client *source_p = hdata->client;
struct Client *source_p = hdata->client;
if (MyClient(source_p) && source_p->umodes & UMODE_LOCOPS) {
source_p->umodes &= ~UMODE_LOCOPS;
}
if (MyClient(source_p) && source_p->umodes & UMODE_LOCOPS)
{
source_p->umodes &= ~UMODE_LOCOPS;
}
}

View File

@ -17,8 +17,8 @@
static void h_noi_umode_changed(hook_data_umode_changed *);
mapi_hfn_list_av1 noi_hfnlist[] = {
{ "umode_changed", (hookfn) h_noi_umode_changed },
{ NULL, NULL }
{ "umode_changed", (hookfn) h_noi_umode_changed },
{ NULL, NULL }
};
DECLARE_MODULE_AV1(no_oper_invis, NULL, NULL, NULL, NULL, noi_hfnlist, "$Revision: 3219 $");
@ -26,14 +26,15 @@ DECLARE_MODULE_AV1(no_oper_invis, NULL, NULL, NULL, NULL, noi_hfnlist, "$Revisio
static void
h_noi_umode_changed(hook_data_umode_changed *hdata)
{
struct Client *source_p = hdata->client;
struct Client *source_p = hdata->client;
if (MyClient(source_p) && IsOper(source_p) && !IsOperInvis(source_p) &&
IsInvisible(source_p)) {
ClearInvisible(source_p);
/* If they tried /umode +i, complain; do not complain
* if they opered up while invisible -- jilles */
if (hdata->oldumodes & UMODE_OPER)
sendto_one_notice(source_p, ":*** Opers may not set themselves invisible");
}
if (MyClient(source_p) && IsOper(source_p) && !IsOperInvis(source_p) &&
IsInvisible(source_p))
{
ClearInvisible(source_p);
/* If they tried /umode +i, complain; do not complain
* if they opered up while invisible -- jilles */
if (hdata->oldumodes & UMODE_OPER)
sendto_one_notice(source_p, ":*** Opers may not set themselves invisible");
}
}

View File

@ -22,9 +22,9 @@ static void h_gcn_new_remote_user(struct Client *);
static void h_gcn_client_exit(hook_data_client_exit *);
mapi_hfn_list_av1 gcn_hfnlist[] = {
{ "new_remote_user", (hookfn) h_gcn_new_remote_user },
{ "client_exit", (hookfn) h_gcn_client_exit },
{ NULL, NULL }
{ "new_remote_user", (hookfn) h_gcn_new_remote_user },
{ "client_exit", (hookfn) h_gcn_client_exit },
{ NULL, NULL }
};
DECLARE_MODULE_AV1(globalconnexit, _modinit, _moddeinit, NULL, NULL, gcn_hfnlist, "$Revision: 1869 $");
@ -32,49 +32,49 @@ DECLARE_MODULE_AV1(globalconnexit, _modinit, _moddeinit, NULL, NULL, gcn_hfnlist
static int
_modinit(void)
{
/* add the snomask to the available slot */
snomask_modes['F'] = find_snomask_slot();
/* add the snomask to the available slot */
snomask_modes['F'] = find_snomask_slot();
/* show the fact that we are showing user information in /version */
opers_see_all_users = 1;
/* show the fact that we are showing user information in /version */
opers_see_all_users = 1;
return 0;
return 0;
}
static void
_moddeinit(void)
{
/* disable the snomask and remove it from the available list */
snomask_modes['F'] = 0;
/* disable the snomask and remove it from the available list */
snomask_modes['F'] = 0;
}
static void
h_gcn_new_remote_user(struct Client *source_p)
{
if (!HasSentEob(source_p->servptr))
return;
sendto_realops_snomask_from(snomask_modes['F'], L_ALL, source_p->servptr,
"Client connecting: %s (%s@%s) [%s] {%s} [%s]",
source_p->name, source_p->username, source_p->orighost,
show_ip(NULL, source_p) ? source_p->sockhost : "255.255.255.255",
"?", source_p->info);
if (!HasSentEob(source_p->servptr))
return;
sendto_realops_snomask_from(snomask_modes['F'], L_ALL, source_p->servptr,
"Client connecting: %s (%s@%s) [%s] {%s} [%s]",
source_p->name, source_p->username, source_p->orighost,
show_ip(NULL, source_p) ? source_p->sockhost : "255.255.255.255",
"?", source_p->info);
}
static void
h_gcn_client_exit(hook_data_client_exit *hdata)
{
struct Client *source_p;
struct Client *source_p;
source_p = hdata->target;
source_p = hdata->target;
if (MyConnect(source_p) || !IsClient(source_p))
return;
if (!HasSentEob(source_p->servptr))
return;
sendto_realops_snomask_from(snomask_modes['F'], L_ALL, source_p->servptr,
"Client exiting: %s (%s@%s) [%s] [%s]",
source_p->name,
source_p->username, source_p->host, hdata->comment,
show_ip(NULL, source_p) ? source_p->sockhost : "255.255.255.255");
if (MyConnect(source_p) || !IsClient(source_p))
return;
if (!HasSentEob(source_p->servptr))
return;
sendto_realops_snomask_from(snomask_modes['F'], L_ALL, source_p->servptr,
"Client exiting: %s (%s@%s) [%s] [%s]",
source_p->name,
source_p->username, source_p->host, hdata->comment,
show_ip(NULL, source_p) ? source_p->sockhost : "255.255.255.255");
}

View File

@ -19,8 +19,8 @@
static void h_gla_client_exit(hook_data_client_exit *);
mapi_hfn_list_av1 gla_hfnlist[] = {
{ "client_exit", (hookfn) h_gla_client_exit },
{ NULL, NULL }
{ "client_exit", (hookfn) h_gla_client_exit },
{ NULL, NULL }
};
DECLARE_MODULE_AV1(globallineactive, NULL, NULL, NULL, NULL, gla_hfnlist, "$Revision: 613 $");
@ -28,28 +28,35 @@ DECLARE_MODULE_AV1(globallineactive, NULL, NULL, NULL, NULL, gla_hfnlist, "$Revi
static void
h_gla_client_exit(hook_data_client_exit *hdata)
{
struct Client *source_p;
struct Client *source_p;
source_p = hdata->target;
source_p = hdata->target;
if (MyConnect(source_p) || !IsClient(source_p))
return;
if (!strcmp(hdata->comment, "Bad user info")) {
sendto_realops_snomask_from(SNO_GENERAL, L_ALL, source_p->servptr,
"XLINE active for %s[%s@%s]",
source_p->name, source_p->username, source_p->host);
} else if (ConfigFileEntry.kline_reason != NULL &&
!strcmp(hdata->comment, ConfigFileEntry.kline_reason)) {
sendto_realops_snomask_from(SNO_GENERAL, L_ALL, source_p->servptr,
"K/DLINE active for %s[%s@%s]",
source_p->name, source_p->username, source_p->host);
} else if (!strncmp(hdata->comment, "Temporary K-line ", 17)) {
sendto_realops_snomask_from(SNO_GENERAL, L_ALL, source_p->servptr,
"K/DLINE active for %s[%s@%s]",
source_p->name, source_p->username, source_p->host);
} else if (!strncmp(hdata->comment, "Temporary D-line ", 17)) {
sendto_realops_snomask_from(SNO_GENERAL, L_ALL, source_p->servptr,
"K/DLINE active for %s[%s@%s]",
source_p->name, source_p->username, source_p->host);
}
if (MyConnect(source_p) || !IsClient(source_p))
return;
if (!strcmp(hdata->comment, "Bad user info"))
{
sendto_realops_snomask_from(SNO_GENERAL, L_ALL, source_p->servptr,
"XLINE active for %s[%s@%s]",
source_p->name, source_p->username, source_p->host);
}
else if (ConfigFileEntry.kline_reason != NULL &&
!strcmp(hdata->comment, ConfigFileEntry.kline_reason))
{
sendto_realops_snomask_from(SNO_GENERAL, L_ALL, source_p->servptr,
"K/DLINE active for %s[%s@%s]",
source_p->name, source_p->username, source_p->host);
}
else if (!strncmp(hdata->comment, "Temporary K-line ", 17))
{
sendto_realops_snomask_from(SNO_GENERAL, L_ALL, source_p->servptr,
"K/DLINE active for %s[%s@%s]",
source_p->name, source_p->username, source_p->host);
}
else if (!strncmp(hdata->comment, "Temporary D-line ", 17))
{
sendto_realops_snomask_from(SNO_GENERAL, L_ALL, source_p->servptr,
"K/DLINE active for %s[%s@%s]",
source_p->name, source_p->username, source_p->host);
}
}

View File

@ -15,8 +15,8 @@
static void h_sgo_umode_changed(void *);
mapi_hfn_list_av1 sgo_hfnlist[] = {
{ "umode_changed", (hookfn) h_sgo_umode_changed },
{ NULL, NULL }
{ "umode_changed", (hookfn) h_sgo_umode_changed },
{ NULL, NULL }
};
DECLARE_MODULE_AV1(sno_globaloper, NULL, NULL, NULL, NULL, sgo_hfnlist, "$Revision: 639 $");
@ -24,14 +24,14 @@ DECLARE_MODULE_AV1(sno_globaloper, NULL, NULL, NULL, NULL, sgo_hfnlist, "$Revisi
static void
h_sgo_umode_changed(void *vdata)
{
hook_data_umode_changed *data = (hook_data_umode_changed *)vdata;
struct Client *source_p = data->client;
hook_data_umode_changed *data = (hook_data_umode_changed *)vdata;
struct Client *source_p = data->client;
if (MyConnect(source_p) || !HasSentEob(source_p->servptr))
return;
if (MyConnect(source_p) || !HasSentEob(source_p->servptr))
return;
if (!(data->oldumodes & UMODE_OPER) && IsOper(source_p))
sendto_realops_snomask_from(SNO_GENERAL, L_ALL, source_p->servptr,
"%s (%s@%s) is now an operator",
source_p->name, source_p->username, source_p->host);
if (!(data->oldumodes & UMODE_OPER) && IsOper(source_p))
sendto_realops_snomask_from(SNO_GENERAL, L_ALL, source_p->servptr,
"%s (%s@%s) is now an operator",
source_p->name, source_p->username, source_p->host);
}

View File

@ -20,23 +20,23 @@
void show_whois(hook_data_client *);
mapi_hfn_list_av1 whois_hfnlist[] = {
{"doing_whois", (hookfn) show_whois},
{"doing_whois_global", (hookfn) show_whois},
{NULL, NULL}
{"doing_whois", (hookfn) show_whois},
{"doing_whois_global", (hookfn) show_whois},
{NULL, NULL}
};
static int
init(void)
{
snomask_modes['W'] = find_snomask_slot();
snomask_modes['W'] = find_snomask_slot();
return 0;
return 0;
}
static void
fini(void)
{
snomask_modes['W'] = find_snomask_slot();
snomask_modes['W'] = find_snomask_slot();
}
DECLARE_MODULE_AV1(sno_whois, init, fini, NULL, NULL, whois_hfnlist, "$Revision: 3498 $");
@ -44,19 +44,20 @@ DECLARE_MODULE_AV1(sno_whois, init, fini, NULL, NULL, whois_hfnlist, "$Revision:
void
show_whois(hook_data_client *data)
{
struct Client *source_p = data->client;
struct Client *target_p = data->target;
struct Client *source_p = data->client;
struct Client *target_p = data->target;
if(MyClient(target_p) &&
if(MyClient(target_p) &&
#ifdef OPERONLY
IsOper(target_p) &&
IsOper(target_p) &&
#endif
(source_p != target_p) &&
(target_p->snomask & snomask_modes['W'])) {
sendto_one_notice(target_p,
":*** Notice -- %s (%s@%s) is doing a whois on you [%s]",
source_p->name,
source_p->username, source_p->host,
source_p->servptr->name);
}
(source_p != target_p) &&
(target_p->snomask & snomask_modes['W']))
{
sendto_one_notice(target_p,
":*** Notice -- %s (%s@%s) is doing a whois on you [%s]",
source_p->name,
source_p->username, source_p->host,
source_p->servptr->name);
}
}

View File

@ -30,8 +30,8 @@
void show_admin(hook_data *);
mapi_hfn_list_av1 admin_hfnlist[] = {
{"doing_admin", (hookfn) show_admin},
{NULL, NULL}
{"doing_admin", (hookfn) show_admin},
{NULL, NULL}
};
DECLARE_MODULE_AV1(admin_spy, NULL, NULL, NULL, NULL, admin_hfnlist, "$Revision: 498 $");
@ -39,8 +39,8 @@ DECLARE_MODULE_AV1(admin_spy, NULL, NULL, NULL, NULL, admin_hfnlist, "$Revision:
void
show_admin(hook_data *data)
{
sendto_realops_snomask(SNO_SPY, L_ALL,
"admin requested by %s (%s@%s) [%s]",
data->client->name, data->client->username,
data->client->host, data->client->servptr->name);
sendto_realops_snomask(SNO_SPY, L_ALL,
"admin requested by %s (%s@%s) [%s]",
data->client->name, data->client->username,
data->client->host, data->client->servptr->name);
}

View File

@ -30,8 +30,8 @@
void show_info(hook_data *);
mapi_hfn_list_av1 info_hfnlist[] = {
{"doing_info", (hookfn) show_info},
{NULL, NULL}
{"doing_info", (hookfn) show_info},
{NULL, NULL}
};
DECLARE_MODULE_AV1(info_spy, NULL, NULL, NULL, NULL, info_hfnlist, "$Revision: 498 $");
@ -39,8 +39,8 @@ DECLARE_MODULE_AV1(info_spy, NULL, NULL, NULL, NULL, info_hfnlist, "$Revision: 4
void
show_info(hook_data *data)
{
sendto_realops_snomask(SNO_SPY, L_ALL,
"info requested by %s (%s@%s) [%s]",
data->client->name, data->client->username,
data->client->host, data->client->servptr->name);
sendto_realops_snomask(SNO_SPY, L_ALL,
"info requested by %s (%s@%s) [%s]",
data->client->name, data->client->username,
data->client->host, data->client->servptr->name);
}

View File

@ -30,8 +30,8 @@
void show_links(hook_data *);
mapi_hfn_list_av1 links_hfnlist[] = {
{"doing_links", (hookfn) show_links},
{NULL, NULL}
{"doing_links", (hookfn) show_links},
{NULL, NULL}
};
DECLARE_MODULE_AV1(links_spy, NULL, NULL, NULL, NULL, links_hfnlist, "$Revision: 498 $");
@ -39,10 +39,10 @@ DECLARE_MODULE_AV1(links_spy, NULL, NULL, NULL, NULL, links_hfnlist, "$Revision:
void
show_links(hook_data *data)
{
const char *mask = data->arg1;
const char *mask = data->arg1;
sendto_realops_snomask(SNO_SPY, L_ALL,
"LINKS '%s' requested by %s (%s@%s) [%s]",
mask, data->client->name, data->client->username,
data->client->host, data->client->servptr->name);
sendto_realops_snomask(SNO_SPY, L_ALL,
"LINKS '%s' requested by %s (%s@%s) [%s]",
mask, data->client->name, data->client->username,
data->client->host, data->client->servptr->name);
}

View File

@ -30,8 +30,8 @@
void show_motd(hook_data *);
mapi_hfn_list_av1 motd_hfnlist[] = {
{"doing_motd", (hookfn) show_motd},
{NULL, NULL}
{"doing_motd", (hookfn) show_motd},
{NULL, NULL}
};
DECLARE_MODULE_AV1(motd_spy, NULL, NULL, NULL, NULL, motd_hfnlist, "$Revision: 498 $");
@ -39,8 +39,8 @@ DECLARE_MODULE_AV1(motd_spy, NULL, NULL, NULL, NULL, motd_hfnlist, "$Revision: 4
void
show_motd(hook_data *data)
{
sendto_realops_snomask(SNO_SPY, L_ALL,
"motd requested by %s (%s@%s) [%s]",
data->client->name, data->client->username,
data->client->host, data->client->servptr->name);
sendto_realops_snomask(SNO_SPY, L_ALL,
"motd requested by %s (%s@%s) [%s]",
data->client->name, data->client->username,
data->client->host, data->client->servptr->name);
}

View File

@ -30,8 +30,8 @@
void show_stats(hook_data_int *);
mapi_hfn_list_av1 stats_hfnlist[] = {
{"doing_stats", (hookfn) show_stats},
{NULL, NULL}
{"doing_stats", (hookfn) show_stats},
{NULL, NULL}
};
DECLARE_MODULE_AV1(stats_spy, NULL, NULL, NULL, NULL, stats_hfnlist, "$Revision: 498 $");
@ -39,28 +39,31 @@ DECLARE_MODULE_AV1(stats_spy, NULL, NULL, NULL, NULL, stats_hfnlist, "$Revision:
void
show_stats(hook_data_int *data)
{
char statchar = (char) data->arg2;
char statchar = (char) data->arg2;
if(statchar == 'L' || statchar == 'l') {
const char *name = data->arg1;
if(statchar == 'L' || statchar == 'l')
{
const char *name = data->arg1;
if(!EmptyString(name))
sendto_realops_snomask(SNO_SPY, L_ALL,
"STATS %c requested by %s (%s@%s) [%s] on %s",
statchar, data->client->name,
data->client->username,
data->client->host,
data->client->servptr->name, name);
else
sendto_realops_snomask(SNO_SPY, L_ALL,
"STATS %c requested by %s (%s@%s) [%s]",
statchar, data->client->name,
data->client->username,
data->client->host, data->client->servptr->name);
} else {
sendto_realops_snomask(SNO_SPY, L_ALL,
"STATS %c requested by %s (%s@%s) [%s]",
statchar, data->client->name, data->client->username,
data->client->host, data->client->servptr->name);
}
if(!EmptyString(name))
sendto_realops_snomask(SNO_SPY, L_ALL,
"STATS %c requested by %s (%s@%s) [%s] on %s",
statchar, data->client->name,
data->client->username,
data->client->host,
data->client->servptr->name, name);
else
sendto_realops_snomask(SNO_SPY, L_ALL,
"STATS %c requested by %s (%s@%s) [%s]",
statchar, data->client->name,
data->client->username,
data->client->host, data->client->servptr->name);
}
else
{
sendto_realops_snomask(SNO_SPY, L_ALL,
"STATS %c requested by %s (%s@%s) [%s]",
statchar, data->client->name, data->client->username,
data->client->host, data->client->servptr->name);
}
}

View File

@ -30,8 +30,8 @@
void show_stats_p(hook_data *);
mapi_hfn_list_av1 stats_p_hfnlist[] = {
{"doing_stats_p", (hookfn) show_stats_p},
{NULL, NULL}
{"doing_stats_p", (hookfn) show_stats_p},
{NULL, NULL}
};
DECLARE_MODULE_AV1(stats_p_spy, NULL, NULL, NULL, NULL, stats_p_hfnlist, "$Revision: 498 $");
@ -39,8 +39,8 @@ DECLARE_MODULE_AV1(stats_p_spy, NULL, NULL, NULL, NULL, stats_p_hfnlist, "$Revis
void
show_stats_p(hook_data *data)
{
sendto_realops_snomask(SNO_SPY, L_ALL,
"STATS p requested by %s (%s@%s) [%s]",
data->client->name, data->client->username,
data->client->host, data->client->servptr->name);
sendto_realops_snomask(SNO_SPY, L_ALL,
"STATS p requested by %s (%s@%s) [%s]",
data->client->name, data->client->username,
data->client->host, data->client->servptr->name);
}

View File

@ -30,8 +30,8 @@
void show_trace(hook_data_client *);
mapi_hfn_list_av1 trace_hfnlist[] = {
{"doing_trace", (hookfn) show_trace},
{NULL, NULL}
{"doing_trace", (hookfn) show_trace},
{NULL, NULL}
};
DECLARE_MODULE_AV1(trace_spy, NULL, NULL, NULL, NULL, trace_hfnlist, "$Revision: 498 $");
@ -39,15 +39,15 @@ DECLARE_MODULE_AV1(trace_spy, NULL, NULL, NULL, NULL, trace_hfnlist, "$Revision:
void
show_trace(hook_data_client *data)
{
if(data->target)
sendto_realops_snomask(SNO_SPY, L_ALL,
"trace requested by %s (%s@%s) [%s] on %s",
data->client->name, data->client->username,
data->client->host, data->client->servptr->name,
data->target->name);
else
sendto_realops_snomask(SNO_SPY, L_ALL,
"trace requested by %s (%s@%s) [%s]",
data->client->name, data->client->username,
data->client->host, data->client->servptr->name);
if(data->target)
sendto_realops_snomask(SNO_SPY, L_ALL,
"trace requested by %s (%s@%s) [%s] on %s",
data->client->name, data->client->username,
data->client->host, data->client->servptr->name,
data->target->name);
else
sendto_realops_snomask(SNO_SPY, L_ALL,
"trace requested by %s (%s@%s) [%s]",
data->client->name, data->client->username,
data->client->host, data->client->servptr->name);
}

View File

@ -1,3 +0,0 @@
#!/bin/sh
setuser ircd /home/ircd/run/bin/ircd -foreground

File diff suppressed because it is too large Load Diff

View File

@ -1,414 +0,0 @@
/* Elemental-IRCd functions
*
* (C) 2014 Sam Dodrill <shadowh511@gmail.com>
* (C) 2003-2014 Anope Team
* Contact us at team@anope.org
*
* Please read COPYING and README for further details.
*
* Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church.
*/
#include "module.h"
#include "modules/cs_mode.h"
#include "modules/sasl.h"
static Anope::string UplinkSID;
static ServiceReference<IRCDProto> ratbox("IRCDProto", "ratbox");
class ChannelModeLargeBan : public ChannelMode
{
public:
ChannelModeLargeBan(const Anope::string &mname, char modeChar) : ChannelMode(mname, modeChar) { }
bool CanSet(User *u) const anope_override
{
return u && u->HasMode("OPER");
}
};
class ElementalProto : public IRCDProto
{
public:
ElementalProto(Module *creator) : IRCDProto(creator, "Elemental-IRCd 6.5+")
{
DefaultPseudoclientModes = "+oiS";
CanCertFP = true;
CanSNLine = true;
CanSQLine = true;
CanSZLine = true;
CanSVSNick = true;
CanSVSHold = true;
CanSetVHost = true;
RequiresID = true;
MaxModes = 4;
}
void SendSVSKillInternal(const MessageSource &source, User *targ, const Anope::string &reason) anope_override { ratbox->SendSVSKillInternal(source, targ, reason); }
void SendGlobalNotice(BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override { ratbox->SendGlobalNotice(bi, dest, msg); }
void SendGlobalPrivmsg(BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override { ratbox->SendGlobalPrivmsg(bi, dest, msg); }
void SendGlobopsInternal(const MessageSource &source, const Anope::string &buf) anope_override { ratbox->SendGlobopsInternal(source, buf); }
void SendSGLine(User *u, const XLine *x) anope_override { ratbox->SendSGLine(u, x); }
void SendSGLineDel(const XLine *x) anope_override { ratbox->SendSGLineDel(x); }
void SendAkill(User *u, XLine *x) anope_override { ratbox->SendAkill(u, x); }
void SendAkillDel(const XLine *x) anope_override { ratbox->SendAkillDel(x); }
void SendSQLineDel(const XLine *x) anope_override { ratbox->SendSQLineDel(x); }
void SendJoin(User *user, Channel *c, const ChannelStatus *status) anope_override { ratbox->SendJoin(user, c, status); }
void SendServer(const Server *server) anope_override { ratbox->SendServer(server); }
void SendChannel(Channel *c) anope_override { ratbox->SendChannel(c); }
void SendTopic(const MessageSource &source, Channel *c) anope_override { ratbox->SendTopic(source, c); }
bool IsIdentValid(const Anope::string &ident) anope_override { return ratbox->IsIdentValid(ident); }
void SendLogin(User *u, NickAlias *na) anope_override { ratbox->SendLogin(u, na); }
void SendLogout(User *u) anope_override { ratbox->SendLogout(u); }
void SendSQLine(User *, const XLine *x) anope_override
{
UplinkSocket::Message(Me) << "RESV * " << x->mask << " :" << x->GetReason();
}
void SendConnect() anope_override
{
UplinkSocket::Message() << "PASS " << Config->Uplinks[Anope::CurrentUplink].password << " TS 6 :" << Me->GetSID();
/*
* Received: CAPAB :BAN CHW CLUSTER ENCAP EOPMOD EUID EX IE KLN
* KNOCK MLOCK QS RSFNC SAVE SERVICES TB UNKLN
*
* BAN - Can do BAN message
* CHW - Can do channel wall @#
* CLUSTER - Supports umode +l, can send LOCOPS (encap only)
* ENCAP - Can do ENCAP message
* EOPMOD - Can do channel wall =# (for cmode +z)
* EUID - Can do EUID (its similar to UID but includes the ENCAP REALHOST and ENCAP LOGIN information)
* EX - Can do channel +e exemptions
* GLN - Can set G:Lines
* IE - Can do invite exceptions
* KLN - Can set K:Lines (encap only)
* KNOCK - Supports KNOCK
* MLOCK - Supports MLOCK
* RSFNC - Forces a nickname change and propagates it (encap only)
* SERVICES - Support channel mode +r (only registered users may join)
* SAVE - Resolve a nick collision by changing a nickname to the UID.
* TB - Supports topic burst
* UNKLN - Can do UNKLINE (encap only)
* QS - Can handle quit storm removal
*/
UplinkSocket::Message() << "CAPAB :BAN CHW CLUSTER ENCAP EOPMOD EUID EX IE KLN KNOCK MLOCK QS RSFNC SERVICES TB UNKLN";
/* Make myself known to myself in the serverlist */
SendServer(Me);
/*
* Received: SVINFO 6 6 0 :1353235537
* arg[0] = current TS version
* arg[1] = minimum required TS version
* arg[2] = '0'
* arg[3] = server's idea of UTC time
*/
UplinkSocket::Message() << "SVINFO 6 6 0 :" << Anope::CurTime;
}
void SendClientIntroduction(User *u) anope_override
{
Anope::string modes = "+" + u->GetModes();
UplinkSocket::Message(Me) << "EUID " << u->nick << " 1 " << u->timestamp << " " << modes << " " << u->GetIdent() << " " << u->host << " 0 " << u->GetUID() << " * * :" << u->realname;
}
void SendForceNickChange(User *u, const Anope::string &newnick, time_t when) anope_override
{
UplinkSocket::Message(Me) << "ENCAP " << u->server->GetName() << " RSFNC " << u->GetUID()
<< " " << newnick << " " << when << " " << u->timestamp;
}
void SendSVSHold(const Anope::string &nick, time_t delay) anope_override
{
UplinkSocket::Message(Me) << "ENCAP * NICKDELAY " << delay << " " << nick;
}
void SendSVSHoldDel(const Anope::string &nick) anope_override
{
UplinkSocket::Message(Me) << "ENCAP * NICKDELAY 0 " << nick;
}
void SendVhost(User *u, const Anope::string &ident, const Anope::string &host) anope_override
{
UplinkSocket::Message(Me) << "ENCAP * CHGHOST " << u->GetUID() << " :" << host;
}
void SendVhostDel(User *u) anope_override
{
this->SendVhost(u, "", u->host);
}
void SendSASLMessage(const SASL::Message &message) anope_override
{
Server *s = Server::Find(message.target.substr(0, 3));
UplinkSocket::Message(Me) << "ENCAP " << (s ? s->GetName() : message.target.substr(0, 3)) << " SASL " << message.source << " " << message.target << " " << message.type << " " << message.data << (message.ext.empty() ? "" : (" " + message.ext));
}
void SendSVSLogin(const Anope::string &uid, const Anope::string &acc) anope_override
{
Server *s = Server::Find(uid.substr(0, 3));
UplinkSocket::Message(Me) << "ENCAP " << (s ? s->GetName() : uid.substr(0, 3)) << " SVSLOGIN " << uid << " * * * " << acc;
}
};
struct IRCDMessageEncap : IRCDMessage
{
IRCDMessageEncap(Module *creator) : IRCDMessage(creator, "ENCAP", 3) { SetFlag(IRCDMESSAGE_SOFT_LIMIT);}
void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
{
User *u = source.GetUser();
// In a burst, states that the source user is logged in as the account.
if (params[1] == "LOGIN" || params[1] == "SU")
{
NickCore *nc = NickCore::Find(params[2]);
if (!nc)
return;
u->Login(nc);
}
// Received: :42XAAAAAE ENCAP * CERTFP :3f122a9cc7811dbad3566bf2cec3009007c0868f
if (params[1] == "CERTFP")
{
u->fingerprint = params[2];
FOREACH_MOD(OnFingerprint, (u));
}
/*
* Received: :42X ENCAP * SASL 42XAAAAAH * S PLAIN
* Received: :42X ENCAP * SASL 42XAAAAAC * D A
*
* Part of a SASL authentication exchange. The mode is 'C' to send some data
* (base64 encoded), or 'S' to end the exchange (data indicates type of
* termination: 'A' for abort, 'F' for authentication failure, 'S' for
* authentication success).
*
* Charybdis only accepts messages from SASL agents; these must have umode +S
*/
if (params[1] == "SASL" && SASL::sasl && params.size() >= 6)
{
SASL::Message m;
m.source = params[2];
m.target = params[3];
m.type = params[4];
m.data = params[5];
m.ext = params.size() > 6 ? params[6] : "";
SASL::sasl->ProcessMessage(m);
}
}
};
struct IRCDMessageEUID : IRCDMessage
{
IRCDMessageEUID(Module *creator) : IRCDMessage(creator, "EUID", 11) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
/*
* :42X EUID DukePyrolator 1 1353240577 +Zi ~jens erft-5d80b00b.pool.mediaWays.net 93.128.176.11 42XAAAAAD * * :jens
* :<SID> EUID <NICK> <HOPS> <TS> +<UMODE> <USERNAME> <VHOST> <IP> <UID> <REALHOST> <ACCOUNT> :<GECOS>
* 0 1 2 3 4 5 6 7 8 9 10
*
* Introduces a user. The hostname field is now always the visible host.
* The realhost field is * if the real host is equal to the visible host.
* The account field is * if the login is not set.
* Note that even if both new fields are *, an EUID command still carries more
* information than a UID command (namely that real host is visible host and the
* user is not logged in with services). Hence a NICK or UID command received
* from a remote server should not be sent in EUID form to other servers.
*/
void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
{
NickAlias *na = NULL;
if (params[9] != "*")
na = NickAlias::Find(params[9]);
User::OnIntroduce(params[0], params[4], params[8], params[5], params[6], source.GetServer(), params[10], params[2].is_pos_number_only() ? convertTo<time_t>(params[2]) : Anope::CurTime, params[3], params[7], na ? *na->nc : NULL);
}
};
// we cant use this function from ratbox because we set a local variable here
struct IRCDMessageServer : IRCDMessage
{
IRCDMessageServer(Module *creator) : IRCDMessage(creator, "SERVER", 3) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
// SERVER dev.anope.de 1 :charybdis test server
void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
{
// Servers other then our immediate uplink are introduced via SID
if (params[1] != "1")
return;
new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], 1, params[2], UplinkSID);
IRCD->SendPing(Me->GetName(), params[0]);
}
};
// we cant use this function from ratbox because we set a local variable here
struct IRCDMessagePass : IRCDMessage
{
IRCDMessagePass(Module *creator) : IRCDMessage(creator, "PASS", 4) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
void Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
{
// UplinkSID is used in IRCDMessageServer
UplinkSID = params[3];
}
};
class ProtoElemental : public Module
{
Module *m_ratbox;
ElementalProto ircd_proto;
/* Core message handlers */
Message::Away message_away;
Message::Capab message_capab;
Message::Error message_error;
Message::Invite message_invite;
Message::Kick message_kick;
Message::Kill message_kill;
Message::Mode message_mode;
Message::MOTD message_motd;
Message::Notice message_notice;
Message::Part message_part;
Message::Ping message_ping;
Message::Privmsg message_privmsg;
Message::Quit message_quit;
Message::SQuit message_squit;
Message::Stats message_stats;
Message::Time message_time;
Message::Topic message_topic;
Message::Version message_version;
Message::Whois message_whois;
/* Ratbox Message Handlers */
ServiceAlias message_bmask, message_join, message_nick, message_pong, message_sid, message_sjoin,
message_tb, message_tmode, message_uid;
/* Our message handlers */
IRCDMessageEncap message_encap;
IRCDMessageEUID message_euid;
IRCDMessagePass message_pass;
IRCDMessageServer message_server;
bool use_server_side_mlock;
void AddModes()
{
ModeManager::AddChannelMode(new ChannelModeStatus("HALFOP", 'h', '%', 1));
ModeManager::AddChannelMode(new ChannelModeStatus("PROTECT", 'a', '!', 3));
ModeManager::AddChannelMode(new ChannelModeStatus("OWNER", 'y', '~', 4));
/* Add user modes */
ModeManager::AddUserMode(new UserMode("NOFORWARD", 'Q'));
ModeManager::AddUserMode(new UserMode("REGPRIV", 'R'));
ModeManager::AddUserMode(new UserModeOperOnly("OPERWALLS", 'z'));
ModeManager::AddUserMode(new UserModeNoone("SSL", 'Z'));
/* b/e/I */
ModeManager::AddChannelMode(new ChannelModeList("QUIET", 'q'));
/* Add channel modes */
ModeManager::AddChannelMode(new ChannelMode("BLOCKCOLOR", 'c'));
ModeManager::AddChannelMode(new ChannelMode("NOCTCP", 'C'));
ModeManager::AddChannelMode(new ChannelModeParam("REDIRECT", 'f'));
ModeManager::AddChannelMode(new ChannelMode("ALLOWFORWARD", 'F'));
ModeManager::AddChannelMode(new ChannelMode("ALLINVITE", 'g'));
ModeManager::AddChannelMode(new ChannelModeParam("JOINFLOOD", 'j'));
ModeManager::AddChannelMode(new ChannelModeLargeBan("LBAN", 'L'));
ModeManager::AddChannelMode(new ChannelMode("PERM", 'P'));
ModeManager::AddChannelMode(new ChannelMode("NOFORWARD", 'Q'));
ModeManager::AddChannelMode(new ChannelMode("OPMODERATED", 'z'));
}
public:
ProtoElemental(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PROTOCOL | VENDOR),
ircd_proto(this),
message_away(this), message_capab(this), message_error(this), message_invite(this), message_kick(this),
message_kill(this), message_mode(this), message_motd(this), message_notice(this), message_part(this),
message_ping(this), message_privmsg(this), message_quit(this), message_squit(this), message_stats(this),
message_time(this), message_topic(this), message_version(this), message_whois(this),
message_bmask("IRCDMessage", "charybdis/bmask", "ratbox/bmask"),
message_join("IRCDMessage", "charybdis/join", "ratbox/join"),
message_nick("IRCDMessage", "charybdis/nick", "ratbox/nick"),
message_pong("IRCDMessage", "charybdis/pong", "ratbox/pong"),
message_sid("IRCDMessage", "charybdis/sid", "ratbox/sid"),
message_sjoin("IRCDMessage", "charybdis/sjoin", "ratbox/sjoin"),
message_tb("IRCDMessage", "charybdis/tb", "ratbox/tb"),
message_tmode("IRCDMessage", "charybdis/tmode", "ratbox/tmode"),
message_uid("IRCDMessage", "charybdis/uid", "ratbox/uid"),
message_encap(this), message_euid(this), message_pass(this), message_server(this)
{
if (ModuleManager::LoadModule("ratbox", User::Find(creator)) != MOD_ERR_OK)
throw ModuleException("Unable to load ratbox");
m_ratbox = ModuleManager::FindModule("ratbox");
if (!m_ratbox)
throw ModuleException("Unable to find ratbox");
if (!ratbox)
throw ModuleException("No protocol interface for ratbox");
this->AddModes();
}
~ProtoElemental()
{
m_ratbox = ModuleManager::FindModule("ratbox");
ModuleManager::UnloadModule(m_ratbox, NULL);
}
void OnReload(Configuration::Conf *conf) anope_override
{
use_server_side_mlock = conf->GetModule(this)->Get<bool>("use_server_side_mlock");
}
void OnChannelSync(Channel *c) anope_override
{
if (!c->ci)
return;
ModeLocks *modelocks = c->ci->GetExt<ModeLocks>("modelocks");
if (use_server_side_mlock && modelocks && Servers::Capab.count("MLOCK") > 0)
{
Anope::string modes = modelocks->GetMLockAsString(false).replace_all_cs("+", "").replace_all_cs("-", "");
UplinkSocket::Message(Me) << "MLOCK " << static_cast<long>(c->creation_time) << " " << c->ci->name << " " << modes;
}
}
EventReturn OnMLock(ChannelInfo *ci, ModeLock *lock) anope_override
{
ModeLocks *modelocks = ci->GetExt<ModeLocks>("modelocks");
ChannelMode *cm = ModeManager::FindChannelModeByName(lock->name);
if (use_server_side_mlock && cm && ci->c && modelocks && (cm->type == MODE_REGULAR || cm->type == MODE_PARAM) && Servers::Capab.count("MLOCK") > 0)
{
Anope::string modes = modelocks->GetMLockAsString(false).replace_all_cs("+", "").replace_all_cs("-", "") + cm->mchar;
UplinkSocket::Message(Me) << "MLOCK " << static_cast<long>(ci->c->creation_time) << " " << ci->name << " " << modes;
}
return EVENT_CONTINUE;
}
EventReturn OnUnMLock(ChannelInfo *ci, ModeLock *lock) anope_override
{
ModeLocks *modelocks = ci->GetExt<ModeLocks>("modelocks");
ChannelMode *cm = ModeManager::FindChannelModeByName(lock->name);
if (use_server_side_mlock && cm && modelocks && ci->c && (cm->type == MODE_REGULAR || cm->type == MODE_PARAM) && Servers::Capab.count("MLOCK") > 0)
{
Anope::string modes = modelocks->GetMLockAsString(false).replace_all_cs("+", "").replace_all_cs("-", "").replace_all_cs(cm->mchar, "");
UplinkSocket::Message(Me) << "MLOCK " << static_cast<long>(ci->c->creation_time) << " " << ci->name << " " << modes;
}
return EVENT_CONTINUE;
}
};
MODULE_INIT(ProtoElemental)

View File

@ -1,125 +0,0 @@
/*
* Copyright (c) 2003-2004 E. Will et al.
* Copyright (c) 2005-2008 Atheme Development Group
* Copyright (c) 2008-2010 ShadowIRCd Development Group
* Copyright (c) 2013 PonyChat Development Group
* Rights to this code are documented in doc/LICENSE.
*
* This file contains protocol support for ponychat-ircd.
*
*/
#include "atheme.h"
#include "uplink.h"
#include "pmodule.h"
#include "protocol/shadowircd.h"
DECLARE_MODULE_V1("protocol/elemental-ircd", true, _modinit, NULL, PACKAGE_STRING, "PonyChat Development Group <http://www.ponychat.net>");
/* *INDENT-OFF* */
ircd_t elemental_ircd = {
"elemental-ircd", /* IRCd name */
"$$", /* TLD Prefix, used by Global. */
true, /* Whether or not we use IRCNet/TS6 UID */
false, /* Whether or not we use RCOMMAND */
true, /* Whether or not we support channel owners. */
true, /* Whether or not we support channel protection. */
true, /* Whether or not we support halfops. */
false, /* Whether or not we use P10 */
false, /* Whether or not we use vHosts. */
CMODE_EXLIMIT | CMODE_PERM | CMODE_IMMUNE, /* Oper-only cmodes */
CSTATUS_OWNER, /* Integer flag for owner channel flag. */
CSTATUS_PROTECT, /* Integer flag for protect channel flag. */
CSTATUS_HALFOP, /* Integer flag for halfops. */
"+y", /* Mode we set for owner. */
"+a", /* Mode we set for protect. */
"+h", /* Mode we set for halfops. */
PROTOCOL_SHADOWIRCD, /* Protocol type */
CMODE_PERM, /* Permanent cmodes */
CMODE_IMMUNE, /* Oper-immune cmode */
"beIq", /* Ban-like cmodes */
'e', /* Except mchar */
'I', /* Invex mchar */
IRCD_CIDR_BANS | IRCD_HOLDNICK /* Flags */
};
struct cmode_ elemental_mode_list[] = {
{ 'i', CMODE_INVITE },
{ 'm', CMODE_MOD },
{ 'n', CMODE_NOEXT },
{ 'p', CMODE_PRIV },
{ 's', CMODE_SEC },
{ 't', CMODE_TOPIC },
{ 'c', CMODE_NOCOLOR},
{ 'r', CMODE_REGONLY},
{ 'z', CMODE_OPMOD },
{ 'g', CMODE_FINVITE},
{ 'L', CMODE_EXLIMIT},
{ 'P', CMODE_PERM },
{ 'F', CMODE_FTARGET},
{ 'Q', CMODE_DISFWD },
{ 'M', CMODE_IMMUNE },
{ 'C', CMODE_NOCTCP },
{ 'A', CMODE_ADMINONLY },
{ 'O', CMODE_OPERONLY },
{ 'S', CMODE_SSLONLY },
{ 'D', CMODE_NOACTIONS },
{ 'T', CMODE_NONOTICE },
{ 'G', CMODE_NOCAPS },
{ 'E', CMODE_NOKICKS },
{ 'd', CMODE_NONICKS },
{ 'K', CMODE_NOREPEAT },
{ 'J', CMODE_KICKNOREJOIN },
{ '\0', 0 }
};
struct cmode_ elemental_status_mode_list[] = {
{ 'y', CSTATUS_OWNER },
{ 'a', CSTATUS_PROTECT },
{ 'o', CSTATUS_OP },
{ 'h', CSTATUS_HALFOP },
{ 'v', CSTATUS_VOICE },
{ '\0', 0 }
};
struct cmode_ elemental_prefix_mode_list[] = {
{ '~', CSTATUS_OWNER },
{ '!', CSTATUS_PROTECT },
{ '@', CSTATUS_OP },
{ '%', CSTATUS_HALFOP },
{ '+', CSTATUS_VOICE },
{ '\0', 0 }
};
struct cmode_ elemental_user_mode_list[] = {
{ 'a', UF_ADMIN },
{ 'i', UF_INVIS },
{ 'o', UF_IRCOP },
{ 'D', UF_DEAF },
{ '\0', 0 }
};
/* *INDENT-ON* */
void _modinit(module_t * m)
{
MODULE_TRY_REQUEST_DEPENDENCY(m, "protocol/charybdis");
mode_list = elemental_mode_list;
user_mode_list = elemental_user_mode_list;
status_mode_list = elemental_status_mode_list;
prefix_mode_list = elemental_prefix_mode_list;
ircd = &elemental_ircd;
m->mflags = MODTYPE_CORE;
pmodule_loaded = true;
}
/* vim:cinoptions=>s,e0,n0,f0,{0,}0,^0,=s,ps,t0,c3,+s,(2s,us,)20,*30,gs,hs
* vim:ts=8
* vim:sw=8
* vim:noexpandtab
*/

View File

@ -26,8 +26,6 @@ NO PARAMETERS:
weakens +i control.
+z - Op moderated. Messages blocked by +m, +b and +q are instead
sent to ops.
+u - Hidden ban/quiet list. Ban/quiet lists may only be seen
by halfops or higher.
* +L - Large ban list. Increase maximum number of +beIq entries.
* +P - Permanent. Channel does not disappear when empty.
+F - Free target. Anyone may set forwards to this (otherwise

View File

@ -16,7 +16,7 @@ $$servermask - Send a message to a server or set of
$#hostmask - Send a message to users matching the
hostmask specified.
These two require Oper Priv: oper:mass_notice
These two are operator only.
The nick can be extended to fit into the following
syntax:

View File

@ -4,4 +4,4 @@ Restarts the IRC server. If a second server name
is provided, remotely restart that server. In this
case, both server names must match.
- Requires Oper Priv: oper:die
- Requires Oper Priv: oper:admin

View File

@ -25,6 +25,4 @@ User modes: (* designates that the umode is oper only)
+G - "soft caller id" mode - same as +g but automatically allows
anyone who's in a common channel with you to message you.
+V - Prevents you from receiving invites.
+I - Prevents non-opers from seeing your channel list in
a whois query.
+Z - Is connected via SSL (set only on connection).

View File

@ -5,4 +5,4 @@ who are umode +w (including non-opers).
Server sent WALLOPS go to all opers who are umode +w.
- Requires Oper Priv: oper:mass_notice
- Requires Oper Priv: oper:operwall

View File

@ -24,8 +24,6 @@ NO PARAMETERS:
change nick.
+g - Free invite. Everyone may invite users. Significantly
weakens +i control.
+u - Hidden ban/quiet lists. Ban/quiet lists are hidden from all
channel members that are not a halfop or higher.
+z - Op moderated. Messages blocked by +m, +b and +q are instead
sent to ops.
* +L - Large ban list. Increase maximum number of +beIq entries.

View File

@ -14,8 +14,6 @@ User modes: (? designates that the umode is provided by an extension
+B - Marks you as a bot in /whois.
+C - Prevents you from receiving CTCPs other than ACTION.
+D - Deaf - ignores all channel messages.
+I - Prevents non-opers from seeing your channel list in
a whois query.
+Q - Prevents you from being affected by channel forwarding.
+R - Prevents non accept unidentified users from messaging you.
+G - "soft caller id" mode - same as +g but automatically allows

View File

@ -3,16 +3,17 @@
void init_bandb(void);
typedef enum {
BANDB_KLINE,
BANDB_DLINE,
BANDB_XLINE,
BANDB_RESV,
LAST_BANDB_TYPE
typedef enum
{
BANDB_KLINE,
BANDB_DLINE,
BANDB_XLINE,
BANDB_RESV,
LAST_BANDB_TYPE
} bandb_type;
void bandb_add(bandb_type, struct Client *source_p, const char *mask1,
const char *mask2, const char *reason, const char *oper_reason, int perm);
const char *mask2, const char *reason, const char *oper_reason, int perm);
void bandb_del(bandb_type, const char *mask1, const char *mask2);
void bandb_rehash_bans(void);
#endif

View File

@ -26,26 +26,26 @@
/* A configured DNSBL */
struct Blacklist {
unsigned int status; /* If CONF_ILLEGAL, delete when no clients */
int refcount;
int ipv4; /* Does this blacklist support IPv4 lookups? */
int ipv6; /* Does this blacklist support IPv6 lookups? */
char host[IRCD_RES_HOSTLEN + 1];
char reject_reason[IRCD_BUFSIZE];
unsigned int hits;
time_t lastwarning;
unsigned int status; /* If CONF_ILLEGAL, delete when no clients */
int refcount;
int ipv4; /* Does this blacklist support IPv4 lookups? */
int ipv6; /* Does this blacklist support IPv6 lookups? */
char host[IRCD_RES_HOSTLEN + 1];
char reject_reason[IRCD_BUFSIZE];
unsigned int hits;
time_t lastwarning;
};
/* A lookup in progress for a particular DNSBL for a particular client */
struct BlacklistClient {
struct Blacklist *blacklist;
struct Client *client_p;
struct DNSQuery dns_query;
rb_dlink_node node;
struct Blacklist *blacklist;
struct Client *client_p;
struct DNSQuery dns_query;
rb_dlink_node node;
};
/* public interfaces */
struct Blacklist *new_blacklist(char *host, char *reject_reason, int ipv4, int ipv6);
struct Blacklist *new_blacklist(char *host, char *reject_reason, int ipv4, int ipv6);
void lookup_blacklists(struct Client *client_p);
void abort_blacklist_queries(struct Client *client_p);
void unref_blacklist(struct Blacklist *blptr);

View File

@ -3,8 +3,7 @@
#define HELP_MAX 100
/* Adjusted to allow wider MOTD */
#define CACHELINELEN 513
#define CACHELINELEN 81
#define CACHEFILELEN 30
/* two servernames, a gecos, three spaces, ":1", '\0' */
#define LINKSLINELEN (HOSTLEN + HOSTLEN + REALLEN + 6)
@ -14,15 +13,17 @@
struct Client;
struct cachefile {
char name[CACHEFILELEN];
rb_dlink_list contents;
int flags;
struct cachefile
{
char name[CACHEFILELEN];
rb_dlink_list contents;
int flags;
};
struct cacheline {
char data[CACHELINELEN];
rb_dlink_node linenode;
struct cacheline
{
char data[CACHELINELEN];
rb_dlink_node linenode;
};
extern struct cachefile *user_motd;

View File

@ -35,102 +35,110 @@
struct Client;
/* mode structure for channels */
struct Mode {
unsigned int mode;
int limit;
char key[KEYLEN];
unsigned int join_num;
unsigned int join_time;
char forward[LOC_CHANNELLEN + 1];
struct Mode
{
unsigned int mode;
int limit;
char key[KEYLEN];
unsigned int join_num;
unsigned int join_time;
char forward[LOC_CHANNELLEN + 1];
};
/* channel structure */
struct Channel {
rb_dlink_node node;
struct Mode mode;
char *mode_lock;
char *topic;
char *topic_info;
time_t topic_time;
time_t last_knock; /* don't allow knock to flood */
struct Channel
{
rb_dlink_node node;
struct Mode mode;
char *mode_lock;
char *topic;
char *topic_info;
time_t topic_time;
time_t last_knock; /* don't allow knock to flood */
rb_dlink_list members; /* channel members */
rb_dlink_list locmembers; /* local channel members */
rb_dlink_list members; /* channel members */
rb_dlink_list locmembers; /* local channel members */
rb_dlink_list invites;
rb_dlink_list banlist;
rb_dlink_list exceptlist;
rb_dlink_list invexlist;
rb_dlink_list quietlist;
rb_dlink_list invites;
rb_dlink_list banlist;
rb_dlink_list exceptlist;
rb_dlink_list invexlist;
rb_dlink_list quietlist;
time_t first_received_message_time; /* channel flood control */
int received_number_of_privmsgs;
int flood_noticed;
time_t first_received_message_time; /* channel flood control */
int received_number_of_privmsgs;
int flood_noticed;
unsigned int join_count; /* joins within delta */
unsigned int join_delta; /* last ts of join */
unsigned int join_count; /* joins within delta */
unsigned int join_delta; /* last ts of join */
struct Dictionary *metadata;
struct Dictionary *metadata;
unsigned long bants;
time_t channelts;
char *chname;
unsigned long bants;
time_t channelts;
char *chname;
};
struct membership {
rb_dlink_node channode;
rb_dlink_node locchannode;
rb_dlink_node usernode;
struct membership
{
rb_dlink_node channode;
rb_dlink_node locchannode;
rb_dlink_node usernode;
struct Channel *chptr;
struct Client *client_p;
unsigned int flags;
struct Channel *chptr;
struct Client *client_p;
unsigned int flags;
unsigned long bants;
unsigned long bants;
};
#define BANLEN 195
struct Ban {
char *banstr;
char *who;
time_t when;
rb_dlink_node node;
struct Ban
{
char *banstr;
char *who;
time_t when;
rb_dlink_node node;
};
struct mode_letter {
int mode;
char letter;
struct mode_letter
{
int mode;
char letter;
};
struct ChModeChange {
char letter;
const char *arg;
const char *id;
int dir;
int caps;
int nocaps;
int mems;
int override;
struct Client *client;
struct ChModeChange
{
char letter;
const char *arg;
const char *id;
int dir;
int caps;
int nocaps;
int mems;
int override;
struct Client *client;
};
struct ChCapCombo {
int count;
int cap_yes;
int cap_no;
struct ChCapCombo
{
int count;
int cap_yes;
int cap_no;
};
typedef void (*ChannelModeFunc)(struct Client *source_p, struct Channel *chptr,
int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type);
int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type);
struct ChannelMode {
ChannelModeFunc set_func;
long mode_type;
struct ChannelMode
{
ChannelModeFunc set_func;
long mode_type;
};
typedef int (*ExtbanFunc)(const char *data, struct Client *client_p,
struct Channel *chptr, long mode_type);
struct Channel *chptr, long mode_type);
/* can_send results */
#define CAN_SEND_NO 0
@ -183,7 +191,6 @@ typedef int (*ExtbanFunc)(const char *data, struct Client *client_p,
#define MODE_NOREJOIN 0x200000 /* Block rejoin immediately after kick */
#define MODE_NOREPEAT 0x400000 /* Block repeat messages */
#define MODE_NOOPERKICK 0x800000 /* disallow kicking opers */
#define MODE_HIDEBANS 0x1000000 /* disallow non-chanops from seeing ban/quiet lists */
#define CHFL_BAN 0x10000000 /* ban channel flag */
#define CHFL_EXCEPTION 0x20000000 /* exception to ban channel flag */
@ -224,14 +231,14 @@ void free_ban(struct Ban *bptr);
extern void destroy_channel(struct Channel *);
extern int can_send(struct Channel *chptr, struct Client *who,
struct membership *);
extern int can_send(struct Channel *chptr, struct Client *who,
struct membership *);
extern int flood_attack_channel(int p_or_n, struct Client *source_p,
struct Channel *chptr, char *chname);
struct Channel *chptr, char *chname);
extern int is_banned(struct Channel *chptr, struct Client *who,
struct membership *msptr, const char *, const char *);
struct membership *msptr, const char *, const char *);
extern int is_quieted(struct Channel *chptr, struct Client *who,
struct membership *msptr, const char *, const char *);
struct membership *msptr, const char *, const char *);
extern int can_join(struct Client *source_p, struct Channel *chptr, char *key);
extern struct membership *find_channel_membership(struct Channel *, struct Client *);
@ -252,7 +259,7 @@ extern void free_channel_list(rb_dlink_list *);
extern int check_channel_name(const char *name);
extern void channel_member_names(struct Channel *chptr, struct Client *,
int show_eon);
int show_eon);
extern void del_invite(struct Channel *chptr, struct Client *who);
@ -269,25 +276,25 @@ extern void check_spambot_warning(struct Client *source_p, const char *name);
extern void check_splitmode(void *);
void set_channel_topic(struct Channel *chptr, const char *topic,
const char *topic_info, time_t topicts);
const char *topic_info, time_t topicts);
extern void init_chcap_usage_counts(void);
extern void set_chcap_usage_counts(struct Client *serv_p);
extern void unset_chcap_usage_counts(struct Client *serv_p);
extern void send_cap_mode_changes(struct Client *client_p, struct Client *source_p,
struct Channel *chptr, struct ChModeChange foo[], int);
struct Channel *chptr, struct ChModeChange foo[], int);
void resv_chan_forcepart(const char *name, const char *reason, int temp_time);
extern void set_channel_mode(struct Client *client_p, struct Client *source_p,
struct Channel *chptr, struct membership *msptr, int parc, const char *parv[]);
struct Channel *chptr, struct membership *msptr, int parc, const char *parv[]);
extern void set_channel_mlock(struct Client *client_p, struct Client *source_p,
struct Channel *chptr, const char *newmlock, int propagate);
struct Channel *chptr, const char *newmlock, int propagate);
extern struct ChannelMode chmode_table[256];
extern int add_id(struct Client *source_p, struct Channel *chptr, const char *banid,
rb_dlink_list * list, long mode_type);
rb_dlink_list * list, long mode_type);
extern int del_id(struct Channel *chptr, const char *banid, rb_dlink_list * list, long mode_type);
@ -302,9 +309,9 @@ extern void user_join(struct Client * client_p, struct Client * source_p, const
extern void do_join_0(struct Client *client_p, struct Client *source_p);
extern int check_channel_name_loc(struct Client *source_p, const char *name);
extern struct Metadata *channel_metadata_add(struct Channel *target, const char *name, const char *value, int propagate);
extern struct Metadata *channel_metadata_add(struct Channel *target, const char *name, const char *value, int propegate);
extern struct Metadata *channel_metadata_time_add(struct Channel *target, const char *name, time_t timevalue, const char *value);
extern void channel_metadata_delete(struct Channel *target, const char *name, int propagate);
extern void channel_metadata_delete(struct Channel *target, const char *name, int propegate);
extern struct Metadata *channel_metadata_find(struct Channel *target, const char *name);
extern void channel_metadata_clear(struct Channel *target);

View File

@ -37,50 +37,50 @@
extern int chmode_flags[256];
extern void chm_nosuch(struct Client *source_p, struct Channel *chptr,
int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type);
int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type);
extern void chm_orphaned(struct Client *source_p, struct Channel *chptr,
int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type);
int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type);
extern void chm_simple(struct Client *source_p, struct Channel *chptr,
int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type);
int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type);
extern void chm_ban(struct Client *source_p, struct Channel *chptr,
int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type);
int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type);
extern void chm_hidden(struct Client *source_p, struct Channel *chptr,
int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type);
int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type);
extern void chm_staff(struct Client *source_p, struct Channel *chptr,
int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type);
int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type);
extern void chm_forward(struct Client *source_p, struct Channel *chptr,
int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type);
int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type);
extern void chm_throttle(struct Client *source_p, struct Channel *chptr,
int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type);
int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type);
extern void chm_key(struct Client *source_p, struct Channel *chptr,
int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type);
int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type);
extern void chm_limit(struct Client *source_p, struct Channel *chptr,
int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type);
int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type);
extern void chm_owner(struct Client *source_p, struct Channel *chptr,
int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type);
int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type);
extern void chm_admin(struct Client *source_p, struct Channel *chptr,
int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type);
int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type);
extern void chm_op(struct Client *source_p, struct Channel *chptr,
int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type);
int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type);
extern void chm_halfop(struct Client *source_p, struct Channel *chptr,
int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type);
int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type);
extern void chm_voice(struct Client *source_p, struct Channel *chptr,
int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type);
int alevel, int parc, int *parn,
const char **parv, int *errors, int dir, char c, long mode_type);
extern unsigned int cflag_add(char c, ChannelModeFunc function);
extern void cflag_orphan(char c);

View File

@ -30,21 +30,22 @@ struct ConfItem;
struct Client;
struct _patricia_tree_t;
struct Class {
struct Class *next;
char *class_name;
int max_total;
int max_local;
int max_global;
int max_ident;
int max_sendq;
int con_freq;
int ping_freq;
int total;
rb_patricia_tree_t *ip_limits;
int cidr_ipv4_bitlen;
int cidr_ipv6_bitlen;
int cidr_amount;
struct Class
{
struct Class *next;
char *class_name;
int max_total;
int max_local;
int max_global;
int max_ident;
int max_sendq;
int con_freq;
int ping_freq;
int total;
rb_patricia_tree_t *ip_limits;
int cidr_ipv4_bitlen;
int cidr_ipv6_bitlen;
int cidr_amount;
};

View File

@ -76,231 +76,238 @@ struct scache_entry;
/*
* Client structures
*/
struct User {
rb_dlink_list channel; /* chain of channel pointer blocks */
rb_dlink_list invited; /* chain of invite pointer blocks */
char *away; /* pointer to away message */
int refcnt; /* Number of times this block is referenced */
struct User
{
rb_dlink_list channel; /* chain of channel pointer blocks */
rb_dlink_list invited; /* chain of invite pointer blocks */
char *away; /* pointer to away message */
int refcnt; /* Number of times this block is referenced */
struct Dictionary *metadata;
struct Dictionary *metadata;
char suser[NICKLEN+1];
char suser[NICKLEN+1];
};
struct Server {
struct User *user; /* who activated this connection */
char by[NICKLEN];
rb_dlink_list servers;
rb_dlink_list users;
int caps; /* capabilities bit-field */
char *fullcaps;
struct scache_entry *nameinfo;
struct Server
{
struct User *user; /* who activated this connection */
char by[NICKLEN];
rb_dlink_list servers;
rb_dlink_list users;
int caps; /* capabilities bit-field */
char *fullcaps;
struct scache_entry *nameinfo;
};
struct ZipStats {
unsigned long long in;
unsigned long long in_wire;
unsigned long long out;
unsigned long long out_wire;
double in_ratio;
double out_ratio;
struct ZipStats
{
unsigned long long in;
unsigned long long in_wire;
unsigned long long out;
unsigned long long out_wire;
double in_ratio;
double out_ratio;
};
struct Client {
rb_dlink_node node;
rb_dlink_node lnode;
struct User *user; /* ...defined, if this is a User */
struct Server *serv; /* ...defined, if this is a server */
struct Client *servptr; /* Points to server this Client is on */
struct Client *from; /* == self, if Local Client, *NEVER* NULL! */
struct Client
{
rb_dlink_node node;
rb_dlink_node lnode;
struct User *user; /* ...defined, if this is a User */
struct Server *serv; /* ...defined, if this is a server */
struct Client *servptr; /* Points to server this Client is on */
struct Client *from; /* == self, if Local Client, *NEVER* NULL! */
struct Whowas *whowas; /* Pointers to whowas structs */
time_t tsinfo; /* TS on the nick, SVINFO on server */
unsigned int umodes; /* opers, normal users subset */
unsigned int flags; /* client flags */
unsigned int flags2; /* ugh. overflow */
struct Whowas *whowas; /* Pointers to whowas structs */
time_t tsinfo; /* TS on the nick, SVINFO on server */
unsigned int umodes; /* opers, normal users subset */
unsigned int flags; /* client flags */
unsigned int flags2; /* ugh. overflow */
unsigned int snomask; /* server notice mask */
unsigned int snomask; /* server notice mask */
int hopcount; /* number of servers to this 0 = local */
unsigned short status; /* Client type */
unsigned char handler; /* Handler index */
unsigned long serial; /* used to enforce 1 send per nick */
int hopcount; /* number of servers to this 0 = local */
unsigned short status; /* Client type */
unsigned char handler; /* Handler index */
unsigned long serial; /* used to enforce 1 send per nick */
/* client->name is the unique name for a client nick or host */
char name[HOSTLEN + 1];
/* client->name is the unique name for a client nick or host */
char name[HOSTLEN + 1];
/*
* client->username is the username from ident or the USER message,
* If the client is idented the USER message is ignored, otherwise
* the username part of the USER message is put here prefixed with a
* tilde depending on the I:line, Once a client has registered, this
* field should be considered read-only.
*/
char username[USERLEN + 1]; /* client's username */
/*
* client->username is the username from ident or the USER message,
* If the client is idented the USER message is ignored, otherwise
* the username part of the USER message is put here prefixed with a
* tilde depending on the I:line, Once a client has registered, this
* field should be considered read-only.
*/
char username[USERLEN + 1]; /* client's username */
/*
* client->host contains the resolved name or ip address
* as a string for the user, it may be fiddled with for oper spoofing etc.
*/
char host[HOSTLEN + 1]; /* client's hostname */
char orighost[HOSTLEN + 1]; /* original hostname (before dynamic spoofing) */
char sockhost[HOSTIPLEN + 1]; /* clients ip */
char info[REALLEN + 1]; /* Free form additional client info */
/*
* client->host contains the resolved name or ip address
* as a string for the user, it may be fiddled with for oper spoofing etc.
*/
char host[HOSTLEN + 1]; /* client's hostname */
char orighost[HOSTLEN + 1]; /* original hostname (before dynamic spoofing) */
char sockhost[HOSTIPLEN + 1]; /* clients ip */
char info[REALLEN + 1]; /* Free form additional client info */
char id[IDLEN]; /* UID/SID, unique on the network */
char id[IDLEN]; /* UID/SID, unique on the network */
/* list of who has this client on their allow list, its counterpart
* is in LocalUser
*/
rb_dlink_list on_allow_list;
/* list of who has this client on their allow list, its counterpart
* is in LocalUser
*/
rb_dlink_list on_allow_list;
time_t first_received_message_time;
int received_number_of_privmsgs;
int flood_noticed;
time_t first_received_message_time;
int received_number_of_privmsgs;
int flood_noticed;
struct LocalUser *localClient;
struct PreClient *preClient;
struct LocalUser *localClient;
struct PreClient *preClient;
time_t large_ctcp_sent; /* ctcp to large group sent, relax flood checks */
char *certfp; /* client certificate fingerprint */
time_t large_ctcp_sent; /* ctcp to large group sent, relax flood checks */
char *certfp; /* client certificate fingerprint */
};
struct LocalUser {
rb_dlink_node tnode; /* This is the node for the local list type the client is on*/
/*
* The following fields are allocated only for local clients
* (directly connected to *this* server with a socket.
*/
/* Anti flooding part, all because of lamers... */
time_t last_join_time; /* when this client last
struct LocalUser
{
rb_dlink_node tnode; /* This is the node for the local list type the client is on*/
/*
* The following fields are allocated only for local clients
* (directly connected to *this* server with a socket.
*/
/* Anti flooding part, all because of lamers... */
time_t last_join_time; /* when this client last
joined a channel */
time_t last_leave_time; /* when this client last
time_t last_leave_time; /* when this client last
* left a channel */
int join_leave_count; /* count of JOIN/LEAVE in less than
int join_leave_count; /* count of JOIN/LEAVE in less than
MIN_JOIN_LEAVE_TIME seconds */
int oper_warn_count_down; /* warn opers of this possible
int oper_warn_count_down; /* warn opers of this possible
spambot every time this gets to 0 */
time_t last_caller_id_time;
time_t last_caller_id_time;
time_t lasttime; /* last time we parsed something */
time_t firsttime; /* time client was created */
time_t lasttime; /* last time we parsed something */
time_t firsttime; /* time client was created */
/* Send and receive linebuf queues .. */
buf_head_t buf_sendq;
buf_head_t buf_recvq;
/*
* we want to use unsigned int here so the sizes have a better chance of
* staying the same on 64 bit machines. The current trend is to use
* I32LP64, (32 bit ints, 64 bit longs and pointers) and since ircd
* will NEVER run on an operating system where ints are less than 32 bits,
* it's a relatively safe bet to use ints. Since right shift operations are
* performed on these, it's not safe to allow them to become negative,
* which is possible for long running server connections. Unsigned values
* generally overflow gracefully. --Bleep
*/
unsigned int sendM; /* Statistics: protocol messages send */
unsigned int sendK; /* Statistics: total k-bytes send */
unsigned int receiveM; /* Statistics: protocol messages received */
unsigned int receiveK; /* Statistics: total k-bytes received */
unsigned short sendB; /* counters to count upto 1-k lots of bytes */
unsigned short receiveB; /* sent and received. */
struct Listener *listener; /* listener accepted from */
struct ConfItem *att_conf; /* attached conf */
struct server_conf *att_sconf;
/* Send and receive linebuf queues .. */
buf_head_t buf_sendq;
buf_head_t buf_recvq;
/*
* we want to use unsigned int here so the sizes have a better chance of
* staying the same on 64 bit machines. The current trend is to use
* I32LP64, (32 bit ints, 64 bit longs and pointers) and since ircd
* will NEVER run on an operating system where ints are less than 32 bits,
* it's a relatively safe bet to use ints. Since right shift operations are
* performed on these, it's not safe to allow them to become negative,
* which is possible for long running server connections. Unsigned values
* generally overflow gracefully. --Bleep
*/
unsigned int sendM; /* Statistics: protocol messages send */
unsigned int sendK; /* Statistics: total k-bytes send */
unsigned int receiveM; /* Statistics: protocol messages received */
unsigned int receiveK; /* Statistics: total k-bytes received */
unsigned short sendB; /* counters to count upto 1-k lots of bytes */
unsigned short receiveB; /* sent and received. */
struct Listener *listener; /* listener accepted from */
struct ConfItem *att_conf; /* attached conf */
struct server_conf *att_sconf;
struct rb_sockaddr_storage ip;
time_t last_nick_change;
int number_of_nick_changes;
struct rb_sockaddr_storage ip;
time_t last_nick_change;
int number_of_nick_changes;
/*
* XXX - there is no reason to save this, it should be checked when it's
* received and not stored, this is not used after registration
*
* agreed. lets get rid of it someday! --nenolod
*/
char *passwd;
char *auth_user;
char *opername; /* name of operator{} block being used or tried (challenge) */
char *challenge;
char *fullcaps;
/*
* XXX - there is no reason to save this, it should be checked when it's
* received and not stored, this is not used after registration
*
* agreed. lets get rid of it someday! --nenolod
*/
char *passwd;
char *auth_user;
char *opername; /* name of operator{} block being used or tried (challenge) */
char *challenge;
char *fullcaps;
int caps; /* capabilities bit-field */
rb_fde_t *F; /* >= 0, for local clients */
int caps; /* capabilities bit-field */
rb_fde_t *F; /* >= 0, for local clients */
/* time challenge response is valid for */
time_t chal_time;
/* time challenge response is valid for */
time_t chal_time;
struct DNSQuery *dnsquery; /* for outgoing server's name lookup */
struct DNSQuery *dnsquery; /* for outgoing server's name lookup */
time_t next_away; /* Don't allow next away before... */
time_t last;
time_t last;
/* clients allowed to talk through +g */
rb_dlink_list allow_list;
/* clients allowed to talk through +g */
rb_dlink_list allow_list;
/* nicknames theyre monitoring */
rb_dlink_list monitor_list;
/* nicknames theyre monitoring */
rb_dlink_list monitor_list;
/*
* Anti-flood stuff. We track how many messages were parsed and how
* many we were allowed in the current second, and apply a simple decay
* to avoid flooding.
* -- adrian
*/
int allow_read; /* how many we're allowed to read in this second */
int actually_read; /* how many we've actually read in this second */
int sent_parsed; /* how many messages we've parsed in this second */
time_t last_knock; /* time of last knock */
unsigned long random_ping;
struct AuthRequest *auth_request;
/*
* Anti-flood stuff. We track how many messages were parsed and how
* many we were allowed in the current second, and apply a simple decay
* to avoid flooding.
* -- adrian
*/
int allow_read; /* how many we're allowed to read in this second */
int actually_read; /* how many we've actually read in this second */
int sent_parsed; /* how many messages we've parsed in this second */
time_t last_knock; /* time of last knock */
unsigned long random_ping;
struct AuthRequest *auth_request;
/* target change stuff */
/* targets we're aware of (fnv32(use_id(target_p))):
* 0..TGCHANGE_NUM-1 regular slots
* TGCHANGE_NUM..TGCHANGE_NUM+TGCHANGE_REPLY-1 reply slots
*/
uint32_t targets[TGCHANGE_NUM + TGCHANGE_REPLY];
unsigned int targets_free; /* free targets */
time_t target_last; /* last time we cleared a slot */
/* target change stuff */
/* targets we're aware of (fnv32(use_id(target_p))):
* 0..TGCHANGE_NUM-1 regular slots
* TGCHANGE_NUM..TGCHANGE_NUM+TGCHANGE_REPLY-1 reply slots
*/
uint32_t targets[TGCHANGE_NUM + TGCHANGE_REPLY];
unsigned int targets_free; /* free targets */
time_t target_last; /* last time we cleared a slot */
struct ListClient *safelist_data;
struct ListClient *safelist_data;
char *mangledhost; /* non-NULL if host mangling module loaded and
char *mangledhost; /* non-NULL if host mangling module loaded and
applicable to this client */
struct _ssl_ctl *ssl_ctl; /* which ssl daemon we're associate with */
struct _ssl_ctl *z_ctl; /* second ctl for ssl+zlib */
uint32_t localflags;
struct ZipStats *zipstats; /* zipstats */
uint16_t cork_count; /* used for corking/uncorking connections */
struct ev_entry *event; /* used for associated events */
struct _ssl_ctl *ssl_ctl; /* which ssl daemon we're associate with */
struct _ssl_ctl *z_ctl; /* second ctl for ssl+zlib */
uint32_t localflags;
struct ZipStats *zipstats; /* zipstats */
uint16_t cork_count; /* used for corking/uncorking connections */
struct ev_entry *event; /* used for associated events */
struct PrivilegeSet *privset; /* privset... */
struct PrivilegeSet *privset; /* privset... */
struct ev_entry *override_timeout_event;
struct ev_entry *override_timeout_event;
};
struct PreClient {
char spoofnick[NICKLEN + 1];
char spoofuser[USERLEN + 1];
char spoofhost[HOSTLEN + 1];
struct PreClient
{
char spoofnick[NICKLEN + 1];
char spoofuser[USERLEN + 1];
char spoofhost[HOSTLEN + 1];
char sasl_agent[IDLEN];
unsigned char sasl_out;
unsigned char sasl_complete;
char sasl_agent[IDLEN];
unsigned char sasl_out;
unsigned char sasl_complete;
rb_dlink_list dnsbl_queries; /* list of struct BlacklistClient * */
struct Blacklist *dnsbl_listed; /* first dnsbl where it's listed */
rb_dlink_list dnsbl_queries; /* list of struct BlacklistClient * */
struct Blacklist *dnsbl_listed; /* first dnsbl where it's listed */
struct rb_sockaddr_storage lip; /* address of our side of the connection */
struct rb_sockaddr_storage lip; /* address of our side of the connection */
};
struct ListClient {
unsigned int hash_indice;
unsigned int users_min, users_max;
time_t created_min, created_max, topic_min, topic_max;
int operspy;
struct ListClient
{
unsigned int hash_indice;
unsigned int users_min, users_max;
time_t created_min, created_max, topic_min, topic_max;
int operspy;
};
/*
@ -402,6 +409,7 @@ struct ListClient {
#define LFLAGS_SSL 0x00000001
#define LFLAGS_FLUSH 0x00000002
#define LFLAGS_CORK 0x00000004
#define LFLAGS_WEBSOCKET 0x00000008
/* umodes, settable flags */
/* lots of this moved to snomask -- jilles */
@ -419,7 +427,6 @@ struct ListClient {
#define UMODE_NOINVITE 0x0800 /* block invites */
#define UMODE_BOT 0x8000 /* mark as a bot in whois */
#define UMODE_SCALLERID 0x40000 /* soft caller id */
#define UMODE_HIDECHANS 0x80000 /* hide channels in whois */
/* user information flags, only settable by remote mode or local oper */
#define UMODE_OPER 0x1000 /* Operator */
@ -489,6 +496,10 @@ struct ListClient {
#define SetSSL(x) ((x)->localClient->localflags |= LFLAGS_SSL)
#define ClearSSL(x) ((x)->localClient->localflags &= ~LFLAGS_SSL)
#define IsWebSocket(x) ((x)->localClient->localflags & LFLAGS_WEBSOCKET)
#define SetWebSocket(x) ((x)->localClient->localflags |= LFLAGS_WEBSOCKET)
#define ClearWebSocket(x) ((x)->localClient->localflags &= ~LFLAGS_WEBSOCKET)
#define IsFlush(x) ((x)->localClient->localflags & LFLAGS_FLUSH)
#define SetFlush(x) ((x)->localClient->localflags |= LFLAGS_FLUSH)
#define ClearFlush(x) ((x)->localClient->localflags &= ~LFLAGS_FLUSH)
@ -609,8 +620,8 @@ extern char *generate_uid(void);
void allocate_away(struct Client *);
void free_away(struct Client *);
extern struct Metadata *user_metadata_add(struct Client *target, const char *name, const char *value, int propagate);
extern void user_metadata_delete(struct Client *target, const char *name, int propagate);
extern struct Metadata *user_metadata_add(struct Client *target, const char *name, const char *value, int propegate);
extern void user_metadata_delete(struct Client *target, const char *name, int propegate);
extern struct Metadata *user_metadata_find(struct Client *target, const char *name);
extern void user_metadata_clear(struct Client *target);

View File

@ -28,7 +28,7 @@
#include "setup.h"
/*
/*
* Directory paths and filenames for UNIX systems.
* IRCD_PREFIX is set using ./configure --prefix, see INSTALL.
* The other defaults should be fine.
@ -52,7 +52,7 @@
#define LIBPATH IRCD_PREFIX "/lib/"
#define MODPATH MODULE_DIR
#define AUTOMODPATH MODULE_DIR "/autoload/"
#define ETCPATH ETC_DIR
#define ETCPATH ETC_DIR
#define LOGPATH LOG_DIR
#define UHPATH HELP_DIR "/users"
#define HPATH HELP_DIR "/opers"
@ -94,7 +94,7 @@
#define KILLCHASETIMELIMIT 90 /* Recommended value: 90 */
/* RATBOX_SOMAXCONN
* Use SOMAXCONN if OS has it, otherwise use this value for the
* Use SOMAXCONN if OS has it, otherwise use this value for the
* listen(); backlog. 5 for AIX/SUNOS, 25 for other OSs.
*/
#define RATBOX_SOMAXCONN 25

View File

@ -6,9 +6,10 @@
#ifndef INCLUDED_HOOK_H
#define INCLUDED_HOOK_H
typedef struct {
char *name;
rb_dlink_list hooks;
typedef struct
{
char *name;
rb_dlink_list hooks;
} hook;
typedef void (*hookfn) (void *data);
@ -35,58 +36,67 @@ void add_hook(const char *name, hookfn fn);
void remove_hook(const char *name, hookfn fn);
void call_hook(int id, void *arg);
typedef struct {
struct Client *client;
const void *arg1;
const void *arg2;
typedef struct
{
struct Client *client;
const void *arg1;
const void *arg2;
} hook_data;
typedef struct {
struct Client *client;
const void *arg1;
int arg2;
typedef struct
{
struct Client *client;
const void *arg1;
int arg2;
} hook_data_int;
typedef struct {
struct Client *client;
struct Client *target;
typedef struct
{
struct Client *client;
struct Client *target;
} hook_data_client;
typedef struct {
struct Client *client;
struct Channel *chptr;
int approved;
typedef struct
{
struct Client *client;
struct Channel *chptr;
int approved;
} hook_data_channel;
typedef struct {
struct Client *client;
struct Channel *chptr;
char *key;
typedef struct
{
struct Client *client;
struct Channel *chptr;
char *key;
} hook_data_channel_activity;
typedef struct {
struct Client *client;
struct Channel *chptr;
struct Client *target;
int approved;
typedef struct
{
struct Client *client;
struct Channel *chptr;
struct Client *target;
int approved;
} hook_data_channel_approval;
typedef struct {
struct Client *client;
int approved;
typedef struct
{
struct Client *client;
int approved;
} hook_data_client_approval;
typedef struct {
struct Client *local_link; /* local client originating this, or NULL */
struct Client *target; /* dying client */
struct Client *from; /* causing client (could be &me or target) */
const char *comment;
typedef struct
{
struct Client *local_link; /* local client originating this, or NULL */
struct Client *target; /* dying client */
struct Client *from; /* causing client (could be &me or target) */
const char *comment;
} hook_data_client_exit;
typedef struct {
struct Client *client;
unsigned int oldumodes;
unsigned int oldsnomask;
typedef struct
{
struct Client *client;
unsigned int oldumodes;
unsigned int oldsnomask;
} hook_data_umode_changed;
#endif

View File

@ -26,28 +26,29 @@
#ifndef INCLUDE_hostmask_h
#define INCLUDE_hostmask_h 1
enum {
HM_HOST,
HM_IPV4
enum
{
HM_HOST,
HM_IPV4
#ifdef RB_IPV6
, HM_IPV6
, HM_IPV6
#endif
};
int parse_netmask(const char *, struct sockaddr *, int *);
struct ConfItem *find_conf_by_address(const char *host, const char *sockhost,
const char *orighost, struct sockaddr *,
int, int, const char *, const char *);
const char *orighost, struct sockaddr *,
int, int, const char *, const char *);
struct ConfItem *find_exact_conf_by_address(const char *address, int type,
const char *username);
const char *username);
void add_conf_by_address(const char *, int, const char *, const char *, struct ConfItem *);
void delete_one_address_conf(const char *, struct ConfItem *);
void clear_out_address_conf(void);
void clear_out_address_conf_bans(void);
void init_host_hash(void);
struct ConfItem *find_address_conf(const char *host, const char *sockhost,
const char *, const char *, struct sockaddr *,
int, char *);
struct ConfItem *find_address_conf(const char *host, const char *sockhost,
const char *, const char *, struct sockaddr *,
int, char *);
struct ConfItem *find_dline(struct sockaddr *, int);
@ -69,37 +70,40 @@ int match_ipv4(struct sockaddr *, struct sockaddr *, int);
extern struct AddressRec *atable[ATABLE_SIZE];
struct AddressRec {
/* masktype: HM_HOST, HM_IPV4, HM_IPV6 -A1kmm */
int masktype;
struct AddressRec
{
/* masktype: HM_HOST, HM_IPV4, HM_IPV6 -A1kmm */
int masktype;
union {
struct {
/* Pointer into ConfItem... -A1kmm */
struct rb_sockaddr_storage addr;
int bits;
}
ipa;
union
{
struct
{
/* Pointer into ConfItem... -A1kmm */
struct rb_sockaddr_storage addr;
int bits;
}
ipa;
/* Pointer into ConfItem... -A1kmm */
const char *hostname;
}
Mask;
/* Pointer into ConfItem... -A1kmm */
const char *hostname;
}
Mask;
/* type: CONF_CLIENT, CONF_DLINE, CONF_KILL etc... -A1kmm */
int type;
/* type: CONF_CLIENT, CONF_DLINE, CONF_KILL etc... -A1kmm */
int type;
/* Higher precedences overrule lower ones... */
unsigned long precedence;
/* Higher precedences overrule lower ones... */
unsigned long precedence;
/* Only checked if !(type & 1)... */
const char *username;
/* Only checked if type == CONF_CLIENT */
const char *auth_user;
struct ConfItem *aconf;
/* Only checked if !(type & 1)... */
const char *username;
/* Only checked if type == CONF_CLIENT */
const char *auth_user;
struct ConfItem *aconf;
/* The next record in this hash bucket. */
struct AddressRec *next;
/* The next record in this hash bucket. */
struct AddressRec *next;
};

318
include/http_parser.h Normal file
View File

@ -0,0 +1,318 @@
/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
#ifndef http_parser_h
#define http_parser_h
#ifdef __cplusplus
extern "C" {
#endif
/* Also update SONAME in the Makefile whenever you change these. */
#define HTTP_PARSER_VERSION_MAJOR 2
#define HTTP_PARSER_VERSION_MINOR 1
#define HTTP_PARSER_VERSION_PATCH 0
#include <sys/types.h>
#if defined(_WIN32) && !defined(__MINGW32__) && (!defined(_MSC_VER) || _MSC_VER<1600)
#include <BaseTsd.h>
#include <stddef.h>
typedef __int8 int8_t;
typedef unsigned __int8 uint8_t;
typedef __int16 int16_t;
typedef unsigned __int16 uint16_t;
typedef __int32 int32_t;
typedef unsigned __int32 uint32_t;
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
#else
#include <stdint.h>
#endif
/* Compile with -DHTTP_PARSER_STRICT=0 to make less checks, but run
* faster
*/
#ifndef HTTP_PARSER_STRICT
# define HTTP_PARSER_STRICT 1
#endif
/* Maximium header size allowed */
#define HTTP_MAX_HEADER_SIZE (80*1024)
typedef struct http_parser http_parser;
typedef struct http_parser_settings http_parser_settings;
/* Callbacks should return non-zero to indicate an error. The parser will
* then halt execution.
*
* The one exception is on_headers_complete. In a HTTP_RESPONSE parser
* returning '1' from on_headers_complete will tell the parser that it
* should not expect a body. This is used when receiving a response to a
* HEAD request which may contain 'Content-Length' or 'Transfer-Encoding:
* chunked' headers that indicate the presence of a body.
*
* http_data_cb does not return data chunks. It will be call arbitrarally
* many times for each string. E.G. you might get 10 callbacks for "on_url"
* each providing just a few characters more data.
*/
typedef int (*http_data_cb) (http_parser*, const char *at, size_t length);
typedef int (*http_cb) (http_parser*);
/* Request Methods */
#define HTTP_METHOD_MAP(XX) \
XX(0, DELETE, DELETE) \
XX(1, GET, GET) \
XX(2, HEAD, HEAD) \
XX(3, POST, POST) \
XX(4, PUT, PUT) \
/* pathological */ \
XX(5, CONNECT, CONNECT) \
XX(6, OPTIONS, OPTIONS) \
XX(7, TRACE, TRACE) \
/* webdav */ \
XX(8, COPY, COPY) \
XX(9, LOCK, LOCK) \
XX(10, MKCOL, MKCOL) \
XX(11, MOVE, MOVE) \
XX(12, PROPFIND, PROPFIND) \
XX(13, PROPPATCH, PROPPATCH) \
XX(14, SEARCH, SEARCH) \
XX(15, UNLOCK, UNLOCK) \
/* subversion */ \
XX(16, REPORT, REPORT) \
XX(17, MKACTIVITY, MKACTIVITY) \
XX(18, CHECKOUT, CHECKOUT) \
XX(19, MERGE, MERGE) \
/* upnp */ \
XX(20, MSEARCH, M-SEARCH) \
XX(21, NOTIFY, NOTIFY) \
XX(22, SUBSCRIBE, SUBSCRIBE) \
XX(23, UNSUBSCRIBE, UNSUBSCRIBE) \
/* RFC-5789 */ \
XX(24, PATCH, PATCH) \
XX(25, PURGE, PURGE) \
enum http_method
{
#define XX(num, name, string) HTTP_##name = num,
HTTP_METHOD_MAP(XX)
#undef XX
};
enum http_parser_type { HTTP_REQUEST, HTTP_RESPONSE, HTTP_BOTH };
/* Flag values for http_parser.flags field */
enum flags
{ F_CHUNKED = 1 << 0
, F_CONNECTION_KEEP_ALIVE = 1 << 1
, F_CONNECTION_CLOSE = 1 << 2
, F_TRAILING = 1 << 3
, F_UPGRADE = 1 << 4
, F_SKIPBODY = 1 << 5
};
/* Map for errno-related constants
*
* The provided argument should be a macro that takes 2 arguments.
*/
#define HTTP_ERRNO_MAP(XX) \
/* No error */ \
XX(OK, "success") \
\
/* Callback-related errors */ \
XX(CB_message_begin, "the on_message_begin callback failed") \
XX(CB_status_complete, "the on_status_complete callback failed") \
XX(CB_url, "the on_url callback failed") \
XX(CB_header_field, "the on_header_field callback failed") \
XX(CB_header_value, "the on_header_value callback failed") \
XX(CB_headers_complete, "the on_headers_complete callback failed") \
XX(CB_body, "the on_body callback failed") \
XX(CB_message_complete, "the on_message_complete callback failed") \
\
/* Parsing-related errors */ \
XX(INVALID_EOF_STATE, "stream ended at an unexpected time") \
XX(HEADER_OVERFLOW, \
"too many header bytes seen; overflow detected") \
XX(CLOSED_CONNECTION, \
"data received after completed connection: close message") \
XX(INVALID_VERSION, "invalid HTTP version") \
XX(INVALID_STATUS, "invalid HTTP status code") \
XX(INVALID_METHOD, "invalid HTTP method") \
XX(INVALID_URL, "invalid URL") \
XX(INVALID_HOST, "invalid host") \
XX(INVALID_PORT, "invalid port") \
XX(INVALID_PATH, "invalid path") \
XX(INVALID_QUERY_STRING, "invalid query string") \
XX(INVALID_FRAGMENT, "invalid fragment") \
XX(LF_EXPECTED, "LF character expected") \
XX(INVALID_HEADER_TOKEN, "invalid character in header") \
XX(INVALID_CONTENT_LENGTH, \
"invalid character in content-length header") \
XX(INVALID_CHUNK_SIZE, \
"invalid character in chunk size header") \
XX(INVALID_CONSTANT, "invalid constant string") \
XX(INVALID_INTERNAL_STATE, "encountered unexpected internal state")\
XX(STRICT, "strict mode assertion failed") \
XX(PAUSED, "parser is paused") \
XX(UNKNOWN, "an unknown error occurred")
/* Define HPE_* values for each errno value above */
#define HTTP_ERRNO_GEN(n, s) HPE_##n,
enum http_errno {
HTTP_ERRNO_MAP(HTTP_ERRNO_GEN)
};
#undef HTTP_ERRNO_GEN
/* Get an http_errno value from an http_parser */
#define HTTP_PARSER_ERRNO(p) ((enum http_errno) (p)->http_errno)
struct http_parser {
/** PRIVATE **/
unsigned int type : 2; /* enum http_parser_type */
unsigned int flags : 6; /* F_* values from 'flags' enum; semi-public */
unsigned int state : 8; /* enum state from http_parser.c */
unsigned int header_state : 8; /* enum header_state from http_parser.c */
unsigned int index : 8; /* index into current matcher */
uint32_t nread; /* # bytes read in various scenarios */
uint64_t content_length; /* # bytes in body (0 if no Content-Length header) */
/** READ-ONLY **/
unsigned short http_major;
unsigned short http_minor;
unsigned int status_code : 16; /* responses only */
unsigned int method : 8; /* requests only */
unsigned int http_errno : 7;
/* 1 = Upgrade header was present and the parser has exited because of that.
* 0 = No upgrade header present.
* Should be checked when http_parser_execute() returns in addition to
* error checking.
*/
unsigned int upgrade : 1;
/** PUBLIC **/
void *data; /* A pointer to get hook to the "connection" or "socket" object */
};
struct http_parser_settings {
http_cb on_message_begin;
http_data_cb on_url;
http_cb on_status_complete;
http_data_cb on_header_field;
http_data_cb on_header_value;
http_cb on_headers_complete;
http_data_cb on_body;
http_cb on_message_complete;
};
enum http_parser_url_fields
{ UF_SCHEMA = 0
, UF_HOST = 1
, UF_PORT = 2
, UF_PATH = 3
, UF_QUERY = 4
, UF_FRAGMENT = 5
, UF_USERINFO = 6
, UF_MAX = 7
};
/* Result structure for http_parser_parse_url().
*
* Callers should index into field_data[] with UF_* values iff field_set
* has the relevant (1 << UF_*) bit set. As a courtesy to clients (and
* because we probably have padding left over), we convert any port to
* a uint16_t.
*/
struct http_parser_url {
uint16_t field_set; /* Bitmask of (1 << UF_*) values */
uint16_t port; /* Converted UF_PORT string */
struct {
uint16_t off; /* Offset into buffer in which field starts */
uint16_t len; /* Length of run in buffer */
} field_data[UF_MAX];
};
/* Returns the library version. Bits 16-23 contain the major version number,
* bits 8-15 the minor version number and bits 0-7 the patch level.
* Usage example:
*
* unsigned long version = http_parser_version();
* unsigned major = (version >> 16) & 255;
* unsigned minor = (version >> 8) & 255;
* unsigned patch = version & 255;
* printf("http_parser v%u.%u.%u\n", major, minor, version);
*/
unsigned long http_parser_version(void);
void http_parser_init(http_parser *parser, enum http_parser_type type);
size_t http_parser_execute(http_parser *parser,
const http_parser_settings *settings,
const char *data,
size_t len);
/* If http_should_keep_alive() in the on_headers_complete or
* on_message_complete callback returns 0, then this should be
* the last message on the connection.
* If you are the server, respond with the "Connection: close" header.
* If you are the client, close the connection.
*/
int http_should_keep_alive(const http_parser *parser);
/* Returns a string version of the HTTP method. */
const char *http_method_str(enum http_method m);
/* Return a string name of the given error */
const char *http_errno_name(enum http_errno err);
/* Return a string description of the given error */
const char *http_errno_description(enum http_errno err);
/* Parse a URL; return nonzero on failure */
int http_parser_parse_url(const char *buf, size_t buflen,
int is_connect,
struct http_parser_url *u);
/* Pause or un-pause the parser; a nonzero value pauses */
void http_parser_pause(http_parser *parser, int paused);
/* Checks if this is the final chunk of the body. */
int http_body_is_final(const http_parser *parser);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -30,90 +30,96 @@
static inline char *
strip_colour(char *string)
{
char *c = string;
char *c2 = string;
char *last_non_space = NULL;
char *c = string;
char *c2 = string;
char *last_non_space = NULL;
/* c is source, c2 is target */
for(; c && *c; c++)
switch (*c) {
case 3:
if(isdigit(c[1])) {
c++;
if(isdigit(c[1]))
c++;
if(c[1] == ',' && isdigit(c[2])) {
c += 2;
if(isdigit(c[1]))
c++;
}
}
break;
case 2:
case 6:
case 7:
case 22:
case 23:
case 27:
case 29:
case 31:
break;
case 32:
*c2++ = *c;
break;
default:
*c2++ = *c;
last_non_space = c2;
break;
}
/* c is source, c2 is target */
for(; c && *c; c++)
switch (*c)
{
case 3:
if(isdigit(c[1]))
{
c++;
if(isdigit(c[1]))
c++;
if(c[1] == ',' && isdigit(c[2]))
{
c += 2;
if(isdigit(c[1]))
c++;
}
}
break;
case 2:
case 6:
case 7:
case 22:
case 23:
case 27:
case 29:
case 31:
break;
case 32:
*c2++ = *c;
break;
default:
*c2++ = *c;
last_non_space = c2;
break;
}
*c2 = '\0';
*c2 = '\0';
if(last_non_space)
*last_non_space = '\0';
if(last_non_space)
*last_non_space = '\0';
return string;
return string;
}
static inline char *
strip_unprintable(char *string)
{
char *c = string;
char *c2 = string;
char *last_non_space = NULL;
char *c = string;
char *c2 = string;
char *last_non_space = NULL;
/* c is source, c2 is target */
for(; c && *c; c++)
switch (*c) {
case 3:
if(isdigit(c[1])) {
c++;
if(isdigit(c[1]))
c++;
if(c[1] == ',' && isdigit(c[2])) {
c += 2;
if(isdigit(c[1]))
c++;
}
}
break;
case 32:
*c2++ = *c;
break;
default:
if (*c < 32 && *c >= 0)
break;
*c2++ = *c;
last_non_space = c2;
break;
}
/* c is source, c2 is target */
for(; c && *c; c++)
switch (*c)
{
case 3:
if(isdigit(c[1]))
{
c++;
if(isdigit(c[1]))
c++;
if(c[1] == ',' && isdigit(c[2]))
{
c += 2;
if(isdigit(c[1]))
c++;
}
}
break;
case 32:
*c2++ = *c;
break;
default:
if (*c < 32)
break;
*c2++ = *c;
last_non_space = c2;
break;
}
*c2 = '\0';
*c2 = '\0';
if(last_non_space)
*last_non_space = '\0';
if(last_non_space)
*last_non_space = '\0';
return string;
return string;
}
#endif

Some files were not shown because too many files have changed in this diff Show More