Compare commits
2 Commits
armageddon
...
websockets
Author | SHA1 | Date |
---|---|---|
Sam Dodrill | 3d74da6cbc | |
Sam Dodrill | 1553d3c136 |
2
.lvimrc
2
.lvimrc
|
@ -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'
|
|
12
.travis.yml
12
.travis.yml
|
@ -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"
|
|
|
@ -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
15
CREDITS
|
@ -1,23 +1,14 @@
|
||||||
$Id: CREDITS 3133 2007-01-21 15:38:16Z jilles $
|
$Id: CREDITS 3133 2007-01-21 15:38:16Z jilles $
|
||||||
|
|
||||||
Elemental-IRCd is a fork of the now-defunct ShadowIRCD project.
|
elemental-ircd is a fork of the ShadowIRCD project created to meet
|
||||||
|
|
||||||
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
|
|
||||||
PonyChat's needs and keep the now-defunct ShadowIRCD project's goals
|
PonyChat's needs and keep the now-defunct ShadowIRCD project's goals
|
||||||
alive.
|
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>
|
aji, Alex Iadicico <alex -at- ajitek.net>
|
||||||
|
lyska, Sam Dodrill <shadowh511 -at- gmail.com>>
|
||||||
Kabaka, Kyle Johnson <kabaka -at- ponychat.net>
|
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
|
ShadowIRCd 6 is a modern restart of the old ShadowIRCd project
|
||||||
based on Charybdis with a few additional features to make it appeal
|
based on Charybdis with a few additional features to make it appeal
|
||||||
|
|
99
Config
99
Config
|
@ -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
|
|
22
Dockerfile
22
Dockerfile
|
@ -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
|
|
|
@ -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
|
|
@ -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
56
NEWS
|
@ -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).
|
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
|
-- ponychat-ircd 6.5
|
||||||
|
|
||||||
additions
|
additions
|
||||||
|
|
|
@ -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$
|
35
README.md
35
README.md
|
@ -1,35 +1,18 @@
|
||||||
# Elemental-IRCd
|
# elemental-ircd
|
||||||
|
|
||||||
**Elemental-IRCd** is a high performance, lightweight, and scalable
|
**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
|
IRC daemon. It is a fork of the now-defunct ShadowIRCD created to meet
|
||||||
the direction ShadowIRCD was headed.
|
PonyChat's needs, and seeks to continue in the direction ShadowIRCD
|
||||||
|
was headed.
|
||||||
|
|
||||||
## Supported Platforms
|
## Supported Platforms
|
||||||
|
|
||||||
All modern \*NIX systems should work. You need the equivalent of the following
|
<Cassy> If you put something on a platform which cannot support it
|
||||||
Debian packages:
|
it may tip and fall and become broken. Simple physics.
|
||||||
|
|
||||||
- `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.
|
|
||||||
|
|
||||||
## Support
|
## Support
|
||||||
|
|
||||||
The official channel for Elemental-IRCd is `#elemental-ircd` on
|
Our support channel is `#rainbow-factory` on `irc.ponychat.net`. Poke
|
||||||
`irc.yolo-swag.com`. Anyone with push access to the repository will have halfop
|
**aji**, **lyska**, or **Kabaka** for help.
|
||||||
(`+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.
|
|
||||||
|
|
||||||
To report bugs, please use the GitHub issue tracker.
|
To report bugs, please use the GitHub issue tracker.
|
||||||
|
|
|
@ -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?
|
|
@ -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
|
|
@ -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
|
|
||||||
|
|
345
bandb/bandb.c
345
bandb/bandb.c
|
@ -40,20 +40,21 @@
|
||||||
|
|
||||||
#define COMMIT_INTERVAL 3 /* seconds */
|
#define COMMIT_INTERVAL 3 /* seconds */
|
||||||
|
|
||||||
typedef enum {
|
typedef enum
|
||||||
BANDB_KLINE,
|
{
|
||||||
BANDB_DLINE,
|
BANDB_KLINE,
|
||||||
BANDB_XLINE,
|
BANDB_DLINE,
|
||||||
BANDB_RESV,
|
BANDB_XLINE,
|
||||||
LAST_BANDB_TYPE
|
BANDB_RESV,
|
||||||
|
LAST_BANDB_TYPE
|
||||||
} bandb_type;
|
} bandb_type;
|
||||||
|
|
||||||
static char bandb_letter[LAST_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] = {
|
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
|
static void
|
||||||
bandb_commit(void *unused)
|
bandb_commit(void *unused)
|
||||||
{
|
{
|
||||||
rsdb_transaction(RSDB_TRANS_END);
|
rsdb_transaction(RSDB_TRANS_END);
|
||||||
in_transaction = 0;
|
in_transaction = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
parse_ban(bandb_type type, char *parv[], int parc)
|
parse_ban(bandb_type type, char *parv[], int parc)
|
||||||
{
|
{
|
||||||
const char *mask1 = NULL;
|
const char *mask1 = NULL;
|
||||||
const char *mask2 = NULL;
|
const char *mask2 = NULL;
|
||||||
const char *oper = NULL;
|
const char *oper = NULL;
|
||||||
const char *curtime = NULL;
|
const char *curtime = NULL;
|
||||||
const char *reason = NULL;
|
const char *reason = NULL;
|
||||||
const char *perm = NULL;
|
const char *perm = NULL;
|
||||||
int para = 1;
|
int para = 1;
|
||||||
|
|
||||||
if(type == BANDB_KLINE) {
|
if(type == BANDB_KLINE)
|
||||||
if(parc != 7)
|
{
|
||||||
return;
|
if(parc != 7)
|
||||||
} else if(parc != 6)
|
return;
|
||||||
return;
|
}
|
||||||
|
else if(parc != 6)
|
||||||
|
return;
|
||||||
|
|
||||||
mask1 = parv[para++];
|
mask1 = parv[para++];
|
||||||
|
|
||||||
if(type == BANDB_KLINE)
|
if(type == BANDB_KLINE)
|
||||||
mask2 = parv[para++];
|
mask2 = parv[para++];
|
||||||
|
|
||||||
oper = parv[para++];
|
oper = parv[para++];
|
||||||
curtime = parv[para++];
|
curtime = parv[para++];
|
||||||
perm = parv[para++];
|
perm = parv[para++];
|
||||||
reason = parv[para++];
|
reason = parv[para++];
|
||||||
|
|
||||||
if(!in_transaction) {
|
if(!in_transaction)
|
||||||
rsdb_transaction(RSDB_TRANS_START);
|
{
|
||||||
in_transaction = 1;
|
rsdb_transaction(RSDB_TRANS_START);
|
||||||
rb_event_addonce("bandb_commit", bandb_commit, NULL,
|
in_transaction = 1;
|
||||||
COMMIT_INTERVAL);
|
rb_event_addonce("bandb_commit", bandb_commit, NULL,
|
||||||
}
|
COMMIT_INTERVAL);
|
||||||
|
}
|
||||||
|
|
||||||
rsdb_exec(NULL,
|
rsdb_exec(NULL,
|
||||||
"INSERT INTO %s (mask1, mask2, oper, time, perm, reason) VALUES('%Q', '%Q', '%Q', %s, %s, '%Q')",
|
"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);
|
bandb_table[type], mask1, mask2 ? mask2 : "", oper, curtime, perm, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
parse_unban(bandb_type type, char *parv[], int parc)
|
parse_unban(bandb_type type, char *parv[], int parc)
|
||||||
{
|
{
|
||||||
const char *mask1 = NULL;
|
const char *mask1 = NULL;
|
||||||
const char *mask2 = NULL;
|
const char *mask2 = NULL;
|
||||||
|
|
||||||
if(type == BANDB_KLINE) {
|
if(type == BANDB_KLINE)
|
||||||
if(parc != 3)
|
{
|
||||||
return;
|
if(parc != 3)
|
||||||
} else if(parc != 2)
|
return;
|
||||||
return;
|
}
|
||||||
|
else if(parc != 2)
|
||||||
|
return;
|
||||||
|
|
||||||
mask1 = parv[1];
|
mask1 = parv[1];
|
||||||
|
|
||||||
if(type == BANDB_KLINE)
|
if(type == BANDB_KLINE)
|
||||||
mask2 = parv[2];
|
mask2 = parv[2];
|
||||||
|
|
||||||
if(!in_transaction) {
|
if(!in_transaction)
|
||||||
rsdb_transaction(RSDB_TRANS_START);
|
{
|
||||||
in_transaction = 1;
|
rsdb_transaction(RSDB_TRANS_START);
|
||||||
rb_event_addonce("bandb_commit", bandb_commit, NULL,
|
in_transaction = 1;
|
||||||
COMMIT_INTERVAL);
|
rb_event_addonce("bandb_commit", bandb_commit, NULL,
|
||||||
}
|
COMMIT_INTERVAL);
|
||||||
|
}
|
||||||
|
|
||||||
rsdb_exec(NULL, "DELETE FROM %s WHERE mask1='%Q' AND mask2='%Q'",
|
rsdb_exec(NULL, "DELETE FROM %s WHERE mask1='%Q' AND mask2='%Q'",
|
||||||
bandb_table[type], mask1, mask2 ? mask2 : "");
|
bandb_table[type], mask1, mask2 ? mask2 : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
list_bans(void)
|
list_bans(void)
|
||||||
{
|
{
|
||||||
static char buf[512];
|
static char buf[512];
|
||||||
struct rsdb_table table;
|
struct rsdb_table table;
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
/* schedule a clear of anything already pending */
|
/* schedule a clear of anything already pending */
|
||||||
rb_helper_write_queue(bandb_helper, "C");
|
rb_helper_write_queue(bandb_helper, "C");
|
||||||
|
|
||||||
for(i = 0; i < LAST_BANDB_TYPE; 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]);
|
rsdb_exec_fetch(&table, "SELECT mask1,mask2,oper,reason FROM %s WHERE 1",
|
||||||
|
bandb_table[i]);
|
||||||
|
|
||||||
for(j = 0; j < table.row_count; j++) {
|
for(j = 0; j < table.row_count; j++)
|
||||||
if(i == BANDB_KLINE)
|
{
|
||||||
snprintf(buf, sizeof(buf), "%c %s %s %s :%s",
|
if(i == BANDB_KLINE)
|
||||||
bandb_letter[i], table.row[j][0],
|
rb_snprintf(buf, sizeof(buf), "%c %s %s %s :%s",
|
||||||
table.row[j][1], table.row[j][2], table.row[j][3]);
|
bandb_letter[i], table.row[j][0],
|
||||||
else
|
table.row[j][1], table.row[j][2], table.row[j][3]);
|
||||||
snprintf(buf, sizeof(buf), "%c %s %s :%s",
|
else
|
||||||
bandb_letter[i], table.row[j][0],
|
rb_snprintf(buf, sizeof(buf), "%c %s %s :%s",
|
||||||
table.row[j][2], table.row[j][3]);
|
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
|
static void
|
||||||
parse_request(rb_helper *helper)
|
parse_request(rb_helper *helper)
|
||||||
{
|
{
|
||||||
static char *parv[MAXPARA + 1];
|
static char *parv[MAXPARA + 1];
|
||||||
static char readbuf[READBUF_SIZE];
|
static char readbuf[READBUF_SIZE];
|
||||||
int parc;
|
int parc;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
|
|
||||||
while((len = rb_helper_read(helper, readbuf, sizeof(readbuf))) > 0) {
|
while((len = rb_helper_read(helper, readbuf, sizeof(readbuf))) > 0)
|
||||||
parc = rb_string_to_array(readbuf, parv, MAXPARA);
|
{
|
||||||
|
parc = rb_string_to_array(readbuf, parv, MAXPARA);
|
||||||
|
|
||||||
if(parc < 1)
|
if(parc < 1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
switch (parv[0][0]) {
|
switch (parv[0][0])
|
||||||
case 'K':
|
{
|
||||||
parse_ban(BANDB_KLINE, parv, parc);
|
case 'K':
|
||||||
break;
|
parse_ban(BANDB_KLINE, parv, parc);
|
||||||
|
break;
|
||||||
|
|
||||||
case 'D':
|
case 'D':
|
||||||
parse_ban(BANDB_DLINE, parv, parc);
|
parse_ban(BANDB_DLINE, parv, parc);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'X':
|
case 'X':
|
||||||
parse_ban(BANDB_XLINE, parv, parc);
|
parse_ban(BANDB_XLINE, parv, parc);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'R':
|
case 'R':
|
||||||
parse_ban(BANDB_RESV, parv, parc);
|
parse_ban(BANDB_RESV, parv, parc);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'k':
|
case 'k':
|
||||||
parse_unban(BANDB_KLINE, parv, parc);
|
parse_unban(BANDB_KLINE, parv, parc);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'd':
|
case 'd':
|
||||||
parse_unban(BANDB_DLINE, parv, parc);
|
parse_unban(BANDB_DLINE, parv, parc);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'x':
|
case 'x':
|
||||||
parse_unban(BANDB_XLINE, parv, parc);
|
parse_unban(BANDB_XLINE, parv, parc);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'r':
|
case 'r':
|
||||||
parse_unban(BANDB_RESV, parv, parc);
|
parse_unban(BANDB_RESV, parv, parc);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'L':
|
case 'L':
|
||||||
list_bans();
|
list_bans();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
error_cb(rb_helper *helper)
|
error_cb(rb_helper *helper)
|
||||||
{
|
{
|
||||||
if(in_transaction)
|
if(in_transaction)
|
||||||
rsdb_transaction(RSDB_TRANS_END);
|
rsdb_transaction(RSDB_TRANS_END);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef WINDOWS
|
#ifndef WINDOWS
|
||||||
static void
|
static void
|
||||||
dummy_handler(int sig)
|
dummy_handler(int sig)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -247,28 +258,28 @@ static void
|
||||||
setup_signals()
|
setup_signals()
|
||||||
{
|
{
|
||||||
#ifndef WINDOWS
|
#ifndef WINDOWS
|
||||||
struct sigaction act;
|
struct sigaction act;
|
||||||
|
|
||||||
act.sa_flags = 0;
|
act.sa_flags = 0;
|
||||||
act.sa_handler = SIG_IGN;
|
act.sa_handler = SIG_IGN;
|
||||||
sigemptyset(&act.sa_mask);
|
sigemptyset(&act.sa_mask);
|
||||||
sigaddset(&act.sa_mask, SIGPIPE);
|
sigaddset(&act.sa_mask, SIGPIPE);
|
||||||
sigaddset(&act.sa_mask, SIGALRM);
|
sigaddset(&act.sa_mask, SIGALRM);
|
||||||
#ifdef SIGTRAP
|
#ifdef SIGTRAP
|
||||||
sigaddset(&act.sa_mask, SIGTRAP);
|
sigaddset(&act.sa_mask, SIGTRAP);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SIGWINCH
|
#ifdef SIGWINCH
|
||||||
sigaddset(&act.sa_mask, SIGWINCH);
|
sigaddset(&act.sa_mask, SIGWINCH);
|
||||||
sigaction(SIGWINCH, &act, 0);
|
sigaction(SIGWINCH, &act, 0);
|
||||||
#endif
|
#endif
|
||||||
sigaction(SIGPIPE, &act, 0);
|
sigaction(SIGPIPE, &act, 0);
|
||||||
#ifdef SIGTRAP
|
#ifdef SIGTRAP
|
||||||
sigaction(SIGTRAP, &act, 0);
|
sigaction(SIGTRAP, &act, 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
act.sa_handler = dummy_handler;
|
act.sa_handler = dummy_handler;
|
||||||
sigaction(SIGALRM, &act, 0);
|
sigaction(SIGALRM, &act, 0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,49 +287,51 @@ setup_signals()
|
||||||
static void
|
static void
|
||||||
db_error_cb(const char *errstr)
|
db_error_cb(const char *errstr)
|
||||||
{
|
{
|
||||||
char buf[256];
|
char buf[256];
|
||||||
snprintf(buf, sizeof(buf), "! :%s", errstr);
|
rb_snprintf(buf, sizeof(buf), "! :%s", errstr);
|
||||||
rb_helper_write(bandb_helper, buf);
|
rb_helper_write(bandb_helper, buf);
|
||||||
rb_sleep(2 << 30, 0);
|
rb_sleep(2 << 30, 0);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
setup_signals();
|
setup_signals();
|
||||||
bandb_helper = rb_helper_child(parse_request, error_cb, NULL, NULL, NULL, 256, 256, 256, 256); /* XXX fix me */
|
bandb_helper = rb_helper_child(parse_request, error_cb, NULL, NULL, NULL, 256, 256, 256, 256); /* XXX fix me */
|
||||||
if(bandb_helper == NULL) {
|
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,
|
||||||
fprintf(stderr,
|
"This is ircd-ratbox bandb. You aren't supposed to run me directly. Maybe you want bantool?\n");
|
||||||
"However I will print my Id tag $Id: bandb.c 26094 2008-09-19 15:33:46Z androsyn $\n");
|
fprintf(stderr,
|
||||||
fprintf(stderr, "Have a nice day\n");
|
"However I will print my Id tag $Id: bandb.c 26094 2008-09-19 15:33:46Z androsyn $\n");
|
||||||
exit(1);
|
fprintf(stderr, "Have a nice day\n");
|
||||||
}
|
exit(1);
|
||||||
rsdb_init(db_error_cb);
|
}
|
||||||
check_schema();
|
rsdb_init(db_error_cb);
|
||||||
rb_helper_loop(bandb_helper, 0);
|
check_schema();
|
||||||
|
rb_helper_loop(bandb_helper, 0);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
check_schema(void)
|
check_schema(void)
|
||||||
{
|
{
|
||||||
struct rsdb_table table;
|
struct rsdb_table table;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for(i = 0; i < LAST_BANDB_TYPE; i++) {
|
for(i = 0; i < LAST_BANDB_TYPE; i++)
|
||||||
rsdb_exec_fetch(&table,
|
{
|
||||||
"SELECT name FROM sqlite_master WHERE type='table' AND name='%s'",
|
rsdb_exec_fetch(&table,
|
||||||
bandb_table[i]);
|
"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)
|
if(!table.row_count)
|
||||||
rsdb_exec(NULL,
|
rsdb_exec(NULL,
|
||||||
"CREATE TABLE %s (mask1 TEXT, mask2 TEXT, oper TEXT, time INTEGER, perm INTEGER, reason TEXT)",
|
"CREATE TABLE %s (mask1 TEXT, mask2 TEXT, oper TEXT, time INTEGER, perm INTEGER, reason TEXT)",
|
||||||
bandb_table[i]);
|
bandb_table[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
1124
bandb/bantool.c
1124
bandb/bantool.c
File diff suppressed because it is too large
Load Diff
18
bandb/rsdb.h
18
bandb/rsdb.h
|
@ -6,17 +6,19 @@ typedef void rsdb_error_cb(const char *);
|
||||||
|
|
||||||
typedef int (*rsdb_callback) (int, const char **);
|
typedef int (*rsdb_callback) (int, const char **);
|
||||||
|
|
||||||
typedef enum rsdb_transtype {
|
typedef enum rsdb_transtype
|
||||||
RSDB_TRANS_START,
|
{
|
||||||
RSDB_TRANS_END
|
RSDB_TRANS_START,
|
||||||
|
RSDB_TRANS_END
|
||||||
}
|
}
|
||||||
rsdb_transtype;
|
rsdb_transtype;
|
||||||
|
|
||||||
struct rsdb_table {
|
struct rsdb_table
|
||||||
char ***row;
|
{
|
||||||
int row_count;
|
char ***row;
|
||||||
int col_count;
|
int row_count;
|
||||||
void *arg;
|
int col_count;
|
||||||
|
void *arg;
|
||||||
};
|
};
|
||||||
|
|
||||||
int rsdb_init(rsdb_error_cb *);
|
int rsdb_init(rsdb_error_cb *);
|
||||||
|
|
|
@ -39,206 +39,206 @@
|
||||||
#define TABLE_MAX 1000
|
#define TABLE_MAX 1000
|
||||||
|
|
||||||
static const char *IntTable[] = {
|
static const char *IntTable[] = {
|
||||||
"000", "100", "200", "300", "400",
|
"000", "100", "200", "300", "400",
|
||||||
"500", "600", "700", "800", "900",
|
"500", "600", "700", "800", "900",
|
||||||
"010", "110", "210", "310", "410",
|
"010", "110", "210", "310", "410",
|
||||||
"510", "610", "710", "810", "910",
|
"510", "610", "710", "810", "910",
|
||||||
"020", "120", "220", "320", "420",
|
"020", "120", "220", "320", "420",
|
||||||
"520", "620", "720", "820", "920",
|
"520", "620", "720", "820", "920",
|
||||||
"030", "130", "230", "330", "430",
|
"030", "130", "230", "330", "430",
|
||||||
"530", "630", "730", "830", "930",
|
"530", "630", "730", "830", "930",
|
||||||
"040", "140", "240", "340", "440",
|
"040", "140", "240", "340", "440",
|
||||||
"540", "640", "740", "840", "940",
|
"540", "640", "740", "840", "940",
|
||||||
"050", "150", "250", "350", "450",
|
"050", "150", "250", "350", "450",
|
||||||
"550", "650", "750", "850", "950",
|
"550", "650", "750", "850", "950",
|
||||||
"060", "160", "260", "360", "460",
|
"060", "160", "260", "360", "460",
|
||||||
"560", "660", "760", "860", "960",
|
"560", "660", "760", "860", "960",
|
||||||
"070", "170", "270", "370", "470",
|
"070", "170", "270", "370", "470",
|
||||||
"570", "670", "770", "870", "970",
|
"570", "670", "770", "870", "970",
|
||||||
"080", "180", "280", "380", "480",
|
"080", "180", "280", "380", "480",
|
||||||
"580", "680", "780", "880", "980",
|
"580", "680", "780", "880", "980",
|
||||||
"090", "190", "290", "390", "490",
|
"090", "190", "290", "390", "490",
|
||||||
"590", "690", "790", "890", "990",
|
"590", "690", "790", "890", "990",
|
||||||
"001", "101", "201", "301", "401",
|
"001", "101", "201", "301", "401",
|
||||||
"501", "601", "701", "801", "901",
|
"501", "601", "701", "801", "901",
|
||||||
"011", "111", "211", "311", "411",
|
"011", "111", "211", "311", "411",
|
||||||
"511", "611", "711", "811", "911",
|
"511", "611", "711", "811", "911",
|
||||||
"021", "121", "221", "321", "421",
|
"021", "121", "221", "321", "421",
|
||||||
"521", "621", "721", "821", "921",
|
"521", "621", "721", "821", "921",
|
||||||
"031", "131", "231", "331", "431",
|
"031", "131", "231", "331", "431",
|
||||||
"531", "631", "731", "831", "931",
|
"531", "631", "731", "831", "931",
|
||||||
"041", "141", "241", "341", "441",
|
"041", "141", "241", "341", "441",
|
||||||
"541", "641", "741", "841", "941",
|
"541", "641", "741", "841", "941",
|
||||||
"051", "151", "251", "351", "451",
|
"051", "151", "251", "351", "451",
|
||||||
"551", "651", "751", "851", "951",
|
"551", "651", "751", "851", "951",
|
||||||
"061", "161", "261", "361", "461",
|
"061", "161", "261", "361", "461",
|
||||||
"561", "661", "761", "861", "961",
|
"561", "661", "761", "861", "961",
|
||||||
"071", "171", "271", "371", "471",
|
"071", "171", "271", "371", "471",
|
||||||
"571", "671", "771", "871", "971",
|
"571", "671", "771", "871", "971",
|
||||||
"081", "181", "281", "381", "481",
|
"081", "181", "281", "381", "481",
|
||||||
"581", "681", "781", "881", "981",
|
"581", "681", "781", "881", "981",
|
||||||
"091", "191", "291", "391", "491",
|
"091", "191", "291", "391", "491",
|
||||||
"591", "691", "791", "891", "991",
|
"591", "691", "791", "891", "991",
|
||||||
"002", "102", "202", "302", "402",
|
"002", "102", "202", "302", "402",
|
||||||
"502", "602", "702", "802", "902",
|
"502", "602", "702", "802", "902",
|
||||||
"012", "112", "212", "312", "412",
|
"012", "112", "212", "312", "412",
|
||||||
"512", "612", "712", "812", "912",
|
"512", "612", "712", "812", "912",
|
||||||
"022", "122", "222", "322", "422",
|
"022", "122", "222", "322", "422",
|
||||||
"522", "622", "722", "822", "922",
|
"522", "622", "722", "822", "922",
|
||||||
"032", "132", "232", "332", "432",
|
"032", "132", "232", "332", "432",
|
||||||
"532", "632", "732", "832", "932",
|
"532", "632", "732", "832", "932",
|
||||||
"042", "142", "242", "342", "442",
|
"042", "142", "242", "342", "442",
|
||||||
"542", "642", "742", "842", "942",
|
"542", "642", "742", "842", "942",
|
||||||
"052", "152", "252", "352", "452",
|
"052", "152", "252", "352", "452",
|
||||||
"552", "652", "752", "852", "952",
|
"552", "652", "752", "852", "952",
|
||||||
"062", "162", "262", "362", "462",
|
"062", "162", "262", "362", "462",
|
||||||
"562", "662", "762", "862", "962",
|
"562", "662", "762", "862", "962",
|
||||||
"072", "172", "272", "372", "472",
|
"072", "172", "272", "372", "472",
|
||||||
"572", "672", "772", "872", "972",
|
"572", "672", "772", "872", "972",
|
||||||
"082", "182", "282", "382", "482",
|
"082", "182", "282", "382", "482",
|
||||||
"582", "682", "782", "882", "982",
|
"582", "682", "782", "882", "982",
|
||||||
"092", "192", "292", "392", "492",
|
"092", "192", "292", "392", "492",
|
||||||
"592", "692", "792", "892", "992",
|
"592", "692", "792", "892", "992",
|
||||||
"003", "103", "203", "303", "403",
|
"003", "103", "203", "303", "403",
|
||||||
"503", "603", "703", "803", "903",
|
"503", "603", "703", "803", "903",
|
||||||
"013", "113", "213", "313", "413",
|
"013", "113", "213", "313", "413",
|
||||||
"513", "613", "713", "813", "913",
|
"513", "613", "713", "813", "913",
|
||||||
"023", "123", "223", "323", "423",
|
"023", "123", "223", "323", "423",
|
||||||
"523", "623", "723", "823", "923",
|
"523", "623", "723", "823", "923",
|
||||||
"033", "133", "233", "333", "433",
|
"033", "133", "233", "333", "433",
|
||||||
"533", "633", "733", "833", "933",
|
"533", "633", "733", "833", "933",
|
||||||
"043", "143", "243", "343", "443",
|
"043", "143", "243", "343", "443",
|
||||||
"543", "643", "743", "843", "943",
|
"543", "643", "743", "843", "943",
|
||||||
"053", "153", "253", "353", "453",
|
"053", "153", "253", "353", "453",
|
||||||
"553", "653", "753", "853", "953",
|
"553", "653", "753", "853", "953",
|
||||||
"063", "163", "263", "363", "463",
|
"063", "163", "263", "363", "463",
|
||||||
"563", "663", "763", "863", "963",
|
"563", "663", "763", "863", "963",
|
||||||
"073", "173", "273", "373", "473",
|
"073", "173", "273", "373", "473",
|
||||||
"573", "673", "773", "873", "973",
|
"573", "673", "773", "873", "973",
|
||||||
"083", "183", "283", "383", "483",
|
"083", "183", "283", "383", "483",
|
||||||
"583", "683", "783", "883", "983",
|
"583", "683", "783", "883", "983",
|
||||||
"093", "193", "293", "393", "493",
|
"093", "193", "293", "393", "493",
|
||||||
"593", "693", "793", "893", "993",
|
"593", "693", "793", "893", "993",
|
||||||
"004", "104", "204", "304", "404",
|
"004", "104", "204", "304", "404",
|
||||||
"504", "604", "704", "804", "904",
|
"504", "604", "704", "804", "904",
|
||||||
"014", "114", "214", "314", "414",
|
"014", "114", "214", "314", "414",
|
||||||
"514", "614", "714", "814", "914",
|
"514", "614", "714", "814", "914",
|
||||||
"024", "124", "224", "324", "424",
|
"024", "124", "224", "324", "424",
|
||||||
"524", "624", "724", "824", "924",
|
"524", "624", "724", "824", "924",
|
||||||
"034", "134", "234", "334", "434",
|
"034", "134", "234", "334", "434",
|
||||||
"534", "634", "734", "834", "934",
|
"534", "634", "734", "834", "934",
|
||||||
"044", "144", "244", "344", "444",
|
"044", "144", "244", "344", "444",
|
||||||
"544", "644", "744", "844", "944",
|
"544", "644", "744", "844", "944",
|
||||||
"054", "154", "254", "354", "454",
|
"054", "154", "254", "354", "454",
|
||||||
"554", "654", "754", "854", "954",
|
"554", "654", "754", "854", "954",
|
||||||
"064", "164", "264", "364", "464",
|
"064", "164", "264", "364", "464",
|
||||||
"564", "664", "764", "864", "964",
|
"564", "664", "764", "864", "964",
|
||||||
"074", "174", "274", "374", "474",
|
"074", "174", "274", "374", "474",
|
||||||
"574", "674", "774", "874", "974",
|
"574", "674", "774", "874", "974",
|
||||||
"084", "184", "284", "384", "484",
|
"084", "184", "284", "384", "484",
|
||||||
"584", "684", "784", "884", "984",
|
"584", "684", "784", "884", "984",
|
||||||
"094", "194", "294", "394", "494",
|
"094", "194", "294", "394", "494",
|
||||||
"594", "694", "794", "894", "994",
|
"594", "694", "794", "894", "994",
|
||||||
"005", "105", "205", "305", "405",
|
"005", "105", "205", "305", "405",
|
||||||
"505", "605", "705", "805", "905",
|
"505", "605", "705", "805", "905",
|
||||||
"015", "115", "215", "315", "415",
|
"015", "115", "215", "315", "415",
|
||||||
"515", "615", "715", "815", "915",
|
"515", "615", "715", "815", "915",
|
||||||
"025", "125", "225", "325", "425",
|
"025", "125", "225", "325", "425",
|
||||||
"525", "625", "725", "825", "925",
|
"525", "625", "725", "825", "925",
|
||||||
"035", "135", "235", "335", "435",
|
"035", "135", "235", "335", "435",
|
||||||
"535", "635", "735", "835", "935",
|
"535", "635", "735", "835", "935",
|
||||||
"045", "145", "245", "345", "445",
|
"045", "145", "245", "345", "445",
|
||||||
"545", "645", "745", "845", "945",
|
"545", "645", "745", "845", "945",
|
||||||
"055", "155", "255", "355", "455",
|
"055", "155", "255", "355", "455",
|
||||||
"555", "655", "755", "855", "955",
|
"555", "655", "755", "855", "955",
|
||||||
"065", "165", "265", "365", "465",
|
"065", "165", "265", "365", "465",
|
||||||
"565", "665", "765", "865", "965",
|
"565", "665", "765", "865", "965",
|
||||||
"075", "175", "275", "375", "475",
|
"075", "175", "275", "375", "475",
|
||||||
"575", "675", "775", "875", "975",
|
"575", "675", "775", "875", "975",
|
||||||
"085", "185", "285", "385", "485",
|
"085", "185", "285", "385", "485",
|
||||||
"585", "685", "785", "885", "985",
|
"585", "685", "785", "885", "985",
|
||||||
"095", "195", "295", "395", "495",
|
"095", "195", "295", "395", "495",
|
||||||
"595", "695", "795", "895", "995",
|
"595", "695", "795", "895", "995",
|
||||||
"006", "106", "206", "306", "406",
|
"006", "106", "206", "306", "406",
|
||||||
"506", "606", "706", "806", "906",
|
"506", "606", "706", "806", "906",
|
||||||
"016", "116", "216", "316", "416",
|
"016", "116", "216", "316", "416",
|
||||||
"516", "616", "716", "816", "916",
|
"516", "616", "716", "816", "916",
|
||||||
"026", "126", "226", "326", "426",
|
"026", "126", "226", "326", "426",
|
||||||
"526", "626", "726", "826", "926",
|
"526", "626", "726", "826", "926",
|
||||||
"036", "136", "236", "336", "436",
|
"036", "136", "236", "336", "436",
|
||||||
"536", "636", "736", "836", "936",
|
"536", "636", "736", "836", "936",
|
||||||
"046", "146", "246", "346", "446",
|
"046", "146", "246", "346", "446",
|
||||||
"546", "646", "746", "846", "946",
|
"546", "646", "746", "846", "946",
|
||||||
"056", "156", "256", "356", "456",
|
"056", "156", "256", "356", "456",
|
||||||
"556", "656", "756", "856", "956",
|
"556", "656", "756", "856", "956",
|
||||||
"066", "166", "266", "366", "466",
|
"066", "166", "266", "366", "466",
|
||||||
"566", "666", "766", "866", "966",
|
"566", "666", "766", "866", "966",
|
||||||
"076", "176", "276", "376", "476",
|
"076", "176", "276", "376", "476",
|
||||||
"576", "676", "776", "876", "976",
|
"576", "676", "776", "876", "976",
|
||||||
"086", "186", "286", "386", "486",
|
"086", "186", "286", "386", "486",
|
||||||
"586", "686", "786", "886", "986",
|
"586", "686", "786", "886", "986",
|
||||||
"096", "196", "296", "396", "496",
|
"096", "196", "296", "396", "496",
|
||||||
"596", "696", "796", "896", "996",
|
"596", "696", "796", "896", "996",
|
||||||
"007", "107", "207", "307", "407",
|
"007", "107", "207", "307", "407",
|
||||||
"507", "607", "707", "807", "907",
|
"507", "607", "707", "807", "907",
|
||||||
"017", "117", "217", "317", "417",
|
"017", "117", "217", "317", "417",
|
||||||
"517", "617", "717", "817", "917",
|
"517", "617", "717", "817", "917",
|
||||||
"027", "127", "227", "327", "427",
|
"027", "127", "227", "327", "427",
|
||||||
"527", "627", "727", "827", "927",
|
"527", "627", "727", "827", "927",
|
||||||
"037", "137", "237", "337", "437",
|
"037", "137", "237", "337", "437",
|
||||||
"537", "637", "737", "837", "937",
|
"537", "637", "737", "837", "937",
|
||||||
"047", "147", "247", "347", "447",
|
"047", "147", "247", "347", "447",
|
||||||
"547", "647", "747", "847", "947",
|
"547", "647", "747", "847", "947",
|
||||||
"057", "157", "257", "357", "457",
|
"057", "157", "257", "357", "457",
|
||||||
"557", "657", "757", "857", "957",
|
"557", "657", "757", "857", "957",
|
||||||
"067", "167", "267", "367", "467",
|
"067", "167", "267", "367", "467",
|
||||||
"567", "667", "767", "867", "967",
|
"567", "667", "767", "867", "967",
|
||||||
"077", "177", "277", "377", "477",
|
"077", "177", "277", "377", "477",
|
||||||
"577", "677", "777", "877", "977",
|
"577", "677", "777", "877", "977",
|
||||||
"087", "187", "287", "387", "487",
|
"087", "187", "287", "387", "487",
|
||||||
"587", "687", "787", "887", "987",
|
"587", "687", "787", "887", "987",
|
||||||
"097", "197", "297", "397", "497",
|
"097", "197", "297", "397", "497",
|
||||||
"597", "697", "797", "897", "997",
|
"597", "697", "797", "897", "997",
|
||||||
"008", "108", "208", "308", "408",
|
"008", "108", "208", "308", "408",
|
||||||
"508", "608", "708", "808", "908",
|
"508", "608", "708", "808", "908",
|
||||||
"018", "118", "218", "318", "418",
|
"018", "118", "218", "318", "418",
|
||||||
"518", "618", "718", "818", "918",
|
"518", "618", "718", "818", "918",
|
||||||
"028", "128", "228", "328", "428",
|
"028", "128", "228", "328", "428",
|
||||||
"528", "628", "728", "828", "928",
|
"528", "628", "728", "828", "928",
|
||||||
"038", "138", "238", "338", "438",
|
"038", "138", "238", "338", "438",
|
||||||
"538", "638", "738", "838", "938",
|
"538", "638", "738", "838", "938",
|
||||||
"048", "148", "248", "348", "448",
|
"048", "148", "248", "348", "448",
|
||||||
"548", "648", "748", "848", "948",
|
"548", "648", "748", "848", "948",
|
||||||
"058", "158", "258", "358", "458",
|
"058", "158", "258", "358", "458",
|
||||||
"558", "658", "758", "858", "958",
|
"558", "658", "758", "858", "958",
|
||||||
"068", "168", "268", "368", "468",
|
"068", "168", "268", "368", "468",
|
||||||
"568", "668", "768", "868", "968",
|
"568", "668", "768", "868", "968",
|
||||||
"078", "178", "278", "378", "478",
|
"078", "178", "278", "378", "478",
|
||||||
"578", "678", "778", "878", "978",
|
"578", "678", "778", "878", "978",
|
||||||
"088", "188", "288", "388", "488",
|
"088", "188", "288", "388", "488",
|
||||||
"588", "688", "788", "888", "988",
|
"588", "688", "788", "888", "988",
|
||||||
"098", "198", "298", "398", "498",
|
"098", "198", "298", "398", "498",
|
||||||
"598", "698", "798", "898", "998",
|
"598", "698", "798", "898", "998",
|
||||||
"009", "109", "209", "309", "409",
|
"009", "109", "209", "309", "409",
|
||||||
"509", "609", "709", "809", "909",
|
"509", "609", "709", "809", "909",
|
||||||
"019", "119", "219", "319", "419",
|
"019", "119", "219", "319", "419",
|
||||||
"519", "619", "719", "819", "919",
|
"519", "619", "719", "819", "919",
|
||||||
"029", "129", "229", "329", "429",
|
"029", "129", "229", "329", "429",
|
||||||
"529", "629", "729", "829", "929",
|
"529", "629", "729", "829", "929",
|
||||||
"039", "139", "239", "339", "439",
|
"039", "139", "239", "339", "439",
|
||||||
"539", "639", "739", "839", "939",
|
"539", "639", "739", "839", "939",
|
||||||
"049", "149", "249", "349", "449",
|
"049", "149", "249", "349", "449",
|
||||||
"549", "649", "749", "849", "949",
|
"549", "649", "749", "849", "949",
|
||||||
"059", "159", "259", "359", "459",
|
"059", "159", "259", "359", "459",
|
||||||
"559", "659", "759", "859", "959",
|
"559", "659", "759", "859", "959",
|
||||||
"069", "169", "269", "369", "469",
|
"069", "169", "269", "369", "469",
|
||||||
"569", "669", "769", "869", "969",
|
"569", "669", "769", "869", "969",
|
||||||
"079", "179", "279", "379", "479",
|
"079", "179", "279", "379", "479",
|
||||||
"579", "679", "779", "879", "979",
|
"579", "679", "779", "879", "979",
|
||||||
"089", "189", "289", "389", "489",
|
"089", "189", "289", "389", "489",
|
||||||
"589", "689", "789", "889", "989",
|
"589", "689", "789", "889", "989",
|
||||||
"099", "199", "299", "399", "499",
|
"099", "199", "299", "399", "499",
|
||||||
"599", "699", "799", "899", "999"
|
"599", "699", "799", "899", "999"
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -274,290 +274,328 @@ NOTE: This function handles the following flags only:
|
||||||
int
|
int
|
||||||
rs_vsnprintf(char *dest, const size_t bytes, const char *format, va_list args)
|
rs_vsnprintf(char *dest, const size_t bytes, const char *format, va_list args)
|
||||||
{
|
{
|
||||||
char ch;
|
char ch;
|
||||||
int written = 0; /* bytes written so far */
|
int written = 0; /* bytes written so far */
|
||||||
int maxbytes = bytes - 1;
|
int maxbytes = bytes - 1;
|
||||||
|
|
||||||
while((ch = *format++) && (written < maxbytes)) {
|
while((ch = *format++) && (written < maxbytes))
|
||||||
if(ch == '%') {
|
{
|
||||||
/*
|
if(ch == '%')
|
||||||
* Advance past the %
|
{
|
||||||
*/
|
/*
|
||||||
ch = *format++;
|
* 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') {
|
if(ch == 's')
|
||||||
const char *str = va_arg(args, const char *);
|
{
|
||||||
|
const char *str = va_arg(args, const char *);
|
||||||
|
|
||||||
while((*dest = *str)) {
|
while((*dest = *str))
|
||||||
++dest;
|
{
|
||||||
++str;
|
++dest;
|
||||||
|
++str;
|
||||||
|
|
||||||
if(++written >= maxbytes)
|
if(++written >= maxbytes)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ch == 'd') {
|
if(ch == 'd')
|
||||||
int num = va_arg(args, int);
|
{
|
||||||
int quotient;
|
int num = va_arg(args, int);
|
||||||
const char *str;
|
int quotient;
|
||||||
char *digitptr = TempBuffer;
|
const char *str;
|
||||||
|
char *digitptr = TempBuffer;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We have to special-case "0" unfortunately
|
* We have to special-case "0" unfortunately
|
||||||
*/
|
*/
|
||||||
if(num == 0) {
|
if(num == 0)
|
||||||
*dest++ = '0';
|
{
|
||||||
++written;
|
*dest++ = '0';
|
||||||
continue;
|
++written;
|
||||||
}
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if(num < 0) {
|
if(num < 0)
|
||||||
*dest++ = '-';
|
{
|
||||||
if(++written >= maxbytes)
|
*dest++ = '-';
|
||||||
continue;
|
if(++written >= maxbytes)
|
||||||
|
continue;
|
||||||
|
|
||||||
num = -num;
|
num = -num;
|
||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do
|
||||||
quotient = num / TABLE_MAX;
|
{
|
||||||
|
quotient = num / TABLE_MAX;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We'll start with the right-most digits of 'num'.
|
* We'll start with the right-most digits of 'num'.
|
||||||
* Dividing by TABLE_MAX cuts off all but the X
|
* Dividing by TABLE_MAX cuts off all but the X
|
||||||
* right-most digits, where X is such that:
|
* right-most digits, where X is such that:
|
||||||
*
|
*
|
||||||
* 10^X = TABLE_MAX
|
* 10^X = TABLE_MAX
|
||||||
*
|
*
|
||||||
* For example, if num = 1200, and TABLE_MAX = 1000,
|
* For example, if num = 1200, and TABLE_MAX = 1000,
|
||||||
* quotient will be 1. Multiplying this by 1000 and
|
* quotient will be 1. Multiplying this by 1000 and
|
||||||
* subtracting from 1200 gives: 1200 - (1 * 1000) = 200.
|
* subtracting from 1200 gives: 1200 - (1 * 1000) = 200.
|
||||||
* We then go right to slot 200 in our array and behold!
|
* We then go right to slot 200 in our array and behold!
|
||||||
* The string "002" (200 backwards) is conveniently
|
* The string "002" (200 backwards) is conveniently
|
||||||
* waiting for us. Then repeat the process with the
|
* waiting for us. Then repeat the process with the
|
||||||
* digits left.
|
* digits left.
|
||||||
*
|
*
|
||||||
* The reason we need to have the integers written
|
* The reason we need to have the integers written
|
||||||
* backwards, is because we don't know how many digits
|
* backwards, is because we don't know how many digits
|
||||||
* there are. If we want to express the number 12130
|
* there are. If we want to express the number 12130
|
||||||
* for example, our first pass would leave us with 130,
|
* for example, our first pass would leave us with 130,
|
||||||
* whose slot in the array yields "031", which we
|
* whose slot in the array yields "031", which we
|
||||||
* plug into our TempBuffer[]. The next pass gives us
|
* plug into our TempBuffer[]. The next pass gives us
|
||||||
* 12, whose slot yields "21" which we append to
|
* 12, whose slot yields "21" which we append to
|
||||||
* TempBuffer[], leaving us with "03121". This is the
|
* TempBuffer[], leaving us with "03121". This is the
|
||||||
* exact number we want, only backwards, so it is
|
* exact number we want, only backwards, so it is
|
||||||
* a simple matter to reverse the string. If we used
|
* a simple matter to reverse the string. If we used
|
||||||
* straightfoward numbers, we would have a TempBuffer
|
* straightfoward numbers, we would have a TempBuffer
|
||||||
* looking like this: "13012" which would be a nightmare
|
* looking like this: "13012" which would be a nightmare
|
||||||
* to deal with.
|
* to deal with.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
str = IntTable[num - (quotient * TABLE_MAX)];
|
str = IntTable[num - (quotient * TABLE_MAX)];
|
||||||
|
|
||||||
while((*digitptr = *str)) {
|
while((*digitptr = *str))
|
||||||
++digitptr;
|
{
|
||||||
++str;
|
++digitptr;
|
||||||
}
|
++str;
|
||||||
} while((num = quotient) != 0);
|
}
|
||||||
|
}
|
||||||
|
while((num = quotient) != 0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the last quotient was a 1 or 2 digit number, there
|
* If the last quotient was a 1 or 2 digit number, there
|
||||||
* will be one or more leading zeroes in TempBuffer[] -
|
* will be one or more leading zeroes in TempBuffer[] -
|
||||||
* get rid of them.
|
* get rid of them.
|
||||||
*/
|
*/
|
||||||
while(*(digitptr - 1) == '0')
|
while(*(digitptr - 1) == '0')
|
||||||
--digitptr;
|
--digitptr;
|
||||||
|
|
||||||
while(digitptr != TempBuffer) {
|
while(digitptr != TempBuffer)
|
||||||
*dest++ = *--digitptr;
|
{
|
||||||
if(++written >= maxbytes)
|
*dest++ = *--digitptr;
|
||||||
break;
|
if(++written >= maxbytes)
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
} /* if (ch == 'd') */
|
} /* if (ch == 'd') */
|
||||||
|
|
||||||
if(ch == 'c') {
|
if(ch == 'c')
|
||||||
*dest++ = va_arg(args, int);
|
{
|
||||||
|
*dest++ = va_arg(args, int);
|
||||||
|
|
||||||
++written;
|
++written;
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
} /* if (ch == 'c') */
|
} /* if (ch == 'c') */
|
||||||
|
|
||||||
if(ch == 'u') {
|
if(ch == 'u')
|
||||||
unsigned int num = va_arg(args, unsigned int);
|
{
|
||||||
unsigned int quotient;
|
unsigned int num = va_arg(args, unsigned int);
|
||||||
const char *str;
|
unsigned int quotient;
|
||||||
char *digitptr = TempBuffer;
|
const char *str;
|
||||||
|
char *digitptr = TempBuffer;
|
||||||
|
|
||||||
if(num == 0) {
|
if(num == 0)
|
||||||
*dest++ = '0';
|
{
|
||||||
++written;
|
*dest++ = '0';
|
||||||
continue;
|
++written;
|
||||||
}
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
do {
|
do
|
||||||
quotient = num / TABLE_MAX;
|
{
|
||||||
|
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)) {
|
while((*digitptr = *str))
|
||||||
++digitptr;
|
{
|
||||||
++str;
|
++digitptr;
|
||||||
}
|
++str;
|
||||||
} while((num = quotient) != 0);
|
}
|
||||||
|
}
|
||||||
|
while((num = quotient) != 0);
|
||||||
|
|
||||||
while(*(digitptr - 1) == '0')
|
while(*(digitptr - 1) == '0')
|
||||||
--digitptr;
|
--digitptr;
|
||||||
|
|
||||||
while(digitptr != TempBuffer) {
|
while(digitptr != TempBuffer)
|
||||||
*dest++ = *--digitptr;
|
{
|
||||||
if(++written >= maxbytes)
|
*dest++ = *--digitptr;
|
||||||
break;
|
if(++written >= maxbytes)
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
} /* if (ch == 'u') */
|
} /* if (ch == 'u') */
|
||||||
|
|
||||||
if(ch == 'Q') {
|
if(ch == 'Q')
|
||||||
const char *arg = va_arg(args, const char *);
|
{
|
||||||
|
const char *arg = va_arg(args, const char *);
|
||||||
|
|
||||||
if(arg == NULL)
|
if(arg == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const char *str = rsdb_quote(arg);
|
const char *str = rsdb_quote(arg);
|
||||||
|
|
||||||
while((*dest = *str)) {
|
while((*dest = *str))
|
||||||
++dest;
|
{
|
||||||
++str;
|
++dest;
|
||||||
|
++str;
|
||||||
|
|
||||||
if(++written >= maxbytes)
|
if(++written >= maxbytes)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ch == 'l') {
|
if(ch == 'l')
|
||||||
if(*format == 'u') {
|
{
|
||||||
unsigned long num = va_arg(args, unsigned long);
|
if(*format == 'u')
|
||||||
unsigned long quotient;
|
{
|
||||||
const char *str;
|
unsigned long num = va_arg(args, unsigned long);
|
||||||
char *digitptr = TempBuffer;
|
unsigned long quotient;
|
||||||
|
const char *str;
|
||||||
|
char *digitptr = TempBuffer;
|
||||||
|
|
||||||
++format;
|
++format;
|
||||||
|
|
||||||
if(num == 0) {
|
if(num == 0)
|
||||||
*dest++ = '0';
|
{
|
||||||
++written;
|
*dest++ = '0';
|
||||||
continue;
|
++written;
|
||||||
}
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
do {
|
do
|
||||||
quotient = num / TABLE_MAX;
|
{
|
||||||
|
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)) {
|
while((*digitptr = *str))
|
||||||
++digitptr;
|
{
|
||||||
++str;
|
++digitptr;
|
||||||
}
|
++str;
|
||||||
} while((num = quotient) != 0);
|
}
|
||||||
|
}
|
||||||
|
while((num = quotient) != 0);
|
||||||
|
|
||||||
while(*(digitptr - 1) == '0')
|
while(*(digitptr - 1) == '0')
|
||||||
--digitptr;
|
--digitptr;
|
||||||
|
|
||||||
while(digitptr != TempBuffer) {
|
while(digitptr != TempBuffer)
|
||||||
*dest++ = *--digitptr;
|
{
|
||||||
if(++written >= maxbytes)
|
*dest++ = *--digitptr;
|
||||||
break;
|
if(++written >= maxbytes)
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
} else
|
}
|
||||||
/* if (*format == 'u') */ if(*format == 'd') {
|
else
|
||||||
long num = va_arg(args, long);
|
/* if (*format == 'u') */ if(*format == 'd')
|
||||||
long quotient;
|
{
|
||||||
const char *str;
|
long num = va_arg(args, long);
|
||||||
char *digitptr = TempBuffer;
|
long quotient;
|
||||||
|
const char *str;
|
||||||
|
char *digitptr = TempBuffer;
|
||||||
|
|
||||||
++format;
|
++format;
|
||||||
|
|
||||||
if(num == 0) {
|
if(num == 0)
|
||||||
*dest++ = '0';
|
{
|
||||||
++written;
|
*dest++ = '0';
|
||||||
continue;
|
++written;
|
||||||
}
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if(num < 0) {
|
if(num < 0)
|
||||||
*dest++ = '-';
|
{
|
||||||
if(++written >= maxbytes)
|
*dest++ = '-';
|
||||||
continue;
|
if(++written >= maxbytes)
|
||||||
|
continue;
|
||||||
|
|
||||||
num = -num;
|
num = -num;
|
||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do
|
||||||
quotient = num / TABLE_MAX;
|
{
|
||||||
|
quotient = num / TABLE_MAX;
|
||||||
|
|
||||||
str = IntTable[num - (quotient * TABLE_MAX)];
|
str = IntTable[num - (quotient * TABLE_MAX)];
|
||||||
|
|
||||||
while((*digitptr = *str)) {
|
while((*digitptr = *str))
|
||||||
++digitptr;
|
{
|
||||||
++str;
|
++digitptr;
|
||||||
}
|
++str;
|
||||||
} while((num = quotient) != 0);
|
}
|
||||||
|
}
|
||||||
|
while((num = quotient) != 0);
|
||||||
|
|
||||||
while(*(digitptr - 1) == '0')
|
while(*(digitptr - 1) == '0')
|
||||||
--digitptr;
|
--digitptr;
|
||||||
|
|
||||||
while(digitptr != TempBuffer) {
|
while(digitptr != TempBuffer)
|
||||||
*dest++ = *--digitptr;
|
{
|
||||||
if(++written >= maxbytes)
|
*dest++ = *--digitptr;
|
||||||
break;
|
if(++written >= maxbytes)
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
} else { /* if (*format == 'd') */
|
}
|
||||||
/* XXX error */
|
else /* if (*format == 'd') */
|
||||||
exit(1);
|
{
|
||||||
}
|
/* XXX error */
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} /* if (ch == 'l') */
|
} /* if (ch == 'l') */
|
||||||
|
|
||||||
if(ch != '%') {
|
if(ch != '%')
|
||||||
/* XXX error */
|
{
|
||||||
exit(1);
|
/* XXX error */
|
||||||
} /* if (ch != '%') */
|
exit(1);
|
||||||
} /* if (ch == '%') */
|
} /* if (ch != '%') */
|
||||||
|
} /* if (ch == '%') */
|
||||||
|
|
||||||
*dest++ = ch;
|
*dest++ = ch;
|
||||||
++written;
|
++written;
|
||||||
} /* while ((ch = *format++) && (written < maxbytes)) */
|
} /* while ((ch = *format++) && (written < maxbytes)) */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Terminate the destination buffer with a \0
|
* Terminate the destination buffer with a \0
|
||||||
*/
|
*/
|
||||||
*dest = '\0';
|
*dest = '\0';
|
||||||
|
|
||||||
return (written);
|
return (written);
|
||||||
} /* vSnprintf() */
|
} /* vSnprintf() */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -576,14 +614,14 @@ Return: number of characters copied, NOT including the terminating
|
||||||
int
|
int
|
||||||
rs_snprintf(char *dest, const size_t bytes, const char *format, ...)
|
rs_snprintf(char *dest, const size_t bytes, const char *format, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
int count;
|
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() */
|
} /* Snprintf() */
|
||||||
|
|
|
@ -41,206 +41,224 @@ rsdb_error_cb *error_cb;
|
||||||
static void
|
static void
|
||||||
mlog(const char *errstr, ...)
|
mlog(const char *errstr, ...)
|
||||||
{
|
{
|
||||||
if(error_cb != NULL) {
|
if(error_cb != NULL)
|
||||||
char buf[256];
|
{
|
||||||
va_list ap;
|
char buf[256];
|
||||||
va_start(ap, errstr);
|
va_list ap;
|
||||||
vsnprintf(buf, sizeof(buf), errstr, ap);
|
va_start(ap, errstr);
|
||||||
va_end(ap);
|
rb_vsnprintf(buf, sizeof(buf), errstr, ap);
|
||||||
error_cb(buf);
|
va_end(ap);
|
||||||
} else
|
error_cb(buf);
|
||||||
exit(1);
|
}
|
||||||
|
else
|
||||||
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
rsdb_init(rsdb_error_cb * ecb)
|
rsdb_init(rsdb_error_cb * ecb)
|
||||||
{
|
{
|
||||||
const char *bandb_dbpath_env;
|
const char *bandb_dbpath_env;
|
||||||
char dbpath[PATH_MAX];
|
char dbpath[PATH_MAX];
|
||||||
char errbuf[128];
|
char errbuf[128];
|
||||||
error_cb = ecb;
|
error_cb = ecb;
|
||||||
|
|
||||||
/* try a path from the environment first, useful for basedir overrides */
|
/* try a path from the environment first, useful for basedir overrides */
|
||||||
bandb_dbpath_env = getenv("BANDB_DBPATH");
|
bandb_dbpath_env = getenv("BANDB_DBPATH");
|
||||||
|
|
||||||
if(bandb_dbpath_env != NULL)
|
if(bandb_dbpath_env != NULL)
|
||||||
rb_strlcpy(dbpath, bandb_dbpath_env, sizeof(dbpath));
|
rb_strlcpy(dbpath, bandb_dbpath_env, sizeof(dbpath));
|
||||||
else
|
else
|
||||||
rb_strlcpy(dbpath, DBPATH, sizeof(dbpath));
|
rb_strlcpy(dbpath, DBPATH, sizeof(dbpath));
|
||||||
|
|
||||||
if(sqlite3_open(dbpath, &rb_bandb) != SQLITE_OK) {
|
if(sqlite3_open(dbpath, &rb_bandb) != SQLITE_OK)
|
||||||
snprintf(errbuf, sizeof(errbuf), "Unable to open sqlite database: %s",
|
{
|
||||||
sqlite3_errmsg(rb_bandb));
|
rb_snprintf(errbuf, sizeof(errbuf), "Unable to open sqlite database: %s",
|
||||||
mlog(errbuf);
|
sqlite3_errmsg(rb_bandb));
|
||||||
return -1;
|
mlog(errbuf);
|
||||||
}
|
return -1;
|
||||||
if(access(dbpath, W_OK)) {
|
}
|
||||||
snprintf(errbuf, sizeof(errbuf), "Unable to open sqlite database for write: %s", strerror(errno));
|
if(access(dbpath, W_OK))
|
||||||
mlog(errbuf);
|
{
|
||||||
return -1;
|
rb_snprintf(errbuf, sizeof(errbuf), "Unable to open sqlite database for write: %s", strerror(errno));
|
||||||
}
|
mlog(errbuf);
|
||||||
return 0;
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
rsdb_shutdown(void)
|
rsdb_shutdown(void)
|
||||||
{
|
{
|
||||||
if(rb_bandb)
|
if(rb_bandb)
|
||||||
sqlite3_close(rb_bandb);
|
sqlite3_close(rb_bandb);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
rsdb_quote(const char *src)
|
rsdb_quote(const char *src)
|
||||||
{
|
{
|
||||||
static char buf[BUFSIZE * 4];
|
static char buf[BUFSIZE * 4];
|
||||||
char *p = buf;
|
char *p = buf;
|
||||||
|
|
||||||
/* cheap and dirty length check.. */
|
/* cheap and dirty length check.. */
|
||||||
if(strlen(src) >= (sizeof(buf) / 2))
|
if(strlen(src) >= (sizeof(buf) / 2))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
while(*src) {
|
while(*src)
|
||||||
if(*src == '\'')
|
{
|
||||||
*p++ = '\'';
|
if(*src == '\'')
|
||||||
|
*p++ = '\'';
|
||||||
|
|
||||||
*p++ = *src++;
|
*p++ = *src++;
|
||||||
}
|
}
|
||||||
|
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
rsdb_callback_func(void *cbfunc, int argc, char **argv, char **colnames)
|
rsdb_callback_func(void *cbfunc, int argc, char **argv, char **colnames)
|
||||||
{
|
{
|
||||||
rsdb_callback cb = (rsdb_callback)((uintptr_t)cbfunc);
|
rsdb_callback cb = (rsdb_callback)((uintptr_t)cbfunc);
|
||||||
(cb) (argc, (const char **)argv);
|
(cb) (argc, (const char **)argv);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
rsdb_exec(rsdb_callback cb, const char *format, ...)
|
rsdb_exec(rsdb_callback cb, const char *format, ...)
|
||||||
{
|
{
|
||||||
static char buf[BUFSIZE * 4];
|
static char buf[BUFSIZE * 4];
|
||||||
va_list args;
|
va_list args;
|
||||||
char *errmsg;
|
char *errmsg;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
i = rs_vsnprintf(buf, sizeof(buf), format, args);
|
i = rs_vsnprintf(buf, sizeof(buf), format, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
if(i >= sizeof(buf)) {
|
if(i >= sizeof(buf))
|
||||||
mlog("fatal error: length problem with compiling sql");
|
{
|
||||||
}
|
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))) {
|
if((i = sqlite3_exec(rb_bandb, buf, (cb ? rsdb_callback_func : NULL), (void *)((uintptr_t)cb), &errmsg)))
|
||||||
switch (i) {
|
{
|
||||||
case SQLITE_BUSY:
|
switch (i)
|
||||||
for(j = 0; j < 5; j++) {
|
{
|
||||||
rb_sleep(0, 500000);
|
case SQLITE_BUSY:
|
||||||
if(!sqlite3_exec
|
for(j = 0; j < 5; j++)
|
||||||
(rb_bandb, buf, (cb ? rsdb_callback_func : NULL), (void *)((uintptr_t)cb), &errmsg))
|
{
|
||||||
return;
|
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 */
|
/* failed, fall through to default */
|
||||||
mlog("fatal error: problem with db file: %s", errmsg);
|
mlog("fatal error: problem with db file: %s", errmsg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
mlog("fatal error: problem with db file: %s", errmsg);
|
mlog("fatal error: problem with db file: %s", errmsg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
rsdb_exec_fetch(struct rsdb_table *table, const char *format, ...)
|
rsdb_exec_fetch(struct rsdb_table *table, const char *format, ...)
|
||||||
{
|
{
|
||||||
static char buf[BUFSIZE * 4];
|
static char buf[BUFSIZE * 4];
|
||||||
va_list args;
|
va_list args;
|
||||||
char *errmsg;
|
char *errmsg;
|
||||||
char **data;
|
char **data;
|
||||||
int pos;
|
int pos;
|
||||||
unsigned int retval;
|
unsigned int retval;
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
retval = rs_vsnprintf(buf, sizeof(buf), format, args);
|
retval = rs_vsnprintf(buf, sizeof(buf), format, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
if(retval >= sizeof(buf)) {
|
if(retval >= sizeof(buf))
|
||||||
mlog("fatal error: length problem with compiling sql");
|
{
|
||||||
}
|
mlog("fatal error: length problem with compiling sql");
|
||||||
|
}
|
||||||
|
|
||||||
if((retval =
|
if((retval =
|
||||||
sqlite3_get_table(rb_bandb, buf, &data, &table->row_count, &table->col_count, &errmsg))) {
|
sqlite3_get_table(rb_bandb, buf, &data, &table->row_count, &table->col_count, &errmsg)))
|
||||||
int success = 0;
|
{
|
||||||
|
int success = 0;
|
||||||
|
|
||||||
switch (retval) {
|
switch (retval)
|
||||||
case SQLITE_BUSY:
|
{
|
||||||
for(i = 0; i < 5; i++) {
|
case SQLITE_BUSY:
|
||||||
rb_sleep(0, 500000);
|
for(i = 0; i < 5; i++)
|
||||||
if(!sqlite3_get_table
|
{
|
||||||
(rb_bandb, buf, &data, &table->row_count, &table->col_count,
|
rb_sleep(0, 500000);
|
||||||
&errmsg)) {
|
if(!sqlite3_get_table
|
||||||
success++;
|
(rb_bandb, buf, &data, &table->row_count, &table->col_count,
|
||||||
break;
|
&errmsg))
|
||||||
}
|
{
|
||||||
}
|
success++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(success)
|
if(success)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
mlog("fatal error: problem with db file: %s", errmsg);
|
mlog("fatal error: problem with db file: %s", errmsg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
mlog("fatal error: problem with db file: %s", errmsg);
|
mlog("fatal error: problem with db file: %s", errmsg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* we need to be able to free data afterward */
|
/* we need to be able to free data afterward */
|
||||||
table->arg = data;
|
table->arg = data;
|
||||||
|
|
||||||
if(table->row_count == 0) {
|
if(table->row_count == 0)
|
||||||
table->row = NULL;
|
{
|
||||||
return;
|
table->row = NULL;
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* sqlite puts the column names as the first row */
|
/* sqlite puts the column names as the first row */
|
||||||
pos = table->col_count;
|
pos = table->col_count;
|
||||||
table->row = rb_malloc(sizeof(char **) * table->row_count);
|
table->row = rb_malloc(sizeof(char **) * table->row_count);
|
||||||
for(i = 0; i < table->row_count; i++) {
|
for(i = 0; i < table->row_count; i++)
|
||||||
table->row[i] = rb_malloc(sizeof(char *) * table->col_count);
|
{
|
||||||
|
table->row[i] = rb_malloc(sizeof(char *) * table->col_count);
|
||||||
|
|
||||||
for(j = 0; j < table->col_count; j++) {
|
for(j = 0; j < table->col_count; j++)
|
||||||
table->row[i][j] = data[pos++];
|
{
|
||||||
}
|
table->row[i][j] = data[pos++];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
rsdb_exec_fetch_end(struct rsdb_table *table)
|
rsdb_exec_fetch_end(struct rsdb_table *table)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for(i = 0; i < table->row_count; i++) {
|
for(i = 0; i < table->row_count; i++)
|
||||||
rb_free(table->row[i]);
|
{
|
||||||
}
|
rb_free(table->row[i]);
|
||||||
rb_free(table->row);
|
}
|
||||||
|
rb_free(table->row);
|
||||||
|
|
||||||
sqlite3_free_table((char **)table->arg);
|
sqlite3_free_table((char **)table->arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
rsdb_transaction(rsdb_transtype type)
|
rsdb_transaction(rsdb_transtype type)
|
||||||
{
|
{
|
||||||
if(type == RSDB_TRANS_START)
|
if(type == RSDB_TRANS_START)
|
||||||
rsdb_exec(NULL, "BEGIN TRANSACTION");
|
rsdb_exec(NULL, "BEGIN TRANSACTION");
|
||||||
else if(type == RSDB_TRANS_END)
|
else if(type == RSDB_TRANS_END)
|
||||||
rsdb_exec(NULL, "COMMIT TRANSACTION");
|
rsdb_exec(NULL, "COMMIT TRANSACTION");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
# Guess values for system-dependent variables and create Makefiles.
|
# 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.
|
# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
|
||||||
|
@ -579,8 +579,8 @@ MAKEFLAGS=
|
||||||
# Identity of this package.
|
# Identity of this package.
|
||||||
PACKAGE_NAME='elemental-ircd'
|
PACKAGE_NAME='elemental-ircd'
|
||||||
PACKAGE_TARNAME='elemental-ircd'
|
PACKAGE_TARNAME='elemental-ircd'
|
||||||
PACKAGE_VERSION='6.6.1'
|
PACKAGE_VERSION='6.5.1'
|
||||||
PACKAGE_STRING='elemental-ircd 6.6.1'
|
PACKAGE_STRING='elemental-ircd 6.5.1'
|
||||||
PACKAGE_BUGREPORT=''
|
PACKAGE_BUGREPORT=''
|
||||||
PACKAGE_URL=''
|
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.
|
# 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.
|
# This message is too long to be a string in the A/UX 3.1 sh.
|
||||||
cat <<_ACEOF
|
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]...
|
Usage: $0 [OPTION]... [VAR=VALUE]...
|
||||||
|
|
||||||
|
@ -1364,7 +1364,7 @@ fi
|
||||||
|
|
||||||
if test -n "$ac_init_help"; then
|
if test -n "$ac_init_help"; then
|
||||||
case $ac_init_help in
|
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
|
esac
|
||||||
cat <<\_ACEOF
|
cat <<\_ACEOF
|
||||||
|
|
||||||
|
@ -1488,14 +1488,14 @@ fi
|
||||||
test -n "$ac_init_help" && exit $ac_status
|
test -n "$ac_init_help" && exit $ac_status
|
||||||
if $ac_init_version; then
|
if $ac_init_version; then
|
||||||
cat <<\_ACEOF
|
cat <<\_ACEOF
|
||||||
elemental-ircd configure 6.6.1
|
elemental-ircd configure 6.5.1
|
||||||
generated by GNU Autoconf 2.69
|
generated by GNU Autoconf 2.69
|
||||||
|
|
||||||
Copyright (C) 2012 Free Software Foundation, Inc.
|
Copyright (C) 2012 Free Software Foundation, Inc.
|
||||||
This configure script is free software; the Free Software Foundation
|
This configure script is free software; the Free Software Foundation
|
||||||
gives unlimited permission to copy, distribute and modify it.
|
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
|
_ACEOF
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
@ -2092,7 +2092,7 @@ cat >config.log <<_ACEOF
|
||||||
This file contains any messages produced by compilers while
|
This file contains any messages produced by compilers while
|
||||||
running configure, to aid debugging if configure makes a mistake.
|
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
|
generated by GNU Autoconf 2.69. Invocation command line was
|
||||||
|
|
||||||
$ $0 $@
|
$ $0 $@
|
||||||
|
@ -10100,7 +10100,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
|
||||||
# report actual input values of CONFIG_FILES etc. instead of their
|
# report actual input values of CONFIG_FILES etc. instead of their
|
||||||
# values after options handling.
|
# values after options handling.
|
||||||
ac_log="
|
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
|
generated by GNU Autoconf 2.69. Invocation command line was
|
||||||
|
|
||||||
CONFIG_FILES = $CONFIG_FILES
|
CONFIG_FILES = $CONFIG_FILES
|
||||||
|
@ -10166,7 +10166,7 @@ _ACEOF
|
||||||
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
|
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
|
||||||
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
|
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
|
||||||
ac_cs_version="\\
|
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,
|
configured by $0, generated by GNU Autoconf 2.69,
|
||||||
with options \\"\$ac_cs_config\\"
|
with options \\"\$ac_cs_config\\"
|
||||||
|
|
||||||
|
|
|
@ -8,9 +8,9 @@ dnl said functions need to be just about as complex as they already are.
|
||||||
AC_PREREQ(2.57)
|
AC_PREREQ(2.57)
|
||||||
|
|
||||||
dnl Sneaky way to get an Id tag into the configure script
|
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)
|
AC_CONFIG_HEADER(include/setup.h)
|
||||||
|
|
||||||
|
@ -253,7 +253,7 @@ AC_SUBST([pkglibdir])
|
||||||
AC_SUBST([rundir])
|
AC_SUBST([rundir])
|
||||||
AC_SUBST([pkgrundir])
|
AC_SUBST([pkgrundir])
|
||||||
AC_SUBST([pkglocalstatedir])
|
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_SUBST([pkglibexecdir])
|
||||||
AC_DEFINE_DIR([PKGLIBEXECDIR], [pkglibexecdir], [Directory where binaries the IRCd itself spawns live])
|
AC_DEFINE_DIR([PKGLIBEXECDIR], [pkglibexecdir], [Directory where binaries the IRCd itself spawns live])
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
* Copyright (C) 2000-2002 Hybrid Development Team
|
* Copyright (C) 2000-2002 Hybrid Development Team
|
||||||
* Copyright (C) 2002-2005 ircd-ratbox development team
|
* Copyright (C) 2002-2005 ircd-ratbox development team
|
||||||
* Copyright (C) 2005-2006 charybdis 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 $
|
* $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";
|
#loadmodule "extensions/sno_whois.so";
|
||||||
|
|
||||||
serverinfo {
|
serverinfo {
|
||||||
name = "hostname.domain.tld";
|
name = "hades.arpa";
|
||||||
sid = "42X";
|
sid = "42X";
|
||||||
description = "elemental-ircd test server";
|
description = "shadowircd test server";
|
||||||
network_name = "ShadowNET";
|
network_name = "AthemeNET";
|
||||||
network_desc = "Your IRC network.";
|
network_desc = "Your IRC network.";
|
||||||
helpchan = "#help";
|
helpchan = "#help";
|
||||||
helpurl = "http://www.mynet.net/help";
|
helpurl = "http://www.mynet.net/help";
|
||||||
|
@ -91,7 +90,7 @@ serverinfo {
|
||||||
|
|
||||||
admin {
|
admin {
|
||||||
name = "Lazy admin (lazya)";
|
name = "Lazy admin (lazya)";
|
||||||
description = "ShadowNET client server";
|
description = "AthemeNET client server";
|
||||||
email = "nobody@127.0.0.1";
|
email = "nobody@127.0.0.1";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -140,8 +139,7 @@ listen {
|
||||||
/* defer_accept: wait for clients to send IRC handshake data before
|
/* defer_accept: wait for clients to send IRC handshake data before
|
||||||
* accepting them. if you intend to use software which depends on the
|
* accepting them. if you intend to use software which depends on the
|
||||||
* server replying first, such as BOPM, you should disable this feature.
|
* server replying first, such as BOPM, you should disable this feature.
|
||||||
* otherwise, you probably want to leave it on. Disabling this will not
|
* otherwise, you probably want to leave it on.
|
||||||
* update on a rehash.
|
|
||||||
*/
|
*/
|
||||||
defer_accept = yes;
|
defer_accept = yes;
|
||||||
|
|
||||||
|
@ -154,8 +152,8 @@ listen {
|
||||||
|
|
||||||
/* Listen on IPv6 (if you used host= above). */
|
/* Listen on IPv6 (if you used host= above). */
|
||||||
#host = "3ffe:1234:a:b:c::d";
|
#host = "3ffe:1234:a:b:c::d";
|
||||||
#port = 5000, 6665 .. 6669;
|
#port = 5000, 6665 .. 6669;
|
||||||
#sslport = 9999;
|
#sslport = 9999;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* auth {}: allow users to connect to the ircd (OLD I:)
|
/* auth {}: allow users to connect to the ircd (OLD I:)
|
||||||
|
@ -200,6 +198,11 @@ auth {
|
||||||
*/
|
*/
|
||||||
autojoin = "#shadowircd,#test";
|
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:
|
/* Possible flags in auth:
|
||||||
*
|
*
|
||||||
* encrypted | password is encrypted with mkpasswd
|
* encrypted | password is encrypted with mkpasswd
|
||||||
|
@ -212,8 +215,8 @@ auth {
|
||||||
* jupe_exempt | exempt this user from generating
|
* jupe_exempt | exempt this user from generating
|
||||||
* warnings joining juped channels
|
* warnings joining juped channels
|
||||||
* resv_exempt | exempt this user from resvs
|
* resv_exempt | exempt this user from resvs
|
||||||
* flood_exempt | exempt this user from flood limits
|
* flood_exempt | exempt this user from flood limits
|
||||||
* USE WITH CAUTION.
|
* USE WITH CAUTION.
|
||||||
* no_tilde (old - flag) | don't prefix ~ to username if no ident
|
* no_tilde (old - flag) | don't prefix ~ to username if no ident
|
||||||
* need_ident (old + flag) | require ident for user in this class
|
* need_ident (old + flag) | require ident for user in this class
|
||||||
* need_ssl | require SSL/TLS for user in this class
|
* need_ssl | require SSL/TLS for user in this class
|
||||||
|
@ -394,14 +397,14 @@ channel {
|
||||||
exemptchanops = "NT";
|
exemptchanops = "NT";
|
||||||
use_halfop = yes;
|
use_halfop = yes;
|
||||||
use_admin = yes;
|
use_admin = yes;
|
||||||
use_owner = yes;
|
use_owner = yes;
|
||||||
use_knock = yes;
|
use_knock = yes;
|
||||||
use_local_channels = yes;
|
use_local_channels = yes;
|
||||||
knock_delay = 5 minutes;
|
knock_delay = 5 minutes;
|
||||||
knock_delay_channel = 1 minute;
|
knock_delay_channel = 1 minute;
|
||||||
max_chans_per_user = 15;
|
max_chans_per_user = 15;
|
||||||
max_bans = 100;
|
max_bans = 100;
|
||||||
max_bans_large = 500;
|
max_bans_large = 500;
|
||||||
default_split_user_count = 0;
|
default_split_user_count = 0;
|
||||||
default_split_server_count = 0;
|
default_split_server_count = 0;
|
||||||
no_create_on_split = no;
|
no_create_on_split = no;
|
||||||
|
@ -427,7 +430,7 @@ serverhide {
|
||||||
* They are used in pairs of one host/rejection reason.
|
* They are used in pairs of one host/rejection reason.
|
||||||
*
|
*
|
||||||
* These settings should be adequate for most networks, and are (presently)
|
* 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
|
* Word to the wise: Do not use blacklists like SPEWS for blocking IRC
|
||||||
* connections.
|
* connections.
|
||||||
|
@ -441,6 +444,9 @@ serverhide {
|
||||||
* ${nick} - the user's nickname
|
* ${nick} - the user's nickname
|
||||||
* ${network-name} - the name of the network
|
* ${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 {
|
blacklist {
|
||||||
host = "rbl.efnetrbl.org";
|
host = "rbl.efnetrbl.org";
|
||||||
|
@ -449,8 +455,11 @@ blacklist {
|
||||||
host = "dnsbl.dronebl.org";
|
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}";
|
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";
|
# host = "ircbl.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.";
|
# 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" {
|
alias "NickServ" {
|
||||||
|
@ -531,23 +540,23 @@ general {
|
||||||
|
|
||||||
default_operstring = "is an IRC Operator";
|
default_operstring = "is an IRC Operator";
|
||||||
default_adminstring = "is a Server Administrator";
|
default_adminstring = "is a Server Administrator";
|
||||||
#default_operhost = "staff.testnet.net";
|
default_operhost = "staff.testnet.net";
|
||||||
#static_quit = "I like turtles!";
|
#static_quit = "I like turtles!";
|
||||||
servicestring = "is a Network Service";
|
servicestring = "is a Network Service";
|
||||||
disable_fake_channels = no;
|
disable_fake_channels = no;
|
||||||
hide_channel_below_users = 3;
|
hide_channel_below_users = 3;
|
||||||
tkline_expire_notices = no;
|
tkline_expire_notices = no;
|
||||||
default_floodcount = 10;
|
default_floodcount = 10;
|
||||||
failed_oper_notice = yes;
|
failed_oper_notice = yes;
|
||||||
dots_in_ident=2;
|
dots_in_ident=2;
|
||||||
min_nonwildcard = 4;
|
min_nonwildcard = 4;
|
||||||
min_nonwildcard_simple = 3;
|
min_nonwildcard_simple = 3;
|
||||||
max_accept = 100;
|
max_accept = 100;
|
||||||
max_monitor = 100;
|
max_monitor = 100;
|
||||||
anti_nick_flood = yes;
|
anti_nick_flood = yes;
|
||||||
max_nick_time = 20 seconds;
|
max_nick_time = 20 seconds;
|
||||||
max_nick_changes = 5;
|
max_nick_changes = 5;
|
||||||
anti_spam_exit_message_time = 5 minutes;
|
anti_spam_exit_message_time = 5 minutes;
|
||||||
use_part_messages = yes;
|
use_part_messages = yes;
|
||||||
ts_warn_delta = 30 seconds;
|
ts_warn_delta = 30 seconds;
|
||||||
ts_max_delta = 5 minutes;
|
ts_max_delta = 5 minutes;
|
||||||
|
@ -571,7 +580,7 @@ general {
|
||||||
stats_P_oper_only=no;
|
stats_P_oper_only=no;
|
||||||
stats_i_oper_only=masked;
|
stats_i_oper_only=masked;
|
||||||
stats_k_oper_only=masked;
|
stats_k_oper_only=masked;
|
||||||
map_oper_only = no;
|
map_oper_only = no;
|
||||||
operspy_admin_only = no;
|
operspy_admin_only = no;
|
||||||
operspy_dont_care_user_info = no;
|
operspy_dont_care_user_info = no;
|
||||||
secret_channels_in_whois = no;
|
secret_channels_in_whois = no;
|
||||||
|
@ -587,11 +596,11 @@ general {
|
||||||
true_no_oper_flood = no;
|
true_no_oper_flood = no;
|
||||||
max_targets = 4;
|
max_targets = 4;
|
||||||
client_flood = 20;
|
client_flood = 20;
|
||||||
use_whois_actually = no;
|
use_whois_actually = no;
|
||||||
oper_only_umodes = operwall, locops, servnotice;
|
oper_only_umodes = operwall, locops, servnotice;
|
||||||
oper_umodes = locops, servnotice, operwall, wallop;
|
oper_umodes = locops, servnotice, operwall, wallop;
|
||||||
oper_snomask = "+s";
|
oper_snomask = "+s";
|
||||||
burst_away = yes;
|
burst_away = yes;
|
||||||
nick_delay = 0 seconds; # 15 minutes if you want to enable this
|
nick_delay = 0 seconds; # 15 minutes if you want to enable this
|
||||||
reject_ban_time = 1 minute;
|
reject_ban_time = 1 minute;
|
||||||
reject_after_count = 3;
|
reject_after_count = 3;
|
||||||
|
@ -599,7 +608,7 @@ general {
|
||||||
throttle_duration = 60;
|
throttle_duration = 60;
|
||||||
throttle_count = 4;
|
throttle_count = 4;
|
||||||
expire_override_time = 5 minutes;
|
expire_override_time = 5 minutes;
|
||||||
away_interval = 30;
|
away_interval = 30;
|
||||||
};
|
};
|
||||||
|
|
||||||
modules {
|
modules {
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
This is the Elemental-IRCd MOTD. You can use this if you like;
|
This is ShadowIRCd MOTD. You might replace it, but if not, your friends will
|
||||||
but if you do, your teacher may send you to magic kindergarten.
|
laugh at you.
|
||||||
|
|
|
@ -373,6 +373,11 @@ auth {
|
||||||
*/
|
*/
|
||||||
autojoin = "#shadowircd,#test";
|
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:
|
/* Possible flags in auth:
|
||||||
*
|
*
|
||||||
* encrypted | password is encrypted with mkpasswd
|
* encrypted | password is encrypted with mkpasswd
|
||||||
|
@ -962,6 +967,9 @@ serverhide {
|
||||||
* ${nick} - the user's nickname
|
* ${nick} - the user's nickname
|
||||||
* ${network-name} - the name of the network
|
* ${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 {
|
blacklist {
|
||||||
host = "rbl.efnetrbl.org";
|
host = "rbl.efnetrbl.org";
|
||||||
|
@ -969,6 +977,12 @@ blacklist {
|
||||||
|
|
||||||
host = "dnsbl.dronebl.org";
|
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}";
|
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.";
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -376,6 +376,11 @@ auth {
|
||||||
*/
|
*/
|
||||||
autojoin = "#shadowircd,#test";
|
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:
|
/* Possible flags in auth:
|
||||||
*
|
*
|
||||||
* encrypted | password is encrypted with mkpasswd
|
* encrypted | password is encrypted with mkpasswd
|
||||||
|
@ -965,6 +970,9 @@ serverhide {
|
||||||
* ${nick} - the user's nickname
|
* ${nick} - the user's nickname
|
||||||
* ${network-name} - the name of the network
|
* ${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 {
|
blacklist {
|
||||||
host = "rbl.efnetrbl.org";
|
host = "rbl.efnetrbl.org";
|
||||||
|
@ -972,6 +980,12 @@ blacklist {
|
||||||
|
|
||||||
host = "dnsbl.dronebl.org";
|
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}";
|
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.";
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -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
|
additional actions (such as `AKILL`s or logging to channels) as needed by the
|
||||||
bot author.
|
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.
|
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,6 @@ SRCS = \
|
||||||
force_user_invis.c \
|
force_user_invis.c \
|
||||||
hurt.c \
|
hurt.c \
|
||||||
ip_cloaking.c \
|
ip_cloaking.c \
|
||||||
ip_cloaking-5.c \
|
|
||||||
sno_farconnect.c \
|
sno_farconnect.c \
|
||||||
sno_globalkline.c \
|
sno_globalkline.c \
|
||||||
sno_globaloper.c \
|
sno_globaloper.c \
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
static void h_can_join(hook_data_channel *);
|
static void h_can_join(hook_data_channel *);
|
||||||
|
|
||||||
mapi_hfn_list_av1 adminonly_hfnlist[] = {
|
mapi_hfn_list_av1 adminonly_hfnlist[] = {
|
||||||
{ "can_join", (hookfn) h_can_join },
|
{ "can_join", (hookfn) h_can_join },
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
static unsigned int mymode;
|
static unsigned int mymode;
|
||||||
|
@ -22,17 +22,17 @@ static unsigned int mymode;
|
||||||
static int
|
static int
|
||||||
_modinit(void)
|
_modinit(void)
|
||||||
{
|
{
|
||||||
mymode = cflag_add('A', chm_staff);
|
mymode = cflag_add('A', chm_staff);
|
||||||
if (mymode == 0)
|
if (mymode == 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_moddeinit(void)
|
_moddeinit(void)
|
||||||
{
|
{
|
||||||
cflag_orphan('A');
|
cflag_orphan('A');
|
||||||
}
|
}
|
||||||
|
|
||||||
DECLARE_MODULE_AV1(chm_adminonly, _modinit, _moddeinit, NULL, NULL, adminonly_hfnlist, "$Revision$");
|
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
|
static void
|
||||||
h_can_join(hook_data_channel *data)
|
h_can_join(hook_data_channel *data)
|
||||||
{
|
{
|
||||||
struct Client *source_p = data->client;
|
struct Client *source_p = data->client;
|
||||||
struct Channel *chptr = data->chptr;
|
struct Channel *chptr = data->chptr;
|
||||||
|
|
||||||
if((chptr->mode.mode & mymode) && !IsAdmin(source_p)) {
|
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);
|
sendto_one_numeric(source_p, 519, "%s :Cannot join channel (+A) - you are not an IRC server administrator", chptr->chname);
|
||||||
data->approved = ERR_CUSTOM;
|
data->approved = ERR_CUSTOM;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
static void h_can_join(hook_data_channel *);
|
static void h_can_join(hook_data_channel *);
|
||||||
|
|
||||||
mapi_hfn_list_av1 operonly_hfnlist[] = {
|
mapi_hfn_list_av1 operonly_hfnlist[] = {
|
||||||
{ "can_join", (hookfn) h_can_join },
|
{ "can_join", (hookfn) h_can_join },
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
static unsigned int mymode;
|
static unsigned int mymode;
|
||||||
|
@ -26,18 +26,18 @@ static unsigned int mymode;
|
||||||
static int
|
static int
|
||||||
_modinit(void)
|
_modinit(void)
|
||||||
{
|
{
|
||||||
mymode = cflag_add('O', chm_staff);
|
mymode = cflag_add('O', chm_staff);
|
||||||
if (mymode == 0)
|
if (mymode == 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_moddeinit(void)
|
_moddeinit(void)
|
||||||
{
|
{
|
||||||
cflag_orphan('O');
|
cflag_orphan('O');
|
||||||
}
|
}
|
||||||
|
|
||||||
DECLARE_MODULE_AV1(chm_operonly, _modinit, _moddeinit, NULL, NULL, operonly_hfnlist, "$Revision$");
|
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
|
static void
|
||||||
h_can_join(hook_data_channel *data)
|
h_can_join(hook_data_channel *data)
|
||||||
{
|
{
|
||||||
struct Client *source_p = data->client;
|
struct Client *source_p = data->client;
|
||||||
struct Channel *chptr = data->chptr;
|
struct Channel *chptr = data->chptr;
|
||||||
|
|
||||||
if((chptr->mode.mode & mymode) && !IsOper(source_p)) {
|
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);
|
sendto_one_numeric(source_p, 520, "%s :Cannot join channel (+O) - you are not an IRC operator", chptr->chname);
|
||||||
data->approved = ERR_CUSTOM;
|
data->approved = ERR_CUSTOM;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,41 +12,41 @@
|
||||||
static int _modinit(void);
|
static int _modinit(void);
|
||||||
static void _moddeinit(void);
|
static void _moddeinit(void);
|
||||||
static void chm_operonly(struct Client *source_p, struct Channel *chptr,
|
static void chm_operonly(struct Client *source_p, struct Channel *chptr,
|
||||||
int alevel, int parc, int *parn,
|
int alevel, int parc, int *parn,
|
||||||
const char **parv, int *errors, int dir, char c, long mode_type);
|
const char **parv, int *errors, int dir, char c, long mode_type);
|
||||||
|
|
||||||
DECLARE_MODULE_AV1(chm_operonly_compat, _modinit, _moddeinit, NULL, NULL, NULL, "$Revision$");
|
DECLARE_MODULE_AV1(chm_operonly_compat, _modinit, _moddeinit, NULL, NULL, NULL, "$Revision$");
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_modinit(void)
|
_modinit(void)
|
||||||
{
|
{
|
||||||
chmode_table['O'].set_func = chm_operonly;
|
chmode_table['O'].set_func = chm_operonly;
|
||||||
chmode_table['O'].mode_type = 0;
|
chmode_table['O'].mode_type = 0;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_moddeinit(void)
|
_moddeinit(void)
|
||||||
{
|
{
|
||||||
chmode_table['O'].set_func = chm_nosuch;
|
chmode_table['O'].set_func = chm_nosuch;
|
||||||
chmode_table['O'].mode_type = 0;
|
chmode_table['O'].mode_type = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
chm_operonly(struct Client *source_p, struct Channel *chptr,
|
chm_operonly(struct Client *source_p, struct Channel *chptr,
|
||||||
int alevel, int parc, int *parn,
|
int alevel, int parc, int *parn,
|
||||||
const char **parv, int *errors, int dir, char c, long mode_type)
|
const char **parv, int *errors, int dir, char c, long mode_type)
|
||||||
{
|
{
|
||||||
int newparn = 0;
|
int newparn = 0;
|
||||||
const char *newparv[] = { "$o" };
|
const char *newparv[] = { "$o" };
|
||||||
|
|
||||||
if (MyClient(source_p)) {
|
if (MyClient(source_p)) {
|
||||||
chm_simple(source_p, chptr, alevel, parc, parn, parv,
|
chm_simple(source_p, chptr, alevel, parc, parn, parv,
|
||||||
errors, dir, 'i', MODE_INVITEONLY);
|
errors, dir, 'i', MODE_INVITEONLY);
|
||||||
chm_ban(source_p, chptr, alevel, 1, &newparn, newparv,
|
chm_ban(source_p, chptr, alevel, 1, &newparn, newparv,
|
||||||
errors, dir, 'I', CHFL_INVEX);
|
errors, dir, 'I', CHFL_INVEX);
|
||||||
} else
|
} else
|
||||||
chm_nosuch(source_p, chptr, alevel, parc, parn, parv,
|
chm_nosuch(source_p, chptr, alevel, parc, parn, parv,
|
||||||
errors, dir, c, mode_type);
|
errors, dir, c, mode_type);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,39 +13,39 @@
|
||||||
static int _modinit(void);
|
static int _modinit(void);
|
||||||
static void _moddeinit(void);
|
static void _moddeinit(void);
|
||||||
static void chm_quietunreg(struct Client *source_p, struct Channel *chptr,
|
static void chm_quietunreg(struct Client *source_p, struct Channel *chptr,
|
||||||
int alevel, int parc, int *parn,
|
int alevel, int parc, int *parn,
|
||||||
const char **parv, int *errors, int dir, char c, long mode_type);
|
const char **parv, int *errors, int dir, char c, long mode_type);
|
||||||
|
|
||||||
DECLARE_MODULE_AV1(chm_quietunreg_compat, _modinit, _moddeinit, NULL, NULL, NULL, "$Revision$");
|
DECLARE_MODULE_AV1(chm_quietunreg_compat, _modinit, _moddeinit, NULL, NULL, NULL, "$Revision$");
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_modinit(void)
|
_modinit(void)
|
||||||
{
|
{
|
||||||
chmode_table['R'].set_func = chm_quietunreg;
|
chmode_table['R'].set_func = chm_quietunreg;
|
||||||
chmode_table['R'].mode_type = 0;
|
chmode_table['R'].mode_type = 0;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_moddeinit(void)
|
_moddeinit(void)
|
||||||
{
|
{
|
||||||
chmode_table['R'].set_func = chm_nosuch;
|
chmode_table['R'].set_func = chm_nosuch;
|
||||||
chmode_table['R'].mode_type = 0;
|
chmode_table['R'].mode_type = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
chm_quietunreg(struct Client *source_p, struct Channel *chptr,
|
chm_quietunreg(struct Client *source_p, struct Channel *chptr,
|
||||||
int alevel, int parc, int *parn,
|
int alevel, int parc, int *parn,
|
||||||
const char **parv, int *errors, int dir, char c, long mode_type)
|
const char **parv, int *errors, int dir, char c, long mode_type)
|
||||||
{
|
{
|
||||||
int newparn = 0;
|
int newparn = 0;
|
||||||
const char *newparv[] = { "$~a" };
|
const char *newparv[] = { "$~a" };
|
||||||
|
|
||||||
if (MyClient(source_p))
|
if (MyClient(source_p))
|
||||||
chm_ban(source_p, chptr, alevel, 1, &newparn, newparv,
|
chm_ban(source_p, chptr, alevel, 1, &newparn, newparv,
|
||||||
errors, dir, 'q', CHFL_QUIET);
|
errors, dir, 'q', CHFL_QUIET);
|
||||||
else
|
else
|
||||||
chm_nosuch(source_p, chptr, alevel, parc, parn, parv,
|
chm_nosuch(source_p, chptr, alevel, parc, parn, parv,
|
||||||
errors, dir, c, mode_type);
|
errors, dir, c, mode_type);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
static void h_can_join(hook_data_channel *);
|
static void h_can_join(hook_data_channel *);
|
||||||
|
|
||||||
mapi_hfn_list_av1 sslonly_hfnlist[] = {
|
mapi_hfn_list_av1 sslonly_hfnlist[] = {
|
||||||
{ "can_join", (hookfn) h_can_join },
|
{ "can_join", (hookfn) h_can_join },
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
static unsigned int mymode;
|
static unsigned int mymode;
|
||||||
|
@ -22,18 +22,18 @@ static unsigned int mymode;
|
||||||
static int
|
static int
|
||||||
_modinit(void)
|
_modinit(void)
|
||||||
{
|
{
|
||||||
mymode = cflag_add('S', chm_simple);
|
mymode = cflag_add('S', chm_simple);
|
||||||
if (mymode == 0)
|
if (mymode == 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_moddeinit(void)
|
_moddeinit(void)
|
||||||
{
|
{
|
||||||
cflag_orphan('S');
|
cflag_orphan('S');
|
||||||
}
|
}
|
||||||
|
|
||||||
DECLARE_MODULE_AV1(chm_sslonly, _modinit, _moddeinit, NULL, NULL, sslonly_hfnlist, "$Revision$");
|
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
|
static void
|
||||||
h_can_join(hook_data_channel *data)
|
h_can_join(hook_data_channel *data)
|
||||||
{
|
{
|
||||||
struct Client *source_p = data->client;
|
struct Client *source_p = data->client;
|
||||||
struct Channel *chptr = data->chptr;
|
struct Channel *chptr = data->chptr;
|
||||||
|
|
||||||
if((chptr->mode.mode & mymode) && !IsSSLClient(source_p)) {
|
if((chptr->mode.mode & mymode) && !IsSSLClient(source_p)) {
|
||||||
sendto_one_notice(source_p, ":Only users using SSL can join this channel!");
|
sendto_one_notice(source_p, ":Only users using SSL could join this channel!");
|
||||||
data->approved = ERR_CUSTOM;
|
data->approved = ERR_CUSTOM;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,39 +12,39 @@
|
||||||
static int _modinit(void);
|
static int _modinit(void);
|
||||||
static void _moddeinit(void);
|
static void _moddeinit(void);
|
||||||
static void chm_sslonly(struct Client *source_p, struct Channel *chptr,
|
static void chm_sslonly(struct Client *source_p, struct Channel *chptr,
|
||||||
int alevel, int parc, int *parn,
|
int alevel, int parc, int *parn,
|
||||||
const char **parv, int *errors, int dir, char c, long mode_type);
|
const char **parv, int *errors, int dir, char c, long mode_type);
|
||||||
|
|
||||||
DECLARE_MODULE_AV1(chm_sslonly_compat, _modinit, _moddeinit, NULL, NULL, NULL, "$Revision$");
|
DECLARE_MODULE_AV1(chm_sslonly_compat, _modinit, _moddeinit, NULL, NULL, NULL, "$Revision$");
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_modinit(void)
|
_modinit(void)
|
||||||
{
|
{
|
||||||
chmode_table['S'].set_func = chm_sslonly;
|
chmode_table['S'].set_func = chm_sslonly;
|
||||||
chmode_table['S'].mode_type = 0;
|
chmode_table['S'].mode_type = 0;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_moddeinit(void)
|
_moddeinit(void)
|
||||||
{
|
{
|
||||||
chmode_table['S'].set_func = chm_nosuch;
|
chmode_table['S'].set_func = chm_nosuch;
|
||||||
chmode_table['S'].mode_type = 0;
|
chmode_table['S'].mode_type = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
chm_sslonly(struct Client *source_p, struct Channel *chptr,
|
chm_sslonly(struct Client *source_p, struct Channel *chptr,
|
||||||
int alevel, int parc, int *parn,
|
int alevel, int parc, int *parn,
|
||||||
const char **parv, int *errors, int dir, char c, long mode_type)
|
const char **parv, int *errors, int dir, char c, long mode_type)
|
||||||
{
|
{
|
||||||
int newparn = 0;
|
int newparn = 0;
|
||||||
const char *newparv[] = { "$~z" };
|
const char *newparv[] = { "$~z" };
|
||||||
|
|
||||||
if (MyClient(source_p))
|
if (MyClient(source_p))
|
||||||
chm_ban(source_p, chptr, alevel, 1, &newparn, newparv,
|
chm_ban(source_p, chptr, alevel, 1, &newparn, newparv,
|
||||||
errors, dir, 'b', CHFL_BAN);
|
errors, dir, 'b', CHFL_BAN);
|
||||||
else
|
else
|
||||||
chm_nosuch(source_p, chptr, alevel, parc, parn, parv,
|
chm_nosuch(source_p, chptr, alevel, parc, parn, parv,
|
||||||
errors, dir, c, mode_type);
|
errors, dir, c, mode_type);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,8 +20,8 @@
|
||||||
static void h_can_create_channel_authenticated(hook_data_client_approval *);
|
static void h_can_create_channel_authenticated(hook_data_client_approval *);
|
||||||
|
|
||||||
mapi_hfn_list_av1 restrict_hfnlist[] = {
|
mapi_hfn_list_av1 restrict_hfnlist[] = {
|
||||||
{ "can_create_channel", (hookfn) h_can_create_channel_authenticated },
|
{ "can_create_channel", (hookfn) h_can_create_channel_authenticated },
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
DECLARE_MODULE_AV1(createauthonly, NULL, NULL, NULL, NULL, restrict_hfnlist, "$Revision: 833 $");
|
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
|
static void
|
||||||
h_can_create_channel_authenticated(hook_data_client_approval *data)
|
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))
|
if (*source_p->user->suser == '\0' && !IsOper(source_p))
|
||||||
data->approved = ERR_NEEDREGGEDNICK;
|
data->approved = ERR_NEEDREGGEDNICK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,8 +20,8 @@
|
||||||
static void h_can_create_channel_authenticated(hook_data_client_approval *);
|
static void h_can_create_channel_authenticated(hook_data_client_approval *);
|
||||||
|
|
||||||
mapi_hfn_list_av1 restrict_hfnlist[] = {
|
mapi_hfn_list_av1 restrict_hfnlist[] = {
|
||||||
{ "can_create_channel", (hookfn) h_can_create_channel_authenticated },
|
{ "can_create_channel", (hookfn) h_can_create_channel_authenticated },
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
DECLARE_MODULE_AV1(createoperonly, NULL, NULL, NULL, NULL, restrict_hfnlist, "$Revision: 3476 $");
|
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
|
static void
|
||||||
h_can_create_channel_authenticated(hook_data_client_approval *data)
|
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)) {
|
if (!IsOper(source_p))
|
||||||
sendto_one_notice(source_p, ":*** Channel creation is restricted to network staff only.");
|
{
|
||||||
data->approved = ERR_NEEDREGGEDNICK;
|
sendto_one_notice(source_p, ":*** Channel creation is restricted to network staff only.");
|
||||||
}
|
data->approved = ERR_NEEDREGGEDNICK;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,25 +47,25 @@ static int moper_test(struct Client *client_p, struct Client *source_p, int parc
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct Message test_msgtab = {
|
struct Message test_msgtab = {
|
||||||
"TEST", /* the /COMMAND you want */
|
"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 */
|
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 */
|
MFLG_SLOW, /* ALWAYS SET TO MFLG_SLOW */
|
||||||
|
|
||||||
/* the functions to call for each handler. If not using the generic
|
/* 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
|
* 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,
|
* required number of parameters. NOTE: If you specify a min para of 2,
|
||||||
* then parv[1] must *also* be non-empty.
|
* then parv[1] must *also* be non-empty.
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
{munreg_test, 0}, /* function call for unregistered clients, 0 parms required */
|
{munreg_test, 0}, /* function call for unregistered clients, 0 parms required */
|
||||||
{mclient_test, 0}, /* function call for local 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 */
|
{mrclient_test, 0}, /* function call for remote clients, 0 parms required */
|
||||||
{mserver_test, 0}, /* function call for servers, 0 parms required */
|
{mserver_test, 0}, /* function call for servers, 0 parms required */
|
||||||
mg_ignore, /* function call for ENCAP, unused in this test */
|
mg_ignore, /* function call for ENCAP, unused in this test */
|
||||||
{moper_test, 0} /* function call for operators, 0 parms required */
|
{moper_test, 0} /* function call for operators, 0 parms required */
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
/*
|
/*
|
||||||
* There are also some macros for the above function calls and parameter counts.
|
* There are also some macros for the above function calls and parameter counts.
|
||||||
|
@ -94,8 +94,8 @@ mapi_clist_av1 test_clist[] = { &test_msgtab, NULL };
|
||||||
*/
|
*/
|
||||||
int doing_example_hook;
|
int doing_example_hook;
|
||||||
mapi_hlist_av1 test_hlist[] = {
|
mapi_hlist_av1 test_hlist[] = {
|
||||||
{ "doing_example_hook", &doing_example_hook, },
|
{ "doing_example_hook", &doing_example_hook, },
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
/* The mapi_hfn_list_av1 declares the hook functions which other modules can
|
/* 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);
|
static void show_example_hook(void *unused);
|
||||||
|
|
||||||
mapi_hfn_list_av1 test_hfnlist[] = {
|
mapi_hfn_list_av1 test_hfnlist[] = {
|
||||||
{ "doing_example_hook", (hookfn) show_example_hook },
|
{ "doing_example_hook", (hookfn) show_example_hook },
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Here we tell it what to do when the module is loaded */
|
/* Here we tell it what to do when the module is loaded */
|
||||||
static int
|
static int
|
||||||
modinit(void)
|
modinit(void)
|
||||||
{
|
{
|
||||||
/* Nothing to do for the example module. */
|
/* Nothing to do for the example module. */
|
||||||
/* The init function should return -1 on failure,
|
/* The init function should return -1 on failure,
|
||||||
which will cause the module to be unloaded,
|
which will cause the module to be unloaded,
|
||||||
otherwise 0 to indicate success. */
|
otherwise 0 to indicate success. */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* here we tell it what to do when the module is unloaded */
|
/* here we tell it what to do when the module is unloaded */
|
||||||
static void
|
static void
|
||||||
moddeinit(void)
|
moddeinit(void)
|
||||||
{
|
{
|
||||||
/* Again, nothing to do. */
|
/* Again, nothing to do. */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* DECLARE_MODULE_AV1() actually declare the MAPI header. */
|
/* DECLARE_MODULE_AV1() actually declare the MAPI header. */
|
||||||
DECLARE_MODULE_AV1(
|
DECLARE_MODULE_AV1(
|
||||||
/* The first argument is the name */
|
/* The first argument is the name */
|
||||||
example,
|
example,
|
||||||
/* The second argument is the function to call on load */
|
/* The second argument is the function to call on load */
|
||||||
modinit,
|
modinit,
|
||||||
/* And the function to call on unload */
|
/* And the function to call on unload */
|
||||||
moddeinit,
|
moddeinit,
|
||||||
/* Then the MAPI command list */
|
/* Then the MAPI command list */
|
||||||
test_clist,
|
test_clist,
|
||||||
/* Next the hook list, if we have one. */
|
/* Next the hook list, if we have one. */
|
||||||
test_hlist,
|
test_hlist,
|
||||||
/* Then the hook function list, if we have one */
|
/* Then the hook function list, if we have one */
|
||||||
test_hfnlist,
|
test_hfnlist,
|
||||||
/* And finally the version number of this module. */
|
/* And finally the version number of this module. */
|
||||||
"$Revision: 3161 $");
|
"$Revision: 3161 $");
|
||||||
|
|
||||||
/* Any of the above arguments can be NULL to indicate they aren't used. */
|
/* Any of the above arguments can be NULL to indicate they aren't used. */
|
||||||
|
|
||||||
|
@ -159,16 +159,19 @@ DECLARE_MODULE_AV1(
|
||||||
static int
|
static int
|
||||||
munreg_test(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
munreg_test(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
||||||
{
|
{
|
||||||
if(parc < 2) {
|
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 no parameters");
|
||||||
sendto_one_notice(source_p, ":You are unregistered and sent parameter: %s", parv[1]);
|
}
|
||||||
}
|
else
|
||||||
|
{
|
||||||
|
sendto_one_notice(source_p, ":You are unregistered and sent parameter: %s", parv[1]);
|
||||||
|
}
|
||||||
|
|
||||||
/* illustration of how to call a hook function */
|
/* illustration of how to call a hook function */
|
||||||
call_hook(doing_example_hook, NULL);
|
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
|
static int
|
||||||
mclient_test(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
mclient_test(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
||||||
{
|
{
|
||||||
if(parc < 2) {
|
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 sent no parameters");
|
||||||
sendto_one_notice(source_p, ":You are a normal user, and send parameters: %s", parv[1]);
|
}
|
||||||
}
|
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 */
|
/* illustration of how to call a hook function */
|
||||||
call_hook(doing_example_hook, NULL);
|
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
|
static int
|
||||||
mrclient_test(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
mrclient_test(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
||||||
{
|
{
|
||||||
if(parc < 2) {
|
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 no parameters");
|
||||||
sendto_one_notice(source_p, ":You are a remote client, and sent parameters: %s", parv[1]);
|
}
|
||||||
}
|
else
|
||||||
return 0;
|
{
|
||||||
|
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
|
static int
|
||||||
mserver_test(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
mserver_test(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
||||||
{
|
{
|
||||||
if(parc < 2) {
|
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 no parameters");
|
||||||
sendto_one_notice(source_p, ":You are a server, and sent parameters: %s", parv[1]);
|
}
|
||||||
}
|
else
|
||||||
return 0;
|
{
|
||||||
|
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
|
static int
|
||||||
moper_test(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
moper_test(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
||||||
{
|
{
|
||||||
if(parc < 2) {
|
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 no parameters");
|
||||||
sendto_one_notice(source_p, ":You are an operator, and sent parameters: %s", parv[1]);
|
}
|
||||||
}
|
else
|
||||||
return 0;
|
{
|
||||||
|
sendto_one_notice(source_p, ":You are an operator, and sent parameters: %s", parv[1]);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
show_example_hook(void *unused)
|
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 */
|
/* END OF EXAMPLE MODULE */
|
||||||
|
|
|
@ -18,25 +18,25 @@ DECLARE_MODULE_AV1(extb_account, _modinit, _moddeinit, NULL, NULL, NULL, "$Revis
|
||||||
static int
|
static int
|
||||||
_modinit(void)
|
_modinit(void)
|
||||||
{
|
{
|
||||||
extban_table['a'] = eb_account;
|
extban_table['a'] = eb_account;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_moddeinit(void)
|
_moddeinit(void)
|
||||||
{
|
{
|
||||||
extban_table['a'] = NULL;
|
extban_table['a'] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int eb_account(const char *data, struct Client *client_p,
|
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;
|
(void)chptr;
|
||||||
/* $a alone matches any logged in user */
|
/* $a alone matches any logged in user */
|
||||||
if (data == NULL)
|
if (data == NULL)
|
||||||
return EmptyString(client_p->user->suser) ? EXTBAN_NOMATCH : EXTBAN_MATCH;
|
return EmptyString(client_p->user->suser) ? EXTBAN_NOMATCH : EXTBAN_MATCH;
|
||||||
/* $a:MASK matches users logged in under matching account */
|
/* $a:MASK matches users logged in under matching account */
|
||||||
return match(data, client_p->user->suser) ? EXTBAN_MATCH : EXTBAN_NOMATCH;
|
return match(data, client_p->user->suser) ? EXTBAN_MATCH : EXTBAN_NOMATCH;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,46 +21,46 @@ DECLARE_MODULE_AV1(extb_canjoin, _modinit, _moddeinit, NULL, NULL, NULL, "$Revis
|
||||||
static int
|
static int
|
||||||
_modinit(void)
|
_modinit(void)
|
||||||
{
|
{
|
||||||
extban_table['j'] = eb_canjoin;
|
extban_table['j'] = eb_canjoin;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_moddeinit(void)
|
_moddeinit(void)
|
||||||
{
|
{
|
||||||
extban_table['j'] = NULL;
|
extban_table['j'] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int eb_canjoin(const char *data, struct Client *client_p,
|
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;
|
struct Channel *chptr2;
|
||||||
int ret;
|
int ret;
|
||||||
static int recurse = 0;
|
static int recurse = 0;
|
||||||
|
|
||||||
(void)mode_type;
|
(void)mode_type;
|
||||||
/* don't process a $j in a $j'ed list */
|
/* don't process a $j in a $j'ed list */
|
||||||
if (recurse)
|
if (recurse)
|
||||||
return EXTBAN_INVALID;
|
return EXTBAN_INVALID;
|
||||||
if (data == NULL)
|
if (data == NULL)
|
||||||
return EXTBAN_INVALID;
|
return EXTBAN_INVALID;
|
||||||
chptr2 = find_channel(data);
|
chptr2 = find_channel(data);
|
||||||
/* must exist, and no point doing this with the same channel */
|
/* must exist, and no point doing this with the same channel */
|
||||||
if (chptr2 == NULL || chptr2 == chptr)
|
if (chptr2 == NULL || chptr2 == chptr)
|
||||||
return EXTBAN_INVALID;
|
return EXTBAN_INVALID;
|
||||||
/* require consistent target */
|
/* require consistent target */
|
||||||
if (chptr->chname[0] == '#' && data[0] == '&')
|
if (chptr->chname[0] == '#' && data[0] == '&')
|
||||||
return EXTBAN_INVALID;
|
return EXTBAN_INVALID;
|
||||||
/* this allows getting some information about ban exceptions
|
/* this allows getting some information about ban exceptions
|
||||||
* but +s/+p doesn't seem the right criterion */
|
* but +s/+p doesn't seem the right criterion */
|
||||||
#if 0
|
#if 0
|
||||||
/* privacy! don't allow +s/+p channels to influence another channel */
|
/* privacy! don't allow +s/+p channels to influence another channel */
|
||||||
if (!PubChannel(chptr2))
|
if (!PubChannel(chptr2))
|
||||||
return EXTBAN_INVALID;
|
return EXTBAN_INVALID;
|
||||||
#endif
|
#endif
|
||||||
recurse = 1;
|
recurse = 1;
|
||||||
ret = is_banned(chptr2, client_p, NULL, NULL, NULL) == CHFL_BAN ? EXTBAN_MATCH : EXTBAN_NOMATCH;
|
ret = is_banned(chptr2, client_p, NULL, NULL, NULL) == CHFL_BAN ? EXTBAN_MATCH : EXTBAN_NOMATCH;
|
||||||
recurse = 0;
|
recurse = 0;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,34 +20,34 @@ DECLARE_MODULE_AV1(extb_channel, _modinit, _moddeinit, NULL, NULL, NULL, "$Revis
|
||||||
static int
|
static int
|
||||||
_modinit(void)
|
_modinit(void)
|
||||||
{
|
{
|
||||||
extban_table['c'] = eb_channel;
|
extban_table['c'] = eb_channel;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_moddeinit(void)
|
_moddeinit(void)
|
||||||
{
|
{
|
||||||
extban_table['c'] = NULL;
|
extban_table['c'] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int eb_channel(const char *data, struct Client *client_p,
|
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)chptr;
|
||||||
(void)mode_type;
|
(void)mode_type;
|
||||||
if (data == NULL)
|
if (data == NULL)
|
||||||
return EXTBAN_INVALID;
|
return EXTBAN_INVALID;
|
||||||
chptr2 = find_channel(data);
|
chptr2 = find_channel(data);
|
||||||
if (chptr2 == NULL)
|
if (chptr2 == NULL)
|
||||||
return EXTBAN_INVALID;
|
return EXTBAN_INVALID;
|
||||||
/* require consistent target */
|
/* require consistent target */
|
||||||
if (chptr->chname[0] == '#' && data[0] == '&')
|
if (chptr->chname[0] == '#' && data[0] == '&')
|
||||||
return EXTBAN_INVALID;
|
return EXTBAN_INVALID;
|
||||||
/* privacy! don't allow +s/+p channels to influence another channel */
|
/* privacy! don't allow +s/+p channels to influence another channel */
|
||||||
if (!PubChannel(chptr2))
|
if (!PubChannel(chptr2))
|
||||||
return EXTBAN_INVALID;
|
return EXTBAN_INVALID;
|
||||||
return IsMember(client_p, chptr2) ? EXTBAN_MATCH : EXTBAN_NOMATCH;
|
return IsMember(client_p, chptr2) ? EXTBAN_MATCH : EXTBAN_NOMATCH;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,39 +19,40 @@ DECLARE_MODULE_AV1(extb_extended, _modinit, _moddeinit, NULL, NULL, NULL, "$Revi
|
||||||
static int
|
static int
|
||||||
_modinit(void)
|
_modinit(void)
|
||||||
{
|
{
|
||||||
extban_table['x'] = eb_extended;
|
extban_table['x'] = eb_extended;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_moddeinit(void)
|
_moddeinit(void)
|
||||||
{
|
{
|
||||||
extban_table['x'] = NULL;
|
extban_table['x'] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int eb_extended(const char *data, struct Client *client_p,
|
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];
|
char buf[BUFSIZE];
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
(void)chptr;
|
(void)chptr;
|
||||||
|
|
||||||
if (data == NULL)
|
if (data == NULL)
|
||||||
return EXTBAN_INVALID;
|
return EXTBAN_INVALID;
|
||||||
|
|
||||||
snprintf(buf, BUFSIZE, "%s!%s@%s#%s",
|
rb_snprintf(buf, BUFSIZE, "%s!%s@%s#%s",
|
||||||
client_p->name, client_p->username, client_p->host, client_p->info);
|
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)) {
|
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);
|
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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,26 +18,26 @@ DECLARE_MODULE_AV1(extb_oper, _modinit, _moddeinit, NULL, NULL, NULL, "$Revision
|
||||||
static int
|
static int
|
||||||
_modinit(void)
|
_modinit(void)
|
||||||
{
|
{
|
||||||
extban_table['o'] = eb_oper;
|
extban_table['o'] = eb_oper;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_moddeinit(void)
|
_moddeinit(void)
|
||||||
{
|
{
|
||||||
extban_table['o'] = NULL;
|
extban_table['o'] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int eb_oper(const char *data, struct Client *client_p,
|
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)chptr;
|
||||||
(void)mode_type;
|
(void)mode_type;
|
||||||
/* perhaps use data somehow? (opernick/flags?) */
|
/* perhaps use data somehow? (opernick/flags?) */
|
||||||
/* so deny any bans with data for now */
|
/* so deny any bans with data for now */
|
||||||
if (data != NULL)
|
if (data != NULL)
|
||||||
return EXTBAN_INVALID;
|
return EXTBAN_INVALID;
|
||||||
return IsOper(client_p) ? EXTBAN_MATCH : EXTBAN_NOMATCH;
|
return IsOper(client_p) ? EXTBAN_MATCH : EXTBAN_NOMATCH;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,26 +18,26 @@ DECLARE_MODULE_AV1(extb_realname, _modinit, _moddeinit, NULL, NULL, NULL, "$Revi
|
||||||
static int
|
static int
|
||||||
_modinit(void)
|
_modinit(void)
|
||||||
{
|
{
|
||||||
extban_table['r'] = eb_realname;
|
extban_table['r'] = eb_realname;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_moddeinit(void)
|
_moddeinit(void)
|
||||||
{
|
{
|
||||||
extban_table['r'] = NULL;
|
extban_table['r'] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int eb_realname(const char *data, struct Client *client_p,
|
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;
|
(void)chptr;
|
||||||
/* This type is not safe for exceptions */
|
/* This type is not safe for exceptions */
|
||||||
if (mode_type == CHFL_EXCEPTION || mode_type == CHFL_INVEX)
|
if (mode_type == CHFL_EXCEPTION || mode_type == CHFL_INVEX)
|
||||||
return EXTBAN_INVALID;
|
return EXTBAN_INVALID;
|
||||||
if (data == NULL)
|
if (data == NULL)
|
||||||
return EXTBAN_INVALID;
|
return EXTBAN_INVALID;
|
||||||
return match(data, client_p->info) ? EXTBAN_MATCH : EXTBAN_NOMATCH;
|
return match(data, client_p->info) ? EXTBAN_MATCH : EXTBAN_NOMATCH;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,26 +18,26 @@ DECLARE_MODULE_AV1(extb_server, _modinit, _moddeinit, NULL, NULL, NULL, "$Revisi
|
||||||
static int
|
static int
|
||||||
_modinit(void)
|
_modinit(void)
|
||||||
{
|
{
|
||||||
extban_table['s'] = eb_server;
|
extban_table['s'] = eb_server;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_moddeinit(void)
|
_moddeinit(void)
|
||||||
{
|
{
|
||||||
extban_table['s'] = NULL;
|
extban_table['s'] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int eb_server(const char *data, struct Client *client_p,
|
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;
|
(void)chptr;
|
||||||
/* This type is not safe for exceptions */
|
/* This type is not safe for exceptions */
|
||||||
if (mode_type == CHFL_EXCEPTION || mode_type == CHFL_INVEX)
|
if (mode_type == CHFL_EXCEPTION || mode_type == CHFL_INVEX)
|
||||||
return EXTBAN_INVALID;
|
return EXTBAN_INVALID;
|
||||||
if (data == NULL)
|
if (data == NULL)
|
||||||
return EXTBAN_INVALID;
|
return EXTBAN_INVALID;
|
||||||
return match(data, me.name) ? EXTBAN_MATCH : EXTBAN_NOMATCH;
|
return match(data, me.name) ? EXTBAN_MATCH : EXTBAN_NOMATCH;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,24 +14,24 @@ DECLARE_MODULE_AV1(extb_ssl, _modinit, _moddeinit, NULL, NULL, NULL, "$Revision$
|
||||||
static int
|
static int
|
||||||
_modinit(void)
|
_modinit(void)
|
||||||
{
|
{
|
||||||
extban_table['z'] = eb_ssl;
|
extban_table['z'] = eb_ssl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_moddeinit(void)
|
_moddeinit(void)
|
||||||
{
|
{
|
||||||
extban_table['z'] = NULL;
|
extban_table['z'] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int eb_ssl(const char *data, struct Client *client_p,
|
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)chptr;
|
||||||
(void)mode_type;
|
(void)mode_type;
|
||||||
if (data != NULL)
|
if (data != NULL)
|
||||||
return EXTBAN_INVALID;
|
return EXTBAN_INVALID;
|
||||||
return IsSSLClient(client_p) ? EXTBAN_MATCH : EXTBAN_NOMATCH;
|
return IsSSLClient(client_p) ? EXTBAN_MATCH : EXTBAN_NOMATCH;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,8 +18,8 @@
|
||||||
static void h_noi_umode_changed(hook_data_umode_changed *);
|
static void h_noi_umode_changed(hook_data_umode_changed *);
|
||||||
|
|
||||||
mapi_hfn_list_av1 noi_hfnlist[] = {
|
mapi_hfn_list_av1 noi_hfnlist[] = {
|
||||||
{ "umode_changed", (hookfn) h_noi_umode_changed },
|
{ "umode_changed", (hookfn) h_noi_umode_changed },
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
DECLARE_MODULE_AV1(force_user_invis, NULL, NULL, NULL, NULL, noi_hfnlist, "1.0.0");
|
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
|
static void
|
||||||
h_noi_umode_changed(hook_data_umode_changed *hdata)
|
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)) {
|
if (MyClient(source_p) && !IsOper(source_p) && !IsInvisible(source_p)) {
|
||||||
SetInvisible(source_p);
|
SetInvisible(source_p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,25 +23,25 @@
|
||||||
#define HURT_EXIT_REASON "Hurt: Failed to identify to services"
|
#define HURT_EXIT_REASON "Hurt: Failed to identify to services"
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
HEAL_NICK = 0,
|
HEAL_NICK = 0,
|
||||||
HEAL_IP
|
HEAL_IP
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct _hurt_state {
|
typedef struct _hurt_state {
|
||||||
time_t start_time;
|
time_t start_time;
|
||||||
uint32_t n_hurts;
|
uint32_t n_hurts;
|
||||||
rb_dlink_list hurt_clients;
|
rb_dlink_list hurt_clients;
|
||||||
uint16_t cutoff;
|
uint16_t cutoff;
|
||||||
time_t default_expire;
|
time_t default_expire;
|
||||||
const char *exit_reason;
|
const char *exit_reason;
|
||||||
} hurt_state_t;
|
} hurt_state_t;
|
||||||
|
|
||||||
typedef struct _hurt {
|
typedef struct _hurt {
|
||||||
char *ip;
|
char *ip;
|
||||||
struct sockaddr *saddr;
|
struct sockaddr *saddr;
|
||||||
int saddr_bits;
|
int saddr_bits;
|
||||||
char *reason;
|
char *reason;
|
||||||
time_t expire;
|
time_t expire;
|
||||||
} hurt_t;
|
} hurt_t;
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
@ -82,45 +82,45 @@ rb_dlink_list hurt_confs = { NULL, NULL, 0 };
|
||||||
|
|
||||||
/* {{{ Messages */
|
/* {{{ Messages */
|
||||||
struct Message hurt_msgtab = {
|
struct Message hurt_msgtab = {
|
||||||
"HURT", 0, 0, 0, MFLG_SLOW, {
|
"HURT", 0, 0, 0, MFLG_SLOW, {
|
||||||
mg_ignore, mg_ignore, mg_ignore,
|
mg_ignore, mg_ignore, mg_ignore,
|
||||||
mg_ignore, {me_hurt, 0}, {mo_hurt, 3}
|
mg_ignore, {me_hurt, 0}, {mo_hurt, 3}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Message heal_msgtab = {
|
struct Message heal_msgtab = {
|
||||||
"HEAL", 0, 0, 0, MFLG_SLOW, {
|
"HEAL", 0, 0, 0, MFLG_SLOW, {
|
||||||
mg_ignore, mg_ignore, mg_ignore,
|
mg_ignore, mg_ignore, mg_ignore,
|
||||||
mg_ignore, {me_heal, 0}, {mo_heal, 2}
|
mg_ignore, {me_heal, 0}, {mo_heal, 2}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
/* {{{ Misc module stuff */
|
/* {{{ Misc module stuff */
|
||||||
mapi_hfn_list_av1 hurt_hfnlist[] = {
|
mapi_hfn_list_av1 hurt_hfnlist[] = {
|
||||||
{"client_exit", (hookfn) client_exit_hook},
|
{"client_exit", (hookfn) client_exit_hook},
|
||||||
{"new_local_user", (hookfn) new_local_user_hook},
|
{"new_local_user", (hookfn) new_local_user_hook},
|
||||||
{"doing_stats", (hookfn) doing_stats_hook},
|
{"doing_stats", (hookfn) doing_stats_hook},
|
||||||
{NULL, NULL},
|
{NULL, NULL},
|
||||||
};
|
};
|
||||||
|
|
||||||
mapi_clist_av1 hurt_clist[] = { &hurt_msgtab, &heal_msgtab, NULL };
|
mapi_clist_av1 hurt_clist[] = { &hurt_msgtab, &heal_msgtab, NULL };
|
||||||
|
|
||||||
DECLARE_MODULE_AV1(
|
DECLARE_MODULE_AV1(
|
||||||
hurt,
|
hurt,
|
||||||
modinit,
|
modinit,
|
||||||
modfini,
|
modfini,
|
||||||
hurt_clist,
|
hurt_clist,
|
||||||
NULL,
|
NULL,
|
||||||
hurt_hfnlist,
|
hurt_hfnlist,
|
||||||
"$Revision: 3161 $"
|
"$Revision: 3161 $"
|
||||||
);
|
);
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
hurt_state_t hurt_state = {
|
hurt_state_t hurt_state = {
|
||||||
.cutoff = HURT_CUTOFF,
|
.cutoff = HURT_CUTOFF,
|
||||||
.default_expire = HURT_DEFAULT_EXPIRE,
|
.default_expire = HURT_DEFAULT_EXPIRE,
|
||||||
.exit_reason = HURT_EXIT_REASON,
|
.exit_reason = HURT_EXIT_REASON,
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -135,14 +135,14 @@ struct ev_entry *hurt_check_ev = NULL;
|
||||||
static int
|
static int
|
||||||
modinit(void)
|
modinit(void)
|
||||||
{
|
{
|
||||||
/* set-up hurt_state. */
|
/* set-up hurt_state. */
|
||||||
hurt_state.start_time = rb_current_time();
|
hurt_state.start_time = rb_current_time();
|
||||||
|
|
||||||
/* add our event handlers. */
|
/* add our event handlers. */
|
||||||
hurt_expire_ev = rb_event_add("hurt_expire", hurt_expire_event, NULL, 60);
|
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);
|
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
|
static void
|
||||||
modfini(void)
|
modfini(void)
|
||||||
{
|
{
|
||||||
rb_dlink_node *ptr, *next_ptr;
|
rb_dlink_node *ptr, *next_ptr;
|
||||||
|
|
||||||
/* and delete our events. */
|
/* and delete our events. */
|
||||||
rb_event_delete(hurt_expire_ev);
|
rb_event_delete(hurt_expire_ev);
|
||||||
rb_event_delete(hurt_check_ev);
|
rb_event_delete(hurt_check_ev);
|
||||||
|
|
||||||
RB_DLINK_FOREACH_SAFE (ptr, next_ptr, hurt_state.hurt_clients.head) {
|
RB_DLINK_FOREACH_SAFE (ptr, next_ptr, hurt_state.hurt_clients.head)
|
||||||
rb_dlinkDestroy(ptr, &hurt_state.hurt_clients);
|
{
|
||||||
}
|
rb_dlinkDestroy(ptr, &hurt_state.hurt_clients);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
@ -176,72 +177,77 @@ modfini(void)
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
mo_hurt(struct Client *client_p, struct Client *source_p,
|
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;
|
const char *ip, *expire, *reason;
|
||||||
int expire_time;
|
int expire_time;
|
||||||
hurt_t *hurt;
|
hurt_t *hurt;
|
||||||
struct Client *target_p;
|
struct Client *target_p;
|
||||||
|
|
||||||
if (!IsOperK(source_p)) {
|
if (!IsOperK(source_p)) {
|
||||||
sendto_one(source_p, form_str(ERR_NOPRIVS), me.name,
|
sendto_one(source_p, form_str(ERR_NOPRIVS), me.name,
|
||||||
source_p->name, "kline");
|
source_p->name, "kline");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parc == 3)
|
if (parc == 3)
|
||||||
expire = NULL, ip = parv[1], reason = parv[2];
|
expire = NULL, ip = parv[1], reason = parv[2];
|
||||||
else
|
else
|
||||||
expire = parv[1], ip = parv[2], reason = parv[3];
|
expire = parv[1], ip = parv[2], reason = parv[3];
|
||||||
|
|
||||||
if (!expire)
|
if (!expire)
|
||||||
expire_time = HURT_DEFAULT_EXPIRE;
|
expire_time = HURT_DEFAULT_EXPIRE;
|
||||||
if (expire && (expire_time = valid_temp_time(expire)) < 1) {
|
if (expire && (expire_time = valid_temp_time(expire)) < 1) {
|
||||||
sendto_one_notice(source_p, ":Permanent HURTs are not supported");
|
sendto_one_notice(source_p, ":Permanent HURTs are not supported");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (EmptyString(reason)) {
|
if (EmptyString(reason)) {
|
||||||
sendto_one_notice(source_p, ":Empty HURT reasons are bad for business");
|
sendto_one_notice(source_p, ":Empty HURT reasons are bad for business");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Is this a client? */
|
/* Is this a client? */
|
||||||
if (strchr(ip, '.') == NULL && strchr(ip, ':') == NULL) {
|
if (strchr(ip, '.') == NULL && strchr(ip, ':') == NULL)
|
||||||
target_p = find_named_person(ip);
|
{
|
||||||
if (target_p == NULL) {
|
target_p = find_named_person(ip);
|
||||||
sendto_one_numeric(source_p, ERR_NOSUCHNICK,
|
if (target_p == NULL)
|
||||||
form_str(ERR_NOSUCHNICK), ip);
|
{
|
||||||
return 0;
|
sendto_one_numeric(source_p, ERR_NOSUCHNICK,
|
||||||
}
|
form_str(ERR_NOSUCHNICK), ip);
|
||||||
ip = target_p->orighost;
|
return 0;
|
||||||
} else {
|
}
|
||||||
if (!strncmp(ip, "*@", 2))
|
ip = target_p->orighost;
|
||||||
ip += 2;
|
}
|
||||||
if (strchr(ip, '!') || strchr(ip, '@')) {
|
else
|
||||||
sendto_one_notice(source_p, ":Invalid HURT mask [%s]",
|
{
|
||||||
ip);
|
if (!strncmp(ip, "*@", 2))
|
||||||
return 0;
|
ip += 2;
|
||||||
}
|
if (strchr(ip, '!') || strchr(ip, '@'))
|
||||||
}
|
{
|
||||||
|
sendto_one_notice(source_p, ":Invalid HURT mask [%s]",
|
||||||
|
ip);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (hurt_find(ip) != NULL) {
|
if (hurt_find(ip) != NULL) {
|
||||||
sendto_one(source_p, ":[%s] already HURT", ip);
|
sendto_one(source_p, ":[%s] already HURT", ip);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* okay, we've got this far, now it's time to add the the HURT locally
|
* 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.
|
* and propagate it to other servers on the network.
|
||||||
*/
|
*/
|
||||||
sendto_realops_snomask(SNO_GENERAL, L_ALL,
|
sendto_realops_snomask(SNO_GENERAL, L_ALL,
|
||||||
"%s added HURT on [%s] for %ld minutes with reason [%s]",
|
"%s added HURT on [%s] for %ld minutes with reason [%s]",
|
||||||
get_oper_name(source_p), ip, (long) expire_time / 60, reason);
|
get_oper_name(source_p), ip, (long) expire_time / 60, reason);
|
||||||
|
|
||||||
hurt = hurt_new(expire_time, ip, reason);
|
hurt = hurt_new(expire_time, ip, reason);
|
||||||
hurt_add(hurt);
|
hurt_add(hurt);
|
||||||
hurt_propagate(NULL, source_p, 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
|
static int
|
||||||
me_hurt(struct Client *client_p, struct Client *source_p,
|
me_hurt(struct Client *client_p, struct Client *source_p,
|
||||||
int parc, const char **parv)
|
int parc, const char **parv)
|
||||||
{
|
{
|
||||||
time_t expire_time;
|
time_t expire_time;
|
||||||
hurt_t *hurt;
|
hurt_t *hurt;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* right... if we don't get enough arguments, or if we get any invalid
|
* 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
|
* arguments, just ignore this request - shit happens, and it's not worth
|
||||||
* dropping a server over.
|
* dropping a server over.
|
||||||
*/
|
*/
|
||||||
if (parc < 4 || !IsPerson(source_p))
|
if (parc < 4 || !IsPerson(source_p))
|
||||||
return 0;
|
return 0;
|
||||||
if ((expire_time = atoi(parv[1])) < 1)
|
if ((expire_time = atoi(parv[1])) < 1)
|
||||||
return 0;
|
return 0;
|
||||||
if (hurt_find(parv[2]) != NULL)
|
if (hurt_find(parv[2]) != NULL)
|
||||||
return 0;
|
return 0;
|
||||||
if (EmptyString(parv[3]))
|
if (EmptyString(parv[3]))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
sendto_realops_snomask(SNO_GENERAL, L_ALL,
|
sendto_realops_snomask(SNO_GENERAL, L_ALL,
|
||||||
"%s added HURT on [%s] for %ld minutes with reason [%s]",
|
"%s added HURT on [%s] for %ld minutes with reason [%s]",
|
||||||
get_oper_name(source_p), parv[2], (long) expire_time / 60, parv[3]);
|
get_oper_name(source_p), parv[2], (long) expire_time / 60, parv[3]);
|
||||||
hurt = hurt_new(expire_time, parv[2], parv[3]);
|
hurt = hurt_new(expire_time, parv[2], parv[3]);
|
||||||
hurt_add(hurt);
|
hurt_add(hurt);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
@ -292,76 +298,88 @@ me_hurt(struct Client *client_p, struct Client *source_p,
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
mo_heal(struct Client *client_p, struct Client *source_p,
|
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)) {
|
if (!IsOperUnkline(source_p))
|
||||||
sendto_one(source_p, form_str(ERR_NOPRIVS),
|
{
|
||||||
me.name, source_p->name, "unkline");
|
sendto_one(source_p, form_str(ERR_NOPRIVS),
|
||||||
return 0;
|
me.name, source_p->name, "unkline");
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (nick_is_valid(parv[1])) {
|
if (nick_is_valid(parv[1]))
|
||||||
target_p = find_named_person(parv[1]);
|
{
|
||||||
if (target_p == NULL) {
|
target_p = find_named_person(parv[1]);
|
||||||
sendto_one_numeric(source_p, ERR_NOSUCHNICK,
|
if (target_p == NULL)
|
||||||
form_str(ERR_NOSUCHNICK), parv[1]);
|
{
|
||||||
return 0;
|
sendto_one_numeric(source_p, ERR_NOSUCHNICK,
|
||||||
}
|
form_str(ERR_NOSUCHNICK), parv[1]);
|
||||||
if (MyConnect(target_p))
|
return 0;
|
||||||
heal_nick(source_p, target_p);
|
}
|
||||||
else
|
if (MyConnect(target_p))
|
||||||
sendto_one(target_p, ":%s ENCAP %s HEAL %s",
|
heal_nick(source_p, target_p);
|
||||||
get_id(source_p, target_p),
|
else
|
||||||
target_p->servptr->name,
|
sendto_one(target_p, ":%s ENCAP %s HEAL %s",
|
||||||
get_id(target_p, target_p));
|
get_id(source_p, target_p),
|
||||||
} else if (strchr(parv[1], '.')) {
|
target_p->servptr->name,
|
||||||
if (hurt_find_exact(parv[1]) == NULL) {
|
get_id(target_p, target_p));
|
||||||
sendto_one_notice(source_p, ":Mask [%s] is not HURT", parv[1]);
|
}
|
||||||
return 0;
|
else if (strchr(parv[1], '.'))
|
||||||
}
|
{
|
||||||
hurt_remove(parv[1]);
|
if (hurt_find_exact(parv[1]) == NULL)
|
||||||
sendto_realops_snomask(SNO_GENERAL, L_ALL, "%s removed HURT on %s",
|
{
|
||||||
get_oper_name(source_p), parv[1]);
|
sendto_one_notice(source_p, ":Mask [%s] is not HURT", parv[1]);
|
||||||
sendto_server(NULL, NULL, NOCAPS, NOCAPS, ":%s ENCAP * HEAL %s",
|
return 0;
|
||||||
source_p->name, parv[1]);
|
}
|
||||||
} else {
|
hurt_remove(parv[1]);
|
||||||
sendto_one(source_p, ":[%s] is not a valid IP address/nick", parv[1]);
|
sendto_realops_snomask(SNO_GENERAL, L_ALL, "%s removed HURT on %s",
|
||||||
return 0;
|
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
|
static int
|
||||||
me_heal(struct Client *client_p, struct Client *source_p,
|
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...
|
/* as noted in me_hurt(), if we don't get sufficient arguments...
|
||||||
* *poof*, it's dropped...
|
* *poof*, it's dropped...
|
||||||
*/
|
*/
|
||||||
if (parc < 2)
|
if (parc < 2)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (nick_is_valid(parv[1])) {
|
if (nick_is_valid(parv[1]))
|
||||||
target_p = find_person(parv[1]);
|
{
|
||||||
if (target_p != NULL && MyConnect(target_p))
|
target_p = find_person(parv[1]);
|
||||||
heal_nick(source_p, target_p);
|
if (target_p != NULL && MyConnect(target_p))
|
||||||
} else if (strchr(parv[1], '.')) { /* host or mask to remove ban for */
|
heal_nick(source_p, target_p);
|
||||||
if (hurt_find_exact(parv[1]) == NULL)
|
}
|
||||||
return 0;
|
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]);
|
hurt_remove(parv[1]);
|
||||||
sendto_realops_snomask(SNO_GENERAL, L_ALL, "%s removed HURT on %s",
|
sendto_realops_snomask(SNO_GENERAL, L_ALL, "%s removed HURT on %s",
|
||||||
get_oper_name(source_p), parv[1]);
|
get_oper_name(source_p), parv[1]);
|
||||||
} else
|
}
|
||||||
return 0;
|
else
|
||||||
|
return 0;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -372,18 +390,20 @@ me_heal(struct Client *client_p, struct Client *source_p,
|
||||||
static void
|
static void
|
||||||
hurt_check_event(void *arg)
|
hurt_check_event(void *arg)
|
||||||
{
|
{
|
||||||
rb_dlink_node *ptr, *next_ptr;
|
rb_dlink_node *ptr, *next_ptr;
|
||||||
struct Client *client_p;
|
struct Client *client_p;
|
||||||
|
|
||||||
RB_DLINK_FOREACH_SAFE (ptr, next_ptr, hurt_state.hurt_clients.head) {
|
RB_DLINK_FOREACH_SAFE (ptr, next_ptr, hurt_state.hurt_clients.head) {
|
||||||
client_p = ptr->data;
|
client_p = ptr->data;
|
||||||
if (!EmptyString(client_p->user->suser)) {
|
if (!EmptyString(client_p->user->suser))
|
||||||
rb_dlinkDestroy(ptr, &hurt_state.hurt_clients);
|
{
|
||||||
sendto_one_notice(client_p, ":HURT restriction removed for this session");
|
rb_dlinkDestroy(ptr, &hurt_state.hurt_clients);
|
||||||
client_p->localClient->target_last = rb_current_time(); /* don't ask --nenolod */
|
sendto_one_notice(client_p, ":HURT restriction removed for this session");
|
||||||
} else if (client_p->localClient->receiveM > hurt_state.cutoff)
|
client_p->localClient->target_last = rb_current_time(); /* don't ask --nenolod */
|
||||||
exit_client(NULL, client_p, &me, hurt_state.exit_reason);
|
}
|
||||||
}
|
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
|
static void
|
||||||
hurt_expire_event(void *unused)
|
hurt_expire_event(void *unused)
|
||||||
{
|
{
|
||||||
rb_dlink_node *ptr, *next_ptr;
|
rb_dlink_node *ptr, *next_ptr;
|
||||||
hurt_t *hurt;
|
hurt_t *hurt;
|
||||||
|
|
||||||
RB_DLINK_FOREACH_SAFE (ptr, next_ptr, hurt_confs.head) {
|
RB_DLINK_FOREACH_SAFE (ptr, next_ptr, hurt_confs.head)
|
||||||
hurt = (hurt_t *) ptr->data;
|
{
|
||||||
|
hurt = (hurt_t *) ptr->data;
|
||||||
|
|
||||||
if (hurt->expire <= rb_current_time()) {
|
if (hurt->expire <= rb_current_time())
|
||||||
rb_dlinkFindDestroy(hurt, &hurt_confs);
|
{
|
||||||
hurt_destroy(hurt);
|
rb_dlinkFindDestroy(hurt, &hurt_confs);
|
||||||
}
|
hurt_destroy(hurt);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
@ -413,10 +435,10 @@ hurt_expire_event(void *unused)
|
||||||
static void
|
static void
|
||||||
client_exit_hook(hook_data_client_exit *data)
|
client_exit_hook(hook_data_client_exit *data)
|
||||||
{
|
{
|
||||||
s_assert(data != NULL);
|
s_assert(data != NULL);
|
||||||
s_assert(data->target != 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
|
static void
|
||||||
new_local_user_hook(struct Client *source_p)
|
new_local_user_hook(struct Client *source_p)
|
||||||
{
|
{
|
||||||
if (IsAnyDead(source_p) || !EmptyString(source_p->user->suser) ||
|
if (IsAnyDead(source_p) || !EmptyString(source_p->user->suser) ||
|
||||||
IsExemptKline(source_p))
|
IsExemptKline(source_p))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (hurt_find(source_p->sockhost) || hurt_find(source_p->orighost)) {
|
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);
|
source_p->localClient->target_last = rb_current_time() + 600; /* don't ask --nenolod */
|
||||||
rb_dlinkAddAlloc(source_p, &hurt_state.hurt_clients);
|
SetTGChange(source_p);
|
||||||
sendto_one_notice(source_p, ":You are hurt. Please identify to services immediately, or use /stats p for assistance.");
|
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
|
static void
|
||||||
doing_stats_hook(hook_data_int *hdata)
|
doing_stats_hook(hook_data_int *hdata)
|
||||||
{
|
{
|
||||||
rb_dlink_node *ptr;
|
rb_dlink_node *ptr;
|
||||||
hurt_t *hurt;
|
hurt_t *hurt;
|
||||||
struct Client *source_p;
|
struct Client *source_p;
|
||||||
|
|
||||||
s_assert(hdata);
|
s_assert(hdata);
|
||||||
s_assert(hdata->client);
|
s_assert(hdata->client);
|
||||||
|
|
||||||
source_p = hdata->client;
|
source_p = hdata->client;
|
||||||
if(hdata->arg2 != (int) 's')
|
if(hdata->arg2 != (int) 's')
|
||||||
return;
|
return;
|
||||||
if((ConfigFileEntry.stats_k_oper_only == 2) && !IsOper(source_p))
|
if((ConfigFileEntry.stats_k_oper_only == 2) && !IsOper(source_p))
|
||||||
return;
|
return;
|
||||||
if ((ConfigFileEntry.stats_k_oper_only == 1) && !IsOper(source_p)) {
|
if ((ConfigFileEntry.stats_k_oper_only == 1) && !IsOper(source_p))
|
||||||
hurt = hurt_find(source_p->sockhost);
|
{
|
||||||
if (hurt != NULL) {
|
hurt = hurt_find(source_p->sockhost);
|
||||||
sendto_one_numeric(source_p, RPL_STATSKLINE,
|
if (hurt != NULL)
|
||||||
form_str(RPL_STATSKLINE), 's',
|
{
|
||||||
"*", hurt->ip, hurt->reason, "", "");
|
sendto_one_numeric(source_p, RPL_STATSKLINE,
|
||||||
return;
|
form_str(RPL_STATSKLINE), 's',
|
||||||
}
|
"*", hurt->ip, hurt->reason, "", "");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
hurt = hurt_find(source_p->orighost);
|
hurt = hurt_find(source_p->orighost);
|
||||||
if (hurt != NULL) {
|
if (hurt != NULL)
|
||||||
sendto_one_numeric(source_p, RPL_STATSKLINE,
|
{
|
||||||
form_str(RPL_STATSKLINE), 's',
|
sendto_one_numeric(source_p, RPL_STATSKLINE,
|
||||||
"*", hurt->ip, hurt->reason, "", "");
|
form_str(RPL_STATSKLINE), 's',
|
||||||
return;
|
"*", hurt->ip, hurt->reason, "", "");
|
||||||
}
|
return;
|
||||||
return;
|
}
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
RB_DLINK_FOREACH(ptr, hurt_confs.head) {
|
RB_DLINK_FOREACH(ptr, hurt_confs.head)
|
||||||
hurt = (hurt_t *) ptr->data;
|
{
|
||||||
sendto_one_numeric(source_p, RPL_STATSKLINE,
|
hurt = (hurt_t *) ptr->data;
|
||||||
form_str(RPL_STATSKLINE), 's',
|
sendto_one_numeric(source_p, RPL_STATSKLINE,
|
||||||
"*", hurt->ip, hurt->reason, "", "");
|
form_str(RPL_STATSKLINE), 's',
|
||||||
}
|
"*", hurt->ip, hurt->reason, "", "");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
@ -491,18 +518,18 @@ doing_stats_hook(hook_data_int *hdata)
|
||||||
static void
|
static void
|
||||||
hurt_propagate(struct Client *client_p, struct Client *source_p, hurt_t *hurt)
|
hurt_propagate(struct Client *client_p, struct Client *source_p, hurt_t *hurt)
|
||||||
{
|
{
|
||||||
if (client_p)
|
if (client_p)
|
||||||
sendto_one(client_p,
|
sendto_one(client_p,
|
||||||
":%s ENCAP %s HURT %ld %s :%s",
|
":%s ENCAP %s HURT %ld %s :%s",
|
||||||
source_p->name, client_p->name,
|
source_p->name, client_p->name,
|
||||||
(long)(hurt->expire - rb_current_time()),
|
(long)(hurt->expire - rb_current_time()),
|
||||||
hurt->ip, hurt->reason);
|
hurt->ip, hurt->reason);
|
||||||
else
|
else
|
||||||
sendto_server(&me, NULL, NOCAPS, NOCAPS,
|
sendto_server(&me, NULL, NOCAPS, NOCAPS,
|
||||||
":%s ENCAP * HURT %ld %s :%s",
|
":%s ENCAP * HURT %ld %s :%s",
|
||||||
source_p->name,
|
source_p->name,
|
||||||
(long)(hurt->expire - rb_current_time()),
|
(long)(hurt->expire - rb_current_time()),
|
||||||
hurt->ip, hurt->reason);
|
hurt->ip, hurt->reason);
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
@ -510,15 +537,15 @@ hurt_propagate(struct Client *client_p, struct Client *source_p, hurt_t *hurt)
|
||||||
static hurt_t *
|
static hurt_t *
|
||||||
hurt_new(time_t expire, const char *ip, const char *reason)
|
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->ip = rb_strdup(ip);
|
||||||
hurt->reason = rb_strdup(reason);
|
hurt->reason = rb_strdup(reason);
|
||||||
hurt->expire = rb_current_time() + expire;
|
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
|
static void
|
||||||
hurt_destroy(void *hurt)
|
hurt_destroy(void *hurt)
|
||||||
{
|
{
|
||||||
hurt_t *h;
|
hurt_t *h;
|
||||||
|
|
||||||
if (!hurt)
|
if (!hurt)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
h = (hurt_t *) hurt;
|
h = (hurt_t *) hurt;
|
||||||
rb_free(h->ip);
|
rb_free(h->ip);
|
||||||
rb_free(h->reason);
|
rb_free(h->reason);
|
||||||
rb_free(h);
|
rb_free(h);
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
hurt_add(hurt_t *hurt)
|
hurt_add(hurt_t *hurt)
|
||||||
{
|
{
|
||||||
rb_dlinkAddAlloc(hurt, &hurt_confs);
|
rb_dlinkAddAlloc(hurt, &hurt_confs);
|
||||||
}
|
}
|
||||||
|
|
||||||
static hurt_t *
|
static hurt_t *
|
||||||
hurt_find_exact(const char *ip)
|
hurt_find_exact(const char *ip)
|
||||||
{
|
{
|
||||||
rb_dlink_node *ptr;
|
rb_dlink_node *ptr;
|
||||||
hurt_t *hurt;
|
hurt_t *hurt;
|
||||||
|
|
||||||
RB_DLINK_FOREACH(ptr, hurt_confs.head) {
|
RB_DLINK_FOREACH(ptr, hurt_confs.head)
|
||||||
hurt = (hurt_t *) ptr->data;
|
{
|
||||||
|
hurt = (hurt_t *) ptr->data;
|
||||||
|
|
||||||
if (!strcasecmp(ip, hurt->ip))
|
if (!strcasecmp(ip, hurt->ip))
|
||||||
return hurt;
|
return hurt;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static hurt_t *
|
static hurt_t *
|
||||||
hurt_find(const char *ip)
|
hurt_find(const char *ip)
|
||||||
{
|
{
|
||||||
rb_dlink_node *ptr;
|
rb_dlink_node *ptr;
|
||||||
hurt_t *hurt;
|
hurt_t *hurt;
|
||||||
|
|
||||||
RB_DLINK_FOREACH(ptr, hurt_confs.head) {
|
RB_DLINK_FOREACH(ptr, hurt_confs.head)
|
||||||
hurt = (hurt_t *) ptr->data;
|
{
|
||||||
|
hurt = (hurt_t *) ptr->data;
|
||||||
|
|
||||||
if (match(hurt->ip, ip))
|
if (match(hurt->ip, ip))
|
||||||
return hurt;
|
return hurt;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
hurt_remove(const char *ip)
|
hurt_remove(const char *ip)
|
||||||
{
|
{
|
||||||
hurt_t *hurt = hurt_find_exact(ip);
|
hurt_t *hurt = hurt_find_exact(ip);
|
||||||
|
|
||||||
rb_dlinkFindDestroy(hurt, &hurt_confs);
|
rb_dlinkFindDestroy(hurt, &hurt_confs);
|
||||||
hurt_destroy(hurt);
|
hurt_destroy(hurt);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* {{{ static int heal_nick() */
|
/* {{{ static int heal_nick() */
|
||||||
static int
|
static int
|
||||||
heal_nick(struct Client *source_p, struct Client *target_p)
|
heal_nick(struct Client *source_p, struct Client *target_p)
|
||||||
{
|
{
|
||||||
if (rb_dlinkFindDestroy(target_p, &hurt_state.hurt_clients)) {
|
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_realops_snomask(SNO_GENERAL, L_ALL, "%s used HEAL on %s",
|
||||||
sendto_one_notice(target_p, ":HURT restriction temporarily removed by operator");
|
get_oper_name(source_p), get_client_name(target_p, HIDE_IP));
|
||||||
sendto_one_notice(source_p, ":HURT restriction on %s temporarily removed", target_p->name);
|
sendto_one_notice(target_p, ":HURT restriction temporarily removed by operator");
|
||||||
target_p->localClient->target_last = rb_current_time(); /* don't ask --nenolod */
|
sendto_one_notice(source_p, ":HURT restriction on %s temporarily removed", target_p->name);
|
||||||
return 1;
|
target_p->localClient->target_last = rb_current_time(); /* don't ask --nenolod */
|
||||||
} else {
|
return 1;
|
||||||
sendto_one_notice(source_p, ":%s was not hurt", target_p->name);
|
}
|
||||||
return 0;
|
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
|
static int
|
||||||
nick_is_valid(const char *nick)
|
nick_is_valid(const char *nick)
|
||||||
{
|
{
|
||||||
const char *s = nick;
|
const char *s = nick;
|
||||||
|
|
||||||
for (; *s != '\0'; s++) {
|
for (; *s != '\0'; s++) {
|
||||||
if (!IsNickChar(*s))
|
if (!IsNickChar(*s))
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
|
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -20,191 +20,206 @@
|
||||||
static int
|
static int
|
||||||
_modinit(void)
|
_modinit(void)
|
||||||
{
|
{
|
||||||
/* add the usermode to the available slot */
|
/* add the usermode to the available slot */
|
||||||
user_modes['x'] = find_umode_slot();
|
user_modes['x'] = find_umode_slot();
|
||||||
construct_umodebuf();
|
construct_umodebuf();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_moddeinit(void)
|
_moddeinit(void)
|
||||||
{
|
{
|
||||||
/* disable the umode and remove it from the available list */
|
/* disable the umode and remove it from the available list */
|
||||||
user_modes['x'] = 0;
|
user_modes['x'] = 0;
|
||||||
construct_umodebuf();
|
construct_umodebuf();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void check_umode_change(void *data);
|
static void check_umode_change(void *data);
|
||||||
static void check_new_user(void *data);
|
static void check_new_user(void *data);
|
||||||
mapi_hfn_list_av1 ip_cloaking_hfnlist[] = {
|
mapi_hfn_list_av1 ip_cloaking_hfnlist[] = {
|
||||||
{ "umode_changed", (hookfn) check_umode_change },
|
{ "umode_changed", (hookfn) check_umode_change },
|
||||||
{ "new_local_user", (hookfn) check_new_user },
|
{ "new_local_user", (hookfn) check_new_user },
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
DECLARE_MODULE_AV1(ip_cloaking, _modinit, _moddeinit, NULL, NULL,
|
DECLARE_MODULE_AV1(ip_cloaking, _modinit, _moddeinit, NULL, NULL,
|
||||||
ip_cloaking_hfnlist, "$Revision: 3526 $");
|
ip_cloaking_hfnlist, "$Revision: 3526 $");
|
||||||
|
|
||||||
static void
|
static void
|
||||||
distribute_hostchange(struct Client *client_p, char *newhost)
|
distribute_hostchange(struct Client *client_p, char *newhost)
|
||||||
{
|
{
|
||||||
if (newhost != client_p->orighost)
|
if (newhost != client_p->orighost)
|
||||||
sendto_one_numeric(client_p, RPL_HOSTHIDDEN, "%s :is now your hidden host",
|
sendto_one_numeric(client_p, RPL_HOSTHIDDEN, "%s :is now your hidden host",
|
||||||
newhost);
|
newhost);
|
||||||
else
|
else
|
||||||
sendto_one_numeric(client_p, RPL_HOSTHIDDEN, "%s :hostname reset",
|
sendto_one_numeric(client_p, RPL_HOSTHIDDEN, "%s :hostname reset",
|
||||||
newhost);
|
newhost);
|
||||||
|
|
||||||
sendto_server(NULL, NULL,
|
sendto_server(NULL, NULL,
|
||||||
CAP_EUID | CAP_TS6, NOCAPS, ":%s CHGHOST %s :%s",
|
CAP_EUID | CAP_TS6, NOCAPS, ":%s CHGHOST %s :%s",
|
||||||
use_id(&me), use_id(client_p), newhost);
|
use_id(&me), use_id(client_p), newhost);
|
||||||
sendto_server(NULL, NULL,
|
sendto_server(NULL, NULL,
|
||||||
CAP_TS6, CAP_EUID, ":%s ENCAP * CHGHOST %s :%s",
|
CAP_TS6, CAP_EUID, ":%s ENCAP * CHGHOST %s :%s",
|
||||||
use_id(&me), use_id(client_p), newhost);
|
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)
|
if (newhost != client_p->orighost)
|
||||||
SetDynSpoof(client_p);
|
SetDynSpoof(client_p);
|
||||||
else
|
else
|
||||||
ClearDynSpoof(client_p);
|
ClearDynSpoof(client_p);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
do_host_cloak_ip(const char *inbuf, char *outbuf)
|
do_host_cloak_ip(const char *inbuf, char *outbuf)
|
||||||
{
|
{
|
||||||
/* None of the characters in this table can be valid in an IP */
|
/* None of the characters in this table can be valid in an IP */
|
||||||
char chartable[] = "ghijklmnopqrstuvwxyz";
|
char chartable[] = "ghijklmnopqrstuvwxyz";
|
||||||
char *tptr;
|
char *tptr;
|
||||||
uint32_t accum = fnv_hash((const unsigned char*) inbuf, 32);
|
uint32_t accum = fnv_hash((const unsigned char*) inbuf, 32);
|
||||||
int sepcount = 0;
|
int sepcount = 0;
|
||||||
int totalcount = 0;
|
int totalcount = 0;
|
||||||
int ipv6 = 0;
|
int ipv6 = 0;
|
||||||
|
|
||||||
rb_strlcpy(outbuf, inbuf, HOSTLEN + 1);
|
rb_strlcpy(outbuf, inbuf, HOSTLEN + 1);
|
||||||
|
|
||||||
if (strchr(outbuf, ':')) {
|
if (strchr(outbuf, ':'))
|
||||||
ipv6 = 1;
|
{
|
||||||
|
ipv6 = 1;
|
||||||
|
|
||||||
/* Damn you IPv6...
|
/* Damn you IPv6...
|
||||||
* We count the number of colons so we can calculate how much
|
* We count the number of colons so we can calculate how much
|
||||||
* of the host to cloak. This is because some hostmasks may not
|
* of the host to cloak. This is because some hostmasks may not
|
||||||
* have as many octets as we'd like.
|
* have as many octets as we'd like.
|
||||||
*
|
*
|
||||||
* We have to do this ahead of time because doing this during
|
* We have to do this ahead of time because doing this during
|
||||||
* the actual cloaking would get ugly
|
* the actual cloaking would get ugly
|
||||||
*/
|
*/
|
||||||
for (tptr = outbuf; *tptr != '\0'; tptr++)
|
for (tptr = outbuf; *tptr != '\0'; tptr++)
|
||||||
if (*tptr == ':')
|
if (*tptr == ':')
|
||||||
totalcount++;
|
totalcount++;
|
||||||
} else if (!strchr(outbuf, '.'))
|
}
|
||||||
return;
|
else if (!strchr(outbuf, '.'))
|
||||||
|
return;
|
||||||
|
|
||||||
for (tptr = outbuf; *tptr != '\0'; tptr++) {
|
for (tptr = outbuf; *tptr != '\0'; tptr++)
|
||||||
if (*tptr == ':' || *tptr == '.') {
|
{
|
||||||
sepcount++;
|
if (*tptr == ':' || *tptr == '.')
|
||||||
continue;
|
{
|
||||||
}
|
sepcount++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (ipv6 && sepcount < totalcount / 2)
|
if (ipv6 && sepcount < totalcount / 2)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!ipv6 && sepcount < 2)
|
if (!ipv6 && sepcount < 2)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
*tptr = chartable[(*tptr + accum) % 20];
|
*tptr = chartable[(*tptr + accum) % 20];
|
||||||
accum = (accum << 1) | (accum >> 31);
|
accum = (accum << 1) | (accum >> 31);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
do_host_cloak_host(const char *inbuf, char *outbuf)
|
do_host_cloak_host(const char *inbuf, char *outbuf)
|
||||||
{
|
{
|
||||||
char b26_alphabet[] = "abcdefghijklmnopqrstuvwxyz";
|
char b26_alphabet[] = "abcdefghijklmnopqrstuvwxyz";
|
||||||
char *tptr;
|
char *tptr;
|
||||||
uint32_t accum = fnv_hash((const unsigned char*) inbuf, 32);
|
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
|
/* pass 1: scramble first section of hostname using base26
|
||||||
* alphabet toasted against the FNV hash of the string.
|
* alphabet toasted against the FNV hash of the string.
|
||||||
*
|
*
|
||||||
* numbers are not changed at this time, only letters.
|
* numbers are not changed at this time, only letters.
|
||||||
*/
|
*/
|
||||||
for (tptr = outbuf; *tptr != '\0'; tptr++) {
|
for (tptr = outbuf; *tptr != '\0'; tptr++)
|
||||||
if (*tptr == '.')
|
{
|
||||||
break;
|
if (*tptr == '.')
|
||||||
|
break;
|
||||||
|
|
||||||
if (isdigit(*tptr) || *tptr == '-')
|
if (isdigit(*tptr) || *tptr == '-')
|
||||||
continue;
|
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 */
|
/* Rotate one bit to avoid all digits being turned odd or even */
|
||||||
accum = (accum << 1) | (accum >> 31);
|
accum = (accum << 1) | (accum >> 31);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* pass 2: scramble each number in the address */
|
/* pass 2: scramble each number in the address */
|
||||||
for (tptr = outbuf; *tptr != '\0'; tptr++) {
|
for (tptr = outbuf; *tptr != '\0'; tptr++)
|
||||||
if (isdigit(*tptr))
|
{
|
||||||
*tptr = '0' + (*tptr + accum) % 10;
|
if (isdigit(*tptr))
|
||||||
|
*tptr = '0' + (*tptr + accum) % 10;
|
||||||
|
|
||||||
accum = (accum << 1) | (accum >> 31);
|
accum = (accum << 1) | (accum >> 31);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
check_umode_change(void *vdata)
|
check_umode_change(void *vdata)
|
||||||
{
|
{
|
||||||
hook_data_umode_changed *data = (hook_data_umode_changed *)vdata;
|
hook_data_umode_changed *data = (hook_data_umode_changed *)vdata;
|
||||||
struct Client *source_p = data->client;
|
struct Client *source_p = data->client;
|
||||||
|
|
||||||
if (!MyClient(source_p))
|
if (!MyClient(source_p))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* didn't change +h umode, we don't need to do anything */
|
/* didn't change +h umode, we don't need to do anything */
|
||||||
if (!((data->oldumodes ^ source_p->umodes) & user_modes['x']))
|
if (!((data->oldumodes ^ source_p->umodes) & user_modes['x']))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (source_p->umodes & user_modes['x']) {
|
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'];
|
if (IsIPSpoof(source_p) || source_p->localClient->mangledhost == NULL || (IsDynSpoof(source_p) && strcmp(source_p->host, source_p->localClient->mangledhost)))
|
||||||
return;
|
{
|
||||||
}
|
source_p->umodes &= ~user_modes['x'];
|
||||||
if (strcmp(source_p->host, source_p->localClient->mangledhost)) {
|
return;
|
||||||
distribute_hostchange(source_p, source_p->localClient->mangledhost);
|
}
|
||||||
} else /* not really nice, but we need to send this numeric here */
|
if (strcmp(source_p->host, source_p->localClient->mangledhost))
|
||||||
sendto_one_numeric(source_p, RPL_HOSTHIDDEN, "%s :is now your hidden host",
|
{
|
||||||
source_p->host);
|
distribute_hostchange(source_p, source_p->localClient->mangledhost);
|
||||||
} else if (!(source_p->umodes & user_modes['x'])) {
|
}
|
||||||
if (source_p->localClient->mangledhost != NULL &&
|
else /* not really nice, but we need to send this numeric here */
|
||||||
!strcmp(source_p->host, source_p->localClient->mangledhost)) {
|
sendto_one_numeric(source_p, RPL_HOSTHIDDEN, "%s :is now your hidden host",
|
||||||
distribute_hostchange(source_p, source_p->orighost);
|
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
|
static void
|
||||||
check_new_user(void *vdata)
|
check_new_user(void *vdata)
|
||||||
{
|
{
|
||||||
struct Client *source_p = (void *)vdata;
|
struct Client *source_p = (void *)vdata;
|
||||||
|
|
||||||
if (IsIPSpoof(source_p)) {
|
if (IsIPSpoof(source_p))
|
||||||
source_p->umodes &= ~user_modes['x'];
|
{
|
||||||
return;
|
source_p->umodes &= ~user_modes['x'];
|
||||||
}
|
return;
|
||||||
source_p->localClient->mangledhost = rb_malloc(HOSTLEN + 1);
|
}
|
||||||
if (!irccmp(source_p->orighost, source_p->sockhost))
|
source_p->localClient->mangledhost = rb_malloc(HOSTLEN + 1);
|
||||||
do_host_cloak_ip(source_p->orighost, source_p->localClient->mangledhost);
|
if (!irccmp(source_p->orighost, source_p->sockhost))
|
||||||
else
|
do_host_cloak_ip(source_p->orighost, source_p->localClient->mangledhost);
|
||||||
do_host_cloak_host(source_p->orighost, source_p->localClient->mangledhost);
|
else
|
||||||
if (IsDynSpoof(source_p))
|
do_host_cloak_host(source_p->orighost, source_p->localClient->mangledhost);
|
||||||
source_p->umodes &= ~user_modes['x'];
|
if (IsDynSpoof(source_p))
|
||||||
if (source_p->umodes & user_modes['x']) {
|
source_p->umodes &= ~user_modes['x'];
|
||||||
rb_strlcpy(source_p->host, source_p->localClient->mangledhost, sizeof(source_p->host));
|
if (source_p->umodes & user_modes['x'])
|
||||||
if (irccmp(source_p->host, source_p->orighost))
|
{
|
||||||
SetDynSpoof(source_p);
|
rb_strlcpy(source_p->host, source_p->localClient->mangledhost, sizeof(source_p->host));
|
||||||
}
|
if (irccmp(source_p->host, source_p->orighost))
|
||||||
|
SetDynSpoof(source_p);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,10 +13,9 @@
|
||||||
static int mclient_42(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
|
static int mclient_42(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
|
||||||
|
|
||||||
struct Message hgtg_msgtab = {
|
struct Message hgtg_msgtab = {
|
||||||
"42", 0, 0, 0, MFLG_SLOW,
|
"42", 0, 0, 0, MFLG_SLOW,
|
||||||
{
|
{ mg_ignore, {mclient_42, 0}, mg_ignore, mg_ignore, mg_ignore, {mclient_42, 0}
|
||||||
mg_ignore, {mclient_42, 0}, mg_ignore, mg_ignore, mg_ignore, {mclient_42, 0}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
mapi_clist_av1 hgtg_clist[] = { &hgtg_msgtab, NULL };
|
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
|
static int
|
||||||
mclient_42(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
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.");
|
sendto_one_notice(source_p, ":The Answer to Life, the Universe, and Everything.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -41,8 +41,8 @@ static int mo_adminwall(struct Client *, struct Client *, int, const char **);
|
||||||
static int me_adminwall(struct Client *, struct Client *, int, const char **);
|
static int me_adminwall(struct Client *, struct Client *, int, const char **);
|
||||||
|
|
||||||
struct Message adminwall_msgtab = {
|
struct Message adminwall_msgtab = {
|
||||||
"ADMINWALL", 0, 0, 0, MFLG_SLOW,
|
"ADMINWALL", 0, 0, 0, MFLG_SLOW,
|
||||||
{mg_unreg, mg_not_oper, mg_ignore, mg_ignore, {me_adminwall, 2}, {mo_adminwall, 2}}
|
{mg_unreg, mg_not_oper, mg_ignore, mg_ignore, {me_adminwall, 2}, {mo_adminwall, 2}}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -58,19 +58,20 @@ DECLARE_MODULE_AV1(adminwall, NULL, NULL, adminwall_clist, NULL, NULL, "$Revisio
|
||||||
static int
|
static int
|
||||||
mo_adminwall(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
mo_adminwall(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
||||||
{
|
{
|
||||||
if(!IsAdmin(source_p)) {
|
if(!IsAdmin(source_p))
|
||||||
sendto_one(source_p, form_str(ERR_NOPRIVS),
|
{
|
||||||
me.name, source_p->name, "adminwall");
|
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;
|
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
|
static int
|
||||||
me_adminwall(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
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]);
|
sendto_wallops_flags(UMODE_ADMIN, source_p, "ADMINWALL - %s", parv[1]);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,8 +25,8 @@ extern struct module **modlist;
|
||||||
static int m_cycle(struct Client *, struct Client *, int, const char **);
|
static int m_cycle(struct Client *, struct Client *, int, const char **);
|
||||||
|
|
||||||
struct Message cycle_msgtab = {
|
struct Message cycle_msgtab = {
|
||||||
"CYCLE", 0, 0, 0, MFLG_SLOW,
|
"CYCLE", 0, 0, 0, MFLG_SLOW,
|
||||||
{mg_unreg, {m_cycle, 2}, {m_cycle, 2}, mg_ignore, mg_ignore, {m_cycle, 2}}
|
{mg_unreg, {m_cycle, 2}, {m_cycle, 2}, mg_ignore, mg_ignore, {m_cycle, 2}}
|
||||||
};
|
};
|
||||||
mapi_clist_av1 cycle_clist[] = { &cycle_msgtab, NULL };
|
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
|
static int
|
||||||
m_cycle(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
m_cycle(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
||||||
{
|
{
|
||||||
char *p, *name;
|
char *p, *name;
|
||||||
char *s = LOCAL_COPY(parv[1]);
|
char *s = LOCAL_COPY(parv[1]);
|
||||||
struct Channel *chptr;
|
struct Channel *chptr;
|
||||||
struct membership *msptr;
|
struct membership *msptr;
|
||||||
|
|
||||||
name = rb_strtok_r(s, ",", &p);
|
name = rb_strtok_r(s, ",", &p);
|
||||||
|
|
||||||
/* Finish the flood grace period... */
|
/* Finish the flood grace period... */
|
||||||
if(MyClient(source_p) && !IsFloodDone(source_p))
|
if(MyClient(source_p) && !IsFloodDone(source_p))
|
||||||
flood_endgrace(source_p);
|
flood_endgrace(source_p);
|
||||||
|
|
||||||
while(name) {
|
while(name)
|
||||||
if((chptr = find_channel(name)) == NULL) {
|
{
|
||||||
sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL, form_str(ERR_NOSUCHCHANNEL), name);
|
if((chptr = find_channel(name)) == NULL)
|
||||||
return 0;
|
{
|
||||||
}
|
sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL, form_str(ERR_NOSUCHCHANNEL), name);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
msptr = find_channel_membership(chptr, source_p);
|
msptr = find_channel_membership(chptr, source_p);
|
||||||
if(msptr == NULL) {
|
if(msptr == NULL)
|
||||||
sendto_one_numeric(source_p, ERR_NOTONCHANNEL, form_str(ERR_NOTONCHANNEL), name);
|
{
|
||||||
return 0;
|
sendto_one_numeric(source_p, ERR_NOTONCHANNEL, form_str(ERR_NOTONCHANNEL), name);
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if(MyConnect(source_p) && !IsOper(source_p) && !IsExemptSpambot(source_p))
|
if(MyConnect(source_p) && !IsOper(source_p) && !IsExemptSpambot(source_p))
|
||||||
check_spambot_warning(source_p, NULL);
|
check_spambot_warning(source_p, NULL);
|
||||||
|
|
||||||
if((is_any_op(msptr) || !MyConnect(source_p) ||
|
if((is_any_op(msptr) || !MyConnect(source_p) ||
|
||||||
((can_send(chptr, source_p, msptr) > 0 &&
|
((can_send(chptr, source_p, msptr) > 0 &&
|
||||||
(source_p->localClient->firsttime +
|
(source_p->localClient->firsttime +
|
||||||
ConfigFileEntry.anti_spam_exit_message_time) < rb_current_time())))) {
|
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_server(client_p, chptr, CAP_TS6, NOCAPS,
|
||||||
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s PART %s :Cycling",
|
":%s PART %s :Cycling", use_id(source_p), chptr->chname);
|
||||||
source_p->name, source_p->username,
|
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s PART %s :Cycling",
|
||||||
source_p->host, chptr->chname);
|
source_p->name, source_p->username,
|
||||||
} else {
|
source_p->host, chptr->chname);
|
||||||
sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
|
}
|
||||||
":%s PART %s", use_id(source_p), chptr->chname);
|
else
|
||||||
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s PART %s",
|
{
|
||||||
source_p->name, source_p->username,
|
sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
|
||||||
source_p->host, chptr->chname);
|
":%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);
|
remove_user_from_channel(msptr);
|
||||||
|
|
||||||
chptr = NULL;
|
chptr = NULL;
|
||||||
msptr = NULL;
|
msptr = NULL;
|
||||||
|
|
||||||
name = rb_strtok_r(NULL, ",", &p);
|
name = rb_strtok_r(NULL, ",", &p);
|
||||||
}
|
}
|
||||||
|
|
||||||
user_join(client_p, source_p, parv[1], parc > 2 ? parv[2] : NULL);
|
user_join(client_p, source_p, parv[1], parc > 2 ? parv[2] : NULL);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,11 +35,11 @@
|
||||||
#include "packet.h"
|
#include "packet.h"
|
||||||
|
|
||||||
static int m_findforwards(struct Client *client_p, struct Client *source_p,
|
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 = {
|
struct Message findforwards_msgtab = {
|
||||||
"FINDFORWARDS", 0, 0, 0, MFLG_SLOW,
|
"FINDFORWARDS", 0, 0, 0, MFLG_SLOW,
|
||||||
{mg_unreg, {m_findforwards, 2}, mg_ignore, mg_ignore, mg_ignore, {m_findforwards, 2}}
|
{mg_unreg, {m_findforwards, 2}, mg_ignore, mg_ignore, mg_ignore, {m_findforwards, 2}}
|
||||||
};
|
};
|
||||||
|
|
||||||
mapi_clist_av1 findforwards_clist[] = { &findforwards_msgtab, NULL };
|
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
|
static int
|
||||||
m_findforwards(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
m_findforwards(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
||||||
{
|
{
|
||||||
static time_t last_used = 0;
|
static time_t last_used = 0;
|
||||||
struct Channel *chptr;
|
struct Channel *chptr;
|
||||||
struct membership *msptr;
|
struct membership *msptr;
|
||||||
rb_dlink_node *ptr;
|
rb_dlink_node *ptr;
|
||||||
char buf[414];
|
char buf[414];
|
||||||
char *p = buf, *end = buf + sizeof buf - 1;
|
char *p = buf, *end = buf + sizeof buf - 1;
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
|
|
||||||
/* Allow ircops to search for forwards to nonexistent channels */
|
/* Allow ircops to search for forwards to nonexistent channels */
|
||||||
if(!IsOper(source_p)) {
|
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,
|
if((chptr = find_channel(parv[1])) == NULL || (msptr = find_channel_membership(chptr, source_p)) == NULL)
|
||||||
form_str(ERR_NOTONCHANNEL), parv[1]);
|
{
|
||||||
return 0;
|
sendto_one_numeric(source_p, ERR_NOTONCHANNEL,
|
||||||
}
|
form_str(ERR_NOTONCHANNEL), parv[1]);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if(!is_any_op(msptr)) {
|
if(!is_any_op(msptr))
|
||||||
sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
|
{
|
||||||
me.name, source_p->name, parv[1]);
|
sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
|
||||||
return 0;
|
me.name, source_p->name, parv[1]);
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if((last_used + ConfigFileEntry.pace_wait) > 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");
|
sendto_one(source_p, form_str(RPL_LOAD2HI),
|
||||||
return 0;
|
me.name, source_p->name, "FINDFORWARDS");
|
||||||
} else
|
return 0;
|
||||||
last_used = rb_current_time();
|
}
|
||||||
}
|
else
|
||||||
|
last_used = rb_current_time();
|
||||||
|
}
|
||||||
|
|
||||||
RB_DLINK_FOREACH(ptr, global_channel_list.head) {
|
RB_DLINK_FOREACH(ptr, global_channel_list.head)
|
||||||
chptr = ptr->data;
|
{
|
||||||
if(chptr->mode.forward && !irccmp(chptr->mode.forward, parv[1])) {
|
chptr = ptr->data;
|
||||||
if(p + strlen(chptr->chname) >= end - 13) {
|
if(chptr->mode.forward && !irccmp(chptr->mode.forward, parv[1]))
|
||||||
strcpy(p, "<truncated> ");
|
{
|
||||||
p += 12;
|
if(p + strlen(chptr->chname) >= end - 13)
|
||||||
break;
|
{
|
||||||
}
|
strcpy(p, "<truncated> ");
|
||||||
strcpy(p, chptr->chname);
|
p += 12;
|
||||||
p += strlen(chptr->chname);
|
break;
|
||||||
*p++ = ' ';
|
}
|
||||||
}
|
strcpy(p, chptr->chname);
|
||||||
}
|
p += strlen(chptr->chname);
|
||||||
|
*p++ = ' ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(buf[0])
|
if(buf[0])
|
||||||
*(--p) = '\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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,11 +48,11 @@
|
||||||
#include "modules.h"
|
#include "modules.h"
|
||||||
|
|
||||||
static int mo_forcejoin(struct Client *client_p, struct Client *source_p,
|
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 = {
|
struct Message forcejoin_msgtab = {
|
||||||
"FORCEJOIN", 0, 0, 0, MFLG_SLOW,
|
"FORCEJOIN", 0, 0, 0, MFLG_SLOW,
|
||||||
{mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_forcejoin, 3}}
|
{mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_forcejoin, 3}}
|
||||||
};
|
};
|
||||||
|
|
||||||
mapi_clist_av1 force_clist[] = { &forcejoin_msgtab, NULL };
|
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
|
static int
|
||||||
mo_forcejoin(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
mo_forcejoin(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
||||||
{
|
{
|
||||||
struct Client *target_p;
|
struct Client *target_p;
|
||||||
struct Channel *chptr;
|
struct Channel *chptr;
|
||||||
int type;
|
int type;
|
||||||
char mode;
|
char mode;
|
||||||
char sjmode;
|
char sjmode;
|
||||||
char *newch;
|
char *newch;
|
||||||
|
|
||||||
if(!IsOperAdmin(source_p)) {
|
if(!IsOperAdmin(source_p))
|
||||||
sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "admin");
|
{
|
||||||
return 0;
|
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)
|
if((hunt_server(client_p, source_p, ":%s FORCEJOIN %s %s", 1, parc, parv)) != HUNTED_ISME)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* if target_p is not existant, print message
|
/* if target_p is not existant, print message
|
||||||
* to source_p and bail - scuzzy
|
* to source_p and bail - scuzzy
|
||||||
*/
|
*/
|
||||||
if((target_p = find_client(parv[1])) == NULL) {
|
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;
|
sendto_one(source_p, form_str(ERR_NOSUCHNICK), me.name, source_p->name, parv[1]);
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if(!IsPerson(target_p))
|
if(!IsPerson(target_p))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
sendto_wallops_flags(UMODE_WALLOP, &me,
|
sendto_wallops_flags(UMODE_WALLOP, &me,
|
||||||
"FORCEJOIN called for %s %s by %s!%s@%s",
|
"FORCEJOIN called for %s %s by %s!%s@%s",
|
||||||
parv[1], parv[2], source_p->name, source_p->username, source_p->host);
|
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",
|
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);
|
parv[1], parv[2], source_p->name, source_p->username, source_p->host);
|
||||||
sendto_server(NULL, NULL, NOCAPS, NOCAPS,
|
sendto_server(NULL, NULL, NOCAPS, NOCAPS,
|
||||||
":%s WALLOPS :FORCEJOIN called for %s %s by %s!%s@%s",
|
":%s WALLOPS :FORCEJOIN called for %s %s by %s!%s@%s",
|
||||||
me.name, parv[1], parv[2],
|
me.name, parv[1], parv[2],
|
||||||
source_p->name, source_p->username, source_p->host);
|
source_p->name, source_p->username, source_p->host);
|
||||||
|
|
||||||
/* select our modes from parv[2] if they exist... (chanop) */
|
/* select our modes from parv[2] if they exist... (chanop) */
|
||||||
if(*parv[2] == '@') {
|
if(*parv[2] == '@')
|
||||||
type = CHFL_CHANOP;
|
{
|
||||||
mode = 'o';
|
type = CHFL_CHANOP;
|
||||||
sjmode = '@';
|
mode = 'o';
|
||||||
} else if(*parv[2] == '+') {
|
sjmode = '@';
|
||||||
type = CHFL_VOICE;
|
}
|
||||||
mode = 'v';
|
else if(*parv[2] == '+')
|
||||||
sjmode = '+';
|
{
|
||||||
} else {
|
type = CHFL_VOICE;
|
||||||
type = CHFL_PEON;
|
mode = 'v';
|
||||||
mode = sjmode = '\0';
|
sjmode = '+';
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
type = CHFL_PEON;
|
||||||
|
mode = sjmode = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
if(mode != '\0')
|
if(mode != '\0')
|
||||||
parv[2]++;
|
parv[2]++;
|
||||||
|
|
||||||
if((chptr = find_channel(parv[2])) != NULL) {
|
if((chptr = find_channel(parv[2])) != NULL)
|
||||||
if(IsMember(target_p, chptr)) {
|
{
|
||||||
/* debugging is fun... */
|
if(IsMember(target_p, chptr))
|
||||||
sendto_one_notice(source_p, ":*** Notice -- %s is already in %s",
|
{
|
||||||
target_p->name, chptr->chname);
|
/* debugging is fun... */
|
||||||
return 0;
|
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,
|
sendto_server(target_p, chptr, NOCAPS, NOCAPS,
|
||||||
":%s SJOIN %ld %s + :%c%s",
|
":%s SJOIN %ld %s + :%c%s",
|
||||||
me.name, (long) chptr->channelts,
|
me.name, (long) chptr->channelts,
|
||||||
chptr->chname, type ? sjmode : ' ', target_p->name);
|
chptr->chname, type ? sjmode : ' ', target_p->name);
|
||||||
|
|
||||||
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN :%s",
|
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN :%s",
|
||||||
target_p->name, target_p->username,
|
target_p->name, target_p->username,
|
||||||
target_p->host, chptr->chname);
|
target_p->host, chptr->chname);
|
||||||
|
|
||||||
if(type)
|
if(type)
|
||||||
sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +%c %s",
|
sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +%c %s",
|
||||||
me.name, chptr->chname, mode, target_p->name);
|
me.name, chptr->chname, mode, target_p->name);
|
||||||
|
|
||||||
if(chptr->topic != NULL) {
|
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_TOPIC), me.name,
|
||||||
sendto_one(target_p, form_str(RPL_TOPICWHOTIME),
|
target_p->name, chptr->chname, chptr->topic);
|
||||||
me.name, source_p->name, chptr->chname,
|
sendto_one(target_p, form_str(RPL_TOPICWHOTIME),
|
||||||
chptr->topic_info, chptr->topic_time);
|
me.name, source_p->name, chptr->chname,
|
||||||
}
|
chptr->topic_info, chptr->topic_time);
|
||||||
|
}
|
||||||
|
|
||||||
channel_member_names(chptr, target_p, 1);
|
channel_member_names(chptr, target_p, 1);
|
||||||
} else {
|
}
|
||||||
newch = LOCAL_COPY(parv[2]);
|
else
|
||||||
if(!check_channel_name(newch)) {
|
{
|
||||||
sendto_one(source_p, form_str(ERR_BADCHANNAME), me.name,
|
newch = LOCAL_COPY(parv[2]);
|
||||||
source_p->name, (unsigned char *) newch);
|
if(!check_channel_name(newch))
|
||||||
return 0;
|
{
|
||||||
}
|
sendto_one(source_p, form_str(ERR_BADCHANNAME), me.name,
|
||||||
|
source_p->name, (unsigned char *) newch);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* channel name must begin with & or # */
|
/* channel name must begin with & or # */
|
||||||
if(!IsChannelName(newch)) {
|
if(!IsChannelName(newch))
|
||||||
sendto_one(source_p, form_str(ERR_BADCHANNAME), me.name,
|
{
|
||||||
source_p->name, (unsigned char *) newch);
|
sendto_one(source_p, form_str(ERR_BADCHANNAME), me.name,
|
||||||
return 0;
|
source_p->name, (unsigned char *) newch);
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* newch can't be longer than CHANNELLEN */
|
/* newch can't be longer than CHANNELLEN */
|
||||||
if(strlen(newch) > CHANNELLEN) {
|
if(strlen(newch) > CHANNELLEN)
|
||||||
sendto_one_notice(source_p, ":Channel name is too long");
|
{
|
||||||
return 0;
|
sendto_one_notice(source_p, ":Channel name is too long");
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
chptr = get_or_create_channel(target_p, newch, NULL);
|
chptr = get_or_create_channel(target_p, newch, NULL);
|
||||||
add_user_to_channel(chptr, target_p, CHFL_CHANOP);
|
add_user_to_channel(chptr, target_p, CHFL_CHANOP);
|
||||||
|
|
||||||
/* send out a join, make target_p join chptr */
|
/* send out a join, make target_p join chptr */
|
||||||
sendto_server(target_p, chptr, NOCAPS, NOCAPS,
|
sendto_server(target_p, chptr, NOCAPS, NOCAPS,
|
||||||
":%s SJOIN %ld %s +nt :@%s", me.name,
|
":%s SJOIN %ld %s +nt :@%s", me.name,
|
||||||
(long) chptr->channelts, chptr->chname, target_p->name);
|
(long) chptr->channelts, chptr->chname, target_p->name);
|
||||||
|
|
||||||
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN :%s",
|
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN :%s",
|
||||||
target_p->name, target_p->username,
|
target_p->name, target_p->username,
|
||||||
target_p->host, chptr->chname);
|
target_p->host, chptr->chname);
|
||||||
|
|
||||||
chptr->mode.mode |= MODE_TOPICLIMIT;
|
chptr->mode.mode |= MODE_TOPICLIMIT;
|
||||||
chptr->mode.mode |= MODE_NOPRIVMSGS;
|
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();
|
target_p->localClient->last_join_time = rb_current_time();
|
||||||
channel_member_names(chptr, target_p, 1);
|
channel_member_names(chptr, target_p, 1);
|
||||||
|
|
||||||
/* we do this to let the oper know that a channel was created, this will be
|
/* 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
|
* seen from the server handling the command instead of the server that
|
||||||
* the oper is on.
|
* the oper is on.
|
||||||
*/
|
*/
|
||||||
sendto_one_notice(source_p, ":*** Notice -- Creating channel %s", chptr->chname);
|
sendto_one_notice(source_p, ":*** Notice -- Creating channel %s", chptr->chname);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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[]);
|
static int m_identify(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
|
||||||
|
|
||||||
struct Message identify_msgtab = {
|
struct Message identify_msgtab = {
|
||||||
"IDENTIFY", 0, 0, 0, MFLG_SLOW,
|
"IDENTIFY", 0, 0, 0, MFLG_SLOW,
|
||||||
{mg_unreg, {m_identify, 0}, mg_ignore, mg_ignore, mg_ignore, {m_identify, 0}}
|
{mg_unreg, {m_identify, 0}, mg_ignore, mg_ignore, mg_ignore, {m_identify, 0}}
|
||||||
};
|
};
|
||||||
|
|
||||||
mapi_clist_av1 identify_clist[] = {
|
mapi_clist_av1 identify_clist[] = {
|
||||||
&identify_msgtab,
|
&identify_msgtab,
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
DECLARE_MODULE_AV1(identify, NULL, NULL, identify_clist, NULL, NULL, "$Revision: 2729 $");
|
DECLARE_MODULE_AV1(identify, NULL, NULL, identify_clist, NULL, NULL, "$Revision: 2729 $");
|
||||||
|
|
||||||
char *reconstruct_parv(int parc, const char *parv[])
|
char *reconstruct_parv(int parc, const char *parv[])
|
||||||
{
|
{
|
||||||
static char tmpbuf[BUFSIZE];
|
static char tmpbuf[BUFSIZE]; int i;
|
||||||
int i;
|
|
||||||
|
|
||||||
rb_strlcpy(tmpbuf, parv[0], BUFSIZE);
|
rb_strlcpy(tmpbuf, parv[0], BUFSIZE);
|
||||||
for (i = 1; i < parc; i++) {
|
for (i = 1; i < parc; i++)
|
||||||
rb_strlcat(tmpbuf, " ", BUFSIZE);
|
{
|
||||||
rb_strlcat(tmpbuf, parv[i], BUFSIZE);
|
rb_strlcat(tmpbuf, " ", BUFSIZE);
|
||||||
}
|
rb_strlcat(tmpbuf, parv[i], BUFSIZE);
|
||||||
return tmpbuf;
|
}
|
||||||
|
return tmpbuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int m_identify(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
static int m_identify(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
||||||
{
|
{
|
||||||
const char *nick;
|
const char *nick;
|
||||||
struct Client *target_p;
|
struct Client *target_p;
|
||||||
|
|
||||||
if (parc < 2 || EmptyString(parv[1])) {
|
if (parc < 2 || EmptyString(parv[1]))
|
||||||
sendto_one(source_p, form_str(ERR_NOTEXTTOSEND), me.name, source_p->name);
|
{
|
||||||
return 0;
|
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;
|
nick = parv[1][0] == '#' ? SVS_chanserv_NICK : SVS_nickserv_NICK;
|
||||||
if ((target_p = find_named_person(nick)) && IsService(target_p)) {
|
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(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]));
|
||||||
sendto_one_numeric(source_p, ERR_SERVICESDOWN, form_str(ERR_SERVICESDOWN), nick);
|
}
|
||||||
}
|
else
|
||||||
return 0;
|
{
|
||||||
|
sendto_one_numeric(source_p, ERR_SERVICESDOWN, form_str(ERR_SERVICESDOWN), nick);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,9 +15,9 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
static int m_mkpasswd(struct Client *client_p, struct Client *source_p,
|
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,
|
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_md5_salt(int);
|
||||||
static char *make_sha256_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 *generate_poor_salt(char *, int);
|
||||||
|
|
||||||
static char saltChars[] = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
static char saltChars[] = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||||
/* 0 .. 63, ascii - 64 */
|
/* 0 .. 63, ascii - 64 */
|
||||||
|
|
||||||
struct Message mkpasswd_msgtab = {
|
struct Message mkpasswd_msgtab = {
|
||||||
"MKPASSWD", 0, 0, 0, MFLG_SLOW,
|
"MKPASSWD", 0, 0, 0, MFLG_SLOW,
|
||||||
{mg_unreg, {m_mkpasswd, 2}, mg_ignore, mg_ignore, mg_ignore, {mo_mkpasswd, 2}}
|
{mg_unreg, {m_mkpasswd, 2}, mg_ignore, mg_ignore, mg_ignore, {mo_mkpasswd, 2}}
|
||||||
};
|
};
|
||||||
|
|
||||||
mapi_clist_av1 mkpasswd_clist[] = { &mkpasswd_msgtab, NULL };
|
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
|
static int
|
||||||
m_mkpasswd(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
m_mkpasswd(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
||||||
{
|
{
|
||||||
static time_t last_used = 0;
|
static time_t last_used = 0;
|
||||||
char *salt;
|
char *salt;
|
||||||
const char *hashtype;
|
const char *hashtype;
|
||||||
const char hashdefault[] = "SHA512";
|
const char hashdefault[] = "SHA512";
|
||||||
|
|
||||||
if(EmptyString(parv[1])) {
|
if(EmptyString(parv[1]))
|
||||||
sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), me.name, source_p->name, "MKPASSWD");
|
{
|
||||||
return 0;
|
sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), me.name, source_p->name, "MKPASSWD");
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if(parc < 3)
|
if(parc < 3)
|
||||||
hashtype = hashdefault;
|
hashtype = hashdefault;
|
||||||
else
|
else
|
||||||
hashtype = parv[2];
|
hashtype = parv[2];
|
||||||
|
|
||||||
if((last_used + ConfigFileEntry.pace_wait) > 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");
|
/* safe enough to give this on a local connect only */
|
||||||
return 0;
|
sendto_one(source_p, form_str(RPL_LOAD2HI), me.name, source_p->name, "MKPASSWD");
|
||||||
} else
|
return 0;
|
||||||
last_used = rb_current_time();
|
}
|
||||||
|
else
|
||||||
|
last_used = rb_current_time();
|
||||||
|
|
||||||
if(!irccmp(hashtype, "SHA256"))
|
if(!irccmp(hashtype, "SHA256"))
|
||||||
salt = make_sha256_salt(16);
|
salt = make_sha256_salt(16);
|
||||||
else if(!irccmp(hashtype, "SHA512"))
|
else if(!irccmp(hashtype, "SHA512"))
|
||||||
salt = make_sha512_salt(16);
|
salt = make_sha512_salt(16);
|
||||||
else if(!irccmp(hashtype, "MD5"))
|
else if(!irccmp(hashtype, "MD5"))
|
||||||
salt = make_md5_salt(8);
|
salt = make_md5_salt(8);
|
||||||
else {
|
else
|
||||||
sendto_one_notice(source_p,
|
{
|
||||||
":MKPASSWD syntax error: MKPASSWD pass [SHA256|SHA512|MD5]");
|
sendto_one_notice(source_p,
|
||||||
return 0;
|
":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));
|
sendto_one_notice(source_p, ":Hash [%s] for %s: %s", hashtype, parv[1], rb_crypt(parv[1], salt));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* mo_mkpasswd - mkpasswd message handler
|
/* 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
|
static int
|
||||||
mo_mkpasswd(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
mo_mkpasswd(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
||||||
{
|
{
|
||||||
char *salt;
|
char *salt;
|
||||||
const char *hashtype;
|
const char *hashtype;
|
||||||
const char hashdefault[] = "SHA512";
|
const char hashdefault[] = "SHA512";
|
||||||
|
|
||||||
if(EmptyString(parv[1])) {
|
if(EmptyString(parv[1]))
|
||||||
sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), me.name, source_p->name, "MKPASSWD");
|
{
|
||||||
return 0;
|
sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), me.name, source_p->name, "MKPASSWD");
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if(parc < 3)
|
if(parc < 3)
|
||||||
hashtype = hashdefault;
|
hashtype = hashdefault;
|
||||||
else
|
else
|
||||||
hashtype = parv[2];
|
hashtype = parv[2];
|
||||||
|
|
||||||
if(!irccmp(hashtype, "SHA256"))
|
if(!irccmp(hashtype, "SHA256"))
|
||||||
salt = make_sha256_salt(16);
|
salt = make_sha256_salt(16);
|
||||||
else if(!irccmp(hashtype, "SHA512"))
|
else if(!irccmp(hashtype, "SHA512"))
|
||||||
salt = make_sha512_salt(16);
|
salt = make_sha512_salt(16);
|
||||||
else if(!irccmp(hashtype, "MD5"))
|
else if(!irccmp(hashtype, "MD5"))
|
||||||
salt = make_md5_salt(8);
|
salt = make_md5_salt(8);
|
||||||
else {
|
else
|
||||||
sendto_one_notice(source_p,
|
{
|
||||||
":MKPASSWD syntax error: MKPASSWD pass [SHA256|SHA512|MD5]");
|
sendto_one_notice(source_p,
|
||||||
return 0;
|
":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));
|
sendto_one_notice(source_p, ":Hash [%s] for %s: %s", hashtype, parv[1], rb_crypt(parv[1], salt));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
make_md5_salt(int length)
|
make_md5_salt(int length)
|
||||||
{
|
{
|
||||||
static char salt[21];
|
static char salt[21];
|
||||||
if(length > 16) {
|
if(length > 16)
|
||||||
printf("MD5 salt length too long\n");
|
{
|
||||||
exit(0);
|
printf("MD5 salt length too long\n");
|
||||||
}
|
exit(0);
|
||||||
salt[0] = '$';
|
}
|
||||||
salt[1] = '1';
|
salt[0] = '$';
|
||||||
salt[2] = '$';
|
salt[1] = '1';
|
||||||
generate_random_salt(&salt[3], length);
|
salt[2] = '$';
|
||||||
salt[length + 3] = '$';
|
generate_random_salt(&salt[3], length);
|
||||||
salt[length + 4] = '\0';
|
salt[length + 3] = '$';
|
||||||
return salt;
|
salt[length + 4] = '\0';
|
||||||
|
return salt;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
make_sha256_salt(int length)
|
make_sha256_salt(int length)
|
||||||
{
|
{
|
||||||
static char salt[21];
|
static char salt[21];
|
||||||
if(length > 16) {
|
if(length > 16)
|
||||||
printf("SHA256 salt length too long\n");
|
{
|
||||||
exit(0);
|
printf("SHA256 salt length too long\n");
|
||||||
}
|
exit(0);
|
||||||
salt[0] = '$';
|
}
|
||||||
salt[1] = '5';
|
salt[0] = '$';
|
||||||
salt[2] = '$';
|
salt[1] = '5';
|
||||||
generate_random_salt(&salt[3], length);
|
salt[2] = '$';
|
||||||
salt[length + 3] = '$';
|
generate_random_salt(&salt[3], length);
|
||||||
salt[length + 4] = '\0';
|
salt[length + 3] = '$';
|
||||||
return salt;
|
salt[length + 4] = '\0';
|
||||||
|
return salt;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
make_sha512_salt(int length)
|
make_sha512_salt(int length)
|
||||||
{
|
{
|
||||||
static char salt[21];
|
static char salt[21];
|
||||||
if(length > 16) {
|
if(length > 16)
|
||||||
printf("SHA512 salt length too long\n");
|
{
|
||||||
exit(0);
|
printf("SHA512 salt length too long\n");
|
||||||
}
|
exit(0);
|
||||||
salt[0] = '$';
|
}
|
||||||
salt[1] = '6';
|
salt[0] = '$';
|
||||||
salt[2] = '$';
|
salt[1] = '6';
|
||||||
generate_random_salt(&salt[3], length);
|
salt[2] = '$';
|
||||||
salt[length + 3] = '$';
|
generate_random_salt(&salt[3], length);
|
||||||
salt[length + 4] = '\0';
|
salt[length + 3] = '$';
|
||||||
return salt;
|
salt[length + 4] = '\0';
|
||||||
|
return salt;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
generate_poor_salt(char *salt, int length)
|
generate_poor_salt(char *salt, int length)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
srand(time(NULL));
|
srand(time(NULL));
|
||||||
for(i = 0; i < length; i++) {
|
for(i = 0; i < length; i++)
|
||||||
salt[i] = saltChars[rand() % 64];
|
{
|
||||||
}
|
salt[i] = saltChars[rand() % 64];
|
||||||
return (salt);
|
}
|
||||||
|
return (salt);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
generate_random_salt(char *salt, int length)
|
generate_random_salt(char *salt, int length)
|
||||||
{
|
{
|
||||||
char *buf;
|
char *buf;
|
||||||
int fd, i;
|
int fd, i;
|
||||||
if((fd = open("/dev/random", O_RDONLY)) < 0) {
|
if((fd = open("/dev/random", O_RDONLY)) < 0)
|
||||||
return (generate_poor_salt(salt, length));
|
{
|
||||||
}
|
return (generate_poor_salt(salt, length));
|
||||||
buf = calloc(1, length);
|
}
|
||||||
if(read(fd, buf, length) != length) {
|
buf = calloc(1, length);
|
||||||
free(buf);
|
if(read(fd, buf, length) != length)
|
||||||
return (generate_poor_salt(salt, length));
|
{
|
||||||
}
|
free(buf);
|
||||||
|
return (generate_poor_salt(salt, length));
|
||||||
|
}
|
||||||
|
|
||||||
for(i = 0; i < length; i++) {
|
for(i = 0; i < length; i++)
|
||||||
salt[i] = saltChars[abs(buf[i]) % 64];
|
{
|
||||||
}
|
salt[i] = saltChars[abs(buf[i]) % 64];
|
||||||
free(buf);
|
}
|
||||||
return (salt);
|
free(buf);
|
||||||
|
return (salt);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
static int mo_oaccept(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
|
static int mo_oaccept(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
|
||||||
|
|
||||||
struct Message oaccept_msgtab = {
|
struct Message oaccept_msgtab = {
|
||||||
"OACCEPT", 0, 0, 0, MFLG_SLOW,
|
"OACCEPT", 0, 0, 0, MFLG_SLOW,
|
||||||
{mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_oaccept, 2}}
|
{mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_oaccept, 2}}
|
||||||
};
|
};
|
||||||
|
|
||||||
mapi_clist_av1 oaccept_clist[] = { &oaccept_msgtab, NULL };
|
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
|
static int
|
||||||
mo_oaccept(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
mo_oaccept(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
||||||
{
|
{
|
||||||
struct Metadata *md;
|
struct Metadata *md;
|
||||||
struct DictionaryIter iter;
|
struct DictionaryIter iter;
|
||||||
struct Client *target_p;
|
struct Client *target_p;
|
||||||
char text[10];
|
char text[10];
|
||||||
|
|
||||||
if(!(target_p = find_client(parv[1]))) {
|
if(!(target_p = find_client(parv[1])))
|
||||||
sendto_one(source_p, form_str(ERR_NOSUCHNICK), parv[1]);
|
{
|
||||||
return 0;
|
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 we don't check for this, and some idiot tries to OACCEPT a server... */
|
||||||
if(!IsPerson(target_p)) {
|
if(!IsPerson(target_p))
|
||||||
sendto_one_notice(source_p, ":That is a server, not a user. What are you doing?");
|
{
|
||||||
return 0;
|
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
|
/* Provide a nice error message if you try to OACCEPT someone
|
||||||
* who you've already OACCEPTed. */
|
* who you've already OACCEPTed. */
|
||||||
DICTIONARY_FOREACH(md, &iter, target_p->user->metadata) {
|
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);
|
if(!strcmp(md->value, "OACCEPT") && !strcmp(md->name, text))
|
||||||
return 0;
|
{
|
||||||
}
|
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,
|
sendto_wallops_flags(UMODE_WALLOP, &me,
|
||||||
"OACCEPT called for %s by %s!%s@%s",
|
"OACCEPT called for %s by %s!%s@%s",
|
||||||
target_p->name,
|
target_p->name,
|
||||||
source_p->name, source_p->username, source_p->host);
|
source_p->name, source_p->username, source_p->host);
|
||||||
sendto_server(NULL, NULL, NOCAPS, NOCAPS,
|
sendto_server(NULL, NULL, NOCAPS, NOCAPS,
|
||||||
":%s WALLOPS :OACCEPT called for %s by %s!%s@%s",
|
":%s WALLOPS :OACCEPT called for %s by %s!%s@%s",
|
||||||
me.name, target_p->name, source_p->name, source_p->username,
|
me.name, target_p->name, source_p->name, source_p->username,
|
||||||
source_p->host);
|
source_p->host);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,8 +39,8 @@ static int mo_ojoin(struct Client *client_p, struct Client *source_p, int parc,
|
||||||
|
|
||||||
|
|
||||||
struct Message ojoin_msgtab = {
|
struct Message ojoin_msgtab = {
|
||||||
"OJOIN", 0, 0, 0, MFLG_SLOW,
|
"OJOIN", 0, 0, 0, MFLG_SLOW,
|
||||||
{mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_ojoin, 2}}
|
{mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_ojoin, 2}}
|
||||||
};
|
};
|
||||||
|
|
||||||
mapi_clist_av1 ojoin_clist[] = { &ojoin_msgtab, NULL };
|
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
|
static int
|
||||||
mo_ojoin(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
mo_ojoin(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
||||||
{
|
{
|
||||||
struct Channel *chptr;
|
struct Channel *chptr;
|
||||||
int move_me = 0;
|
int move_me = 0;
|
||||||
|
|
||||||
/* admins only */
|
/* admins only */
|
||||||
if(!IsOperAdmin(source_p)) {
|
if(!IsOperAdmin(source_p))
|
||||||
sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "admin");
|
{
|
||||||
return 0;
|
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] == '~') {
|
if(*parv[1] == '@' || *parv[1] == '%' || *parv[1] == '+' || *parv[1] == '!' || *parv[1] == '~')
|
||||||
parv[1]++;
|
{
|
||||||
move_me = 1;
|
parv[1]++;
|
||||||
}
|
move_me = 1;
|
||||||
|
}
|
||||||
|
|
||||||
if((chptr = find_channel(parv[1])) == NULL) {
|
if((chptr = find_channel(parv[1])) == NULL)
|
||||||
sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL,
|
{
|
||||||
form_str(ERR_NOSUCHCHANNEL), parv[1]);
|
sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL,
|
||||||
return 0;
|
form_str(ERR_NOSUCHCHANNEL), parv[1]);
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if(IsMember(source_p, chptr)) {
|
if(IsMember(source_p, chptr))
|
||||||
sendto_one_notice(source_p, ":Please part %s before using OJOIN", parv[1]);
|
{
|
||||||
return 0;
|
sendto_one_notice(source_p, ":Please part %s before using OJOIN", parv[1]);
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if(move_me == 1)
|
if(move_me == 1)
|
||||||
parv[1]--;
|
parv[1]--;
|
||||||
|
|
||||||
sendto_wallops_flags(UMODE_WALLOP, &me,
|
sendto_wallops_flags(UMODE_WALLOP, &me,
|
||||||
"OJOIN called for %s by %s!%s@%s",
|
"OJOIN called for %s by %s!%s@%s",
|
||||||
parv[1], source_p->name, source_p->username, source_p->host);
|
parv[1], source_p->name, source_p->username, source_p->host);
|
||||||
ilog(L_MAIN, "OJOIN called for %s by %s",
|
ilog(L_MAIN, "OJOIN called for %s by %s",
|
||||||
parv[1], get_oper_name(source_p));
|
parv[1], get_oper_name(source_p));
|
||||||
/* only sends stuff for #channels remotely */
|
/* only sends stuff for #channels remotely */
|
||||||
sendto_server(NULL, chptr, NOCAPS, NOCAPS,
|
sendto_server(NULL, chptr, NOCAPS, NOCAPS,
|
||||||
":%s WALLOPS :OJOIN called for %s by %s!%s@%s",
|
":%s WALLOPS :OJOIN called for %s by %s!%s@%s",
|
||||||
me.name, parv[1],
|
me.name, parv[1],
|
||||||
source_p->name, source_p->username, source_p->host);
|
source_p->name, source_p->username, source_p->host);
|
||||||
|
|
||||||
if(*parv[1] == '~' && ConfigChannel.use_owner) {
|
if(*parv[1] == '~' && ConfigChannel.use_owner)
|
||||||
add_user_to_channel(chptr, source_p, CHFL_OWNER);
|
{
|
||||||
sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
|
add_user_to_channel(chptr, source_p, CHFL_OWNER);
|
||||||
":%s SJOIN %ld %s + :~%s",
|
sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
|
||||||
me.id, (long) chptr->channelts, chptr->chname, source_p->id);
|
":%s SJOIN %ld %s + :~%s",
|
||||||
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN %s",
|
me.id, (long) chptr->channelts, chptr->chname, source_p->id);
|
||||||
source_p->name,
|
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN %s",
|
||||||
source_p->username, source_p->host, chptr->chname);
|
source_p->name,
|
||||||
sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +y %s",
|
source_p->username, source_p->host, chptr->chname);
|
||||||
me.name, chptr->chname, source_p->name);
|
sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +y %s",
|
||||||
} else if(*parv[1] == '!' && ConfigChannel.use_admin) {
|
me.name, chptr->chname, source_p->name);
|
||||||
add_user_to_channel(chptr, source_p, CHFL_ADMIN);
|
}
|
||||||
sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
|
else if(*parv[1] == '!' && ConfigChannel.use_admin)
|
||||||
":%s SJOIN %ld %s + :!%s",
|
{
|
||||||
me.id, (long) chptr->channelts, chptr->chname, source_p->id);
|
add_user_to_channel(chptr, source_p, CHFL_ADMIN);
|
||||||
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN %s",
|
sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
|
||||||
source_p->name,
|
":%s SJOIN %ld %s + :!%s",
|
||||||
source_p->username, source_p->host, chptr->chname);
|
me.id, (long) chptr->channelts, chptr->chname, source_p->id);
|
||||||
sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +a %s",
|
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN %s",
|
||||||
me.name, chptr->chname, source_p->name);
|
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);
|
else if(*parv[1] == '@')
|
||||||
sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
|
{
|
||||||
":%s SJOIN %ld %s + :@%s",
|
add_user_to_channel(chptr, source_p, CHFL_CHANOP);
|
||||||
me.id, (long) chptr->channelts, chptr->chname, source_p->id);
|
sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
|
||||||
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN %s",
|
":%s SJOIN %ld %s + :@%s",
|
||||||
source_p->name,
|
me.id, (long) chptr->channelts, chptr->chname, source_p->id);
|
||||||
source_p->username, source_p->host, chptr->chname);
|
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN %s",
|
||||||
sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +o %s",
|
source_p->name,
|
||||||
me.name, chptr->chname, 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);
|
else if(*parv[1] == '%' && ConfigChannel.use_halfop)
|
||||||
sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
|
{
|
||||||
":%s SJOIN %ld %s + :%s%s",
|
add_user_to_channel(chptr, source_p, CHFL_HALFOP);
|
||||||
me.id, (long) chptr->channelts, chptr->chname, "%", source_p->id);
|
sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
|
||||||
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN %s",
|
":%s SJOIN %ld %s + :%s%s",
|
||||||
source_p->name,
|
me.id, (long) chptr->channelts, chptr->chname, "%", source_p->id);
|
||||||
source_p->username, source_p->host, chptr->chname);
|
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN %s",
|
||||||
sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +h %s",
|
source_p->name,
|
||||||
me.name, chptr->chname, source_p->name);
|
source_p->username, source_p->host, chptr->chname);
|
||||||
} else if(*parv[1] == '+') {
|
sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +h %s",
|
||||||
add_user_to_channel(chptr, source_p, CHFL_VOICE);
|
me.name, chptr->chname, source_p->name);
|
||||||
sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
|
}
|
||||||
":%s SJOIN %ld %s + :+%s",
|
else if(*parv[1] == '+')
|
||||||
me.id, (long) chptr->channelts, chptr->chname, source_p->id);
|
{
|
||||||
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN %s",
|
add_user_to_channel(chptr, source_p, CHFL_VOICE);
|
||||||
source_p->name,
|
sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
|
||||||
source_p->username, source_p->host, chptr->chname);
|
":%s SJOIN %ld %s + :+%s",
|
||||||
sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +v %s",
|
me.id, (long) chptr->channelts, chptr->chname, source_p->id);
|
||||||
me.name, chptr->chname, source_p->name);
|
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN %s",
|
||||||
} else {
|
source_p->name,
|
||||||
add_user_to_channel(chptr, source_p, CHFL_PEON);
|
source_p->username, source_p->host, chptr->chname);
|
||||||
sendto_server(client_p, chptr, CAP_TS6, NOCAPS,
|
sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +v %s",
|
||||||
":%s JOIN %ld %s +",
|
me.name, chptr->chname, source_p->name);
|
||||||
source_p->id, (long) chptr->channelts, chptr->chname);
|
}
|
||||||
sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s JOIN %s",
|
else
|
||||||
source_p->name,
|
{
|
||||||
source_p->username, source_p->host, chptr->chname);
|
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... */
|
/* send the topic... */
|
||||||
if(chptr->topic != NULL) {
|
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_TOPIC), me.name,
|
||||||
sendto_one(source_p, form_str(RPL_TOPICWHOTIME), me.name,
|
source_p->name, chptr->chname, chptr->topic);
|
||||||
source_p->name, chptr->chname, chptr->topic_info, chptr->topic_time);
|
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();
|
source_p->localClient->last_join_time = rb_current_time();
|
||||||
channel_member_names(chptr, source_p, 1);
|
channel_member_names(chptr, source_p, 1);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,8 +41,8 @@ static int mo_okick(struct Client *client_p, struct Client *source_p, int parc,
|
||||||
|
|
||||||
|
|
||||||
struct Message okick_msgtab = {
|
struct Message okick_msgtab = {
|
||||||
"OKICK", 0, 0, 0, MFLG_SLOW,
|
"OKICK", 0, 0, 0, MFLG_SLOW,
|
||||||
{mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_okick, 4}}
|
{mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_okick, 4}}
|
||||||
};
|
};
|
||||||
|
|
||||||
mapi_clist_av1 okick_clist[] = { &okick_msgtab, NULL };
|
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
|
static int
|
||||||
mo_okick(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
mo_okick(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
||||||
{
|
{
|
||||||
struct Client *who;
|
struct Client *who;
|
||||||
struct Client *target_p;
|
struct Client *target_p;
|
||||||
struct Channel *chptr;
|
struct Channel *chptr;
|
||||||
struct membership *msptr;
|
struct membership *msptr;
|
||||||
int chasing = 0;
|
int chasing = 0;
|
||||||
char *comment;
|
char *comment;
|
||||||
char *name;
|
char *name;
|
||||||
char *p = NULL;
|
char *p = NULL;
|
||||||
char *user;
|
char *user;
|
||||||
char text[10];
|
char text[10];
|
||||||
static char buf[BUFSIZE];
|
static char buf[BUFSIZE];
|
||||||
|
|
||||||
if(*parv[2] == '\0') {
|
if(*parv[2] == '\0')
|
||||||
sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), me.name, source_p->name, "KICK");
|
{
|
||||||
return 0;
|
sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS), me.name, source_p->name, "KICK");
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if(MyClient(source_p) && !IsFloodDone(source_p))
|
if(MyClient(source_p) && !IsFloodDone(source_p))
|
||||||
flood_endgrace(source_p);
|
flood_endgrace(source_p);
|
||||||
|
|
||||||
comment = (EmptyString(LOCAL_COPY(parv[3]))) ? LOCAL_COPY(parv[2]) : LOCAL_COPY(parv[3]);
|
comment = (EmptyString(LOCAL_COPY(parv[3]))) ? LOCAL_COPY(parv[2]) : LOCAL_COPY(parv[3]);
|
||||||
if(strlen(comment) > (size_t) TOPICLEN)
|
if(strlen(comment) > (size_t) TOPICLEN)
|
||||||
comment[TOPICLEN] = '\0';
|
comment[TOPICLEN] = '\0';
|
||||||
|
|
||||||
*buf = '\0';
|
*buf = '\0';
|
||||||
if((p = strchr(parv[1], ',')))
|
if((p = strchr(parv[1], ',')))
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
|
|
||||||
name = LOCAL_COPY(parv[1]);
|
name = LOCAL_COPY(parv[1]);
|
||||||
|
|
||||||
chptr = find_channel(name);
|
chptr = find_channel(name);
|
||||||
if(!chptr) {
|
if(!chptr)
|
||||||
sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL, form_str(ERR_NOSUCHCHANNEL), name);
|
{
|
||||||
return 0;
|
sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL, form_str(ERR_NOSUCHCHANNEL), name);
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if((p = strchr(parv[2], ',')))
|
if((p = strchr(parv[2], ',')))
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
user = LOCAL_COPY(parv[2]); // strtoken(&p2, parv[2], ",");
|
user = LOCAL_COPY(parv[2]); // strtoken(&p2, parv[2], ",");
|
||||||
if(!(who = find_chasing(source_p, user, &chasing))) {
|
if(!(who = find_chasing(source_p, user, &chasing)))
|
||||||
return 0;
|
{
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if((target_p = find_client(user)) == NULL) {
|
if((target_p = find_client(user)) == NULL)
|
||||||
sendto_one(source_p, form_str(ERR_NOSUCHNICK), me.name, source_p->name, user);
|
{
|
||||||
return 0;
|
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) {
|
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]);
|
sendto_one(source_p, form_str(ERR_USERNOTINCHANNEL),
|
||||||
return 0;
|
me.name, source_p->name, parv[1], parv[2]);
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
sendto_wallops_flags(UMODE_WALLOP, &me,
|
sendto_wallops_flags(UMODE_WALLOP, &me,
|
||||||
"OKICK called for %s %s by %s!%s@%s",
|
"OKICK called for %s %s by %s!%s@%s",
|
||||||
chptr->chname, target_p->name,
|
chptr->chname, target_p->name,
|
||||||
source_p->name, source_p->username, source_p->host);
|
source_p->name, source_p->username, source_p->host);
|
||||||
ilog(L_MAIN, "OKICK called for %s %s by %s",
|
ilog(L_MAIN, "OKICK called for %s %s by %s",
|
||||||
chptr->chname, target_p->name,
|
chptr->chname, target_p->name,
|
||||||
get_oper_name(source_p));
|
get_oper_name(source_p));
|
||||||
/* only sends stuff for #channels remotely */
|
/* only sends stuff for #channels remotely */
|
||||||
sendto_server(NULL, chptr, NOCAPS, NOCAPS,
|
sendto_server(NULL, chptr, NOCAPS, NOCAPS,
|
||||||
":%s WALLOPS :OKICK called for %s %s by %s!%s@%s",
|
":%s WALLOPS :OKICK called for %s %s by %s!%s@%s",
|
||||||
me.name, chptr->chname, target_p->name,
|
me.name, chptr->chname, target_p->name,
|
||||||
source_p->name, source_p->username, source_p->host);
|
source_p->name, source_p->username, source_p->host);
|
||||||
|
|
||||||
sendto_channel_local(ALL_MEMBERS, chptr, ":%s KICK %s %s :%s",
|
sendto_channel_local(ALL_MEMBERS, chptr, ":%s KICK %s %s :%s",
|
||||||
me.name, chptr->chname, who->name, comment);
|
me.name, chptr->chname, who->name, comment);
|
||||||
sendto_server(&me, chptr, CAP_TS6, NOCAPS,
|
sendto_server(&me, chptr, CAP_TS6, NOCAPS,
|
||||||
":%s KICK %s %s :%s", me.id, chptr->chname, who->id, comment);
|
":%s KICK %s %s :%s", me.id, chptr->chname, who->id, comment);
|
||||||
remove_user_from_channel(msptr);
|
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 */
|
/* we don't need to track NOREJOIN stuff unless it's our client being kicked */
|
||||||
if(MyClient(who) && chptr->mode.mode & MODE_NOREJOIN)
|
if(MyClient(who) && chptr->mode.mode & MODE_NOREJOIN)
|
||||||
channel_metadata_time_add(chptr, text, rb_current_time(), "KICKNOREJOIN");
|
channel_metadata_time_add(chptr, text, rb_current_time(), "KICKNOREJOIN");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,8 +46,8 @@ static int mo_olist(struct Client *, struct Client *, int parc, const char *parv
|
||||||
#ifndef STATIC_MODULES
|
#ifndef STATIC_MODULES
|
||||||
|
|
||||||
struct Message olist_msgtab = {
|
struct Message olist_msgtab = {
|
||||||
"OLIST", 0, 0, 0, MFLG_SLOW,
|
"OLIST", 0, 0, 0, MFLG_SLOW,
|
||||||
{mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_olist, 1}}
|
{mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_olist, 1}}
|
||||||
};
|
};
|
||||||
|
|
||||||
mapi_clist_av1 olist_clist[] = { &olist_msgtab, NULL };
|
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
|
static int
|
||||||
mo_olist(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
mo_olist(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
||||||
{
|
{
|
||||||
if(!IsOperSpy(source_p)) {
|
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(ERR_NOPRIVS),
|
||||||
sendto_one(source_p, form_str(RPL_LISTEND),
|
me.name, source_p->name, "oper_spy");
|
||||||
me.name, source_p->name);
|
sendto_one(source_p, form_str(RPL_LISTEND),
|
||||||
return 0;
|
me.name, source_p->name);
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* If no arg, do all channels *whee*, else just one channel */
|
/* If no arg, do all channels *whee*, else just one channel */
|
||||||
if(parc < 2 || EmptyString(parv[1]))
|
if(parc < 2 || EmptyString(parv[1]))
|
||||||
list_all_channels(source_p);
|
list_all_channels(source_p);
|
||||||
else
|
else
|
||||||
list_named_channel(source_p, parv[1]);
|
list_named_channel(source_p, parv[1]);
|
||||||
|
|
||||||
sendto_one(source_p, form_str(RPL_LISTEND), me.name, source_p->name);
|
sendto_one(source_p, form_str(RPL_LISTEND), me.name, source_p->name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -94,23 +95,24 @@ mo_olist(struct Client *client_p, struct Client *source_p, int parc, const char
|
||||||
static void
|
static void
|
||||||
list_all_channels(struct Client *source_p)
|
list_all_channels(struct Client *source_p)
|
||||||
{
|
{
|
||||||
struct Channel *chptr;
|
struct Channel *chptr;
|
||||||
rb_dlink_node *ptr;
|
rb_dlink_node *ptr;
|
||||||
|
|
||||||
report_operspy(source_p, "LIST", NULL);
|
report_operspy(source_p, "LIST", NULL);
|
||||||
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);
|
||||||
|
|
||||||
RB_DLINK_FOREACH(ptr, global_channel_list.head) {
|
RB_DLINK_FOREACH(ptr, global_channel_list.head)
|
||||||
chptr = ptr->data;
|
{
|
||||||
|
chptr = ptr->data;
|
||||||
|
|
||||||
sendto_one(source_p, ":%s 322 %s %s %lu :[%s] %s",
|
sendto_one(source_p, ":%s 322 %s %s %lu :[%s] %s",
|
||||||
me.name, source_p->name, chptr->chname,
|
me.name, source_p->name, chptr->chname,
|
||||||
rb_dlink_list_length(&chptr->members),
|
rb_dlink_list_length(&chptr->members),
|
||||||
channel_modes(chptr, &me),
|
channel_modes(chptr, &me),
|
||||||
chptr->topic == NULL ? "" : chptr->topic);
|
chptr->topic == NULL ? "" : chptr->topic);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -122,28 +124,28 @@ list_all_channels(struct Client *source_p)
|
||||||
static void
|
static void
|
||||||
list_named_channel(struct Client *source_p, const char *name)
|
list_named_channel(struct Client *source_p, const char *name)
|
||||||
{
|
{
|
||||||
struct Channel *chptr;
|
struct Channel *chptr;
|
||||||
char *p;
|
char *p;
|
||||||
char *n = LOCAL_COPY(name);
|
char *n = LOCAL_COPY(name);
|
||||||
|
|
||||||
if((p = strchr(n, ',')))
|
if((p = strchr(n, ',')))
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
|
|
||||||
/* Put operspy notice before any output, but only if channel exists */
|
/* Put operspy notice before any output, but only if channel exists */
|
||||||
chptr = EmptyString(n) ? NULL : find_channel(n);
|
chptr = EmptyString(n) ? NULL : find_channel(n);
|
||||||
if(chptr != NULL)
|
if(chptr != NULL)
|
||||||
report_operspy(source_p, "LIST", chptr->chname);
|
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))
|
if(EmptyString(n))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(chptr == NULL)
|
if(chptr == NULL)
|
||||||
sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL,
|
sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL,
|
||||||
form_str(ERR_NOSUCHCHANNEL), n);
|
form_str(ERR_NOSUCHCHANNEL), n);
|
||||||
else
|
else
|
||||||
sendto_one(source_p, ":%s 322 %s %s %lu :[%s] %s", me.name, source_p->name,
|
sendto_one(source_p, ":%s 322 %s %s %lu :[%s] %s", me.name, source_p->name,
|
||||||
chptr->chname, rb_dlink_list_length(&chptr->members),
|
chptr->chname, rb_dlink_list_length(&chptr->members),
|
||||||
channel_modes(chptr, &me), chptr->topic ? chptr->topic : "");
|
channel_modes(chptr, &me), chptr->topic ? chptr->topic : "");
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,8 +44,8 @@
|
||||||
static int mo_omode(struct Client *, struct Client *, int, const char **);
|
static int mo_omode(struct Client *, struct Client *, int, const char **);
|
||||||
|
|
||||||
struct Message omode_msgtab = {
|
struct Message omode_msgtab = {
|
||||||
"OMODE", 0, 0, 0, MFLG_SLOW,
|
"OMODE", 0, 0, 0, MFLG_SLOW,
|
||||||
{mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_omode, 3}}
|
{mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_omode, 3}}
|
||||||
};
|
};
|
||||||
|
|
||||||
mapi_clist_av1 omode_clist[] = { &omode_msgtab, NULL };
|
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
|
static int
|
||||||
mo_omode(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
mo_omode(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
||||||
{
|
{
|
||||||
struct Channel *chptr = NULL;
|
struct Channel *chptr = NULL;
|
||||||
struct membership *msptr;
|
struct membership *msptr;
|
||||||
char params[512];
|
char params[512];
|
||||||
int i;
|
int i;
|
||||||
int wasonchannel;
|
int wasonchannel;
|
||||||
|
|
||||||
/* admins only */
|
/* admins only */
|
||||||
if(!IsOperAdmin(source_p)) {
|
if(!IsOperAdmin(source_p))
|
||||||
sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "admin");
|
{
|
||||||
return 0;
|
sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "admin");
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Now, try to find the channel in question */
|
/* Now, try to find the channel in question */
|
||||||
if(!IsChanPrefix(parv[1][0]) || !check_channel_name(parv[1])) {
|
if(!IsChanPrefix(parv[1][0]) || !check_channel_name(parv[1]))
|
||||||
sendto_one_numeric(source_p, ERR_BADCHANNAME,
|
{
|
||||||
form_str(ERR_BADCHANNAME), parv[1]);
|
sendto_one_numeric(source_p, ERR_BADCHANNAME,
|
||||||
return 0;
|
form_str(ERR_BADCHANNAME), parv[1]);
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
chptr = find_channel(parv[1]);
|
chptr = find_channel(parv[1]);
|
||||||
|
|
||||||
if(chptr == NULL) {
|
if(chptr == NULL)
|
||||||
sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL,
|
{
|
||||||
form_str(ERR_NOSUCHCHANNEL), parv[1]);
|
sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL,
|
||||||
return 0;
|
form_str(ERR_NOSUCHCHANNEL), parv[1]);
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Now know the channel exists */
|
/* Now know the channel exists */
|
||||||
msptr = find_channel_membership(chptr, source_p);
|
msptr = find_channel_membership(chptr, source_p);
|
||||||
wasonchannel = msptr != NULL;
|
wasonchannel = msptr != NULL;
|
||||||
|
|
||||||
if (is_any_op(msptr)) {
|
if (is_any_op(msptr))
|
||||||
sendto_one_notice(source_p, ":Use a normal MODE you idiot");
|
{
|
||||||
return 0;
|
sendto_one_notice(source_p, ":Use a normal MODE you idiot");
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
params[0] = '\0';
|
params[0] = '\0';
|
||||||
for (i = 2; i < parc; i++) {
|
for (i = 2; i < parc; i++)
|
||||||
if (i != 2)
|
{
|
||||||
rb_strlcat(params, " ", sizeof params);
|
if (i != 2)
|
||||||
rb_strlcat(params, parv[i], sizeof params);
|
rb_strlcat(params, " ", sizeof params);
|
||||||
}
|
rb_strlcat(params, parv[i], sizeof params);
|
||||||
|
}
|
||||||
|
|
||||||
sendto_wallops_flags(UMODE_WALLOP, &me,
|
sendto_wallops_flags(UMODE_WALLOP, &me,
|
||||||
"OMODE called for [%s] [%s] by %s!%s@%s",
|
"OMODE called for [%s] [%s] by %s!%s@%s",
|
||||||
parv[1], params, source_p->name, source_p->username, source_p->host);
|
parv[1], params, source_p->name, source_p->username, source_p->host);
|
||||||
ilog(L_MAIN, "OMODE called for [%s] [%s] by %s",
|
ilog(L_MAIN, "OMODE called for [%s] [%s] by %s",
|
||||||
parv[1], params, get_oper_name(source_p));
|
parv[1], params, get_oper_name(source_p));
|
||||||
|
|
||||||
if(*chptr->chname != '&')
|
if(*chptr->chname != '&')
|
||||||
sendto_server(NULL, NULL, NOCAPS, NOCAPS,
|
sendto_server(NULL, NULL, NOCAPS, NOCAPS,
|
||||||
":%s WALLOPS :OMODE called for [%s] [%s] by %s!%s@%s",
|
":%s WALLOPS :OMODE called for [%s] [%s] by %s!%s@%s",
|
||||||
me.name, parv[1], params, source_p->name, source_p->username,
|
me.name, parv[1], params, source_p->name, source_p->username,
|
||||||
source_p->host);
|
source_p->host);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
set_channel_mode(client_p, source_p->servptr, chptr, msptr,
|
set_channel_mode(client_p, source_p->servptr, chptr, msptr,
|
||||||
parc - 2, parv + 2);
|
parc - 2, parv + 2);
|
||||||
#else
|
#else
|
||||||
if (parc == 4 && !strcmp(parv[2], "+y") && !irccmp(parv[3], source_p->name)) {
|
if (parc == 4 && !strcmp(parv[2], "+y") && !irccmp(parv[3], source_p->name))
|
||||||
/* Ownering themselves */
|
{
|
||||||
if (!wasonchannel) {
|
/* Ownering themselves */
|
||||||
sendto_one_numeric(source_p, ERR_USERNOTINCHANNEL,
|
if (!wasonchannel)
|
||||||
form_str(ERR_USERNOTINCHANNEL), parv[3], chptr->chname);
|
{
|
||||||
return 0;
|
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",
|
else if (parc == 4 && !strcmp(parv[2], "+a") && !irccmp(parv[3], source_p->name))
|
||||||
me.name, parv[1], source_p->name);
|
{
|
||||||
sendto_server(NULL, chptr, CAP_TS6, NOCAPS,
|
/* Admining themselves */
|
||||||
":%s TMODE %ld %s +y %s",
|
if (!wasonchannel)
|
||||||
me.id, (long) chptr->channelts, parv[1],
|
{
|
||||||
source_p->id);
|
sendto_one_numeric(source_p, ERR_USERNOTINCHANNEL,
|
||||||
msptr->flags |= CHFL_OWNER;
|
form_str(ERR_USERNOTINCHANNEL), parv[3], chptr->chname);
|
||||||
} else if (parc == 4 && !strcmp(parv[2], "+a") && !irccmp(parv[3], source_p->name)) {
|
return 0;
|
||||||
/* Admining themselves */
|
}
|
||||||
if (!wasonchannel) {
|
sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +a %s",
|
||||||
sendto_one_numeric(source_p, ERR_USERNOTINCHANNEL,
|
me.name, parv[1], source_p->name);
|
||||||
form_str(ERR_USERNOTINCHANNEL), parv[3], chptr->chname);
|
sendto_server(NULL, chptr, CAP_TS6, NOCAPS,
|
||||||
return 0;
|
":%s TMODE %ld %s +a %s",
|
||||||
}
|
me.id, (long) chptr->channelts, parv[1],
|
||||||
sendto_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +a %s",
|
source_p->id);
|
||||||
me.name, parv[1], source_p->name);
|
msptr->flags |= CHFL_ADMIN;
|
||||||
sendto_server(NULL, chptr, CAP_TS6, NOCAPS,
|
}
|
||||||
":%s TMODE %ld %s +a %s",
|
else if (parc == 4 && !strcmp(parv[2], "+o") && !irccmp(parv[3], source_p->name))
|
||||||
me.id, (long) chptr->channelts, parv[1],
|
{
|
||||||
source_p->id);
|
/* Opping themselves */
|
||||||
msptr->flags |= CHFL_ADMIN;
|
if (!wasonchannel)
|
||||||
} else if (parc == 4 && !strcmp(parv[2], "+o") && !irccmp(parv[3], source_p->name)) {
|
{
|
||||||
/* Opping themselves */
|
sendto_one_numeric(source_p, ERR_USERNOTINCHANNEL,
|
||||||
if (!wasonchannel) {
|
form_str(ERR_USERNOTINCHANNEL), parv[3], chptr->chname);
|
||||||
sendto_one_numeric(source_p, ERR_USERNOTINCHANNEL,
|
return 0;
|
||||||
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_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +o %s",
|
sendto_server(NULL, chptr, CAP_TS6, NOCAPS,
|
||||||
me.name, parv[1], source_p->name);
|
":%s TMODE %ld %s +o %s",
|
||||||
sendto_server(NULL, chptr, CAP_TS6, NOCAPS,
|
me.id, (long) chptr->channelts, parv[1],
|
||||||
":%s TMODE %ld %s +o %s",
|
source_p->id);
|
||||||
me.id, (long) chptr->channelts, parv[1],
|
msptr->flags |= CHFL_CHANOP;
|
||||||
source_p->id);
|
}
|
||||||
msptr->flags |= CHFL_CHANOP;
|
else if (parc == 4 && !strcmp(parv[2], "+h") && !irccmp(parv[3], source_p->name))
|
||||||
} else if (parc == 4 && !strcmp(parv[2], "+h") && !irccmp(parv[3], source_p->name)) {
|
{
|
||||||
/* Halfopping themselves */
|
/* Halfopping themselves */
|
||||||
if (!wasonchannel) {
|
if (!wasonchannel)
|
||||||
sendto_one_numeric(source_p, ERR_USERNOTINCHANNEL,
|
{
|
||||||
form_str(ERR_USERNOTINCHANNEL), parv[3], chptr->chname);
|
sendto_one_numeric(source_p, ERR_USERNOTINCHANNEL,
|
||||||
return 0;
|
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_channel_local(ALL_MEMBERS, chptr, ":%s MODE %s +h %s",
|
||||||
sendto_server(NULL, chptr, CAP_TS6, NOCAPS,
|
me.name, parv[1], source_p->name);
|
||||||
":%s TMODE %ld %s +h %s",
|
sendto_server(NULL, chptr, CAP_TS6, NOCAPS,
|
||||||
me.id, (long) chptr->channelts, parv[1],
|
":%s TMODE %ld %s +h %s",
|
||||||
source_p->id);
|
me.id, (long) chptr->channelts, parv[1],
|
||||||
msptr->flags |= CHFL_HALFOP;
|
source_p->id);
|
||||||
} else if (ConfigChannel.use_owner) {
|
msptr->flags |= CHFL_HALFOP;
|
||||||
/* I hope this is correct.
|
}
|
||||||
* -- Kabaka */
|
else if (ConfigChannel.use_owner)
|
||||||
|
{
|
||||||
|
/* I hope this is correct.
|
||||||
|
* -- Kabaka */
|
||||||
|
|
||||||
/* Hack it so set_channel_mode() will accept */
|
/* Hack it so set_channel_mode() will accept */
|
||||||
if (wasonchannel)
|
if (wasonchannel)
|
||||||
msptr->flags |= CHFL_OWNER;
|
msptr->flags |= CHFL_OWNER;
|
||||||
else {
|
else
|
||||||
add_user_to_channel(chptr, source_p, CHFL_CHANOP);
|
{
|
||||||
msptr = find_channel_membership(chptr, source_p);
|
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,
|
else if (ConfigChannel.use_admin)
|
||||||
parc - 2, parv + 2);
|
{
|
||||||
if (wasonchannel)
|
/* Hack it so set_channel_mode() will accept */
|
||||||
msptr->flags &= ~CHFL_OWNER;
|
if (wasonchannel)
|
||||||
else
|
msptr->flags |= CHFL_ADMIN;
|
||||||
remove_user_from_channel(msptr);
|
else
|
||||||
} else if (ConfigChannel.use_admin) {
|
{
|
||||||
/* Hack it so set_channel_mode() will accept */
|
add_user_to_channel(chptr, source_p, CHFL_CHANOP);
|
||||||
if (wasonchannel)
|
msptr = find_channel_membership(chptr, source_p);
|
||||||
msptr->flags |= CHFL_ADMIN;
|
}
|
||||||
else {
|
set_channel_mode(client_p, source_p, chptr, msptr,
|
||||||
add_user_to_channel(chptr, source_p, CHFL_CHANOP);
|
parc - 2, parv + 2);
|
||||||
msptr = find_channel_membership(chptr, source_p);
|
/* We know they were not opped before and they can't have opped
|
||||||
}
|
* themselves as set_channel_mode() does not allow that
|
||||||
set_channel_mode(client_p, source_p, chptr, msptr,
|
* -- jilles */
|
||||||
parc - 2, parv + 2);
|
if (wasonchannel)
|
||||||
/* We know they were not opped before and they can't have opped
|
msptr->flags &= ~CHFL_ADMIN;
|
||||||
* themselves as set_channel_mode() does not allow that
|
else
|
||||||
* -- jilles */
|
remove_user_from_channel(msptr);
|
||||||
if (wasonchannel)
|
}
|
||||||
msptr->flags &= ~CHFL_ADMIN;
|
else
|
||||||
else
|
{
|
||||||
remove_user_from_channel(msptr);
|
/* CHFL_ADMIN is only useful if admin is enabled
|
||||||
} else {
|
* so hack it with op if it is not. */
|
||||||
/* CHFL_ADMIN is only useful if admin is enabled
|
if (wasonchannel)
|
||||||
* so hack it with op if it is not. */
|
msptr->flags |= CHFL_CHANOP;
|
||||||
if (wasonchannel)
|
else
|
||||||
msptr->flags |= CHFL_CHANOP;
|
{
|
||||||
else {
|
add_user_to_channel(chptr, source_p, CHFL_CHANOP);
|
||||||
add_user_to_channel(chptr, source_p, CHFL_CHANOP);
|
msptr = find_channel_membership(chptr, source_p);
|
||||||
msptr = find_channel_membership(chptr, source_p);
|
}
|
||||||
}
|
set_channel_mode(client_p, source_p, chptr, msptr,
|
||||||
set_channel_mode(client_p, source_p, chptr, msptr,
|
parc - 2, parv + 2);
|
||||||
parc - 2, parv + 2);
|
/* We know they were not opped before and they can't have opped
|
||||||
/* We know they were not opped before and they can't have opped
|
* themselves as set_channel_mode() does not allow that
|
||||||
* themselves as set_channel_mode() does not allow that
|
* -- jilles */
|
||||||
* -- jilles */
|
if (wasonchannel)
|
||||||
if (wasonchannel)
|
msptr->flags &= ~CHFL_CHANOP;
|
||||||
msptr->flags &= ~CHFL_CHANOP;
|
else
|
||||||
else
|
remove_user_from_channel(msptr);
|
||||||
remove_user_from_channel(msptr);
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,8 +37,8 @@
|
||||||
static int mo_opme(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
|
static int mo_opme(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
|
||||||
|
|
||||||
struct Message opme_msgtab = {
|
struct Message opme_msgtab = {
|
||||||
"OPME", 0, 0, 0, MFLG_SLOW,
|
"OPME", 0, 0, 0, MFLG_SLOW,
|
||||||
{mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_opme, 2}}
|
{mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_opme, 2}}
|
||||||
};
|
};
|
||||||
|
|
||||||
mapi_clist_av1 opme_clist[] = { &opme_msgtab, NULL };
|
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
|
static int
|
||||||
mo_opme(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
mo_opme(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
||||||
{
|
{
|
||||||
struct Channel *chptr;
|
struct Channel *chptr;
|
||||||
struct membership *msptr;
|
struct membership *msptr;
|
||||||
rb_dlink_node *ptr;
|
rb_dlink_node *ptr;
|
||||||
|
|
||||||
/* admins only */
|
/* admins only */
|
||||||
if(!IsOperAdmin(source_p)) {
|
if(!IsOperAdmin(source_p))
|
||||||
sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "admin");
|
{
|
||||||
return 0;
|
sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "admin");
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if((chptr = find_channel(parv[1])) == NULL) {
|
if((chptr = find_channel(parv[1])) == NULL)
|
||||||
sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL,
|
{
|
||||||
form_str(ERR_NOSUCHCHANNEL), parv[1]);
|
sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL,
|
||||||
return 0;
|
form_str(ERR_NOSUCHCHANNEL), parv[1]);
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
RB_DLINK_FOREACH(ptr, chptr->members.head) {
|
RB_DLINK_FOREACH(ptr, chptr->members.head)
|
||||||
msptr = ptr->data;
|
{
|
||||||
|
msptr = ptr->data;
|
||||||
|
|
||||||
if(is_chanop(msptr) || is_admin(msptr) || is_owner(msptr)) {
|
if(is_chanop(msptr) || is_admin(msptr) || is_owner(msptr))
|
||||||
sendto_one_notice(source_p, ":%s Channel is not opless", parv[1]);
|
{
|
||||||
return 0;
|
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)
|
if(msptr == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
msptr->flags |= CHFL_CHANOP;
|
msptr->flags |= CHFL_CHANOP;
|
||||||
|
|
||||||
sendto_wallops_flags(UMODE_WALLOP, &me,
|
sendto_wallops_flags(UMODE_WALLOP, &me,
|
||||||
"OPME called for [%s] by %s!%s@%s",
|
"OPME called for [%s] by %s!%s@%s",
|
||||||
parv[1], source_p->name, source_p->username, source_p->host);
|
parv[1], source_p->name, source_p->username, source_p->host);
|
||||||
ilog(L_MAIN, "OPME called for [%s] by %s",
|
ilog(L_MAIN, "OPME called for [%s] by %s",
|
||||||
parv[1], get_oper_name(source_p));
|
parv[1], get_oper_name(source_p));
|
||||||
|
|
||||||
/* dont send stuff for local channels remotely. */
|
/* dont send stuff for local channels remotely. */
|
||||||
if(*chptr->chname != '&') {
|
if(*chptr->chname != '&')
|
||||||
sendto_server(NULL, NULL, NOCAPS, NOCAPS,
|
{
|
||||||
":%s WALLOPS :OPME called for [%s] by %s!%s@%s",
|
sendto_server(NULL, NULL, NOCAPS, NOCAPS,
|
||||||
me.name, parv[1], source_p->name, source_p->username, source_p->host);
|
":%s WALLOPS :OPME called for [%s] by %s!%s@%s",
|
||||||
sendto_server(NULL, chptr, CAP_TS6, NOCAPS, ":%s PART %s", source_p->id, parv[1]);
|
me.name, parv[1], source_p->name, source_p->username, source_p->host);
|
||||||
sendto_server(NULL, chptr, CAP_TS6, NOCAPS,
|
sendto_server(NULL, chptr, CAP_TS6, NOCAPS, ":%s PART %s", source_p->id, parv[1]);
|
||||||
":%s SJOIN %ld %s + :@%s",
|
sendto_server(NULL, chptr, CAP_TS6, NOCAPS,
|
||||||
me.id, (long) chptr->channelts, parv[1], source_p->id);
|
":%s SJOIN %ld %s + :@%s",
|
||||||
}
|
me.id, (long) chptr->channelts, parv[1], source_p->id);
|
||||||
|
}
|
||||||
|
|
||||||
sendto_channel_local(ALL_MEMBERS, chptr,
|
sendto_channel_local(ALL_MEMBERS, chptr,
|
||||||
":%s MODE %s +o %s", me.name, parv[1], source_p->name);
|
":%s MODE %s +o %s", me.name, parv[1], source_p->name);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,56 +39,56 @@ static unsigned int mymode;
|
||||||
static int
|
static int
|
||||||
_modinit(void)
|
_modinit(void)
|
||||||
{
|
{
|
||||||
/* initalize the +N cmode */
|
/* initalize the +N cmode */
|
||||||
mymode = cflag_add('N', chm_simple);
|
mymode = cflag_add('N', chm_simple);
|
||||||
if (mymode == 0)
|
if (mymode == 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_moddeinit(void)
|
_moddeinit(void)
|
||||||
{
|
{
|
||||||
/* orphan the +N cmode on modunload */
|
/* orphan the +N cmode on modunload */
|
||||||
cflag_orphan('N');
|
cflag_orphan('N');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct Message scene_msgtab = {
|
struct Message scene_msgtab = {
|
||||||
"SCENE", 0, 0, 0, MFLG_SLOW,
|
"SCENE", 0, 0, 0, MFLG_SLOW,
|
||||||
{mg_unreg, {m_scene, 3}, mg_ignore, mg_ignore, mg_ignore, {m_scene, 3}}
|
{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 */
|
/* this serves as an alias for people who are used to inspircd/unreal m_roleplay */
|
||||||
struct Message ambiance_msgtab = {
|
struct Message ambiance_msgtab = {
|
||||||
"AMBIANCE", 0, 0, 0, MFLG_SLOW,
|
"AMBIANCE", 0, 0, 0, MFLG_SLOW,
|
||||||
{mg_unreg, {m_scene, 3}, mg_ignore, mg_ignore, mg_ignore, {m_scene, 3}}
|
{mg_unreg, {m_scene, 3}, mg_ignore, mg_ignore, mg_ignore, {m_scene, 3}}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Message fsay_msgtab = {
|
struct Message fsay_msgtab = {
|
||||||
"FSAY", 0, 0, 0, MFLG_SLOW,
|
"FSAY", 0, 0, 0, MFLG_SLOW,
|
||||||
{mg_unreg, {m_npc, 4}, mg_ignore, mg_ignore, mg_ignore, {m_fsay, 4}}
|
{mg_unreg, {m_npc, 4}, mg_ignore, mg_ignore, mg_ignore, {m_fsay, 4}}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Message faction_msgtab = {
|
struct Message faction_msgtab = {
|
||||||
"FACTION", 0, 0, 0, MFLG_SLOW,
|
"FACTION", 0, 0, 0, MFLG_SLOW,
|
||||||
{mg_unreg, {m_npca, 4}, mg_ignore, mg_ignore, mg_ignore, {m_faction, 4}}
|
{mg_unreg, {m_npca, 4}, mg_ignore, mg_ignore, mg_ignore, {m_faction, 4}}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Message npc_msgtab = {
|
struct Message npc_msgtab = {
|
||||||
"NPC", 0, 0, 0, MFLG_SLOW,
|
"NPC", 0, 0, 0, MFLG_SLOW,
|
||||||
{mg_unreg, {m_npc, 4}, mg_ignore, mg_ignore, mg_ignore, {m_npc, 4}}
|
{mg_unreg, {m_npc, 4}, mg_ignore, mg_ignore, mg_ignore, {m_npc, 4}}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Message npca_msgtab = {
|
struct Message npca_msgtab = {
|
||||||
"NPCA", 0, 0, 0, MFLG_SLOW,
|
"NPCA", 0, 0, 0, MFLG_SLOW,
|
||||||
{mg_unreg, {m_npca, 4}, mg_ignore, mg_ignore, mg_ignore, {m_npca, 4}}
|
{mg_unreg, {m_npca, 4}, mg_ignore, mg_ignore, mg_ignore, {m_npca, 4}}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Message roleplay_msgtab = {
|
struct Message roleplay_msgtab = {
|
||||||
"ROLEPLAY", 0, 0, 0, MFLG_SLOW,
|
"ROLEPLAY", 0, 0, 0, MFLG_SLOW,
|
||||||
{mg_ignore, mg_ignore, mg_ignore, mg_ignore, {me_roleplay, 4}, mg_ignore}
|
{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 };
|
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
|
static int
|
||||||
m_scene(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
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]);
|
m_displaymsg(source_p, parv[1], 0, 0, "=Scene=", parv[2]);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
m_fsay(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
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]);
|
m_displaymsg(source_p, parv[1], 0, 0, parv[2], parv[3]);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
m_faction(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
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]);
|
m_displaymsg(source_p, parv[1], 0, 1, parv[2], parv[3]);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
m_npc(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
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]);
|
m_displaymsg(source_p, parv[1], 1, 0, parv[2], parv[3]);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
m_npca(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
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]);
|
m_displaymsg(source_p, parv[1], 1, 1, parv[2], parv[3]);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
m_displaymsg(struct Client *source_p, const char *channel, int underline, int action, const char *nick, const char *text)
|
m_displaymsg(struct Client *source_p, const char *channel, int underline, int action, const char *nick, const char *text)
|
||||||
{
|
{
|
||||||
struct Channel *chptr;
|
struct Channel *chptr;
|
||||||
struct membership *msptr;
|
struct membership *msptr;
|
||||||
char nick2[NICKLEN+1];
|
char nick2[NICKLEN+1];
|
||||||
char *nick3 = rb_strdup(nick);
|
char *nick3 = rb_strdup(nick);
|
||||||
char text2[BUFSIZE];
|
char text2[BUFSIZE];
|
||||||
|
|
||||||
if((chptr = find_channel(channel)) == NULL) {
|
if((chptr = find_channel(channel)) == NULL)
|
||||||
sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL), channel);
|
{
|
||||||
return 0;
|
sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL), channel);
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if(!(msptr = find_channel_membership(chptr, source_p))) {
|
if(!(msptr = find_channel_membership(chptr, source_p)))
|
||||||
sendto_one_numeric(source_p, ERR_NOTONCHANNEL,
|
{
|
||||||
form_str(ERR_NOTONCHANNEL), chptr->chname);
|
sendto_one_numeric(source_p, ERR_NOTONCHANNEL,
|
||||||
return 0;
|
form_str(ERR_NOTONCHANNEL), chptr->chname);
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if(!(chptr->mode.mode & chmode_flags['N'])) {
|
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;
|
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)) {
|
if(!can_send(chptr, source_p, msptr))
|
||||||
sendto_one_numeric(source_p, 573, "%s :Cannot send to channel.", chptr->chname);
|
{
|
||||||
return 0;
|
sendto_one_numeric(source_p, 573, "%s :Cannot send to channel.", chptr->chname);
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* enforce flood stuff on roleplay commands */
|
/* enforce flood stuff on roleplay commands */
|
||||||
if(flood_attack_channel(0, source_p, chptr, chptr->chname))
|
if(flood_attack_channel(0, source_p, chptr, chptr->chname))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* enforce target change on roleplay commands */
|
/* enforce target change on roleplay commands */
|
||||||
if(!is_chanop_voiced(msptr) && !IsOper(source_p) && !add_channel_target(source_p, chptr)) {
|
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);
|
sendto_one(source_p, form_str(ERR_TARGCHANGE),
|
||||||
return 0;
|
me.name, source_p->name, chptr->chname);
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if(underline)
|
if(underline)
|
||||||
snprintf(nick2, sizeof(nick2), "\x1F%s\x1F", strip_unprintable(nick3));
|
rb_snprintf(nick2, sizeof(nick2), "\x1F%s\x1F", strip_unprintable(nick3));
|
||||||
else
|
else
|
||||||
snprintf(nick2, sizeof(nick2), "%s", strip_unprintable(nick3));
|
rb_snprintf(nick2, sizeof(nick2), "%s", strip_unprintable(nick3));
|
||||||
|
|
||||||
/* don't allow nicks to be empty after stripping
|
/* don't allow nicks to be empty after stripping
|
||||||
* this prevents nastiness like fake factions, etc. */
|
* this prevents nastiness like fake factions, etc. */
|
||||||
if(EmptyString(nick3)) {
|
if(EmptyString(nick3))
|
||||||
sendto_one_numeric(source_p, 573, "%s :No visible non-stripped characters in nick.", chptr->chname);
|
{
|
||||||
return 0;
|
sendto_one_numeric(source_p, 573, "%s :No visible non-stripped characters in nick.", chptr->chname);
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if(action)
|
if(action)
|
||||||
snprintf(text2, sizeof(text2), "\1ACTION %s\1", text);
|
rb_snprintf(text2, sizeof(text2), "\1ACTION %s\1", text);
|
||||||
else
|
else
|
||||||
snprintf(text2, sizeof(text2), "%s", text);
|
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_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",
|
sendto_match_servs(source_p, "*", CAP_ENCAP, NOCAPS, "ENCAP * ROLEPLAY %s %s :%s",
|
||||||
channel, nick2, text2);
|
channel, nick2, text2);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
me_roleplay(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
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.
|
/* 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. */
|
* This shouldn't happen but it's best to be on the safe side. */
|
||||||
if((chptr = find_channel(parv[1])) == NULL)
|
if((chptr = find_channel(parv[1])) == NULL)
|
||||||
return 0;
|
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);
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,120 +46,130 @@
|
||||||
static int mo_sendbans(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
|
static int mo_sendbans(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
|
||||||
|
|
||||||
struct Message sendbans_msgtab = {
|
struct Message sendbans_msgtab = {
|
||||||
"SENDBANS", 0, 0, 0, MFLG_SLOW,
|
"SENDBANS", 0, 0, 0, MFLG_SLOW,
|
||||||
{mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_sendbans, 2}}
|
{mg_unreg, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_sendbans, 2}}
|
||||||
};
|
};
|
||||||
|
|
||||||
mapi_clist_av1 sendbans_clist[] = {
|
mapi_clist_av1 sendbans_clist[] = {
|
||||||
&sendbans_msgtab,
|
&sendbans_msgtab,
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
DECLARE_MODULE_AV1(sendbans, NULL, NULL, sendbans_clist, NULL, NULL, "$Revision$");
|
DECLARE_MODULE_AV1(sendbans, NULL, NULL, sendbans_clist, NULL, NULL, "$Revision$");
|
||||||
|
|
||||||
static const char *expand_xline(const char *mask)
|
static const char *expand_xline(const char *mask)
|
||||||
{
|
{
|
||||||
static char buf[512];
|
static char buf[512];
|
||||||
const char *p;
|
const char *p;
|
||||||
char *q;
|
char *q;
|
||||||
|
|
||||||
if (!strchr(mask, ' '))
|
if (!strchr(mask, ' '))
|
||||||
return mask;
|
return mask;
|
||||||
if (strlen(mask) > 250)
|
if (strlen(mask) > 250)
|
||||||
return NULL;
|
return NULL;
|
||||||
p = mask;
|
p = mask;
|
||||||
q = buf;
|
q = buf;
|
||||||
while (*p != '\0') {
|
while (*p != '\0')
|
||||||
if (*p == ' ')
|
{
|
||||||
*q++ = '\\', *q++ = 's';
|
if (*p == ' ')
|
||||||
else
|
*q++ = '\\', *q++ = 's';
|
||||||
*q++ = *p;
|
else
|
||||||
p++;
|
*q++ = *p;
|
||||||
}
|
p++;
|
||||||
*q = '\0';
|
}
|
||||||
return buf;
|
*q = '\0';
|
||||||
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mo_sendbans(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
static int mo_sendbans(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
||||||
{
|
{
|
||||||
struct ConfItem *aconf;
|
struct ConfItem *aconf;
|
||||||
rb_dlink_node *ptr;
|
rb_dlink_node *ptr;
|
||||||
int i, count;
|
int i, count;
|
||||||
const char *target, *mask2;
|
const char *target, *mask2;
|
||||||
struct Client *server_p;
|
struct Client *server_p;
|
||||||
|
|
||||||
if (!IsOperRemoteBan(source_p)) {
|
if (!IsOperRemoteBan(source_p))
|
||||||
sendto_one(source_p, form_str(ERR_NOPRIVS),
|
{
|
||||||
me.name, source_p->name, "remoteban");
|
sendto_one(source_p, form_str(ERR_NOPRIVS),
|
||||||
return 0;
|
me.name, source_p->name, "remoteban");
|
||||||
}
|
return 0;
|
||||||
if (!IsOperXline(source_p)) {
|
}
|
||||||
sendto_one(source_p, form_str(ERR_NOPRIVS),
|
if (!IsOperXline(source_p))
|
||||||
me.name, source_p->name, "xline");
|
{
|
||||||
return 0;
|
sendto_one(source_p, form_str(ERR_NOPRIVS),
|
||||||
}
|
me.name, source_p->name, "xline");
|
||||||
if (!IsOperResv(source_p)) {
|
return 0;
|
||||||
sendto_one(source_p, form_str(ERR_NOPRIVS),
|
}
|
||||||
me.name, source_p->name, "resv");
|
if (!IsOperResv(source_p))
|
||||||
return 0;
|
{
|
||||||
}
|
sendto_one(source_p, form_str(ERR_NOPRIVS),
|
||||||
|
me.name, source_p->name, "resv");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
target = parv[1];
|
target = parv[1];
|
||||||
count = 0;
|
count = 0;
|
||||||
RB_DLINK_FOREACH(ptr, global_serv_list.head) {
|
RB_DLINK_FOREACH(ptr, global_serv_list.head)
|
||||||
server_p = ptr->data;
|
{
|
||||||
if (IsMe(server_p))
|
server_p = ptr->data;
|
||||||
continue;
|
if (IsMe(server_p))
|
||||||
if (match(target, server_p->name))
|
continue;
|
||||||
count++;
|
if (match(target, server_p->name))
|
||||||
}
|
count++;
|
||||||
if (count == 0) {
|
}
|
||||||
sendto_one_numeric(source_p, ERR_NOSUCHSERVER,
|
if (count == 0)
|
||||||
form_str(ERR_NOSUCHSERVER), target);
|
{
|
||||||
return 0;
|
sendto_one_numeric(source_p, ERR_NOSUCHSERVER,
|
||||||
}
|
form_str(ERR_NOSUCHSERVER), target);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
sendto_realops_snomask(SNO_GENERAL, L_NETWIDE,
|
sendto_realops_snomask(SNO_GENERAL, L_NETWIDE,
|
||||||
"%s!%s@%s is sending resvs and xlines to %s",
|
"%s!%s@%s is sending resvs and xlines to %s",
|
||||||
source_p->name, source_p->username, source_p->host,
|
source_p->name, source_p->username, source_p->host,
|
||||||
target);
|
target);
|
||||||
|
|
||||||
RB_DLINK_FOREACH(ptr, resv_conf_list.head) {
|
RB_DLINK_FOREACH(ptr, resv_conf_list.head)
|
||||||
aconf = ptr->data;
|
{
|
||||||
if (aconf->hold)
|
aconf = ptr->data;
|
||||||
continue;
|
if (aconf->hold)
|
||||||
sendto_match_servs(source_p, target,
|
continue;
|
||||||
CAP_ENCAP, NOCAPS,
|
sendto_match_servs(source_p, target,
|
||||||
"ENCAP %s RESV 0 %s 0 :%s",
|
CAP_ENCAP, NOCAPS,
|
||||||
target, aconf->host, aconf->passwd);
|
"ENCAP %s RESV 0 %s 0 :%s",
|
||||||
}
|
target, aconf->host, aconf->passwd);
|
||||||
|
}
|
||||||
|
|
||||||
HASH_WALK(i, R_MAX, ptr, resvTable) {
|
HASH_WALK(i, R_MAX, ptr, resvTable)
|
||||||
aconf = ptr->data;
|
{
|
||||||
if (aconf->hold)
|
aconf = ptr->data;
|
||||||
continue;
|
if (aconf->hold)
|
||||||
sendto_match_servs(source_p, target,
|
continue;
|
||||||
CAP_ENCAP, NOCAPS,
|
sendto_match_servs(source_p, target,
|
||||||
"ENCAP %s RESV 0 %s 0 :%s",
|
CAP_ENCAP, NOCAPS,
|
||||||
target, aconf->host, aconf->passwd);
|
"ENCAP %s RESV 0 %s 0 :%s",
|
||||||
}
|
target, aconf->host, aconf->passwd);
|
||||||
HASH_WALK_END
|
}
|
||||||
|
HASH_WALK_END
|
||||||
|
|
||||||
RB_DLINK_FOREACH(ptr, xline_conf_list.head) {
|
RB_DLINK_FOREACH(ptr, xline_conf_list.head)
|
||||||
aconf = ptr->data;
|
{
|
||||||
if (aconf->hold)
|
aconf = ptr->data;
|
||||||
continue;
|
if (aconf->hold)
|
||||||
mask2 = expand_xline(aconf->host);
|
continue;
|
||||||
if (mask2 == NULL) {
|
mask2 = expand_xline(aconf->host);
|
||||||
sendto_one_notice(source_p, ":Skipping xline [%s]",
|
if (mask2 == NULL)
|
||||||
aconf->host);
|
{
|
||||||
continue;
|
sendto_one_notice(source_p, ":Skipping xline [%s]",
|
||||||
}
|
aconf->host);
|
||||||
sendto_match_servs(source_p, target,
|
continue;
|
||||||
CAP_ENCAP, NOCAPS,
|
}
|
||||||
"ENCAP %s XLINE 0 %s 2 :%s",
|
sendto_match_servs(source_p, target,
|
||||||
target, mask2, aconf->passwd);
|
CAP_ENCAP, NOCAPS,
|
||||||
}
|
"ENCAP %s XLINE 0 %s 2 :%s",
|
||||||
|
target, mask2, aconf->passwd);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,8 +57,8 @@
|
||||||
static int mr_webirc(struct Client *, struct Client *, int, const char **);
|
static int mr_webirc(struct Client *, struct Client *, int, const char **);
|
||||||
|
|
||||||
struct Message webirc_msgtab = {
|
struct Message webirc_msgtab = {
|
||||||
"WEBIRC", 0, 0, 0, MFLG_SLOW | MFLG_UNREG,
|
"WEBIRC", 0, 0, 0, MFLG_SLOW | MFLG_UNREG,
|
||||||
{{mr_webirc, 5}, mg_reg, mg_ignore, mg_ignore, mg_ignore, mg_reg}
|
{{mr_webirc, 5}, mg_reg, mg_ignore, mg_ignore, mg_ignore, mg_reg}
|
||||||
};
|
};
|
||||||
|
|
||||||
mapi_clist_av1 webirc_clist[] = { &webirc_msgtab, NULL };
|
mapi_clist_av1 webirc_clist[] = { &webirc_msgtab, NULL };
|
||||||
|
@ -74,62 +74,68 @@ DECLARE_MODULE_AV1(webirc, NULL, NULL, webirc_clist, NULL, NULL, "$Revision: 207
|
||||||
static int
|
static int
|
||||||
mr_webirc(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
mr_webirc(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
|
||||||
{
|
{
|
||||||
struct ConfItem *aconf;
|
struct ConfItem *aconf;
|
||||||
const char *encr;
|
const char *encr;
|
||||||
|
|
||||||
if (!strchr(parv[4], '.') && !strchr(parv[4], ':')) {
|
if (!strchr(parv[4], '.') && !strchr(parv[4], ':'))
|
||||||
sendto_one(source_p, "NOTICE * :Invalid IP");
|
{
|
||||||
return 0;
|
sendto_one(source_p, "NOTICE * :Invalid IP");
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
aconf = find_address_conf(client_p->host, client_p->sockhost,
|
aconf = find_address_conf(client_p->host, client_p->sockhost,
|
||||||
IsGotId(client_p) ? client_p->username : "webirc",
|
IsGotId(client_p) ? client_p->username : "webirc",
|
||||||
IsGotId(client_p) ? client_p->username : "webirc",
|
IsGotId(client_p) ? client_p->username : "webirc",
|
||||||
(struct sockaddr *) &client_p->localClient->ip,
|
(struct sockaddr *) &client_p->localClient->ip,
|
||||||
client_p->localClient->ip.ss_family, NULL);
|
client_p->localClient->ip.ss_family, NULL);
|
||||||
if (aconf == NULL || !(aconf->status & CONF_CLIENT))
|
if (aconf == NULL || !(aconf->status & CONF_CLIENT))
|
||||||
return 0;
|
return 0;
|
||||||
if (!IsConfDoSpoofIp(aconf) || irccmp(aconf->info.name, "webirc.")) {
|
if (!IsConfDoSpoofIp(aconf) || irccmp(aconf->info.name, "webirc."))
|
||||||
/* XXX */
|
{
|
||||||
sendto_one(source_p, "NOTICE * :Not a CGI:IRC auth block");
|
/* XXX */
|
||||||
return 0;
|
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");
|
if (EmptyString(aconf->passwd))
|
||||||
return 0;
|
{
|
||||||
}
|
sendto_one(source_p, "NOTICE * :CGI:IRC auth blocks must have a password");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (EmptyString(parv[1]))
|
if (EmptyString(parv[1]))
|
||||||
encr = "";
|
encr = "";
|
||||||
else if (IsConfEncrypted(aconf))
|
else if (IsConfEncrypted(aconf))
|
||||||
encr = rb_crypt(parv[1], aconf->passwd);
|
encr = rb_crypt(parv[1], aconf->passwd);
|
||||||
else
|
else
|
||||||
encr = parv[1];
|
encr = parv[1];
|
||||||
|
|
||||||
if (strcmp(encr, aconf->passwd)) {
|
if (strcmp(encr, aconf->passwd))
|
||||||
sendto_one(source_p, "NOTICE * :CGI:IRC password incorrect");
|
{
|
||||||
return 0;
|
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)
|
if(strlen(parv[3]) <= HOSTLEN)
|
||||||
rb_strlcpy(source_p->host, parv[3], sizeof(source_p->host));
|
rb_strlcpy(source_p->host, parv[3], sizeof(source_p->host));
|
||||||
else
|
else
|
||||||
rb_strlcpy(source_p->host, source_p->sockhost, sizeof(source_p->host));
|
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 */
|
/* Check dlines now, klines will be checked on registration */
|
||||||
if((aconf = find_dline((struct sockaddr *)&source_p->localClient->ip,
|
if((aconf = find_dline((struct sockaddr *)&source_p->localClient->ip,
|
||||||
source_p->localClient->ip.ss_family))) {
|
source_p->localClient->ip.ss_family)))
|
||||||
if(!(aconf->status & CONF_EXEMPTDLINE)) {
|
{
|
||||||
exit_client(client_p, source_p, &me, "D-lined");
|
if(!(aconf->status & CONF_EXEMPTDLINE))
|
||||||
return 0;
|
{
|
||||||
}
|
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]);
|
sendto_one(source_p, "NOTICE * :CGI:IRC host/IP set to %s %s", parv[3], parv[4]);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
static void h_nl_umode_changed(hook_data_umode_changed *);
|
static void h_nl_umode_changed(hook_data_umode_changed *);
|
||||||
|
|
||||||
mapi_hfn_list_av1 nl_hfnlist[] = {
|
mapi_hfn_list_av1 nl_hfnlist[] = {
|
||||||
{ "umode_changed", (hookfn) h_nl_umode_changed },
|
{ "umode_changed", (hookfn) h_nl_umode_changed },
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
DECLARE_MODULE_AV1(no_locops, NULL, NULL, NULL, NULL, nl_hfnlist, "$Revision: 3219 $");
|
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
|
static void
|
||||||
h_nl_umode_changed(hook_data_umode_changed *hdata)
|
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) {
|
if (MyClient(source_p) && source_p->umodes & UMODE_LOCOPS)
|
||||||
source_p->umodes &= ~UMODE_LOCOPS;
|
{
|
||||||
}
|
source_p->umodes &= ~UMODE_LOCOPS;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,8 +17,8 @@
|
||||||
static void h_noi_umode_changed(hook_data_umode_changed *);
|
static void h_noi_umode_changed(hook_data_umode_changed *);
|
||||||
|
|
||||||
mapi_hfn_list_av1 noi_hfnlist[] = {
|
mapi_hfn_list_av1 noi_hfnlist[] = {
|
||||||
{ "umode_changed", (hookfn) h_noi_umode_changed },
|
{ "umode_changed", (hookfn) h_noi_umode_changed },
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
DECLARE_MODULE_AV1(no_oper_invis, NULL, NULL, NULL, NULL, noi_hfnlist, "$Revision: 3219 $");
|
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
|
static void
|
||||||
h_noi_umode_changed(hook_data_umode_changed *hdata)
|
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) &&
|
if (MyClient(source_p) && IsOper(source_p) && !IsOperInvis(source_p) &&
|
||||||
IsInvisible(source_p)) {
|
IsInvisible(source_p))
|
||||||
ClearInvisible(source_p);
|
{
|
||||||
/* If they tried /umode +i, complain; do not complain
|
ClearInvisible(source_p);
|
||||||
* if they opered up while invisible -- jilles */
|
/* If they tried /umode +i, complain; do not complain
|
||||||
if (hdata->oldumodes & UMODE_OPER)
|
* if they opered up while invisible -- jilles */
|
||||||
sendto_one_notice(source_p, ":*** Opers may not set themselves invisible");
|
if (hdata->oldumodes & UMODE_OPER)
|
||||||
}
|
sendto_one_notice(source_p, ":*** Opers may not set themselves invisible");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,9 +22,9 @@ static void h_gcn_new_remote_user(struct Client *);
|
||||||
static void h_gcn_client_exit(hook_data_client_exit *);
|
static void h_gcn_client_exit(hook_data_client_exit *);
|
||||||
|
|
||||||
mapi_hfn_list_av1 gcn_hfnlist[] = {
|
mapi_hfn_list_av1 gcn_hfnlist[] = {
|
||||||
{ "new_remote_user", (hookfn) h_gcn_new_remote_user },
|
{ "new_remote_user", (hookfn) h_gcn_new_remote_user },
|
||||||
{ "client_exit", (hookfn) h_gcn_client_exit },
|
{ "client_exit", (hookfn) h_gcn_client_exit },
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
DECLARE_MODULE_AV1(globalconnexit, _modinit, _moddeinit, NULL, NULL, gcn_hfnlist, "$Revision: 1869 $");
|
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
|
static int
|
||||||
_modinit(void)
|
_modinit(void)
|
||||||
{
|
{
|
||||||
/* add the snomask to the available slot */
|
/* add the snomask to the available slot */
|
||||||
snomask_modes['F'] = find_snomask_slot();
|
snomask_modes['F'] = find_snomask_slot();
|
||||||
|
|
||||||
/* show the fact that we are showing user information in /version */
|
/* show the fact that we are showing user information in /version */
|
||||||
opers_see_all_users = 1;
|
opers_see_all_users = 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_moddeinit(void)
|
_moddeinit(void)
|
||||||
{
|
{
|
||||||
/* disable the snomask and remove it from the available list */
|
/* disable the snomask and remove it from the available list */
|
||||||
snomask_modes['F'] = 0;
|
snomask_modes['F'] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
h_gcn_new_remote_user(struct Client *source_p)
|
h_gcn_new_remote_user(struct Client *source_p)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!HasSentEob(source_p->servptr))
|
if (!HasSentEob(source_p->servptr))
|
||||||
return;
|
return;
|
||||||
sendto_realops_snomask_from(snomask_modes['F'], L_ALL, source_p->servptr,
|
sendto_realops_snomask_from(snomask_modes['F'], L_ALL, source_p->servptr,
|
||||||
"Client connecting: %s (%s@%s) [%s] {%s} [%s]",
|
"Client connecting: %s (%s@%s) [%s] {%s} [%s]",
|
||||||
source_p->name, source_p->username, source_p->orighost,
|
source_p->name, source_p->username, source_p->orighost,
|
||||||
show_ip(NULL, source_p) ? source_p->sockhost : "255.255.255.255",
|
show_ip(NULL, source_p) ? source_p->sockhost : "255.255.255.255",
|
||||||
"?", source_p->info);
|
"?", source_p->info);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
h_gcn_client_exit(hook_data_client_exit *hdata)
|
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))
|
if (MyConnect(source_p) || !IsClient(source_p))
|
||||||
return;
|
return;
|
||||||
if (!HasSentEob(source_p->servptr))
|
if (!HasSentEob(source_p->servptr))
|
||||||
return;
|
return;
|
||||||
sendto_realops_snomask_from(snomask_modes['F'], L_ALL, source_p->servptr,
|
sendto_realops_snomask_from(snomask_modes['F'], L_ALL, source_p->servptr,
|
||||||
"Client exiting: %s (%s@%s) [%s] [%s]",
|
"Client exiting: %s (%s@%s) [%s] [%s]",
|
||||||
source_p->name,
|
source_p->name,
|
||||||
source_p->username, source_p->host, hdata->comment,
|
source_p->username, source_p->host, hdata->comment,
|
||||||
show_ip(NULL, source_p) ? source_p->sockhost : "255.255.255.255");
|
show_ip(NULL, source_p) ? source_p->sockhost : "255.255.255.255");
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,8 @@
|
||||||
static void h_gla_client_exit(hook_data_client_exit *);
|
static void h_gla_client_exit(hook_data_client_exit *);
|
||||||
|
|
||||||
mapi_hfn_list_av1 gla_hfnlist[] = {
|
mapi_hfn_list_av1 gla_hfnlist[] = {
|
||||||
{ "client_exit", (hookfn) h_gla_client_exit },
|
{ "client_exit", (hookfn) h_gla_client_exit },
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
DECLARE_MODULE_AV1(globallineactive, NULL, NULL, NULL, NULL, gla_hfnlist, "$Revision: 613 $");
|
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
|
static void
|
||||||
h_gla_client_exit(hook_data_client_exit *hdata)
|
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))
|
if (MyConnect(source_p) || !IsClient(source_p))
|
||||||
return;
|
return;
|
||||||
if (!strcmp(hdata->comment, "Bad user info")) {
|
if (!strcmp(hdata->comment, "Bad user info"))
|
||||||
sendto_realops_snomask_from(SNO_GENERAL, L_ALL, source_p->servptr,
|
{
|
||||||
"XLINE active for %s[%s@%s]",
|
sendto_realops_snomask_from(SNO_GENERAL, L_ALL, source_p->servptr,
|
||||||
source_p->name, source_p->username, source_p->host);
|
"XLINE active for %s[%s@%s]",
|
||||||
} else if (ConfigFileEntry.kline_reason != NULL &&
|
source_p->name, source_p->username, source_p->host);
|
||||||
!strcmp(hdata->comment, ConfigFileEntry.kline_reason)) {
|
}
|
||||||
sendto_realops_snomask_from(SNO_GENERAL, L_ALL, source_p->servptr,
|
else if (ConfigFileEntry.kline_reason != NULL &&
|
||||||
"K/DLINE active for %s[%s@%s]",
|
!strcmp(hdata->comment, ConfigFileEntry.kline_reason))
|
||||||
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,
|
||||||
sendto_realops_snomask_from(SNO_GENERAL, L_ALL, source_p->servptr,
|
"K/DLINE active for %s[%s@%s]",
|
||||||
"K/DLINE active for %s[%s@%s]",
|
source_p->name, source_p->username, source_p->host);
|
||||||
source_p->name, source_p->username, source_p->host);
|
}
|
||||||
} else if (!strncmp(hdata->comment, "Temporary D-line ", 17)) {
|
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]",
|
sendto_realops_snomask_from(SNO_GENERAL, L_ALL, source_p->servptr,
|
||||||
source_p->name, source_p->username, source_p->host);
|
"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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
static void h_sgo_umode_changed(void *);
|
static void h_sgo_umode_changed(void *);
|
||||||
|
|
||||||
mapi_hfn_list_av1 sgo_hfnlist[] = {
|
mapi_hfn_list_av1 sgo_hfnlist[] = {
|
||||||
{ "umode_changed", (hookfn) h_sgo_umode_changed },
|
{ "umode_changed", (hookfn) h_sgo_umode_changed },
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
DECLARE_MODULE_AV1(sno_globaloper, NULL, NULL, NULL, NULL, sgo_hfnlist, "$Revision: 639 $");
|
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
|
static void
|
||||||
h_sgo_umode_changed(void *vdata)
|
h_sgo_umode_changed(void *vdata)
|
||||||
{
|
{
|
||||||
hook_data_umode_changed *data = (hook_data_umode_changed *)vdata;
|
hook_data_umode_changed *data = (hook_data_umode_changed *)vdata;
|
||||||
struct Client *source_p = data->client;
|
struct Client *source_p = data->client;
|
||||||
|
|
||||||
if (MyConnect(source_p) || !HasSentEob(source_p->servptr))
|
if (MyConnect(source_p) || !HasSentEob(source_p->servptr))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!(data->oldumodes & UMODE_OPER) && IsOper(source_p))
|
if (!(data->oldumodes & UMODE_OPER) && IsOper(source_p))
|
||||||
sendto_realops_snomask_from(SNO_GENERAL, L_ALL, source_p->servptr,
|
sendto_realops_snomask_from(SNO_GENERAL, L_ALL, source_p->servptr,
|
||||||
"%s (%s@%s) is now an operator",
|
"%s (%s@%s) is now an operator",
|
||||||
source_p->name, source_p->username, source_p->host);
|
source_p->name, source_p->username, source_p->host);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,23 +20,23 @@
|
||||||
void show_whois(hook_data_client *);
|
void show_whois(hook_data_client *);
|
||||||
|
|
||||||
mapi_hfn_list_av1 whois_hfnlist[] = {
|
mapi_hfn_list_av1 whois_hfnlist[] = {
|
||||||
{"doing_whois", (hookfn) show_whois},
|
{"doing_whois", (hookfn) show_whois},
|
||||||
{"doing_whois_global", (hookfn) show_whois},
|
{"doing_whois_global", (hookfn) show_whois},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
static int
|
static int
|
||||||
init(void)
|
init(void)
|
||||||
{
|
{
|
||||||
snomask_modes['W'] = find_snomask_slot();
|
snomask_modes['W'] = find_snomask_slot();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
fini(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 $");
|
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
|
void
|
||||||
show_whois(hook_data_client *data)
|
show_whois(hook_data_client *data)
|
||||||
{
|
{
|
||||||
struct Client *source_p = data->client;
|
struct Client *source_p = data->client;
|
||||||
struct Client *target_p = data->target;
|
struct Client *target_p = data->target;
|
||||||
|
|
||||||
if(MyClient(target_p) &&
|
if(MyClient(target_p) &&
|
||||||
#ifdef OPERONLY
|
#ifdef OPERONLY
|
||||||
IsOper(target_p) &&
|
IsOper(target_p) &&
|
||||||
#endif
|
#endif
|
||||||
(source_p != target_p) &&
|
(source_p != target_p) &&
|
||||||
(target_p->snomask & snomask_modes['W'])) {
|
(target_p->snomask & snomask_modes['W']))
|
||||||
sendto_one_notice(target_p,
|
{
|
||||||
":*** Notice -- %s (%s@%s) is doing a whois on you [%s]",
|
sendto_one_notice(target_p,
|
||||||
source_p->name,
|
":*** Notice -- %s (%s@%s) is doing a whois on you [%s]",
|
||||||
source_p->username, source_p->host,
|
source_p->name,
|
||||||
source_p->servptr->name);
|
source_p->username, source_p->host,
|
||||||
}
|
source_p->servptr->name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,8 +30,8 @@
|
||||||
void show_admin(hook_data *);
|
void show_admin(hook_data *);
|
||||||
|
|
||||||
mapi_hfn_list_av1 admin_hfnlist[] = {
|
mapi_hfn_list_av1 admin_hfnlist[] = {
|
||||||
{"doing_admin", (hookfn) show_admin},
|
{"doing_admin", (hookfn) show_admin},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
DECLARE_MODULE_AV1(admin_spy, NULL, NULL, NULL, NULL, admin_hfnlist, "$Revision: 498 $");
|
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
|
void
|
||||||
show_admin(hook_data *data)
|
show_admin(hook_data *data)
|
||||||
{
|
{
|
||||||
sendto_realops_snomask(SNO_SPY, L_ALL,
|
sendto_realops_snomask(SNO_SPY, L_ALL,
|
||||||
"admin requested by %s (%s@%s) [%s]",
|
"admin requested by %s (%s@%s) [%s]",
|
||||||
data->client->name, data->client->username,
|
data->client->name, data->client->username,
|
||||||
data->client->host, data->client->servptr->name);
|
data->client->host, data->client->servptr->name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,8 +30,8 @@
|
||||||
void show_info(hook_data *);
|
void show_info(hook_data *);
|
||||||
|
|
||||||
mapi_hfn_list_av1 info_hfnlist[] = {
|
mapi_hfn_list_av1 info_hfnlist[] = {
|
||||||
{"doing_info", (hookfn) show_info},
|
{"doing_info", (hookfn) show_info},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
DECLARE_MODULE_AV1(info_spy, NULL, NULL, NULL, NULL, info_hfnlist, "$Revision: 498 $");
|
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
|
void
|
||||||
show_info(hook_data *data)
|
show_info(hook_data *data)
|
||||||
{
|
{
|
||||||
sendto_realops_snomask(SNO_SPY, L_ALL,
|
sendto_realops_snomask(SNO_SPY, L_ALL,
|
||||||
"info requested by %s (%s@%s) [%s]",
|
"info requested by %s (%s@%s) [%s]",
|
||||||
data->client->name, data->client->username,
|
data->client->name, data->client->username,
|
||||||
data->client->host, data->client->servptr->name);
|
data->client->host, data->client->servptr->name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,8 +30,8 @@
|
||||||
void show_links(hook_data *);
|
void show_links(hook_data *);
|
||||||
|
|
||||||
mapi_hfn_list_av1 links_hfnlist[] = {
|
mapi_hfn_list_av1 links_hfnlist[] = {
|
||||||
{"doing_links", (hookfn) show_links},
|
{"doing_links", (hookfn) show_links},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
DECLARE_MODULE_AV1(links_spy, NULL, NULL, NULL, NULL, links_hfnlist, "$Revision: 498 $");
|
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
|
void
|
||||||
show_links(hook_data *data)
|
show_links(hook_data *data)
|
||||||
{
|
{
|
||||||
const char *mask = data->arg1;
|
const char *mask = data->arg1;
|
||||||
|
|
||||||
sendto_realops_snomask(SNO_SPY, L_ALL,
|
sendto_realops_snomask(SNO_SPY, L_ALL,
|
||||||
"LINKS '%s' requested by %s (%s@%s) [%s]",
|
"LINKS '%s' requested by %s (%s@%s) [%s]",
|
||||||
mask, data->client->name, data->client->username,
|
mask, data->client->name, data->client->username,
|
||||||
data->client->host, data->client->servptr->name);
|
data->client->host, data->client->servptr->name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,8 +30,8 @@
|
||||||
void show_motd(hook_data *);
|
void show_motd(hook_data *);
|
||||||
|
|
||||||
mapi_hfn_list_av1 motd_hfnlist[] = {
|
mapi_hfn_list_av1 motd_hfnlist[] = {
|
||||||
{"doing_motd", (hookfn) show_motd},
|
{"doing_motd", (hookfn) show_motd},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
DECLARE_MODULE_AV1(motd_spy, NULL, NULL, NULL, NULL, motd_hfnlist, "$Revision: 498 $");
|
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
|
void
|
||||||
show_motd(hook_data *data)
|
show_motd(hook_data *data)
|
||||||
{
|
{
|
||||||
sendto_realops_snomask(SNO_SPY, L_ALL,
|
sendto_realops_snomask(SNO_SPY, L_ALL,
|
||||||
"motd requested by %s (%s@%s) [%s]",
|
"motd requested by %s (%s@%s) [%s]",
|
||||||
data->client->name, data->client->username,
|
data->client->name, data->client->username,
|
||||||
data->client->host, data->client->servptr->name);
|
data->client->host, data->client->servptr->name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,8 +30,8 @@
|
||||||
void show_stats(hook_data_int *);
|
void show_stats(hook_data_int *);
|
||||||
|
|
||||||
mapi_hfn_list_av1 stats_hfnlist[] = {
|
mapi_hfn_list_av1 stats_hfnlist[] = {
|
||||||
{"doing_stats", (hookfn) show_stats},
|
{"doing_stats", (hookfn) show_stats},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
DECLARE_MODULE_AV1(stats_spy, NULL, NULL, NULL, NULL, stats_hfnlist, "$Revision: 498 $");
|
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
|
void
|
||||||
show_stats(hook_data_int *data)
|
show_stats(hook_data_int *data)
|
||||||
{
|
{
|
||||||
char statchar = (char) data->arg2;
|
char statchar = (char) data->arg2;
|
||||||
|
|
||||||
if(statchar == 'L' || statchar == 'l') {
|
if(statchar == 'L' || statchar == 'l')
|
||||||
const char *name = data->arg1;
|
{
|
||||||
|
const char *name = data->arg1;
|
||||||
|
|
||||||
if(!EmptyString(name))
|
if(!EmptyString(name))
|
||||||
sendto_realops_snomask(SNO_SPY, L_ALL,
|
sendto_realops_snomask(SNO_SPY, L_ALL,
|
||||||
"STATS %c requested by %s (%s@%s) [%s] on %s",
|
"STATS %c requested by %s (%s@%s) [%s] on %s",
|
||||||
statchar, data->client->name,
|
statchar, data->client->name,
|
||||||
data->client->username,
|
data->client->username,
|
||||||
data->client->host,
|
data->client->host,
|
||||||
data->client->servptr->name, name);
|
data->client->servptr->name, name);
|
||||||
else
|
else
|
||||||
sendto_realops_snomask(SNO_SPY, L_ALL,
|
sendto_realops_snomask(SNO_SPY, L_ALL,
|
||||||
"STATS %c requested by %s (%s@%s) [%s]",
|
"STATS %c requested by %s (%s@%s) [%s]",
|
||||||
statchar, data->client->name,
|
statchar, data->client->name,
|
||||||
data->client->username,
|
data->client->username,
|
||||||
data->client->host, data->client->servptr->name);
|
data->client->host, data->client->servptr->name);
|
||||||
} else {
|
}
|
||||||
sendto_realops_snomask(SNO_SPY, L_ALL,
|
else
|
||||||
"STATS %c requested by %s (%s@%s) [%s]",
|
{
|
||||||
statchar, data->client->name, data->client->username,
|
sendto_realops_snomask(SNO_SPY, L_ALL,
|
||||||
data->client->host, data->client->servptr->name);
|
"STATS %c requested by %s (%s@%s) [%s]",
|
||||||
}
|
statchar, data->client->name, data->client->username,
|
||||||
|
data->client->host, data->client->servptr->name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,8 +30,8 @@
|
||||||
void show_stats_p(hook_data *);
|
void show_stats_p(hook_data *);
|
||||||
|
|
||||||
mapi_hfn_list_av1 stats_p_hfnlist[] = {
|
mapi_hfn_list_av1 stats_p_hfnlist[] = {
|
||||||
{"doing_stats_p", (hookfn) show_stats_p},
|
{"doing_stats_p", (hookfn) show_stats_p},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
DECLARE_MODULE_AV1(stats_p_spy, NULL, NULL, NULL, NULL, stats_p_hfnlist, "$Revision: 498 $");
|
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
|
void
|
||||||
show_stats_p(hook_data *data)
|
show_stats_p(hook_data *data)
|
||||||
{
|
{
|
||||||
sendto_realops_snomask(SNO_SPY, L_ALL,
|
sendto_realops_snomask(SNO_SPY, L_ALL,
|
||||||
"STATS p requested by %s (%s@%s) [%s]",
|
"STATS p requested by %s (%s@%s) [%s]",
|
||||||
data->client->name, data->client->username,
|
data->client->name, data->client->username,
|
||||||
data->client->host, data->client->servptr->name);
|
data->client->host, data->client->servptr->name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,8 +30,8 @@
|
||||||
void show_trace(hook_data_client *);
|
void show_trace(hook_data_client *);
|
||||||
|
|
||||||
mapi_hfn_list_av1 trace_hfnlist[] = {
|
mapi_hfn_list_av1 trace_hfnlist[] = {
|
||||||
{"doing_trace", (hookfn) show_trace},
|
{"doing_trace", (hookfn) show_trace},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
DECLARE_MODULE_AV1(trace_spy, NULL, NULL, NULL, NULL, trace_hfnlist, "$Revision: 498 $");
|
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
|
void
|
||||||
show_trace(hook_data_client *data)
|
show_trace(hook_data_client *data)
|
||||||
{
|
{
|
||||||
if(data->target)
|
if(data->target)
|
||||||
sendto_realops_snomask(SNO_SPY, L_ALL,
|
sendto_realops_snomask(SNO_SPY, L_ALL,
|
||||||
"trace requested by %s (%s@%s) [%s] on %s",
|
"trace requested by %s (%s@%s) [%s] on %s",
|
||||||
data->client->name, data->client->username,
|
data->client->name, data->client->username,
|
||||||
data->client->host, data->client->servptr->name,
|
data->client->host, data->client->servptr->name,
|
||||||
data->target->name);
|
data->target->name);
|
||||||
else
|
else
|
||||||
sendto_realops_snomask(SNO_SPY, L_ALL,
|
sendto_realops_snomask(SNO_SPY, L_ALL,
|
||||||
"trace requested by %s (%s@%s) [%s]",
|
"trace requested by %s (%s@%s) [%s]",
|
||||||
data->client->name, data->client->username,
|
data->client->name, data->client->username,
|
||||||
data->client->host, data->client->servptr->name);
|
data->client->host, data->client->servptr->name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
setuser ircd /home/ircd/run/bin/ircd -foreground
|
|
File diff suppressed because it is too large
Load Diff
|
@ -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> ¶ms) 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> ¶ms) 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> ¶ms) 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> ¶ms) 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)
|
|
|
@ -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
|
|
||||||
*/
|
|
|
@ -26,8 +26,6 @@ NO PARAMETERS:
|
||||||
weakens +i control.
|
weakens +i control.
|
||||||
+z - Op moderated. Messages blocked by +m, +b and +q are instead
|
+z - Op moderated. Messages blocked by +m, +b and +q are instead
|
||||||
sent to ops.
|
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.
|
* +L - Large ban list. Increase maximum number of +beIq entries.
|
||||||
* +P - Permanent. Channel does not disappear when empty.
|
* +P - Permanent. Channel does not disappear when empty.
|
||||||
+F - Free target. Anyone may set forwards to this (otherwise
|
+F - Free target. Anyone may set forwards to this (otherwise
|
||||||
|
|
|
@ -16,7 +16,7 @@ $$servermask - Send a message to a server or set of
|
||||||
$#hostmask - Send a message to users matching the
|
$#hostmask - Send a message to users matching the
|
||||||
hostmask specified.
|
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
|
The nick can be extended to fit into the following
|
||||||
syntax:
|
syntax:
|
||||||
|
|
|
@ -4,4 +4,4 @@ Restarts the IRC server. If a second server name
|
||||||
is provided, remotely restart that server. In this
|
is provided, remotely restart that server. In this
|
||||||
case, both server names must match.
|
case, both server names must match.
|
||||||
|
|
||||||
- Requires Oper Priv: oper:die
|
- Requires Oper Priv: oper:admin
|
||||||
|
|
|
@ -25,6 +25,4 @@ User modes: (* designates that the umode is oper only)
|
||||||
+G - "soft caller id" mode - same as +g but automatically allows
|
+G - "soft caller id" mode - same as +g but automatically allows
|
||||||
anyone who's in a common channel with you to message you.
|
anyone who's in a common channel with you to message you.
|
||||||
+V - Prevents you from receiving invites.
|
+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).
|
+Z - Is connected via SSL (set only on connection).
|
||||||
|
|
|
@ -5,4 +5,4 @@ who are umode +w (including non-opers).
|
||||||
|
|
||||||
Server sent WALLOPS go to all opers who are umode +w.
|
Server sent WALLOPS go to all opers who are umode +w.
|
||||||
|
|
||||||
- Requires Oper Priv: oper:mass_notice
|
- Requires Oper Priv: oper:operwall
|
||||||
|
|
|
@ -24,8 +24,6 @@ NO PARAMETERS:
|
||||||
change nick.
|
change nick.
|
||||||
+g - Free invite. Everyone may invite users. Significantly
|
+g - Free invite. Everyone may invite users. Significantly
|
||||||
weakens +i control.
|
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
|
+z - Op moderated. Messages blocked by +m, +b and +q are instead
|
||||||
sent to ops.
|
sent to ops.
|
||||||
* +L - Large ban list. Increase maximum number of +beIq entries.
|
* +L - Large ban list. Increase maximum number of +beIq entries.
|
||||||
|
|
|
@ -14,8 +14,6 @@ User modes: (? designates that the umode is provided by an extension
|
||||||
+B - Marks you as a bot in /whois.
|
+B - Marks you as a bot in /whois.
|
||||||
+C - Prevents you from receiving CTCPs other than ACTION.
|
+C - Prevents you from receiving CTCPs other than ACTION.
|
||||||
+D - Deaf - ignores all channel messages.
|
+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.
|
+Q - Prevents you from being affected by channel forwarding.
|
||||||
+R - Prevents non accept unidentified users from messaging you.
|
+R - Prevents non accept unidentified users from messaging you.
|
||||||
+G - "soft caller id" mode - same as +g but automatically allows
|
+G - "soft caller id" mode - same as +g but automatically allows
|
||||||
|
|
|
@ -3,16 +3,17 @@
|
||||||
|
|
||||||
void init_bandb(void);
|
void init_bandb(void);
|
||||||
|
|
||||||
typedef enum {
|
typedef enum
|
||||||
BANDB_KLINE,
|
{
|
||||||
BANDB_DLINE,
|
BANDB_KLINE,
|
||||||
BANDB_XLINE,
|
BANDB_DLINE,
|
||||||
BANDB_RESV,
|
BANDB_XLINE,
|
||||||
LAST_BANDB_TYPE
|
BANDB_RESV,
|
||||||
|
LAST_BANDB_TYPE
|
||||||
} bandb_type;
|
} bandb_type;
|
||||||
|
|
||||||
void bandb_add(bandb_type, struct Client *source_p, const char *mask1,
|
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_del(bandb_type, const char *mask1, const char *mask2);
|
||||||
void bandb_rehash_bans(void);
|
void bandb_rehash_bans(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -26,22 +26,22 @@
|
||||||
|
|
||||||
/* A configured DNSBL */
|
/* A configured DNSBL */
|
||||||
struct Blacklist {
|
struct Blacklist {
|
||||||
unsigned int status; /* If CONF_ILLEGAL, delete when no clients */
|
unsigned int status; /* If CONF_ILLEGAL, delete when no clients */
|
||||||
int refcount;
|
int refcount;
|
||||||
int ipv4; /* Does this blacklist support IPv4 lookups? */
|
int ipv4; /* Does this blacklist support IPv4 lookups? */
|
||||||
int ipv6; /* Does this blacklist support IPv6 lookups? */
|
int ipv6; /* Does this blacklist support IPv6 lookups? */
|
||||||
char host[IRCD_RES_HOSTLEN + 1];
|
char host[IRCD_RES_HOSTLEN + 1];
|
||||||
char reject_reason[IRCD_BUFSIZE];
|
char reject_reason[IRCD_BUFSIZE];
|
||||||
unsigned int hits;
|
unsigned int hits;
|
||||||
time_t lastwarning;
|
time_t lastwarning;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* A lookup in progress for a particular DNSBL for a particular client */
|
/* A lookup in progress for a particular DNSBL for a particular client */
|
||||||
struct BlacklistClient {
|
struct BlacklistClient {
|
||||||
struct Blacklist *blacklist;
|
struct Blacklist *blacklist;
|
||||||
struct Client *client_p;
|
struct Client *client_p;
|
||||||
struct DNSQuery dns_query;
|
struct DNSQuery dns_query;
|
||||||
rb_dlink_node node;
|
rb_dlink_node node;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* public interfaces */
|
/* public interfaces */
|
||||||
|
|
|
@ -3,8 +3,7 @@
|
||||||
|
|
||||||
#define HELP_MAX 100
|
#define HELP_MAX 100
|
||||||
|
|
||||||
/* Adjusted to allow wider MOTD */
|
#define CACHELINELEN 81
|
||||||
#define CACHELINELEN 513
|
|
||||||
#define CACHEFILELEN 30
|
#define CACHEFILELEN 30
|
||||||
/* two servernames, a gecos, three spaces, ":1", '\0' */
|
/* two servernames, a gecos, three spaces, ":1", '\0' */
|
||||||
#define LINKSLINELEN (HOSTLEN + HOSTLEN + REALLEN + 6)
|
#define LINKSLINELEN (HOSTLEN + HOSTLEN + REALLEN + 6)
|
||||||
|
@ -14,15 +13,17 @@
|
||||||
|
|
||||||
struct Client;
|
struct Client;
|
||||||
|
|
||||||
struct cachefile {
|
struct cachefile
|
||||||
char name[CACHEFILELEN];
|
{
|
||||||
rb_dlink_list contents;
|
char name[CACHEFILELEN];
|
||||||
int flags;
|
rb_dlink_list contents;
|
||||||
|
int flags;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct cacheline {
|
struct cacheline
|
||||||
char data[CACHELINELEN];
|
{
|
||||||
rb_dlink_node linenode;
|
char data[CACHELINELEN];
|
||||||
|
rb_dlink_node linenode;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct cachefile *user_motd;
|
extern struct cachefile *user_motd;
|
||||||
|
|
|
@ -35,102 +35,110 @@
|
||||||
struct Client;
|
struct Client;
|
||||||
|
|
||||||
/* mode structure for channels */
|
/* mode structure for channels */
|
||||||
struct Mode {
|
struct Mode
|
||||||
unsigned int mode;
|
{
|
||||||
int limit;
|
unsigned int mode;
|
||||||
char key[KEYLEN];
|
int limit;
|
||||||
unsigned int join_num;
|
char key[KEYLEN];
|
||||||
unsigned int join_time;
|
unsigned int join_num;
|
||||||
char forward[LOC_CHANNELLEN + 1];
|
unsigned int join_time;
|
||||||
|
char forward[LOC_CHANNELLEN + 1];
|
||||||
};
|
};
|
||||||
|
|
||||||
/* channel structure */
|
/* channel structure */
|
||||||
struct Channel {
|
struct Channel
|
||||||
rb_dlink_node node;
|
{
|
||||||
struct Mode mode;
|
rb_dlink_node node;
|
||||||
char *mode_lock;
|
struct Mode mode;
|
||||||
char *topic;
|
char *mode_lock;
|
||||||
char *topic_info;
|
char *topic;
|
||||||
time_t topic_time;
|
char *topic_info;
|
||||||
time_t last_knock; /* don't allow knock to flood */
|
time_t topic_time;
|
||||||
|
time_t last_knock; /* don't allow knock to flood */
|
||||||
|
|
||||||
rb_dlink_list members; /* channel members */
|
rb_dlink_list members; /* channel members */
|
||||||
rb_dlink_list locmembers; /* local channel members */
|
rb_dlink_list locmembers; /* local channel members */
|
||||||
|
|
||||||
rb_dlink_list invites;
|
rb_dlink_list invites;
|
||||||
rb_dlink_list banlist;
|
rb_dlink_list banlist;
|
||||||
rb_dlink_list exceptlist;
|
rb_dlink_list exceptlist;
|
||||||
rb_dlink_list invexlist;
|
rb_dlink_list invexlist;
|
||||||
rb_dlink_list quietlist;
|
rb_dlink_list quietlist;
|
||||||
|
|
||||||
time_t first_received_message_time; /* channel flood control */
|
time_t first_received_message_time; /* channel flood control */
|
||||||
int received_number_of_privmsgs;
|
int received_number_of_privmsgs;
|
||||||
int flood_noticed;
|
int flood_noticed;
|
||||||
|
|
||||||
unsigned int join_count; /* joins within delta */
|
unsigned int join_count; /* joins within delta */
|
||||||
unsigned int join_delta; /* last ts of join */
|
unsigned int join_delta; /* last ts of join */
|
||||||
|
|
||||||
struct Dictionary *metadata;
|
struct Dictionary *metadata;
|
||||||
|
|
||||||
unsigned long bants;
|
unsigned long bants;
|
||||||
time_t channelts;
|
time_t channelts;
|
||||||
char *chname;
|
char *chname;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct membership {
|
struct membership
|
||||||
rb_dlink_node channode;
|
{
|
||||||
rb_dlink_node locchannode;
|
rb_dlink_node channode;
|
||||||
rb_dlink_node usernode;
|
rb_dlink_node locchannode;
|
||||||
|
rb_dlink_node usernode;
|
||||||
|
|
||||||
struct Channel *chptr;
|
struct Channel *chptr;
|
||||||
struct Client *client_p;
|
struct Client *client_p;
|
||||||
unsigned int flags;
|
unsigned int flags;
|
||||||
|
|
||||||
unsigned long bants;
|
unsigned long bants;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define BANLEN 195
|
#define BANLEN 195
|
||||||
struct Ban {
|
struct Ban
|
||||||
char *banstr;
|
{
|
||||||
char *who;
|
char *banstr;
|
||||||
time_t when;
|
char *who;
|
||||||
rb_dlink_node node;
|
time_t when;
|
||||||
|
rb_dlink_node node;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct mode_letter {
|
struct mode_letter
|
||||||
int mode;
|
{
|
||||||
char letter;
|
int mode;
|
||||||
|
char letter;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ChModeChange {
|
struct ChModeChange
|
||||||
char letter;
|
{
|
||||||
const char *arg;
|
char letter;
|
||||||
const char *id;
|
const char *arg;
|
||||||
int dir;
|
const char *id;
|
||||||
int caps;
|
int dir;
|
||||||
int nocaps;
|
int caps;
|
||||||
int mems;
|
int nocaps;
|
||||||
int override;
|
int mems;
|
||||||
struct Client *client;
|
int override;
|
||||||
|
struct Client *client;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ChCapCombo {
|
struct ChCapCombo
|
||||||
int count;
|
{
|
||||||
int cap_yes;
|
int count;
|
||||||
int cap_no;
|
int cap_yes;
|
||||||
|
int cap_no;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef void (*ChannelModeFunc)(struct Client *source_p, struct Channel *chptr,
|
typedef void (*ChannelModeFunc)(struct Client *source_p, struct Channel *chptr,
|
||||||
int alevel, int parc, int *parn,
|
int alevel, int parc, int *parn,
|
||||||
const char **parv, int *errors, int dir, char c, long mode_type);
|
const char **parv, int *errors, int dir, char c, long mode_type);
|
||||||
|
|
||||||
struct ChannelMode {
|
struct ChannelMode
|
||||||
ChannelModeFunc set_func;
|
{
|
||||||
long mode_type;
|
ChannelModeFunc set_func;
|
||||||
|
long mode_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef int (*ExtbanFunc)(const char *data, struct Client *client_p,
|
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 */
|
/* can_send results */
|
||||||
#define CAN_SEND_NO 0
|
#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_NOREJOIN 0x200000 /* Block rejoin immediately after kick */
|
||||||
#define MODE_NOREPEAT 0x400000 /* Block repeat messages */
|
#define MODE_NOREPEAT 0x400000 /* Block repeat messages */
|
||||||
#define MODE_NOOPERKICK 0x800000 /* disallow kicking opers */
|
#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_BAN 0x10000000 /* ban channel flag */
|
||||||
#define CHFL_EXCEPTION 0x20000000 /* exception to ban channel flag */
|
#define CHFL_EXCEPTION 0x20000000 /* exception to ban channel flag */
|
||||||
|
@ -225,13 +232,13 @@ void free_ban(struct Ban *bptr);
|
||||||
extern void destroy_channel(struct Channel *);
|
extern void destroy_channel(struct Channel *);
|
||||||
|
|
||||||
extern int can_send(struct Channel *chptr, struct Client *who,
|
extern int can_send(struct Channel *chptr, struct Client *who,
|
||||||
struct membership *);
|
struct membership *);
|
||||||
extern int flood_attack_channel(int p_or_n, struct Client *source_p,
|
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,
|
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,
|
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 int can_join(struct Client *source_p, struct Channel *chptr, char *key);
|
||||||
|
|
||||||
extern struct membership *find_channel_membership(struct Channel *, struct Client *);
|
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 int check_channel_name(const char *name);
|
||||||
|
|
||||||
extern void channel_member_names(struct Channel *chptr, struct Client *,
|
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);
|
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 *);
|
extern void check_splitmode(void *);
|
||||||
|
|
||||||
void set_channel_topic(struct Channel *chptr, const char *topic,
|
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 init_chcap_usage_counts(void);
|
||||||
extern void set_chcap_usage_counts(struct Client *serv_p);
|
extern void set_chcap_usage_counts(struct Client *serv_p);
|
||||||
extern void unset_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,
|
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);
|
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,
|
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,
|
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 struct ChannelMode chmode_table[256];
|
||||||
|
|
||||||
extern int add_id(struct Client *source_p, struct Channel *chptr, const char *banid,
|
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);
|
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 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 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 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 struct Metadata *channel_metadata_find(struct Channel *target, const char *name);
|
||||||
extern void channel_metadata_clear(struct Channel *target);
|
extern void channel_metadata_clear(struct Channel *target);
|
||||||
|
|
||||||
|
|
|
@ -37,50 +37,50 @@
|
||||||
extern int chmode_flags[256];
|
extern int chmode_flags[256];
|
||||||
|
|
||||||
extern void chm_nosuch(struct Client *source_p, struct Channel *chptr,
|
extern void chm_nosuch(struct Client *source_p, struct Channel *chptr,
|
||||||
int alevel, int parc, int *parn,
|
int alevel, int parc, int *parn,
|
||||||
const char **parv, int *errors, int dir, char c, long mode_type);
|
const char **parv, int *errors, int dir, char c, long mode_type);
|
||||||
extern void chm_orphaned(struct Client *source_p, struct Channel *chptr,
|
extern void chm_orphaned(struct Client *source_p, struct Channel *chptr,
|
||||||
int alevel, int parc, int *parn,
|
int alevel, int parc, int *parn,
|
||||||
const char **parv, int *errors, int dir, char c, long mode_type);
|
const char **parv, int *errors, int dir, char c, long mode_type);
|
||||||
extern void chm_simple(struct Client *source_p, struct Channel *chptr,
|
extern void chm_simple(struct Client *source_p, struct Channel *chptr,
|
||||||
int alevel, int parc, int *parn,
|
int alevel, int parc, int *parn,
|
||||||
const char **parv, int *errors, int dir, char c, long mode_type);
|
const char **parv, int *errors, int dir, char c, long mode_type);
|
||||||
extern void chm_ban(struct Client *source_p, struct Channel *chptr,
|
extern void chm_ban(struct Client *source_p, struct Channel *chptr,
|
||||||
int alevel, int parc, int *parn,
|
int alevel, int parc, int *parn,
|
||||||
const char **parv, int *errors, int dir, char c, long mode_type);
|
const char **parv, int *errors, int dir, char c, long mode_type);
|
||||||
extern void chm_hidden(struct Client *source_p, struct Channel *chptr,
|
extern void chm_hidden(struct Client *source_p, struct Channel *chptr,
|
||||||
int alevel, int parc, int *parn,
|
int alevel, int parc, int *parn,
|
||||||
const char **parv, int *errors, int dir, char c, long mode_type);
|
const char **parv, int *errors, int dir, char c, long mode_type);
|
||||||
extern void chm_staff(struct Client *source_p, struct Channel *chptr,
|
extern void chm_staff(struct Client *source_p, struct Channel *chptr,
|
||||||
int alevel, int parc, int *parn,
|
int alevel, int parc, int *parn,
|
||||||
const char **parv, int *errors, int dir, char c, long mode_type);
|
const char **parv, int *errors, int dir, char c, long mode_type);
|
||||||
extern void chm_forward(struct Client *source_p, struct Channel *chptr,
|
extern void chm_forward(struct Client *source_p, struct Channel *chptr,
|
||||||
int alevel, int parc, int *parn,
|
int alevel, int parc, int *parn,
|
||||||
const char **parv, int *errors, int dir, char c, long mode_type);
|
const char **parv, int *errors, int dir, char c, long mode_type);
|
||||||
extern void chm_throttle(struct Client *source_p, struct Channel *chptr,
|
extern void chm_throttle(struct Client *source_p, struct Channel *chptr,
|
||||||
int alevel, int parc, int *parn,
|
int alevel, int parc, int *parn,
|
||||||
const char **parv, int *errors, int dir, char c, long mode_type);
|
const char **parv, int *errors, int dir, char c, long mode_type);
|
||||||
extern void chm_key(struct Client *source_p, struct Channel *chptr,
|
extern void chm_key(struct Client *source_p, struct Channel *chptr,
|
||||||
int alevel, int parc, int *parn,
|
int alevel, int parc, int *parn,
|
||||||
const char **parv, int *errors, int dir, char c, long mode_type);
|
const char **parv, int *errors, int dir, char c, long mode_type);
|
||||||
extern void chm_limit(struct Client *source_p, struct Channel *chptr,
|
extern void chm_limit(struct Client *source_p, struct Channel *chptr,
|
||||||
int alevel, int parc, int *parn,
|
int alevel, int parc, int *parn,
|
||||||
const char **parv, int *errors, int dir, char c, long mode_type);
|
const char **parv, int *errors, int dir, char c, long mode_type);
|
||||||
extern void chm_owner(struct Client *source_p, struct Channel *chptr,
|
extern void chm_owner(struct Client *source_p, struct Channel *chptr,
|
||||||
int alevel, int parc, int *parn,
|
int alevel, int parc, int *parn,
|
||||||
const char **parv, int *errors, int dir, char c, long mode_type);
|
const char **parv, int *errors, int dir, char c, long mode_type);
|
||||||
extern void chm_admin(struct Client *source_p, struct Channel *chptr,
|
extern void chm_admin(struct Client *source_p, struct Channel *chptr,
|
||||||
int alevel, int parc, int *parn,
|
int alevel, int parc, int *parn,
|
||||||
const char **parv, int *errors, int dir, char c, long mode_type);
|
const char **parv, int *errors, int dir, char c, long mode_type);
|
||||||
extern void chm_op(struct Client *source_p, struct Channel *chptr,
|
extern void chm_op(struct Client *source_p, struct Channel *chptr,
|
||||||
int alevel, int parc, int *parn,
|
int alevel, int parc, int *parn,
|
||||||
const char **parv, int *errors, int dir, char c, long mode_type);
|
const char **parv, int *errors, int dir, char c, long mode_type);
|
||||||
extern void chm_halfop(struct Client *source_p, struct Channel *chptr,
|
extern void chm_halfop(struct Client *source_p, struct Channel *chptr,
|
||||||
int alevel, int parc, int *parn,
|
int alevel, int parc, int *parn,
|
||||||
const char **parv, int *errors, int dir, char c, long mode_type);
|
const char **parv, int *errors, int dir, char c, long mode_type);
|
||||||
extern void chm_voice(struct Client *source_p, struct Channel *chptr,
|
extern void chm_voice(struct Client *source_p, struct Channel *chptr,
|
||||||
int alevel, int parc, int *parn,
|
int alevel, int parc, int *parn,
|
||||||
const char **parv, int *errors, int dir, char c, long mode_type);
|
const char **parv, int *errors, int dir, char c, long mode_type);
|
||||||
|
|
||||||
extern unsigned int cflag_add(char c, ChannelModeFunc function);
|
extern unsigned int cflag_add(char c, ChannelModeFunc function);
|
||||||
extern void cflag_orphan(char c);
|
extern void cflag_orphan(char c);
|
||||||
|
|
|
@ -30,21 +30,22 @@ struct ConfItem;
|
||||||
struct Client;
|
struct Client;
|
||||||
struct _patricia_tree_t;
|
struct _patricia_tree_t;
|
||||||
|
|
||||||
struct Class {
|
struct Class
|
||||||
struct Class *next;
|
{
|
||||||
char *class_name;
|
struct Class *next;
|
||||||
int max_total;
|
char *class_name;
|
||||||
int max_local;
|
int max_total;
|
||||||
int max_global;
|
int max_local;
|
||||||
int max_ident;
|
int max_global;
|
||||||
int max_sendq;
|
int max_ident;
|
||||||
int con_freq;
|
int max_sendq;
|
||||||
int ping_freq;
|
int con_freq;
|
||||||
int total;
|
int ping_freq;
|
||||||
rb_patricia_tree_t *ip_limits;
|
int total;
|
||||||
int cidr_ipv4_bitlen;
|
rb_patricia_tree_t *ip_limits;
|
||||||
int cidr_ipv6_bitlen;
|
int cidr_ipv4_bitlen;
|
||||||
int cidr_amount;
|
int cidr_ipv6_bitlen;
|
||||||
|
int cidr_amount;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
365
include/client.h
365
include/client.h
|
@ -76,231 +76,238 @@ struct scache_entry;
|
||||||
/*
|
/*
|
||||||
* Client structures
|
* Client structures
|
||||||
*/
|
*/
|
||||||
struct User {
|
struct User
|
||||||
rb_dlink_list channel; /* chain of channel pointer blocks */
|
{
|
||||||
rb_dlink_list invited; /* chain of invite pointer blocks */
|
rb_dlink_list channel; /* chain of channel pointer blocks */
|
||||||
char *away; /* pointer to away message */
|
rb_dlink_list invited; /* chain of invite pointer blocks */
|
||||||
int refcnt; /* Number of times this block is referenced */
|
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 Server
|
||||||
struct User *user; /* who activated this connection */
|
{
|
||||||
char by[NICKLEN];
|
struct User *user; /* who activated this connection */
|
||||||
rb_dlink_list servers;
|
char by[NICKLEN];
|
||||||
rb_dlink_list users;
|
rb_dlink_list servers;
|
||||||
int caps; /* capabilities bit-field */
|
rb_dlink_list users;
|
||||||
char *fullcaps;
|
int caps; /* capabilities bit-field */
|
||||||
struct scache_entry *nameinfo;
|
char *fullcaps;
|
||||||
|
struct scache_entry *nameinfo;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ZipStats {
|
struct ZipStats
|
||||||
unsigned long long in;
|
{
|
||||||
unsigned long long in_wire;
|
unsigned long long in;
|
||||||
unsigned long long out;
|
unsigned long long in_wire;
|
||||||
unsigned long long out_wire;
|
unsigned long long out;
|
||||||
double in_ratio;
|
unsigned long long out_wire;
|
||||||
double out_ratio;
|
double in_ratio;
|
||||||
|
double out_ratio;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Client {
|
struct Client
|
||||||
rb_dlink_node node;
|
{
|
||||||
rb_dlink_node lnode;
|
rb_dlink_node node;
|
||||||
struct User *user; /* ...defined, if this is a User */
|
rb_dlink_node lnode;
|
||||||
struct Server *serv; /* ...defined, if this is a server */
|
struct User *user; /* ...defined, if this is a User */
|
||||||
struct Client *servptr; /* Points to server this Client is on */
|
struct Server *serv; /* ...defined, if this is a server */
|
||||||
struct Client *from; /* == self, if Local Client, *NEVER* NULL! */
|
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 */
|
struct Whowas *whowas; /* Pointers to whowas structs */
|
||||||
time_t tsinfo; /* TS on the nick, SVINFO on server */
|
time_t tsinfo; /* TS on the nick, SVINFO on server */
|
||||||
unsigned int umodes; /* opers, normal users subset */
|
unsigned int umodes; /* opers, normal users subset */
|
||||||
unsigned int flags; /* client flags */
|
unsigned int flags; /* client flags */
|
||||||
unsigned int flags2; /* ugh. overflow */
|
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 */
|
int hopcount; /* number of servers to this 0 = local */
|
||||||
unsigned short status; /* Client type */
|
unsigned short status; /* Client type */
|
||||||
unsigned char handler; /* Handler index */
|
unsigned char handler; /* Handler index */
|
||||||
unsigned long serial; /* used to enforce 1 send per nick */
|
unsigned long serial; /* used to enforce 1 send per nick */
|
||||||
|
|
||||||
/* client->name is the unique name for a client nick or host */
|
/* client->name is the unique name for a client nick or host */
|
||||||
char name[HOSTLEN + 1];
|
char name[HOSTLEN + 1];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* client->username is the username from ident or the USER message,
|
* client->username is the username from ident or the USER message,
|
||||||
* If the client is idented the USER message is ignored, otherwise
|
* If the client is idented the USER message is ignored, otherwise
|
||||||
* the username part of the USER message is put here prefixed with a
|
* 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
|
* tilde depending on the I:line, Once a client has registered, this
|
||||||
* field should be considered read-only.
|
* field should be considered read-only.
|
||||||
*/
|
*/
|
||||||
char username[USERLEN + 1]; /* client's username */
|
char username[USERLEN + 1]; /* client's username */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* client->host contains the resolved name or ip address
|
* client->host contains the resolved name or ip address
|
||||||
* as a string for the user, it may be fiddled with for oper spoofing etc.
|
* as a string for the user, it may be fiddled with for oper spoofing etc.
|
||||||
*/
|
*/
|
||||||
char host[HOSTLEN + 1]; /* client's hostname */
|
char host[HOSTLEN + 1]; /* client's hostname */
|
||||||
char orighost[HOSTLEN + 1]; /* original hostname (before dynamic spoofing) */
|
char orighost[HOSTLEN + 1]; /* original hostname (before dynamic spoofing) */
|
||||||
char sockhost[HOSTIPLEN + 1]; /* clients ip */
|
char sockhost[HOSTIPLEN + 1]; /* clients ip */
|
||||||
char info[REALLEN + 1]; /* Free form additional client info */
|
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
|
/* list of who has this client on their allow list, its counterpart
|
||||||
* is in LocalUser
|
* is in LocalUser
|
||||||
*/
|
*/
|
||||||
rb_dlink_list on_allow_list;
|
rb_dlink_list on_allow_list;
|
||||||
|
|
||||||
time_t first_received_message_time;
|
time_t first_received_message_time;
|
||||||
int received_number_of_privmsgs;
|
int received_number_of_privmsgs;
|
||||||
int flood_noticed;
|
int flood_noticed;
|
||||||
|
|
||||||
struct LocalUser *localClient;
|
struct LocalUser *localClient;
|
||||||
struct PreClient *preClient;
|
struct PreClient *preClient;
|
||||||
|
|
||||||
time_t large_ctcp_sent; /* ctcp to large group sent, relax flood checks */
|
time_t large_ctcp_sent; /* ctcp to large group sent, relax flood checks */
|
||||||
char *certfp; /* client certificate fingerprint */
|
char *certfp; /* client certificate fingerprint */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct LocalUser {
|
struct LocalUser
|
||||||
rb_dlink_node tnode; /* This is the node for the local list type the client is on*/
|
{
|
||||||
/*
|
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.
|
* 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
|
/* Anti flooding part, all because of lamers... */
|
||||||
|
time_t last_join_time; /* when this client last
|
||||||
joined a channel */
|
joined a channel */
|
||||||
time_t last_leave_time; /* when this client last
|
time_t last_leave_time; /* when this client last
|
||||||
* left a channel */
|
* 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 */
|
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 */
|
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 lasttime; /* last time we parsed something */
|
||||||
time_t firsttime; /* time client was created */
|
time_t firsttime; /* time client was created */
|
||||||
|
|
||||||
/* Send and receive linebuf queues .. */
|
/* Send and receive linebuf queues .. */
|
||||||
buf_head_t buf_sendq;
|
buf_head_t buf_sendq;
|
||||||
buf_head_t buf_recvq;
|
buf_head_t buf_recvq;
|
||||||
/*
|
/*
|
||||||
* we want to use unsigned int here so the sizes have a better chance of
|
* 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
|
* 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
|
* 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,
|
* 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
|
* 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,
|
* performed on these, it's not safe to allow them to become negative,
|
||||||
* which is possible for long running server connections. Unsigned values
|
* which is possible for long running server connections. Unsigned values
|
||||||
* generally overflow gracefully. --Bleep
|
* generally overflow gracefully. --Bleep
|
||||||
*/
|
*/
|
||||||
unsigned int sendM; /* Statistics: protocol messages send */
|
unsigned int sendM; /* Statistics: protocol messages send */
|
||||||
unsigned int sendK; /* Statistics: total k-bytes send */
|
unsigned int sendK; /* Statistics: total k-bytes send */
|
||||||
unsigned int receiveM; /* Statistics: protocol messages received */
|
unsigned int receiveM; /* Statistics: protocol messages received */
|
||||||
unsigned int receiveK; /* Statistics: total k-bytes received */
|
unsigned int receiveK; /* Statistics: total k-bytes received */
|
||||||
unsigned short sendB; /* counters to count upto 1-k lots of bytes */
|
unsigned short sendB; /* counters to count upto 1-k lots of bytes */
|
||||||
unsigned short receiveB; /* sent and received. */
|
unsigned short receiveB; /* sent and received. */
|
||||||
struct Listener *listener; /* listener accepted from */
|
struct Listener *listener; /* listener accepted from */
|
||||||
struct ConfItem *att_conf; /* attached conf */
|
struct ConfItem *att_conf; /* attached conf */
|
||||||
struct server_conf *att_sconf;
|
struct server_conf *att_sconf;
|
||||||
|
|
||||||
struct rb_sockaddr_storage ip;
|
struct rb_sockaddr_storage ip;
|
||||||
time_t last_nick_change;
|
time_t last_nick_change;
|
||||||
int number_of_nick_changes;
|
int number_of_nick_changes;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* XXX - there is no reason to save this, it should be checked when it's
|
* 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
|
* received and not stored, this is not used after registration
|
||||||
*
|
*
|
||||||
* agreed. lets get rid of it someday! --nenolod
|
* agreed. lets get rid of it someday! --nenolod
|
||||||
*/
|
*/
|
||||||
char *passwd;
|
char *passwd;
|
||||||
char *auth_user;
|
char *auth_user;
|
||||||
char *opername; /* name of operator{} block being used or tried (challenge) */
|
char *opername; /* name of operator{} block being used or tried (challenge) */
|
||||||
char *challenge;
|
char *challenge;
|
||||||
char *fullcaps;
|
char *fullcaps;
|
||||||
|
|
||||||
int caps; /* capabilities bit-field */
|
int caps; /* capabilities bit-field */
|
||||||
rb_fde_t *F; /* >= 0, for local clients */
|
rb_fde_t *F; /* >= 0, for local clients */
|
||||||
|
|
||||||
/* time challenge response is valid for */
|
/* time challenge response is valid for */
|
||||||
time_t chal_time;
|
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 next_away; /* Don't allow next away before... */
|
||||||
time_t last;
|
time_t last;
|
||||||
|
|
||||||
/* clients allowed to talk through +g */
|
/* clients allowed to talk through +g */
|
||||||
rb_dlink_list allow_list;
|
rb_dlink_list allow_list;
|
||||||
|
|
||||||
/* nicknames theyre monitoring */
|
/* nicknames theyre monitoring */
|
||||||
rb_dlink_list monitor_list;
|
rb_dlink_list monitor_list;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Anti-flood stuff. We track how many messages were parsed and how
|
* 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
|
* many we were allowed in the current second, and apply a simple decay
|
||||||
* to avoid flooding.
|
* to avoid flooding.
|
||||||
* -- adrian
|
* -- adrian
|
||||||
*/
|
*/
|
||||||
int allow_read; /* how many we're allowed to read in this second */
|
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 actually_read; /* how many we've actually read in this second */
|
||||||
int sent_parsed; /* how many messages we've parsed in this second */
|
int sent_parsed; /* how many messages we've parsed in this second */
|
||||||
time_t last_knock; /* time of last knock */
|
time_t last_knock; /* time of last knock */
|
||||||
unsigned long random_ping;
|
unsigned long random_ping;
|
||||||
struct AuthRequest *auth_request;
|
struct AuthRequest *auth_request;
|
||||||
|
|
||||||
/* target change stuff */
|
/* target change stuff */
|
||||||
/* targets we're aware of (fnv32(use_id(target_p))):
|
/* targets we're aware of (fnv32(use_id(target_p))):
|
||||||
* 0..TGCHANGE_NUM-1 regular slots
|
* 0..TGCHANGE_NUM-1 regular slots
|
||||||
* TGCHANGE_NUM..TGCHANGE_NUM+TGCHANGE_REPLY-1 reply slots
|
* TGCHANGE_NUM..TGCHANGE_NUM+TGCHANGE_REPLY-1 reply slots
|
||||||
*/
|
*/
|
||||||
uint32_t targets[TGCHANGE_NUM + TGCHANGE_REPLY];
|
uint32_t targets[TGCHANGE_NUM + TGCHANGE_REPLY];
|
||||||
unsigned int targets_free; /* free targets */
|
unsigned int targets_free; /* free targets */
|
||||||
time_t target_last; /* last time we cleared a slot */
|
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 */
|
applicable to this client */
|
||||||
|
|
||||||
struct _ssl_ctl *ssl_ctl; /* which ssl daemon we're associate with */
|
struct _ssl_ctl *ssl_ctl; /* which ssl daemon we're associate with */
|
||||||
struct _ssl_ctl *z_ctl; /* second ctl for ssl+zlib */
|
struct _ssl_ctl *z_ctl; /* second ctl for ssl+zlib */
|
||||||
uint32_t localflags;
|
uint32_t localflags;
|
||||||
struct ZipStats *zipstats; /* zipstats */
|
struct ZipStats *zipstats; /* zipstats */
|
||||||
uint16_t cork_count; /* used for corking/uncorking connections */
|
uint16_t cork_count; /* used for corking/uncorking connections */
|
||||||
struct ev_entry *event; /* used for associated events */
|
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 {
|
struct PreClient
|
||||||
char spoofnick[NICKLEN + 1];
|
{
|
||||||
char spoofuser[USERLEN + 1];
|
char spoofnick[NICKLEN + 1];
|
||||||
char spoofhost[HOSTLEN + 1];
|
char spoofuser[USERLEN + 1];
|
||||||
|
char spoofhost[HOSTLEN + 1];
|
||||||
|
|
||||||
char sasl_agent[IDLEN];
|
char sasl_agent[IDLEN];
|
||||||
unsigned char sasl_out;
|
unsigned char sasl_out;
|
||||||
unsigned char sasl_complete;
|
unsigned char sasl_complete;
|
||||||
|
|
||||||
rb_dlink_list dnsbl_queries; /* list of struct BlacklistClient * */
|
rb_dlink_list dnsbl_queries; /* list of struct BlacklistClient * */
|
||||||
struct Blacklist *dnsbl_listed; /* first dnsbl where it's listed */
|
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 {
|
struct ListClient
|
||||||
unsigned int hash_indice;
|
{
|
||||||
unsigned int users_min, users_max;
|
unsigned int hash_indice;
|
||||||
time_t created_min, created_max, topic_min, topic_max;
|
unsigned int users_min, users_max;
|
||||||
int operspy;
|
time_t created_min, created_max, topic_min, topic_max;
|
||||||
|
int operspy;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -402,6 +409,7 @@ struct ListClient {
|
||||||
#define LFLAGS_SSL 0x00000001
|
#define LFLAGS_SSL 0x00000001
|
||||||
#define LFLAGS_FLUSH 0x00000002
|
#define LFLAGS_FLUSH 0x00000002
|
||||||
#define LFLAGS_CORK 0x00000004
|
#define LFLAGS_CORK 0x00000004
|
||||||
|
#define LFLAGS_WEBSOCKET 0x00000008
|
||||||
|
|
||||||
/* umodes, settable flags */
|
/* umodes, settable flags */
|
||||||
/* lots of this moved to snomask -- jilles */
|
/* lots of this moved to snomask -- jilles */
|
||||||
|
@ -419,7 +427,6 @@ struct ListClient {
|
||||||
#define UMODE_NOINVITE 0x0800 /* block invites */
|
#define UMODE_NOINVITE 0x0800 /* block invites */
|
||||||
#define UMODE_BOT 0x8000 /* mark as a bot in whois */
|
#define UMODE_BOT 0x8000 /* mark as a bot in whois */
|
||||||
#define UMODE_SCALLERID 0x40000 /* soft caller id */
|
#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 */
|
/* user information flags, only settable by remote mode or local oper */
|
||||||
#define UMODE_OPER 0x1000 /* Operator */
|
#define UMODE_OPER 0x1000 /* Operator */
|
||||||
|
@ -489,6 +496,10 @@ struct ListClient {
|
||||||
#define SetSSL(x) ((x)->localClient->localflags |= LFLAGS_SSL)
|
#define SetSSL(x) ((x)->localClient->localflags |= LFLAGS_SSL)
|
||||||
#define ClearSSL(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 IsFlush(x) ((x)->localClient->localflags & LFLAGS_FLUSH)
|
||||||
#define SetFlush(x) ((x)->localClient->localflags |= LFLAGS_FLUSH)
|
#define SetFlush(x) ((x)->localClient->localflags |= LFLAGS_FLUSH)
|
||||||
#define ClearFlush(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 allocate_away(struct Client *);
|
||||||
void free_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 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 propagate);
|
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 struct Metadata *user_metadata_find(struct Client *target, const char *name);
|
||||||
extern void user_metadata_clear(struct Client *target);
|
extern void user_metadata_clear(struct Client *target);
|
||||||
|
|
||||||
|
|
|
@ -6,9 +6,10 @@
|
||||||
#ifndef INCLUDED_HOOK_H
|
#ifndef INCLUDED_HOOK_H
|
||||||
#define INCLUDED_HOOK_H
|
#define INCLUDED_HOOK_H
|
||||||
|
|
||||||
typedef struct {
|
typedef struct
|
||||||
char *name;
|
{
|
||||||
rb_dlink_list hooks;
|
char *name;
|
||||||
|
rb_dlink_list hooks;
|
||||||
} hook;
|
} hook;
|
||||||
|
|
||||||
typedef void (*hookfn) (void *data);
|
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 remove_hook(const char *name, hookfn fn);
|
||||||
void call_hook(int id, void *arg);
|
void call_hook(int id, void *arg);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct
|
||||||
struct Client *client;
|
{
|
||||||
const void *arg1;
|
struct Client *client;
|
||||||
const void *arg2;
|
const void *arg1;
|
||||||
|
const void *arg2;
|
||||||
} hook_data;
|
} hook_data;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct
|
||||||
struct Client *client;
|
{
|
||||||
const void *arg1;
|
struct Client *client;
|
||||||
int arg2;
|
const void *arg1;
|
||||||
|
int arg2;
|
||||||
} hook_data_int;
|
} hook_data_int;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct
|
||||||
struct Client *client;
|
{
|
||||||
struct Client *target;
|
struct Client *client;
|
||||||
|
struct Client *target;
|
||||||
} hook_data_client;
|
} hook_data_client;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct
|
||||||
struct Client *client;
|
{
|
||||||
struct Channel *chptr;
|
struct Client *client;
|
||||||
int approved;
|
struct Channel *chptr;
|
||||||
|
int approved;
|
||||||
} hook_data_channel;
|
} hook_data_channel;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct
|
||||||
struct Client *client;
|
{
|
||||||
struct Channel *chptr;
|
struct Client *client;
|
||||||
char *key;
|
struct Channel *chptr;
|
||||||
|
char *key;
|
||||||
} hook_data_channel_activity;
|
} hook_data_channel_activity;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct
|
||||||
struct Client *client;
|
{
|
||||||
struct Channel *chptr;
|
struct Client *client;
|
||||||
struct Client *target;
|
struct Channel *chptr;
|
||||||
int approved;
|
struct Client *target;
|
||||||
|
int approved;
|
||||||
} hook_data_channel_approval;
|
} hook_data_channel_approval;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct
|
||||||
struct Client *client;
|
{
|
||||||
int approved;
|
struct Client *client;
|
||||||
|
int approved;
|
||||||
} hook_data_client_approval;
|
} hook_data_client_approval;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct
|
||||||
struct Client *local_link; /* local client originating this, or NULL */
|
{
|
||||||
struct Client *target; /* dying client */
|
struct Client *local_link; /* local client originating this, or NULL */
|
||||||
struct Client *from; /* causing client (could be &me or target) */
|
struct Client *target; /* dying client */
|
||||||
const char *comment;
|
struct Client *from; /* causing client (could be &me or target) */
|
||||||
|
const char *comment;
|
||||||
} hook_data_client_exit;
|
} hook_data_client_exit;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct
|
||||||
struct Client *client;
|
{
|
||||||
unsigned int oldumodes;
|
struct Client *client;
|
||||||
unsigned int oldsnomask;
|
unsigned int oldumodes;
|
||||||
|
unsigned int oldsnomask;
|
||||||
} hook_data_umode_changed;
|
} hook_data_umode_changed;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -26,28 +26,29 @@
|
||||||
|
|
||||||
#ifndef INCLUDE_hostmask_h
|
#ifndef INCLUDE_hostmask_h
|
||||||
#define INCLUDE_hostmask_h 1
|
#define INCLUDE_hostmask_h 1
|
||||||
enum {
|
enum
|
||||||
HM_HOST,
|
{
|
||||||
HM_IPV4
|
HM_HOST,
|
||||||
|
HM_IPV4
|
||||||
#ifdef RB_IPV6
|
#ifdef RB_IPV6
|
||||||
, HM_IPV6
|
, HM_IPV6
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
int parse_netmask(const char *, struct sockaddr *, int *);
|
int parse_netmask(const char *, struct sockaddr *, int *);
|
||||||
struct ConfItem *find_conf_by_address(const char *host, const char *sockhost,
|
struct ConfItem *find_conf_by_address(const char *host, const char *sockhost,
|
||||||
const char *orighost, struct sockaddr *,
|
const char *orighost, struct sockaddr *,
|
||||||
int, int, const char *, const char *);
|
int, int, const char *, const char *);
|
||||||
struct ConfItem *find_exact_conf_by_address(const char *address, int type,
|
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 add_conf_by_address(const char *, int, const char *, const char *, struct ConfItem *);
|
||||||
void delete_one_address_conf(const char *, struct ConfItem *);
|
void delete_one_address_conf(const char *, struct ConfItem *);
|
||||||
void clear_out_address_conf(void);
|
void clear_out_address_conf(void);
|
||||||
void clear_out_address_conf_bans(void);
|
void clear_out_address_conf_bans(void);
|
||||||
void init_host_hash(void);
|
void init_host_hash(void);
|
||||||
struct ConfItem *find_address_conf(const char *host, const char *sockhost,
|
struct ConfItem *find_address_conf(const char *host, const char *sockhost,
|
||||||
const char *, const char *, struct sockaddr *,
|
const char *, const char *, struct sockaddr *,
|
||||||
int, char *);
|
int, char *);
|
||||||
|
|
||||||
struct ConfItem *find_dline(struct sockaddr *, int);
|
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];
|
extern struct AddressRec *atable[ATABLE_SIZE];
|
||||||
|
|
||||||
struct AddressRec {
|
struct AddressRec
|
||||||
/* masktype: HM_HOST, HM_IPV4, HM_IPV6 -A1kmm */
|
{
|
||||||
int masktype;
|
/* masktype: HM_HOST, HM_IPV4, HM_IPV6 -A1kmm */
|
||||||
|
int masktype;
|
||||||
|
|
||||||
union {
|
union
|
||||||
struct {
|
{
|
||||||
/* Pointer into ConfItem... -A1kmm */
|
struct
|
||||||
struct rb_sockaddr_storage addr;
|
{
|
||||||
int bits;
|
/* Pointer into ConfItem... -A1kmm */
|
||||||
}
|
struct rb_sockaddr_storage addr;
|
||||||
ipa;
|
int bits;
|
||||||
|
}
|
||||||
|
ipa;
|
||||||
|
|
||||||
/* Pointer into ConfItem... -A1kmm */
|
/* Pointer into ConfItem... -A1kmm */
|
||||||
const char *hostname;
|
const char *hostname;
|
||||||
}
|
}
|
||||||
Mask;
|
Mask;
|
||||||
|
|
||||||
/* type: CONF_CLIENT, CONF_DLINE, CONF_KILL etc... -A1kmm */
|
/* type: CONF_CLIENT, CONF_DLINE, CONF_KILL etc... -A1kmm */
|
||||||
int type;
|
int type;
|
||||||
|
|
||||||
/* Higher precedences overrule lower ones... */
|
/* Higher precedences overrule lower ones... */
|
||||||
unsigned long precedence;
|
unsigned long precedence;
|
||||||
|
|
||||||
/* Only checked if !(type & 1)... */
|
/* Only checked if !(type & 1)... */
|
||||||
const char *username;
|
const char *username;
|
||||||
/* Only checked if type == CONF_CLIENT */
|
/* Only checked if type == CONF_CLIENT */
|
||||||
const char *auth_user;
|
const char *auth_user;
|
||||||
struct ConfItem *aconf;
|
struct ConfItem *aconf;
|
||||||
|
|
||||||
/* The next record in this hash bucket. */
|
/* The next record in this hash bucket. */
|
||||||
struct AddressRec *next;
|
struct AddressRec *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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
|
|
@ -30,90 +30,96 @@
|
||||||
static inline char *
|
static inline char *
|
||||||
strip_colour(char *string)
|
strip_colour(char *string)
|
||||||
{
|
{
|
||||||
char *c = string;
|
char *c = string;
|
||||||
char *c2 = string;
|
char *c2 = string;
|
||||||
char *last_non_space = NULL;
|
char *last_non_space = NULL;
|
||||||
|
|
||||||
/* c is source, c2 is target */
|
/* c is source, c2 is target */
|
||||||
for(; c && *c; c++)
|
for(; c && *c; c++)
|
||||||
switch (*c) {
|
switch (*c)
|
||||||
case 3:
|
{
|
||||||
if(isdigit(c[1])) {
|
case 3:
|
||||||
c++;
|
if(isdigit(c[1]))
|
||||||
if(isdigit(c[1]))
|
{
|
||||||
c++;
|
c++;
|
||||||
if(c[1] == ',' && isdigit(c[2])) {
|
if(isdigit(c[1]))
|
||||||
c += 2;
|
c++;
|
||||||
if(isdigit(c[1]))
|
if(c[1] == ',' && isdigit(c[2]))
|
||||||
c++;
|
{
|
||||||
}
|
c += 2;
|
||||||
}
|
if(isdigit(c[1]))
|
||||||
break;
|
c++;
|
||||||
case 2:
|
}
|
||||||
case 6:
|
}
|
||||||
case 7:
|
break;
|
||||||
case 22:
|
case 2:
|
||||||
case 23:
|
case 6:
|
||||||
case 27:
|
case 7:
|
||||||
case 29:
|
case 22:
|
||||||
case 31:
|
case 23:
|
||||||
break;
|
case 27:
|
||||||
case 32:
|
case 29:
|
||||||
*c2++ = *c;
|
case 31:
|
||||||
break;
|
break;
|
||||||
default:
|
case 32:
|
||||||
*c2++ = *c;
|
*c2++ = *c;
|
||||||
last_non_space = c2;
|
break;
|
||||||
break;
|
default:
|
||||||
}
|
*c2++ = *c;
|
||||||
|
last_non_space = c2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
*c2 = '\0';
|
*c2 = '\0';
|
||||||
|
|
||||||
if(last_non_space)
|
if(last_non_space)
|
||||||
*last_non_space = '\0';
|
*last_non_space = '\0';
|
||||||
|
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline char *
|
static inline char *
|
||||||
strip_unprintable(char *string)
|
strip_unprintable(char *string)
|
||||||
{
|
{
|
||||||
char *c = string;
|
char *c = string;
|
||||||
char *c2 = string;
|
char *c2 = string;
|
||||||
char *last_non_space = NULL;
|
char *last_non_space = NULL;
|
||||||
|
|
||||||
/* c is source, c2 is target */
|
/* c is source, c2 is target */
|
||||||
for(; c && *c; c++)
|
for(; c && *c; c++)
|
||||||
switch (*c) {
|
switch (*c)
|
||||||
case 3:
|
{
|
||||||
if(isdigit(c[1])) {
|
case 3:
|
||||||
c++;
|
if(isdigit(c[1]))
|
||||||
if(isdigit(c[1]))
|
{
|
||||||
c++;
|
c++;
|
||||||
if(c[1] == ',' && isdigit(c[2])) {
|
if(isdigit(c[1]))
|
||||||
c += 2;
|
c++;
|
||||||
if(isdigit(c[1]))
|
if(c[1] == ',' && isdigit(c[2]))
|
||||||
c++;
|
{
|
||||||
}
|
c += 2;
|
||||||
}
|
if(isdigit(c[1]))
|
||||||
break;
|
c++;
|
||||||
case 32:
|
}
|
||||||
*c2++ = *c;
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
case 32:
|
||||||
if (*c < 32 && *c >= 0)
|
*c2++ = *c;
|
||||||
break;
|
break;
|
||||||
*c2++ = *c;
|
default:
|
||||||
last_non_space = c2;
|
if (*c < 32)
|
||||||
break;
|
break;
|
||||||
}
|
*c2++ = *c;
|
||||||
|
last_non_space = c2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
*c2 = '\0';
|
*c2 = '\0';
|
||||||
|
|
||||||
if(last_non_space)
|
if(last_non_space)
|
||||||
*last_non_space = '\0';
|
*last_non_space = '\0';
|
||||||
|
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -29,15 +29,17 @@ struct Dictionary; /* defined in src/dictionary.c */
|
||||||
|
|
||||||
typedef int (*DCF)(const char *a, const char *b);
|
typedef int (*DCF)(const char *a, const char *b);
|
||||||
|
|
||||||
struct DictionaryElement {
|
struct DictionaryElement
|
||||||
struct DictionaryElement *left, *right, *prev, *next;
|
{
|
||||||
void *data;
|
struct DictionaryElement *left, *right, *prev, *next;
|
||||||
const char *key;
|
void *data;
|
||||||
int position;
|
const char *key;
|
||||||
|
int position;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DictionaryIter {
|
struct DictionaryIter
|
||||||
struct DictionaryElement *cur, *next;
|
{
|
||||||
|
struct DictionaryElement *cur, *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -63,7 +65,7 @@ extern struct Dictionary *irc_dictionary_create_named(const char *name, DCF comp
|
||||||
* insertions in the DTree structure.
|
* insertions in the DTree structure.
|
||||||
*/
|
*/
|
||||||
extern void irc_dictionary_set_comparator_func(struct Dictionary *dict,
|
extern void irc_dictionary_set_comparator_func(struct Dictionary *dict,
|
||||||
DCF compare_cb);
|
DCF compare_cb);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* irc_dictionary_get_comparator_func() returns the comparator used for lookups and
|
* irc_dictionary_get_comparator_func() returns the comparator used for lookups and
|
||||||
|
@ -82,8 +84,8 @@ extern int irc_dictionary_get_linear_index(struct Dictionary *dict, const char *
|
||||||
* a defined callback function to destroy any data attached to it.
|
* a defined callback function to destroy any data attached to it.
|
||||||
*/
|
*/
|
||||||
extern void irc_dictionary_destroy(struct Dictionary *dtree,
|
extern void irc_dictionary_destroy(struct Dictionary *dtree,
|
||||||
void (*destroy_cb)(struct DictionaryElement *delem, void *privdata),
|
void (*destroy_cb)(struct DictionaryElement *delem, void *privdata),
|
||||||
void *privdata);
|
void *privdata);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* irc_dictionary_foreach() iterates all entries in a dtree, and also optionally calls
|
* irc_dictionary_foreach() iterates all entries in a dtree, and also optionally calls
|
||||||
|
@ -92,8 +94,8 @@ extern void irc_dictionary_destroy(struct Dictionary *dtree,
|
||||||
* To shortcircuit iteration, return non-zero from the callback function.
|
* To shortcircuit iteration, return non-zero from the callback function.
|
||||||
*/
|
*/
|
||||||
extern void irc_dictionary_foreach(struct Dictionary *dtree,
|
extern void irc_dictionary_foreach(struct Dictionary *dtree,
|
||||||
int (*foreach_cb)(struct DictionaryElement *delem, void *privdata),
|
int (*foreach_cb)(struct DictionaryElement *delem, void *privdata),
|
||||||
void *privdata);
|
void *privdata);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* irc_dictionary_search() iterates all entries in a dtree, and also optionally calls
|
* irc_dictionary_search() iterates all entries in a dtree, and also optionally calls
|
||||||
|
@ -103,8 +105,8 @@ extern void irc_dictionary_foreach(struct Dictionary *dtree,
|
||||||
* in that object being returned to the user.
|
* in that object being returned to the user.
|
||||||
*/
|
*/
|
||||||
extern void *irc_dictionary_search(struct Dictionary *dtree,
|
extern void *irc_dictionary_search(struct Dictionary *dtree,
|
||||||
void *(*foreach_cb)(struct DictionaryElement *delem, void *privdata),
|
void *(*foreach_cb)(struct DictionaryElement *delem, void *privdata),
|
||||||
void *privdata);
|
void *privdata);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* irc_dictionary_foreach_start() begins an iteration over all items
|
* irc_dictionary_foreach_start() begins an iteration over all items
|
||||||
|
@ -113,20 +115,20 @@ extern void *irc_dictionary_search(struct Dictionary *dtree,
|
||||||
* of the iteration (but not any other element).
|
* of the iteration (but not any other element).
|
||||||
*/
|
*/
|
||||||
extern void irc_dictionary_foreach_start(struct Dictionary *dtree,
|
extern void irc_dictionary_foreach_start(struct Dictionary *dtree,
|
||||||
struct DictionaryIter *state);
|
struct DictionaryIter *state);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* irc_dictionary_foreach_cur() returns the current element of the iteration,
|
* irc_dictionary_foreach_cur() returns the current element of the iteration,
|
||||||
* or NULL if there are no more elements.
|
* or NULL if there are no more elements.
|
||||||
*/
|
*/
|
||||||
extern void *irc_dictionary_foreach_cur(struct Dictionary *dtree,
|
extern void *irc_dictionary_foreach_cur(struct Dictionary *dtree,
|
||||||
struct DictionaryIter *state);
|
struct DictionaryIter *state);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* irc_dictionary_foreach_next() moves to the next element.
|
* irc_dictionary_foreach_next() moves to the next element.
|
||||||
*/
|
*/
|
||||||
extern void irc_dictionary_foreach_next(struct Dictionary *dtree,
|
extern void irc_dictionary_foreach_next(struct Dictionary *dtree,
|
||||||
struct DictionaryIter *state);
|
struct DictionaryIter *state);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* irc_dictionary_add() adds a key->value entry to the dictionary tree.
|
* irc_dictionary_add() adds a key->value entry to the dictionary tree.
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue