1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-06-12 17:34:46 +02:00

Addition of Unreal3.1-beta3

This commit is contained in:
cmunk
2000-05-28 08:45:32 +00:00
parent 7c8ad67b28
commit 5f49057d01
70 changed files with 23857 additions and 19803 deletions
+304 -124
View File
@@ -1,5 +1,5 @@
esOriginally by Roddy Vagg -- roddy@dal.net Originally by Roddy Vagg -- roddy@dal.net
modified for UnrealIRCD3.0 modified for UnrealIRCD3.1 by codemastr
-------------------- --------------------
@@ -40,7 +40,15 @@ modified for UnrealIRCD3.0
7.7) .......................... Set SHOWOPERS Line 7.7) .......................... Set SHOWOPERS Line
7.8) .......................... Set KILLDIFF Line 7.8) .......................... Set KILLDIFF Line
7.9) .......................... Set SHOWOPERMOTD Line 7.9) .......................... Set SHOWOPERMOTD Line
7.10) .......................... Set HIDE_ULINES Line 7.10).......................... Set HIDE_ULINES Line
7.11).......................... Set ALLOW_CHATOPS Line
7.12).......................... Set SOCKS_BAN_MESSAGE Line
7.13).......................... Set SOCKS_QUIT_MESSAGE Line
7.14).......................... Set SOCKSBANTIME Line
7.15).......................... Set MAXCHANNELSPERUSER Line
7.16).......................... Set WEBTV_SUPPORT Line
7.17).......................... Set NO_OPER_HIDING Line
7.18) ......................... Set AUTO_JOIN_CHANS Line
8) ............................. network files 8) ............................. network files
8.1) .......................... Network Line 8.1) .......................... Network Line
8.2) .......................... Set ircnetwork Line 8.2) .......................... Set ircnetwork Line
@@ -76,8 +84,8 @@ modified for UnrealIRCD3.0
2) ircd.conf Basics: 2) ircd.conf Basics:
When you compile your server, you must specify the correct paths to When you compile your server, you must specify the correct paths to
where you plan on keeping your ircd.conf, for simplicity it is recomended where you plan on keeping your ircd.conf, for simplicity it is recommended
that you keep it in the same diretory as your ircd binary and other ircd that you keep it in the same directory as your ircd binary and other ircd
files. files.
note: You need only supply full pathnames for DPATH and SPATH, the note: You need only supply full pathnames for DPATH and SPATH, the
other defines will only point to files under these directories so you other defines will only point to files under these directories so you
@@ -89,7 +97,7 @@ modified for UnrealIRCD3.0
When you have made your ircd.conf you may check it with the program When you have made your ircd.conf you may check it with the program
`chkconf', this program is supplied with the source code release and will `chkconf', this program is supplied with the source code release and will
be installed into your ircd directory when you run `make install', be installed into your ircd directory when you run `make install',
`chkconf' will check your ircd.conf for errors so is a usefull tool for `chkconf' will check your ircd.conf for errors so is a useful tool for
beginners to ircd.conf. beginners to ircd.conf.
Your ircd.conf will be made up of a series of lines, each line is used Your ircd.conf will be made up of a series of lines, each line is used
for a different purpose in the running of your server, some lines are for a different purpose in the running of your server, some lines are
@@ -97,12 +105,12 @@ modified for UnrealIRCD3.0
start, these lines are listed below. start, these lines are listed below.
You may enter comments in your ircd.conf with the use of a hash mark (#) You may enter comments in your ircd.conf with the use of a hash mark (#)
at the beginning of a line, it is recommended that you make full use of at the beginning of a line, it is recommended that you make full use of
this to add comments to everything you put in your ircd.conf so you dont this to add comments to everything you put in your ircd.conf so you don't
have any problems later. have any problems later.
eg: Put a contact email address and the name/nick of the server admin eg: Put a contact email address and the name/nick of the server admin
above each C/N line pair. above each C/N line pair.
When ircd reads the ircd.conf file, it does it upside down, so lines with When ircd reads the ircd.conf file, it does it upside down, so lines with
higher prefrence should go lower in the file, this will be explained later. higher preference should go lower in the file, this will be explained later.
-------------------- --------------------
@@ -116,7 +124,7 @@ modified for UnrealIRCD3.0
to other servers. (note: you can run ircd stand alone) to other servers. (note: you can run ircd stand alone)
SUGGESTED: it is highly suggested that you use this line SUGGESTED: it is highly suggested that you use this line
OPTIONAL: it's completely up to you whether to define this or not OPTIONAL: it's completely up to you whether to define this or not
DISCOURAGED: you really really should not use this line if at all DISCOURAGED: you really should not use this line if at all
possible. possible.
Note that "*" in a field indicates an "unused" field. Note that "*" in a field indicates an "unused" field.
@@ -126,35 +134,18 @@ modified for UnrealIRCD3.0
3.1) M Lines: [MANDATORY] 3.1) M Lines: [MANDATORY]
This line sets your server's name, description, and port number. This line sets your server's name, description, and port number.
If you are to be a part of DALnet you will be assigned 2 different The standard port number used by most networks and supported by most clients is
DNS entries for your ircd machine, the 1st is for general public use 6667. It is recommended that you specify this as your main port.
and involves: <servername>.DAL.net
The second is for use between servers for identification, these take
the form of: <servername>.[<state>].<country>.DAL.net
If your server is located in the US or Australia, you will be given
a `state' field in your server's real name, otherwise your `state', or
`area' will not be included.
Most IRC networks default to port 6667 for their client connection's,
but DALnet uses port 7000 as its standard, you should compile ircd with
port 7000, not 6667, but you may open up port 6667 (it is recomended
that you do) with a P line (see later). Your M line's port number
should be the same as the number you defined in your config.h at compile
time.
Syntax: Syntax:
M:hostname:IP:Description Of Your Server:7000 M:hostname:IP:Description Of Your Server:6667
The 1st field should be the `real' name of your server, not the short The 1st field should be the `real' name of your server, not the short
name. name.
The 2nd field is the IP the server should bind to - "*" if all interfaces The 2nd field is the IP the server should bind to. Use an "*" to bind to all interfaces on the server. The 3rd field is your server's description, it is up to you what you put in this field, but a short description of its geographic location is recommended. The 4th field is the port number you compiled ircd with. This generally should be 6667.
on the server
The 3rd field is your server's description, it is up to you what you
put in this field, but a short description of its geographic location
is recomended.
The 4th field is the port number you compiled ircd with. This should be
7000 for DALnet.
Example: Example:
M:disney.irc.net::Walt's IRC Server:7000 M:Irc.yournet.com::My first IRC server:6667
-------------------- --------------------
@@ -174,7 +165,7 @@ A:A little info about your server:Admin's nick/real name:contact address
responsible for the server. responsible for the server.
Example: Example:
A:Disney's IRC Server:Admin - Walt Disney:walt@RIP.org A:FooBar IRC Server:Admin - foobar:email - foo@bar.com
-------------------- --------------------
@@ -183,10 +174,8 @@ A:Disney's IRC Server:Admin - Walt Disney:walt@RIP.org
These lines define connection classes. They allow you to fine-tune These lines define connection classes. They allow you to fine-tune
your incomming and outgoing connections, both server and client types. your incomming and outgoing connections, both server and client types.
These classes are for use with C, N, I and O lines, more on this in later These classes are for use with C, N, I and O lines, more on this in later
sections. DALnet has a set of Y lines that each server must use for their sections. Client and server connection classes are your responsibility, you
server connections, these are listed below and again at the bottom of this must make up your own set of Y lines for client connections based on your own
document. Client connection classes are your responsibility, you must
make up your own set of Y lines for client connections based on your own
situation (netwise location, machine, etc). situation (netwise location, machine, etc).
Connection classes define a number of parameters for connections, these Connection classes define a number of parameters for connections, these
include: include:
@@ -210,7 +199,7 @@ A:Disney's IRC Server:Admin - Walt Disney:walt@RIP.org
listed in the server's ircd.conf (see C/N lines) is missing and belongs listed in the server's ircd.conf (see C/N lines) is missing and belongs
on a conenction class that is holding less connections that defined by on a conenction class that is holding less connections that defined by
the max links field, the server will keep on trying to connect to the max links field, the server will keep on trying to connect to
the missing server. The ammount time between connection attempts is what the missing server. The amount time between connection attempts is what
you define in this field. you define in this field.
example: example:
server1 and server2 are listed in server0's ircd.conf but the only server1 and server2 are listed in server0's ircd.conf but the only
@@ -226,10 +215,10 @@ A:Disney's IRC Server:Admin - Walt Disney:walt@RIP.org
class will be allowed as this number on server connection classes is used for class will be allowed as this number on server connection classes is used for
auto-connect purposes. As shown in the above example, when a missing server auto-connect purposes. As shown in the above example, when a missing server
is listed for a particular connection class, and the class is not `full', is listed for a particular connection class, and the class is not `full',
your server will try and connect to this server untill it becomes visible your server will try and connect to this server until it becomes visible
again. Servers being connected manually on a `full' connection class via the again. Servers being connected manually on a `full' connection class via the
/connect command will be allowed as long as you compiled with MAXIMUM_LINKS /connect command will be allowed as long as you compiled with MAXIMUM_LINKS
high enough to accomidate all of your server connections. (you must compile high enough to accommodate all of your server connections. (you must compile
as a HUB if you wish to hold more than one server connection, also see H as a HUB if you wish to hold more than one server connection, also see H
lines later in this document). lines later in this document).
- Maximum sendq: SendQ defines the `que' of data waiting to be sent to the - Maximum sendq: SendQ defines the `que' of data waiting to be sent to the
@@ -242,7 +231,7 @@ A:Disney's IRC Server:Admin - Walt Disney:walt@RIP.org
0, it is `abnormal' for a sendq to be high for a client for a long period 0, it is `abnormal' for a sendq to be high for a client for a long period
of time. When 2 servers connect, they must send their own data to of time. When 2 servers connect, they must send their own data to
eachother, this data includes: all the users on the server and already eachother, this data includes: all the users on the server and already
connected servers, channels, user modes, channel modes, topics (DALnet only) connected servers, channels, user modes, channel modes, topics
etc. When there are many clients on a particular side of the connection, a etc. When there are many clients on a particular side of the connection, a
sendq will build up, especially if the link is slow, or already congested sendq will build up, especially if the link is slow, or already congested
(example: the link from Australia to the US). When the sendq built up reaches (example: the link from Australia to the US). When the sendq built up reaches
@@ -272,7 +261,7 @@ Y:1:90:0:20:10000
The number of clients allowed to use this class is 20. The number of clients allowed to use this class is 20.
Clients may only build up a sendq on the server of 10000 bits. Clients may only build up a sendq on the server of 10000 bits.
These are the standard server Y lines used on DALnet: These are some standard Y:lines that most networks use:
# Connecting a hub to a hub # Connecting a hub to a hub
Y:20:10:300:1:3000000 Y:20:10:300:1:3000000
@@ -288,6 +277,10 @@ Y:45:60:20:1:2200000
Y:42:240:0:0:2200000 Y:42:240:0:0:2200000
# Connecting an AU leaf to a US hub # Connecting an AU leaf to a US hub
Y:43:240:60:1:2200000 Y:43:240:60:1:2200000
# Oper connection class
Y:10:300:0:20:1000000
#User connection class
Y:1:90:0:256:500000
-------------------- --------------------
@@ -298,7 +291,7 @@ Y:43:240:60:1:2200000
may connect, and which connection class they will connect through. may connect, and which connection class they will connect through.
I lines, like C, N and O lines refer back to Y lines, as they allow I lines, like C, N and O lines refer back to Y lines, as they allow
connections, and each connection to ircd needs to be assigned to a connections, and each connection to ircd needs to be assigned to a
connection class. If you dont provide a connection class, the connection connection class. If you don't provide a connection class, the connection
will be governed by the defaults set at compile time in your config.h. will be governed by the defaults set at compile time in your config.h.
When a client connects to the server, it gives its own information, When a client connects to the server, it gives its own information,
this information includes username, nick and can include a password, the this information includes username, nick and can include a password, the
@@ -346,9 +339,9 @@ I:205.133.*::*.toledolink.com::1
address starting with 205.133 OR with a hostname ending in address starting with 205.133 OR with a hostname ending in
.toledolink.com to connect to the server. remember, ircd uses the .toledolink.com to connect to the server. remember, ircd uses the
right-most match, so if I connect as rmiller@glass.toledolink.com right-most match, so if I connect as rmiller@glass.toledolink.com
(which is rmiller@205.133.127.8) I will show up on irc as (which is rmiller@205.133.127.8) I will show up on IRC as
rmiller@glass.toledolink.com since that is the first match it found. rmiller@glass.toledolink.com since that is the first match it found.
(Even though the second match is valid). Any clients comming through (Even though the second match is valid). Any clients coming through
on this line will use connection class 1. on this line will use connection class 1.
I:*@205.133.*::*@*.toledolink.com::1 I:*@205.133.*::*@*.toledolink.com::1
@@ -374,11 +367,11 @@ I:NOMATCH::*@*.de::3
I:NOMATCH::*@*.se::4 I:NOMATCH::*@*.se::4
I:NOMATCH::*@*.au::5 I:NOMATCH::*@*.au::5
I:129.180.*::*.une.edu.au::6 I:129.180.*::*.une.edu.au::6
In this example, conencting clients will 1st be matched against the mask In this example, connecting clients will 1st be matched against the mask
*.une.edu.au, if they match they will be placed on connection class 6 *.une.edu.au, if they match they will be placed on connection class 6
(note: if 6 is full, they will be rejected, they wont be passed on to the (note: if 6 is full, they will be rejected, they wont be passed on to the
next I line), then tried against the IP 129.180.*, if they match, they will next I line), then tried against the IP 129.180.*, if they match, they will
be placed on class 6. If the client dosen't match either of these masks, they be placed on class 6. If the client doesn't match either of these masks, they
will be tried against the mask *.au, so if they are from Australia, but are will be tried against the mask *.au, so if they are from Australia, but are
not from *.une.edu.au they will be placed on class 5. This goes on through not from *.une.edu.au they will be placed on class 5. This goes on through
the other lines, being placed on the various connection classes if they match the other lines, being placed on the various connection classes if they match
@@ -394,12 +387,12 @@ I:129.180.*::*.une.edu.au::6
These lines provide rules as to who may gain Operator status on your server. These lines provide rules as to who may gain Operator status on your server.
O lines are much like I lines in their operation and syntax. O lines are much like I lines in their operation and syntax.
Servers need not have any Operators as ircd, given well defined connection's Servers need not have any Operators as ircd, given well defined connection's
can perform all of its functions automatically. Server admins have the can perform all of its functions automatically. Server admin's have the
ability to `kill -HUP' the server's PID to rehash the config file, removing ability to `kill -HUP' the server's PID to rehash the config file, removing
the need to use the /rehash command. However, a well running network such as the need to use the /rehash command. However, an efficient network needs
DALnet needs operators to oversee the users of the server, and make sure operators to oversee the users of the server, and make sure
users actually enjoy their time on IRC without being continually harrased users actually enjoy their time on IRC without being continually harassed
etc by troublematers. etc by troublemakers.
O lines give users power over the whole network, to use commands O lines give users power over the whole network, to use commands
such as /kill, local Operators only have power on their local server, that such as /kill, local Operators only have power on their local server, that
is, the server where they can use the /oper command to make themselves +o. is, the server where they can use the /oper command to make themselves +o.
@@ -411,41 +404,77 @@ I:129.180.*::*.une.edu.au::6
Syntax: Syntax:
O:hostname:password:nickname::class O:hostname:password:nickname:flags:class
See I lines for rules about the hostname and using ident. See I lines for rules about the hostname and using ident.
If you use ident, a client matching the hostname must have ident running on If you use ident, a client matching the hostname must have ident running on
their host to be able to +o themselves. their host to be able to +o themselves.
If you compiled defining oper passwords to be crypted, you must 1st crypt If you compiled defining oper passwords to be crypted, you must 1st crypt
the plaintext using mkpasswd, a program supplied with the ircd distribution. the plain text using mkpasswd, a program supplied with the ircd distribution.
See src/crypt/README for more information on this. See src/crypt/README for more information on this.
The nickname is the nickname they must pass with the /oper command The nickname is the nickname they must pass with the /oper command
ie: ie:
/oper <nickname> <password> /oper <nickname> <password>
The flags allow you to specify what access an oper will have with great
control. This also allows you to give users Administrator access on your
server. A set of standard FULL ACCESS flags is OaARDNz*^. See below for a
complete list of flags.
The class is the connection class to be used when the user /oper's using The class is the connection class to be used when the user /oper's using
the O line, they connect using the standard I -- Y lines, but when they the O line, they connect using the standard I -- Y lines, but when they
/oper succusfully they are passed across to the new Y line. /oper successfully they are passed across to the new Y line.
Examples: Examples:
O:RIP.org:waltspass:Walt::10 O:RIP.org:waltspass:Walt:OaARD:10
This line will allow anyone on the host RIP.org (running ident or not) to This line will allow anyone on the host RIP.org (running ident or not) to
issue the command `/oper Walt waltspass', at which point they will be moved issue the command `/oper Walt waltspass', at which point they will be moved
over to class 10 and be made usermode +o. over to class 10 and be made an Admin with /restart and /die access.
Valid Flags:
r = access to /rehash server
R = access to /restart server
D = access to /die server
h = oper can send /help ops
g = oper can send /globops
w = oper can send /wallops
l = oper can send /locops
c = access to do local /squits and /connects
L = access to do remote /squits and /connects
k = access to do local /kills
K = access to do global /kills
b = oper can /kline users from server
B = oper can /unkline users from server
n = oper can send local server notices(/notice $servername message)
G = oper can send global server notices(/notce $*.my.net message)
S = oper can join unlimited amount of channels
A = admin
u = oper can set /umode +c
f = oper can set /umode +f
^ = oper can set /umode +I
e = oper can set /umode +e
W = oper can set /umode +W
H = oper gets auto +x on /oper
o = local oper, flags included: rhgwlckbBnuf
O = global oper, flags included: oRDCK
a = services admin, access to /samode
C = co admin
T = tech admin
A = admin
N = network admin access to remote /rehash and remote /restart and a bunch more
* = flags included: AaNCTzSHW^
-------------------- --------------------
3.6) U Lines: [OPTIONAL] 3.6) U Lines: [OPTIONAL]
These lines define which server(s) on the network your server is connected These lines define which server(s) on the network your server is connected
to will be able to `hack' channel modes. to will be able to `hack' channel modes.
On DALnet, services.dal.net is given this power, this allows the server On most networks, services are given this power, this allows the server
to change modes on channels without being a channel operator, the to change modes on channels without being a channel operator, the
commonly used form is ChanServ changing channel modes while not in the commonly used form is ChanServ changing channel modes while not in the
channels. channels.
If you are connected to a network such as DALnet that requires you to have It is very important that you add the U:lines required by your network, because
certain U lines and you don't have them, your server will cause problems if you don't it can lead to desync in channel modes as well as "mode setting
to the other servers when the server(s) that require U lines attempt to wars".
change channel modes.
U lined servers also have the capability to add Akill's to your server, U lined servers also have the capability to add Akill's to your server,
Akill's are much the same as the /kline command except that they show up Akill's are much the same as the /kline command except that they show up
as A: lines on /stats k. as A: lines on /stats k.
@@ -456,11 +485,9 @@ U:servername:*:*
lined server's name. lined server's name.
Example: Example:
U:services.dal.net:: U:services.your.net:*:*
U:services2.dal.net:: This will allow services.your.net to "hack" channel modes and use certain
Both these lines are required on all DALnet server's, they allow servers U:line only commands.
with the name's `services.dal.net' and `services2.dal.net' to hack channel
modes.
-------------------- --------------------
@@ -469,13 +496,13 @@ U:services2.dal.net::
These lines are always used in pairs, one will not work without the other. These lines are always used in pairs, one will not work without the other.
C lines define who your server may connect to, while N lines define what C lines define who your server may connect to, while N lines define what
servers may connect to you. servers may connect to you.
When two servers connect, they both send eachother the `SERVER' command, When two servers connect, they both send each other the `SERVER' command,
this command contains the server name and server info (set by M lines) this command contains the server name and server info (set by M lines)
along with this command is sent a password with the PASS command, C and N along with this command is sent a password with the PASS command, C and N
lines provide a set of rules governing the connection between servers lines provide a set of rules governing the connection between servers
given the details of the server and pass command's. given the details of the server and pass command's.
When one a server initiates the connection, the other server will check When one a server initiates the connection, the other server will check
the details of the incomming server against its N lines, if a match is the details of the incoming server against its N lines, if a match is
found, the server will return the server and pass command's to the found, the server will return the server and pass command's to the
initiating server, which will also check its N lines for a match. initiating server, which will also check its N lines for a match.
For a server to initiate a connection, it must have a C line. C lines For a server to initiate a connection, it must have a C line. C lines
@@ -488,7 +515,7 @@ U:services2.dal.net::
C:remote server's hostname/IP:password:remote server's name:port:class C:remote server's hostname/IP:password:remote server's name:port:class
N:remote server's hostname/IP:password:remote server's name:host mask:class N:remote server's hostname/IP:password:remote server's name:host mask:class
The remote server's hostname/IP should be the location on the internet that The remote server's hostname/IP should be the location on the internet that
the server can be found. IP addresses are prefered as they are more secure, the server can be found. IP addresses are preferred as they are more secure,
and can be a little quicker for the server. As with I and O lines, ident and can be a little quicker for the server. As with I and O lines, ident
can be used with this 1st field to specify the username the ircd on the can be used with this 1st field to specify the username the ircd on the
remote server is running from (if the remote server is running ident), to remote server is running from (if the remote server is running ident), to
@@ -496,10 +523,10 @@ N:remote server's hostname/IP:password:remote server's name:host mask:class
The password should be crypted if you compile ircd specifying that link The password should be crypted if you compile ircd specifying that link
passwords should be crypted. Your link passwords should be very secure, as passwords should be crypted. Your link passwords should be very secure, as
they provide more power, if hacked, than Operator passwords do. However they provide more power, if hacked, than Operator passwords do. However
crypted link passwords can be very akward to keep track of. crypted link passwords can be very awkward to keep track of.
Your C line password is the password used in the pass command, while your Your C line password is the password used in the pass command, while your
N line password will be used to check against the pass command used by N line password will be used to check against the pass command used by
incomming servers. So, your C line password should match the listed incoming servers. So, your C line password should match the listed
server's N line password, and your N line password should match their C server's N line password, and your N line password should match their C
line password. line password.
If you compile your ircd specifying crypted link passwords, you only need If you compile your ircd specifying crypted link passwords, you only need
@@ -513,10 +540,8 @@ N:remote server's hostname/IP:password:remote server's name:host mask:class
with the SERVER command, so it must match the one given. The C and N line with the SERVER command, so it must match the one given. The C and N line
pair should have the same name for this field. pair should have the same name for this field.
The 4th field of C lines may contain the remote servers connection port. The 4th field of C lines may contain the remote servers connection port.
Even though DALnet runs all its servers with a standard port 7000 open, It is not mandatory that you place a port number in this field. If you don't
server -- server connections should be taken place through port 7325. It is give a port number, the server will not try and autoconnect to the listed
not mandatory that you place a port number in this field. If you don't give
a port number, the server will not try and autoconnect to the listed
server. If you do give a port number, the server will only try and server. If you do give a port number, the server will only try and
autoconnect to the listed server if there is enough room on the connection autoconnect to the listed server if there is enough room on the connection
class listed at the end of the C line (connection classes are covered in class listed at the end of the C line (connection classes are covered in
@@ -527,7 +552,7 @@ N:remote server's hostname/IP:password:remote server's name:host mask:class
port number, any /connect command's will use this port unless another port port number, any /connect command's will use this port unless another port
number is given with the command. number is given with the command.
The 4th field of N lines is called the `host mask', this defined how many The 4th field of N lines is called the `host mask', this defined how many
parts of your hostname the incomming server will mask to. So, if your parts of your hostname the incoming server will mask to. So, if your
server's name is disney.us.dal.net, and you want the connecting server to server's name is disney.us.dal.net, and you want the connecting server to
see you as *.us.dal.net you will give a host mask of 1 in your N line. This see you as *.us.dal.net you will give a host mask of 1 in your N line. This
field should normally be left blank. field should normally be left blank.
@@ -535,38 +560,38 @@ N:remote server's hostname/IP:password:remote server's name:host mask:class
place the connection on. If your C line has a 42 in this field, and your place the connection on. If your C line has a 42 in this field, and your
server initiates a connection through this line, the connection will be server initiates a connection through this line, the connection will be
placed on class 42, however, if You have a 42 in your C line and a 43 in placed on class 42, however, if You have a 42 in your C line and a 43 in
your N line and an incomming server initiates a connection via this N your N line and an incoming server initiates a connection via this N
line, the server connection will be placed on class 43. line, the server connection will be placed on class 43.
Examples: Examples:
C:143.53.233.32:mypass:somewhere.fr.dal.net:7325:35 C:143.53.233.32:mypass:somewhere.fr.your.net:7325:35
N:143.53.233.32:yourpass:somewhere.fr.dal.net::35 N:143.53.233.32:yourpass:somewhere.fr.your.net::35
This set will allow a server named somewhere.fr.dal.net to connect to your This set will allow a server named somewhere.fr.dal.net to connect to your
server if it has the IP address of 143.53.233.32 and gives a password of server if it has the IP address of 143.53.233.32 and gives a password of
`yourpass'. This connection will be governed by connection class 35. `yourpass'. This connection will be governed by connection class 35.
If your server recieves the command /connect somewhere.*, it will try and If your server receives the command /connect somewhere.*, it will try and
connect to the IP 143.53.233.32 through port 7325 and give the password connect to the IP 143.53.233.32 through port 7325 and give the password
`mypass'. `mypass'.
C:143.53.233.32:mypass:somewhere.fr.dal.net:7325:35 C:143.53.233.32:mypass:somewhere.fr.your.net:7325:35
N:143.53.233.32:yourpass:somewhere.fr.dal.net::35 N:143.53.233.32:yourpass:somewhere.fr.your.net::35
C:ircd@176.43.652.31:apass:elsewhere.jp.dal.net:7235:35 C:ircd@176.43.652.31:apass:elsewhere.jp.your.net:7235:35
N:ircd@176.43.652.31:THEpass:elsewhere.jp.dal.net::33 N:ircd@176.43.652.31:THEpass:elsewhere.jp.your.net::33
Both these set's will work as explained above, but if your Y line defining Both these set's will work as explained above, but if your Y line defining
class 35 has `max links' set to 1, and one of these servers is connected to class 35 has `max links' set to 1, and one of these servers is connected to
your server, your server will not try and autoconnect to the other since your server, your server will not try and autoconnect to the other since
the Y line is `full', but it will accept any incomming connections from the the Y line is `full', but it will accept any incoming connections from the
other server and any /connect commands given for this server. If your Y other server and any /connect commands given for this server. If your Y
line allows for more connections but your C lines do not have port numbers, line allows for more connections but your C lines do not have port numbers,
your server will not try and autoconnect. your server will not try and autoconnect.
Since the second set in this example has a username, ident will be used to Since the second set in this example has a username, ident will be used to
authenticate any connections made to this server. If the listed server does authenticate any connections made to this server. If the listed server does
not run ident, or the incomming connection comes from another username, the not run ident, or the incoming connection comes from another username, the
connection will be rejected. connection will be rejected.
If a connection is made via the second set by your server, the connection If a connection is made via the second set by your server, the connection
will be ruled by connection class 35, if the other server initiates the will be ruled by connection class 35, if the other server initiates the
connection, the connection will use class 33. connection, the connection will use class 33.
Autoconnect C/N line pairs can be given prefrence over other pairs by placing Autoconnect C/N line pairs can be given preference over other pairs by placing
them lower in your ircd.conf, the lower the line, the higher the priority them lower in your ircd.conf, the lower the line, the higher the priority
when autoconnecting. when autoconnecting.
Connection classes and C/N line set's allow you to refine your autoconnects Connection classes and C/N line set's allow you to refine your autoconnects
@@ -577,16 +602,16 @@ N:ircd@176.43.652.31:THEpass:elsewhere.jp.dal.net::33
3.8) K Lines [OPTIONAL] 3.8) K Lines [OPTIONAL]
These lines restric access to certain users to your server based on These lines restrict access to certain users to your server based on
user@host matches and time of the day. user@host matches and time of the day.
K lines can come in 3 forms, only one of which you can specify in your K lines can come in 3 forms, only one of which you can specify in your
ircd.conf, this type will show up as K on /stats k, the other other types ircd.conf, this type will show up as K on /stats k, the other types
are `AutoKill' which will show up as A on /stats k, and `kline' which will are `AutoKill' which will show up as A on /stats k, and `kline' which will
show up as k on /stats k. AutoKill's are set by U lined servers (see show up as k on /stats k. AutoKill's are set by U lined servers (see
above), they act in the same way as K lines except that they are set above), they act in the same way as K lines except that they are set
remotly and are usually set on all servers, they dissapear when you remotely and are usually set on all servers, they disappear when you
/rehash or restart your server. klines are set via the /kline command, /rehash or restart your server. klines are set via the /kline command,
they operate more like AutoKill's than K lines because they also dissapear they operate more like AutoKill's than K lines because they also disappear
when you /rehash, or restart the server. The /kline command can be used on when you /rehash, or restart the server. The /kline command can be used on
nicknames that appear on IRC, or you can use a user@host mask. If the nicknames that appear on IRC, or you can use a user@host mask. If the
/kline is done on an existing nickname, a kline will be set with that users /kline is done on an existing nickname, a kline will be set with that users
@@ -628,9 +653,9 @@ K:*.lamer.org:|kc.spamming:*
K:*::*rad K:*::*rad
This K line will reject anyone with the username `rad', or anything ending This K line will reject anyone with the username `rad', or anything ending
in `rad'. This ban will dissalow anyone using `rad' running ident or not. in `rad'. This ban will disallow anyone using `rad' running ident or not.
You must always take into account the ident character (`~') that is placed You must always take into account the ident character (`~') that is placed
infront of usernames when their host is not running ident. If you place a in front of usernames when their host is not running ident. If you place a
K line on a username `rad' the user will be banned only if they are running K line on a username `rad' the user will be banned only if they are running
ident, but if this user can turn off ident they can appear as ~rad, this ident, but if this user can turn off ident they can appear as ~rad, this
will allow them to bypass any ban of username `rad'. So, wildcards should will allow them to bypass any ban of username `rad'. So, wildcards should
@@ -642,24 +667,24 @@ K:*::*rad
3.9) Q Lines (server form) [DISCOURAGED] 3.9) Q Lines (server form) [DISCOURAGED]
Server form Q lines on DALnet servers are used to dissalow operators on Server form Q lines on servers are used to disallow operators on
certain servers to use commands such as remote /kill's, and remote certain servers to use commands such as remote /kill's, and remote
/connect's, this will effectivly restrict the operators on the server to /connect's, this will effectively restrict the operators on the server to
local operator priveleges. These lines are usually only used for `test' local operator privileges. These lines are usually only used for `test'
server situations. If a server isn't officially part of DALnet, they may server situations. If a server isn't officially part of a network, they may
be temporarily linked and Q lined, this means the server can be tested be temporarily linked and Q lined, this means the server can be tested
while not posing a threat to the rest of DALnet. Q lines need only be while not posing a threat to the rest of the network. Q lines need only be
placed on the hub connecting the `test' server. placed on the hub connecting the `test' server.
Syntax: Syntax:
Q:*:*:servername Q:*:*:servername
The 1st 2 fields are currently unused. A Q line placed on a hub connected The 1st 2 fields are currently unused. A Q line placed on a hub connected
to the named server will dissalow operators on the server to affect other to the named server will disallow operators on the server to affect other
DALnet users/servers. DALnet users/servers.
Example: Example:
Q:::test-server.my.dal.net Q:::test-server.my.net
Q line a server with the name `test-server.my.dal.net'. Q line a server with the name `test-server.my.net'.
-------------------- --------------------
@@ -682,10 +707,10 @@ Q:*:reason why nick is quarantined:nickname
Examples: Examples:
Q::No nicknames on MY server!:* Q::No nicknames on MY server!:*
This Q line will dissalow any nicknames on the server giving the reason: This Q line will disallow any nicknames on the server giving the reason:
No nicknames on MY server! No nicknames on MY server!
Only Operators will be allowed to use any nicknames, but since you must be Only Operators will be allowed to use any nicknames, but since you must be
a user before you can be +o, you will effectivly ban everyone from your a user before you can be +o, you will effectively ban everyone from your
server. server.
Q::Do not use the Lords name in vain!:God Q::Do not use the Lords name in vain!:God
@@ -693,7 +718,7 @@ Q::Do not use the Lords name in vain!:God
that they must find a new nickname and will be given the reason: that they must find a new nickname and will be given the reason:
Do not use the Lords name in vain! Do not use the Lords name in vain!
DALnet has a set of standard Q lines that should be in place on all Below are a set of standard Q lines that should be in place on all
server's. They are as follows: server's. They are as follows:
Q::Reserved for services:*Chan*S*rv* Q::Reserved for services:*Chan*S*rv*
@@ -701,8 +726,9 @@ Q::Reserved for services:*Nick*S*rv*
Q::Reserved for services:*Memo*S*rv Q::Reserved for services:*Memo*S*rv
Q::Reserved for services:*Oper*S*rv* Q::Reserved for services:*Oper*S*rv*
Q::Reserved for services:*Help*S*rv* Q::Reserved for services:*Help*S*rv*
Q::Reserved for operators:DALnet Q::Reserved for services:*Stat*S*rv*
Q::Reserved for operators:IRC*op* Q::Reserved for operators:IRC*op*
Q::Reserved for operators:*oper*
Q::Causes problems with mIRC:Status Q::Causes problems with mIRC:Status
-------------------- --------------------
@@ -711,7 +737,7 @@ Q::Causes problems with mIRC:Status
These lines specify which servers are to behave as leaves, that is, These lines specify which servers are to behave as leaves, that is,
servers that may not have any other servers connected to them. servers that may not have any other servers connected to them.
They will only be usefull if your server is a non-leaf (hub) server. They will only be useful if your server is a non-leaf (hub) server.
Not only can you limit servers to leaves, but you can also specify Not only can you limit servers to leaves, but you can also specify
what tree depth may appear after certain servers. If a server connects what tree depth may appear after certain servers. If a server connects
but tells your server that it has a larger tree depth behind it than is but tells your server that it has a larger tree depth behind it than is
@@ -738,18 +764,18 @@ L:hostmask of disallowed servers:*:server name:depth
Examples: Examples:
L:::leaf.de.dal.net L:::leaf.de.dal.net
This line will allow a server named `leaf.de.dal.net' to connect only as This line will allow a server named `leaf.de.your.net' to connect only as
a leaf. So this server may not connect any other servers behind it. a leaf. So this server may not connect any other servers behind it.
L:::semi-hub.sg.dal.net:1 L:::semi-hub.sg.dal.net:1
This line will force the server named `semi-hub.sg.dal.net' to allow only This line will force the server named `semi-hub.sg.your.net' to allow only
leaf servers to connect behind it. ie: to have a tree depth of 1. leaf servers to connect behind it. ie: to have a tree depth of 1.
L:*.us.dal.net::*.au.dal.net L:*.us.dal.net::*.au.your.net
L:*.eu.dal.net::*.au.dal.net L:*.eu.dal.net::*.au.your.net
These lines will make sure that any server with a name matching These lines will make sure that any server with a name matching
*.au.dal.net will not introduce any servers matching *.us.dal.net or *.au.your.net will not introduce any servers matching *.us.your.net or
*.eu.dal.net. This can be usefull for stopping certain hubs from letting *.eu.your.net. This can be useful for stopping certain hubs from letting
its autoconnects route the network badly. its autoconnects route the network badly.
-------------------- --------------------
@@ -763,7 +789,7 @@ L:*.eu.dal.net::*.au.dal.net
Syntax: Syntax:
H:servers which are allowed behind the hub:*:hub servername H:servers which are allowed behind the hub:*:hub servername
The 1st field defines what servernames the H lined server is allowed to The 1st field defines what server names the H lined server is allowed to
introduce. Wildcards are allowed. introduce. Wildcards are allowed.
The 2nd field is currently unused and should be left blank. The 2nd field is currently unused and should be left blank.
The 3rd field should be the exact name of the server allowed to be a hub The 3rd field should be the exact name of the server allowed to be a hub
@@ -771,16 +797,16 @@ H:servers which are allowed behind the hub:*:hub servername
the server's name includes a `*' (See N lines for host masking). the server's name includes a `*' (See N lines for host masking).
Examples: Examples:
H:*::dal-hub.us.dal.net H:*::dal-hub.us.your.net
This line will allow the server with the name `dal-hub.us.dal.net' to act This line will allow the server with the name `dal-hub.us.your.net' to act
as a hub server while you are connected to it, there are no restrictions as a hub server while you are connected to it, there are no restrictions
on the names of the servers it may introduce. on the names of the servers it may introduce.
H:*.us.dal.net::usa-hub.us.dal.net H:*.us.dal.net::usa-hub.us.your.net
This line will allow the server named `usa-hub.us.dal.net' to act as a hub This line will allow the server named `usa-hub.us.your.net' to act as a hub
while your server is connected to it, but it is limited to introducing while your server is connected to it, but it is limited to introducing
servers with names matching `*.us.dal.net', so any servers trying to servers with names matching `*.us.your.net', so any servers trying to
connect to `usa-hub.us.dal.net' with a name such as `bad-link.nz.dal.net' connect to `usa-hub.us.your.net' with a name such as `bad-link.nz.your.net'
will be rejected by your server. will be rejected by your server.
-------------------- --------------------
@@ -811,8 +837,7 @@ P:hostmask or UNIX socket file:*:*:port number
Examples: Examples:
P:*:::7325 P:*:::7325
This will open up the DALnet server connection port and wait for This will open up port 7325.
connections. This line is mandatory if you run a server connected to DALnet
P:*.net:::6665 P:*.net:::6665
This line will open up port 6665 and wait for connections, connections from This line will open up port 6665 and wait for connections, connections from
@@ -906,10 +931,10 @@ e:234.45.32.1:*:*
3.17) Summary: 3.17) Summary:
Well, thats it for the lines you may use in your ircd.conf. Remember that Well, that's it for the lines you may use in your ircd.conf. Remember that
ircd.conf is an art, just like any other type of programming. Some parts ircd.conf is an art, just like any other type of programming. Some parts
are particularly easy, but other's, like Y lines, can take a while to get are particularly easy, but other's, like Y lines, can take a while to get
used to. Given a little time experementing with lines on a network of used to. Given a little time experimenting with lines on a network of
servers, you will become well versed in ircd.conf programming. servers, you will become well versed in ircd.conf programming.
Good luck! Good luck!
@@ -1257,6 +1282,161 @@ Set HIDE_ULINES .........: 0
-------------------- --------------------
7.11) Set ALLOW_CHATOPS Line
This line defines whether or not /chatops will be allowed to be used. When
disabled /chatops as well as user mode +b will be disabled.
Syntax:
Set ALLOW_CHATOPS .......: 1/0
If this line is set to 1, then /chatops and +b are allowed, if it is set to 0,
then /chatops and +b are disabled.
Examples:
Set ALLOW_CHATOPS .......: 1
This line will allow use of /chatops and +b.
Set ALLOW_CHATOPS .......: 0
This line will disable /chatops and +b.
--------------------
7.12) Set SOCKS_BAN_MESSAGE Line
This line allows you to specify the reason to be used in the Z:line when a user
is killed for an open proxy server. It is very important that this is set, if
left NULL it can cause serious problems.
Syntax:
Set SOCKS_BAN_MESSAGE ...: message
In this line the word "message" should be replaced with the reason the user is
being Z:lined, the default is "Insecure SOCKS Server".
Examples:
Set SOCKS_BAN_MESSAGE ...: You are running an insecure SOCKS Server.
This line will Z:line a user using an open SOCKS server with the reason, "You
are running an insecure SOCKS Server."
--------------------
7.13) Set SOCKS_QUIT_MESSAGE Line
This line defines the message that will be used in the QUIT message the user
will have when they are killed for an insecure SOCKS server.
Syntax:
Set SOCKS_QUIT_MESSAGE ..: message
In this line the word "message" will be used as the QUIT message for the user
being killed.
Examples:
Set SOCKS_QUIT_MESSAGE ..: User was running an insecure SOCKS Server.
This line will use "User was running an insecure SOCKS Server." as the QUIT
message for the user when they are found to be running an insecure SOCKS
server.
--------------------
7.14) Set SOCKSBANTIME Line
This line lets you specify how long a user using an open SOCKS server will be
Z:lined for.
Syntax:
Set SOCKSBANTIME ........: time in seconds
This line will ban a user for "time in seconds" seconds, it is important to
remember that this is seconds, not minutes.
Examples:
Set SOCKSBANTIME ........: 86400
This line will Z:line all users running open SOCKS servers for 86400 seconds.
--------------------
7.15) Set MAXCHANNELSPERUSER Line
This line allows you to define the max amount of channels a user may join.
Note, IRCd Agents can still join unlimited channels no matter what this is set
to.
Syntax:
Set MAXCHANNELSPERUSER ..: number of channels
This line will allow users to join "number of channels", the recommended value
is 10 but it is not required.
Examples:
Set MAXCHANNELSPERUSER ..: 11
This line will allow users to join 11 channels before they are given an error.
--------------------
7.16) Set WEBTV_SUPPORT Line
This line allows you to specify whether WebTV Support will be enabled or not.
When WebTV Support is enabled the /NOTICE command is disabled also, anyone
using /NOTICE will send a /PRIVMSG. Also, in addition to using /<command> users
can /PRIVMSG irc <command> this is so WebTV users can also use commands.
Syntax:
Set WEBTV_SUPPORT .......: 1/0
When this line is set to 1, WebTV support will be enabled, when it is set to 0
it will be disabled and the IRCd will support /NOTICE as it normally would.
Examples:
Set WEBTV_SUPPORT .......: 1
This line enables WebTV Support disabling /NOTICE and enabling /PRIVMSG irc
<command>.
Set WEBTV_SUPPORT .......: 0
This line disables WebTV Support and leaving /NOTICE alone.
--------------------
7.17) Set NO_OPER_HIDING Line
This line allows you to specify whether IRCops will be allowed to set
themselves +I (if they have the ^ Oflag).
Syntax:
Set NO_OPER_HIDING ......: 1/0
If this line is set to 1 IRCops will not be able to use usermode +I, if this is
set to 0 they may use usermode +I.
Examples:
Set NO_OPER_HIDING ......: 1
This line has use of usermode +I disabled.
Set NO_OPER_HIDING ......: 0
This line has use of usermode +I enabled for IRCops.
--------------------
7.18) Set AUTO_JOIN_CHANS Line
This line allows you to force a user to join one or more channels when they
connect to the server. Using this will not override modes if you set it to make
a user join a +k channel they still need the password.
Syntax:
Set AUTO_JOIN_CHANS .....: 0/<channel>[,channel2,...]
When this line is set to 0 it will not make the user join any channels on
connect. If this is set to a channel name it will name the user join that
channel, to enter more than one channel use a comma separated list.
Examples:
Set AUTO_JOIN_CHANS .....: 0
This line makes it so the user will not be forced to join a channel when they
connect to the server.
Set AUTO_JOIN_CHANS .....: #main
This line will make the user join #main when they connect to the server.
Set AUTO_JOIN_CHANS .....: #main,#help
This line will make the user join #main and help when they connect, you may
specify as many channels as are defined in MAXCHANNELSPERUSER (see 7.15).
--------------------
8) network files: 8) network files:
The networks files allow you to specify some information specific about your The networks files allow you to specify some information specific about your
+1 -1
View File
@@ -1,5 +1,5 @@
/************************************************************************ /************************************************************************
* IRC - Internet Relay Chat, ircd/channel.h * Unreal Internet Relay Chat Daemon, ircd/channel.h
* Copyright (C) 1990 Jarkko Oikarinen * Copyright (C) 1990 Jarkko Oikarinen
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
+1 -1
View File
@@ -1,5 +1,5 @@
/************************************************************************ /************************************************************************
* IRC - Internet Relay Chat, include/class.h * Unreal Internet Relay Chat Daemon, include/class.h
* Copyright (C) 1990 Darren Reed * Copyright (C) 1990 Darren Reed
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
+22 -12
View File
@@ -1,5 +1,5 @@
/************************************************************************ /************************************************************************
* IRC - Internet Relay Chat, include/common.h * Unreal Internet Relay Chat Daemon, include/common.h
* Copyright (C) 1990 Armin Gruner * Copyright (C) 1990 Armin Gruner
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@@ -32,6 +32,7 @@
#include "struct.h" #include "struct.h"
#endif #endif
#include "dynconf.h" #include "dynconf.h"
#include "ircsprintf.h"
#ifdef PARAMH #ifdef PARAMH
#include <sys/param.h> #include <sys/param.h>
@@ -45,9 +46,15 @@
#endif #endif
#endif #endif
#ifdef DEVELOP_CVS
#define ID_CVS(x) static char id_cvs[] = x #define ID_CVS(x) static char id_cvs[] = x
#define ID_Copyright(x) static char id_copyright[] = x #define ID_Copyright(x) static char id_copyright[] = x
#define ID_Notes(x) static char id_notes[] = x #define ID_Notes(x) static char id_notes[] = x
#else
#define ID_CVS(x)
#define ID_Copyright(x)
#define ID_Notes(x)
#endif
#define BMAGIC 0x4675636B596F754661736369737473 #define BMAGIC 0x4675636B596F754661736369737473
@@ -102,11 +109,11 @@ extern unsigned long inet_addr PROTO((char *));
#include <netinet/in.h> #include <netinet/in.h>
#endif #endif
#ifdef NEED_INET_NTOA #ifdef NEED_INET_NTOA
extern char *inet_ntoa PROTO((struct in_addr)); extern char *inet_ntoa PROTO((struct IN_ADDR));
#endif #endif
#ifdef NEED_INET_NETOF #ifdef NEED_INET_NETOF
extern int inet_netof PROTO((struct in_addr)); extern int inet_netof PROTO((struct IN_ADDR));
#endif #endif
int global_count, max_global_count; int global_count, max_global_count;
@@ -124,14 +131,9 @@ extern char *strtoken PROTO((char **, char *, char *));
#define DupString(x,y) do{x=MyMalloc(strlen(y)+1);(void)strcpy(x,y);}while(0) #define DupString(x,y) do{x=MyMalloc(strlen(y)+1);(void)strcpy(x,y);}while(0)
#ifdef USE_CASETABLES
extern int casetable;
extern u_char *tolowertab, tolowertab1[], tolowertab2[];
extern u_char *touppertab, touppertab1[], touppertab2[];
#else
extern u_char tolowertab[], touppertab[]; extern u_char tolowertab[], touppertab[];
#endif
#ifndef USE_LOCALE
#undef tolower #undef tolower
#define tolower(c) (tolowertab[(c)]) #define tolower(c) (tolowertab[(c)])
@@ -150,7 +152,7 @@ extern u_char tolowertab[], touppertab[];
#undef isupper #undef isupper
#undef isspace #undef isspace
#undef iscntrl #undef iscntrl
#endif
extern unsigned char char_atribs[]; extern unsigned char char_atribs[];
#define PRINT 1 #define PRINT 1
@@ -168,8 +170,9 @@ extern unsigned char char_atribs[];
#define KLINE_EXCEPT 3 #define KLINE_EXCEPT 3
#endif #endif
#define iscntrl(c) (char_atribs[(u_char)(c)]&CNTRL)
#define isallowed(c) (char_atribs[(u_char)(c)]&ALLOW) #define isallowed(c) (char_atribs[(u_char)(c)]&ALLOW)
#ifndef USE_LOCALE
#define iscntrl(c) (char_atribs[(u_char)(c)]&CNTRL)
#define isalpha(c) (char_atribs[(u_char)(c)]&ALPHA) #define isalpha(c) (char_atribs[(u_char)(c)]&ALPHA)
#define isspace(c) (char_atribs[(u_char)(c)]&SPACE) #define isspace(c) (char_atribs[(u_char)(c)]&SPACE)
#define islower(c) ((char_atribs[(u_char)(c)]&ALPHA) && ((u_char)(c) > 0x5f)) #define islower(c) ((char_atribs[(u_char)(c)]&ALPHA) && ((u_char)(c) > 0x5f))
@@ -182,8 +185,15 @@ extern unsigned char char_atribs[];
#define isascii(c) ((u_char)(c) >= 0 && (u_char)(c) <= 0x7f) #define isascii(c) ((u_char)(c) >= 0 && (u_char)(c) <= 0x7f)
#define isgraph(c) ((char_atribs[(u_char)(c)]&PRINT) && ((u_char)(c) != 0x32)) #define isgraph(c) ((char_atribs[(u_char)(c)]&PRINT) && ((u_char)(c) != 0x32))
#define ispunct(c) (!(char_atribs[(u_char)(c)]&(CNTRL|ALPHA|DIGIT))) #define ispunct(c) (!(char_atribs[(u_char)(c)]&(CNTRL|ALPHA|DIGIT)))
#endif
// #ifndef DMALLOC
extern char *MyMalloc(); extern char *MyMalloc();
// #else
// #define MyMalloc malloc
// #define MyRealloc realloc
// #define MyFree free
// #endif
extern void flush_connections(); extern void flush_connections();
extern struct SLink *find_user_link(/* struct SLink *, struct Client * */); extern struct SLink *find_user_link(/* struct SLink *, struct Client * */);
@@ -192,7 +202,7 @@ extern struct SLink *find_user_link(/* struct SLink *, struct Client * */);
* you are doing. * you are doing.
*/ */
#define PROTOCTL_CLIENT "TOKEN WATCH=128 SAFELIST HCN PREFIX=@+%" #define PROTOCTL_CLIENT "TOKEN WATCH=128 SAFELIST HCN PREFIX=@+%"
#define PROTOCTL_SERVER "NOQUIT TOKEN NICKv2 SJOIN SJOIN2" #define PROTOCTL_SERVER "NOQUIT TOKEN NICKv2 SJOIN SJOIN2 UMODE2 ALN"
#ifdef _WIN32 #ifdef _WIN32
/* /*
+50 -33
View File
@@ -1,5 +1,5 @@
/* /*
* IRC - Internet Relay Chat, include/config.h * Unreal Internet Relay Chat Daemon, include/config.h
* Copyright (C) 1990 Jarkko Oikarinen * Copyright (C) 1990 Jarkko Oikarinen
* *
* $Id$ * $Id$
@@ -81,37 +81,12 @@
*/ */
#undef CONFROOM_JAVA_PORT #undef CONFROOM_JAVA_PORT
/*
REMOVE_ADVERTISING -ice
If you send a text to a user like "irc.roxnet.org" it will show up as "irc.******.org"
Off by default --stskeeps
*/
#undef REMOVE_ADVERTISING
/*
UnrealIRCd WebTV support
*/
#undef WEBTV
#ifdef WEBTV
/* enable /msg irc user */
#define WEBTV_IRCUSER
/* NOTICE's dont exist (except from server) */
#define WEBTV_NONOTICE
#endif
/* /*
dog3/comstud ircd fdlists dog3/comstud ircd fdlists
undef this to make them work undef this to make them work
*/ */
#undef NO_FDLIST #undef NO_FDLIST
/*
OPER_NO_HIDING
This makes +I an unexisting mode
On by default --stskeeps
*/
#undef OPER_NO_HIDING
/* /*
* Admin's chat... * Admin's chat...
@@ -123,6 +98,12 @@
*/ */
#define REMOTE_REHASH #define REMOTE_REHASH
/*
Ident checking
#define this to disable ident checking
*/
#undef NO_IDENT_CHECKING
/* /*
* No spoof code * No spoof code
* *
@@ -182,6 +163,18 @@
#define NICK_DELAY 15 /* recommended value 15 */ #define NICK_DELAY 15 /* recommended value 15 */
/*
** Freelinks garbage collector -Stskeeps
**
** GARBAGE_COLLECT_EVERY - how many seconds between every garbage collect
** HOW_MANY_FREELINKS_ALLOWED - how many freelinks allowed
*/
#ifndef GARBAGE_COLLECT_EVERY
#define GARBAGE_COLLECT_EVERY 600 /* default: 600 (10 mins) */
#endif
#define HOW_MANY_FREELINKS_ALLOWED 200 /* default: 200 */
/* /*
* Define this if you wish to output a *file* to a K lined client rather * Define this if you wish to output a *file* to a K lined client rather
* than the K line comment (the comment field is treated as a filename) * than the K line comment (the comment field is treated as a filename)
@@ -244,6 +237,7 @@
#define PPATH "ircd.pid" /* file for server pid */ #define PPATH "ircd.pid" /* file for server pid */
#define lPATH "ircd.log" /* server log file */ #define lPATH "ircd.log" /* server log file */
#define VPATH "ircd.svsmotd" /* Services MOTD append. */ #define VPATH "ircd.svsmotd" /* Services MOTD append. */
#define BPATH "bot.motd" /* Bot MOTD */
#define IRCDTUNE "ircd.tune" /* tuning .. */ #define IRCDTUNE "ircd.tune" /* tuning .. */
/* /*
@@ -407,8 +401,27 @@
* define IRC_UID to that UID. This should only be defined if you are running * define IRC_UID to that UID. This should only be defined if you are running
* as root and even then perhaps not. * as root and even then perhaps not.
*/ */
/* #undef IRC_UID /* */
/* #undef IRC_GID /* */ /*
* Ok this one is being changed. it is advisable never to run anything that
* uses sockets etc. and has the potential for the outside world to connect to it
* to run as root... Hackers do things like buffer overruns, and get dumped on
* a shell with root access effectivley ... so DONT do it.. if a program uses a
* port <1024 it will run as root, once the program has binded to the socket it
* will set its uid to something OTHER than root ... you set that in unrealircd.conf
*
* If you _must_ insist on running as root and not wanting the program to change its
* UID, then define BIG_SECURITY_HOLE below
*/
#if !defined(_WIN32) && !defined(_AMIGA)
/* Change This Line Below \/ */
#define BIG_SECURITY_HOLE
/* Its the one above ^^^^^^^ */
#ifndef BIG_SECUTIRY_HOLE
#define IRC_UID un_uid
#define IRC_GID un_gid
#endif
#endif
/* /*
* CLIENT_FLOOD * CLIENT_FLOOD
@@ -568,7 +581,7 @@
* CONNECTTIMEOUT - 10 seconds for its host to respond to an ident lookup * CONNECTTIMEOUT - 10 seconds for its host to respond to an ident lookup
* query and for a DNS answer to be retrieved. * query and for a DNS answer to be retrieved.
*/ */
#define CONNECTTIMEOUT 90 /* Recommended value: 90 */ #define CONNECTTIMEOUT 60 /* Recommended value: 60 */
/* /*
* Max time from the nickname change that still causes KILL * Max time from the nickname change that still causes KILL
@@ -576,10 +589,6 @@
*/ */
#define KILLCHASETIMELIMIT 90 /* Recommended value: 90 */ #define KILLCHASETIMELIMIT 90 /* Recommended value: 90 */
/*
* Max number of channels a user is allowed to join.
*/
#define MAXCHANNELSPERUSER 10 /* Recommended value: 10 */
/* /*
* SendQ-Always causes the server to put all outbound data into the sendq and * SendQ-Always causes the server to put all outbound data into the sendq and
@@ -717,6 +726,7 @@ error CLIENT_FLOOD needs redefining.
#else #else
error CLIENT_FLOOD undefined error CLIENT_FLOOD undefined
#endif #endif
#if (NICKNAMEHISTORYLENGTH < 100) #if (NICKNAMEHISTORYLENGTH < 100)
# define NICKNAMEHISTORYLENGTH 100 # define NICKNAMEHISTORYLENGTH 100
#endif #endif
@@ -737,6 +747,13 @@ error CLIENT_FLOOD undefined
*/ */
# define BSD_INCLUDES # define BSD_INCLUDES
#endif #endif
/*
* This is just to make Solaris porting easier -- codemastr
*/
#if defined(SOL20) || defined(SOL25) || defined(SOL26) || defined(SOL27)
#define _SOLARIS
#endif
/* /*
* Cleaup for WIN32 platform. * Cleaup for WIN32 platform.
+1 -1
View File
@@ -1,5 +1,5 @@
/************************************************************************ /************************************************************************
* IRC - Internet Relay Chat, include/dbuf.h * Unreal Internet Relay Chat Daemon, include/dbuf.h
* Copyright (C) 1990 Markku Savela * Copyright (C) 1990 Markku Savela
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
+36 -18
View File
@@ -1,5 +1,5 @@
/************************************************************************ /************************************************************************
* IRC - Internet Relay Chat, include/dynconf.h * Unreal Internet Relay Chat Daemon, include/dynconf.h
* Copyright (C) 1999 Carsten Munk * Copyright (C) 1999 Carsten Munk
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@@ -21,8 +21,14 @@
#define DYNCONF_H #define DYNCONF_H
/* config level */
#define DYNCONF_CONF_VERSION "1.5"
#define DYNCONF_NETWORK_VERSION "2.2"
typedef struct zNetwork aNetwork; typedef struct zNetwork aNetwork;
struct zNetwork { struct zNetwork {
unsigned x_inah : 1;
char *x_ircnetwork; char *x_ircnetwork;
char *x_defserv; char *x_defserv;
char *x_services_name; char *x_services_name;
@@ -37,30 +43,34 @@ struct zNetwork {
char *x_netdomain; char *x_netdomain;
char *x_helpchan; char *x_helpchan;
char *x_stats_server; char *x_stats_server;
int x_halfhub;
int x_inah;
char *x_net_quit;
int x_se;
}; };
typedef struct zConfiguration aConfiguration; typedef struct zConfiguration aConfiguration;
struct zConfiguration { struct zConfiguration {
long nospoof_seed01; unsigned som : 1;
long nospoof_seed02; unsigned mode_x : 1;
unsigned mode_i : 1;
unsigned mode_stripbadwords : 1;
unsigned truehub : 1;
unsigned stop : 1;
unsigned showopers : 1;
unsigned killdiff : 1;
unsigned hide_ulines : 1;
unsigned allow_chatops : 1;
unsigned webtv_support : 1;
unsigned no_oper_hiding : 1;
/* long nospoof_seed01;
long nospoof_seed02; */
long host_timeout;
int host_retries;
char *kline_address; char *kline_address;
char *include; char *include;
char *domainname; char *domainname;
char *domainmask; /* '*' + domainname */ char *domainmask; /* '*' + domainname */
int som; char *auto_join_chans;
int mode_x; char *oper_auto_join_chans;
int mode_i;
int truehub;
int stop;
int showopers;
int killdiff;
int hide_ulines;
int allow_chatops;
int socksbantime; int socksbantime;
int maxchannelsperuser;
char *socksbanmessage; char *socksbanmessage;
char *socksquitmessage; char *socksquitmessage;
aNetwork network; aNetwork network;
@@ -77,12 +87,20 @@ extern aConfiguration iConf;
#define DOMAINNAMEMASK "*" DOMAINNAME #define DOMAINNAMEMASK "*" DOMAINNAME
#define MODE_X iConf.mode_x #define MODE_X iConf.mode_x
#define MODE_I iConf.mode_i #define MODE_I iConf.mode_i
#define MODE_STRIPWORDS iConf.mode_stripbadwords
#define TRUEHUB iConf.truehub #define TRUEHUB iConf.truehub
#define SHOWOPERS iConf.showopers #define SHOWOPERS iConf.showopers
#define KILLDIFF iConf.killdiff #define KILLDIFF iConf.killdiff
#define SHOWOPERMOTD iConf.som #define SHOWOPERMOTD iConf.som
#define HIDE_ULINES iConf.hide_ulines #define HIDE_ULINES iConf.hide_ulines
#define ALLOW_CHATOPS iConf.allow_chatops #define ALLOW_CHATOPS iConf.allow_chatops
#define MAXCHANNELSPERUSER iConf.maxchannelsperuser
#define WEBTV_SUPPORT iConf.webtv_support
#define NO_OPER_HIDING iConf.no_oper_hiding
#define AUTO_JOIN_CHANS iConf.auto_join_chans
#define OPER_AUTO_JOIN_CHANS iConf.oper_auto_join_chans
#define HOST_TIMEOUT iConf.host_timeout
#define HOST_RETRIES iConf.host_retries
#define ircnetwork iConf.network.x_ircnetwork #define ircnetwork iConf.network.x_ircnetwork
#define defserv iConf.network.x_defserv #define defserv iConf.network.x_defserv
@@ -100,4 +118,4 @@ extern aConfiguration iConf;
#define STATS_SERVER iConf.network.x_stats_server #define STATS_SERVER iConf.network.x_stats_server
#define iNAH iConf.network.x_inah #define iNAH iConf.network.x_inah
#define net_quit iConf.network.x_net_quit #define net_quit iConf.network.x_net_quit
#define STOPSE iConf.network.x_se #define STOPSE iConf.network.x_se
+12 -8
View File
@@ -1,5 +1,5 @@
/************************************************************************ /************************************************************************
* IRC - Internet Relay Chat, include/h.h * Unreal Internet Relay Chat Daemon, include/h.h
* Copyright (C) 1992 Darren Reed * Copyright (C) 1992 Darren Reed
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@@ -74,6 +74,7 @@ extern int R_do_dns, R_fin_dns, R_fin_dnsc, R_fail_dns,
extern int R_do_socks, extern int R_do_socks,
R_good_socks, R_no_socks; R_good_socks, R_no_socks;
#endif #endif
#endif #endif
extern aChannel *find_channel PROTO((char *, aChannel *)); extern aChannel *find_channel PROTO((char *, aChannel *));
extern void remove_user_from_channel PROTO((aClient *, aChannel *)); extern void remove_user_from_channel PROTO((aClient *, aChannel *));
@@ -100,6 +101,7 @@ extern aClient *find_person PROTO((char *, aClient *));
extern aClient *find_server PROTO((char *, aClient *)); extern aClient *find_server PROTO((char *, aClient *));
extern aClient *find_service PROTO((char *, aClient *)); extern aClient *find_service PROTO((char *, aClient *));
extern char *find_or_add PROTO((char *));
extern int attach_conf PROTO((aClient *, aConfItem *)); extern int attach_conf PROTO((aClient *, aConfItem *));
extern aConfItem *attach_confs PROTO((aClient*, char *, int)); extern aConfItem *attach_confs PROTO((aClient*, char *, int));
extern aConfItem *attach_confs_host PROTO((aClient*, char *, int)); extern aConfItem *attach_confs_host PROTO((aClient*, char *, int));
@@ -132,6 +134,7 @@ extern void reset_help PROTO(());
extern int find_exception(char *); /* hidden host */ extern int find_exception(char *); /* hidden host */
extern char *MyMalloc PROTO((int)), *MyRealloc PROTO((char *, int)); extern char *MyMalloc PROTO((int)), *MyRealloc PROTO((char *, int));
extern char *debugmode, *configfile, *sbrk0; extern char *debugmode, *configfile, *sbrk0;
extern char *getfield PROTO((char *)); extern char *getfield PROTO((char *));
extern void get_sockhost PROTO((aClient *, char *)); extern void get_sockhost PROTO((aClient *, char *));
@@ -315,16 +318,13 @@ extern int hash_del_notify_list PROTO((aClient *));
extern void count_watch_memory PROTO((int *, u_long *)); extern void count_watch_memory PROTO((int *, u_long *));
extern aNotify *hash_get_notify PROTO((char *)); extern aNotify *hash_get_notify PROTO((char *));
extern aChannel *hash_get_chan_bucket PROTO((int)); extern aChannel *hash_get_chan_bucket PROTO((int));
extern aChannel *hash_find_channel PROTO((char *, aChannel *));
extern aClient *hash_find_client PROTO((char *, aClient *)); extern aClient *hash_find_client PROTO((char *, aClient *));
extern aClient *hash_find_nickserver PROTO((char *, aClient *)); extern aClient *hash_find_nickserver PROTO((char *, aClient *));
extern aClient *hash_find_server PROTO((char *, aClient *)); extern aClient *hash_find_server PROTO((char *, aClient *));
extern char *find_by_aln PROTO((char *));
extern void add_history PROTO((aClient *)); extern char *convert2aln PROTO((int));
extern aClient *get_history PROTO((char *, time_t)); extern int convertfromaln PROTO((char *));
extern void initwhowas PROTO(()); extern char *find_server_aln PROTO((char *));
extern void off_history PROTO((aClient *));
extern int dopacket PROTO((aClient *, char *, int)); extern int dopacket PROTO((aClient *, char *, int));
/*VARARGS2*/ /*VARARGS2*/
@@ -335,6 +335,10 @@ extern void send_listinfo PROTO((aClient *, char *));
extern void count_memory PROTO((aClient *, char *)); extern void count_memory PROTO((aClient *, char *));
#endif #endif
#ifdef INET6
extern char *inetntop(int af, const void *in, char *local_dummy, size_t the_size);
#endif
char *crule_parse PROTO((char *)); char *crule_parse PROTO((char *));
int crule_eval PROTO((char *)); int crule_eval PROTO((char *));
void crule_free PROTO((char **)); void crule_free PROTO((char **));
+38 -20
View File
@@ -1,5 +1,5 @@
/************************************************************************ /************************************************************************
* IRC - Internet Relay Chat, include/hash.h * Unreal Internet Relay Chat Daemon, include/hash.h
* Copyright (C) 1991 Darren Reed * Copyright (C) 1991 Darren Reed
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@@ -22,27 +22,45 @@
#ifndef __hash_include__ #ifndef __hash_include__
#define __hash_include__ #define __hash_include__
/* Ditch the stats if not running in debugmode */ typedef struct hashentry {
#ifdef DEBUGMODE int hits;
typedef struct hashentry { int links;
int hits; void *list;
int links; } aHashEntry;
void *list;
} aHashEntry;
#else /* DEBUGMODE */
typedef void *aHashEntry;
#endif /* DEBUGMODE */
#ifndef DEBUGMODE /* Taner had BITS_PER_COL 4 BITS_PER_COL_MASK 0xF - Dianora */
#define HASHSIZE 32003 /* prime number */
#define CHANNELHASHSIZE 10007 /* prime number */
#else
extern int HASHSIZE;
extern int CHANNELHASHSIZE;
#endif
#define NOTIFYHASHSIZE 10007 /* prime number */ #define BITS_PER_COL 3
#define BITS_PER_COL_MASK 0x7
#define MAX_SUB (1<<BITS_PER_COL)
#define NullChn ((aChannel *)0) /* Client hash table
* used in hash.c
*/
#define U_MAX_INITIAL 8192
#define U_MAX_INITIAL_MASK (U_MAX_INITIAL-1)
#define U_MAX (U_MAX_INITIAL*MAX_SUB)
/* Channel hash table
* used in hash.c
*/
#define CH_MAX_INITIAL 2048
#define CH_MAX_INITIAL_MASK (CH_MAX_INITIAL-1)
#define CH_MAX (CH_MAX_INITIAL*MAX_SUB)
/* Who was hash table
* used in whowas.c
*/
#define WW_MAX_INITIAL 16
#define WW_MAX_INITIAL_MASK (WW_MAX_INITIAL-1)
#define WW_MAX (WW_MAX_INITIAL*MAX_SUB)
#define NOTIFYHASHSIZE 10007 /* prime number */
#define NullChn ((aChannel *)0)
#define find_channel hash_find_channel
#endif /* __hash_include__ */ #endif /* __hash_include__ */
+2 -3
View File
@@ -1,5 +1,5 @@
/* /*
* IRC - Internet Relay Chat, include/license.h * Unreal Internet Relay Chat Daemon, include/license.h
* Copyright (C) 1999 Carsten Munk * Copyright (C) 1999 Carsten Munk
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@@ -17,8 +17,7 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
* *
* This file may not be removed from the IRCd package. * This file may not be removed from the IRCd package.
* It will be a violation of copyright. This program must always * It will be a violation of copyright.
* stay free and not be sold, or charged.
* *
* $Id$ * $Id$
*/ */
+39 -27
View File
@@ -1,5 +1,5 @@
/************************************************************************ /************************************************************************
* IRC - Internet Relay Chat, include/msg.h * Unreal Internet Relay Chat Daemon, include/msg.h
* Copyright (C) 1990 Jarkko Oikarinen and * Copyright (C) 1990 Jarkko Oikarinen and
* University of Oulu, Computing Center * University of Oulu, Computing Center
* *
@@ -91,7 +91,6 @@
#define TOK_USERS "3" /* 51 */ #define TOK_USERS "3" /* 51 */
#define MSG_HELP "HELP" /* HELP */ #define MSG_HELP "HELP" /* HELP */
#define MSG_HELPOP "HELPOP" /* HELP */ #define MSG_HELPOP "HELPOP" /* HELP */
#define MSG_IRCDHELP "IRCDHELP" /* HELP */
#define TOK_HELP "4" /* 52 */ #define TOK_HELP "4" /* 52 */
#define MSG_ERROR "ERROR" /* ERRO */ #define MSG_ERROR "ERROR" /* ERRO */
#define TOK_ERROR "5" /* 53 */ #define TOK_ERROR "5" /* 53 */
@@ -266,8 +265,6 @@
#define TOK_ADDOMOTD "AR" #define TOK_ADDOMOTD "AR"
#define MSG_SVSMOTD "SVSMOTD" #define MSG_SVSMOTD "SVSMOTD"
#define TOK_SVSMOTD "AS" #define TOK_SVSMOTD "AS"
#define MSG_DUSERS "DUSERS"
#define TOK_DUSERS "AT"
#define MSG_SMO "SMO" #define MSG_SMO "SMO"
#define TOK_SMO "AU" #define TOK_SMO "AU"
#define MSG_OPERMOTD "OPERMOTD" #define MSG_OPERMOTD "OPERMOTD"
@@ -300,8 +297,17 @@
#define TOK_REMGLINE "BG" #define TOK_REMGLINE "BG"
#define MSG_HTM "HTM" #define MSG_HTM "HTM"
#define TOK_HTM "BH" #define TOK_HTM "BH"
#define MAXPARA 15 #define MSG_UMODE2 "UMODE2"
#define TOK_UMODE2 "|"
#define MSG_DCCDENY "DCCDENY"
#define TOK_DCCDENY "BI"
#define MSG_UNDCCDENY "UNDCCDENY"
#define TOK_UNDCCDENY "BJ"
#define MSG_CHGNAME "CHGNAME"
#define MSG_SVSNAME "SVSNAME"
#define TOK_CHGNAME "BK"
#define MAXPARA 15
extern int m_private(), m_topic(), m_join(), m_part(), m_mode(), m_svsmode(); extern int m_private(), m_topic(), m_join(), m_part(), m_mode(), m_svsmode();
extern int m_ping(), m_pong(), m_wallops(), m_kick(), m_svsnick(); extern int m_ping(), m_pong(), m_wallops(), m_kick(), m_svsnick();
@@ -332,45 +338,51 @@ extern int m_sethost(), m_nachat(), m_techat(), m_setident(), m_setname();
extern int m_lag(), m_sdesc(), m_knock(), m_credits(); extern int m_lag(), m_sdesc(), m_knock(), m_credits();
extern int m_license(), m_chghost(), m_rping(), m_rpong(); extern int m_license(), m_chghost(), m_rping(), m_rpong();
extern int m_netinfo(), m_sendumode(), m_addmotd(), m_addomotd(); extern int m_netinfo(), m_sendumode(), m_addmotd(), m_addomotd();
extern int m_svsmotd(), m_dusers(), m_opermotd(), m_tsctl(); extern int m_svsmotd(), m_opermotd(), m_tsctl();
extern int m_svsjoin(), m_sajoin(), m_svspart(), m_sapart(); extern int m_svsjoin(), m_sajoin(), m_svspart(), m_sapart();
extern int m_chgident(), m_swhois(), m_svso(), m_svsfline(); extern int m_chgident(), m_swhois(), m_svso(), m_svsfline();
extern int m_tkl(), m_vhost(), m_botmotd(), m_sjoin(), m_htm(); extern int m_tkl(), m_vhost(), m_botmotd(), m_sjoin(), m_htm();
extern int m_umode2(), m_dccdeny(), m_undccdeny();
extern int m_chgname();
#ifdef MSGTAB #ifdef MSGTAB
struct Message *msgmap[256]; struct Message *msgmap[256];
struct Message msgtab[] = { struct Message msgtab[] = {
{ MSG_PRIVATE, m_private, 0, MAXPARA, 1, TOK_PRIVATE, 0L }, { MSG_PRIVATE, m_private, 0, MAXPARA, 1, TOK_PRIVATE, 0L },
{ MSG_NICK, m_nick, 0, MAXPARA, 1, TOK_NICK, 0L },
{ MSG_NOTICE, m_notice, 0, MAXPARA, 1, TOK_NOTICE, 0L }, { MSG_NOTICE, m_notice, 0, MAXPARA, 1, TOK_NOTICE, 0L },
{ MSG_JOIN, m_join, 0, MAXPARA, 1, TOK_JOIN, 0L },
{ MSG_MODE, m_mode, 0, MAXPARA, 1, TOK_MODE, 0L }, { MSG_MODE, m_mode, 0, MAXPARA, 1, TOK_MODE, 0L },
{ MSG_QUIT, m_quit, 0, MAXPARA, 1, TOK_QUIT, 0L }, { MSG_NICK, m_nick, 0, MAXPARA, 1, TOK_NICK, 0L },
{ MSG_JOIN, m_join, 0, MAXPARA, 1, TOK_JOIN, 0L },
{ MSG_PING, m_ping, 0, MAXPARA, 1, TOK_PING, 0L },
{ MSG_WHOIS, m_whois, 0, MAXPARA, 1, TOK_WHOIS, 0L },
{ MSG_ISON, m_ison, 0, 1, 1, TOK_ISON, 0L },
{ MSG_USER, m_user, 0, MAXPARA, 1, TOK_USER, 0L },
{ MSG_PONG, m_pong, 0, MAXPARA, 1, TOK_PONG, 0L },
{ MSG_PART, m_part, 0, MAXPARA, 1, TOK_PART, 0L }, { MSG_PART, m_part, 0, MAXPARA, 1, TOK_PART, 0L },
{ MSG_QUIT, m_quit, 0, MAXPARA, 1, TOK_QUIT, 0L },
{ MSG_WATCH, m_watch, 0, 1, 1, TOK_WATCH, 0L },
{ MSG_USERHOST,m_userhost, 0, 1, 1, TOK_USERHOST,0L },
{ MSG_SVSNICK, m_svsnick, 0, MAXPARA, 1, TOK_SVSNICK, 0L },
{ MSG_SVSMODE, m_svsmode, 0, MAXPARA, 1, TOK_SVSMODE, 0L },
{ MSG_LUSERS, m_lusers, 0, MAXPARA, 1, TOK_LUSERS, 0L },
{ MSG_IDENTIFY,m_identify, 0, 1, 1, TOK_IDENTIFY,0L },
{ MSG_CHANSERV,m_chanserv, 0, 1, 1, TOK_CHANSERV,0L },
{ MSG_TOPIC, m_topic, 0, MAXPARA, 1, TOK_TOPIC, 0L }, { MSG_TOPIC, m_topic, 0, MAXPARA, 1, TOK_TOPIC, 0L },
{ MSG_INVITE, m_invite, 0, MAXPARA, 1, TOK_INVITE, 0L }, { MSG_INVITE, m_invite, 0, MAXPARA, 1, TOK_INVITE, 0L },
{ MSG_KICK, m_kick, 0, MAXPARA, 1, TOK_KICK, 0L }, { MSG_KICK, m_kick, 0, MAXPARA, 1, TOK_KICK, 0L },
{ MSG_WALLOPS, m_wallops, 0, 1, 1, TOK_WALLOPS, 0L }, { MSG_WALLOPS, m_wallops, 0, 1, 1, TOK_WALLOPS, 0L },
{ MSG_PING, m_ping, 0, MAXPARA, 1, TOK_PING, 0L },
{ MSG_PONG, m_pong, 0, MAXPARA, 1, TOK_PONG, 0L },
{ MSG_ERROR, m_error, 0, MAXPARA, 1, TOK_ERROR, 0L }, { MSG_ERROR, m_error, 0, MAXPARA, 1, TOK_ERROR, 0L },
{ MSG_KILL, m_kill, 0, MAXPARA, 1, TOK_KILL, 0L }, { MSG_KILL, m_kill, 0, MAXPARA, 1, TOK_KILL, 0L },
{ MSG_PROTOCTL,m_protoctl, 0, MAXPARA, 1, TOK_PROTOCTL,0L }, { MSG_PROTOCTL,m_protoctl, 0, MAXPARA, 1, TOK_PROTOCTL,0L },
{ MSG_USER, m_user, 0, MAXPARA, 1, TOK_USER, 0L },
{ MSG_AWAY, m_away, 0, MAXPARA, 1, TOK_AWAY, 0L }, { MSG_AWAY, m_away, 0, MAXPARA, 1, TOK_AWAY, 0L },
{ MSG_ISON, m_ison, 0, 1, 1, TOK_ISON, 0L },
{ MSG_WATCH, m_watch, 0, 1, 1, TOK_WATCH, 0L },
{ MSG_SERVER, m_server, 0, MAXPARA, 1, TOK_SERVER, 0L }, { MSG_SERVER, m_server, 0, MAXPARA, 1, TOK_SERVER, 0L },
{ MSG_SQUIT, m_squit, 0, MAXPARA, 1, TOK_SQUIT, 0L }, { MSG_SQUIT, m_squit, 0, MAXPARA, 1, TOK_SQUIT, 0L },
{ MSG_WHOIS, m_whois, 0, MAXPARA, 1, TOK_WHOIS, 0L },
{ MSG_WHO, m_who, 0, MAXPARA, 1, TOK_WHO, 0L }, { MSG_WHO, m_who, 0, MAXPARA, 1, TOK_WHO, 0L },
{ MSG_WHOWAS, m_whowas, 0, MAXPARA, 1, TOK_WHOWAS, 0L }, { MSG_WHOWAS, m_whowas, 0, MAXPARA, 1, TOK_WHOWAS, 0L },
{ MSG_LIST, m_list, 0, MAXPARA, 1, TOK_LIST, 0L }, { MSG_LIST, m_list, 0, MAXPARA, 1, TOK_LIST, 0L },
{ MSG_NAMES, m_names, 0, MAXPARA, 1, TOK_NAMES, 0L }, { MSG_NAMES, m_names, 0, MAXPARA, 1, TOK_NAMES, 0L },
{ MSG_USERHOST,m_userhost, 0, 1, 1, TOK_USERHOST,0L },
{ MSG_TRACE, m_trace, 0, MAXPARA, 1, TOK_TRACE, 0L }, { MSG_TRACE, m_trace, 0, MAXPARA, 1, TOK_TRACE, 0L },
{ MSG_PASS, m_pass, 0, MAXPARA, 1, TOK_PASS, 0L }, { MSG_PASS, m_pass, 0, MAXPARA, 1, TOK_PASS, 0L },
{ MSG_LUSERS, m_lusers, 0, MAXPARA, 1, TOK_LUSERS, 0L },
{ MSG_TIME, m_time, 0, MAXPARA, 1, TOK_TIME, 0L }, { MSG_TIME, m_time, 0, MAXPARA, 1, TOK_TIME, 0L },
{ MSG_OPER, m_oper, 0, MAXPARA, 1, TOK_OPER, 0L }, { MSG_OPER, m_oper, 0, MAXPARA, 1, TOK_OPER, 0L },
{ MSG_CONNECT, m_connect, 0, MAXPARA, 1, TOK_CONNECT, 0L }, { MSG_CONNECT, m_connect, 0, MAXPARA, 1, TOK_CONNECT, 0L },
@@ -379,23 +391,19 @@ struct Message msgtab[] = {
{ MSG_LINKS, m_links, 0, MAXPARA, 1, TOK_LINKS, 0L }, { MSG_LINKS, m_links, 0, MAXPARA, 1, TOK_LINKS, 0L },
{ MSG_ADMIN, m_admin, 0, MAXPARA, 1, TOK_ADMIN, 0L }, { MSG_ADMIN, m_admin, 0, MAXPARA, 1, TOK_ADMIN, 0L },
{ MSG_USERS, m_users, 0, MAXPARA, 1, TOK_USERS, 0L }, { MSG_USERS, m_users, 0, MAXPARA, 1, TOK_USERS, 0L },
{ MSG_SVSMODE, m_svsmode, 0, MAXPARA, 1, TOK_SVSMODE, 0L },
{ MSG_SAMODE, m_samode, 0, MAXPARA, 1, TOK_SAMODE, 0L }, { MSG_SAMODE, m_samode, 0, MAXPARA, 1, TOK_SAMODE, 0L },
{ MSG_SVSKILL, m_svskill, 0, MAXPARA, 1, TOK_SVSKILL, 0L }, { MSG_SVSKILL, m_svskill, 0, MAXPARA, 1, TOK_SVSKILL, 0L },
{ MSG_SVSNICK, m_svsnick, 0, MAXPARA, 1, TOK_SVSNICK, 0L },
{ MSG_SVSNOOP, m_svsnoop, 0, MAXPARA, 1, TOK_SVSNOOP, 0L }, { MSG_SVSNOOP, m_svsnoop, 0, MAXPARA, 1, TOK_SVSNOOP, 0L },
{ MSG_CHANSERV,m_chanserv, 0, 1, 1, TOK_CHANSERV,0L }, { MSG_CS, m_chanserv, 0, 1, 1, TOK_CHANSERV,0L },
/* { MSG_CS, m_noshortc, 0, 1, 1, TOK_CHANSERV,0L }, */
{ MSG_NICKSERV,m_nickserv, 0, 1, 1, TOK_NICKSERV,0L }, { MSG_NICKSERV,m_nickserv, 0, 1, 1, TOK_NICKSERV,0L },
/* { MSG_NS, m_noshortn, 0, 1, 1, TOK_NICKSERV,0L }, */ { MSG_NS, m_nickserv, 0, 1, 1, TOK_NICKSERV,0L },
{ MSG_OPERSERV,m_operserv, 0, 1, 1, TOK_OPERSERV,0L }, { MSG_OPERSERV,m_operserv, 0, 1, 1, TOK_OPERSERV,0L },
/* { MSG_OS, m_noshorto, 0, 1, 1, TOK_OPERSERV,0L }, */ { MSG_OS, m_operserv, 0, 1, 1, TOK_OPERSERV,0L },
{ MSG_MEMOSERV,m_memoserv, 0, 1, 1, TOK_MEMOSERV,0L }, { MSG_MEMOSERV,m_memoserv, 0, 1, 1, TOK_MEMOSERV,0L },
/*{ MSG_MS, m_noshortm, 0, 1, 1, TOK_MEMOSERV,0L }, */ { MSG_MS, m_memoserv, 0, 1, 1, TOK_MEMOSERV,0L },
{ MSG_HELPSERV,m_helpserv, 0, 1, 1, TOK_HELPSERV,0L }, { MSG_HELPSERV,m_helpserv, 0, 1, 1, TOK_HELPSERV,0L },
/* { MSG_HS, m_noshorth, 0, 1, 1, TOK_HELPSERV,0L }, */ { MSG_HS, m_helpserv, 0, 1, 1, TOK_HELPSERV,0L },
{ MSG_SERVICES,m_services, 0, 1, 1, TOK_SERVICES,0L }, { MSG_SERVICES,m_services, 0, 1, 1, TOK_SERVICES,0L },
{ MSG_IDENTIFY,m_identify, 0, 1, 1, TOK_IDENTIFY,0L },
{ MSG_SUMMON, m_summon, 0, MAXPARA, 1, TOK_SUMMON, 0L }, { MSG_SUMMON, m_summon, 0, MAXPARA, 1, TOK_SUMMON, 0L },
{ MSG_HELP, m_help, 0, 1, 1, TOK_HELP, 0L }, { MSG_HELP, m_help, 0, 1, 1, TOK_HELP, 0L },
{ MSG_HELPOP, m_help, 0, 1, 1, TOK_HELP, 0L }, { MSG_HELPOP, m_help, 0, 1, 1, TOK_HELP, 0L },
@@ -450,7 +458,6 @@ struct Message msgtab[] = {
{ MSG_ADDMOTD, m_addmotd, 0, 1, 1, TOK_ADDMOTD, 0L}, { MSG_ADDMOTD, m_addmotd, 0, 1, 1, TOK_ADDMOTD, 0L},
{ MSG_ADDOMOTD, m_addomotd, 0, 1, 1, TOK_ADDOMOTD, 0L}, { MSG_ADDOMOTD, m_addomotd, 0, 1, 1, TOK_ADDOMOTD, 0L},
{ MSG_SVSMOTD, m_svsmotd, 0, MAXPARA, 1, TOK_SVSMOTD, 0L}, { MSG_SVSMOTD, m_svsmotd, 0, MAXPARA, 1, TOK_SVSMOTD, 0L},
{ MSG_DUSERS, m_dusers, 0, MAXPARA, 1, TOK_DUSERS, 0L},
{ MSG_OPERMOTD, m_opermotd, 0, MAXPARA, 1, TOK_OPERMOTD, 0L}, { MSG_OPERMOTD, m_opermotd, 0, MAXPARA, 1, TOK_OPERMOTD, 0L},
{ MSG_TSCTL, m_tsctl, 0, MAXPARA, 1, TOK_TSCTL, 0L}, { MSG_TSCTL, m_tsctl, 0, MAXPARA, 1, TOK_TSCTL, 0L},
{ MSG_SVSJOIN, m_svsjoin, 0, MAXPARA, 1, TOK_SVSJOIN, 0L}, { MSG_SVSJOIN, m_svsjoin, 0, MAXPARA, 1, TOK_SVSJOIN, 0L},
@@ -466,6 +473,11 @@ struct Message msgtab[] = {
{ MSG_BOTMOTD, m_botmotd, 0, MAXPARA,1,TOK_BOTMOTD,0L}, { MSG_BOTMOTD, m_botmotd, 0, MAXPARA,1,TOK_BOTMOTD,0L},
{ MSG_SJOIN, m_sjoin, 0, MAXPARA, 1, TOK_SJOIN,0L}, { MSG_SJOIN, m_sjoin, 0, MAXPARA, 1, TOK_SJOIN,0L},
{ MSG_HTM, m_htm, 0, MAXPARA, 1, TOK_HTM, 0L}, { MSG_HTM, m_htm, 0, MAXPARA, 1, TOK_HTM, 0L},
{ MSG_UMODE2, m_umode2, 0, MAXPARA, 1, TOK_UMODE2, 0L},
{ MSG_DCCDENY,m_dccdeny, 0, 2, 1, TOK_DCCDENY,0L },
{ MSG_UNDCCDENY,m_undccdeny, 0, MAXPARA, 1, TOK_UNDCCDENY,0L },
{ MSG_CHGNAME, m_chgname, 0, MAXPARA, 1, TOK_CHGNAME, 0L},
{ MSG_SVSNAME, m_chgname, 0, MAXPARA, 1, TOK_CHGNAME, 0L},
{ (char *) 0, (int (*)()) 0 , 0, 0, 0, 0, 0L} { (char *) 0, (int (*)()) 0 , 0, 0, 0, 0, 0L}
}; };
+22 -2
View File
@@ -88,6 +88,26 @@
#define T_MINFO 14 /* mailbox information */ #define T_MINFO 14 /* mailbox information */
#define T_MX 15 /* mail routing information */ #define T_MX 15 /* mail routing information */
#define T_TXT 16 /* text strings */ #define T_TXT 16 /* text strings */
#define T_RP 17 /* responsible person */
#define T_AFSDB 18 /* AFS cell database */
#define T_X25 19 /* X_25 calling address */
#define T_ISDN 20 /* ISDN calling address */
#define T_RT 21 /* router */
#define T_NSAP 22 /* NSAP address */
#define T_NSAP_PTR 23 /* reverse NSAP lookup (deprecated) */
#define T_SIG 24 /* security signature */
#define T_KEY 25 /* security key */
#define T_PX 26 /* X.400 mail mapping */
#define T_GPOS 27 /* geographical position (withdrawn) */
#define T_AAAA 28 /* IP6 Address */
#define T_LOC 29 /* Location Information */
#define T_NXT 30 /* Next Valid Name in Zone */
#define T_EID 31 /* Endpoint identifier */
#define T_NIMLOC 32 /* Nimrod locator */
#define T_SRV 33 /* Server selection */
#define T_ATMA 34 /* ATM Address */
#define T_NAPTR 35 /* Naming Authority PoinTeR */
/* non standard */ /* non standard */
#define T_UINFO 100 /* user (finger) information */ #define T_UINFO 100 /* user (finger) information */
#define T_UID 101 /* user ID */ #define T_UID 101 /* user ID */
@@ -130,10 +150,10 @@
#define BYTE_ORDER LITTLE_ENDIAN #define BYTE_ORDER LITTLE_ENDIAN
#endif #endif
#if defined(sel) || defined(pyr) || defined(mc68000) || defined(sparc) || \ #if defined(sel) || defined(mc68000) || defined(sparc) || \
defined(is68k) || defined(tahoe) || defined(ibm032) || defined(ibm370) || \ defined(is68k) || defined(tahoe) || defined(ibm032) || defined(ibm370) || \
defined(MIPSEB) || defined(__hpux) || defined(__convex__) || \ defined(MIPSEB) || defined(__hpux) || defined(__convex__) || \
defined(__pyr__) || defined(__mc68000__) || defined(__sparc__) ||\ defined(__mc68000__) || defined(__sparc__) ||\
defined(_IBMR2) || defined (BIT_ZERO_ON_LEFT) defined(_IBMR2) || defined (BIT_ZERO_ON_LEFT)
#define BYTE_ORDER BIG_ENDIAN #define BYTE_ORDER BIG_ENDIAN
#endif #endif
+11 -4
View File
@@ -1,5 +1,5 @@
/************************************************************************ /************************************************************************
* IRC - Internet Relay Chat, include/numeric.h * Unreal Internet Relay Chat Daemon, include/numeric.h
* Copyright (C) 1990 Jarkko Oikarinen * Copyright (C) 1990 Jarkko Oikarinen
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@@ -112,6 +112,8 @@
#define ERR_ATTACKDENY 484 #define ERR_ATTACKDENY 484
#define ERR_KILLDENY 485 #define ERR_KILLDENY 485
#define ERR_HTMDISABLED 486
#define ERR_NOOPERHOST 491 #define ERR_NOOPERHOST 491
#define ERR_NOSERVICEHOST 492 #define ERR_NOSERVICEHOST 492
@@ -206,6 +208,10 @@
#define RPL_YOURESERVICE 383 #define RPL_YOURESERVICE 383
#define RPL_MYPORTIS 384 #define RPL_MYPORTIS 384
#define RPL_NOTOPERANYMORE 385 #define RPL_NOTOPERANYMORE 385
#define RPL_QLIST 386
#define RPL_ENDOFQLIST 387
#define RPL_ALIST 388
#define RPL_ENDOFALIST 389
#define RPL_TIME 391 #define RPL_TIME 391
#define RPL_USERSSTART 392 #define RPL_USERSSTART 392
@@ -217,6 +223,7 @@
#define RPL_TRACECONNECTING 201 #define RPL_TRACECONNECTING 201
#define RPL_TRACEHANDSHAKE 202 #define RPL_TRACEHANDSHAKE 202
#define RPL_TRACEUNKNOWN 203 #define RPL_TRACEUNKNOWN 203
#define RPL_TRACEOPERATOR 204 #define RPL_TRACEOPERATOR 204
#define RPL_TRACEUSER 205 #define RPL_TRACEUSER 205
#define RPL_TRACESERVER 206 #define RPL_TRACESERVER 206
@@ -227,7 +234,6 @@
#define RPL_STATSLINKINFO 211 #define RPL_STATSLINKINFO 211
#define RPL_STATSCOMMANDS 212 #define RPL_STATSCOMMANDS 212
#define RPL_STATSCLINE 213 #define RPL_STATSCLINE 213
#define RPL_STATSNLINE 214
#define RPL_STATSILINE 215 #define RPL_STATSILINE 215
#define RPL_STATSKLINE 216 #define RPL_STATSKLINE 216
#define RPL_STATSQLINE 217 #define RPL_STATSQLINE 217
@@ -235,10 +241,13 @@
#define RPL_ENDOFSTATS 219 #define RPL_ENDOFSTATS 219
#define RPL_STATSBLINE 220 #define RPL_STATSBLINE 220
#define RPL_UMODEIS 221 #define RPL_UMODEIS 221
#define RPL_SQLINE_NICK 222 #define RPL_SQLINE_NICK 222
#define RPL_STATSGLINE 223 #define RPL_STATSGLINE 223
#define RPL_STATSTLINE 224 #define RPL_STATSTLINE 224
#define RPL_STATSELINE 225
#define RPL_STATSNLINE 226
#define RPL_SERVICEINFO 231 #define RPL_SERVICEINFO 231
#define RPL_RULES 232 #define RPL_RULES 232
#define RPL_SERVICE 233 #define RPL_SERVICE 233
@@ -266,13 +275,11 @@
#define RPL_ADMINEMAIL 259 #define RPL_ADMINEMAIL 259
#define RPL_TRACELOG 261 #define RPL_TRACELOG 261
#define RPL_LOCALUSERS 265 #define RPL_LOCALUSERS 265
#define RPL_GLOBALUSERS 266 #define RPL_GLOBALUSERS 266
#define RPL_SILELIST 271 #define RPL_SILELIST 271
#define RPL_ENDOFSILELIST 272 #define RPL_ENDOFSILELIST 272
#define RPL_STATSDLINE 275 #define RPL_STATSDLINE 275
#define RPL_HELPHDR 290 #define RPL_HELPHDR 290
+2 -2
View File
@@ -23,7 +23,7 @@ struct hent {
int h_addrtype; /* host address type */ int h_addrtype; /* host address type */
int h_length; /* length of address */ int h_length; /* length of address */
/* list of addresses from name server */ /* list of addresses from name server */
struct in_addr h_addr_list[MAXADDRS]; struct IN_ADDR h_addr_list[MAXADDRS];
#define h_addr h_addr_list[0] /* address, for backward compatiblity */ #define h_addr h_addr_list[0] /* address, for backward compatiblity */
}; };
@@ -38,7 +38,7 @@ typedef struct reslist {
char resend; /* send flag. 0 == dont resend */ char resend; /* send flag. 0 == dont resend */
time_t sentat; time_t sentat;
time_t timeout; time_t timeout;
struct in_addr addr; struct IN_ADDR addr;
char *name; char *name;
struct reslist *next; struct reslist *next;
Link cinfo; Link cinfo;
+1 -1
View File
@@ -46,7 +46,7 @@ struct state {
int retry; /* number of times to retransmit */ int retry; /* number of times to retransmit */
long options; /* option flags - see below. */ long options; /* option flags - see below. */
int nscount; /* number of name servers */ int nscount; /* number of name servers */
struct sockaddr_in nsaddr_list[MAXNS]; /* address of name server */ struct SOCKADDR_IN nsaddr_list[MAXNS]; /* address of name server */
#define nsaddr nsaddr_list[0] /* for backward compatibility */ #define nsaddr nsaddr_list[0] /* for backward compatibility */
unsigned short id; /* current packet id */ unsigned short id; /* current packet id */
char defdname[MAXDNAME]; /* default domain */ char defdname[MAXDNAME]; /* default domain */
+1 -1
View File
@@ -1,5 +1,5 @@
/************************************************************************ /************************************************************************
* IRC - Internet Relay Chat, include/sjoin.h * Unreal Internet Relay Chat Daemon, include/sjoin.h
* (C) Carsten Munk 2000 * (C) Carsten Munk 2000
* Contains code from StarChat IRCd, (C) their respective authors * Contains code from StarChat IRCd, (C) their respective authors
* *
+4 -1
View File
@@ -1,5 +1,5 @@
/************************************************************************ /************************************************************************
* IRC - Internet Relay Chat, include/sock.h * Unreal Internet Relay Chat Daemon, include/sock.h
* Copyright (C) 1990 Jarkko Oikarinen and * Copyright (C) 1990 Jarkko Oikarinen and
* University of Oulu, Computing Center * University of Oulu, Computing Center
* *
@@ -22,6 +22,9 @@
* $Id$ * $Id$
* *
* $Log$ * $Log$
* Revision 1.2 2000/03/02 21:22:37 stskeeps
* ...........
*
* Revision 1.1.1.1 2000/01/30 12:16:33 stskeeps * Revision 1.1.1.1 2000/01/30 12:16:33 stskeeps
* Begin of CVS at cvs.unreal.sourceforge.net * Begin of CVS at cvs.unreal.sourceforge.net
* *
+1 -1
View File
@@ -1,4 +1,4 @@
/* Auto created release stamping */ /* Auto created release stamping */
#define RELEASEID2 "951777936" #define RELEASEID2 "959378517"
#define RELEASESTUFF "draconic" #define RELEASESTUFF "draconic"
+88 -39
View File
@@ -1,5 +1,5 @@
/************************************************************************ /************************************************************************
* IRC - Internet Relay Chat, include/struct.h * Unreal Internet Relay Chat Daemon, include/struct.h
* Copyright (C) 1990 Jarkko Oikarinen and * Copyright (C) 1990 Jarkko Oikarinen and
* University of Oulu, Computing Center * University of Oulu, Computing Center
* *
@@ -26,7 +26,7 @@
#include "config.h" #include "config.h"
#include "common.h" #include "common.h"
#include "sys.h" #include "sys.h"
#include "hash.h"
#include <stdio.h> #include <stdio.h>
#include <sys/types.h> #include <sys/types.h>
#ifndef _WIN32 #ifndef _WIN32
@@ -43,9 +43,6 @@
# include <sys/syslog.h> # include <sys/syslog.h>
# endif # endif
#endif #endif
#ifdef pyr
#include <sys/time.h>
#endif
typedef struct t_fline aFline; typedef struct t_fline aFline;
typedef struct t_crline aCRline; typedef struct t_crline aCRline;
@@ -67,6 +64,9 @@ typedef struct SMode Mode;
typedef struct ListOptions LOpts; typedef struct ListOptions LOpts;
typedef struct FloodOpt aFloodOpt; typedef struct FloodOpt aFloodOpt;
typedef struct CloneItem aClone; typedef struct CloneItem aClone;
typedef struct ircstatsx ircstats;
typedef struct MotdItem aMotd;
typedef struct trecord aTrecord;
#ifdef NEED_U_INT32_T #ifdef NEED_U_INT32_T
typedef unsigned int u_int32_t; /* XXX Hope this works! */ typedef unsigned int u_int32_t; /* XXX Hope this works! */
@@ -110,10 +110,6 @@ typedef unsigned int u_int32_t; /* XXX Hope this works! */
#define USERHOST_REPLYLEN (NICKLEN+HOSTLEN+USERLEN+5) #define USERHOST_REPLYLEN (NICKLEN+HOSTLEN+USERLEN+5)
#ifdef USE_SERVICES
#include "service.h"
#endif
/* NOTE: this must be down here so the stuff from struct.h IT uses works */ /* NOTE: this must be down here so the stuff from struct.h IT uses works */
#include "whowas.h" #include "whowas.h"
@@ -240,14 +236,14 @@ typedef unsigned int u_int32_t; /* XXX Hope this works! */
#define UMODE_CODER 0x800000 /* User is a network coder */ #define UMODE_CODER 0x800000 /* User is a network coder */
#define UMODE_FCLIENT 0x1000000 /* recieve client on far connects.. */ #define UMODE_FCLIENT 0x1000000 /* recieve client on far connects.. */
#define UMODE_HIDING 0x2000000 /* Totally invisible .. */ #define UMODE_HIDING 0x2000000 /* Totally invisible .. */
#define UMODE_AGENT 0x4000000 /* Is an IRCd Agent local only */
#define UMODE_VICTIM 0x8000000 /* Intentional Victim */ #define UMODE_VICTIM 0x8000000 /* Intentional Victim */
#define UMODE_DEAF 0x10000000 #define UMODE_DEAF 0x10000000
#define UMODE_HIDEOPER 0x20000000 /* Hide oper mode */ #define UMODE_HIDEOPER 0x20000000 /* Hide oper mode */
#define UMODE_SETHOST 0x40000000 /* used sethost */ #define UMODE_SETHOST 0x40000000 /* used sethost */
#define UMODE_STRIPBADWORDS 0x80000000 /* */
#define SEND_UMODES (UMODE_INVISIBLE|UMODE_OPER|UMODE_WALLOP|UMODE_FAILOP|UMODE_HELPOP|UMODE_REGNICK|UMODE_SADMIN|UMODE_NETADMIN|UMODE_TECHADMIN|UMODE_COADMIN|UMODE_ADMIN|UMODE_SERVICES|UMODE_HIDE|UMODE_EYES|UMODE_WHOIS|UMODE_KIX|UMODE_BOT|UMODE_CODER|UMODE_FCLIENT|UMODE_HIDING|UMODE_AGENT|UMODE_DEAF|UMODE_VICTIM|UMODE_HIDEOPER|UMODE_SETHOST) #define SEND_UMODES (UMODE_INVISIBLE|UMODE_OPER|UMODE_WALLOP|UMODE_FAILOP|UMODE_HELPOP|UMODE_REGNICK|UMODE_SADMIN|UMODE_NETADMIN|UMODE_TECHADMIN|UMODE_COADMIN|UMODE_ADMIN|UMODE_SERVICES|UMODE_HIDE|UMODE_EYES|UMODE_WHOIS|UMODE_KIX|UMODE_BOT|UMODE_CODER|UMODE_FCLIENT|UMODE_HIDING|UMODE_DEAF|UMODE_VICTIM|UMODE_HIDEOPER|UMODE_SETHOST|UMODE_STRIPBADWORDS)
#define ALL_UMODES (SEND_UMODES|UMODE_SERVNOTICE|UMODE_LOCOP|UMODE_KILLS|UMODE_CLIENT|UMODE_FLOOD|UMODE_CHATOP|UMODE_SERVICES|UMODE_EYES|UMODE_AGENT) #define ALL_UMODES (SEND_UMODES|UMODE_SERVNOTICE|UMODE_LOCOP|UMODE_KILLS|UMODE_CLIENT|UMODE_FLOOD|UMODE_CHATOP|UMODE_SERVICES|UMODE_EYES)
#define FLAGS_ID (FLAGS_DOID|FLAGS_GOTID) #define FLAGS_ID (FLAGS_DOID|FLAGS_GOTID)
#define PROTO_NOQUIT 0x1 /* Negotiated NOQUIT protocol */ #define PROTO_NOQUIT 0x1 /* Negotiated NOQUIT protocol */
@@ -255,6 +251,8 @@ typedef unsigned int u_int32_t; /* XXX Hope this works! */
#define PROTO_SJOIN 0x4 /* Negotiated SJOIN protocol */ #define PROTO_SJOIN 0x4 /* Negotiated SJOIN protocol */
#define PROTO_NICKv2 0x8 /* Negotiated NICKv2 protocol */ #define PROTO_NICKv2 0x8 /* Negotiated NICKv2 protocol */
#define PROTO_SJOIN2 0x10 /* Negotiated SJOIN2 protocol */ #define PROTO_SJOIN2 0x10 /* Negotiated SJOIN2 protocol */
#define PROTO_UMODE2 0x20 /* Negotiated UMODE2 protocol */
#define PROTO_ALN 0x40 /* Negotiated ALN protocol */
/* /*
* flags macros. * flags macros.
*/ */
@@ -269,6 +267,11 @@ typedef unsigned int u_int32_t; /* XXX Hope this works! */
#define IsHelpOp(x) ((x)->umodes & UMODE_HELPOP) #define IsHelpOp(x) ((x)->umodes & UMODE_HELPOP)
#define IsAdmin(x) ((x)->umodes & UMODE_ADMIN) #define IsAdmin(x) ((x)->umodes & UMODE_ADMIN)
#define IsHiding(x) ((x)->umodes & UMODE_HIDING) #define IsHiding(x) ((x)->umodes & UMODE_HIDING)
#ifdef STRIPBADWORDS
#define IsFilteringWords(x) ((x)->umodes & UMODE_STRIPBADWORDS)
#endif
#define IsNetAdmin(x) ((x)->umodes & UMODE_NETADMIN) #define IsNetAdmin(x) ((x)->umodes & UMODE_NETADMIN)
#define IsTechAdmin(x) ((x)->umodes & UMODE_TECHADMIN) #define IsTechAdmin(x) ((x)->umodes & UMODE_TECHADMIN)
#define IsCoAdmin(x) ((x)->umodes & UMODE_COADMIN) #define IsCoAdmin(x) ((x)->umodes & UMODE_COADMIN)
@@ -277,7 +280,6 @@ typedef unsigned int u_int32_t; /* XXX Hope this works! */
#define SendChatops(x) ((x)->umodes & UMODE_CHATOP) #define SendChatops(x) ((x)->umodes & UMODE_CHATOP)
#define IsOper(x) ((x)->umodes & UMODE_OPER) #define IsOper(x) ((x)->umodes & UMODE_OPER)
#define IsLocOp(x) ((x)->umodes & UMODE_LOCOP) #define IsLocOp(x) ((x)->umodes & UMODE_LOCOP)
#define IsAgent(x) ((x)->umodes & UMODE_AGENT)
#define IsInvisible(x) ((x)->umodes & UMODE_INVISIBLE) #define IsInvisible(x) ((x)->umodes & UMODE_INVISIBLE)
#define IsServices(x) ((x)->umodes & UMODE_SERVICES) #define IsServices(x) ((x)->umodes & UMODE_SERVICES)
#define IsAnOper(x) ((x)->umodes & (UMODE_OPER|UMODE_LOCOP)) #define IsAnOper(x) ((x)->umodes & (UMODE_OPER|UMODE_LOCOP))
@@ -319,7 +321,6 @@ typedef unsigned int u_int32_t; /* XXX Hope this works! */
#define SetHelpOp(x) ((x)->umodes |= UMODE_HELPOP) #define SetHelpOp(x) ((x)->umodes |= UMODE_HELPOP)
#define SetOper(x) ((x)->umodes |= UMODE_OPER) #define SetOper(x) ((x)->umodes |= UMODE_OPER)
#define SetLocOp(x) ((x)->umodes |= UMODE_LOCOP) #define SetLocOp(x) ((x)->umodes |= UMODE_LOCOP)
#define SetAgent(x) ((x)->umodes |= UMODE_AGENT)
#define SetAdmin(x) ((x)->umodes |= UMODE_ADMIN) #define SetAdmin(x) ((x)->umodes |= UMODE_ADMIN)
#define SetSAdmin(x) ((x)->umodes |= UMODE_SADMIN) #define SetSAdmin(x) ((x)->umodes |= UMODE_SADMIN)
#define SetNetAdmin(x) ((x)->umodes |= UMODE_NETADMIN) #define SetNetAdmin(x) ((x)->umodes |= UMODE_NETADMIN)
@@ -355,7 +356,6 @@ typedef unsigned int u_int32_t; /* XXX Hope this works! */
#define ClearFailops(x) ((x)->umodes &= ~UMODE_FAILOP) #define ClearFailops(x) ((x)->umodes &= ~UMODE_FAILOP)
#define ClearChatops(x) ((x)->umodes &= ~UMODE_CHATOP) #define ClearChatops(x) ((x)->umodes &= ~UMODE_CHATOP)
#define ClearOper(x) ((x)->umodes &= ~UMODE_OPER) #define ClearOper(x) ((x)->umodes &= ~UMODE_OPER)
#define ClearAgent(x) ((x)->umodes &= ~UMODE_AGENT)
#define ClearInvisible(x) ((x)->umodes &= ~UMODE_INVISIBLE) #define ClearInvisible(x) ((x)->umodes &= ~UMODE_INVISIBLE)
#define ClearServices(x) ((x)->umodes &= ~UMODE_SERVICES) #define ClearServices(x) ((x)->umodes &= ~UMODE_SERVICES)
#define ClearWallops(x) ((x)->umodes &= ~UMODE_WALLOP) #define ClearWallops(x) ((x)->umodes &= ~UMODE_WALLOP)
@@ -378,12 +378,16 @@ typedef unsigned int u_int32_t; /* XXX Hope this works! */
#define SupportSJOIN(x) ((x)->proto & PROTO_SJOIN) #define SupportSJOIN(x) ((x)->proto & PROTO_SJOIN)
#define SupportNICKv2(x) ((x)->proto & PROTO_NICKv2) #define SupportNICKv2(x) ((x)->proto & PROTO_NICKv2)
#define SupportSJOIN2(x) ((x)->proto & PROTO_SJOIN2) #define SupportSJOIN2(x) ((x)->proto & PROTO_SJOIN2)
#define SupportUMODE2(x) ((x)->proto & PROTO_UMODE2)
#define SupportALN(x) ((x)->proto & PROTO_ALN)
#define SetSJOIN(x) ((x)->proto |= PROTO_SJOIN) #define SetSJOIN(x) ((x)->proto |= PROTO_SJOIN)
#define SetNoQuit(x) ((x)->proto |= PROTO_NOQUIT) #define SetNoQuit(x) ((x)->proto |= PROTO_NOQUIT)
#define SetToken(x) ((x)->proto |= PROTO_TOKEN) #define SetToken(x) ((x)->proto |= PROTO_TOKEN)
#define SetNICKv2(x) ((x)->proto |= PROTO_NICKv2) #define SetNICKv2(x) ((x)->proto |= PROTO_NICKv2)
#define SetSJOIN2(x) ((x)->proto |= PROTO_SJOIN2) #define SetSJOIN2(x) ((x)->proto |= PROTO_SJOIN2)
#define SetUMODE2(x) ((x)->proto |= PROTO_UMODE2)
#define SetALN(x) ((x)->proto |= PROTO_ALN)
#define ClearSJOIN(x) ((x)->proto &= ~PROTO_SJOIN) #define ClearSJOIN(x) ((x)->proto &= ~PROTO_SJOIN)
#define ClearNoQuit(x) ((x)->proto &= ~PROTO_NOQUIT) #define ClearNoQuit(x) ((x)->proto &= ~PROTO_NOQUIT)
@@ -420,7 +424,6 @@ typedef unsigned int u_int32_t; /* XXX Hope this works! */
#define OFLAG_SADMIN 0x01000000 /* services admin gets +a */ #define OFLAG_SADMIN 0x01000000 /* services admin gets +a */
#define OFLAG_WHOIS 0x02000000 /* gets auto +W on oper up */ #define OFLAG_WHOIS 0x02000000 /* gets auto +W on oper up */
#define OFLAG_HIDE 0x04000000 /* gets auto +x on oper up */ #define OFLAG_HIDE 0x04000000 /* gets auto +x on oper up */
#define OFLAG_AGENT 0x08000000 /* Is an IRCd Agent */
#define OFLAG_AFOUNDER 0x10000000 #define OFLAG_AFOUNDER 0x10000000
#define OFLAG_COFOUND 0x20000000 #define OFLAG_COFOUND 0x20000000
#define OFLAG_WMASTER 0x40000000 #define OFLAG_WMASTER 0x40000000
@@ -529,6 +532,41 @@ typedef unsigned int u_int32_t; /* XXX Hope this works! */
#define CURSES_TERM 1 #define CURSES_TERM 1
#define TERMCAP_TERM 2 #define TERMCAP_TERM 2
struct MotdItem {
char line[82];
struct MotdItem *next;
};
/* Hack for T:lines and cached MOTDs */
struct trecord {
char *hostmask;
struct MotdItem *tmotd;
struct MotdItem *trules;
struct tm *tmotd_tm;
struct trecord *next;
};
typedef struct Whowas
{
int hashv;
char *name;
char *username;
char *hostname;
char *virthost;
char *servername;
char *realname;
char *away;
long umodes;
time_t logoff;
struct Client *online; /* Pointer to new nickname for chasing or NULL */
struct Whowas *next; /* for hash table... */
struct Whowas *prev; /* for hash table... */
struct Whowas *cnext; /* for client struct linked list */
struct Whowas *cprev; /* for client struct linked list */
}aWhowas;
struct SqlineItem { struct SqlineItem {
unsigned int status; unsigned int status;
char *sqline; char *sqline;
@@ -539,7 +577,7 @@ struct SqlineItem {
struct ConfItem { struct ConfItem {
unsigned int status; /* If CONF_ILLEGAL, delete when no clients */ unsigned int status; /* If CONF_ILLEGAL, delete when no clients */
int clients; /* Number of *LOCAL* clients using this */ int clients; /* Number of *LOCAL* clients using this */
struct in_addr ipnum; /* ip number of host field */ struct IN_ADDR ipnum; /* ip number of host field */
char *host; char *host;
char *passwd; char *passwd;
char *name; char *name;
@@ -583,6 +621,7 @@ struct ConfItem {
#define CONF_EXCEPT 0x4000000 /* K:Line exception */ #define CONF_EXCEPT 0x4000000 /* K:Line exception */
#define CONF_TLINE 0x8000000 /* T:Line */ #define CONF_TLINE 0x8000000 /* T:Line */
#define CONF_SOCKSEXCEPT 0x10000000 #define CONF_SOCKSEXCEPT 0x10000000
#define CONF_NLINE 0x20000000
#define CONF_OPS (CONF_OPERATOR | CONF_LOCOP) #define CONF_OPS (CONF_OPERATOR | CONF_LOCOP)
#define CONF_SERVER_MASK (CONF_CONNECT_SERVER | CONF_NOCONNECT_SERVER) #define CONF_SERVER_MASK (CONF_CONNECT_SERVER | CONF_NOCONNECT_SERVER)
#define CONF_CLIENT_MASK (CONF_CLIENT | CONF_SERVICE | CONF_OPS | \ #define CONF_CLIENT_MASK (CONF_CLIENT | CONF_SERVICE | CONF_OPS | \
@@ -608,10 +647,10 @@ struct User {
int joined; /* number of channels joined */ int joined; /* number of channels joined */
char username[USERLEN+1]; char username[USERLEN+1];
char realhost[HOSTLEN+1]; char realhost[HOSTLEN+1];
char virthost[HOSTLEN+1]; char *virthost;
char server[HOSTLEN+1]; char *server;
char *swhois; /* special whois thing */ char *swhois; /* special whois thing */
aClient *serv; aClient *serv;
#ifdef LIST_DEBUG #ifdef LIST_DEBUG
aClient *bcptr; aClient *bcptr;
@@ -621,12 +660,10 @@ struct User {
struct Server { struct Server {
struct Server *nexts; struct Server *nexts;
anUser *user; /* who activated this connection */ anUser *user; /* who activated this connection */
char up[HOSTLEN+1]; /* uplink for this server */ char *up; /* uplink for this server */
char by[NICKLEN+1]; char by[NICKLEN+1];
aConfItem *nline; /* N-line pointer for this server */ aConfItem *nline; /* N-line pointer for this server */
time_t timestamp; /* Remotely determined connect try time */ time_t timestamp; /* Remotely determined connect try time */
time_t ghost; /* Local time at which a new server caused a Ghost */
u_short prot; /* Major protocol */
#ifdef LIST_DEBUG #ifdef LIST_DEBUG
aClient *bcptr; aClient *bcptr;
#endif #endif
@@ -674,6 +711,19 @@ struct t_kline {
aTKline *prev; aTKline *prev;
}; };
struct ircstatsx {
int clients; /* total */
int invisible; /* invisible */
int servers; /* servers */
int operators; /* operators */
int unknown; /* unknown local connections */
int channels; /* channels */
int me_clients; /* my clients */
int me_servers; /* my servers */
int me_max; /* local max */
int global_max; /* global max */
};
struct t_fline { struct t_fline {
char *mask; char *mask;
char *reason; char *reason;
@@ -696,15 +746,16 @@ struct t_vhline {
aVHline *next, *prev; aVHline *next, *prev;
}; };
#define LISTENER_NORMAL 0x000001
#define LISTENER_CLIENTSONLY 0x000002
#define LISTENER_SERVERSONLY 0x000004
#define LISTENER_REMOTEADMIN 0x000008
#define LISTENER_JAVACLIENT 0x000010
#define LISTENER_MASK 0x000020
struct Client { struct Client {
struct Client *next, *prev, *hnext; struct Client *next, *prev, *hnext;
anUser *user; /* ...defined, if this is a User */ anUser *user; /* ...defined, if this is a User */
aServer *serv; /* ...defined, if this is a server */ aServer *serv; /* ...defined, if this is a server */
int tag; /* tag */
int iown; /* 1 if mine, 0 if not */
#ifdef USE_SERVICES
aService *service;
#endif
time_t lasttime; /* ...should be only LOCAL clients? --msa */ time_t lasttime; /* ...should be only LOCAL clients? --msa */
time_t firsttime; /* time client was created */ time_t firsttime; /* time client was created */
time_t since; /* last time we parsed something */ time_t since; /* last time we parsed something */
@@ -712,17 +763,16 @@ struct Client {
time_t nextnick; /* Time the next nick change will be allowed */ time_t nextnick; /* Time the next nick change will be allowed */
time_t nexttarget; /* Time until a change in targets is allowed */ time_t nexttarget; /* Time until a change in targets is allowed */
u_char targets[MAXTARGETS]; /* Hash values of current targets */ u_char targets[MAXTARGETS]; /* Hash values of current targets */
aWhowas *whowas;
long flags; /* client flags */ long flags; /* client flags */
long umodes; /* client usermodes */ long umodes; /* client usermodes */
aClient *from; /* == self, if Local Client, *NEVER* NULL! */ aClient *from; /* == self, if Local Client, *NEVER* NULL! */
int fd; /* >= 0, for local clients */ int fd; /* >= 0, for local clients */
int hopcount; /* number of servers to this 0 = local */ int hopcount; /* number of servers to this 0 = local */
int curruser; /* Number of users on this server */
short status; /* Client type */ short status; /* Client type */
char name[HOSTLEN+1]; /* Unique name of the client, nick or host */ char name[HOSTLEN+1]; /* Unique name of the client, nick or host */
char username[USERLEN+1]; /* username here now for auth stuff */ char username[USERLEN+1]; /* username here now for auth stuff */
char info[REALLEN+1]; /* Free form additional client information */ char info[REALLEN+1]; /* Free form additional client information */
char virthost[HOSTLEN+1]; /* hidden host */
aClient *srvptr; /* Server introducing this. May be &me */ aClient *srvptr; /* Server introducing this. May be &me */
Link *history; /* Whowas linked list */ Link *history; /* Whowas linked list */
/* /*
@@ -758,15 +808,12 @@ struct Client {
#ifdef SOCKSPORT #ifdef SOCKSPORT
int socksfd; int socksfd;
#endif #endif
struct in_addr ip; /* keep real ip# too */ struct IN_ADDR ip; /* keep real ip# too */
u_short port; /* and the remote port# too :-) */ u_short port; /* and the remote port# too :-) */
struct hostent *hostp; struct hostent *hostp;
u_short notifies; /* Keep track of count of notifies */ u_short notifies; /* Keep track of count of notifies */
Link *notify; /* Links to clients notify-structures */ Link *notify; /* Links to clients notify-structures */
LOpts *lopt; /* Saved /list options */ LOpts *lopt; /* Saved /list options */
#ifdef pyr
struct timeval lw;
#endif
char sockhost[HOSTLEN+1]; /* This is the host name from the socket char sockhost[HOSTLEN+1]; /* This is the host name from the socket
** and after which the connection was ** and after which the connection was
** accepted. ** accepted.
@@ -914,13 +961,12 @@ struct Channel {
struct Channel *nextch, *prevch, *hnextch; struct Channel *nextch, *prevch, *hnextch;
Mode mode; Mode mode;
time_t creationtime; time_t creationtime;
char topic[TOPICLEN+1]; char *topic;
char topic_nick[NICKLEN+1]; char *topic_nick;
time_t topic_time; time_t topic_time;
int users; int users;
Link *members; Link *members;
Link *invites; Link *invites;
Link *blist;
Ban *banlist; Ban *banlist;
Ban *exlist; /* exceptions */ Ban *exlist; /* exceptions */
char chname[1]; char chname[1];
@@ -976,6 +1022,9 @@ struct Channel {
#define MODE_NOINVITE 0x1000000 #define MODE_NOINVITE 0x1000000
#define MODE_FLOODLIMIT 0x2000000 #define MODE_FLOODLIMIT 0x2000000
#define MODE_NOHIDING 0x4000000 #define MODE_NOHIDING 0x4000000
#ifdef STRIPBADWORDS
#define MODE_STRIPBADWORDS 0x8000000
#endif
#define is_halfop is_half_op #define is_halfop is_half_op
/* /*
* mode flags which take another parameter (With PARAmeterS) * mode flags which take another parameter (With PARAmeterS)
@@ -998,7 +1047,7 @@ struct Channel {
#define PubChannel(x) ((!x) || ((x)->mode.mode &\ #define PubChannel(x) ((!x) || ((x)->mode.mode &\
(MODE_PRIVATE | MODE_SECRET)) == 0) (MODE_PRIVATE | MODE_SECRET)) == 0)
#define IsChannelName(name) ((name) && (*(name) == '#' || *(name) == '&' || *(name) == '+')) #define IsChannelName(name) ((name) && (*(name) == '#'))
#define IsModelessChannel(name) ((name) && (*(name) == '+')) #define IsModelessChannel(name) ((name) && (*(name) == '+'))
#define IsMember(blah,chan) ((blah && blah->user && \ #define IsMember(blah,chan) ((blah && blah->user && \
+63 -6
View File
@@ -1,5 +1,5 @@
/* /*
* IRC - Internet Relay Chat, include/sys.h * Unreal Internet Relay Chat Daemon, include/sys.h
* Copyright (C) 1990 University of Oulu, Computing Center * Copyright (C) 1990 University of Oulu, Computing Center
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@@ -30,7 +30,6 @@
#include <errno.h> #include <errno.h>
# endif # endif
#endif #endif
#include "setup.h" #include "setup.h"
#include <stdio.h> #include <stdio.h>
#include <sys/types.h> #include <sys/types.h>
@@ -85,8 +84,7 @@ extern char *rindex PROTO((char *, char));
#else #else
#include <sys/time.h> #include <sys/time.h>
#endif #endif
#if !defined(DEBUGMODE)
#if !defined(DEBUGMODE)
# ifndef _WIN32 # ifndef _WIN32
# define MyFree(x) if ((x) != NULL) free(x) # define MyFree(x) if ((x) != NULL) free(x)
# else # else
@@ -95,14 +93,13 @@ extern char *rindex PROTO((char *, char));
#else #else
#define free(x) MyFree(x) #define free(x) MyFree(x)
#endif #endif
#ifdef NEXT #ifdef NEXT
#define VOIDSIG int /* whether signal() returns int of void */ #define VOIDSIG int /* whether signal() returns int of void */
#else #else
#define VOIDSIG void /* whether signal() returns int of void */ #define VOIDSIG void /* whether signal() returns int of void */
#endif #endif
#ifdef SOL20 #ifdef _SOLARIS
#define OPT_TYPE char /* opt type for get/setsockopt */ #define OPT_TYPE char /* opt type for get/setsockopt */
#else #else
#define OPT_TYPE void #define OPT_TYPE void
@@ -137,5 +134,65 @@ typedef unsigned int u_int;
#ifdef _WIN32 #ifdef _WIN32
#define MYOSNAME "Win32" #define MYOSNAME "Win32"
#endif #endif
#ifdef DEBUGMODE
#define ircsprintf sprintf
#define ircvsprintf vsprintf
#endif
/*
* IPv4 or IPv6 structures?
*/
#ifdef INET6
# define AND16(x) ((x)[0]&(x)[1]&(x)[2]&(x)[3]&(x)[4]&(x)[5]&(x)[6]&(x)[7]&(x)[8]&(x)[9]&(x)[10]&(x)[11]&(x)[12]&(x)[13]&(x)[14]&(x)[15])
static unsigned char minus_one[]={ 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 0};
# define WHOSTENTP(x) ((x)[0]|(x)[1]|(x)[2]|(x)[3]|(x)[4]|(x)[5]|(x)[6]|(x)[7]|(x)[8]|(x)[9]|(x)[10]|(x)[11]|(x)[12]|(x)[13]|(x)[14]|(x)[15])
# define AFINET AF_INET6
# define SOCKADDR_IN sockaddr_in6
# define SOCKADDR sockaddr
# define SIN_FAMILY sin6_family
# define SIN_PORT sin6_port
# define SIN_ADDR sin6_addr
# define S_ADDR s6_addr
# define IN_ADDR in6_addr
# ifndef uint32_t
# define uint32_t __u32
# endif
# define MYDUMMY_SIZE 128
char mydummy[MYDUMMY_SIZE];
char mydummy2[MYDUMMY_SIZE];
# if defined(linux) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(bsdi)
# ifndef s6_laddr
# define s6_laddr s6_addr32
# endif
# endif
# if defined(linux)
static const struct in6_addr in6addr_any={ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0};
# endif
# define IRCDCONF_DELIMITER '%'
#else
# define AFINET AF_INET
# define SOCKADDR_IN sockaddr_in
# define SOCKADDR sockaddr
# define SIN_FAMILY sin_family
# define SIN_PORT sin_port
# define SIN_ADDR sin_addr
# define S_ADDR s_addr
# define IN_ADDR in_addr
# define WHOSTENTP(x) (x)
# define IRCDCONF_DELIMITER ':'
#endif
#endif /* __sys_include__ */ #endif /* __sys_include__ */
+1 -1
View File
@@ -2,7 +2,7 @@
* Userload module by Michael L. VanLoon (mlv) <michaelv@iastate.edu> * Userload module by Michael L. VanLoon (mlv) <michaelv@iastate.edu>
* Written 2/93. Originally grafted into irc2.7.2g 4/93. * Written 2/93. Originally grafted into irc2.7.2g 4/93.
* *
* IRC - Internet Relay Chat, ircd/userload.h * Unreal Internet Relay Chat Daemon, ircd/userload.h
* Copyright (C) 1990 University of Oulu, Computing Center * Copyright (C) 1990 University of Oulu, Computing Center
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
+6 -11
View File
@@ -24,24 +24,19 @@
#endif #endif
/**/ /**/
#define COMPILEINFO DEBUGMODESET DEBUGSET #define COMPILEINFO DEBUGMODESET DEBUGSET
#ifndef WEBTV
#define XTRAINFO ""
#else
#define XTRAINFO "(WebTV)"
#endif
/* /*
* Version Unreal3.0 * Version Unreal3.1
*/ */
#define UnrealProtocol 2300 #define UnrealProtocol 2301
#define PATCH1 "3" #define PATCH1 "3"
#define PATCH2 ".0" #define PATCH2 ".1"
#define PATCH3 "-Morrigan" #define PATCH3 "-Silverheart"
#define PATCH4 "(fix)" #define PATCH4 "(beta3)"
#define PATCH5 "" #define PATCH5 ""
#define PATCH6 "" #define PATCH6 ""
#define PATCH7 "" #define PATCH7 ""
#define PATCH8 COMPILEINFO #define PATCH8 COMPILEINFO
#define PATCH9 XTRAINFO #define PATCH9 ""
#ifndef _WIN32 #ifndef _WIN32
#define BASE_VERSION "Unreal" #define BASE_VERSION "Unreal"
+12 -46
View File
@@ -18,58 +18,23 @@
*/ */
/* /*
* $Id$ * from original rcs
* * $ Id: whowas.h,v 6.1 1991/07/04 21:04:39 gruner stable gruner $
* $Log$
* Revision 1.1.1.1 2000/01/30 12:16:34 stskeeps
* Begin of CVS at cvs.unreal.sourceforge.net
*
*
* Revision 1.1.1.1 1999/09/01 23:20:37 stskeeps
*
* Revision 1.1.1.1 1999/07/22 13:56:41 stskeeps
* 16:56 22-07-99 techie
* - Started on using CVS to develop Unreal
*
*
* Revision 1.1.1.1 1999/07/21 10:48:18 stskeeps
* 12:47 GMT+2 21 July 1999 - Techie
* Starting Unreal with CVS..
*
*
* Revision 1.2 1997/12/29 07:17:35 wd
* df4.6.2
* ee CHANGES for updates
* -wd
*
* Revision 1.1.1.1 1997/08/22 17:23:01 donwulff
* Original import from the "deadlined" version.
*
* Revision 1.1.1.1 1996/11/18 07:53:42 explorer
* ircd 4.3.3 -- about time
*
* Revision 1.1.1.1.4.1 1996/09/16 02:45:41 donwulff
* *** empty log message ***
* *
* $ Log: whowas.h,v $
* Revision 6.1 1991/07/04 21:04:39 gruner * Revision 6.1 1991/07/04 21:04:39 gruner
* Revision 2.6.1 [released] * Revision 2.6.1 [released]
* *
* Revision 6.0 1991/07/04 18:05:08 gruner * Revision 6.0 1991/07/04 18:05:08 gruner
* frozen beta revision 2.6.1 * frozen beta revision 2.6.1
* *
* th+hybrid rcs version
* $Id$
*/ */
#ifndef __whowas_include__ #ifndef __whowas_include__
#define __whowas_include__ #define __whowas_include__
#ifndef PROTO
#if __STDC__
# define PROTO(x) x
#else
# define PROTO(x) ()
#endif /* __STDC__ */
#endif /* ! PROTO */
/* /*
** WHOWAS structure moved here from whowas.c ** WHOWAS structure moved here from whowas.c
*/ */
@@ -77,11 +42,12 @@ typedef struct aname {
anUser *ww_user; anUser *ww_user;
aClient *ww_online; aClient *ww_online;
time_t ww_logout; time_t ww_logout;
long ww_umodes; long ww_umodes;
char ww_nick[NICKLEN+1]; char ww_nick[NICKLEN+1];
char ww_info[REALLEN+1]; char ww_info[REALLEN+1];
} aName; } aName;
/* /*
** add_history ** add_history
** Add the currently defined name of the client to history. ** Add the currently defined name of the client to history.
@@ -89,7 +55,7 @@ typedef struct aname {
** Client must be a fully registered user (specifically, ** Client must be a fully registered user (specifically,
** the user structure must have been allocated). ** the user structure must have been allocated).
*/ */
void add_history PROTO((aClient *)); void add_history (aClient *, int);
/* /*
** off_history ** off_history
@@ -98,7 +64,7 @@ void add_history PROTO((aClient *));
** structures and it must know when they cease to exist. This ** structures and it must know when they cease to exist. This
** also implicitly calls AddHistory. ** also implicitly calls AddHistory.
*/ */
void off_history PROTO((aClient *)); void off_history (aClient *);
/* /*
** get_history ** get_history
@@ -106,15 +72,15 @@ void off_history PROTO((aClient *));
** nickname within the timelimit. Returns NULL, if no ** nickname within the timelimit. Returns NULL, if no
** one found... ** one found...
*/ */
aClient *get_history PROTO((char *, time_t)); aClient *get_history (char *, time_t);
/* Nick name */ /* Nick name */
/* Time limit in seconds */ /* Time limit in seconds */
int m_whowas PROTO((aClient *, aClient *, int, char *[])); int m_whowas (aClient *, aClient *, int, char *[]);
/* /*
** for debugging...counts related structures stored in whowas array. ** for debugging...counts related structures stored in whowas array.
*/ */
void count_whowas_memory PROTO((int *, int *, u_long *)); void count_whowas_memory (int *, u_long *);
#endif /* __whowas_include__ */ #endif /* __whowas_include__ */
+11 -1
View File
@@ -21,4 +21,14 @@ networks/digitalirc.network ......: DigitalIRC (http://www.digitalirc.net)
networks/fireirc.network .........: FireIRC (http://www.fireirc.net) networks/fireirc.network .........: FireIRC (http://www.fireirc.net)
networks/stormdancing.network ....: StormDancing (http://www.stormdancing.net) networks/stormdancing.network ....: StormDancing (http://www.stormdancing.net)
networks/972-scripterz.network ...: 972-scripterz networks/972-scripterz.network ...: 972-scripterz
networks/v64net.network ..........: v64 networks/v64net.network ..........: v64
networks/treklink.network ........: Treklink (http://www.treklink.net)
networks/axenet.network ..........: AXEnet
networks/kammtech.network ........: KammTecH
networks/linuxactive.network .....: Linuxactive (http://www.linuxactive.net)
networks/ircthai.network .........: IRCThai.com (http://www.ircthai.com)
networks/chatplace.network .......: ChatPlace (http://www.chatplace.net)
networks/interturk.network .......: InterTurk (http://www.interturk.net)
networks/cc2.network .............: CC2 (http://www.cc2.org)
networks/kissland.network ........: Kissland (http://www.kissland.com)
networks/digital-irc.network .....: Digital-IRC (http://www.digital-irc.net)
+49 -2
View File
@@ -1,4 +1,4 @@
ver^1.1 ver^1.5
# #
# UnrealIRCd Configuration file - unrealircd.conf # UnrealIRCd Configuration file - unrealircd.conf
# (C) Carsten Munk 1999 - Under the GNU license # (C) Carsten Munk 1999 - Under the GNU license
@@ -7,7 +7,7 @@ ver^1.1
# #
# change the filename to what network header file you use # change the filename to what network header file you use
# relative to DPATH # relative to DPATH
Include .................: networks/roxnet.network Include .................: networks/unreal-test.network
# #
# What K:Line address can K:lined users mail at? # What K:Line address can K:lined users mail at?
@@ -22,6 +22,9 @@ Set MODE_X ..............: 1
# 1 = Yes 0 = No # 1 = Yes 0 = No
Set MODE_I ..............: 0 Set MODE_I ..............: 0
# Auto +X users when they connect? This can help as a new REMOVE_ADVERTISE
Set MODE_STRIPWORDS .....: 0
# If compiled on a halfhub network this will upgrade it to be a real hub # If compiled on a halfhub network this will upgrade it to be a real hub
# * else if tried on a leaf (not hub) it will cause an error # * else if tried on a leaf (not hub) it will cause an error
# * NOTE: There are only TWO versions of UnrealIRCd - Leaf and [Half]Hub # * NOTE: There are only TWO versions of UnrealIRCd - Leaf and [Half]Hub
@@ -79,3 +82,47 @@ Set SOCKS_QUIT_MESSAGE ..: Insecure SOCKS server
# How many seconds will a insecure SOCKS be banned? # How many seconds will a insecure SOCKS be banned?
# #
Set SOCKSBANTIME ........: 86400 Set SOCKSBANTIME ........: 86400
#
# How many channels are users allowed to join?
#
Set MAXCHANNELSPERUSER ..: 10
#
# Will we support WebTV, NOTE replaces /NOTICE with a /PRIVMSG
# 1 = Yes 0 = No
Set WEBTV_SUPPORT .......: 0
#
# Should usermode +I (Total Invisibility) be disabled?
# 1 = Yes 0 = No
Set NO_OPER_HIDING ......: 0
#
# Should we make the user join a channel(s) on connect?
# 0 = No, if Yes, enter the channel name
# to make them join multiple channels seperate with ,s
# ex Set AUTO_JOIN_CHANS .....: #chan1,#chan2,#chan3
#
Set AUTO_JOIN_CHANS .....: 0
#
# Should we make the user join a channel(s) on /oper?
# 0 = No, if Yes, enter the channel name
# to make them join multiple channels seperate with ,s
# ex Set OPER_AUTO_JOIN_CHANS : #chan1,#chan2,#chan3
#
Set OPER_AUTO_JOIN_CHANS : 0
#
# This allows you specify the amount of time (in seconds)
# to wait for a DNS response. Set this to 0 to disable
# hostname resolving
#
Set HOST_TIMEOUT ........: 2
#
# This allows you to specify the anount of retries
# that should be send when no DNS response is received
#
Set HOST_RETRIES ........: 2
+8 -8
View File
@@ -25,40 +25,40 @@ Set SERVICES_NAME .: service.uzaynet.com
# This is the virtual hostname IRCops will get if iNAH option is enabled # This is the virtual hostname IRCops will get if iNAH option is enabled
# on oper up # on oper up
Set oper_host .....: ircop.silverserver.nu Set oper_host .....: ircop.uzaynet.com
# This is the virtual hostname Server Admins will get if iNAH option is enabled # This is the virtual hostname Server Admins will get if iNAH option is enabled
# on oper up # on oper up
Set admin_host ....: admin.uzaynet.nu Set admin_host ....: admin.uzaynet.com
# This is the virtual hostname Local IRCops will get if iNAH option is enabled # This is the virtual hostname Local IRCops will get if iNAH option is enabled
# on oper up # on oper up
Set locop_host ....: locop.uzaynet.nu Set locop_host ....: locop.uzaynet.com
# This is the virtual hostname Services Operators/Admins will get # This is the virtual hostname Services Operators/Admins will get
# if iNAH option is enabled on oper up # if iNAH option is enabled on oper up
Set sadmin_host ...: serviceop.uzaynet.nu Set sadmin_host ...: serviceop.uzaynet.com
# This is the virtual hostname NetAdmins will get # This is the virtual hostname NetAdmins will get
# if iNAH option is enabled on oper up # if iNAH option is enabled on oper up
Set netadmin_host .: netadmin.uzaynet.nu Set netadmin_host .: netadmin.uzaynet.com
# This is the virtual hostname CoAdmins will get # This is the virtual hostname CoAdmins will get
# if iNAH option is enabled on oper up # if iNAH option is enabled on oper up
Set coadmin_host ..: coadmin.uzaynet.nu Set coadmin_host ..: coadmin.uzaynet.com
# This is the virtual hostname TechAdmins will get # This is the virtual hostname TechAdmins will get
# if iNAH option is enabled on oper up # if iNAH option is enabled on oper up
Set techadmin_host : techadmin.uzaynet.nu Set techadmin_host : techadmin.uzaynet.com
# This is the prefix of the hidden host (cloaking) hostname # This is the prefix of the hidden host (cloaking) hostname
Set hidden_host ...: UzayNet Set hidden_host ...: UzayNet
# This is the domain of the IRC network # This is the domain of the IRC network
Set netdomain .....: uzaynet.nu Set netdomain .....: uzaynet.com
# This is where people can go for help # This is where people can go for help
Set helpchan ......: #Help Set helpchan ......: #Help
# This is the name of the stats server # This is the name of the stats server
+241 -240
View File
@@ -6,226 +6,226 @@
#include <io.h> #include <io.h>
#endif #endif
#include <fcntl.h> #include <fcntl.h>
#ifdef _WIN32 #ifdef _WIN32
#include <sys\stat.h> #include <sys\stat.h>
#endif #endif
#include <time.h> #include <time.h>
int _FD_SETSIZE = 1024; int _FD_SETSIZE = 1024;
char _NS_ADDRESS[256], _KLINE_ADDRESS[256]; char _NS_ADDRESS[256], _KLINE_ADDRESS[256];
char Makefile[] = char Makefile[] =
"CC=cl\n" "CC=cl\n"
"FD_SETSIZE=/D FD_SETSIZE=$FD_SETSIZE\n" "FD_SETSIZE=/D FD_SETSIZE=$FD_SETSIZE\n"
"CFLAGS=/MT /O2 /I ./INCLUDE /Fosrc/ /nologo $(FD_SETSIZE) $(NS_ADDRESS) /D NOSPOOF=1 /c\n" "CFLAGS=/MT /O2 /I ./INCLUDE /Fosrc/ /nologo $(FD_SETSIZE) $(NS_ADDRESS) /D NOSPOOF=1 /c\n"
"INCLUDES=./include/struct.h ./include/config.h ./include/sys.h \\\n" "INCLUDES=./include/struct.h ./include/config.h ./include/sys.h \\\n"
" ./include/common.h ./include/settings.h ./include/h.h ./include/numeric.h \\\n" " ./include/common.h ./include/settings.h ./include/h.h ./include/numeric.h \\\n"
" ./include/msg.h ./include/setup.h\n" " ./include/msg.h ./include/setup.h\n"
"LINK=link.exe\n" "LINK=link.exe\n"
"LFLAGS=kernel32.lib user32.lib gdi32.lib shell32.lib wsock32.lib \\\n" "LFLAGS=kernel32.lib user32.lib gdi32.lib shell32.lib wsock32.lib \\\n"
" oldnames.lib libcmt.lib /nodefaultlib /nologo /out:SRC/WIRCD.EXE\n" " oldnames.lib libcmt.lib /nodefaultlib /nologo /out:SRC/WIRCD.EXE\n"
"OBJ_FILES=SRC/CHANNEL.OBJ SRC/USERLOAD.OBJ SRC/SEND.OBJ SRC/BSD.OBJ \\\n" "OBJ_FILES=SRC/CHANNEL.OBJ SRC/USERLOAD.OBJ SRC/SEND.OBJ SRC/BSD.OBJ \\\n"
" SRC/CIO_MAIN.OBJ SRC/S_CONF.OBJ SRC/DBUF.OBJ SRC/RES.OBJ \\\n" " SRC/CIO_MAIN.OBJ SRC/S_CONF.OBJ SRC/DBUF.OBJ SRC/RES.OBJ \\\n"
" SRC/HASH.OBJ SRC/CIO_INIT.OBJ SRC/PARSE.OBJ SRC/IRCD.OBJ \\\n" " SRC/HASH.OBJ SRC/CIO_INIT.OBJ SRC/PARSE.OBJ SRC/IRCD.OBJ \\\n"
" SRC/S_NUMERIC.OBJ SRC/WHOWAS.OBJ SRC/RES_COMP.OBJ SRC/S_AUTH.OBJ \\\n" " SRC/S_NUMERIC.OBJ SRC/WHOWAS.OBJ SRC/RES_COMP.OBJ SRC/S_AUTH.OBJ \\\n"
" SRC/HELP.OBJ SRC/S_MISC.OBJ SRC/MATCH.OBJ SRC/CRULE.OBJ \\\n" " SRC/HELP.OBJ SRC/S_MISC.OBJ SRC/MATCH.OBJ SRC/CRULE.OBJ \\\n"
" SRC/S_DEBUG.OBJ SRC/RES_INIT.OBJ SRC/SUPPORT.OBJ SRC/LIST.OBJ \\\n" " SRC/S_DEBUG.OBJ SRC/RES_INIT.OBJ SRC/SUPPORT.OBJ SRC/LIST.OBJ \\\n"
" SRC/S_ERR.OBJ SRC/PACKET.OBJ SRC/CLASS.OBJ SRC/S_BSD.OBJ \\\n" " SRC/S_ERR.OBJ SRC/PACKET.OBJ SRC/CLASS.OBJ SRC/S_BSD.OBJ \\\n"
" SRC/MD5.OBJ SRC/S_SERV.OBJ SRC/S_USER.OBJ SRC/WIN32.OBJ \\\n" " SRC/MD5.OBJ SRC/S_SERV.OBJ SRC/S_USER.OBJ SRC/WIN32.OBJ \\\n"
" SRC/DYNCONF.OBJ\\\n" " SRC/DYNCONF.OBJ\\\n"
" SRC/VERSION.OBJ SRC/WIN32.RES SRC/CLOAK.OBJ SRC/S_UNREAL.OBJ\n" " SRC/VERSION.OBJ SRC/WIN32.RES SRC/CLOAK.OBJ SRC/S_UNREAL.OBJ\n"
"RC=rc.exe\n" "RC=rc.exe\n"
"\n" "\n"
"ALL: SRC/WIRCD.EXE SRC/CHKCONF.EXE\n" "ALL: SRC/WIRCD.EXE SRC/CHKCONF.EXE\n"
" @echo Complete.\n" " @echo Complete.\n"
"\n" "\n"
"CLEAN:\n" "CLEAN:\n"
" -@erase src\\*.exe 2>NUL\n" " -@erase src\\*.exe 2>NUL\n"
" -@erase src\\*.obj 2>NUL\n" " -@erase src\\*.obj 2>NUL\n"
" -@erase src\\win32.res 2>NUL\n" " -@erase src\\win32.res 2>NUL\n"
" -@erase src\\version.c 2>NUL\n" " -@erase src\\version.c 2>NUL\n"
"\n" "\n"
"include/setup.h:\n" "include/setup.h:\n"
" @echo Hmm...doesn't look like you've run Config...\n" " @echo Hmm...doesn't look like you've run Config...\n"
" @echo Doing so now.\n" " @echo Doing so now.\n"
" @config.exe\n" " @config.exe\n"
"\n" "\n"
"src/version.c: dummy\n" "src/version.c: dummy\n"
" @config.exe -v\n" " @config.exe -v\n"
"\n" "\n"
"src/version.obj: src/version.c\n" "src/version.obj: src/version.c\n"
" $(CC) $(CFLAGS) src/version.c\n" " $(CC) $(CFLAGS) src/version.c\n"
"\n" "\n"
"SRC/WIRCD.EXE: $(OBJ_FILES) src/version.obj\n" "SRC/WIRCD.EXE: $(OBJ_FILES) src/version.obj\n"
" $(LINK) $(LFLAGS) $(OBJ_FILES)\n" " $(LINK) $(LFLAGS) $(OBJ_FILES)\n"
"\n" "\n"
"SRC/CHKCONF.EXE: ./include/struct.h ./include/config.h ./include/sys.h \\\n" "SRC/CHKCONF.EXE: ./include/struct.h ./include/config.h ./include/sys.h \\\n"
" ./include/common.h ./src/crule.c ./src/match.c ./src/chkconf.c\n" " ./include/common.h ./src/crule.c ./src/match.c ./src/chkconf.c\n"
" $(CC) /nologo /I ./include /D CR_CHKCONF /Fosrc/chkcrule.obj /c src/crule.c\n" " $(CC) /nologo /I ./include /D CR_CHKCONF /Fosrc/chkcrule.obj /c src/crule.c\n"
" $(CC) /nologo /I ./include /D CR_CHKCONF /Fosrc/chkmatch.obj /c src/match.c\n" " $(CC) /nologo /I ./include /D CR_CHKCONF /Fosrc/chkmatch.obj /c src/match.c\n"
" $(CC) /nologo /I ./include /D CR_CHKCONF /Fosrc/chkconf.obj /c src/chkconf.c\n" " $(CC) /nologo /I ./include /D CR_CHKCONF /Fosrc/chkconf.obj /c src/chkconf.c\n"
" $(LINK) /nologo /out:src/chkconf.exe src/chkconf.obj src/chkmatch.obj \\\n" " $(LINK) /nologo /out:src/chkconf.exe src/chkconf.obj src/chkmatch.obj \\\n"
" src/chkcrule.obj\n" " src/chkcrule.obj\n"
"\n" "\n"
"src/parse.obj: src/parse.c $(INCLUDES)\n" "src/parse.obj: src/parse.c $(INCLUDES)\n"
" $(CC) $(CFLAGS) src/parse.c\n" " $(CC) $(CFLAGS) src/parse.c\n"
"\n" "\n"
"src/bsd.obj: src/bsd.c $(INCLUDES)\n" "src/bsd.obj: src/bsd.c $(INCLUDES)\n"
" $(CC) $(CFLAGS) src/bsd.c\n" " $(CC) $(CFLAGS) src/bsd.c\n"
"\n" "\n"
"src/dbuf.obj: src/dbuf.c $(INCLUDES) ./include/dbuf.h\n" "src/dbuf.obj: src/dbuf.c $(INCLUDES) ./include/dbuf.h\n"
" $(CC) $(CFLAGS) src/dbuf.c\n" " $(CC) $(CFLAGS) src/dbuf.c\n"
"\n" "\n"
"src/packet.obj: src/packet.c $(INCLUDES)\n" "src/packet.obj: src/packet.c $(INCLUDES)\n"
" $(CC) $(CFLAGS) src/packet.c\n" " $(CC) $(CFLAGS) src/packet.c\n"
"\n" "\n"
"src/send.obj: src/send.c $(INCLUDES)\n" "src/send.obj: src/send.c $(INCLUDES)\n"
" $(CC) $(CFLAGS) src/send.c\n" " $(CC) $(CFLAGS) src/send.c\n"
"\n" "\n"
"src/match.obj: src/match.c $(INCLUDES)\n" "src/match.obj: src/match.c $(INCLUDES)\n"
" $(CC) $(CFLAGS) src/match.c\n" " $(CC) $(CFLAGS) src/match.c\n"
"\n" "\n"
"src/support.obj: src/support.c $(INCLUDES)\n" "src/support.obj: src/support.c $(INCLUDES)\n"
" $(CC) $(CFLAGS) src/support.c\n" " $(CC) $(CFLAGS) src/support.c\n"
"\n" "\n"
"src/channel.obj: src/channel.c $(INCLUDES) ./include/channel.h\n" "src/channel.obj: src/channel.c $(INCLUDES) ./include/channel.h\n"
" $(CC) $(CFLAGS) src/channel.c\n" " $(CC) $(CFLAGS) src/channel.c\n"
"\n" "\n"
"src/class.obj: src/class.c $(INCLUDES) ./include/class.h\n" "src/class.obj: src/class.c $(INCLUDES) ./include/class.h\n"
" $(CC) $(CFLAGS) src/class.c\n" " $(CC) $(CFLAGS) src/class.c\n"
"\n" "\n"
"src/ircd.obj: src/ircd.c $(INCLUDES)\n" "src/ircd.obj: src/ircd.c $(INCLUDES)\n"
" $(CC) $(CFLAGS) src/ircd.c\n" " $(CC) $(CFLAGS) src/ircd.c\n"
"\n" "\n"
"src/list.obj: src/list.c $(INCLUDES)\n" "src/list.obj: src/list.c $(INCLUDES)\n"
" $(CC) $(CFLAGS) src/list.c\n" " $(CC) $(CFLAGS) src/list.c\n"
"\n" "\n"
"src/res.obj: src/res.c $(INCLUDES)\n" "src/res.obj: src/res.c $(INCLUDES)\n"
" $(CC) $(CFLAGS) src/res.c\n" " $(CC) $(CFLAGS) src/res.c\n"
"\n" "\n"
"src/s_bsd.obj: src/s_bsd.c $(INCLUDES)\n" "src/s_bsd.obj: src/s_bsd.c $(INCLUDES)\n"
" $(CC) $(CFLAGS) src/s_bsd.c\n" " $(CC) $(CFLAGS) src/s_bsd.c\n"
"\n" "\n"
"src/s_auth.obj: src/s_auth.c $(INCLUDES)\n" "src/s_auth.obj: src/s_auth.c $(INCLUDES)\n"
" $(CC) $(CFLAGS) src/s_auth.c\n" " $(CC) $(CFLAGS) src/s_auth.c\n"
"\n" "\n"
"src/s_conf.obj: src/s_conf.c $(INCLUDES)\n" "src/s_conf.obj: src/s_conf.c $(INCLUDES)\n"
" $(CC) $(CFLAGS) src/s_conf.c\n" " $(CC) $(CFLAGS) src/s_conf.c\n"
"\n" "\n"
"src/s_debug.obj: src/s_debug.c $(INCLUDES)\n" "src/s_debug.obj: src/s_debug.c $(INCLUDES)\n"
" $(CC) $(CFLAGS) src/s_debug.c\n" " $(CC) $(CFLAGS) src/s_debug.c\n"
"\n" "\n"
"src/s_err.obj: src/s_err.c $(INCLUDES)\n" "src/s_err.obj: src/s_err.c $(INCLUDES)\n"
" $(CC) $(CFLAGS) src/s_err.c\n" " $(CC) $(CFLAGS) src/s_err.c\n"
"\n" "\n"
"src/s_misc.obj: src/s_misc.c $(INCLUDES) ./include/dbuf.h\n" "src/s_misc.obj: src/s_misc.c $(INCLUDES) ./include/dbuf.h\n"
" $(CC) $(CFLAGS) src/s_misc.c\n" " $(CC) $(CFLAGS) src/s_misc.c\n"
"\n" "\n"
"src/s_user.obj: src/s_user.c $(INCLUDES) ./include/dbuf.h \\\n" "src/s_user.obj: src/s_user.c $(INCLUDES) ./include/dbuf.h \\\n"
" ./include/channel.h ./include/whowas.h\n" " ./include/channel.h ./include/whowas.h\n"
" $(CC) $(CFLAGS) src/s_user.c\n" " $(CC) $(CFLAGS) src/s_user.c\n"
"\n" "\n"
"src/dynconf.obj: src/dynconf.c $(INCLUDES) ./include/dbuf.h \\\n" "src/dynconf.obj: src/dynconf.c $(INCLUDES) ./include/dbuf.h \\\n"
" ./include/channel.h ./include/whowas.h ./include/dynconf.h\n" " ./include/channel.h ./include/whowas.h ./include/dynconf.h\n"
" $(CC) $(CFLAGS) src/dynconf.c\n" " $(CC) $(CFLAGS) src/dynconf.c\n"
"\n" "\n"
"src/s_unreal.obj: src/s_unreal.c $(INCLUDES) ./include/dbuf.h \\\n" "src/s_unreal.obj: src/s_unreal.c $(INCLUDES) ./include/dbuf.h \\\n"
" ./include/channel.h ./include/whowas.h\n" " ./include/channel.h ./include/whowas.h\n"
" $(CC) $(CFLAGS) src/s_unreal.c\n" " $(CC) $(CFLAGS) src/s_unreal.c\n"
"\n" "\n"
"src/cloak.obj: src/cloak.c $(INCLUDES) ./include/dbuf.h \\\n" "src/cloak.obj: src/cloak.c $(INCLUDES) ./include/dbuf.h \\\n"
" ./include/channel.h ./include/whowas.h\n" " ./include/channel.h ./include/whowas.h\n"
" $(CC) $(CFLAGS) src/s_unreal.c\n" " $(CC) $(CFLAGS) src/s_unreal.c\n"
"\n" "\n"
"src/s_serv.obj: src/s_serv.c $(INCLUDES) ./include/dbuf.h ./include/whowas.h\n" "src/s_serv.obj: src/s_serv.c $(INCLUDES) ./include/dbuf.h ./include/whowas.h\n"
" $(CC) $(CFLAGS) src/s_serv.c\n" " $(CC) $(CFLAGS) src/s_serv.c\n"
"\n" "\n"
"src/s_numeric.obj: src/s_numeric.c $(INCLUDES) ./include/dbuf.h\n" "src/s_numeric.obj: src/s_numeric.c $(INCLUDES) ./include/dbuf.h\n"
" $(CC) $(CFLAGS) src/s_numeric.c\n" " $(CC) $(CFLAGS) src/s_numeric.c\n"
"\n" "\n"
"src/whowas.obj: src/whowas.c $(INCLUDES) ./include/dbuf.h ./include/whowas.h\n" "src/whowas.obj: src/whowas.c $(INCLUDES) ./include/dbuf.h ./include/whowas.h\n"
" $(CC) $(CFLAGS) src/whowas.c\n" " $(CC) $(CFLAGS) src/whowas.c\n"
"\n" "\n"
"src/hash.obj: src/hash.c $(INCLUDES) ./include/hash.h\n" "src/hash.obj: src/hash.c $(INCLUDES) ./include/hash.h\n"
" $(CC) $(CFLAGS) src/hash.c\n" " $(CC) $(CFLAGS) src/hash.c\n"
"\n" "\n"
"src/crule.obj: src/crule.c $(INCLUDES)\n" "src/crule.obj: src/crule.c $(INCLUDES)\n"
" $(CC) $(CFLAGS) src/crule.c\n" " $(CC) $(CFLAGS) src/crule.c\n"
"\n" "\n"
"src/win32.obj: src/win32.c $(INCLUDES) ./include/resource.h\n" "src/win32.obj: src/win32.c $(INCLUDES) ./include/resource.h\n"
" $(CC) $(CFLAGS) src/win32.c\n" " $(CC) $(CFLAGS) src/win32.c\n"
"\n" "\n"
"src/cio_main.obj: src/cio_main.c $(INCLUDES) ./include/cio.h ./include/ciofunc.h\n" "src/cio_main.obj: src/cio_main.c $(INCLUDES) ./include/cio.h ./include/ciofunc.h\n"
" $(CC) $(CFLAGS) src/cio_main.c\n" " $(CC) $(CFLAGS) src/cio_main.c\n"
"\n" "\n"
"src/cio_init.obj: src/cio_init.c $(INCLUDES) ./include/cio.h ./include/ciofunc.h\n" "src/cio_init.obj: src/cio_init.c $(INCLUDES) ./include/cio.h ./include/ciofunc.h\n"
" $(CC) $(CFLAGS) src/cio_init.c\n" " $(CC) $(CFLAGS) src/cio_init.c\n"
"\n" "\n"
"src/res_comp.obj: src/res_comp.c $(INCLUDES)\n" "src/res_comp.obj: src/res_comp.c $(INCLUDES)\n"
" $(CC) $(CFLAGS) src/res_comp.c\n" " $(CC) $(CFLAGS) src/res_comp.c\n"
"\n" "\n"
"src/res_init.obj: src/res_init.c $(INCLUDES)\n" "src/res_init.obj: src/res_init.c $(INCLUDES)\n"
" $(CC) $(CFLAGS) src/res_init.c\n" " $(CC) $(CFLAGS) src/res_init.c\n"
"\n" "\n"
"src/help.obj: src/help.c $(INCLUDES)\n" "src/help.obj: src/help.c $(INCLUDES)\n"
" $(CC) $(CFLAGS) src/help.c\n" " $(CC) $(CFLAGS) src/help.c\n"
"\n" "\n"
"src/md5.obj: src/md5.c $(INCLUDES)\n" "src/md5.obj: src/md5.c $(INCLUDES)\n"
" $(CC) $(CFLAGS) src/md5.c\n" " $(CC) $(CFLAGS) src/md5.c\n"
"\n" "\n"
"src/win32.res: src/win32.rc\n" "src/win32.res: src/win32.rc\n"
" $(RC) /l 0x409 /fosrc/win32.res /i ./include /i ./src \\\n" " $(RC) /l 0x409 /fosrc/win32.res /i ./include /i ./src \\\n"
" /d NDEBUG src/win32.rc\n" " /d NDEBUG src/win32.rc\n" "\n" "dummy:\n" "\n";
"\n"
"dummy:\n"
"\n";
char SetupH[] = char SetupH[] =
"/* This is only a wrapper.. --Stskeeps */\n" "/* This is only a wrapper.. --Stskeeps */\n"
"#include \"win32/setup.h\"\n"; "#include \"win32/setup.h\"\n";
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
if (argc>1) if (argc > 1)
{ {
if (!strcmp(argv[1], "-v")) if (!strcmp(argv[1], "-v"))
return do_version(); return do_version();
if (!strcmp(argv[1], "-n")) if (!strcmp(argv[1], "-n"))
return do_config(1); return do_config(1);
} }
printf("To do win32 compiling copy include/win32/setup.h to include/\n"); printf
("To do win32 compiling copy include/win32/setup.h to include/\n");
printf("Copy include/win32/settings.h to include/ and modify it\n"); printf("Copy include/win32/settings.h to include/ and modify it\n");
printf("and copy makefile.win32 to Makefile\n"); printf("and copy makefile.win32 to Makefile\n");
// return do_config(0); // return do_config(0);
} }
int do_config(int autoconf) int do_config(int autoconf)
{ {
int fd; int fd;
char str[128]; char str[128];
if ((fd = open("include\\setup.h", O_CREAT|O_TRUNC|O_WRONLY|O_TEXT, if ((fd =
S_IREAD|S_IWRITE)) == -1) open("include\\setup.h", O_CREAT | O_TRUNC | O_WRONLY | O_TEXT,
S_IREAD | S_IWRITE)) == -1)
printf("Error opening include\\setup.h\n\r"); printf("Error opening include\\setup.h\n\r");
else else
{ {
write(fd, SetupH, strlen(SetupH)); write(fd, SetupH, strlen(SetupH));
close(fd); close(fd);
} }
while (1) while (1)
{ {
/* /*
* FD_SETSIZE * FD_SETSIZE
*/ */
printf("\n"); printf("\n");
printf("How many file descriptors (or sockets) can the irc server use?"); printf
("How many file descriptors (or sockets) can the irc server use?");
printf("\n"); printf("\n");
printf("[%d] -> ", _FD_SETSIZE); printf("[%d] -> ", _FD_SETSIZE);
gets(str); gets(str);
@@ -233,18 +233,20 @@ int do_config(int autoconf)
sscanf(str, "%d", &_FD_SETSIZE); sscanf(str, "%d", &_FD_SETSIZE);
if (_FD_SETSIZE >= 100) if (_FD_SETSIZE >= 100)
{ {
printf("\n"); printf("\n");
printf("FD_SETSIZE will be overridden using -D " printf("FD_SETSIZE will be overridden using -D "
"FD_SETSIZE=%d when compiling ircd.", _FD_SETSIZE); "FD_SETSIZE=%d when compiling ircd.", _FD_SETSIZE);
printf("\n"); printf("\n");
break; break;
}
printf("\n");
printf("You need to enter a number here, greater or equal to 100.\n");
}
while (1) {
} }
printf("\n");
printf
("You need to enter a number here, greater or equal to 100.\n");
}
while (1)
{
}
/* /*
* Now write the makefile out. * Now write the makefile out.
*/ */
@@ -254,28 +256,28 @@ int do_config(int autoconf)
} }
int write_makefile(void) int write_makefile(void)
{ {
int fd, makfd, len; int fd, makfd, len;
char *buffer, *s; char *buffer, *s;
buffer = (char *)malloc(strlen(Makefile)+4096); buffer = (char *)malloc(strlen(Makefile) + 4096);
memcpy(buffer, Makefile, strlen(Makefile)+1); memcpy(buffer, Makefile, strlen(Makefile) + 1);
s = (char *)strstr(buffer, "$FD_SETSIZE"); s = (char *)strstr(buffer, "$FD_SETSIZE");
if (s) if (s)
{ {
itoa(_FD_SETSIZE, s, 10); itoa(_FD_SETSIZE, s, 10);
memmove(s+strlen(s), s+11, strlen(s+11)+1); memmove(s + strlen(s), s + 11, strlen(s + 11) + 1);
} }
if ((makfd = open("Makefile", O_CREAT|O_TRUNC|O_WRONLY|O_TEXT, if ((makfd = open("Makefile", O_CREAT | O_TRUNC | O_WRONLY | O_TEXT,
S_IREAD|S_IWRITE)) == -1) S_IREAD | S_IWRITE)) == -1)
{ {
printf("Error creating Makefile\n\r"); printf("Error creating Makefile\n\r");
return 1; return 1;
} }
write(makfd, buffer, strlen(buffer)); write(makfd, buffer, strlen(buffer));
close(makfd); close(makfd);
@@ -284,94 +286,93 @@ int write_makefile(void)
} }
int do_version(void) int do_version(void)
{ {
int fd, verfd, generation=0, len, doingvernow=0; int fd, verfd, generation = 0, len, doingvernow = 0;
char buffer[16384], *s; char buffer[16384], *s;
if ((verfd = open("src\\version.c", O_RDONLY | O_TEXT)) != -1) if ((verfd = open("src\\version.c", O_RDONLY | O_TEXT)) != -1)
{ {
while (!eof(verfd)) while (!eof(verfd))
{ {
len = read(verfd, buffer, sizeof(buffer)-1); len = read(verfd, buffer, sizeof(buffer) - 1);
if (len == -1) if (len == -1)
break; break;
buffer[len] = 0; buffer[len] = 0;
s = (char *)strstr(buffer, "char *generation = \""); s = (char *)strstr(buffer, "char *generation = \"");
if (s) if (s)
{ {
s += 20; s += 20;
generation = atoi(s); generation = atoi(s);
break; break;
} }
} }
close(verfd); close(verfd);
} }
if ((fd = open("src\\version.c.SH", O_RDONLY | O_TEXT)) == -1) if ((fd = open("src\\version.c.SH", O_RDONLY | O_TEXT)) == -1)
{ {
printf("Error opening src\\version.c.SH\n\r"); printf("Error opening src\\version.c.SH\n\r");
return 1; return 1;
} }
if ((verfd = open("src\\version.c", O_CREAT|O_TRUNC|O_WRONLY|O_TEXT, if ((verfd =
S_IREAD|S_IWRITE)) == -1) open("src\\version.c", O_CREAT | O_TRUNC | O_WRONLY | O_TEXT,
{ S_IREAD | S_IWRITE)) == -1)
{
printf("Error opening src\\version.c\n\r"); printf("Error opening src\\version.c\n\r");
return 1; return 1;
} }
generation++; generation++;
printf("Extracting IRC/ircd/version.c...\n\r"); printf("Extracting IRC/ircd/version.c...\n\r");
while (!eof(fd)) while (!eof(fd))
{ {
len = read(fd, buffer, sizeof(buffer)-1); len = read(fd, buffer, sizeof(buffer) - 1);
if (len == -1) if (len == -1)
break; break;
buffer[len] = 0; buffer[len] = 0;
if (!doingvernow) if (!doingvernow)
{ {
s = (char *)strstr(buffer, "/*"); s = (char *)strstr(buffer, "/*");
if (!s) if (!s)
continue; continue;
memmove(buffer, s, strlen(s)+1); memmove(buffer, s, strlen(s) + 1);
doingvernow=1; doingvernow = 1;
} }
s = (char *)strstr(buffer, "$generation"); s = (char *)strstr(buffer, "$generation");
if (s) if (s)
{ {
itoa(generation, s, 10); itoa(generation, s, 10);
memmove(s+strlen(s), s+11, strlen(s+11)+1); memmove(s + strlen(s), s + 11, strlen(s + 11) + 1);
} }
s = (char *)strstr(buffer, "$creation"); s = (char *)strstr(buffer, "$creation");
if (s) if (s)
{ {
time_t t = time(0); time_t t = time(0);
char *ct = ctime(&t); char *ct = ctime(&t);
memmove(s+strlen(ct)-1, s+9, strlen(s+9)+1); memmove(s + strlen(ct) - 1, s + 9, strlen(s + 9) + 1);
memmove(s, ct, strlen(ct)-1); memmove(s, ct, strlen(ct) - 1);
} }
s = (char *)strstr(buffer, "$package"); s = (char *)strstr(buffer, "$package");
if (s) if (s)
{ {
memmove(s, "IRC", 3); memmove(s, "IRC", 3);
memmove(s+3, s+8, strlen(s+8)+1); memmove(s + 3, s + 8, strlen(s + 8) + 1);
} }
s = (char *)strstr(buffer, "!SUB!THIS!"); s = (char *)strstr(buffer, "!SUB!THIS!");
if (s) if (s)
*s = 0; *s = 0;
write(verfd, buffer, strlen(buffer)); write(verfd, buffer, strlen(buffer));
} }
close(fd); close(fd);
close(verfd); close(verfd);
return 0; return 0;
} }
+55 -8
View File
@@ -23,12 +23,19 @@ CC=danger will robinson
LINTFLAGS=-hba LINTFLAGS=-hba
OBJS=bsd.o dbuf.o packet.o send.o match.o parse.o support.o channel.o \ OBJS=agent.o aln.o badwords.o bsd.o channel.o class.o cloak.o crule.o dbuf.o dynconf.o \
class.o hash.o ircd.o list.o res.o cloak.o s_auth.o s_bsd.o s_conf.o \ fdlist.o hash.o help.o ircd.o ircsprintf.o list.o lusers.o \
s_debug.o s_err.o s_extra.o s_misc.o s_numeric.o s_serv.o s_user.o s_unreal.o \ match.o md5.o packet.o parse.o res.o $(RES) s_auth.o \
whowas.o userload.o crule.o help.o md5.o version.o dynconf.o \ s_bsd.o s_conf.o s_debug.o s_err.o s_extra.o s_kline.o \
s_socks.o s_kline.o fdlist.o \ s_misc.o s_numeric.o s_serv.o s_socks.o $(STRTOUL) s_unreal.o \
$(RES) $(STRTOUL) s_user.o scache.o send.o support.o userload.o version.o whowas.o
# OBJS=bsd.o dbuf.o packet.o send.o match.o parse.o support.o channel.o \
# class.o hash.o ircd.o list.o res.o cloak.o s_auth.o s_bsd.o s_conf.o \
# s_debug.o s_err.o s_extra.o s_misc.o s_numeric.o s_serv.o s_user.o s_unreal.o \
# whowas.o userload.o crule.o help.o md5.o dynconf.o \
# s_socks.o s_kline.o fdlist.o ircsprintf.o agent.o lusers.o version.o \
# $(RES) $(STRTOUL)
SRC=$(OBJS:%.o=%.c) SRC=$(OBJS:%.o=%.c)
@@ -44,14 +51,14 @@ all: build
build: ircd chkconf build: ircd chkconf
version.c: version.c: version.c.SH
$(SHELL) version.c.SH $(SHELL) version.c.SH
version.o: version.c ../include/version.h version.o: version.c ../include/version.h
$(CC) $(CFLAGS) -c version.c $(CC) $(CFLAGS) -c version.c
ircd: $(OBJS) ircd: $(OBJS)
$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(IRCDLIBS) -o ircd $(CC) $(CFLAGS) -o ircd $(OBJS) $(LDFLAGS) $(IRCDLIBS)
chmod $(IRCDMODE) ircd chmod $(IRCDMODE) ircd
chkconf: ../include/struct.h ../include/config.h ../include/settings.h ../include/sys.h \ chkconf: ../include/struct.h ../include/config.h ../include/settings.h ../include/sys.h \
@@ -68,12 +75,40 @@ lint:
lint $(LINTFLAGS) -I../include $(SRC) | egrep -v 'sendto_|debug' lint $(LINTFLAGS) -I../include $(SRC) | egrep -v 'sendto_|debug'
parse.o: parse.c $(INCLUDES) parse.o: parse.c $(INCLUDES)
$(CC) $(CFLAGS) -c parse.c
bsd.o: bsd.c $(INCLUDES) bsd.o: bsd.c $(INCLUDES)
$(CC) $(CFLAGS) -c bsd.c
dbuf.o: dbuf.c $(INCLUDES) ../include/dbuf.h dbuf.o: dbuf.c $(INCLUDES) ../include/dbuf.h
$(CC) $(CFLAGS) -c dbuf.c
packet.o: packet.c $(INCLUDES) packet.o: packet.c $(INCLUDES)
$(CC) $(CFLAGS) -c packet.c
badwords.o: badwords.c $(INCLUDES)
$(CC) $(CFLAGS) -c badwords.c
aln.o: aln.c $(INCLUDES)
$(CC) $(CFLAGS) -c aln.c
send.o: send.c $(INCLUDES) send.o: send.c $(INCLUDES)
$(CC) $(CFLAGS) -c send.c
match.o: match.c $(INCLUDES) match.o: match.c $(INCLUDES)
$(CC) $(CFLAGS) -c match.c
support.o: support.c $(INCLUDES) support.o: support.c $(INCLUDES)
$(CC) $(CFLAGS) -c support.c
userload.o: userload.c $(INCLUDES)
$(CC) $(CFLAGS) -c userload.c
help.o: help.c $(INCLUDES)
$(CC) $(CFLAGS) -c help.c
md5.o: md5.c $(INCLUDES)
$(CC) $(CFLAGS) -c md5.c
#install: all #install: all
# -if [ ! -d ${IRCDDIR} -a ! -f ${IRCDDIR} ] ; then \ # -if [ ! -d ${IRCDDIR} -a ! -f ${IRCDDIR} ] ; then \
@@ -108,6 +143,9 @@ ircd.o: ircd.c ../include/dbuf.h $(INCLUDES)
list.o: list.c ../include/dbuf.h $(INCLUDES) list.o: list.c ../include/dbuf.h $(INCLUDES)
$(CC) $(CFLAGS) -c list.c $(CC) $(CFLAGS) -c list.c
lusers.o: lusers.c ../include/dbuf.h $(INCLUDES)
$(CC) $(CFLAGS) -c lusers.c
res.o: res.c ../include/res.h $(INCLUDES) res.o: res.c ../include/res.h $(INCLUDES)
$(CC) $(CFLAGS) -c res.c $(CC) $(CFLAGS) -c res.c
@@ -138,6 +176,15 @@ s_err.o: ../include/msg.h s_err.c $(INCLUDES)
s_misc.o: s_misc.c ../include/dbuf.h $(INCLUDES) s_misc.o: s_misc.c ../include/dbuf.h $(INCLUDES)
$(CC) $(CFLAGS) -c s_misc.c $(CC) $(CFLAGS) -c s_misc.c
scache.o: scache.c ../include/dbuf.h $(INCLUDES)
$(CC) $(CFLAGS) -c scache.c
ircsprintf.o: ircsprintf.c ../include/dbuf.h $(INCLUDES)
$(CC) $(CFLAGS) -c ircsprintf.c
agent.o: agent.c ../include/dbuf.h $(INCLUDES)
$(CC) $(CFLAGS) -c agent.c
s_user.o: s_user.c $(INCLUDES) \ s_user.o: s_user.c $(INCLUDES) \
../include/dbuf.h ../include/channel.h ../include/whowas.h ../include/dbuf.h ../include/channel.h ../include/whowas.h
$(CC) $(CFLAGS) -c s_user.c $(CC) $(CFLAGS) -c s_user.c
+64 -57
View File
@@ -1,5 +1,5 @@
/************************************************************************ /************************************************************************
* IRC - Internet Relay Chat, common/bsd.c * Unreal Internet Relay Chat Daemon - src/bsd.c
* Copyright (C) 1990 Jarkko Oikarinen and * Copyright (C) 1990 Jarkko Oikarinen and
* University of Oulu, Computing Center * University of Oulu, Computing Center
* *
@@ -25,18 +25,19 @@
#include <signal.h> #include <signal.h>
ID_CVS("$Id$"); ID_CVS("$Id$");
ID_Copyright("(C) 1988 University of Oulu, Computing Center and Jarkko Oikarinen"); ID_Copyright
("(C) 1988 University of Oulu, Computing Center and Jarkko Oikarinen");
#ifndef _WIN32 #ifndef _WIN32
extern int errno; /* ...seems that errno.h doesn't define this everywhere */ extern int errno; /* ...seems that errno.h doesn't define this everywhere */
#endif #endif
#if !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__linux__) #if !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__linux__)
extern char *sys_errlist[]; extern char *sys_errlist[];
#endif #endif
#ifdef DEBUGMODE #ifdef DEBUGMODE
int writecalls = 0, writeb[10] = {0,0,0,0,0,0,0,0,0,0}; int writecalls = 0, writeb[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
#endif #endif
#ifndef _WIN32 #ifndef _WIN32
VOIDSIG dummy() VOIDSIG dummy()
@@ -44,14 +45,14 @@ VOIDSIG dummy()
#ifndef HAVE_RELIABLE_SIGNALS #ifndef HAVE_RELIABLE_SIGNALS
(void)signal(SIGALRM, dummy); (void)signal(SIGALRM, dummy);
(void)signal(SIGPIPE, dummy); (void)signal(SIGPIPE, dummy);
#ifndef HPUX /* Only 9k/800 series require this, but don't know how to.. */ #ifndef HPUX /* Only 9k/800 series require this, but don't know how to.. */
# ifdef SIGWINCH # ifdef SIGWINCH
(void)signal(SIGWINCH, dummy); (void)signal(SIGWINCH, dummy);
# endif # endif
#endif #endif
#else #else
# ifdef POSIX_SIGNALS # ifdef POSIX_SIGNALS
struct sigaction act; struct sigaction act;
act.sa_handler = dummy; act.sa_handler = dummy;
act.sa_flags = 0; act.sa_flags = 0;
@@ -69,6 +70,7 @@ VOIDSIG dummy()
# endif # endif
#endif #endif
} }
#endif /* _WIN32 */ #endif /* _WIN32 */
@@ -94,13 +96,13 @@ VOIDSIG dummy()
** *NOTE* I nuked 'em. At the load of current ircd servers ** *NOTE* I nuked 'em. At the load of current ircd servers
** you can't run with stuff that blocks. And we don't. ** you can't run with stuff that blocks. And we don't.
*/ */
int deliver_it(cptr, str, len) int deliver_it(cptr, str, len)
aClient *cptr; aClient *cptr;
int len; int len;
char *str; char *str;
{ {
int retval; int retval;
aClient *acpt = cptr->acpt; aClient *acpt = cptr->acpt;
#ifdef DEBUGMODE #ifdef DEBUGMODE
writecalls++; writecalls++;
@@ -108,54 +110,59 @@ char *str;
#ifdef VMS #ifdef VMS
retval = netwrite(cptr->fd, str, len); retval = netwrite(cptr->fd, str, len);
#else #else
if (IsDead(cptr) || (!IsServer(cptr) && !IsPerson(cptr) && !IsHandshake(cptr) && !IsUnknown(cptr))) if (IsDead(cptr) || (!IsServer(cptr) && !IsPerson(cptr)
&& !IsHandshake(cptr) && !IsUnknown(cptr)))
{ {
str[len]='\0'; str[len] = '\0';
sendto_ops("* * * DEBUG ERROR * * * !!! Calling deliver_it() for %s, status %d %s, with message: %s", sendto_ops
cptr->name, cptr->status, IsDead(cptr)?"DEAD":"", str); ("* * * DEBUG ERROR * * * !!! Calling deliver_it() for %s, status %d %s, with message: %s",
return -1; cptr->name, cptr->status, IsDead(cptr) ? "DEAD" : "", str);
return -1;
} }
#ifndef INET6
retval = send(cptr->fd, str, len, 0); retval = send(cptr->fd, str, len, 0);
#else
retval = sendto(cptr->fd, str, len, 0, 0, 0);
#endif
/* /*
** Convert WOULDBLOCK to a return of "0 bytes moved". This ** Convert WOULDBLOCK to a return of "0 bytes moved". This
** should occur only if socket was non-blocking. Note, that ** should occur only if socket was non-blocking. Note, that
** all is Ok, if the 'write' just returns '0' instead of an ** all is Ok, if the 'write' just returns '0' instead of an
** error and errno=EWOULDBLOCK. ** error and errno=EWOULDBLOCK.
** **
** ...now, would this work on VMS too? --msa ** ...now, would this work on VMS too? --msa
*/ */
# ifndef _WIN32 # ifndef _WIN32
if (retval < 0 && (errno == EWOULDBLOCK || errno == EAGAIN || if (retval < 0 && (errno == EWOULDBLOCK || errno == EAGAIN ||
errno == ENOBUFS)) errno == ENOBUFS))
# else # else
if (retval < 0 && (WSAGetLastError() == WSAEWOULDBLOCK || if (retval < 0 && (WSAGetLastError() == WSAEWOULDBLOCK ||
WSAGetLastError() == WSAENOBUFS)) WSAGetLastError() == WSAENOBUFS))
# endif # endif
{ {
retval = 0; retval = 0;
SetBlocked(cptr); SetBlocked(cptr);
} }
else if (retval > 0) else if (retval > 0)
{ {
#ifdef pyr ClearBlocked(cptr);
(void)gettimeofday(&cptr->lw, NULL); }
#endif
ClearBlocked(cptr);
}
#endif #endif
#ifdef DEBUGMODE #ifdef DEBUGMODE
if (retval < 0) { if (retval < 0)
{
writeb[0]++; writeb[0]++;
# ifndef _WIN32 # ifndef _WIN32
Debug((DEBUG_ERROR,"write error (%s) to %s", Debug((DEBUG_ERROR, "write error (%s) to %s",
sys_errlist[errno], cptr->name)); sys_errlist[errno], cptr->name));
# else # else
Debug((DEBUG_ERROR,"write error (%s) to %s", Debug((DEBUG_ERROR, "write error (%s) to %s",
sys_errlist[WSAGetLastError()], cptr->name)); sys_errlist[WSAGetLastError()], cptr->name));
# endif # endif
} else if (retval == 0) }
else if (retval == 0)
writeb[1]++; writeb[1]++;
else if (retval < 16) else if (retval < 16)
writeb[2]++; writeb[2]++;
@@ -175,28 +182,28 @@ char *str;
writeb[9]++; writeb[9]++;
#endif #endif
if (retval > 0) if (retval > 0)
{ {
cptr->sendB += retval; cptr->sendB += retval;
me.sendB += retval; me.sendB += retval;
if (cptr->sendB > 1023) if (cptr->sendB > 1023)
{ {
cptr->sendK += (cptr->sendB >> 10); cptr->sendK += (cptr->sendB >> 10);
cptr->sendB &= 0x03ff; /* 2^10 = 1024, 3ff = 1023 */ cptr->sendB &= 0x03ff; /* 2^10 = 1024, 3ff = 1023 */
} }
if (acpt != &me) if (acpt != &me)
{ {
acpt->sendB += retval; acpt->sendB += retval;
if (acpt->sendB > 1023) if (acpt->sendB > 1023)
{ {
acpt->sendK += (acpt->sendB >> 10); acpt->sendK += (acpt->sendB >> 10);
acpt->sendB &= 0x03ff; acpt->sendB &= 0x03ff;
} }
} }
else if (me.sendB > 1023) else if (me.sendB > 1023)
{ {
me.sendK += (me.sendB >> 10); me.sendK += (me.sendB >> 10);
me.sendB &= 0x03ff; me.sendB &= 0x03ff;
} }
} }
return(retval); return (retval);
} }
+3511 -2903
View File
File diff suppressed because it is too large Load Diff
+359 -387
View File
File diff suppressed because it is too large Load Diff
+76 -68
View File
@@ -1,5 +1,5 @@
/* /*
* IRC - Internet Relay Chat, ircd/class.c * Unreal Internet Relay Chat Daemon - src/class.c
* Copyright (C) 1990 Darren Reed * Copyright (C) 1990 Darren Reed
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@@ -32,93 +32,94 @@ ID_Notes("1.4 6/28/93");
#define BAD_PING -2 #define BAD_PING -2
#define BAD_CLIENT_CLASS -3 #define BAD_CLIENT_CLASS -3
aClass *classes; aClass *classes;
int badclass = 0;
int get_conf_class(aconf) int get_conf_class(aconf)
aConfItem *aconf; aConfItem *aconf;
{ {
if ((aconf) && Class(aconf)) if ((aconf) && Class(aconf))
return (ConfClass(aconf)); return (ConfClass(aconf));
Debug((DEBUG_DEBUG,"No Class For %s", Debug((DEBUG_DEBUG, "No Class For %s",
(aconf) ? aconf->name : "*No Conf*")); (aconf) ? aconf->name : "*No Conf*"));
return (BAD_CONF_CLASS); return (BAD_CONF_CLASS);
} }
static int get_conf_ping(aconf) static int get_conf_ping(aconf)
aConfItem *aconf; aConfItem *aconf;
{ {
if ((aconf) && Class(aconf)) if ((aconf) && Class(aconf))
return (ConfPingFreq(aconf)); return (ConfPingFreq(aconf));
Debug((DEBUG_DEBUG,"No Ping For %s", Debug((DEBUG_DEBUG, "No Ping For %s",
(aconf) ? aconf->name : "*No Conf*")); (aconf) ? aconf->name : "*No Conf*"));
return (BAD_PING); return (BAD_PING);
} }
int get_client_class(acptr) int get_client_class(acptr)
aClient *acptr; aClient *acptr;
{ {
Reg1 Link *tmp; Link *tmp;
Reg2 aClass *cl; aClass *cl;
int i = 0, retc = BAD_CLIENT_CLASS; int i = 0, retc = BAD_CLIENT_CLASS;
if (acptr && !IsMe(acptr) && (acptr->confs)) if (acptr && !IsMe(acptr) && (acptr->confs))
for (tmp = acptr->confs; tmp; tmp = tmp->next) for (tmp = acptr->confs; tmp; tmp = tmp->next)
{ {
if (!tmp->value.aconf || if (!tmp->value.aconf ||
!(cl = tmp->value.aconf->class)) !(cl = tmp->value.aconf->class))
continue; continue;
if (Class(cl) > retc) if (Class(cl) > retc)
retc = Class(cl); retc = Class(cl);
} }
Debug((DEBUG_DEBUG,"Returning Class %d For %s",retc,acptr->name)); Debug((DEBUG_DEBUG, "Returning Class %d For %s", retc, acptr->name));
return (retc); return (retc);
} }
int get_client_ping(acptr) int get_client_ping(acptr)
aClient *acptr; aClient *acptr;
{ {
int ping = 0, ping2; int ping = 0, ping2;
aConfItem *aconf; aConfItem *aconf;
Link *link; Link *link;
link = acptr->confs; link = acptr->confs;
if (link) if (link)
while (link) while (link)
{ {
aconf = link->value.aconf; aconf = link->value.aconf;
if (aconf->status & (CONF_CLIENT|CONF_CONNECT_SERVER| if (aconf->status & (CONF_CLIENT | CONF_CONNECT_SERVER |
CONF_NOCONNECT_SERVER)) CONF_NOCONNECT_SERVER))
{ {
ping2 = get_conf_ping(aconf); ping2 = get_conf_ping(aconf);
if ((ping2 != BAD_PING) && ((ping > ping2) || if ((ping2 != BAD_PING) && ((ping > ping2) ||
!ping)) !ping))
ping = ping2; ping = ping2;
} }
link = link->next; link = link->next;
} }
else else
{ {
ping = PINGFREQUENCY; ping = PINGFREQUENCY;
Debug((DEBUG_DEBUG,"No Attached Confs")); Debug((DEBUG_DEBUG, "No Attached Confs"));
} }
if (ping <= 0) if (ping <= 0)
ping = PINGFREQUENCY; ping = PINGFREQUENCY;
Debug((DEBUG_DEBUG,"Client %s Ping %d", acptr->name, ping)); Debug((DEBUG_DEBUG, "Client %s Ping %d", acptr->name, ping));
return (ping); return (ping);
} }
int get_con_freq(clptr) int get_con_freq(clptr)
aClass *clptr; aClass *clptr;
{ {
if (clptr) if (clptr)
return (ConFreq(clptr)); return (ConFreq(clptr));
@@ -133,24 +134,31 @@ aClass *clptr;
* if no present entry is found, then create a new one and add it in * if no present entry is found, then create a new one and add it in
* immeadiately after the first one (class 0). * immeadiately after the first one (class 0).
*/ */
void add_class(class, ping, confreq, maxli, sendq) void add_class(class, ping, confreq, maxli, sendq)
int class, ping, confreq, maxli; int class, ping, confreq, maxli;
long sendq; long sendq;
{ {
aClass *t, *p; aClass *t, *p;
if (maxli > (MAXCONNECTIONS - 15))
{
Debug((DEBUG_DEBUG, "Not adding Class %d as maxli is > MAXCONNECTIONS - 15",
class));
badclass = class;
return;
}
t = find_class(class); t = find_class(class);
if ((t == classes) && (class != 0)) if ((t == classes) && (class != 0))
{ {
p = (aClass *)make_class(); p = (aClass *)make_class();
NextClass(p) = NextClass(t); NextClass(p) = NextClass(t);
NextClass(t) = p; NextClass(t) = p;
} }
else else
p = t; p = t;
Debug((DEBUG_DEBUG, Debug((DEBUG_DEBUG,
"Add Class %d: p %x t %x - cf: %d pf: %d ml: %d sq: %l", "Add Class %d: p %x t %x - cf: %d pf: %d ml: %d sq: %l",
class, p, t, confreq, ping, maxli, sendq)); class, p, t, confreq, ping, maxli, sendq));
Class(p) = class; Class(p) = class;
ConFreq(p) = confreq; ConFreq(p) = confreq;
PingFreq(p) = ping; PingFreq(p) = ping;
@@ -160,8 +168,8 @@ long sendq;
Links(p) = 0; Links(p) = 0;
} }
aClass *find_class(cclass) aClass *find_class(cclass)
int cclass; int cclass;
{ {
aClass *cltmp; aClass *cltmp;
@@ -171,30 +179,30 @@ int cclass;
return classes; return classes;
} }
void check_class() void check_class()
{ {
Reg1 aClass *cltmp, *cltmp2; aClass *cltmp, *cltmp2;
Debug((DEBUG_DEBUG, "Class check:")); Debug((DEBUG_DEBUG, "Class check:"));
for (cltmp2 = cltmp = FirstClass(); cltmp; cltmp = NextClass(cltmp2)) for (cltmp2 = cltmp = FirstClass(); cltmp; cltmp = NextClass(cltmp2))
{ {
Debug((DEBUG_DEBUG, Debug((DEBUG_DEBUG,
"Class %d : CF: %d PF: %d ML: %d LI: %d SQ: %ld", "Class %d : CF: %d PF: %d ML: %d LI: %d SQ: %ld",
Class(cltmp), ConFreq(cltmp), PingFreq(cltmp), Class(cltmp), ConFreq(cltmp), PingFreq(cltmp),
MaxLinks(cltmp), Links(cltmp), MaxSendq(cltmp))); MaxLinks(cltmp), Links(cltmp), MaxSendq(cltmp)));
if (MaxLinks(cltmp) < 0) if (MaxLinks(cltmp) < 0)
{ {
NextClass(cltmp2) = NextClass(cltmp); NextClass(cltmp2) = NextClass(cltmp);
if (Links(cltmp) <= 0) if (Links(cltmp) <= 0)
free_class(cltmp); free_class(cltmp);
} }
else else
cltmp2 = cltmp; cltmp2 = cltmp;
} }
} }
void initclass() void initclass()
{ {
classes = (aClass *)make_class(); classes = (aClass *)make_class();
@@ -207,32 +215,32 @@ void initclass()
NextClass(FirstClass()) = NULL; NextClass(FirstClass()) = NULL;
} }
void report_classes(sptr) void report_classes(sptr)
aClient *sptr; aClient *sptr;
{ {
Reg1 aClass *cltmp; aClass *cltmp;
for (cltmp = FirstClass(); cltmp; cltmp = NextClass(cltmp)) for (cltmp = FirstClass(); cltmp; cltmp = NextClass(cltmp))
sendto_one(sptr, rpl_str(RPL_STATSYLINE), me.name, sptr->name, sendto_one(sptr, rpl_str(RPL_STATSYLINE), me.name, sptr->name,
'Y', Class(cltmp), PingFreq(cltmp), ConFreq(cltmp), 'Y', Class(cltmp), PingFreq(cltmp), ConFreq(cltmp),
MaxLinks(cltmp), MaxSendq(cltmp)); MaxLinks(cltmp), MaxSendq(cltmp));
} }
long get_sendq(cptr) long get_sendq(cptr)
aClient *cptr; aClient *cptr;
{ {
Reg1 int sendq = MAXSENDQLENGTH, retc = BAD_CLIENT_CLASS; int sendq = MAXSENDQLENGTH, retc = BAD_CLIENT_CLASS;
Reg2 Link *tmp; Link *tmp;
Reg2 aClass *cl; aClass *cl;
if (cptr && !IsMe(cptr) && (cptr->confs)) if (cptr && !IsMe(cptr) && (cptr->confs))
for (tmp = cptr->confs; tmp; tmp = tmp->next) for (tmp = cptr->confs; tmp; tmp = tmp->next)
{ {
if (!tmp->value.aconf || if (!tmp->value.aconf ||
!(cl = tmp->value.aconf->class)) !(cl = tmp->value.aconf->class))
continue; continue;
if (Class(cl) > retc) if (Class(cl) > retc)
sendq = MaxSendq(cl); sendq = MaxSendq(cl);
} }
return sendq; return sendq;
} }
+111 -203
View File
@@ -1,5 +1,5 @@
/************************************************************************ /************************************************************************
* IRC - Internet Relay Chat, src/cloak.c * Unreal Internet Relay Chat Daemon, src/cloak.c
* (C) VirtualWorld code made originally by RogerY (rogery@austnet.org) * (C) VirtualWorld code made originally by RogerY (rogery@austnet.org)
* Some coding by Potvin (potvin@shadownet.org) * Some coding by Potvin (potvin@shadownet.org)
* Modified by Stskeeps with some TerraX codebits * Modified by Stskeeps with some TerraX codebits
@@ -25,6 +25,7 @@
static char sccxid[] = "@(#)cloak.c 9.00 7/12/99 UnrealIRCd"; static char sccxid[] = "@(#)cloak.c 9.00 7/12/99 UnrealIRCd";
#endif #endif
*/ */
#include "struct.h" #include "struct.h"
#include "common.h" #include "common.h"
#include "sys.h" #include "sys.h"
@@ -48,56 +49,57 @@ ID_CVS("$Id$");
#define HASHVAL_TOTAL 30011 #define HASHVAL_TOTAL 30011
#define HASHVAL_PARTIAL 211 #define HASHVAL_PARTIAL 211
extern aClient me; extern aClient me;
extern int seed; extern int seed;
int match(char *, char *), find_exception(char *); int match(char *, char *), find_exception(char *);
extern unsigned char tolowertab[]; extern unsigned char tolowertab[];
int str2array(char **pparv, char *string, char *delim) int str2array(char **pparv, char *string, char *delim)
{ {
char *tok; char *tok;
int pparc=0; int pparc = 0;
tok=(char *) strtok((char *) string,delim); tok = (char *)strtok((char *)string, delim);
while(tok != NULL) while (tok != NULL)
{ {
pparv[pparc++]=tok; pparv[pparc++] = tok;
tok= (char *) strtok((char *) NULL,(char *) delim); tok = (char *)strtok((char *)NULL, (char *)delim);
} }
return pparc; return pparc;
} }
void truncstring(char *stringvar, int firstlast, int amount){ void truncstring(char *stringvar, int firstlast, int amount)
if (firstlast) {
{ if (firstlast)
stringvar+=amount; {
*stringvar=0; stringvar += amount;
stringvar-=amount; *stringvar = 0;
} stringvar -= amount;
else }
{ else
stringvar+=strlen(stringvar); {
stringvar-=amount; stringvar += strlen(stringvar);
} stringvar -= amount;
}
} }
#define B_BASE 1000 #define B_BASE 1000
int Maskchecksum (char *data, int len) int Maskchecksum(char *data, int len)
{ {
int i; int i;
int j; int j;
j=0; j = 0;
for (i=0 ; i<len ; i++) for (i = 0; i < len; i++)
{ {
j += *data++ * (i < 16 ? (i+1)*(i+1) : i*(i-15)); j += *data++ * (i < 16 ? (i + 1) * (i + 1) : i * (i - 15));
} }
return (j+B_BASE)%0xffff; return (j + B_BASE) % 0xffff;
} }
@@ -107,218 +109,124 @@ int Maskchecksum (char *data, int len)
* new hidehost by vmlinuz * new hidehost by vmlinuz
* added some extra fixes by stskeeps * added some extra fixes by stskeeps
* originally based on TerraIRCd * originally based on TerraIRCd
* Fixed serious memory leak
*/ */
char *hidehost (char *s, int useless) char *hidehost(char *s, int useless)
{ {
// static char mask[128]; static char mask[128];
char *mask;
static char ipmask[64]; static char ipmask[64];
int csum; int csum;
char *dot,*tmp; char *dot;
char *cp; char *cp;
int i, isdns; int i, isdns;
int dots = 0; int dots = 0;
mask = MyMalloc(129);
memset (mask, 0, 128);
csum = Maskchecksum (s, strlen(s)); memset(mask, 0, 128);
if (strlen (s) > 127) /* this isn't likely to happen: s is limited to HOSTLEN+1 (64) */ csum = Maskchecksum(s, strlen(s));
if (strlen(s) > 127) /* this isn't likely to happen: s is limited to HOSTLEN+1 (64) */
{ {
s[128] = 0; s[128] = 0;
} }
isdns = 0; isdns = 0;
cp = s; cp = s;
for (i=0; i < strlen(s); i++) for (i = 0; i < strlen(s); i++)
{ {
if (*cp == '.') { if (*cp == '.')
{
dots++; dots++;
} }
cp++; cp++;
} }
for (i=0 ; i<strlen(s) ; i++) for (i = 0; i < strlen(s); i++)
{ {
if (s[i] == '.') { if (s[i] == '.')
continue; {
} continue;
}
if (isalpha(s[i]))
if (isalpha(s[i]))
{ {
isdns = 1; isdns = 1;
break; break;
} }
} }
if (isdns) if (isdns)
{ {
/* it is a resolved yes.. */ /* it is a resolved yes.. */
if (dots == 1) { /* mystro.org f.x */ if (dots == 1)
sprintf(mask, "%s%c%d.%s", { /* mystro.org f.x */
hidden_host, ircsprintf(mask, "%s%c%d.%s",
(csum < 0 ? '=' : '-'), hidden_host,
(csum < 0 ? -csum : csum), s); (csum < 0 ? '=' : '-'),
} (csum < 0 ? -csum : csum), s);
if (dots == 0) { /* localhost */ }
sprintf(mask, "%s%c%d", if (dots == 0)
s, { /* localhost */
(csum < 0 ? '=' : '-'), ircsprintf(mask, "%s%c%d",
(csum < 0 ? -csum : csum)); s,
(csum < 0 ? '=' : '-'), (csum < 0 ? -csum : csum));
} }
if (dots > 1) { if (dots > 1)
dot = (char *) strchr((char *) s, '.'); {
dot = (char *)strchr((char *)s, '.');
/* mask like *<first dot> */ /* mask like *<first dot> */
sprintf(mask, "%s%c%d.%s", ircsprintf(mask, "%s%c%d.%s",
hidden_host, hidden_host,
(csum < 0 ? '=' : '-'), (csum < 0 ? '=' : '-'),
(csum < 0 ? -csum : csum), dot+1); (csum < 0 ? -csum : csum), dot + 1);
} }
} }
else else
{ {
strncpy(ipmask, s, sizeof(ipmask)); strncpy(ipmask, s, sizeof(ipmask));
ipmask[sizeof(ipmask)-1]='\0'; /* safety check */ ipmask[sizeof(ipmask) - 1] = '\0'; /* safety check */
dot = (char *) strrchr((char *) ipmask, '.'); dot = (char *)strrchr((char *)ipmask, '.');
*dot = '\0'; *dot = '\0';
if (dot == NULL) /* dot should never be NULL: IP needs dots */
sprintf (mask, "%s%c%i",
hidden_host,
(csum < 0 ? '=' : '-'),
(csum < 0 ? -csum : csum));
else
sprintf (mask, "%s.%s%c%i",
ipmask,
hidden_host,
(csum < 0 ? '=' : '-'),
(csum < 0 ? -csum : csum));
}
ok1: if (dot == NULL) /* dot should never be NULL: IP needs dots */
ircsprintf(mask, "%s%c%i",
hidden_host,
(csum < 0 ? '=' : '-'), (csum < 0 ? -csum : csum));
else
ircsprintf(mask, "%s.%s%c%i",
ipmask,
hidden_host,
(csum < 0 ? '=' : '-'), (csum < 0 ? -csum : csum));
}
return mask; return mask;
} }
/* Regular user host */ /* Regular user host */
void make_virthost(char *curr, char *new) /* mode = 0, just use strncpyzt, 1 = Realloc new and return new pointer */
char *make_virthost(char *curr, char *new, int mode)
{ {
char *mask; char *mask;
char *x;
int i;
if (curr == NULL) if (curr == NULL)
return; return;
if (new == NULL) if (new == NULL)
return; return;
mask = hidehost(curr, 0); mask = hidehost(curr, 0);
if (mode == 0)
strncpyzt(new, mask, HOSTLEN); /* */ {
return; strncpyzt(new, mask, HOSTLEN); /* */
return NULL;
}
i = strlen(mask) + 1;
if (new)
MyFree(new);
x = MyMalloc(i);
strcpy(x, mask);
return x;
} }
/* Netadmin host */
void make_netadminhost(char *new)
{
char tmpnew[HOSTLEN];
#ifndef iNAH2
sprintf(tmpnew, "%s", netadmin_host);
strncpyzt(new, tmpnew, HOSTLEN);
#endif
return;
}
/* Coadmin host */
void make_coadminhost(char *new)
{
char tmpnew[HOSTLEN];
#ifndef iNAH2
sprintf(tmpnew, "%s", coadmin_host);
strncpyzt(new, tmpnew, HOSTLEN);
#endif
return;
}
/* Techadmin host */
void make_techadminhost(char *new)
{
char tmpnew[HOSTLEN];
#ifndef iNAH2
sprintf(tmpnew, "%s", techadmin_host);
strncpyzt(new, tmpnew, HOSTLEN);
#endif
return;
}
/* Server admin host */
void make_adminhost(char *new)
{
char tmpnew[HOSTLEN];
#ifndef iNAH2
sprintf(tmpnew, "%s", admin_host);
strncpyzt(new, tmpnew, HOSTLEN);
#endif
return;
}
/* Service admin host */
void make_sadminhost(char *new)
{
char tmpnew[HOSTLEN];
#ifndef iNAH2
sprintf(tmpnew, "%s", sadmin_host);
strncpyzt(new, tmpnew, HOSTLEN);
#endif
return;
}
/* Global Oper host */
void make_operhost(char *new)
{
char tmpnew[HOSTLEN];
#ifndef iNAH2
sprintf(tmpnew, "%s", oper_host);
strncpyzt(new, tmpnew, HOSTLEN);
#endif
return;
}
/* Local Oper host */
void make_locophost(char *new)
{
char tmpnew[HOSTLEN];
#ifndef iNAH2
sprintf(tmpnew, "%s", locop_host);
strncpyzt(new, tmpnew, HOSTLEN);
#endif
return;
}
/* Make SETHOST */
void make_sethost(char *new, char *new2)
{
char tmpnew[HOSTLEN];
sprintf(tmpnew,"%s", new2);
strncpyzt(new, tmpnew, HOSTLEN);
return;
}
/* make setname */
void make_setname(char *new, char *new2)
{
char tmpnew[REALLEN];
sprintf(tmpnew,"%s", new2);
strncpyzt(new, tmpnew, REALLEN);
return;
}
/* make setident */
void make_setident(char *new, char *new2)
{
char tmpnew[USERLEN];
sprintf(tmpnew, "%s", new2);
strncpyzt(new, tmpnew, USERLEN);
return;
}
+5 -3
View File
@@ -3,7 +3,8 @@
* $Id$ * $Id$
*/ */
int main() { int main()
{
printf("|=-=-=-=-=-==-==--=-=-=-=-=-==-==--=-=-=-=-=-==-==|\n"); printf("|=-=-=-=-=-==-==--=-=-=-=-=-==-==--=-=-=-=-=-==-==|\n");
printf("| |\n"); printf("| |\n");
printf("| UnrealIRCd Configuration Tool |\n"); printf("| UnrealIRCd Configuration Tool |\n");
@@ -11,5 +12,6 @@ int main() {
printf("| |\n"); printf("| |\n");
printf("|-=-=-=-=-=-==-=-=-=-=-=-=-=-==-==-=-=-=-=-=-==-==|\n"); printf("|-=-=-=-=-=-==-=-=-=-=-=-=-=-==-==-=-=-=-=-=-==-==|\n");
printf("Actually this is only a demo .. so wait for it to be released;p"); printf
} ("Actually this is only a demo .. so wait for it to be released;p");
}
+582 -567
View File
File diff suppressed because it is too large Load Diff
+117 -109
View File
@@ -1,5 +1,5 @@
/************************************************************************ /************************************************************************
* IRC - Internet Relay Chat, common/dbuf.c * Unreal Internet Relay Chat Daemon, src/dbuf.c
* Copyright (C) 1990 Markku Savela * Copyright (C) 1990 Markku Savela
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@@ -39,21 +39,21 @@
#include "struct.h" #include "struct.h"
#include "common.h" #include "common.h"
#include "sys.h" #include "sys.h"
#ifdef USE_DMALLOC
#include "h.h"
#endif
ID_CVS("$Id$"); ID_CVS("$Id$");
ID_Copyright("(C) 1990 Markku Savela"); ID_Copyright("(C) 1990 Markku Savela");
ID_Notes("2.17 1/30/94 (C) 1990 Markku Savela"); ID_Notes("2.17 1/30/94 (C) 1990 Markku Savela");
#if !defined(VALLOC) && !defined(valloc) && !defined(USE_DMALLOC)
#if !defined(VALLOC) && !defined(valloc)
# ifndef _WIN32 # ifndef _WIN32
# define valloc malloc # define valloc malloc
# else # else
# define valloc MyMalloc # define valloc MyMalloc
# endif # endif
#endif #endif
int dbufalloc = 0, dbufblocks = 0;
int dbufalloc = 0, dbufblocks = 0; static dbufbuf *freelist = NULL;
static dbufbuf *freelist = NULL;
/* This is a dangerous define because a broken compiler will set DBUFSIZ /* This is a dangerous define because a broken compiler will set DBUFSIZ
** to 4, which will work but will be very inefficient. However, there ** to 4, which will work but will be very inefficient. However, there
@@ -70,62 +70,64 @@ static dbufbuf *freelist = NULL;
static dbufbuf *dbuf_alloc() static dbufbuf *dbuf_alloc()
{ {
#if defined(VALLOC) && !defined(DEBUGMODE) #if defined(VALLOC) && !defined(DEBUGMODE)
Reg1 dbufbuf *dbptr, *db2ptr; dbufbuf *dbptr, *db2ptr;
Reg2 int num; int num;
#else #else
Reg1 dbufbuf *dbptr; dbufbuf *dbptr;
#endif #endif
dbufalloc++; dbufalloc++;
if ((dbptr = freelist)) if ((dbptr = freelist))
{ {
freelist = freelist->next; freelist = freelist->next;
return dbptr; return dbptr;
} }
if (dbufalloc * DBUFSIZ > BUFFERPOOL) if (dbufalloc * DBUFSIZ > BUFFERPOOL)
{ {
dbufalloc--; dbufalloc--;
return NULL; return NULL;
} }
#if defined(VALLOC) && !defined(DEBUGMODE) #if defined(VALLOC) && !defined(DEBUGMODE)
# if defined(SOL20) || defined(_SC_PAGESIZE) # if defined(_SOLARIS) || defined(_SC_PAGESIZE)
num = sysconf(_SC_PAGESIZE)/sizeof(dbufbuf); num = sysconf(_SC_PAGESIZE) / sizeof(dbufbuf);
# else # else
num = getpagesize()/sizeof(dbufbuf); num = getpagesize() / sizeof(dbufbuf);
# endif # endif
if (num < 0) if (num < 0)
num = 1; num = 1;
dbufblocks += num; dbufblocks += num;
dbptr = (dbufbuf *)valloc(num*sizeof(dbufbuf)); dbptr = (dbufbuf *)valloc(num * sizeof(dbufbuf));
if (!dbptr) if (!dbptr)
return (dbufbuf *)NULL; return (dbufbuf *)NULL;
num--; num--;
for (db2ptr = dbptr; num; num--) for (db2ptr = dbptr; num; num--)
{ {
db2ptr = (dbufbuf *)((char *)db2ptr + sizeof(dbufbuf)); db2ptr = (dbufbuf *)((char *)db2ptr + sizeof(dbufbuf));
db2ptr->next = freelist; db2ptr->next = freelist;
freelist = db2ptr; freelist = db2ptr;
} }
return dbptr; return dbptr;
#else #else
dbufblocks++; dbufblocks++;
return (dbufbuf *)MyMalloc(sizeof(dbufbuf)); return (dbufbuf *)MyMalloc(sizeof(dbufbuf));
#endif #endif
} }
/* /*
** dbuf_free - return a dbufbuf structure to the freelist ** dbuf_free - return a dbufbuf structure to the freelist
*/ */
static void dbuf_free(ptr) static void dbuf_free(ptr)
Reg1 dbufbuf *ptr; dbufbuf *ptr;
{ {
dbufalloc--; dbufalloc--;
ptr->next = freelist; ptr->next = freelist;
freelist = ptr; freelist = ptr;
} }
/* /*
** This is called when malloc fails. Scrap the whole content ** This is called when malloc fails. Scrap the whole content
** of dynamic buffer and return -1. (malloc errors are FATAL, ** of dynamic buffer and return -1. (malloc errors are FATAL,
@@ -133,60 +135,65 @@ Reg1 dbufbuf *ptr;
** the "dbuf" has consistent EMPTY status... ;) ** the "dbuf" has consistent EMPTY status... ;)
*/ */
static int dbuf_malloc_error(dyn) static int dbuf_malloc_error(dyn)
dbuf *dyn; dbuf *dyn;
{ {
dbufbuf *p; dbufbuf *p;
dyn->length = 0; dyn->length = 0;
dyn->offset = 0; dyn->offset = 0;
while ((p = dyn->head) != NULL) while ((p = dyn->head) != NULL)
{ {
dyn->head = p->next; dyn->head = p->next;
dbuf_free(p); dbuf_free(p);
} }
dyn->tail = dyn->head; dyn->tail = dyn->head;
return -1; return -1;
} }
int dbuf_put(dyn, buf, length) int dbuf_put(dyn, buf, length)
dbuf *dyn; dbuf *dyn;
char *buf; char *buf;
int length; int length;
{ {
Reg1 dbufbuf **h, *d; dbufbuf **h, *d;
Reg2 int off; int off;
Reg3 int chunk; int chunk;
if(!length) return 1; /* Nothing to do */ if (!length)
return 1; /* Nothing to do */
off = (dyn->offset + dyn->length) % DBUFSIZ; off = (dyn->offset + dyn->length) % DBUFSIZ;
/* /*
** Locate the last non-empty buffer. If the last buffer is ** Locate the last non-empty buffer. If the last buffer is
** full, the loop will terminate with 'd==NULL'. This loop ** full, the loop will terminate with 'd==NULL'. This loop
** assumes that the 'dyn->length' field is correctly ** assumes that the 'dyn->length' field is correctly
** maintained, as it should--no other check really needed. ** maintained, as it should--no other check really needed.
*/ */
if (!dyn->length) h = &(dyn->head); if (!dyn->length)
else { h = &(dyn->head);
if (off) h = &(dyn->tail); else
else h = &(dyn->tail->next); {
if (off)
h = &(dyn->tail);
else
h = &(dyn->tail->next);
} }
/* /*
** Append users data to buffer, allocating buffers as needed ** Append users data to buffer, allocating buffers as needed
*/ */
chunk = DBUFSIZ - off; chunk = DBUFSIZ - off;
dyn->length += length; dyn->length += length;
for ( ;length > 0; h = &(d->next)) for (; length > 0; h = &(d->next))
{ {
if ((d = *h) == NULL) if ((d = *h) == NULL)
{ {
if ((d = (dbufbuf *)dbuf_alloc()) == NULL) if ((d = (dbufbuf *)dbuf_alloc()) == NULL)
return dbuf_malloc_error(dyn); return dbuf_malloc_error(dyn);
dyn->tail = d; dyn->tail = d;
*h = d; *h = d;
d->next = NULL; d->next = NULL;
} }
if (chunk > length) if (chunk > length)
chunk = length; chunk = length;
bcopy(buf, d->data + off, chunk); bcopy(buf, d->data + off, chunk);
@@ -194,71 +201,72 @@ int length;
buf += chunk; buf += chunk;
off = 0; off = 0;
chunk = DBUFSIZ; chunk = DBUFSIZ;
} }
return 1; return 1;
} }
char *dbuf_map(dyn,length) char *dbuf_map(dyn, length)
dbuf *dyn; dbuf *dyn;
int *length; int *length;
{ {
if (dyn->head == NULL) if (dyn->head == NULL)
{ {
dyn->tail = NULL; dyn->tail = NULL;
*length = 0; *length = 0;
return NULL; return NULL;
} }
*length = DBUFSIZ - dyn->offset; *length = DBUFSIZ - dyn->offset;
if (*length > dyn->length) if (*length > dyn->length)
*length = dyn->length; *length = dyn->length;
return (dyn->head->data + dyn->offset); return (dyn->head->data + dyn->offset);
} }
int dbuf_delete(dyn,length) int dbuf_delete(dyn, length)
dbuf *dyn; dbuf *dyn;
int length; int length;
{ {
dbufbuf *d; dbufbuf *d;
int chunk; int chunk;
if (length > dyn->length) if (length > dyn->length)
length = dyn->length; length = dyn->length;
chunk = DBUFSIZ - dyn->offset; chunk = DBUFSIZ - dyn->offset;
while (length > 0) while (length > 0)
{ {
if (chunk > length) if (chunk > length)
chunk = length; chunk = length;
length -= chunk; length -= chunk;
dyn->offset += chunk; dyn->offset += chunk;
dyn->length -= chunk; dyn->length -= chunk;
if (dyn->offset == DBUFSIZ || dyn->length == 0) if (dyn->offset == DBUFSIZ || dyn->length == 0)
{ {
d = dyn->head; d = dyn->head;
dyn->head = d->next; dyn->head = d->next;
dyn->offset = 0; dyn->offset = 0;
dbuf_free(d); dbuf_free(d);
} }
chunk = DBUFSIZ; chunk = DBUFSIZ;
} }
if (dyn->head == (dbufbuf *)NULL) { if (dyn->head == (dbufbuf *)NULL)
{
dyn->length = 0; dyn->length = 0;
dyn->tail = 0; dyn->tail = 0;
} }
return 0; return 0;
} }
int dbuf_get(dyn, buf, length) int dbuf_get(dyn, buf, length)
dbuf *dyn; dbuf *dyn;
char *buf; char *buf;
int length; int length;
{ {
int moved = 0; int moved = 0;
int chunk; int chunk;
char *b; char *b;
while (length > 0 && (b = dbuf_map(dyn, &chunk)) != NULL) while (length > 0 && (b = dbuf_map(dyn, &chunk)) != NULL)
{ {
if (chunk > length) if (chunk > length)
chunk = length; chunk = length;
bcopy(b, buf, (int)chunk); bcopy(b, buf, (int)chunk);
@@ -266,9 +274,9 @@ int length;
buf += chunk; buf += chunk;
length -= chunk; length -= chunk;
moved += chunk; moved += chunk;
} }
return moved; return moved;
} }
/* /*
** dbuf_getmsg ** dbuf_getmsg
@@ -277,18 +285,18 @@ int length;
** either a \r or \n prsent. If so, copy as much as possible (determined by ** either a \r or \n prsent. If so, copy as much as possible (determined by
** length) into buf and return the amount copied - else return 0. ** length) into buf and return the amount copied - else return 0.
*/ */
int dbuf_getmsg(dyn, buf, length) int dbuf_getmsg(dyn, buf, length)
dbuf *dyn; dbuf *dyn;
char *buf; char *buf;
register int length; int length;
{ {
dbufbuf *d; dbufbuf *d;
register char *s; char *s;
register int dlen; int dlen;
register int i; int i;
int copy; int copy;
getmsg_init: getmsg_init:
d = dyn->head; d = dyn->head;
dlen = dyn->length; dlen = dyn->length;
i = DBUFSIZ - dyn->offset; i = DBUFSIZ - dyn->offset;
@@ -303,49 +311,49 @@ getmsg_init:
if (i > dlen) if (i > dlen)
i = dlen; i = dlen;
while (length > 0 && dlen > 0) while (length > 0 && dlen > 0)
{ {
dlen--; dlen--;
if (*s == '\n' || *s == '\r') if (*s == '\n' || *s == '\r')
{ {
copy = dyn->length - dlen; copy = dyn->length - dlen;
/* /*
** Shortcut this case here to save time elsewhere. ** Shortcut this case here to save time elsewhere.
** -avalon ** -avalon
*/ */
if (copy == 1) if (copy == 1)
{ {
(void)dbuf_delete(dyn, 1); (void)dbuf_delete(dyn, 1);
goto getmsg_init; goto getmsg_init;
} }
break; break;
} }
length--; length--;
if (!--i) if (!--i)
{ {
if ((d = d->next)) if ((d = d->next))
{ {
s = d->data; s = d->data;
i = MIN(DBUFSIZ, dlen); i = MIN(DBUFSIZ, dlen);
} }
} }
else else
s++; s++;
} }
if (copy <= 0) if (copy <= 0)
return 0; return 0;
/* /*
** copy as much of the message as wanted into parse buffer ** copy as much of the message as wanted into parse buffer
*/ */
i = dbuf_get(dyn, buf, MIN(copy, length)); i = dbuf_get(dyn, buf, MIN(copy, length));
/* /*
** and delete the rest of it! ** and delete the rest of it!
*/ */
if (copy - i > 0) if (copy - i > 0)
(void)dbuf_delete(dyn, copy - i); (void)dbuf_delete(dyn, copy - i);
if (i >= 0) if (i >= 0)
*(buf+i) = '\0'; /* mark end of messsage */ *(buf + i) = '\0'; /* mark end of messsage */
return i; return i;
} }
+568 -271
View File
@@ -1,6 +1,6 @@
/************************************************************************ /************************************************************************
* IRC - Internet Relay Chat, dynconf.c * Unreal Internet Relay Chat Daemon, src/dynconf.c
* (C) 1999 Carsten Munk (Techie/Stskeeps) <cmunk@toybox.flirt.org> * (C) 1999-2000 Carsten Munk (Techie/Stskeeps) <stskeeps@tspre.org>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -17,7 +17,6 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#define DYNCONF_C
#include "struct.h" #include "struct.h"
#include "common.h" #include "common.h"
#include "sys.h" #include "sys.h"
@@ -39,145 +38,218 @@
#include "h.h" #include "h.h"
ID_CVS("$Id$"); ID_CVS("$Id$");
ID_Copyright("(C) 1999 Carsten Munk"); ID_Copyright("(C) 1999-2000 Carsten Munk");
#define DoDebug fprintf(stderr, "[%s] %s | %li\n", babuf, __FILE__, __LINE__); #define DoDebug fprintf(stderr, "[%s] %s | %li\n", babuf, __FILE__, __LINE__);
#define AllocCpy(x,y) if ((x) && type == 1) MyFree((x)); x = (char *) MyMalloc(strlen(y) + 1); strcpy(x,y) #define AllocCpy(x,y) if ((x) && type == 1) MyFree((x)); x = (char *) MyMalloc(strlen(y) + 1); strcpy(x,y)
#define XtndCpy(x,y) x = (char *) MyMalloc(strlen(y) + 2); *x = '\0'; strcat(x, "*"); strcpy(x,y) #define XtndCpy(x,y) x = (char *) MyMalloc(strlen(y) + 2); *x = '\0'; strcat(x, "*"); strcpy(x,y)
/* externals */
extern int un_uid, un_gid;
/* internals */
aConfiguration iConf; aConfiguration iConf;
int icx = 0; int icx = 0;
char buf[1024];
/* strips \r and \n's from the line */
void iCstrip(char *line) void iCstrip(char *line)
{ {
char *c; char *c;
if ((c = strchr(line, '\n'))) *c = '\0'; if ((c = strchr(line, '\n')))
if ((c = strchr(line, '\r'))) *c = '\0'; *c = '\0';
if ((c = strchr(line, '\r')))
*c = '\0';
} }
/* /* this loads dynamic ZCONF */
for (q = p; *q; q++) { int load_conf(char *filename, int type)
printf("%x ", *q);
}
*/
/* Get the unrealircd.conf/*.network file version and check it */
char *get_version(char *file) {
FILE *fd = fopen(file, "r");
char buf[24], *tmp = '\0', *buf2 = '\0', *version = '\0';
/* This should never happen, but we'll keep it just to be safe */
if (!fd) {
#ifdef _WIN32
MessageBox(NULL, "UnrealIRCD/32 Init Error", "Unable to load dynamic config (or network) file !! ", MB_OK);
#else
fprintf(stderr, "[error] Couldn't load %s !!!\n", file);
#endif
exit(-1);
}
/* We only want to read the first line */
fgets(buf, 24, fd);
tmp = strtok(buf, "\n");
/* Make sure that it is a valid version line */
buf2 = strtok(tmp,"^");
/* If it isn't exit */
if (strcmp(buf2, "ver")) {
#ifdef _WIN32
MessageBox(NULL, "Dynamic config file (or network file) is not valid, visit http://unreal.tspre.org to learn how to upgrade", "UnrealIRCD/32 Init Error", MB_OK);
#else
fprintf(stderr, "%s is invalid, visit http://unreal.tspre.org to learn how to upgrade", file);
#endif
exit(-1);
}
/* If it is we get the version number */
version = strtok(NULL, "");
fclose(fd);
/* Now return the version */
return version;
}
int load_conf(char *file, int type)
{ {
FILE *zConf; FILE *zConf;
char *stat; char *version = NULL;
char *buf = MyMalloc(1024); char *i;
char *babuf = MyMalloc(1024);
char *p, *q; zConf = fopen(filename, "r");
char *var, *setto;
long aint; if (!zConf)
int v1, v2; {
/* Since we have no real way of knowing what file we are dealing with, we will check if (type == 1)
* for *.conf then get the version */ {
if(!match("*.conf",file)) { sendto_ops("[error] Could not load %s !", filename);
if (strcmp(get_version(file), "1.1")) { return -1;
}
else
{
#ifdef _WIN32 #ifdef _WIN32
ircsprintf(buf, "Unable to load dynamic config %s",
MessageBox(NULL, "Dynamic config file is not valid, visit http://unreal.tspre.org to learn how to upgrade", "UnrealIRCD/32 Init Error", MB_OK); filename);
MessageBox(NULL, "UnrealIRCD/32 Init Error", buf,
MB_OK);
#else #else
fprintf(stderr, "%s is invalid, visit http://unreal.tspre.org to learn how to upgrade\n", file); fprintf(stderr, "[error] Couldn't load %s !!!\n",
filename);
#endif #endif
exit(-1); exit(-1);
} }
} }
i = fgets(buf, 1023, zConf);
zConf = fopen(file, "r"); if (!i)
if (zConf == NULL && (type == 0)) { {
if (type == 1)
{
sendto_ops("[error] Error reading from %s !", filename);
return -1;
}
else
{
#ifdef _WIN32 #ifdef _WIN32
MessageBox(NULL, "UnrealIRCD/32 Init Error", "Unable to load dynamic config (or network) file !! ", MB_OK); ircsprintf(buf, "Unable to read dynamic config %s",
filename);
MessageBox(NULL, "UnrealIRCD/32 Init Error", buf,
MB_OK);
#else #else
fprintf(stderr, "[error] Couldn't load %s !!!\n", file); fprintf(stderr, "[error] Couldn't read %s !!!\n",
#endif filename);
exit(-1); #endif
exit(-1);
}
}
iCstrip(buf);
version = strtok(buf, "^");
version = strtok(NULL, "");
/* is this a unrealircd.conf file? */
if (!match("1.*", version))
{
/* wrong version */
if (strcmp(version, DYNCONF_CONF_VERSION))
{
if (type == 1)
{
sendto_ops
("[error] %s got a non-compatible version (%s) !",
filename, version);
sendto_ops
("[error] Please go to http://unreal.tspre.org and learn how to upgrade");
return -1;
}
else
{
#ifdef _WIN32
ircsprintf(buf,
"Incompatible version (%s) in %s - please upgrade",
version, filename);
MessageBox(NULL, "UnrealIRCD/32 Init Error",
buf, MB_OK);
#else
fprintf(stderr,
"[error] Incompatible version (%s) in %s - please upgrade !!!\n",
version, filename);
#endif
exit(-1);
}
}
load_conf2(zConf, filename, type);
return -1;
}
else if (!match("2.*", version))
{
/* network file */
/* wrong version */
if (strcmp(version, DYNCONF_NETWORK_VERSION))
{
if (type == 1)
{
sendto_ops
("[error] %s got a non-compatible network file version (%s) !",
filename, version);
sendto_ops
("[error] Please go to http://unreal.tspre.org and learn how to upgrade");
return -1;
}
else
{
#ifdef _WIN32
ircsprintf(buf,
"Incompatible network file version (%s) in %s - please upgrade",
version, filename);
MessageBox(NULL, "UnrealIRCD/32 Init Error",
buf, MB_OK);
#else
fprintf(stderr,
"[error] Incompatible network file version (%s) in %s - please upgrade !!!\n",
version, filename);
#endif
exit(-1);
}
}
load_conf3(zConf, filename, type);
return -1;
} }
else else
if (zConf == NULL && (type == 1)) {
{ if (type == 1)
sendto_ops("[error] Couldnt load dynconf file %s !!", file); {
} sendto_ops
*buf = '\1'; ("[Error] Malformed version header in %s. Please read Unreal.nfo on info how to get support",
stat = buf; filename);
return -1;
}
else
{
#ifdef _WIN32
ircsprintf(buf,
"Malformed version header in %s. Please read Unreal.nfo on info how to get support",
filename);
MessageBox(NULL, "UnrealIRCD/32 Init Error", buf,
MB_OK);
#else
fprintf(stderr,
"[error] Malformed version header in %s. Please read Unreal.nfo on info how to get support!!\n",
filename);
#endif
exit(-1);
}
return -1;
}
return -1;
}
int load_conf2(FILE * conf, char *filename, int type)
{
char *databuf = buf;
char *stat = databuf;
char *p, *setto, *var;
if (!conf)
return -1;
*databuf = '\0';
/* loop to read data */
while (stat != NULL) while (stat != NULL)
{ {
stat = fgets(buf,1020, zConf); stat = fgets(buf, 1020, conf);
if (*buf == '#') /* comment */ if ((*buf == '#') || (*buf == '/'))
continue; continue;
if (*buf == '/') /* comment */
continue; iCstrip(buf);
iCstrip(buf); /* strip crlf .. */
strcpy(babuf, buf);
if (*buf == '\0') if (*buf == '\0')
continue; continue;
p = strtok(buf, " ");
p = strtok(buf, " "); if (strcmp(p, "Include") == 0)
if (strcmp(p, "Include")==0)
{ {
strtok(NULL, " "); strtok(NULL, " ");
setto = strtok(NULL, ""); setto = strtok(NULL, "");
/* We need this for STATS S */ /* We need this for STATS S -codemastr
AllocCpy(INCLUDE, setto); Isn't there a better way to show all include files? --Stskeeps */
#ifndef _WIN32 AllocCpy(INCLUDE, setto);
#endif load_conf(setto, type);
/* Check the version before we read the file */
if (strcmp(get_version(setto),"2.2"))
{
#ifdef _WIN32
MessageBox(NULL, "Network file is not valid, visit http://unreal.tspre.org to learn how to upgrade", "UnrealIRCD/32 Init Error", MB_OK);
#else
fprintf(stderr, "%s is invalid, visit http://unreal.tspre.org to learn how to upgrade\n", setto);
#endif
exit(-1);
}
load_conf(setto,type);
} }
else if (strcmp(p, "Set") == 0)
else
if (strcmp(p, "Set")==0)
{ {
var = strtok(NULL, " "); var = strtok(NULL, " ");
/* Yes it was a good idea when i moved it. */
if (var == NULL) if (var == NULL)
continue; continue;
if (*var == '\0') if (*var == '\0')
@@ -185,189 +257,414 @@ int load_conf(char *file, int type)
strtok(NULL, " "); strtok(NULL, " ");
setto = strtok(NULL, ""); setto = strtok(NULL, "");
if (setto == NULL) /* Is it a aint variable */
continue; if (strcmp(var, "MODE_X") == 0)
if (*setto == '\0') {
continue; MODE_X = atoi(setto);
}
if (*setto >= '0' && *setto <= '9') { else if (strcmp(var, "MODE_STRIPWORDS") == 0)
aint = atol(setto); {
if (strcmp(var, "MODE_X")==0) MODE_STRIPWORDS = atoi(setto);
MODE_X = aint; }
else else if (strcmp(var, "MODE_I") == 0)
if (strcmp(var, "MODE_I")==0) {
MODE_I = aint; MODE_I = atoi(setto);
else }
if (strcmp(var, "TRUEHUB")==0) { else if (strcmp(var, "TRUEHUB") == 0)
TRUEHUB = aint; {
#ifndef HUB TRUEHUB = atoi(setto);
/* Only display if _not_ called thru /rehash */ #ifndef HUB
if (aint == 1 && type == 0) { if ((TRUEHUB == 1) && (type == 0))
{
#ifdef _WIN32 #ifdef _WIN32
MessageBox(NULL, "UnrealIRCD/32 Init Error", "I'm a leaf NOT an hub! ", MB_OK); MessageBox(NULL,
"UnrealIRCd/32 Init Error",
"TRUEHUB value set to 1, but I'm not a hub!",
MB_OK);
#else #else
fprintf(stderr, "[error] I'm a leaf NOT a hub!\n"); fprintf(stderr,
"[error] I'm a leaf NOT a hub!\n");
#endif #endif
return 0; exit(-1);
}
else if ((type == 1) && (TRUEHUB == 1))
{
sendto_ops
("TRUEHUB value set to 1, but I'm not a hub!");
} }
#endif #endif
} }
if (strcmp(var, "CONFIG_FILE_STOP")==0) { else if (strcmp(var, "CONFIG_FILE_STOP") == 0)
if (aint == 1) { {
if (atoi(setto) == 1)
{
#ifdef _WIN32 #ifdef _WIN32
MessageBox(NULL, "UnrealIRCD/32 Init Error", "Read Config stop code in file", MB_OK); MessageBox(NULL,
"UnrealIRCD/32 Init Error",
"Read Config stop code in file",
MB_OK);
#else #else
fprintf(stderr, "[fatal error] File stop code recieved in %s - RTFM\n", file); fprintf(stderr,
"[fatal error] File stop code recieved in %s - RTFM\n",
filename);
#endif #endif
exit(-1); exit(-1);
}
} }
}
if (strcmp(var, "SHOWOPERS")==0) { else if (strcmp(var, "SHOWOPERS") == 0)
SHOWOPERS = aint; {
} SHOWOPERS = atoi(setto);
if (strcmp(var, "SHOWOPERMOTD")==0) { }
SHOWOPERMOTD = aint; else if (strcmp(var, "WEBTV_SUPPORT") == 0)
} {
if (strcmp(var, "SOCKSBANTIME")==0) { WEBTV_SUPPORT = atoi(setto);
iConf.socksbantime = aint; }
} else if (strcmp(var, "SHOWOPERMOTD") == 0)
if (strcmp(var, "iNAH")==0) { {
iNAH = aint; SHOWOPERMOTD = atoi(setto);
} }
if (strcmp(var, "ALLOW_CHATOPS")==0) { else if (strcmp(var, "SOCKSBANTIME") == 0)
ALLOW_CHATOPS = aint; {
} iConf.socksbantime = atol(setto);
if (strcmp(var, "HIDE_ULINES")==0) { }
HIDE_ULINES = aint; else if (strcmp(var, "MAXCHANNELSPERUSER") == 0)
} {
if (strcmp(var, "KILLDIFF")==0) { MAXCHANNELSPERUSER = atol(setto);
KILLDIFF = aint; }
} else if (strcmp(var, "ALLOW_CHATOPS") == 0)
continue; {
} ALLOW_CHATOPS = atoi(setto);
/* if (strcmp(var, "DOMAINNAME")==0) { }
AllocCpy(DOMAINNAME, setto); else if (strcmp(var, "HIDE_ULINES") == 0)
XtndCpy(DOMAINNAMEMASK, setto); {
} HIDE_ULINES = atoi(setto);
*/ }
/* uhm networks */ else if (strcmp(var, "NO_OPER_HIDING") == 0)
if (strcmp(var, "ircnetwork")==0) { {
AllocCpy(ircnetwork, setto); NO_OPER_HIDING = atoi(setto);
} }
else else if (strcmp(var, "KILLDIFF") == 0)
if (strcmp(var, "defserv")==0) { {
AllocCpy(defserv, setto); KILLDIFF = atoi(setto);
} }
else if (strcmp(var, "KLINE_ADDRESS") == 0)
if (strcmp(var, "SERVICES_NAME")==0) { {
AllocCpy(SERVICES_NAME, setto);
}
else
if (strcmp(var, "oper_host")==0) {
AllocCpy(oper_host, setto);
}
else
if (strcmp(var, "admin_host")==0) {
AllocCpy(admin_host, setto);
}
else
if (strcmp(var, "locop_host")==0) {
AllocCpy(locop_host, setto);
}
else
if (strcmp(var, "sadmin_host")==0) {
AllocCpy(sadmin_host, setto);
}
else
if (strcmp(var, "netadmin_host")==0) {
AllocCpy(netadmin_host, setto);
}
else
if (strcmp(var, "techadmin_host")==0) {
AllocCpy(techadmin_host, setto);
}
else
if (strcmp(var, "coadmin_host")==0) {
AllocCpy(coadmin_host, setto);
}
else
if (strcmp(var, "hidden_host")==0) {
AllocCpy(hidden_host, setto);
}
else
if (strcmp(var, "netdomain")==0) {
AllocCpy(netdomain, setto);
}
else
if (strcmp(var, "helpchan")==0) {
AllocCpy(helpchan, setto);
}
else
if (strcmp(var, "STATS_SERVER")==0) {
AllocCpy(STATS_SERVER, setto);
}
else
if (strcmp(var, "KLINE_ADDRESS")==0) {
AllocCpy(KLINE_ADDRESS, setto); AllocCpy(KLINE_ADDRESS, setto);
} }
else else if (strcmp(var, "SOCKS_BAN_MESSAGE") == 0)
if (strcmp(var, "SOCKS_BAN_MESSAGE")==0) { {
AllocCpy(iConf.socksbanmessage, setto); AllocCpy(iConf.socksbanmessage, setto);
} }
else else if (strcmp(var, "SOCKS_QUIT_MESSAGE") == 0)
if (strcmp(var, "SOCKS_QUIT_MESSAGE")==0) { {
AllocCpy(iConf.socksquitmessage, setto); AllocCpy(iConf.socksquitmessage, setto);
} }
else if (strcmp(var, "AUTO_JOIN_CHANS") == 0)
} {
AllocCpy(AUTO_JOIN_CHANS, setto);
}
else if (strcmp(var, "OPER_AUTO_JOIN_CHANS") == 0)
{
AllocCpy(OPER_AUTO_JOIN_CHANS, setto);
}
else if (strcmp(var, "HOST_TIMEOUT") == 0)
{
HOST_TIMEOUT = atol(setto);
}
else if (strcmp(var, "HOST_RETRIES") == 0)
{
HOST_RETRIES = atoi(setto);
}
#ifndef BIG_SECURITY_HOLE
else if (strcmp(var, "SETUID") == 0)
{
un_uid = atoi(setto);
}
else if (strcmp(var, "SETGID") == 0)
{
un_gid = atoi(setto);
}
#endif
}
}
if (type == 0)
{
fprintf(stderr, "* Loaded %s ..\n", filename);
}
else
{
sendto_realops("Loaded %s ..", filename);
} }
#ifndef _WIN32
fprintf(stderr, "* Loaded %s ..\n", file);
#endif
} }
void doneconf(void) { /* Load .network options */
int load_conf3(FILE * conf, char *filename, int type)
{
char *databuf = buf;
char *stat = databuf;
char *p, *setto, *var;
if (!conf)
return -1;
*databuf = '\0';
/* loop to read data */
while (stat != NULL)
{
stat = fgets(buf, 1020, conf);
if ((*buf == '#') || (*buf == '/'))
continue;
iCstrip(buf);
if (*buf == '\0')
continue;
p = strtok(buf, " ");
if (strcmp(p, "Set") == 0)
{
var = strtok(NULL, " ");
if (var == NULL)
continue;
if (*var == '\0')
continue;
strtok(NULL, " ");
setto = strtok(NULL, "");
/* Is it a aint variable */
if (strcmp(var, "iNAH") == 0)
{
iNAH = atoi(setto);
}
else
/* uhm networks */
if (strcmp(var, "ircnetwork") == 0)
{
AllocCpy(ircnetwork, setto);
}
else if (strcmp(var, "defserv") == 0)
{
AllocCpy(defserv, setto);
}
else if (strcmp(var, "SERVICES_NAME") == 0)
{
AllocCpy(SERVICES_NAME, setto);
}
else if (strcmp(var, "oper_host") == 0)
{
AllocCpy(oper_host, setto);
}
else if (strcmp(var, "admin_host") == 0)
{
AllocCpy(admin_host, setto);
}
else if (strcmp(var, "locop_host") == 0)
{
AllocCpy(locop_host, setto);
}
else if (strcmp(var, "sadmin_host") == 0)
{
AllocCpy(sadmin_host, setto);
}
else if (strcmp(var, "netadmin_host") == 0)
{
AllocCpy(netadmin_host, setto);
}
else if (strcmp(var, "techadmin_host") == 0)
{
AllocCpy(techadmin_host, setto);
}
else if (strcmp(var, "coadmin_host") == 0)
{
AllocCpy(coadmin_host, setto);
}
else if (strcmp(var, "hidden_host") == 0)
{
AllocCpy(hidden_host, setto);
}
else if (strcmp(var, "netdomain") == 0)
{
AllocCpy(netdomain, setto);
}
else if (strcmp(var, "helpchan") == 0)
{
AllocCpy(helpchan, setto);
}
else if (strcmp(var, "STATS_SERVER") == 0)
{
AllocCpy(STATS_SERVER, setto);
}
}
}
if (type == 0)
{
fprintf(stderr, "* Loaded %s ..\n", INCLUDE);
}
else
{
sendto_realops("Loaded %s ..", INCLUDE);
}
}
void doneconf(int type)
{
/* calculate on errors */
char *errormsg = MyMalloc(16384);
*errormsg = '\0';
if (!KLINE_ADDRESS || (*KLINE_ADDRESS == '\0'))
strcat(errormsg, "- Missing KLINE_ADDRESS\n");
#ifndef DEVELOP
if (KLINE_ADDRESS)
if (!strchr(KLINE_ADDRESS, '@') && !strchr(KLINE_ADDRESS, ':'))
{
strcat(errormsg,
"- KLINE_ADDRESS is not an e-mail or an URL\n");
}
#endif
if ((MAXCHANNELSPERUSER < 1))
strcat(errormsg,
"- MAXCHANNELSPERUSER is an invalid value, must be > 0\n");
if ((iNAH < 0) || (iNAH > 1))
strcat(errormsg, "- iNAH is an invalid value\n");
if (AUTO_JOIN_CHANS == '\0')
strcat(errormsg, "- AUTO_JOIN_CHANS is an invalid value\n");
if (OPER_AUTO_JOIN_CHANS == '\0')
strcat(errormsg,
"- OPER_AUTO_JOIN_CHANS is an invalid value\n");
if (HOST_TIMEOUT < 0 || HOST_TIMEOUT > 180)
strcat(errormsg, "- HOST_TIMEOUT is an invalid value\n");
if (HOST_RETRIES < 0 || HOST_RETRIES > 10)
strcat(errormsg, "- HOST_RETRIES is an invalid value\n");
#define Missing(x) !(x) || (*(x) == '\0')
if (Missing(defserv))
strcat(errormsg, "- Missing defserv field\n");
if (Missing(SERVICES_NAME))
strcat(errormsg, "- Missing SERVICES_NAME field\n");
if (Missing(oper_host))
strcat(errormsg, "- Missing oper_host field\n");
if (Missing(admin_host))
strcat(errormsg, "- Missing admin_host field\n");
if (Missing(locop_host))
strcat(errormsg, "- Missing locop_host field\n");
if (Missing(sadmin_host))
strcat(errormsg, "- Missing sadmin_host field\n");
if (Missing(netadmin_host))
strcat(errormsg, "- Missing netadmin_host field\n");
if (Missing(coadmin_host))
strcat(errormsg, "- Missing coadmin_host field\n");
if (Missing(techadmin_host))
strcat(errormsg, "- Missing techadmin_host field\n");
if (Missing(hidden_host))
strcat(errormsg, "- Missing hidden_host field\n");
if (Missing(netdomain))
strcat(errormsg, "- Missing netdomain field\n");
if (Missing(helpchan))
strcat(errormsg, "- Missing helpchan field\n");
if (Missing(STATS_SERVER))
strcat(errormsg, "- Missing STATS_SERVER field\n");
if (Missing(iConf.socksbanmessage))
strcat(errormsg, "- Missing SOCKSBANMESSAGE field\n");
if (Missing(iConf.socksquitmessage))
strcat(errormsg, "- Missing SOCKSQUITMESSAGE field\n");
if (*errormsg != '\0')
{
fprintf(stderr,
"\n*** ERRORS IN DYNAMIC CONFIGURATION (listed below) ***\n");
fprintf(stderr, errormsg);
MyFree(errormsg);
exit(-1);
}
MyFree(errormsg);
}
void init_dynconf(void)
{
bzero(&iConf, sizeof(iConf));
} }
/* Report the unrealircd.conf info -codemastr*/ /* Report the unrealircd.conf info -codemastr*/
void report_dynconf (aClient *sptr) void report_dynconf(aClient *sptr)
{ {
sendto_one(sptr, ":%s %i %s :*** Dynamic Configuration Report ***", me.name, RPL_TEXT, sptr->name); sendto_one(sptr, ":%s %i %s :*** Dynamic Configuration Report ***",
sendto_one(sptr, ":%s %i %s :INCLUDE: %s", me.name, RPL_TEXT, sptr->name, INCLUDE); me.name, RPL_TEXT, sptr->name);
sendto_one(sptr, ":%s %i %s :KLINE_ADDRESS: %s", me.name, RPL_TEXT, sptr->name, KLINE_ADDRESS); sendto_one(sptr, ":%s %i %s :INCLUDE: %s", me.name, RPL_TEXT,
sendto_one(sptr, ":%s %i %s :MODE_X: %i", me.name, RPL_TEXT, sptr->name, MODE_X); sptr->name, INCLUDE);
sendto_one(sptr, ":%s %i %s :MODE_I: %i", me.name, RPL_TEXT, sptr->name, MODE_I); sendto_one(sptr, ":%s %i %s :KLINE_ADDRESS: %s", me.name, RPL_TEXT,
sendto_one(sptr, ":%s %i %s :TRUEHUB: %i", me.name, RPL_TEXT, sptr->name, TRUEHUB); sptr->name, KLINE_ADDRESS);
sendto_one(sptr, ":%s %i %s :SHOWOPERS: %i", me.name, RPL_TEXT, sptr->name, SHOWOPERS); sendto_one(sptr, ":%s %i %s :MODE_X: %d", me.name, RPL_TEXT, sptr->name,
sendto_one(sptr, ":%s %i %s :KILLDIFF: %i", me.name, RPL_TEXT, sptr->name, KILLDIFF); MODE_X);
sendto_one(sptr, ":%s %i %s :SHOWOPERMOTD: %i", me.name, RPL_TEXT, sptr->name, SHOWOPERMOTD); sendto_one(sptr, ":%s %i %s :MODE_STRIPWORDS: %d", me.name, RPL_TEXT,
sendto_one(sptr, ":%s %i %s :HIDE_ULINES: %i", me.name, RPL_TEXT, sptr->name, HIDE_ULINES); sptr->name, MODE_STRIPWORDS);
sendto_one(sptr, ":%s %i %s :ALLOW_CHATOPS: %i", me.name, RPL_TEXT, sptr->name, ALLOW_CHATOPS); sendto_one(sptr, ":%s %i %s :MODE_I: %d", me.name, RPL_TEXT, sptr->name,
sendto_one(sptr, ":%s %i %s :SOCKS_BAN_MESSAGE: %s", me.name, RPL_TEXT, sptr->name, iConf.socksbanmessage); MODE_I);
sendto_one(sptr, ":%s %i %s :SOCKS_QUIT_MESSAGE: %s", me.name, RPL_TEXT, sptr->name, iConf.socksquitmessage); sendto_one(sptr, ":%s %i %s :TRUEHUB: %d", me.name, RPL_TEXT,
sendto_one(sptr, ":%s %i %s :SOCKSBANTIME: %i",me.name, RPL_TEXT, sptr->name, iConf.socksbantime); sptr->name, TRUEHUB);
sendto_one(sptr, ":%s %i %s :SHOWOPERS: %d", me.name, RPL_TEXT,
sptr->name, SHOWOPERS);
sendto_one(sptr, ":%s %i %s :KILLDIFF: %d", me.name, RPL_TEXT,
sptr->name, KILLDIFF);
sendto_one(sptr, ":%s %i %s :SHOWOPERMOTD: %d", me.name, RPL_TEXT,
sptr->name, SHOWOPERMOTD);
sendto_one(sptr, ":%s %i %s :HIDE_ULINES: %d", me.name, RPL_TEXT,
sptr->name, HIDE_ULINES);
sendto_one(sptr, ":%s %i %s :ALLOW_CHATOPS: %d", me.name, RPL_TEXT,
sptr->name, ALLOW_CHATOPS);
sendto_one(sptr, ":%s %i %s :SOCKS_BAN_MESSAGE: %s", me.name, RPL_TEXT,
sptr->name, iConf.socksbanmessage);
sendto_one(sptr, ":%s %i %s :SOCKS_QUIT_MESSAGE: %s", me.name, RPL_TEXT,
sptr->name, iConf.socksquitmessage);
sendto_one(sptr, ":%s %i %s :SOCKSBANTIME: %i", me.name, RPL_TEXT,
sptr->name, iConf.socksbantime);
sendto_one(sptr, ":%s %i %s :MAXCHANNELSPERUSER: %i", me.name, RPL_TEXT,
sptr->name, MAXCHANNELSPERUSER);
sendto_one(sptr, ":%s %i %s :WEBTV_SUPPORT: %d", me.name, RPL_TEXT,
sptr->name, WEBTV_SUPPORT);
sendto_one(sptr, ":%s %i %s :NO_OPER_HIDING: %d", me.name, RPL_TEXT,
sptr->name, NO_OPER_HIDING);
sendto_one(sptr, ":%s %i %s :AUTO_JOIN_CHANS: %s", me.name, RPL_TEXT,
sptr->name, AUTO_JOIN_CHANS);
sendto_one(sptr, ":%s %i %s :OPER_AUTO_JOIN_CHANS: %s", me.name,
RPL_TEXT, sptr->name, OPER_AUTO_JOIN_CHANS);
sendto_one(sptr, ":%s %i %s :HOST_TIMEOUT: %li", me.name, RPL_TEXT,
sptr->name, HOST_TIMEOUT);
sendto_one(sptr, ":%s %i %s :HOST_RETRIES: %d", me.name, RPL_TEXT,
sptr->name, HOST_RETRIES);
} }
/* Report the network file info -codemastr */ /* Report the network file info -codemastr */
void report_network (aClient *sptr) void report_network(aClient *sptr)
{ {
sendto_one(sptr, ":%s %i %s :*** Network Configuration Report ***", me.name, RPL_TEXT, sptr->name); sendto_one(sptr, ":%s %i %s :*** Network Configuration Report ***",
sendto_one(sptr, ":%s %i %s :NETWORK: %s", me.name, RPL_TEXT, sptr->name, ircnetwork); me.name, RPL_TEXT, sptr->name);
sendto_one(sptr, ":%s %i %s :DEFAULT_SERVER: %s", me.name, RPL_TEXT, sptr->name, defserv); sendto_one(sptr, ":%s %i %s :NETWORK: %s", me.name, RPL_TEXT,
sendto_one(sptr, ":%s %i %s :SERVICES_NAME: %s", me.name, RPL_TEXT, sptr->name, SERVICES_NAME); sptr->name, ircnetwork);
sendto_one(sptr, ":%s %i %s :OPER_HOST: %s", me.name, RPL_TEXT, sptr->name, oper_host); sendto_one(sptr, ":%s %i %s :DEFAULT_SERVER: %s", me.name, RPL_TEXT,
sendto_one(sptr, ":%s %i %s :ADMIN_HOST: %s", me.name, RPL_TEXT, sptr->name, admin_host); sptr->name, defserv);
sendto_one(sptr, ":%s %i %s :LOCOP_HOST: %s", me.name, RPL_TEXT, sptr->name, locop_host); sendto_one(sptr, ":%s %i %s :SERVICES_NAME: %s", me.name, RPL_TEXT,
sendto_one(sptr, ":%s %i %s :SADMIN_HOST: %s", me.name, RPL_TEXT, sptr->name, sadmin_host); sptr->name, SERVICES_NAME);
sendto_one(sptr, ":%s %i %s :NETADMIN_HOST: %s", me.name, RPL_TEXT, sptr->name, netadmin_host); sendto_one(sptr, ":%s %i %s :OPER_HOST: %s", me.name, RPL_TEXT,
sendto_one(sptr, ":%s %i %s :COADMIN_HOST: %s", me.name, RPL_TEXT, sptr->name, coadmin_host); sptr->name, oper_host);
sendto_one(sptr, ":%s %i %s :TECHADMIN_HOST: %s", me.name, RPL_TEXT, sptr->name, techadmin_host); sendto_one(sptr, ":%s %i %s :ADMIN_HOST: %s", me.name, RPL_TEXT,
sendto_one(sptr, ":%s %i %s :HIDDEN_HOST: %s", me.name, RPL_TEXT, sptr->name, hidden_host); sptr->name, admin_host);
sendto_one(sptr, ":%s %i %s :NETDOMAIN: %s", me.name, RPL_TEXT, sptr->name, netdomain); sendto_one(sptr, ":%s %i %s :LOCOP_HOST: %s", me.name, RPL_TEXT,
sendto_one(sptr, ":%s %i %s :HELPCHAN: %s", me.name, RPL_TEXT, sptr->name, helpchan); sptr->name, locop_host);
sendto_one(sptr, ":%s %i %s :STATS_SERVER: %s", me.name, RPL_TEXT, sptr->name, STATS_SERVER); sendto_one(sptr, ":%s %i %s :SADMIN_HOST: %s", me.name, RPL_TEXT,
sendto_one(sptr, ":%s %i %s :INAH: %i", me.name, RPL_TEXT, sptr->name, iNAH); sptr->name, sadmin_host);
sendto_one(sptr, ":%s %i %s :NETADMIN_HOST: %s", me.name, RPL_TEXT,
sptr->name, netadmin_host);
sendto_one(sptr, ":%s %i %s :COADMIN_HOST: %s", me.name, RPL_TEXT,
sptr->name, coadmin_host);
sendto_one(sptr, ":%s %i %s :TECHADMIN_HOST: %s", me.name, RPL_TEXT,
sptr->name, techadmin_host);
sendto_one(sptr, ":%s %i %s :HIDDEN_HOST: %s", me.name, RPL_TEXT,
sptr->name, hidden_host);
sendto_one(sptr, ":%s %i %s :NETDOMAIN: %s", me.name, RPL_TEXT,
sptr->name, netdomain);
sendto_one(sptr, ":%s %i %s :HELPCHAN: %s", me.name, RPL_TEXT,
sptr->name, helpchan);
sendto_one(sptr, ":%s %i %s :STATS_SERVER: %s", me.name, RPL_TEXT,
sptr->name, STATS_SERVER);
sendto_one(sptr, ":%s %i %s :INAH: %i", me.name, RPL_TEXT, sptr->name,
iNAH);
} }
+61 -44
View File
@@ -1,5 +1,21 @@
/*
* fdlist.c maintain lists of certain important fds /************************************************************************
* Unreal Internet Relay Chat Daemon, src/fdlist.c
* Copyright (C) Mika Nystrom
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 1, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id$ */ /* $Id$ */
@@ -11,60 +27,61 @@
#include "config.h" #include "config.h"
#include "fdlist.h" #include "fdlist.h"
void void addto_fdlist(int fd, fdlist * listp)
addto_fdlist(int fd, fdlist * listp)
{ {
int index; int index;
if ((index = ++listp->last_entry) >= MAXCONNECTIONS) { if ((index = ++listp->last_entry) >= MAXCONNECTIONS)
/* {
* list too big.. must exit /*
*/ * list too big.. must exit
--listp->last_entry; */
--listp->last_entry;
#ifdef USE_SYSLOG #ifdef USE_SYSLOG
(void) syslog(LOG_CRIT, "fdlist.c list too big.. must exit"); (void)syslog(LOG_CRIT, "fdlist.c list too big.. must exit");
#endif #endif
abort(); abort();
} }
else else
listp->entry[index] = fd; listp->entry[index] = fd;
return; return;
} }
void void delfrom_fdlist(int fd, fdlist * listp)
delfrom_fdlist(int fd, fdlist * listp)
{ {
int i; int i;
for (i = listp->last_entry; i; i--) { for (i = listp->last_entry; i; i--)
if (listp->entry[i] == fd) {
break; if (listp->entry[i] == fd)
} break;
if (!i) }
return; /* if (!i)
return; /*
* could not find it! * could not find it!
*/ */
/* /*
* swap with last_entry * swap with last_entry
*/ */
if (i == listp->last_entry) { if (i == listp->last_entry)
listp->entry[i] = 0; {
listp->last_entry--; listp->entry[i] = 0;
return; listp->last_entry--;
} return;
else { }
listp->entry[i] = listp->entry[listp->last_entry]; else
listp->entry[listp->last_entry] = 0; {
listp->last_entry--; listp->entry[i] = listp->entry[listp->last_entry];
return; listp->entry[listp->last_entry] = 0;
} listp->last_entry--;
return;
}
} }
void void init_fdlist(fdlist * listp)
init_fdlist(fdlist * listp)
{ {
listp->last_entry = 0; listp->last_entry = 0;
memset((char *) listp->entry, '\0', sizeof(listp->entry)); memset((char *)listp->entry, '\0', sizeof(listp->entry));
return; return;
} }
+445 -856
View File
File diff suppressed because it is too large Load Diff
+580 -407
View File
File diff suppressed because it is too large Load Diff
+869 -728
View File
File diff suppressed because it is too large Load Diff
+188 -153
View File
@@ -1,5 +1,5 @@
/************************************************************************ /************************************************************************
* IRC - Internet Relay Chat, ircd/list.c * Unreal Internet Relay Chat, src/list.c
* Copyright (C) 1990 Jarkko Oikarinen and * Copyright (C) 1990 Jarkko Oikarinen and
* University of Oulu, Finland * University of Oulu, Finland
* *
@@ -44,28 +44,32 @@
#ifdef DBMALLOC #ifdef DBMALLOC
#include "malloc.h" #include "malloc.h"
#endif #endif
void free_link PROTO((Link *)); void free_link PROTO((Link *));
Link *make_link PROTO(()); Link *make_link PROTO(());
extern ircstats IRCstats;
ID_CVS("$Id$"); ID_CVS("$Id$");
ID_Copyright("(C) 1988 University of Oulu, Computing Center and Jarkko Oikarinen"); ID_Copyright
("(C) 1988 University of Oulu, Computing Center and Jarkko Oikarinen");
ID_Notes("2.24 4/20/94"); ID_Notes("2.24 4/20/94");
#ifdef DEBUGMODE #ifdef DEBUGMODE
static struct liststats { static struct liststats {
int inuse; int inuse;
} cloc, crem, users, servs, links, classs, aconfs; } cloc, crem, users, servs, links, classs, aconfs;
#endif #endif
void outofmemory(); void outofmemory();
int flinks = 0; int flinks = 0;
Link *freelink = NULL; int freelinks = 0;
Link *freelink = NULL;
int numclients = 0;
void initlists() int numclients = 0;
void initlists()
{ {
#ifdef DEBUGMODE #ifdef DEBUGMODE
bzero((char *)&cloc, sizeof(cloc)); bzero((char *)&cloc, sizeof(cloc));
@@ -78,13 +82,13 @@ void initlists()
#endif #endif
} }
void outofmemory() void outofmemory()
{ {
Debug((DEBUG_FATAL, "Out of memory: restarting server...")); Debug((DEBUG_FATAL, "Out of memory: restarting server..."));
restart("Out of Memory"); restart("Out of Memory");
} }
/* /*
** Create a new aClient structure and set it to initial state. ** Create a new aClient structure and set it to initial state.
** **
@@ -95,11 +99,11 @@ void outofmemory()
** associated with the client defined by ** associated with the client defined by
** 'from'). ('from' is a local client!!). ** 'from'). ('from' is a local client!!).
*/ */
aClient *make_client(from, servr) aClient *make_client(from, servr)
aClient *from, *servr; aClient *from, *servr;
{ {
Reg1 aClient *cptr = NULL; aClient *cptr = NULL;
Reg2 unsigned size = CLIENT_REMOTE_SIZE; unsigned size = CLIENT_REMOTE_SIZE;
/* /*
* Check freelists first to see if we can grab a client without * Check freelists first to see if we can grab a client without
@@ -120,8 +124,8 @@ aClient *from, *servr;
#endif #endif
/* Note: structure is zero (calloc) */ /* Note: structure is zero (calloc) */
cptr->from = from ? from : cptr; /* 'from' of local client is self! */ cptr->from = from ? from : cptr; /* 'from' of local client is self! */
cptr->next = NULL; /* For machines with NON-ZERO NULL pointers >;) */ cptr->next = NULL; /* For machines with NON-ZERO NULL pointers >;) */
cptr->prev = NULL; cptr->prev = NULL;
cptr->hnext = NULL; cptr->hnext = NULL;
cptr->user = NULL; cptr->user = NULL;
@@ -131,9 +135,9 @@ aClient *from, *servr;
cptr->fd = -1; cptr->fd = -1;
(void)strcpy(cptr->username, "unknown"); (void)strcpy(cptr->username, "unknown");
if (size == CLIENT_LOCAL_SIZE) if (size == CLIENT_LOCAL_SIZE)
{ {
cptr->since = cptr->lasttime = cptr->since = cptr->lasttime =
cptr->lastnick = cptr->firsttime = TStime(); cptr->lastnick = cptr->firsttime = TStime();
cptr->confs = NULL; cptr->confs = NULL;
cptr->sockhost[0] = '\0'; cptr->sockhost[0] = '\0';
cptr->buffer[0] = '\0'; cptr->buffer[0] = '\0';
@@ -141,12 +145,12 @@ aClient *from, *servr;
#ifdef SOCKSPORT #ifdef SOCKSPORT
cptr->socksfd = -1; cptr->socksfd = -1;
#endif #endif
} }
return (cptr); return (cptr);
} }
void free_client(cptr) void free_client(cptr)
aClient *cptr; aClient *cptr;
{ {
MyFree((char *)cptr); MyFree((char *)cptr);
} }
@@ -155,14 +159,14 @@ aClient *cptr;
** 'make_user' add's an User information block to a client ** 'make_user' add's an User information block to a client
** if it was not previously allocated. ** if it was not previously allocated.
*/ */
anUser *make_user(cptr) anUser *make_user(cptr)
aClient *cptr; aClient *cptr;
{ {
Reg1 anUser *user; anUser *user;
user = cptr->user; user = cptr->user;
if (!user) if (!user)
{ {
user = (anUser *)MyMalloc(sizeof(anUser)); user = (anUser *)MyMalloc(sizeof(anUser));
#ifdef DEBUGMODE #ifdef DEBUGMODE
users.inuse++; users.inuse++;
@@ -174,18 +178,21 @@ aClient *cptr;
user->channel = NULL; user->channel = NULL;
user->invited = NULL; user->invited = NULL;
user->silence = NULL; user->silence = NULL;
user->server = NULL;
user->virthost = MyMalloc(2);
*user->virthost = '\0';
cptr->user = user; cptr->user = user;
} }
return user; return user;
} }
aServer *make_server(cptr) aServer *make_server(cptr)
aClient *cptr; aClient *cptr;
{ {
Reg1 aServer *serv = cptr->serv; aServer *serv = cptr->serv;
if (!serv) if (!serv)
{ {
serv = (aServer *)MyMalloc(sizeof(aServer)); serv = (aServer *)MyMalloc(sizeof(aServer));
#ifdef DEBUGMODE #ifdef DEBUGMODE
servs.inuse++; servs.inuse++;
@@ -193,9 +200,9 @@ aClient *cptr;
serv->user = NULL; serv->user = NULL;
serv->nexts = NULL; serv->nexts = NULL;
*serv->by = '\0'; *serv->by = '\0';
*serv->up = '\0'; serv->up = NULL;
cptr->serv = serv; cptr->serv = serv;
} }
return cptr->serv; return cptr->serv;
} }
@@ -204,16 +211,18 @@ aClient *cptr;
** Decrease user reference count by one and realease block, ** Decrease user reference count by one and realease block,
** if count reaches 0 ** if count reaches 0
*/ */
void free_user(user, cptr) void free_user(user, cptr)
Reg1 anUser *user; anUser *user;
aClient *cptr; aClient *cptr;
{ {
if (--user->refcnt <= 0) if (--user->refcnt <= 0)
{ {
if (user->away) if (user->away)
MyFree((char *)user->away); MyFree((char *)user->away);
if (user->swhois) if (user->swhois)
MyFree((char *)user->swhois); MyFree((char *)user->swhois);
if (user->virthost)
MyFree((char *)user->virthost);
/* /*
* sanity check * sanity check
*/ */
@@ -221,58 +230,68 @@ aClient *cptr;
user->invited || user->channel) user->invited || user->channel)
#ifdef DEBUGMODE #ifdef DEBUGMODE
dumpcore("%#x user (%s!%s@%s) %#x %#x %#x %d %d", dumpcore("%#x user (%s!%s@%s) %#x %#x %#x %d %d",
cptr, cptr ? cptr->name : "<noname>", cptr, cptr ? cptr->name : "<noname>",
user->username, user->realhost, user, user->username, user->realhost, user,
user->invited, user->channel, user->joined, user->invited, user->channel, user->joined,
user->refcnt); user->refcnt);
#else #else
sendto_ops("* %#x user (%s!%s@%s) %#x %#x %#x %d %d *", sendto_ops("* %#x user (%s!%s@%s) %#x %#x %#x %d %d *",
cptr, cptr ? cptr->name : "<noname>", cptr, cptr ? cptr->name : "<noname>",
user->username, user->realhost, user, user->username, user->realhost, user,
user->invited, user->channel, user->joined, user->invited, user->channel, user->joined,
user->refcnt); user->refcnt);
#endif #endif
MyFree((char *)user); MyFree((char *)user);
#ifdef DEBUGMODE #ifdef DEBUGMODE
users.inuse--; users.inuse--;
#endif #endif
} }
} }
/* /*
* taken the code from ExitOneClient() for this and placed it here. * taken the code from ExitOneClient() for this and placed it here.
* - avalon * - avalon
*/ */
void remove_client_from_list(cptr) void remove_client_from_list(cptr)
Reg1 aClient *cptr; aClient *cptr;
{ {
if (IsServer(cptr))
IRCstats.servers--;
if (IsClient(cptr))
{
if (IsInvisible(cptr))
IRCstats.invisible--;
if (IsOper(cptr))
IRCstats.operators--;
IRCstats.clients--;
}
checklist(); checklist();
if (cptr->prev) if (cptr->prev)
cptr->prev->next = cptr->next; cptr->prev->next = cptr->next;
else else
{ {
client = cptr->next; client = cptr->next;
if (client) if (client)
client->prev = NULL; client->prev = NULL;
} }
if (cptr->next) if (cptr->next)
cptr->next->prev = cptr->prev; cptr->next->prev = cptr->prev;
if (IsPerson(cptr)) /* Only persons can have been added before */ if (IsPerson(cptr)) /* Only persons can have been added before */
{ {
add_history(cptr); add_history(cptr, 0);
off_history(cptr); /* Remove all pointers to cptr */ off_history(cptr); /* Remove all pointers to cptr */
} }
if (cptr->user) if (cptr->user)
(void)free_user(cptr->user, cptr); (void)free_user(cptr->user, cptr);
if (cptr->serv) if (cptr->serv)
{ {
if (cptr->serv->user) if (cptr->serv->user)
free_user(cptr->serv->user, cptr); free_user(cptr->serv->user, cptr);
MyFree((char *)cptr->serv); MyFree((char *)cptr->serv);
#ifdef DEBUGMODE #ifdef DEBUGMODE
servs.inuse--; servs.inuse--;
#endif #endif
} }
#ifdef DEBUGMODE #ifdef DEBUGMODE
if (cptr->fd == -2) if (cptr->fd == -2)
cloc.inuse--; cloc.inuse--;
@@ -290,8 +309,8 @@ Reg1 aClient *cptr;
* in this file, shouldnt they ? after all, this is list.c, isnt it ? * in this file, shouldnt they ? after all, this is list.c, isnt it ?
* -avalon * -avalon
*/ */
void add_client_to_list(cptr) void add_client_to_list(cptr)
aClient *cptr; aClient *cptr;
{ {
/* /*
* since we always insert new clients to the top of the list, * since we always insert new clients to the top of the list,
@@ -307,31 +326,31 @@ aClient *cptr;
/* /*
* Look for ptr in the linked listed pointed to by link. * Look for ptr in the linked listed pointed to by link.
*/ */
Link *find_user_link(lp, ptr) Link *find_user_link(lp, ptr)
Reg1 Link *lp; Link *lp;
Reg2 aClient *ptr; aClient *ptr;
{ {
if (ptr) if (ptr)
while (lp) while (lp)
{ {
if (lp->value.cptr == ptr) if (lp->value.cptr == ptr)
return (lp); return (lp);
lp = lp->next; lp = lp->next;
} }
return NULL; return NULL;
} }
Link *find_channel_link(lp, ptr) Link *find_channel_link(lp, ptr)
Reg1 Link *lp; Link *lp;
Reg2 aChannel *ptr; aChannel *ptr;
{ {
if (ptr) if (ptr)
while (lp) while (lp)
{ {
if (lp->value.chptr == ptr) if (lp->value.chptr == ptr)
return (lp); return (lp);
lp = lp->next; lp = lp->next;
} }
return NULL; return NULL;
} }
@@ -342,12 +361,13 @@ Reg2 aChannel *ptr;
* match() on it. Side effect: if found, this link is moved to the top of * match() on it. Side effect: if found, this link is moved to the top of
* the list. * the list.
*/ */
int find_str_match_link(lp, str) int find_str_match_link(lp, str)
Reg1 Link **lp; /* Two **'s, since we might modify the original *lp */ Link **lp; /* Two **'s, since we might modify the original *lp */
Reg2 char *str; char *str;
{ {
Link *ptr, **head = lp; Link **head = lp;
if (!str || !lp)
return 0;
if (lp && *lp) if (lp && *lp)
{ {
if (!match((*lp)->value.cp, str)) if (!match((*lp)->value.cp, str))
@@ -366,29 +386,30 @@ Reg2 char *str;
return 0; return 0;
} }
void free_str_list(lp) void free_str_list(lp)
Reg1 Link *lp; Link *lp;
{ {
Reg2 Link *next; Link *next;
while (lp) { while (lp)
{
next = lp->next; next = lp->next;
MyFree((char *)lp->value.cp); MyFree((char *)lp->value.cp);
free_link(lp); free_link(lp);
lp = next; lp = next;
} }
return; return;
} }
#define LINKSIZE (4072/sizeof(Link)) #define LINKSIZE (4072/sizeof(Link))
Link *make_link() Link *make_link()
{ {
Link *lp; Link *lp, *lp1;
int i; int i;
/* "caching" slab-allocator... ie. we're allocating one pages /* "caching" slab-allocator... ie. we're allocating one pages
(hopefully - upped to the Linux default, not dbuf.c) worth of (hopefully - upped to the Linux default, not dbuf.c) worth of
@@ -396,15 +417,26 @@ Link *make_link()
All links left free from this process or separately freed All links left free from this process or separately freed
by a call to free_link() are moved over to freelink-list. by a call to free_link() are moved over to freelink-list.
Impact? Let's see... -Donwulff */ Impact? Let's see... -Donwulff */
if(freelink==NULL) { /* Impact is a huge memory leak -Stskeeps
lp = (Link *)MyMalloc(LINKSIZE*sizeof(Link)); hope this implementation works a little bit better */
freelink=lp+1; if (freelink == NULL)
flinks+=LINKSIZE; {
for(i=1;i<(LINKSIZE-1);i++) for (i = 1; i <= LINKSIZE; i++)
(lp+i)->next=lp+i+1; (lp+i)->next=NULL; {
} else { lp = (Link *)MyMalloc(sizeof(Link));
lp->next = freelink;
freelink = lp;
}
freelinks = freelinks + LINKSIZE;
lp = freelink; lp = freelink;
freelink=freelink->next; freelink = lp->next;
freelinks--;
}
else
{
lp = freelink;
freelink = freelink->next;
freelinks--;
} }
#ifdef DEBUGMODE #ifdef DEBUGMODE
links.inuse++; links.inuse++;
@@ -412,29 +444,31 @@ Link *make_link()
return lp; return lp;
} }
void free_link(lp) void free_link(lp)
Reg1 Link *lp; Link *lp;
{ {
lp->next=freelink; lp->next = freelink;
freelink=lp; freelink = lp;
freelinks++;
#ifdef DEBUGMODE #ifdef DEBUGMODE
links.inuse--; links.inuse--;
#endif #endif
} }
Ban *make_ban() Ban *make_ban()
{ {
Reg1 Ban *lp; Ban *lp;
lp = (Ban *)MyMalloc(sizeof(Ban)); lp = (Ban *) MyMalloc(sizeof(Ban));
#ifdef DEBUGMODE #ifdef DEBUGMODE
links.inuse++; links.inuse++;
#endif #endif
return lp; return lp;
} }
void free_ban(lp) void free_ban(lp)
Reg1 Ban *lp; Ban *lp;
{ {
MyFree((char *)lp); MyFree((char *)lp);
#ifdef DEBUGMODE #ifdef DEBUGMODE
@@ -442,9 +476,9 @@ Reg1 Ban *lp;
#endif #endif
} }
aClass *make_class() aClass *make_class()
{ {
Reg1 aClass *tmp; aClass *tmp;
tmp = (aClass *)MyMalloc(sizeof(aClass)); tmp = (aClass *)MyMalloc(sizeof(aClass));
#ifdef DEBUGMODE #ifdef DEBUGMODE
@@ -453,8 +487,8 @@ aClass *make_class()
return tmp; return tmp;
} }
void free_class(tmp) void free_class(tmp)
Reg1 aClass *tmp; aClass *tmp;
{ {
MyFree((char *)tmp); MyFree((char *)tmp);
#ifdef DEBUGMODE #ifdef DEBUGMODE
@@ -462,9 +496,9 @@ Reg1 aClass *tmp;
#endif #endif
} }
aSqlineItem *make_sqline() aSqlineItem *make_sqline()
{ {
Reg1 aSqlineItem *asqline; aSqlineItem *asqline;
asqline = (struct SqlineItem *)MyMalloc(sizeof(aSqlineItem)); asqline = (struct SqlineItem *)MyMalloc(sizeof(aSqlineItem));
asqline->next = NULL; asqline->next = NULL;
@@ -473,15 +507,15 @@ aSqlineItem *make_sqline()
return (asqline); return (asqline);
} }
aConfItem *make_conf() aConfItem *make_conf()
{ {
Reg1 aConfItem *aconf; aConfItem *aconf;
aconf = (struct ConfItem *)MyMalloc(sizeof(aConfItem)); aconf = (struct ConfItem *)MyMalloc(sizeof(aConfItem));
#ifdef DEBUGMODE #ifdef DEBUGMODE
aconfs.inuse++; aconfs.inuse++;
#endif #endif
bzero((char *)&aconf->ipnum, sizeof(struct in_addr)); bzero((char *)&aconf->ipnum, sizeof(struct IN_ADDR));
aconf->next = NULL; aconf->next = NULL;
aconf->host = aconf->passwd = aconf->name = NULL; aconf->host = aconf->passwd = aconf->name = NULL;
aconf->status = CONF_ILLEGAL; aconf->status = CONF_ILLEGAL;
@@ -492,24 +526,24 @@ aConfItem *make_conf()
return (aconf); return (aconf);
} }
void delist_conf(aconf) void delist_conf(aconf)
aConfItem *aconf; aConfItem *aconf;
{ {
if (aconf == conf) if (aconf == conf)
conf = conf->next; conf = conf->next;
else else
{ {
aConfItem *bconf; aConfItem *bconf;
for (bconf = conf; aconf != bconf->next; bconf = bconf->next) for (bconf = conf; aconf != bconf->next; bconf = bconf->next)
; ;
bconf->next = aconf->next; bconf->next = aconf->next;
} }
aconf->next = NULL; aconf->next = NULL;
} }
void free_sqline(asqline) void free_sqline(asqline)
aSqlineItem *asqline; aSqlineItem *asqline;
{ {
del_queries((char *)asqline); del_queries((char *)asqline);
MyFree(asqline->sqline); MyFree(asqline->sqline);
@@ -518,8 +552,8 @@ aSqlineItem *asqline;
return; return;
} }
void free_conf(aconf) void free_conf(aconf)
aConfItem *aconf; aConfItem *aconf;
{ {
del_queries((char *)aconf); del_queries((char *)aconf);
MyFree(aconf->host); MyFree(aconf->host);
@@ -535,47 +569,48 @@ aConfItem *aconf;
} }
#ifdef DEBUGMODE #ifdef DEBUGMODE
void send_listinfo(cptr, name) void send_listinfo(cptr, name)
aClient *cptr; aClient *cptr;
char *name; char *name;
{ {
int inuse = 0, mem = 0, tmp = 0; int inuse = 0, mem = 0, tmp = 0;
sendto_one(cptr, ":%s %d %s :Local: inuse: %d(%d)", sendto_one(cptr, ":%s %d %s :Local: inuse: %d(%d)",
me.name, RPL_STATSDEBUG, name, inuse += cloc.inuse, me.name, RPL_STATSDEBUG, name, inuse += cloc.inuse,
tmp = cloc.inuse * CLIENT_LOCAL_SIZE); tmp = cloc.inuse * CLIENT_LOCAL_SIZE);
mem += tmp; mem += tmp;
sendto_one(cptr, ":%s %d %s :Remote: inuse: %d(%d)", sendto_one(cptr, ":%s %d %s :Remote: inuse: %d(%d)",
me.name, RPL_STATSDEBUG, name, me.name, RPL_STATSDEBUG, name,
crem.inuse, tmp = crem.inuse * CLIENT_REMOTE_SIZE); crem.inuse, tmp = crem.inuse * CLIENT_REMOTE_SIZE);
mem += tmp; mem += tmp;
inuse += crem.inuse; inuse += crem.inuse;
sendto_one(cptr, ":%s %d %s :Users: inuse: %d(%d)", sendto_one(cptr, ":%s %d %s :Users: inuse: %d(%d)",
me.name, RPL_STATSDEBUG, name, users.inuse, me.name, RPL_STATSDEBUG, name, users.inuse,
tmp = users.inuse * sizeof(anUser)); tmp = users.inuse * sizeof(anUser));
mem += tmp; mem += tmp;
inuse += users.inuse, inuse += users.inuse,
sendto_one(cptr, ":%s %d %s :Servs: inuse: %d(%d)", sendto_one(cptr, ":%s %d %s :Servs: inuse: %d(%d)",
me.name, RPL_STATSDEBUG, name, servs.inuse, me.name, RPL_STATSDEBUG, name, servs.inuse,
tmp = servs.inuse * sizeof(aServer)); tmp = servs.inuse * sizeof(aServer));
mem += tmp; mem += tmp;
inuse += servs.inuse, inuse += servs.inuse,
sendto_one(cptr, ":%s %d %s :Links: inuse: %d(%d)", sendto_one(cptr, ":%s %d %s :Links: inuse: %d(%d)",
me.name, RPL_STATSDEBUG, name, links.inuse, me.name, RPL_STATSDEBUG, name, links.inuse,
tmp = links.inuse * sizeof(Link)); tmp = links.inuse * sizeof(Link));
mem += tmp; mem += tmp;
inuse += links.inuse, inuse += links.inuse,
sendto_one(cptr, ":%s %d %s :Classes: inuse: %d(%d)", sendto_one(cptr, ":%s %d %s :Classes: inuse: %d(%d)",
me.name, RPL_STATSDEBUG, name, classs.inuse, me.name, RPL_STATSDEBUG, name, classs.inuse,
tmp = classs.inuse * sizeof(aClass)); tmp = classs.inuse * sizeof(aClass));
mem += tmp; mem += tmp;
inuse += classs.inuse, inuse += classs.inuse,
sendto_one(cptr, ":%s %d %s :Confs: inuse: %d(%d)", sendto_one(cptr, ":%s %d %s :Confs: inuse: %d(%d)",
me.name, RPL_STATSDEBUG, name, aconfs.inuse, me.name, RPL_STATSDEBUG, name, aconfs.inuse,
tmp = aconfs.inuse * sizeof(aConfItem)); tmp = aconfs.inuse * sizeof(aConfItem));
mem += tmp; mem += tmp;
inuse += aconfs.inuse, inuse += aconfs.inuse,
sendto_one(cptr, ":%s %d %s :Totals: inuse %d %d", sendto_one(cptr, ":%s %d %s :Totals: inuse %d %d",
me.name, RPL_STATSDEBUG, name, inuse, mem); me.name, RPL_STATSDEBUG, name, inuse, mem);
} }
#endif #endif
+319 -293
View File
@@ -1,5 +1,5 @@
/* /*
* IRC - Internet Relay Chat, common/match.c * Unreal Internet Relay Chat Daemon, src/match.c
* Copyright (C) 1990 Jarkko Oikarinen * Copyright (C) 1990 Jarkko Oikarinen
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@@ -34,124 +34,130 @@ ID_Copyright("(C) 1990 Jarkko Oikarinen");
* 1, if no match * 1, if no match
*/ */
#ifndef USE_LOCALE
u_char touppertab[], tolowertab[]; u_char touppertab[], tolowertab[];
#define tolowertab2 tolowertab #define tolowertab2 tolowertab
#endif
/* /*
* match() * match()
* written by binary * written by binary
*/ */
int match(mask, name) int match(mask, name)
char *mask, *name; char *mask, *name;
{ {
Reg1 u_char *m; /* why didn't the old one use registers ?!??!?!?! */ u_char *m; /* why didn't the old one use registers ?!??!?!?! */
Reg2 u_char *n; u_char *n;
Reg3 u_char cm; u_char cm;
Reg4 u_char *mylowertab; u_char *mylowertab;
u_char *wsn; u_char *wsn;
u_char *wsm; u_char *wsm;
m = (u_char *)mask;
cm = *m;
mylowertab = tolowertab2; m = (u_char *)mask;
#define lc(x) mylowertab[x] /* use mylowertab, because registers are FASTER */
n = (u_char *)name; cm = *m;
if (cm == '*')
{ #ifndef USE_LOCALE
if (m[1] == '\0') /* mask is just "*", so true */ mylowertab = tolowertab2;
return 0; #define lc(x) mylowertab[x] /* use mylowertab, because registers are FASTER */
} #else
else if (cm != '?' && lc(cm) != lc(*n)) #define lc(x) tolower(x)
return 1; /* most likely first chars won't match */ #endif
else
{ n = (u_char *)name;
m++; if (cm == '*')
n++; {
} if (m[1] == '\0') /* mask is just "*", so true */
cm = lc(*m); return 0;
wsm = (char *)NULL; }
while (1) else if (cm != '?' && lc(cm) != lc(*n))
{ return 1; /* most likely first chars won't match */
if (cm == '*') /* found the * wildcard */ else
{ {
m++; /* go to next char of mask */ m++;
if (!*m) /* if at end of mask, */ n++;
return 0; /* function becomes true. */ }
while (*m == '*') /* while the char at m is "*" */ cm = lc(*m);
{ wsm = (char *)NULL;
m++; /* go to next char of mask */ while (1)
if (!*m) /* if at end of mask, */ {
return 0; /* function becomes true. */ if (cm == '*') /* found the * wildcard */
} {
cm = *m; m++; /* go to next char of mask */
if (cm == '\\') /* don't do ? checking if a \ */ if (!*m) /* if at end of mask, */
{ return 0; /* function becomes true. */
cm = *(++m); /* just skip this char, no ? checking */ while (*m == '*') /* while the char at m is "*" */
} {
else if (cm == '?') /* if it's a ? */ m++; /* go to next char of mask */
{ if (!*m) /* if at end of mask, */
do return 0; /* function becomes true. */
{ }
m++; /* go to the next char of both */ cm = *m;
n++; if (cm == '\\') /* don't do ? checking if a \ */
if (!*n) /* if end of test string... */ {
return (!*m ? 0 : 1); /* true if end of mask str, else false */ cm = *(++m); /* just skip this char, no ? checking */
} while (*m == '?'); /* while we have ?'s */ }
cm = *m; else if (cm == '?') /* if it's a ? */
if (!cm) /* last char of mask is ?, so it's true */ {
return 0; do
} {
cm = lc(cm); m++; /* go to the next char of both */
while (lc(*n) != cm) n++;
{ /* compare */ if (!*n) /* if end of test string... */
n++; /* go to next char of n */ return (!*m ? 0 : 1); /* true if end of mask str, else false */
if (!*n) /* if at end of n string */ }
return 1; /* function becomes false. */ while (*m == '?'); /* while we have ?'s */
} cm = *m;
wsm = m; /* mark after where wildcard found */ if (!cm) /* last char of mask is ?, so it's true */
cm = lc(*(++m)); /* go to next mask char */ return 0;
wsn = n; /* mark spot first char was found */ }
n++; /* go to next char of n */ cm = lc(cm);
continue; while (lc(*n) != cm)
} { /* compare */
if (cm == '?') /* found ? wildcard */ n++; /* go to next char of n */
{ if (!*n) /* if at end of n string */
cm = lc(*(++m)); /* just skip and go to next */ return 1; /* function becomes false. */
n++; }
if (!*n) /* return true if end of both, */ wsm = m; /* mark after where wildcard found */
return (cm ? 1 : 0); /* false if end of test str only */ cm = lc(*(++m)); /* go to next mask char */
continue; wsn = n; /* mark spot first char was found */
} n++; /* go to next char of n */
if (cm == '\\') /* next char will not be a wildcard. */ continue;
{ /* skip wild checking, don't continue */ }
cm = lc(*(++m)); if (cm == '?') /* found ? wildcard */
n++; {
} cm = lc(*(++m)); /* just skip and go to next */
/* Complicated to read, but to save CPU time. Every ounce counts. */ n++;
if (lc(*n) != cm) /* if the current chars don't equal, */ if (!*n) /* return true if end of both, */
{ return (cm ? 1 : 0); /* false if end of test str only */
if (!wsm) /* if there was no * wildcard, */ continue;
return 1; /* function becomes false. */ }
n = wsn + 1; /* start on char after the one we found last */ if (cm == '\\') /* next char will not be a wildcard. */
m = wsm; /* set m to the spot after the "*" */ { /* skip wild checking, don't continue */
cm = lc(*m); cm = lc(*(++m));
while (cm != lc(*n)) n++;
{ /* compare them */ }
n++; /* go to next char of n */ /* Complicated to read, but to save CPU time. Every ounce counts. */
if (!*n) /* if we reached end of n string, */ if (lc(*n) != cm) /* if the current chars don't equal, */
return 1; /* function becomes false. */ {
} if (!wsm) /* if there was no * wildcard, */
wsn = n; /* mark spot first char was found */ return 1; /* function becomes false. */
} n = wsn + 1; /* start on char after the one we found last */
if (!cm) /* cm == cn, so if !cm, then we've */ m = wsm; /* set m to the spot after the "*" */
return 0; /* reached end of BOTH, so it matches */ cm = lc(*m);
m++; /* go to next mask char */ while (cm != lc(*n))
n++; /* go to next testing char */ { /* compare them */
cm = lc(*m); /* pointers are slower */ n++; /* go to next char of n */
} if (!*n) /* if we reached end of n string, */
return 1; /* function becomes false. */
}
wsn = n; /* mark spot first char was found */
}
if (!cm) /* cm == cn, so if !cm, then we've */
return 0; /* reached end of BOTH, so it matches */
m++; /* go to next mask char */
n++; /* go to next testing char */
cm = lc(*m); /* pointers are slower */
}
} }
/* /*
@@ -159,41 +165,41 @@ char *mask, *name;
* This particular version is "in place", so that it changes the pattern * This particular version is "in place", so that it changes the pattern
* which is to be reduced to a "minimal" size. * which is to be reduced to a "minimal" size.
*/ */
char * char *collapse(pattern)
collapse(pattern) char *pattern;
char *pattern;
{ {
Reg1 char *s; char *s;
Reg2 char *s1; char *s1;
Reg3 char *t; char *t;
s = pattern; s = pattern;
if (BadPtr(pattern)) if (BadPtr(pattern))
return pattern; return pattern;
/* /*
* Collapse all \** into \*, \*[?]+\** into \*[?]+ * Collapse all \** into \*, \*[?]+\** into \*[?]+
*/ */
for (; *s; s++) for (; *s; s++)
if (*s == '\\') if (*s == '\\')
{ {
if (!*(s + 1)) if (!*(s + 1))
break; break;
else else
s++; s++;
} }
else if (*s == '*') { else if (*s == '*')
if (*(t = s1 = s + 1) == '*') {
while (*t == '*') if (*(t = s1 = s + 1) == '*')
t++; while (*t == '*')
else if (*t == '?') t++;
for (t++, s1++; *t == '*' || *t == '?'; t++) else if (*t == '?')
if (*t == '?') for (t++, s1++; *t == '*' || *t == '?'; t++)
*s1++ = *t; if (*t == '?')
while ((*s1++ = *t++)) *s1++ = *t;
; while ((*s1++ = *t++))
} ;
return pattern; }
return pattern;
} }
@@ -204,167 +210,187 @@ collapse(pattern)
* <0, if s1 lexicographically less than s2 * <0, if s1 lexicographically less than s2
* >0, if s1 lexicographically greater than s2 * >0, if s1 lexicographically greater than s2
*/ */
int int smycmp(s1, s2)
smycmp(s1, s2) char *s1;
char *s1; char *s2;
char *s2;
{ {
Reg1 u_char *str1; u_char *str1;
Reg2 u_char *str2; u_char *str2;
Reg3 int res; int res;
str1 = (u_char *)s1; str1 = (u_char *)s1;
str2 = (u_char *)s2; str2 = (u_char *)s2;
while ((res = toupper(*str1) - toupper(*str2)) == 0) { while ((res = toupper(*str1) - toupper(*str2)) == 0)
if (*str1 == '\0') {
return 0; if (*str1 == '\0')
str1++; return 0;
str2++; str1++;
} str2++;
return (res); }
return (res);
} }
int int myncmp(str1, str2, n)
myncmp(str1, str2, n) char *str1;
char *str1; char *str2;
char *str2; int n;
int n;
{ {
Reg1 u_char *s1; u_char *s1;
Reg2 u_char *s2; u_char *s2;
Reg3 int res; int res;
s1 = (u_char *)str1; s1 = (u_char *)str1;
s2 = (u_char *)str2; s2 = (u_char *)str2;
while ((res = toupper(*s1) - toupper(*s2)) == 0) while ((res = toupper(*s1) - toupper(*s2)) == 0)
{ {
s1++; s1++;
s2++; s2++;
n--; n--;
if (n == 0 || (*s1 == '\0' && *s2 == '\0')) if (n == 0 || (*s1 == '\0' && *s2 == '\0'))
return 0; return 0;
} }
return (res); return (res);
} }
#ifndef USE_LOCALE
u_char tolowertab[] = { u_char tolowertab[] = {
0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa,
0xb, 0xc, 0xd, 0xe, 0xf, 0x10, 0x11, 0x12, 0x13, 0x14, 0xb, 0xc, 0xd, 0xe, 0xf, 0x10, 0x11, 0x12, 0x13, 0x14,
0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d,
0x1e, 0x1f, 0x1e, 0x1f,
' ', '!', '"', '#', '$', '%', '&', 0x27, '(', ')', ' ', '!', '"', '#', '$', '%', '&', 0x27, '(', ')',
'*', '+', ',', '-', '.', '/', '*', '+', ',', '-', '.', '/',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
':', ';', '<', '=', '>', '?', ':', ';', '<', '=', '>', '?',
'@', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', '@', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
't', 'u', 'v', 'w', 'x', 'y', 'z', '[', '\\', ']', '^', 't', 'u', 'v', 'w', 'x', 'y', 'z', '[', '\\', ']', '^',
'_', '_',
'`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~',
0x7f, 0x7f,
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89,
0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99,
0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9,
0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9,
0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9,
0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9,
0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9,
0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9,
0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
}; };
u_char touppertab[] = { u_char touppertab[] = {
0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa,
0xb, 0xc, 0xd, 0xe, 0xf, 0x10, 0x11, 0x12, 0x13, 0x14, 0xb, 0xc, 0xd, 0xe, 0xf, 0x10, 0x11, 0x12, 0x13, 0x14,
0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d,
0x1e, 0x1f, 0x1e, 0x1f,
' ', '!', '"', '#', '$', '%', '&', 0x27, '(', ')', ' ', '!', '"', '#', '$', '%', '&', 0x27, '(', ')',
'*', '+', ',', '-', '.', '/', '*', '+', ',', '-', '.', '/',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
':', ';', '<', '=', '>', '?', ':', ';', '<', '=', '>', '?',
'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']', '^', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']', '^',
0x5f, 0x5f,
'`', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', '`', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '{', '|', '}', '~', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '{', '|', '}', '~',
0x7f, 0x7f,
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89,
0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99,
0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9,
0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9,
0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9,
0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9,
0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9,
0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9,
0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
}; };
#endif
u_char char_atribs[] = { u_char char_atribs[] = {
/* 0-7 */ CNTRL, CNTRL, CNTRL, CNTRL, CNTRL, CNTRL, CNTRL, CNTRL, /* 0-7 */ CNTRL, CNTRL, CNTRL, CNTRL, CNTRL, CNTRL, CNTRL, CNTRL,
/* 8-12 */ CNTRL, CNTRL|SPACE, CNTRL|SPACE, CNTRL|SPACE, CNTRL|SPACE, /* 8-12 */ CNTRL, CNTRL | SPACE, CNTRL | SPACE, CNTRL | SPACE,
/* 13-15 */ CNTRL|SPACE, CNTRL, CNTRL, CNTRL | SPACE,
/* 16-23 */ CNTRL, CNTRL, CNTRL, CNTRL, CNTRL, CNTRL, CNTRL, CNTRL, /* 13-15 */ CNTRL | SPACE, CNTRL, CNTRL,
/* 24-31 */ CNTRL, CNTRL, CNTRL, CNTRL, CNTRL, CNTRL, CNTRL, CNTRL, /* 16-23 */ CNTRL, CNTRL, CNTRL, CNTRL, CNTRL, CNTRL, CNTRL, CNTRL,
/* space */ PRINT|SPACE, /* 24-31 */ CNTRL, CNTRL, CNTRL, CNTRL, CNTRL, CNTRL, CNTRL, CNTRL,
/* !"#$%&'( */ PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, /* space */ PRINT | SPACE,
/* )*+,-./ */ PRINT, PRINT, PRINT, PRINT, PRINT|ALLOW, PRINT|ALLOW, PRINT, /* !"#$%&'( */ PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT, PRINT,
/* 012 */ PRINT|DIGIT|ALLOW, PRINT|DIGIT|ALLOW, PRINT|DIGIT|ALLOW, /* )*+,-./ */ PRINT, PRINT, PRINT, PRINT, PRINT | ALLOW, PRINT | ALLOW,
/* 345 */ PRINT|DIGIT|ALLOW, PRINT|DIGIT|ALLOW, PRINT|DIGIT|ALLOW, PRINT,
/* 678 */ PRINT|DIGIT|ALLOW, PRINT|DIGIT|ALLOW, PRINT|DIGIT|ALLOW, /* 012 */ PRINT | DIGIT | ALLOW, PRINT | DIGIT | ALLOW,
/* 9:; */ PRINT|DIGIT|ALLOW, PRINT, PRINT, PRINT | DIGIT | ALLOW,
/* <=>? */ PRINT, PRINT, PRINT, PRINT, /* 345 */ PRINT | DIGIT | ALLOW, PRINT | DIGIT | ALLOW,
/* @ */ PRINT, PRINT | DIGIT | ALLOW,
/* ABC */ PRINT|ALPHA|ALLOW, PRINT|ALPHA|ALLOW, PRINT|ALPHA|ALLOW, /* 678 */ PRINT | DIGIT | ALLOW, PRINT | DIGIT | ALLOW,
/* DEF */ PRINT|ALPHA|ALLOW, PRINT|ALPHA|ALLOW, PRINT|ALPHA|ALLOW, PRINT | DIGIT | ALLOW,
/* GHI */ PRINT|ALPHA|ALLOW, PRINT|ALPHA|ALLOW, PRINT|ALPHA|ALLOW, /* 9:; */ PRINT | DIGIT | ALLOW, PRINT, PRINT,
/* JKL */ PRINT|ALPHA|ALLOW, PRINT|ALPHA|ALLOW, PRINT|ALPHA|ALLOW, /* <=>? */ PRINT, PRINT, PRINT, PRINT,
/* MNO */ PRINT|ALPHA|ALLOW, PRINT|ALPHA|ALLOW, PRINT|ALPHA|ALLOW, /* @ */ PRINT,
/* PQR */ PRINT|ALPHA|ALLOW, PRINT|ALPHA|ALLOW, PRINT|ALPHA|ALLOW, /* ABC */ PRINT | ALPHA | ALLOW, PRINT | ALPHA | ALLOW,
/* STU */ PRINT|ALPHA|ALLOW, PRINT|ALPHA|ALLOW, PRINT|ALPHA|ALLOW, PRINT | ALPHA | ALLOW,
/* VWX */ PRINT|ALPHA|ALLOW, PRINT|ALPHA|ALLOW, PRINT|ALPHA|ALLOW, /* DEF */ PRINT | ALPHA | ALLOW, PRINT | ALPHA | ALLOW,
/* YZ[ */ PRINT|ALPHA|ALLOW, PRINT|ALPHA|ALLOW, PRINT|ALPHA, PRINT | ALPHA | ALLOW,
/* \]^ */ PRINT|ALPHA, PRINT|ALPHA, PRINT|ALPHA, /* GHI */ PRINT | ALPHA | ALLOW, PRINT | ALPHA | ALLOW,
/* _` */ PRINT|ALLOW,PRINT, PRINT | ALPHA | ALLOW,
/* abc */ PRINT|ALPHA|ALLOW, PRINT|ALPHA|ALLOW, PRINT|ALPHA|ALLOW, /* JKL */ PRINT | ALPHA | ALLOW, PRINT | ALPHA | ALLOW,
/* def */ PRINT|ALPHA|ALLOW, PRINT|ALPHA|ALLOW, PRINT|ALPHA|ALLOW, PRINT | ALPHA | ALLOW,
/* ghi */ PRINT|ALPHA|ALLOW, PRINT|ALPHA|ALLOW, PRINT|ALPHA|ALLOW, /* MNO */ PRINT | ALPHA | ALLOW, PRINT | ALPHA | ALLOW,
/* jkl */ PRINT|ALPHA|ALLOW, PRINT|ALPHA|ALLOW, PRINT|ALPHA|ALLOW, PRINT | ALPHA | ALLOW,
/* mno */ PRINT|ALPHA|ALLOW, PRINT|ALPHA|ALLOW, PRINT|ALPHA|ALLOW, /* PQR */ PRINT | ALPHA | ALLOW, PRINT | ALPHA | ALLOW,
/* pqr */ PRINT|ALPHA|ALLOW, PRINT|ALPHA|ALLOW, PRINT|ALPHA|ALLOW, PRINT | ALPHA | ALLOW,
/* stu */ PRINT|ALPHA|ALLOW, PRINT|ALPHA|ALLOW, PRINT|ALPHA|ALLOW, /* STU */ PRINT | ALPHA | ALLOW, PRINT | ALPHA | ALLOW,
/* vwx */ PRINT|ALPHA|ALLOW, PRINT|ALPHA|ALLOW, PRINT|ALPHA|ALLOW, PRINT | ALPHA | ALLOW,
/* yz{ */ PRINT|ALPHA|ALLOW, PRINT|ALPHA|ALLOW, PRINT|ALPHA, /* VWX */ PRINT | ALPHA | ALLOW, PRINT | ALPHA | ALLOW,
/* |}~ */ PRINT|ALPHA, PRINT|ALPHA, PRINT|ALPHA, PRINT | ALPHA | ALLOW,
/* del */ 0, /* YZ[ */ PRINT | ALPHA | ALLOW, PRINT | ALPHA | ALLOW, PRINT | ALPHA,
/* 80-8f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* \]^ */ PRINT | ALPHA, PRINT | ALPHA, PRINT | ALPHA,
/* 90-9f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* _` */ PRINT | ALLOW, PRINT,
/* a0-af */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* abc */ PRINT | ALPHA | ALLOW, PRINT | ALPHA | ALLOW,
/* b0-bf */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, PRINT | ALPHA | ALLOW,
/* c0-cf */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* def */ PRINT | ALPHA | ALLOW, PRINT | ALPHA | ALLOW,
/* d0-df */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, PRINT | ALPHA | ALLOW,
/* e0-ef */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* ghi */ PRINT | ALPHA | ALLOW, PRINT | ALPHA | ALLOW,
/* f0-ff */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 PRINT | ALPHA | ALLOW,
/* jkl */ PRINT | ALPHA | ALLOW, PRINT | ALPHA | ALLOW,
PRINT | ALPHA | ALLOW,
/* mno */ PRINT | ALPHA | ALLOW, PRINT | ALPHA | ALLOW,
PRINT | ALPHA | ALLOW,
/* pqr */ PRINT | ALPHA | ALLOW, PRINT | ALPHA | ALLOW,
PRINT | ALPHA | ALLOW,
/* stu */ PRINT | ALPHA | ALLOW, PRINT | ALPHA | ALLOW,
PRINT | ALPHA | ALLOW,
/* vwx */ PRINT | ALPHA | ALLOW, PRINT | ALPHA | ALLOW,
PRINT | ALPHA | ALLOW,
/* yz{ */ PRINT | ALPHA | ALLOW, PRINT | ALPHA | ALLOW, PRINT | ALPHA,
/* |}~ */ PRINT | ALPHA, PRINT | ALPHA, PRINT | ALPHA,
/* del */ 0,
/* 80-8f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 90-9f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* a0-af */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* b0-bf */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* c0-cf */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* d0-df */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* e0-ef */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* f0-ff */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
}; };
+69 -73
View File
@@ -1,4 +1,3 @@
/* $Id$ */
/* /*
* Copyright (c) 1996 Michael Shalayeff. * Copyright (c) 1996 Michael Shalayeff.
@@ -55,9 +54,8 @@ ID_CVS("$Id$");
* QUESTION: Replace this with SHA, which as generally received better * QUESTION: Replace this with SHA, which as generally received better
* reviews from the cryptographic community? * reviews from the cryptographic community?
*/ */
void void MD5Init(buf)
MD5Init(buf) u_int32_t buf[4];
u_int32_t buf[4];
{ {
buf[0] = 0x67452301; buf[0] = 0x67452301;
buf[1] = 0xefcdab89; buf[1] = 0xefcdab89;
@@ -81,89 +79,87 @@ MD5Init(buf)
* The core of the MD5 algorithm, this alters an existing MD5 hash to * The core of the MD5 algorithm, this alters an existing MD5 hash to
* reflect the addition of 16 longwords of new data. * reflect the addition of 16 longwords of new data.
*/ */
void void MD5Transform(buf, in)
MD5Transform(buf, in) u_int32_t buf[4];
u_int32_t buf[4];
u_int32_t in[16]; u_int32_t in[16];
{ {
u_int32_t a, b, c, d; u_int32_t a, b, c, d;
a = buf[0]; a = buf[0];
b = buf[1]; b = buf[1];
c = buf[2]; c = buf[2];
d = buf[3]; d = buf[3];
MD5STEP(F1, a, b, c, d, in[ 0]+0xd76aa478, 7); MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
MD5STEP(F1, d, a, b, c, in[ 1]+0xe8c7b756, 12); MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
MD5STEP(F1, c, d, a, b, in[ 2]+0x242070db, 17); MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
MD5STEP(F1, b, c, d, a, in[ 3]+0xc1bdceee, 22); MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
MD5STEP(F1, a, b, c, d, in[ 4]+0xf57c0faf, 7); MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
MD5STEP(F1, d, a, b, c, in[ 5]+0x4787c62a, 12); MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
MD5STEP(F1, c, d, a, b, in[ 6]+0xa8304613, 17); MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
MD5STEP(F1, b, c, d, a, in[ 7]+0xfd469501, 22); MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
MD5STEP(F1, a, b, c, d, in[ 8]+0x698098d8, 7); MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
MD5STEP(F1, d, a, b, c, in[ 9]+0x8b44f7af, 12); MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
MD5STEP(F1, c, d, a, b, in[10]+0xffff5bb1, 17); MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
MD5STEP(F1, b, c, d, a, in[11]+0x895cd7be, 22); MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
MD5STEP(F1, a, b, c, d, in[12]+0x6b901122, 7); MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
MD5STEP(F1, d, a, b, c, in[13]+0xfd987193, 12); MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
MD5STEP(F1, c, d, a, b, in[14]+0xa679438e, 17); MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
MD5STEP(F1, b, c, d, a, in[15]+0x49b40821, 22); MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
MD5STEP(F2, a, b, c, d, in[ 1]+0xf61e2562, 5); MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
MD5STEP(F2, d, a, b, c, in[ 6]+0xc040b340, 9); MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
MD5STEP(F2, c, d, a, b, in[11]+0x265e5a51, 14); MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
MD5STEP(F2, b, c, d, a, in[ 0]+0xe9b6c7aa, 20); MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
MD5STEP(F2, a, b, c, d, in[ 5]+0xd62f105d, 5); MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
MD5STEP(F2, d, a, b, c, in[10]+0x02441453, 9); MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
MD5STEP(F2, c, d, a, b, in[15]+0xd8a1e681, 14); MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
MD5STEP(F2, b, c, d, a, in[ 4]+0xe7d3fbc8, 20); MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
MD5STEP(F2, a, b, c, d, in[ 9]+0x21e1cde6, 5); MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
MD5STEP(F2, d, a, b, c, in[14]+0xc33707d6, 9); MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
MD5STEP(F2, c, d, a, b, in[ 3]+0xf4d50d87, 14); MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
MD5STEP(F2, b, c, d, a, in[ 8]+0x455a14ed, 20); MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
MD5STEP(F2, a, b, c, d, in[13]+0xa9e3e905, 5); MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
MD5STEP(F2, d, a, b, c, in[ 2]+0xfcefa3f8, 9); MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
MD5STEP(F2, c, d, a, b, in[ 7]+0x676f02d9, 14); MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
MD5STEP(F2, b, c, d, a, in[12]+0x8d2a4c8a, 20); MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
MD5STEP(F3, a, b, c, d, in[ 5]+0xfffa3942, 4); MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
MD5STEP(F3, d, a, b, c, in[ 8]+0x8771f681, 11); MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
MD5STEP(F3, c, d, a, b, in[11]+0x6d9d6122, 16); MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
MD5STEP(F3, b, c, d, a, in[14]+0xfde5380c, 23); MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
MD5STEP(F3, a, b, c, d, in[ 1]+0xa4beea44, 4); MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
MD5STEP(F3, d, a, b, c, in[ 4]+0x4bdecfa9, 11); MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
MD5STEP(F3, c, d, a, b, in[ 7]+0xf6bb4b60, 16); MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
MD5STEP(F3, b, c, d, a, in[10]+0xbebfbc70, 23); MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
MD5STEP(F3, a, b, c, d, in[13]+0x289b7ec6, 4); MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
MD5STEP(F3, d, a, b, c, in[ 0]+0xeaa127fa, 11); MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
MD5STEP(F3, c, d, a, b, in[ 3]+0xd4ef3085, 16); MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
MD5STEP(F3, b, c, d, a, in[ 6]+0x04881d05, 23); MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
MD5STEP(F3, a, b, c, d, in[ 9]+0xd9d4d039, 4); MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
MD5STEP(F3, d, a, b, c, in[12]+0xe6db99e5, 11); MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
MD5STEP(F3, c, d, a, b, in[15]+0x1fa27cf8, 16); MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
MD5STEP(F3, b, c, d, a, in[ 2]+0xc4ac5665, 23); MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
MD5STEP(F4, a, b, c, d, in[ 0]+0xf4292244, 6); MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
MD5STEP(F4, d, a, b, c, in[ 7]+0x432aff97, 10); MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
MD5STEP(F4, c, d, a, b, in[14]+0xab9423a7, 15); MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
MD5STEP(F4, b, c, d, a, in[ 5]+0xfc93a039, 21); MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
MD5STEP(F4, a, b, c, d, in[12]+0x655b59c3, 6); MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
MD5STEP(F4, d, a, b, c, in[ 3]+0x8f0ccc92, 10); MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
MD5STEP(F4, c, d, a, b, in[10]+0xffeff47d, 15); MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
MD5STEP(F4, b, c, d, a, in[ 1]+0x85845dd1, 21); MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
MD5STEP(F4, a, b, c, d, in[ 8]+0x6fa87e4f, 6); MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
MD5STEP(F4, d, a, b, c, in[15]+0xfe2ce6e0, 10); MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
MD5STEP(F4, c, d, a, b, in[ 6]+0xa3014314, 15); MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
MD5STEP(F4, b, c, d, a, in[13]+0x4e0811a1, 21); MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
MD5STEP(F4, a, b, c, d, in[ 4]+0xf7537e82, 6); MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
MD5STEP(F4, d, a, b, c, in[11]+0xbd3af235, 10); MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
MD5STEP(F4, c, d, a, b, in[ 2]+0x2ad7d2bb, 15); MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
MD5STEP(F4, b, c, d, a, in[ 9]+0xeb86d391, 21); MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
buf[0] += a; buf[0] += a;
buf[1] += b; buf[1] += b;
buf[2] += c; buf[2] += c;
buf[3] += d; buf[3] += d;
} }
+45 -44
View File
@@ -1,5 +1,5 @@
/************************************************************************ /************************************************************************
* IRC - Internet Relay Chat, common/packet.c * Unreal Internet Relay Chat Daemon, src/packet.c
* Copyright (C) 1990 Jarkko Oikarinen and * Copyright (C) 1990 Jarkko Oikarinen and
* University of Oulu, Computing Center * University of Oulu, Computing Center
* *
@@ -25,7 +25,8 @@
#include "h.h" #include "h.h"
ID_CVS("$Id$"); ID_CVS("$Id$");
ID_Copyright("(C) 1988 University of Oulu, Computing Center and Jarkko Oikarinen"); ID_Copyright
("(C) 1988 University of Oulu, Computing Center and Jarkko Oikarinen");
ID_Notes("2.12 1/30/94"); ID_Notes("2.12 1/30/94");
/* /*
* inittoken * inittoken
@@ -33,22 +34,22 @@ ID_Notes("2.12 1/30/94");
* call them msgmap's. Called in main() with other inits. * call them msgmap's. Called in main() with other inits.
* Yes, I know this is not the right module, but I said I cheat ;) * Yes, I know this is not the right module, but I said I cheat ;)
*/ */
void inittoken(void) void inittoken(void)
{ {
Reg1 int loopy; int loopy;
Reg2 int final; int final;
/* Find the zero-entry */ /* Find the zero-entry */
for (final = 0; msgtab[final].cmd; final++) for (final = 0; msgtab[final].cmd; final++)
; ;
/* Point all entries to it */ /* Point all entries to it */
for (loopy = 0; loopy<256; loopy++) for (loopy = 0; loopy < 256; loopy++)
msgmap[loopy] = &msgtab[final]; msgmap[loopy] = &msgtab[final];
/* Build references to existing commands */ /* Build references to existing commands */
for (loopy = 0; msgtab[loopy].cmd; loopy++) for (loopy = 0; msgtab[loopy].cmd; loopy++)
msgmap[msgtab[loopy].token[0]] = &msgtab[loopy]; msgmap[msgtab[loopy].token[0]] = &msgtab[loopy];
} }
/* /*
** dopacket ** dopacket
** cptr - pointer to client structure for which the buffer data ** cptr - pointer to client structure for which the buffer data
@@ -61,42 +62,42 @@ void inittoken(void)
** with cptr of "local" variation, which contains all the ** with cptr of "local" variation, which contains all the
** necessary fields (buffer etc..) ** necessary fields (buffer etc..)
*/ */
int dopacket(cptr, buffer, length) int dopacket(cptr, buffer, length)
Reg3 aClient *cptr; aClient *cptr;
char *buffer; char *buffer;
Reg4 int length; int length;
{ {
register char *ch1; char *ch1;
register char *ch2; char *ch2;
aClient *acpt = cptr->acpt; aClient *acpt = cptr->acpt;
me.receiveB += length; /* Update bytes received */ me.receiveB += length; /* Update bytes received */
cptr->receiveB += length; cptr->receiveB += length;
if (cptr->receiveB > 1023) if (cptr->receiveB > 1023)
{ {
cptr->receiveK += (cptr->receiveB >> 10); cptr->receiveK += (cptr->receiveB >> 10);
cptr->receiveB &= 0x03ff; /* 2^10 = 1024, 3ff = 1023 */ cptr->receiveB &= 0x03ff; /* 2^10 = 1024, 3ff = 1023 */
} }
if (acpt != &me) if (acpt != &me)
{ {
acpt->receiveB += length; acpt->receiveB += length;
if (acpt->receiveB > 1023) if (acpt->receiveB > 1023)
{ {
acpt->receiveK += (acpt->receiveB >> 10); acpt->receiveK += (acpt->receiveB >> 10);
acpt->receiveB &= 0x03ff; acpt->receiveB &= 0x03ff;
} }
} }
else if (me.receiveB > 1023) else if (me.receiveB > 1023)
{ {
me.receiveK += (me.receiveB >> 10); me.receiveK += (me.receiveB >> 10);
me.receiveB &= 0x03ff; me.receiveB &= 0x03ff;
} }
ch1 = cptr->buffer + cptr->count; ch1 = cptr->buffer + cptr->count;
ch2 = buffer; ch2 = buffer;
while (--length >= 0) while (--length >= 0)
{ {
register char g=(*ch1 = *ch2++); char g = (*ch1 = *ch2++);
/* /*
* Yuck. Stuck. To make sure we stay backward compatible, * Yuck. Stuck. To make sure we stay backward compatible,
* we must assume that either CR or LF terminates the message * we must assume that either CR or LF terminates the message
@@ -104,38 +105,38 @@ Reg4 int length;
* of messages, backward compatibility is lost and major * of messages, backward compatibility is lost and major
* problems will arise. - Avalon * problems will arise. - Avalon
*/ */
if (g<'\16' && (g == '\n' || g == '\r')) if (g < '\16' && (g == '\n' || g == '\r'))
{ {
if (ch1 == cptr->buffer) if (ch1 == cptr->buffer)
continue; /* Skip extra LF/CR's */ continue; /* Skip extra LF/CR's */
*ch1 = '\0'; *ch1 = '\0';
me.receiveM += 1; /* Update messages received */ me.receiveM += 1; /* Update messages received */
cptr->receiveM += 1; cptr->receiveM += 1;
if (cptr->acpt != &me) if (cptr->acpt != &me)
cptr->acpt->receiveM += 1; cptr->acpt->receiveM += 1;
cptr->count = 0; /* ...just in case parse returns with cptr->count = 0; /* ...just in case parse returns with
** FLUSH_BUFFER without removing the ** FLUSH_BUFFER without removing the
** structure pointed by cptr... --msa ** structure pointed by cptr... --msa
*/ */
if (parse(cptr, cptr->buffer, ch1, msgtab) == if (parse(cptr, cptr->buffer, ch1, msgtab) ==
FLUSH_BUFFER) FLUSH_BUFFER)
/* /*
** FLUSH_BUFFER means actually that cptr ** FLUSH_BUFFER means actually that cptr
** structure *does* not exist anymore!!! --msa ** structure *does* not exist anymore!!! --msa
*/ */
return FLUSH_BUFFER; return FLUSH_BUFFER;
/* /*
** Socket is dead so exit (which always returns with ** Socket is dead so exit (which always returns with
** FLUSH_BUFFER here). - avalon ** FLUSH_BUFFER here). - avalon
*/ */
if (cptr->flags & FLAGS_DEADSOCKET) if (cptr->flags & FLAGS_DEADSOCKET)
return exit_client(cptr, cptr, &me, return exit_client(cptr, cptr, &me,
"Dead Socket"); "Dead Socket");
ch1 = cptr->buffer; ch1 = cptr->buffer;
} }
else if (ch1 < cptr->buffer + (sizeof(cptr->buffer)-1)) else if (ch1 < cptr->buffer + (sizeof(cptr->buffer) - 1))
ch1++; /* There is always room for the null */ ch1++; /* There is always room for the null */
} }
cptr->count = ch1 - cptr->buffer; cptr->count = ch1 - cptr->buffer;
return 0; return 0;
} }
+377 -236
View File
@@ -1,5 +1,5 @@
/************************************************************************ /************************************************************************
* IRC - Internet Relay Chat, common/parse.c * Unreal Internet Relay Chat Daemon, src/parse.c
* Copyright (C) 1990 Jarkko Oikarinen and * Copyright (C) 1990 Jarkko Oikarinen and
* University of Oulu, Computing Center * University of Oulu, Computing Center
* *
@@ -23,18 +23,20 @@
*/ */
#ifndef lint #ifndef lint
static char sccsid[] = "@(#)parse.c 2.33 1/30/94 (C) 1988 University of Oulu, \ static char sccsid[] =
"@(#)parse.c 2.33 1/30/94 (C) 1988 University of Oulu, \
Computing Center and Jarkko Oikarinen"; Computing Center and Jarkko Oikarinen";
#endif #endif
#include "struct.h" #include "struct.h"
#include "common.h" #include "common.h"
ID_CVS("$Id$"); ID_CVS("$Id$");
ID_Copyright("(C) 1988 University of Oulu, Computing Center and Jarkko Oikarinen"); ID_Copyright
("(C) 1988 University of Oulu, Computing Center and Jarkko Oikarinen");
ID_Notes("2.33 1/30/94"); ID_Notes("2.33 1/30/94");
#undef RAWDEBUG #undef RAWDEBUG
char backupbuf[8192]; char backupbuf[8192];
#define MSGTAB #define MSGTAB
#include "msg.h" #include "msg.h"
@@ -46,11 +48,12 @@ char backupbuf[8192];
/* /*
* NOTE: parse() should not be called recursively by other functions! * NOTE: parse() should not be called recursively by other functions!
*/ */
static char *para[MAXPARA+1]; static char *para[MAXPARA + 1];
static char sender[HOSTLEN+1]; static char sender[HOSTLEN + 1];
static int cancel_clients PROTO((aClient *, aClient *, char *)); static int cancel_clients PROTO((aClient *, aClient *, char *));
static void remove_unknown PROTO((aClient *, char *)); static void remove_unknown PROTO((aClient *, char *));
static char unknownserver[] = "Unknown.Server";
/* /*
** Find a client (server or user) by name. ** Find a client (server or user) by name.
** **
@@ -60,24 +63,34 @@ static void remove_unknown PROTO((aClient *, char *));
** string and the search is the for server and user. ** string and the search is the for server and user.
*/ */
aClient *find_client(name, cptr) aClient *find_client(name, cptr)
char *name; char *name;
Reg1 aClient *cptr; aClient *cptr;
{ {
char *newname;
if (name) if (name)
{
if (*name == '@')
{
newname = name;
name = find_by_aln(name + 1);
if (!name)
name = newname;
}
cptr = hash_find_client(name, cptr); cptr = hash_find_client(name, cptr);
}
return cptr; return cptr;
} }
aClient *find_nickserv(name, cptr) aClient *find_nickserv(name, cptr)
char *name; char *name;
Reg1 aClient *cptr; aClient *cptr;
{ {
if (name) if (name)
cptr = hash_find_nickserver(name, cptr); cptr = hash_find_nickserver(name, cptr);
return cptr; return cptr;
} }
/* /*
@@ -94,19 +107,61 @@ Reg1 aClient *cptr;
** string. ** string.
*/ */
aClient *find_server(name, cptr) aClient *find_server(name, cptr)
char *name; char *name;
Reg1 aClient *cptr; aClient *cptr;
{ {
char *newname;
if (name) if (name)
{
if (*name == '@')
{
newname = name;
name = find_by_aln(name + 1);
if (!name)
name = newname;
}
cptr = hash_find_server(name, cptr); cptr = hash_find_server(name, cptr);
}
return cptr;
}
aClient *find_serveraln(name, cptr)
char *name;
aClient *cptr;
{
char *newname;
if (name)
{
if (*name == '@')
{
newname = name;
name = find_by_aln(name + 1);
if (!name)
name = newname;
}
if (strlen(name) < 3)
{
newname = name;
#ifdef DEVELOP
// sendto_ops("Trying to find %s", name);
#endif
name = find_by_aln(name);
if (!name)
name = newname;
}
cptr = hash_find_client(name, cptr);
#ifdef DEVELOP
// if (cptr) sendto_ops("Found it ! (%s)", cptr->name);
#endif
}
return cptr; return cptr;
} }
aClient *find_name(name, cptr) aClient *find_name(name, cptr)
char *name; char *name;
aClient *cptr; aClient *cptr;
{ {
Reg1 aClient *c2ptr = cptr; aClient *c2ptr = cptr;
if (!collapse(name)) if (!collapse(name))
return c2ptr; return c2ptr;
@@ -116,15 +171,15 @@ aClient *cptr;
if (!index(name, '*')) if (!index(name, '*'))
return c2ptr; return c2ptr;
for (c2ptr = client; c2ptr; c2ptr = c2ptr->next) for (c2ptr = client; c2ptr; c2ptr = c2ptr->next)
{ {
if (!IsServer(c2ptr) && !IsMe(c2ptr)) if (!IsServer(c2ptr) && !IsMe(c2ptr))
continue; continue;
if (match(name, c2ptr->name) == 0) if (match(name, c2ptr->name) == 0)
break; break;
if (index(c2ptr->name, '*')) if (index(c2ptr->name, '*'))
if (match(c2ptr->name, name) == 0) if (match(c2ptr->name, name) == 0)
break; break;
} }
return (c2ptr ? c2ptr : cptr); return (c2ptr ? c2ptr : cptr);
} }
@@ -132,10 +187,10 @@ aClient *cptr;
** Find person by (nick)name. ** Find person by (nick)name.
*/ */
aClient *find_person(name, cptr) aClient *find_person(name, cptr)
char *name; char *name;
aClient *cptr; aClient *cptr;
{ {
Reg1 aClient *c2ptr = cptr; aClient *c2ptr = cptr;
c2ptr = find_client(name, c2ptr); c2ptr = find_client(name, c2ptr);
@@ -143,66 +198,116 @@ aClient *cptr;
return c2ptr; return c2ptr;
else else
return cptr; return cptr;
} }
int alnprefix = 0;
void ban_flooder(aClient *cptr)
{
char hostip[128], mo[100], mo2[100];
char *tkllayer[9] = {
me.name, /*0 server.name */
"+", /*1 +|- */
"z", /*2 G */
"*", /*3 user */
NULL, /*4 host */
NULL,
NULL, /*6 expire_at */
NULL, /*7 set_at */
NULL /*8 reason */
};
strcpy(hostip, (char *)inetntoa((char *) &cptr->ip));
exit_client(cptr, cptr, &me, "Flooding");
tkllayer[4] = hostip;
tkllayer[5] = me.name;
ircsprintf(mo, "%li", 600 + TStime());
ircsprintf(mo2, "%li", TStime());
tkllayer[6] = mo;
tkllayer[7] = mo2;
tkllayer[8] = "Flood from unknown connection";
m_tkl(&me, &me, 9, tkllayer);
return;
}
/* /*
* parse a buffer. * parse a buffer.
* *
* NOTE: parse() should not be called recusively by any other fucntions! * NOTE: parse() should not be called recusively by any other fucntions!
*/ */
int parse(cptr, buffer, bufend, mptr) int parse(cptr, buffer, bufend, mptr)
aClient *cptr; aClient *cptr;
char *buffer, *bufend; char *buffer, *bufend;
struct Message *mptr; struct Message *mptr;
{ {
Reg1 aClient *from = cptr; aClient *from = cptr;
Reg2 char *ch, *s; char *ch, *s, *p;
Reg3 int len, i, numeric, paramcount, noprefix = 0; int len, i, numeric, paramcount, noprefix = 0;
Reg4 int token,mfound; int token, mfound;
#ifdef DEBUGMODE #ifdef DEBUGMODE
time_t then, ticks; time_t then, ticks;
int retval; int retval;
#endif #endif
struct Message *bmptr; struct Message *bmptr;
Debug((DEBUG_ERROR,"Parsing: %s (from %s)", buffer,(*cptr->name ? cptr->name : "*"))); Debug((DEBUG_ERROR, "Parsing: %s (from %s)", buffer,
(*cptr->name ? cptr->name : "*")));
if (IsDead(cptr)) if (IsDead(cptr))
return 0; return 0;
#ifdef RAWDEBUG #ifdef RAWDEBUG
sendto_ops("Debug: parse(): %s", buffer); sendto_ops("Debug: parse(): %s", buffer);
#endif #endif
if ((cptr->receiveK >= 4) && IsUnknown(cptr))
{
sendto_realops("Flood from unknown connection %s detected", cptr->sockhost);
ban_flooder(cptr);
return 0;
}
/* this call is a bit obsolete? - takes up CPU*/
backupbuf[0] = '\0'; backupbuf[0] = '\0';
strcpy(backupbuf, buffer); strcpy(backupbuf, buffer);
s = sender; s = sender;
*s = '\0'; *s = '\0';
alnprefix = 0;
for (ch = buffer; *ch == ' '; ch++) for (ch = buffer; *ch == ' '; ch++)
; ;
para[0] = from->name; para[0] = from->name;
if (*ch == ':') if (*ch == ':' || *ch == '@')
{ {
if (*ch == '@')
alnprefix = 1;
/* /*
** Copy the prefix to 'sender' assuming it terminates ** Copy the prefix to 'sender' assuming it terminates
** with SPACE (or NULL, which is an error, though). ** with SPACE (or NULL, which is an error, though).
*/ */
for (++ch, i = 0; *ch && *ch != ' '; ++ch ) for (++ch, i = 0; *ch && *ch != ' '; ++ch)
if (s < (sender + sizeof(sender)-1)) if (s < (sender + sizeof(sender) - 1))
*s++ = *ch; /* leave room for NULL */ *s++ = *ch; /* leave room for NULL */
*s = '\0'; *s = '\0';
/* /*
** Actually, only messages coming from servers can have ** Actually, only messages coming from servers can have
** the prefix--prefix silently ignored, if coming from ** the prefix--prefix silently ignored, if coming from
** a user client... ** a user client...
** **
** ...sigh, the current release "v2.2PL1" generates also ** ...sigh, the current release "v2.2PL1" generates also
** null prefixes, at least to NOTIFY messages (e.g. it ** null prefixes, at least to NOTIFY messages (e.g. it
** puts "sptr->nickname" as prefix from server structures ** puts "sptr->nickname" as prefix from server structures
** where it's null--the following will handle this case ** where it's null--the following will handle this case
** as "no prefix" at all --msa (": NOTICE nick ...") ** as "no prefix" at all --msa (": NOTICE nick ...")
*/ */
if (*sender && IsServer(cptr)) if (*sender && IsServer(cptr))
{ {
from = find_client(sender, (aClient *) NULL); if ((strlen(sender) < 3) && alnprefix)
{
p = find_by_aln(sender);
if (p)
strcpy(sender, p);
}
from = find_client(sender, (aClient *)NULL);
if (!from || match(from->name, sender)) if (!from || match(from->name, sender))
from = find_server(sender, (aClient *)NULL); from = find_server(sender, (aClient *)NULL);
else if (!from && index(sender, '@')) else if (!from && index(sender, '@'))
@@ -217,55 +322,55 @@ struct Message *mptr;
* prefix just wasn't there...) --msa * prefix just wasn't there...) --msa
*/ */
if (!from) if (!from)
{ {
Debug((DEBUG_ERROR, Debug((DEBUG_ERROR,
"Unknown prefix (%s)(%s) from (%s)", "Unknown prefix (%s)(%s) from (%s)",
sender, buffer, cptr->name)); sender, buffer, cptr->name));
ircstp->is_unpf++; ircstp->is_unpf++;
remove_unknown(cptr, sender); remove_unknown(cptr, sender);
return -1; return -1;
} }
if (from->from != cptr) if (from->from != cptr)
{ {
ircstp->is_wrdi++; ircstp->is_wrdi++;
Debug((DEBUG_ERROR, Debug((DEBUG_ERROR,
"Message (%s) coming from (%s)", "Message (%s) coming from (%s)",
buffer, cptr->name)); buffer, cptr->name));
return cancel_clients(cptr, from, ch); return cancel_clients(cptr, from, ch);
} }
} }
while (*ch == ' ') while (*ch == ' ')
ch++; ch++;
} }
else else
noprefix = 1; noprefix = 1;
if (*ch == '\0') if (*ch == '\0')
{ {
ircstp->is_empt++; ircstp->is_empt++;
Debug((DEBUG_NOTICE, "Empty message from host %s:%s", Debug((DEBUG_NOTICE, "Empty message from host %s:%s",
cptr->name, from->name)); cptr->name, from->name));
return(-1); return (-1);
} }
/* /*
** Extract the command code from the packet. Point s to the end ** Extract the command code from the packet. Point s to the end
** of the command code and calculate the length using pointer ** of the command code and calculate the length using pointer
** arithmetic. Note: only need length for numerics and *all* ** arithmetic. Note: only need length for numerics and *all*
** numerics must have paramters and thus a space after the command ** numerics must have paramters and thus a space after the command
** code. -avalon ** code. -avalon
*/ */
s = (char *)index(ch, ' '); /* s -> End of the command code */ s = (char *)index(ch, ' '); /* s -> End of the command code */
len = (s) ? (s - ch) : 0; len = (s) ? (s - ch) : 0;
if (len == 3 && if (len == 3 &&
isdigit(*ch) && isdigit(*(ch + 1)) && isdigit(*(ch + 2))) isdigit(*ch) && isdigit(*(ch + 1)) && isdigit(*(ch + 2)))
{ {
mptr = NULL; mptr = NULL;
numeric = (*ch - '0') * 100 + (*(ch + 1) - '0') * 10 numeric = (*ch - '0') * 100 + (*(ch + 1) - '0') * 10
+ (*(ch + 2) - '0'); + (*(ch + 2) - '0');
paramcount = MAXPARA; paramcount = MAXPARA;
ircstp->is_num++; ircstp->is_num++;
} }
else else
{ {
if (s) if (s)
*s++ = '\0'; *s++ = '\0';
@@ -279,118 +384,139 @@ struct Message *mptr;
token = 0; token = 0;
} }
bmptr = mptr; bmptr = mptr;
/* run a fast token search through if token */ /* run a fast token search through if token */
mfound = 0; mfound = 0;
if (token == 1) if (token == 1)
{ {
for (; mptr->cmd; mptr++) for (; mptr->cmd; mptr++)
{ {
if (strcmp(mptr->token, ch)==0) if (strcmp(mptr->token, ch) == 0)
{ {
mfound = 1; mfound = 1;
break; break;
} }
} }
} }
/* no token match .. grr :P */ /* no token match .. grr :P */
if (mfound == 0) if (mfound == 0)
{ {
mptr = bmptr; mptr = bmptr;
for (; mptr->cmd; mptr++) for (; mptr->cmd; mptr++)
{ {
if (mycmp(mptr->cmd, ch)==0) if (mycmp(mptr->cmd, ch) == 0)
break; break;
} }
} }
/* if (ch[1] == '\0' && IsToken(cptr))
mptr = msgmap[(u_char)*ch];
else
*/
if (!mptr->cmd) if (!mptr->cmd)
{ {
/* /*
** Note: Give error message *only* to recognized ** Note: Give error message *only* to recognized
** persons. It's a nightmare situation to have ** persons. It's a nightmare situation to have
** two programs sending "Unknown command"'s or ** two programs sending "Unknown command"'s or
** equivalent to each other at full blast.... ** equivalent to each other at full blast....
** If it has got to person state, it at least ** If it has got to person state, it at least
** seems to be well behaving. Perhaps this message ** seems to be well behaving. Perhaps this message
** should never be generated, though... --msa ** should never be generated, though... --msa
** Hm, when is the buffer empty -- if a command ** Hm, when is the buffer empty -- if a command
** code has been found ?? -Armin ** code has been found ?? -Armin
*/ */
if (buffer[0] != '\0') if (buffer[0] != '\0')
{ {
if (IsPerson(from)) if (IsPerson(from))
sendto_one(from, sendto_one(from,
":%s %d %s %s :Unknown command", ":%s %d %s %s :Unknown command",
me.name, ERR_UNKNOWNCOMMAND, me.name, ERR_UNKNOWNCOMMAND,
from->name, ch); from->name, ch);
Debug((DEBUG_ERROR,"Unknown (%s) from %s", Debug((DEBUG_ERROR, "Unknown (%s) from %s",
ch, get_client_name(cptr, TRUE))); ch, get_client_name(cptr, TRUE)));
} }
ircstp->is_unco++; ircstp->is_unco++;
return(-1); return (-1);
} }
paramcount = mptr->parameters; paramcount = mptr->parameters;
i = bufend - ch; /* Is this right? -Donwulff */ i = bufend - ch; /* Is this right? -Donwulff */
mptr->bytes += i; mptr->bytes += i;
if ((mptr->flags & 1) && !(IsServer(cptr) || IsService(cptr))) if ((mptr->flags & 1) && !(IsServer(cptr) || IsOper(cptr)))
cptr->since += (2 + i / 120); cptr->since += (2 + i / 90);
/* Allow only 1 msg per 2 seconds /* Allow only 1 msg per 2 seconds
* (on average) to prevent dumping. * (on average) to prevent dumping.
* to keep the response rate up, * to keep the response rate up,
* bursts of up to 5 msgs are allowed * bursts of up to 5 msgs are allowed
* -SRB * -SRB
*/ *
} * Not applying to opers now
* -techie
*
* 1 msg per 1.5 second i'd say now
*/
}
/* /*
** Must the following loop really be so devious? On ** Must the following loop really be so devious? On
** surface it splits the message to parameters from ** surface it splits the message to parameters from
** blank spaces. But, if paramcount has been reached, ** blank spaces. But, if paramcount has been reached,
** the rest of the message goes into this last parameter ** the rest of the message goes into this last parameter
** (about same effect as ":" has...) --msa ** (about same effect as ":" has...) --msa
*/ */
/* Note initially true: s==NULL || *(s-1) == '\0' !! */ /* Note initially true: s==NULL || *(s-1) == '\0' !! */
i = 0; i = 0;
if (s) if (s)
{ {
if (paramcount > MAXPARA) if (paramcount > MAXPARA)
paramcount = MAXPARA; paramcount = MAXPARA;
for (;;) for (;;)
{ {
/* /*
** Never "FRANCE " again!! ;-) Clean ** Never "FRANCE " again!! ;-) Clean
** out *all* blanks.. --msa ** out *all* blanks.. --msa
*/ */
while (*s == ' ') while (*s == ' ')
*s++ = '\0'; *s++ = '\0';
if (*s == '\0') if (*s == '\0')
break; break;
if (*s == ':') if (*s == ':')
{ {
/* /*
** The rest is single parameter--can ** The rest is single parameter--can
** include blanks also. ** include blanks also.
*/ */
para[++i] = s + 1; para[++i] = s + 1;
break; break;
} }
para[++i] = s; para[++i] = s;
if (i >= paramcount) if (i >= paramcount)
break; break;
for (; *s != ' ' && *s; s++) for (; *s != ' ' && *s; s++)
; ;
} }
} }
para[++i] = NULL; para[++i] = NULL;
if (mptr == NULL) if (mptr == NULL)
return (do_numeric(numeric, cptr, from, i, para)); return (do_numeric(numeric, cptr, from, i, para));
/* now, lets make sure they use a legit commnd... -nikb */
/* There is code in s_serv.c for ADMIN and VERSION and
* in s_user.c for NOTICE to limit commands by
* unregistered users. -Studded */
if ((!IsRegistered(cptr)) &&
(((mptr->func != m_user) && (mptr->func != m_nick) &&
(mptr->func != m_server) && (mptr->func != m_pong) &&
(mptr->func != m_pass) && (mptr->func != m_quit) &&
(mptr->func != m_protoctl) && (mptr->func != m_error) &&
(mptr->func != m_admin) && (mptr->func != m_version)
#ifdef NOSPOOF
&& (mptr->func != m_notice)
#endif
)))
{
sendto_one(from, ":%s %d %s :You have not registered",
me.name, ERR_NOTREGISTERED, ch);
return -1;
}
mptr->count++; mptr->count++;
if (IsRegisteredUser(cptr) && if (IsRegisteredUser(cptr) &&
#ifdef IDLE_FROM_MSG #ifdef IDLE_FROM_MSG
@@ -398,25 +524,16 @@ struct Message *mptr;
#else #else
mptr->func != m_ping && mptr->func != m_pong) mptr->func != m_ping && mptr->func != m_pong)
#endif #endif
from->user->last = TStime(); from->user->last = TStime();
/* Lame protocol 4 stuff... this if can be removed when all are 2.9 */
if (noprefix && IsServer(cptr) && i >= 2 && mptr->func == m_squit &&
(!(from = find_server(para[1], (aClient *)NULL)) ||
from->from != cptr))
{
Debug((DEBUG_DEBUG,"Ignoring protocol 4 \"%s %s %s ...\"",
para[0], para[1], para[2]));
return 0;
}
#ifndef DEBUGMODE #ifndef DEBUGMODE
return (*mptr->func)(cptr, from, i, para); return (*mptr->func) (cptr, from, i, para);
#else #else
then = clock(); then = clock();
retval = (*mptr->func)(cptr, from, i, para); retval = (*mptr->func) (cptr, from, i, para);
if (retval != FLUSH_BUFFER) { if (retval != FLUSH_BUFFER)
ticks = (clock()-then); {
ticks = (clock() - then);
if (IsServer(cptr)) if (IsServer(cptr))
mptr->rticks += ticks; mptr->rticks += ticks;
else else
@@ -426,40 +543,59 @@ struct Message *mptr;
return retval; return retval;
#endif #endif
} }
/* /*
* field breakup for ircd.conf file. * field breakup for ircd.conf file.
*/ */
char *getfield(newline) char *getfield(newline)
char *newline; char *newline;
{ {
static char *line = NULL; static char *line = NULL;
char *end, *field; char *end, *field, *x;
if (newline) if (newline)
line = newline; line = newline;
if (line == NULL) if (line == NULL)
return(NULL); return (NULL);
field = line; field = line;
if ((end = (char *)index(line,':')) == NULL) if (*field == '"')
{ {
field++;
x = index(field, '"');
if (!x)
{
sendto_ops("FATAL: Misplaced \" in ircd.conf line!");
s_die();
}
*x = '\0';
x++;
if (*x == '\n')
line = NULL;
else
line = x;
end = x;
line++;
goto end1;
}
if ((end = (char *)index(line, ':')) == NULL)
{
line = NULL; line = NULL;
if ((end = (char *)index(field,'\n')) == NULL) if ((end = (char *)index(field, '\n')) == NULL)
end = field + strlen(field); end = field + strlen(field);
} }
else else
line = end + 1; line = end + 1;
end1:
*end = '\0'; *end = '\0';
return(field); return (field);
} }
static int cancel_clients(cptr, sptr, cmd) static int cancel_clients(cptr, sptr, cmd)
aClient *cptr, *sptr; aClient *cptr, *sptr;
char *cmd; char *cmd;
{ {
char *cmdpriv;
/* /*
* kill all possible points that are causing confusion here, * kill all possible points that are causing confusion here,
* I'm not sure I've got this all right... * I'm not sure I've got this all right...
@@ -469,16 +605,16 @@ char *cmd;
*/ */
/* This little bit of code allowed paswords to nickserv to be /* This little bit of code allowed paswords to nickserv to be
* seen. A definite no-no. --Russell * seen. A definite no-no. --Russell
sendto_ops("Message (%s) for %s[%s!%s@%s] from %s", cmd, sendto_ops("Message (%s) for %s[%s!%s@%s] from %s", cmd,
sptr->name, sptr->from->name, sptr->from->username, sptr->name, sptr->from->name, sptr->from->username,
sptr->from->sockhost, get_client_name(cptr, TRUE));*/ sptr->from->sockhost, get_client_name(cptr, TRUE));*/
/* /*
* Incorrect prefix for a server from some connection. If it is a * Incorrect prefix for a server from some connection. If it is a
* client trying to be annoying, just QUIT them, if it is a server * client trying to be annoying, just QUIT them, if it is a server
* then the same deal. * then the same deal.
*/ */
if (IsServer(sptr) || IsMe(sptr)) if (IsServer(sptr) || IsMe(sptr))
{ {
/* /*
* First go at tracking down what really causes the * First go at tracking down what really causes the
* dreaded Fake Direction error. It should not be possible * dreaded Fake Direction error. It should not be possible
@@ -504,73 +640,73 @@ char *cmd;
* just completely ignore them. Needs to be modified to * just completely ignore them. Needs to be modified to
* send these messages to a special oper channel. -Cabal95 * send these messages to a special oper channel. -Cabal95
* *
aClient *from; aClient *from;
char *fromname=NULL, *sptrname=NULL, *cptrname=NULL, *s; char *fromname=NULL, *sptrname=NULL, *cptrname=NULL, *s;
while (*cmd == ' ') while (*cmd == ' ')
cmd++; cmd++;
if (s = index(cmd, ' ')) if (s = index(cmd, ' '))
*s++ = '\0'; *s++ = '\0';
if (!strcasecmp(cmd, "PRIVMSG") || if (!strcasecmp(cmd, "PRIVMSG") ||
!strcasecmp(cmd, "NOTICE") || !strcasecmp(cmd, "NOTICE") ||
!strcasecmp(cmd, "PASS")) !strcasecmp(cmd, "PASS"))
s = NULL; s = NULL;
if (sptr && sptr->name) if (sptr && sptr->name)
sptrname = sptr->name; sptrname = sptr->name;
if (cptr && cptr->name) if (cptr && cptr->name)
cptrname = cptr->name; cptrname = cptr->name;
if (sptr && sptr->from && sptr->from->name) if (sptr && sptr->from && sptr->from->name)
fromname = sptr->from->name; fromname = sptr->from->name;
sendto_serv_butone(NULL, ":%s GLOBOPS :" sendto_serv_butone(NULL, ":%s GLOBOPS :"
"Fake Direction: Message[%s %s] from %s via %s " "Fake Direction: Message[%s %s] from %s via %s "
"instead of %s (Tell Cabal95)", me.name, cmd, "instead of %s (Tell Cabal95)", me.name, cmd,
(s ? s : ""), (s ? s : ""),
(sptr->name!=NULL)?sptr->name:"<unknown>", (sptr->name!=NULL)?sptr->name:"<unknown>",
(cptr->name!=NULL)?cptr->name:"<unknown>", (cptr->name!=NULL)?cptr->name:"<unknown>",
(fromname!=NULL)?fromname:"<unknown>"); (fromname!=NULL)?fromname:"<unknown>");
sendto_ops( sendto_ops(
"Fake Direction: Message[%s %s] from %s via %s " "Fake Direction: Message[%s %s] from %s via %s "
"instead of %s (Tell Cabal95)", cmd, "instead of %s (Tell Cabal95)", cmd,
(s ? s : ""), (s ? s : ""),
(sptr->name!=NULL)?sptr->name:"<unknown>", (sptr->name!=NULL)?sptr->name:"<unknown>",
(cptr->name!=NULL)?cptr->name:"<unknown>", (cptr->name!=NULL)?cptr->name:"<unknown>",
(fromname!=NULL)?fromname:"<unknown>"); (fromname!=NULL)?fromname:"<unknown>");
/* /*
* We don't drop the server anymore. Just ignore * We don't drop the server anymore. Just ignore
* the message and go about your business. And hope * the message and go about your business. And hope
* we don't get flooded. :-) -Cabal95 * we don't get flooded. :-) -Cabal95
sendto_ops("Dropping server %s", cptr->name); sendto_ops("Dropping server %s", cptr->name);
return exit_client(cptr, cptr, &me, "Fake Direction"); return exit_client(cptr, cptr, &me, "Fake Direction");
*/ */
return 0; return 0;
} }
/* /*
* Ok, someone is trying to impose as a client and things are * Ok, someone is trying to impose as a client and things are
* confused. If we got the wrong prefix from a server, send out a * confused. If we got the wrong prefix from a server, send out a
* kill, else just exit the lame client. * kill, else just exit the lame client.
*/ */
if (IsServer(cptr)) if (IsServer(cptr))
{ {
/* /*
** It is NOT necessary to send a KILL here... ** It is NOT necessary to send a KILL here...
** We come here when a previous 'NICK new' ** We come here when a previous 'NICK new'
** nick collided with an older nick, and was ** nick collided with an older nick, and was
** ignored, and other messages still were on ** ignored, and other messages still were on
** the way (like the following USER). ** the way (like the following USER).
** We simply ignore it all, a purge will be done ** We simply ignore it all, a purge will be done
** automatically by the server 'cptr' as a reaction ** automatically by the server 'cptr' as a reaction
** on our 'NICK older'. --Run ** on our 'NICK older'. --Run
*/ */
return 0; /* On our side, nothing changed */ return 0; /* On our side, nothing changed */
} }
return exit_client(cptr, cptr, &me, "Fake prefix"); return exit_client(cptr, cptr, &me, "Fake prefix");
} }
static void remove_unknown(cptr, sender) static void remove_unknown(cptr, sender)
aClient *cptr; aClient *cptr;
char *sender; char *sender;
{ {
if (!IsRegistered(cptr) || IsClient(cptr)) if (!IsRegistered(cptr) || IsClient(cptr))
return; return;
@@ -580,15 +716,20 @@ char *sender;
if (!IsServer(cptr)) if (!IsServer(cptr))
return; return;
#ifdef DEVELOP
sendto_ops("Killing %s (%s)", sender, backupbuf);
return;
#endif
/* /*
* Do kill if it came from a server because it means there is a ghost * Do kill if it came from a server because it means there is a ghost
* user on the other server which needs to be removed. -avalon * user on the other server which needs to be removed. -avalon
*/ */
if (!index(sender, '.')) if (!index(sender, '.') && !alnprefix)
sendto_one(cptr, ":%s KILL %s :%s (%s(?) <- %s)", sendto_one(cptr, ":%s KILL %s :%s (%s(?) <- %s)",
me.name, sender, me.name, sender, me.name, sender, me.name, sender,
get_client_name(cptr, FALSE)); get_client_name(cptr, FALSE));
else else
sendto_one(cptr, ":%s SQUIT %s :(Unknown from %s)", sendto_one(cptr, ":%s SQUIT %s%s :(Unknown from %s)",
me.name, sender, get_client_name(cptr, FALSE)); me.name, (alnprefix ? "@" : ""), sender,
get_client_name(cptr, FALSE));
} }
+262 -120
View File
@@ -1,10 +1,11 @@
/* /*
* ircd/res.c (C)opyright 1992, 1993, 1994 Darren Reed. All rights reserved. * src/res.c (C)opyright 1992, 1993, 1994 Darren Reed. All rights reserved.
* This file may not be distributed without the author's prior permission in * This file may not be distributed without the author's prior permission in
* any shape or form. The author takes no responsibility for any damage or * any shape or form. The author takes no responsibility for any damage or
* loss of property which results from the use of this software. Distribution * loss of property which results from the use of this software. Distribution
* of this file must include this notice. * of this file must include this notice.
*/ */
// *INDENT-OFF*
#include "struct.h" #include "struct.h"
#include "common.h" #include "common.h"
#include "sys.h" #include "sys.h"
@@ -29,7 +30,8 @@ ID_Copyright("(C) 1992 Darren Reed");
ID_Notes("2.38 4/13/94"); ID_Notes("2.38 4/13/94");
#undef DEBUG /* because there is a lot of debug code in here :-) */ #undef DEBUG /* because there is a lot of debug code in here :-) */
#define INADDRSZ sizeof(struct IN_ADDR)
#define IN6ADDRSZ sizeof(struct IN_ADDR)
extern int dn_expand PROTO((char *, char *, char *, char *, int)); extern int dn_expand PROTO((char *, char *, char *, char *, int));
extern int dn_skipname PROTO((char *, char *)); extern int dn_skipname PROTO((char *, char *));
extern int res_mkquery PROTO((int, char *, int, int, char *, int, extern int res_mkquery PROTO((int, char *, int, int, char *, int,
@@ -51,7 +53,7 @@ static ResRQ *last, *first;
static void rem_cache PROTO((aCache *)); static void rem_cache PROTO((aCache *));
static void rem_request PROTO((ResRQ *)); static void rem_request PROTO((ResRQ *));
static int do_query_name PROTO((Link *, char *, ResRQ *)); static int do_query_name PROTO((Link *, char *, ResRQ *));
static int do_query_number PROTO((Link *, struct in_addr *, ResRQ *)); static int do_query_number PROTO((Link *, struct IN_ADDR *, ResRQ *));
static void resend_query PROTO((ResRQ *)); static void resend_query PROTO((ResRQ *));
static int proc_answer PROTO((ResRQ *, HEADER *, char *, char *)); static int proc_answer PROTO((ResRQ *, HEADER *, char *, char *));
static int query_name PROTO((char *, int, int, ResRQ *)); static int query_name PROTO((char *, int, int, ResRQ *));
@@ -112,8 +114,14 @@ int op;
if (!_res.nscount) if (!_res.nscount)
{ {
_res.nscount = 1; _res.nscount = 1;
_res.nsaddr_list[0].sin_addr.s_addr = #ifdef INET6
/* still IPv4 */
inet_pton(AFINET, "127.0.0.1",
&_res.nsaddr_list[0].SIN_ADDR.S_ADDR);
#else
_res.nsaddr_list[0].SIN_ADDR.S_ADDR =
inet_addr("127.0.0.1"); inet_addr("127.0.0.1");
#endif
} }
} }
@@ -121,7 +129,7 @@ int op;
{ {
#ifndef _WIN32 #ifndef _WIN32
int on = 0; int on = 0;
ret = resfd = socket(AF_INET, SOCK_DGRAM, 0); ret = resfd = socket(AFINET, SOCK_DGRAM, 0);
set_non_blocking(resfd, &me); set_non_blocking(resfd, &me);
(void) setsockopt(ret, SOL_SOCKET, SO_BROADCAST, (void) setsockopt(ret, SOL_SOCKET, SO_BROADCAST,
(char *)&on, sizeof(on)); (char *)&on, sizeof(on));
@@ -169,9 +177,9 @@ ResRQ *new;
static void rem_request(old) static void rem_request(old)
ResRQ *old; ResRQ *old;
{ {
Reg1 ResRQ **rptr, *r2ptr = NULL; ResRQ **rptr, *r2ptr = NULL;
Reg2 int i; int i;
Reg3 char *s; char *s;
if (!old) if (!old)
return; return;
@@ -215,28 +223,28 @@ ResRQ *old;
static ResRQ *make_request(lp) static ResRQ *make_request(lp)
Link *lp; Link *lp;
{ {
Reg1 ResRQ *nreq; ResRQ *nreq;
nreq = (ResRQ *)MyMalloc(sizeof(ResRQ)); nreq = (ResRQ *)MyMalloc(sizeof(ResRQ));
bzero((char *)nreq, sizeof(ResRQ)); bzero((char *)nreq, sizeof(ResRQ));
nreq->next = NULL; /* where NULL is non-zero ;) */ nreq->next = NULL; /* where NULL is non-zero ;) */
nreq->sentat = TStime(); nreq->sentat = TStime();
nreq->retries = 3; nreq->retries = HOST_RETRIES;
nreq->resend = 1; nreq->resend = 1;
nreq->srch = -1; nreq->srch = -1;
if (lp) if (lp)
bcopy((char *)lp, (char *)&nreq->cinfo, sizeof(Link)); bcopy((char *)lp, (char *)&nreq->cinfo, sizeof(Link));
else else
bzero((char *)&nreq->cinfo, sizeof(Link)); bzero((char *)&nreq->cinfo, sizeof(Link));
nreq->timeout = 4; /* start at 4 and exponential inc. */ nreq->timeout = HOST_TIMEOUT;
#ifndef _WIN32 #ifndef _WIN32
nreq->he.h_addrtype = AF_INET; nreq->he.h_addrtype = AFINET;
nreq->he.h_name = NULL; nreq->he.h_name = NULL;
nreq->he.h_aliases[0] = NULL; nreq->he.h_aliases[0] = NULL;
#else #else
nreq->he = (struct hostent *)MyMalloc(MAXGETHOSTSTRUCT); nreq->he = (struct hostent *)MyMalloc(MAXGETHOSTSTRUCT);
bzero((char *)nreq->he, MAXGETHOSTSTRUCT); bzero((char *)nreq->he, MAXGETHOSTSTRUCT);
nreq->he->h_addrtype = AF_INET; nreq->he->h_addrtype = AFINET;
nreq->he->h_name = NULL; nreq->he->h_name = NULL;
#endif #endif
(void)add_request(nreq); (void)add_request(nreq);
@@ -250,8 +258,8 @@ Link *lp;
time_t timeout_query_list(now) time_t timeout_query_list(now)
time_t now; time_t now;
{ {
Reg1 ResRQ *rptr, *r2ptr; ResRQ *rptr, *r2ptr;
Reg2 time_t next = 0, tout; time_t next = 0, tout;
aClient *cptr; aClient *cptr;
Debug((DEBUG_DNS,"timeout_query_list at %s",myctime(now))); Debug((DEBUG_DNS,"timeout_query_list at %s",myctime(now)));
@@ -335,7 +343,7 @@ time_t now;
void del_queries(cp) void del_queries(cp)
char *cp; char *cp;
{ {
Reg1 ResRQ *rptr, *r2ptr; ResRQ *rptr, *r2ptr;
for (rptr = first; rptr; rptr = r2ptr) for (rptr = first; rptr; rptr = r2ptr)
{ {
@@ -357,7 +365,7 @@ static int send_res_msg(msg, len, rcount)
char *msg; char *msg;
int len, rcount; int len, rcount;
{ {
Reg1 int i; int i;
int sent = 0, max; int sent = 0, max;
if (!msg) if (!msg)
@@ -371,9 +379,9 @@ int len, rcount;
for (i = 0; i < max; i++) for (i = 0; i < max; i++)
{ {
_res.nsaddr_list[i].sin_family = AF_INET; _res.nsaddr_list[i].SIN_FAMILY = AFINET;
if (sendto(resfd, msg, len, 0, (struct sockaddr *) if (sendto(resfd, msg, len, 0, (struct SOCKADDR *)
&(_res.nsaddr_list[i]), sizeof(struct sockaddr)) == len) &(_res.nsaddr_list[i]), sizeof(struct SOCKADDR)) == len)
{ {
reinfo.re_sent++; reinfo.re_sent++;
sent++; sent++;
@@ -393,7 +401,7 @@ int len, rcount;
static ResRQ *find_id(id) static ResRQ *find_id(id)
int id; int id;
{ {
Reg1 ResRQ *rptr; ResRQ *rptr;
for (rptr = first; rptr; rptr = rptr->next) for (rptr = first; rptr; rptr = rptr->next)
if (rptr->id == id) if (rptr->id == id)
@@ -405,7 +413,7 @@ struct hostent *gethost_byname(name, lp)
char *name; char *name;
Link *lp; Link *lp;
{ {
Reg1 aCache *cp; aCache *cp;
reinfo.re_na_look++; reinfo.re_na_look++;
if ((cp = find_cache_name(name))) if ((cp = find_cache_name(name)))
@@ -435,14 +443,14 @@ Link *lp;
#endif #endif
if (!lp) if (!lp)
return NULL; return NULL;
(void)do_query_number(lp, (struct in_addr *)addr, NULL); (void)do_query_number(lp, (struct IN_ADDR *)addr, NULL);
return NULL; return NULL;
} }
static int do_query_name(lp, name, rptr) static int do_query_name(lp, name, rptr)
Link *lp; Link *lp;
char *name; char *name;
Reg1 ResRQ *rptr; ResRQ *rptr;
{ {
#ifndef _WIN32 #ifndef _WIN32
char hname[HOSTLEN+1]; char hname[HOSTLEN+1];
@@ -465,12 +473,20 @@ Reg1 ResRQ *rptr;
if (!rptr) if (!rptr)
{ {
rptr = make_request(lp); rptr = make_request(lp);
#ifdef INET6
rptr->type = T_AAAA;
#else
rptr->type = T_A; rptr->type = T_A;
#endif
rptr->name = (char *)MyMalloc(strlen(name) + 1); rptr->name = (char *)MyMalloc(strlen(name) + 1);
(void)strcpy(rptr->name, name); (void)strcpy(rptr->name, name);
} }
#ifndef _WIN32 #ifndef _WIN32
#ifdef INET6
return (query_name(hname, C_IN, T_AAAA, rptr));
#else
return (query_name(hname, C_IN, T_A, rptr)); return (query_name(hname, C_IN, T_A, rptr));
#endif
#else #else
rptr->id = _beginthread(async_dns, 0, (void *)rptr); rptr->id = _beginthread(async_dns, 0, (void *)rptr);
@@ -484,29 +500,70 @@ Reg1 ResRQ *rptr;
*/ */
static int do_query_number(lp, numb, rptr) static int do_query_number(lp, numb, rptr)
Link *lp; Link *lp;
struct in_addr *numb; struct IN_ADDR *numb;
Reg1 ResRQ *rptr; ResRQ *rptr;
{ {
#ifndef _WIN32 char ipbuf[128];
char ipbuf[32]; u_char *cp;
Reg2 u_char *cp;
cp = (u_char *)&numb->s_addr; #ifndef _WIN32
(void)sprintf(ipbuf,"%u.%u.%u.%u.in-addr.arpa.", #ifdef INET6
cp = (u_char *)numb->s6_addr;
if (cp[0]==0 && cp[1]==0 && cp[2]==0 && cp[3]==0 && cp[4]==0 &&
cp[5]==0 && cp[6]==0 && cp[7]==0 && cp[8]==0 && cp[9]==0 &&
((cp[10]==0 && cp[11]==0) || (cp[10]==0xff && cp[11]==0xff)))
{
(void)sprintf(ipbuf, "%u.%u.%u.%u.in-addr.arpa.",
(u_int)(cp[15]), (u_int)(cp[14]),
(u_int)(cp[13]), (u_int)(cp[12]));
}
else
{
(void)sprintf(ipbuf, "%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.ip6.int.",
(u_int)(cp[15]&0xf), (u_int)(cp[15]>>4),
(u_int)(cp[14]&0xf), (u_int)(cp[14]>>4),
(u_int)(cp[13]&0xf), (u_int)(cp[13]>>4),
(u_int)(cp[12]&0xf), (u_int)(cp[12]>>4),
(u_int)(cp[11]&0xf), (u_int)(cp[11]>>4),
(u_int)(cp[10]&0xf), (u_int)(cp[10]>>4),
(u_int)(cp[9]&0xf), (u_int)(cp[9]>>4),
(u_int)(cp[8]&0xf), (u_int)(cp[8]>>4),
(u_int)(cp[7]&0xf), (u_int)(cp[7]>>4),
(u_int)(cp[6]&0xf), (u_int)(cp[6]>>4),
(u_int)(cp[5]&0xf), (u_int)(cp[5]>>4),
(u_int)(cp[4]&0xf), (u_int)(cp[4]>>4),
(u_int)(cp[3]&0xf), (u_int)(cp[3]>>4),
(u_int)(cp[2]&0xf), (u_int)(cp[2]>>4),
(u_int)(cp[1]&0xf), (u_int)(cp[1]>>4),
(u_int)(cp[0]&0xf), (u_int)(cp[0]>>4));
}
#else
cp = (u_char *)&numb->S_ADDR;
(void)ircsprintf(ipbuf,"%u.%u.%u.%u.in-addr.arpa.",
(u_int)(cp[3]), (u_int)(cp[2]), (u_int)(cp[3]), (u_int)(cp[2]),
(u_int)(cp[1]), (u_int)(cp[0])); (u_int)(cp[1]), (u_int)(cp[0]));
#endif
#endif #endif
if (!rptr) if (!rptr)
{ {
rptr = make_request(lp); rptr = make_request(lp);
rptr->type = T_PTR; rptr->type = T_PTR;
rptr->addr.s_addr = numb->s_addr; #ifdef INET6
#ifndef _WIN32 bcopy(numb->s6_addr, rptr->addr.s6_addr, IN6ADDRSZ);
bcopy((char *)&numb->s_addr, bcopy((char *)numb->s6_addr,
(char *)&rptr->he.h_addr, sizeof(struct in_addr)); (char *)&rptr->he.h_addr, sizeof(struct in6_addr));
rptr->he.h_length = sizeof(struct in_addr);
#else #else
rptr->he->h_length = sizeof(struct in_addr); rptr->addr.S_ADDR = numb->S_ADDR;
#ifndef _WIN32
bcopy((char *)&numb->S_ADDR,
(char *)&rptr->he.h_addr, sizeof(struct IN_ADDR));
rptr->he.h_length = sizeof(struct IN_ADDR);
#else
rptr->he->h_length = sizeof(struct IN_ADDR);
#endif
#endif #endif
} }
#ifndef _WIN32 #ifndef _WIN32
@@ -580,9 +637,13 @@ ResRQ *rptr;
case T_PTR: case T_PTR:
(void)do_query_number(NULL, &rptr->addr, rptr); (void)do_query_number(NULL, &rptr->addr, rptr);
break; break;
#ifdef INET6
case T_AAAA:
#endif
case T_A: case T_A:
(void)do_query_name(NULL, rptr->name, rptr); (void)do_query_name(NULL, rptr->name, rptr);
break; break;
default: default:
break; break;
} }
@@ -597,20 +658,25 @@ ResRQ *rptr;
char *buf, *eob; char *buf, *eob;
HEADER *hptr; HEADER *hptr;
{ {
Reg1 char *cp, **alias; char *cp, **alias;
Reg2 struct hent *hp; struct hent *hp;
int class, type, dlen, len, ans = 0, n; int class, type, dlen, len, ans = 0, n;
struct in_addr dr, *adr; struct IN_ADDR dr, *adr;
cp = buf + sizeof(HEADER); cp = buf + sizeof(HEADER);
hp = (struct hent *)&(rptr->he); hp = (struct hent *)&(rptr->he);
adr = &hp->h_addr; adr = &hp->h_addr;
while (adr->s_addr) #ifndef INET6
while (adr->S_ADDR)
#else
while (adr->s6_laddr[0] | adr->s6_laddr[1] | adr->s6_laddr[2] |
adr->s6_laddr[3])
#endif
adr++; adr++;
alias = hp->h_aliases; alias = hp->h_aliases;
while (*alias) while (*alias)
alias++; alias++;
#ifdef SOL20 /* brain damaged compiler (Solaris2) it seems */ #ifdef _SOLARIS /* brain damaged compiler (Solaris2) it seems */
for (; hptr->qdcount > 0; hptr->qdcount--) for (; hptr->qdcount > 0; hptr->qdcount--)
#else #else
while (hptr->qdcount-- > 0) while (hptr->qdcount-- > 0)
@@ -633,9 +699,6 @@ HEADER *hptr;
class = (int)_getshort(cp); class = (int)_getshort(cp);
cp += sizeof(short); cp += sizeof(short);
rptr->ttl = _getlong(cp); rptr->ttl = _getlong(cp);
#ifndef LINUX_ALPHA
cp += sizeof(rptr->ttl);
#else
/* This should really use the GETLONG macro which advances /* This should really use the GETLONG macro which advances
* the pointer for us, but I don't know if that'll break other * the pointer for us, but I don't know if that'll break other
* systems. sizeof(_getlong) does not always equal sizeof(time_t). * systems. sizeof(_getlong) does not always equal sizeof(time_t).
@@ -643,9 +706,12 @@ HEADER *hptr;
* for this portion of the resolver reply it would seem. * for this portion of the resolver reply it would seem.
* heydowns@borg.com * heydowns@borg.com
*/ */
cp += 4; #ifdef __alpha
cp += 4;
#else
cp += sizeof(rptr->ttl);
#endif #endif
dlen = (int)_getshort(cp); dlen = (int)_getshort(cp);
cp += sizeof(short); cp += sizeof(short);
rptr->type = type; rptr->type = type;
@@ -664,15 +730,37 @@ HEADER *hptr;
switch(type) switch(type)
{ {
#ifdef INET6
case T_AAAA:
#endif
case T_A : case T_A :
hp->h_length = dlen; hp->h_length = dlen;
if (ans == 1) if (ans == 1)
hp->h_addrtype = (class == C_IN) ? hp->h_addrtype = (class == C_IN) ?
AF_INET : AF_UNSPEC; AFINET : AF_UNSPEC;
#ifdef INET6
if (type == T_AAAA)
bcopy(cp, (char *)&dr, dlen);
else {
dr.s6_laddr[0]=dr.s6_laddr[1]=0;
dr.s6_laddr[2]=htonl(0xffff);
bcopy(cp, &dr.s6_laddr[3], INADDRSZ);
}
bcopy(dr.s6_addr, adr->s6_addr, IN6ADDRSZ);
#else
bcopy(cp, (char *)&dr, dlen); bcopy(cp, (char *)&dr, dlen);
adr->s_addr = dr.s_addr;
adr->S_ADDR = dr.S_ADDR;
#endif
#ifdef INET6
Debug((DEBUG_INFO,"got ip # %s for %s",
inet_ntop(AF_INET6, (char *)adr, mydummy,
MYDUMMY_SIZE),
hostbuf));
#else
Debug((DEBUG_INFO,"got ip # %s for %s", Debug((DEBUG_INFO,"got ip # %s for %s",
inetntoa((char *)adr), hostbuf)); inetntoa((char *)adr), hostbuf));
#endif
if (!hp->h_name) if (!hp->h_name)
{ {
hp->h_name =(char *)MyMalloc(len+1); hp->h_name =(char *)MyMalloc(len+1);
@@ -748,17 +836,17 @@ long id;
{ {
#ifndef _WIN32 #ifndef _WIN32
static char buf[sizeof(HEADER) + MAXPACKET]; static char buf[sizeof(HEADER) + MAXPACKET];
Reg1 HEADER *hptr; HEADER *hptr;
struct sockaddr_in sin; struct SOCKADDR_IN sin;
int rc, a, len = sizeof(sin), max; int rc, a, len = sizeof(sin), max;
#else #else
Reg3 struct hostent *he; struct hostent *he;
#endif #endif
Reg2 ResRQ *rptr = NULL; ResRQ *rptr = NULL;
aCache *cp; aCache *cp;
#ifndef _WIN32 #ifndef _WIN32
rc = recvfrom(resfd, buf, sizeof(buf), 0, (struct sockaddr *)&sin, rc = recvfrom(resfd, buf, sizeof(buf), 0, (struct SOCKADDR *)&sin,
&len); &len);
if (rc == -1 || rc <= sizeof(HEADER)) if (rc == -1 || rc <= sizeof(HEADER))
goto getres_err; goto getres_err;
@@ -797,10 +885,10 @@ long id;
max = 1; max = 1;
for (a = 0; a < max; a++) for (a = 0; a < max; a++)
if (!_res.nsaddr_list[a].sin_addr.s_addr || if (!_res.nsaddr_list[a].SIN_ADDR.S_ADDR ||
!bcmp((char *)&sin.sin_addr, !bcmp((char *)&sin.SIN_ADDR,
(char *)&_res.nsaddr_list[a].sin_addr, (char *)&_res.nsaddr_list[a].SIN_ADDR,
sizeof(struct in_addr))) sizeof(struct IN_ADDR)))
break; break;
if (a == max) if (a == max)
{ {
@@ -849,9 +937,16 @@ long id;
if (a && rptr->type == T_PTR) if (a && rptr->type == T_PTR)
{ {
struct hostent *hp2 = NULL; struct hostent *hp2 = NULL;
#ifdef INET6
Debug((DEBUG_DNS, "relookup %s <-> %s",
rptr->he.h_name, inet_ntop(AF_INET6,
(char *)&rptr->he.h_addr,
mydummy, MYDUMMY_SIZE)));
#else
Debug((DEBUG_DNS, "relookup %s <-> %s", Debug((DEBUG_DNS, "relookup %s <-> %s",
rptr->he.h_name, inetntoa((char *)&rptr->he.h_addr))); rptr->he.h_name, inetntoa((char *)&rptr->he.h_addr)));
#endif
/* /*
* Lookup the 'authoritive' name that we were given for the * Lookup the 'authoritive' name that we were given for the
* ip#. By using this call rather than regenerating the * ip#. By using this call rather than regenerating the
@@ -913,10 +1008,26 @@ getres_err:
rptr->retries = _res.retry; rptr->retries = _res.retry;
rptr->sends = 0; rptr->sends = 0;
rptr->resend = 1; rptr->resend = 1;
#ifdef INET6
/* Comment out this ifdef to get names like ::ffff:a.b.c.d */
if(rptr->type == T_AAAA)
query_name(rptr->name, C_IN, T_A, rptr);
Debug((DEBUG_DNS,"getres_err: didn't work with T_AAAA, now also trying with T_A for %s",rptr->name));
#endif
resend_query(rptr); resend_query(rptr);
} }
else else
{
resend_query(rptr); resend_query(rptr);
#ifdef INET6
/* Comment out this ifdef to get names like ::ffff:a.b.c.d */
if(rptr->type == T_AAAA)
query_name(rptr->name, C_IN, T_A, rptr);
Debug((DEBUG_DNS,"getres_err: didn't work with T_AAAA, now also trying with T_A for %s",rptr->name));
#endif
}
} }
else if (lp) else if (lp)
bcopy((char *)&rptr->cinfo, lp, sizeof(Link)); bcopy((char *)&rptr->cinfo, lp, sizeof(Link));
@@ -924,7 +1035,7 @@ getres_err:
#else /*_WIN32*/ #else /*_WIN32*/
he = rptr->he; he = rptr->he;
if (he && he->h_name && ((struct in_addr *)he->h_addr)->s_addr && if (he && he->h_name && ((struct IN_ADDR *)he->h_addr)->S_ADDR &&
rptr->locked < 2) rptr->locked < 2)
{ {
/* /*
@@ -938,7 +1049,7 @@ getres_err:
strcpy(tempname, he->h_name); strcpy(tempname, he->h_name);
hp = gethostbyname(tempname); hp = gethostbyname(tempname);
if (hp && !bcmp(hp->h_addr, he->h_addr, sizeof(struct in_addr))) if (hp && !bcmp(hp->h_addr, he->h_addr, sizeof(struct IN_ADDR)))
{ {
} }
else else
@@ -962,15 +1073,30 @@ getres_err:
} }
static int hash_number(ip) static int hash_number(ip)
Reg1 unsigned char *ip; unsigned char *ip;
{ {
Reg1 u_int hashv = 0; u_int hashv = 0;
/* could use loop but slower */ /* could use loop but slower */
hashv += (int)*ip++; hashv += (int)*ip++;
hashv += hashv + (int)*ip++; hashv += hashv + (int)*ip++;
hashv += hashv + (int)*ip++; hashv += hashv + (int)*ip++;
hashv += hashv + (int)*ip++; hashv += hashv + (int)*ip++;
#ifdef INET6
hashv += hashv + (int)*ip++;
hashv += hashv + (int)*ip++;
hashv += hashv + (int)*ip++;
hashv += hashv + (int)*ip++;
hashv += hashv + (int)*ip++;
hashv += hashv + (int)*ip++;
hashv += hashv + (int)*ip++;
hashv += hashv + (int)*ip++;
hashv += hashv + (int)*ip++;
hashv += hashv + (int)*ip++;
hashv += hashv + (int)*ip++;
hashv += hashv + (int)*ip++;
#endif
hashv %= ARES_CACSIZE; hashv %= ARES_CACSIZE;
return (hashv); return (hashv);
} }
@@ -978,7 +1104,7 @@ Reg1 unsigned char *ip;
static int hash_name(name) static int hash_name(name)
register char *name; register char *name;
{ {
Reg1 u_int hashv = 0; u_int hashv = 0;
if (name == NULL) { if (name == NULL) {
sendto_realops ("Caught NULL pointer in hash_name(). (Bad thing -- tell rwg.)"); sendto_realops ("Caught NULL pointer in hash_name(). (Bad thing -- tell rwg.)");
@@ -995,16 +1121,25 @@ register char *name;
** Add a new cache item to the queue and hash table. ** Add a new cache item to the queue and hash table.
*/ */
static aCache *add_to_cache(ocp) static aCache *add_to_cache(ocp)
Reg1 aCache *ocp; aCache *ocp;
{ {
Reg1 aCache *cp = NULL; aCache *cp = NULL;
Reg2 int hashv; int hashv;
#ifdef DEBUG #ifdef DEBUG
#ifdef INET6
Debug((DEBUG_INFO,"add_to_cache:added %s[%08x%08x%08x%08x] cache %#x.",
ocp->he.h_name,
((struct in6_addr *)ocp->he.h_addr_list)->s6_laddr[0],
((struct in6_addr *)ocp->he.h_addr_list)->s6_laddr[1],
((struct in6_addr *)ocp->he.h_addr_list)->s6_laddr[2],
((struct in6_addr *)ocp->he.h_addr_list)->s6_laddr[3], ocp));
#else
Debug((DEBUG_INFO, Debug((DEBUG_INFO,
"add_to_cache:ocp %#x he %#x name %#x addrl %#x 0 %#x", "add_to_cache:ocp %#x he %#x name %#x addrl %#x 0 %#x",
ocp, &ocp->he, ocp->he.h_name, ocp->he.h_addr_list, ocp, &ocp->he, ocp->he.h_name, ocp->he.h_addr_list,
ocp->he.h_addr_list[0])); ocp->he.h_addr_list[0]));
#endif
#endif #endif
ocp->list_next = cachetop; ocp->list_next = cachetop;
cachetop = ocp; cachetop = ocp;
@@ -1065,9 +1200,9 @@ static void update_list(rptr, cachep)
ResRQ *rptr; ResRQ *rptr;
aCache *cachep; aCache *cachep;
{ {
Reg1 aCache **cpp, *cp = cachep; aCache **cpp, *cp = cachep;
Reg2 char *s, *t, **base; char *s, *t, **base;
Reg3 int i, j; int i, j;
int addrcount; int addrcount;
/* /*
@@ -1134,11 +1269,11 @@ aCache *cachep;
/* /*
* Do the same again for IP#'s. * Do the same again for IP#'s.
*/ */
for (s = (char *)&rptr->he.h_addr.s_addr; for (s = (char *)&rptr->he.h_addr.S_ADDR;
((struct in_addr *)s)->s_addr; s += sizeof(struct in_addr)) ((struct IN_ADDR *)s)->S_ADDR; s += sizeof(struct IN_ADDR))
{ {
for (i = 0; (t = cp->he.h_addr_list[i]); i++) for (i = 0; (t = cp->he.h_addr_list[i]); i++)
if (!bcmp(s, t, sizeof(struct in_addr))) if (!bcmp(s, t, sizeof(struct IN_ADDR)))
break; break;
if (i >= MAXADDRS || addrcount >= MAXADDRS) if (i >= MAXADDRS || addrcount >= MAXADDRS)
break; break;
@@ -1155,23 +1290,23 @@ aCache *cachep;
base = cp->he.h_addr_list; base = cp->he.h_addr_list;
addrcount++; addrcount++;
t = (char *)MyRealloc(*base, t = (char *)MyRealloc(*base,
addrcount * sizeof(struct in_addr)); addrcount * sizeof(struct IN_ADDR));
base = (char **)MyRealloc((char *)base, base = (char **)MyRealloc((char *)base,
(addrcount + 1) * sizeof(char *)); (addrcount + 1) * sizeof(char *));
cp->he.h_addr_list = base; cp->he.h_addr_list = base;
#ifdef DEBUG #ifdef DEBUG
Debug((DEBUG_DNS,"u_l:add IP %x hal %x ac %d", Debug((DEBUG_DNS,"u_l:add IP %x hal %x ac %d",
ntohl(((struct in_addr *)s)->s_addr), ntohl(((struct IN_ADDR *)s)->S_ADDR),
cp->he.h_addr_list, cp->he.h_addr_list,
addrcount)); addrcount));
#endif #endif
for (; addrcount; addrcount--) for (; addrcount; addrcount--)
{ {
*base++ = t; *base++ = t;
t += sizeof(struct in_addr); t += sizeof(struct IN_ADDR);
} }
*base = NULL; *base = NULL;
bcopy(s, *--base, sizeof(struct in_addr)); bcopy(s, *--base, sizeof(struct IN_ADDR));
} }
} }
#endif /*_WIN32*/ #endif /*_WIN32*/
@@ -1181,9 +1316,9 @@ aCache *cachep;
static aCache *find_cache_name(name) static aCache *find_cache_name(name)
char *name; char *name;
{ {
Reg1 aCache *cp; aCache *cp;
Reg2 char *s; char *s;
Reg3 int hashv, i; int hashv, i;
hashv = hash_name(name); hashv = hash_name(name);
@@ -1241,29 +1376,29 @@ static aCache *find_cache_number(rptr, numb)
ResRQ *rptr; ResRQ *rptr;
char *numb; char *numb;
{ {
Reg1 aCache *cp; aCache *cp;
Reg2 int hashv,i; int hashv,i;
#ifdef DEBUG #ifdef DEBUG
struct in_addr *ip = (struct in_addr *)numb; struct IN_ADDR *ip = (struct IN_ADDR *)numb;
#endif #endif
hashv = hash_number((u_char *)numb); hashv = hash_number((u_char *)numb);
cp = hashtable[hashv].num_list; cp = hashtable[hashv].num_list;
#ifdef DEBUG #if defined(DEBUG) && !defined(INET6)
Debug((DEBUG_DNS,"find_cache_number:find %s[%08x]: hashv = %d", Debug((DEBUG_DNS,"find_cache_number:find %s[%08x]: hashv = %d",
inetntoa(numb), ntohl(ip->s_addr), hashv)); inetntoa(numb), ntohl(ip->S_ADDR), hashv));
#endif #endif
for (; cp; cp = cp->hnum_next) for (; cp; cp = cp->hnum_next)
#ifndef _WIN32 #ifndef _WIN32
for (i = 0; cp->he.h_addr_list[i]; i++) for (i = 0; cp->he.h_addr_list[i]; i++)
if (!bcmp(cp->he.h_addr_list[i], numb, if (!bcmp(cp->he.h_addr_list[i], numb,
sizeof(struct in_addr))) sizeof(struct IN_ADDR)))
#else #else
for (i = 0; cp->he->h_addr_list && cp->he->h_addr_list[i]; i++) for (i = 0; cp->he->h_addr_list && cp->he->h_addr_list[i]; i++)
if (!bcmp(cp->he->h_addr_list[i], numb, if (!bcmp(cp->he->h_addr_list[i], numb,
sizeof(struct in_addr))) sizeof(struct IN_ADDR)))
#endif #endif
{ {
cainfo.ca_nu_hits++; cainfo.ca_nu_hits++;
@@ -1292,13 +1427,13 @@ char *numb;
continue; continue;
for (i = 1; cp->he.h_addr_list[i]; i++) for (i = 1; cp->he.h_addr_list[i]; i++)
if (!bcmp(cp->he.h_addr_list[i], numb, if (!bcmp(cp->he.h_addr_list[i], numb,
sizeof(struct in_addr))) sizeof(struct IN_ADDR)))
#else #else
if (hashv == hash_number((u_char *)cp->he->h_addr_list[0])) if (hashv == hash_number((u_char *)cp->he->h_addr_list[0]))
continue; continue;
for (i = 1; cp->he->h_addr_list && cp->he->h_addr_list[i]; i++) for (i = 1; cp->he->h_addr_list && cp->he->h_addr_list[i]; i++)
if (!bcmp(cp->he->h_addr_list[i], numb, if (!bcmp(cp->he->h_addr_list[i], numb,
sizeof(struct in_addr))) sizeof(struct IN_ADDR)))
#endif #endif
{ {
cainfo.ca_nu_hits++; cainfo.ca_nu_hits++;
@@ -1312,18 +1447,21 @@ char *numb;
static aCache *make_cache(rptr) static aCache *make_cache(rptr)
ResRQ *rptr; ResRQ *rptr;
{ {
Reg1 aCache *cp; aCache *cp;
Reg2 int i, n; int i, n;
Reg3 struct hostent *hp; struct hostent *hp;
Reg3 char *s, **t; char *s, **t;
/* /*
** shouldn't happen but it just might... ** shouldn't happen but it just might...
*/ */
#ifndef _WIN32 #ifndef _WIN32
if (!rptr->he.h_name || !rptr->he.h_addr.s_addr) #ifdef INET6
if (!rptr->he.h_name || !WHOSTENTP(rptr->he.h_addr.S_ADDR))
#else
if (!rptr->he.h_name || !rptr->he.h_addr.S_ADDR)
#endif
#else #else
if (!rptr->he->h_name || !((struct in_addr *)rptr->he->h_addr)->s_addr)
#endif #endif
return NULL; return NULL;
/* /*
@@ -1331,18 +1469,18 @@ ResRQ *rptr;
** and if so, return a pointer to it. ** and if so, return a pointer to it.
*/ */
#ifndef _WIN32 #ifndef _WIN32
if ((cp = find_cache_number(rptr, (char *)&rptr->he.h_addr.s_addr))) if ((cp = find_cache_number(rptr, (char *)&rptr->he.h_addr.S_ADDR)))
return cp; return cp;
for (i = 1; rptr->he.h_addr_list[i].s_addr; i++) for (i = 1; rptr->he.h_addr_list[i].S_ADDR; i++)
if ((cp = find_cache_number(rptr, if ((cp = find_cache_number(rptr,
(char *)&(rptr->he.h_addr_list[i].s_addr)))) (char *)&(rptr->he.h_addr_list[i].S_ADDR))))
#else #else
if ((cp = find_cache_number(rptr, (char *)&((struct in_addr *)rptr->he->h_addr)->s_addr))) if ((cp = find_cache_number(rptr, (char *)&((struct IN_ADDR *)rptr->he->h_addr)->S_ADDR)))
return cp; return cp;
for (i = 1; rptr->he->h_addr_list[i] && for (i = 1; rptr->he->h_addr_list[i] &&
((struct in_addr *)rptr->he->h_addr_list[i])->s_addr; i++) ((struct IN_ADDR *)rptr->he->h_addr_list[i])->S_ADDR; i++)
if ((cp = find_cache_number(rptr, if ((cp = find_cache_number(rptr,
(char *)&((struct in_addr *)rptr->he->h_addr_list[i])->s_addr ))) (char *)&((struct IN_ADDR *)rptr->he->h_addr_list[i])->S_ADDR )))
#endif #endif
return cp; return cp;
@@ -1357,7 +1495,11 @@ ResRQ *rptr;
#else #else
hp = &cp->he; hp = &cp->he;
for (i = 0; i < MAXADDRS; i++) for (i = 0; i < MAXADDRS; i++)
if (!rptr->he.h_addr_list[i].s_addr) #ifdef INET6
if (!WHOSTENTP(rptr->he.h_addr_list[i].S_ADDR))
#else
if (!rptr->he.h_addr_list[i].S_ADDR)
#endif
break; break;
/* /*
@@ -1366,14 +1508,14 @@ ResRQ *rptr;
t = hp->h_addr_list = (char **)MyMalloc(sizeof(char *) * (i+1)); t = hp->h_addr_list = (char **)MyMalloc(sizeof(char *) * (i+1));
bzero((char *)t, sizeof(char *) * (i+1)); bzero((char *)t, sizeof(char *) * (i+1));
s = (char *)MyMalloc(sizeof(struct in_addr) * i); s = (char *)MyMalloc(sizeof(struct IN_ADDR) * i);
bzero(s, sizeof(struct in_addr) * i); bzero(s, sizeof(struct IN_ADDR) * i);
for (n = 0; n < i; n++, s += sizeof(struct in_addr)) for (n = 0; n < i; n++, s += sizeof(struct IN_ADDR))
{ {
*t++ = s; *t++ = s;
bcopy((char *)&(rptr->he.h_addr_list[n].s_addr), s, bcopy((char *)&(rptr->he.h_addr_list[n].S_ADDR), s,
sizeof(struct in_addr)); sizeof(struct IN_ADDR));
} }
*t = (char *)NULL; *t = (char *)NULL;
@@ -1422,14 +1564,14 @@ ResRQ *rptr;
static void rem_cache(ocp) static void rem_cache(ocp)
aCache *ocp; aCache *ocp;
{ {
Reg1 aCache **cp; aCache **cp;
#ifndef _WIN32 #ifndef _WIN32
Reg2 struct hostent *hp = &ocp->he; struct hostent *hp = &ocp->he;
#else #else
Reg2 struct hostent *hp = ocp->he; struct hostent *hp = ocp->he;
#endif #endif
Reg3 int hashv; int hashv;
Reg4 aClient *cptr; aClient *cptr;
#ifdef DEBUG #ifdef DEBUG
Debug((DEBUG_DNS, "rem_cache: ocp %#x hp %#x l_n %#x aliases %#x", Debug((DEBUG_DNS, "rem_cache: ocp %#x hp %#x l_n %#x aliases %#x",
@@ -1523,8 +1665,8 @@ aCache *ocp;
time_t expire_cache(now) time_t expire_cache(now)
time_t now; time_t now;
{ {
Reg1 aCache *cp, *cp2; aCache *cp, *cp2;
Reg2 time_t next = 0; time_t next = 0;
for (cp = cachetop; cp; cp = cp2) for (cp = cachetop; cp; cp = cp2)
{ {
@@ -1546,7 +1688,7 @@ time_t now;
*/ */
void flush_cache() void flush_cache()
{ {
Reg1 aCache *cp; aCache *cp;
while ((cp = cachetop)) while ((cp = cachetop))
rem_cache(cp); rem_cache(cp);
@@ -1557,8 +1699,8 @@ aClient *cptr, *sptr;
int parc; int parc;
char *parv[]; char *parv[];
{ {
Reg1 aCache *cp; aCache *cp;
Reg2 int i; int i;
if (parv[1] && *parv[1] == 'l') { if (parv[1] && *parv[1] == 'l') {
for(cp = cachetop; cp; cp = cp->list_next) for(cp = cachetop; cp; cp = cp->list_next)
@@ -1623,7 +1765,7 @@ aClient *sptr;
for (i = 0; h->h_addr_list[i]; i++) for (i = 0; h->h_addr_list[i]; i++)
{ {
im += sizeof(char *); im += sizeof(char *);
im += sizeof(struct in_addr); im += sizeof(struct IN_ADDR);
} }
im += sizeof(char *); im += sizeof(char *);
for (i = 0; h->h_aliases[i]; i++) for (i = 0; h->h_aliases[i]; i++)
@@ -1663,7 +1805,7 @@ void async_dns(void *parm)
else else
{ {
rptr->locked = 1; rptr->locked = 1;
hp = gethostbyaddr((char *)(&rptr->addr.s_addr), 4, PF_INET); hp = gethostbyaddr((char *)(&rptr->addr.S_ADDR), 4, PF_INET);
} }
if ( !hp ) if ( !hp )
{ {
@@ -1734,7 +1876,7 @@ int res_copyhostent(struct hostent *from, struct hostent *to)
{ {
amt += 4; amt += 4;
to->h_addr_list[i] = (char *)(amt+x); to->h_addr_list[i] = (char *)(amt+x);
((struct in_addr *)to->h_addr_list[i])->s_addr = ((struct in_addr *)from->h_addr_list[i])->s_addr; ((struct IN_ADDR *)to->h_addr_list[i])->S_ADDR = ((struct IN_ADDR *)from->h_addr_list[i])->S_ADDR;
} }
to->h_addr_list[i] = NULL; to->h_addr_list[i] = NULL;
} }
BIN
View File
Binary file not shown.
+145 -125
View File
@@ -1,3 +1,4 @@
/*- /*-
* Copyright (c) 1985, 1989 Regents of the University of California. * Copyright (c) 1985, 1989 Regents of the University of California.
* All rights reserved. * All rights reserved.
@@ -27,7 +28,7 @@ static char sccsid[] = "@(#)res_init.c 6.14.1 (Berkeley) 6/27/90";
#include <netinet/in.h> #include <netinet/in.h>
#endif #endif
#include <stdio.h> #include <stdio.h>
#include "config.h" /* To get #define SOL20 Vesa */ #include "config.h" /* To get #define SOL20 Vesa */
#include "sys.h" #include "sys.h"
#include "common.h" #include "common.h"
#include "nameser.h" #include "nameser.h"
@@ -39,10 +40,10 @@ ID_CVS("$Id$");
*/ */
struct state _res = { struct state _res = {
RES_TIMEOUT, /* retransmition time interval */ RES_TIMEOUT, /* retransmition time interval */
4, /* number of times to retransmit */ 4, /* number of times to retransmit */
RES_DEFAULT, /* options flags */ RES_DEFAULT, /* options flags */
1, /* number of name servers */ 1, /* number of name servers */
}; };
/* /*
@@ -67,141 +68,158 @@ res_init()
register int n; register int n;
char buf[BUFSIZ]; char buf[BUFSIZ];
extern char *getenv(); extern char *getenv();
int nserv = 0; /* number of nameserver records read from file */ int nserv = 0; /* number of nameserver records read from file */
int norder = 0; int norder = 0;
int haveenv = 0; int haveenv = 0;
int havesearch = 0; int havesearch = 0;
_res.nsaddr.sin_addr.s_addr = INADDR_ANY; _res.nsaddr.SIN_ADDR.S_ADDR = INADDR_ANY;
_res.nsaddr.sin_family = AF_INET; _res.nsaddr.SIN_FAMILY = AFINET;
#ifdef TESTNET _res.nsaddr.SIN_PORT = htons(NAMESERVER_PORT);
_res.nsaddr.sin_port = htons(NAMESERVER_PORT + 10000);
#else
_res.nsaddr.sin_port = htons(NAMESERVER_PORT);
#endif
_res.nscount = 1; _res.nscount = 1;
/* Allow user to override the local domain definition */ /* Allow user to override the local domain definition */
if ((cp = getenv("LOCALDOMAIN")) != NULL) { if ((cp = getenv("LOCALDOMAIN")) != NULL)
{
(void)strncpy(_res.defdname, cp, sizeof(_res.defdname)); (void)strncpy(_res.defdname, cp, sizeof(_res.defdname));
haveenv++; haveenv++;
} }
#ifndef _WIN32 #ifndef _WIN32
if ((fp = fopen(_PATH_RESCONF, "r")) != NULL) { if ((fp = fopen(_PATH_RESCONF, "r")) != NULL)
/* read the config file */ {
while (fgets(buf, sizeof(buf), fp) != NULL) { /* read the config file */
/* read default domain name */ while (fgets(buf, sizeof(buf), fp) != NULL)
if (!strncmp(buf, "domain", sizeof("domain") - 1)) { {
if (haveenv) /* skip if have from environ */ /* read default domain name */
continue; if (!strncmp(buf, "domain", sizeof("domain") - 1))
cp = buf + sizeof("domain") - 1; {
while (*cp == ' ' || *cp == '\t') if (haveenv) /* skip if have from environ */
cp++; continue;
if ((*cp == '\0') || (*cp == '\n')) cp = buf + sizeof("domain") - 1;
continue; while (*cp == ' ' || *cp == '\t')
(void)strncpy(_res.defdname, cp, sizeof(_res.defdname) - 1); cp++;
if ((cp = index(_res.defdname, '\n')) != NULL) if ((*cp == '\0') || (*cp == '\n'))
*cp = '\0'; continue;
havesearch = 0;
continue; (void)strncpy(_res.defdname, cp,
sizeof(_res.defdname) - 1);
if ((cp = index(_res.defdname, '\n')) != NULL)
*cp = '\0';
havesearch = 0;
continue;
}
/* set search list */
if (!strncmp(buf, "search", sizeof("search") - 1))
{
if (haveenv) /* skip if have from environ */
continue;
cp = buf + sizeof("search") - 1;
while (*cp == ' ' || *cp == '\t')
cp++;
if ((*cp == '\0') || (*cp == '\n'))
continue;
(void)strncpy(_res.defdname, cp,
sizeof(_res.defdname) - 1);
if ((cp = index(_res.defdname, '\n')) != NULL)
*cp = '\0';
/*
* Set search list to be blank-separated strings
* on rest of line.
*/
cp = _res.defdname;
pp = _res.dnsrch;
*pp++ = cp;
for (n = 0; *cp && pp < _res.dnsrch + MAXDNSRCH;
cp++)
{
if (*cp == ' ' || *cp == '\t')
{
*cp = 0;
n = 1;
}
else if (n)
{
*pp++ = cp;
n = 0;
}
}
/* null terminate last domain if there are excess */
while (*cp != '\0' && *cp != ' ' && *cp != '\t')
cp++;
*cp = '\0';
*pp++ = 0;
havesearch = 1;
continue;
}
/* read nameservers to query */
if (!strncmp(buf, "nameserver",
sizeof("nameserver") - 1) && nserv < MAXNS)
{
cp = buf + sizeof("nameserver") - 1;
while (*cp == ' ' || *cp == '\t')
cp++;
if ((*cp == '\0') || (*cp == '\n'))
continue;
if ((_res.nsaddr_list[nserv].SIN_ADDR.S_ADDR =
inet_addr(cp)) == (unsigned)-1)
{
_res.nsaddr_list[nserv].SIN_ADDR.S_ADDR
= INADDR_ANY;
continue;
}
_res.nsaddr_list[nserv].SIN_FAMILY = AFINET;
_res.nsaddr_list[nserv].SIN_PORT =
htons(NAMESERVER_PORT);
nserv++;
continue;
}
/* read service order */
if (!strncmp(buf, "order", sizeof("order") - 1))
{
cp = buf + sizeof("order") - 1;
while (*cp == ' ' || *cp == '\t')
cp++;
if ((*cp == '\0') || (*cp == '\n'))
continue;
norder = 0;
do
{
if ((dp = index(cp, ',')) != NULL)
*dp = '\0';
if (norder >= MAXSERVICES)
continue;
if (!strncmp(cp, "bind",
sizeof("bind") - 1))
_res.order[norder++] =
RES_SERVICE_BIND;
else if (!strncmp(cp, "local",
sizeof("local") - 1))
_res.order[norder++] =
RES_SERVICE_LOCAL;
cp = dp + 1;
}
while (dp != NULL);
_res.order[norder] = RES_SERVICE_NONE;
continue;
}
} }
/* set search list */ if (nserv > 1)
if (!strncmp(buf, "search", sizeof("search") - 1)) { _res.nscount = nserv;
if (haveenv) /* skip if have from environ */ (void)fclose(fp);
continue;
cp = buf + sizeof("search") - 1;
while (*cp == ' ' || *cp == '\t')
cp++;
if ((*cp == '\0') || (*cp == '\n'))
continue;
(void)strncpy(_res.defdname, cp, sizeof(_res.defdname) - 1);
if ((cp = index(_res.defdname, '\n')) != NULL)
*cp = '\0';
/*
* Set search list to be blank-separated strings
* on rest of line.
*/
cp = _res.defdname;
pp = _res.dnsrch;
*pp++ = cp;
for (n = 0; *cp && pp < _res.dnsrch + MAXDNSRCH; cp++) {
if (*cp == ' ' || *cp == '\t') {
*cp = 0;
n = 1;
} else if (n) {
*pp++ = cp;
n = 0;
}
}
/* null terminate last domain if there are excess */
while (*cp != '\0' && *cp != ' ' && *cp != '\t')
cp++;
*cp = '\0';
*pp++ = 0;
havesearch = 1;
continue;
}
/* read nameservers to query */
if (!strncmp(buf, "nameserver", sizeof("nameserver") - 1) &&
nserv < MAXNS) {
cp = buf + sizeof("nameserver") - 1;
while (*cp == ' ' || *cp == '\t')
cp++;
if ((*cp == '\0') || (*cp == '\n'))
continue;
if ((_res.nsaddr_list[nserv].sin_addr.s_addr =
inet_addr(cp)) == (unsigned)-1) {
_res.nsaddr_list[nserv].sin_addr.s_addr
= INADDR_ANY;
continue;
}
_res.nsaddr_list[nserv].sin_family = AF_INET;
#ifdef TESTNET
_res.nsaddr_list[nserv].sin_port = htons(NAMESERVER_PORT +
10000);
#else
_res.nsaddr_list[nserv].sin_port = htons(NAMESERVER_PORT);
#endif
nserv++;
continue;
}
/* read service order */
if (!strncmp(buf, "order", sizeof("order") - 1)) {
cp = buf + sizeof("order") - 1;
while (*cp == ' ' || *cp == '\t')
cp++;
if ((*cp == '\0') || (*cp == '\n'))
continue;
norder = 0;
do {
if ((dp = index(cp, ',')) != NULL)
*dp = '\0';
if (norder >= MAXSERVICES)
continue;
if (!strncmp(cp, "bind", sizeof("bind") - 1))
_res.order[norder++] = RES_SERVICE_BIND;
else if (!strncmp(cp, "local", sizeof("local") - 1))
_res.order[norder++] = RES_SERVICE_LOCAL;
cp = dp + 1;
} while (dp != NULL);
_res.order[norder] = RES_SERVICE_NONE;
continue;
}
}
if (nserv > 1)
_res.nscount = nserv;
(void) fclose(fp);
} }
#endif /*_WIN32*/ #endif /*_WIN32*/
if (_res.defdname[0] == 0) { if (_res.defdname[0] == 0)
{
if (gethostname(buf, sizeof(_res.defdname)) == 0 && if (gethostname(buf, sizeof(_res.defdname)) == 0 &&
(cp = index(buf, '.'))) (cp = index(buf, '.')))
(void)strcpy(_res.defdname, cp + 1); (void)strcpy(_res.defdname, cp + 1);
} }
/* find components of local domain that might be searched */ /* find components of local domain that might be searched */
if (havesearch == 0) { if (havesearch == 0)
{
pp = _res.dnsrch; pp = _res.dnsrch;
*pp++ = _res.defdname; *pp++ = _res.defdname;
for (cp = _res.defdname, n = 0; *cp; cp++) for (cp = _res.defdname, n = 0; *cp; cp++)
@@ -209,14 +227,16 @@ res_init()
n++; n++;
cp = _res.defdname; cp = _res.defdname;
for (; n >= LOCALDOMAINPARTS && pp < _res.dnsrch + MAXDFLSRCH; for (; n >= LOCALDOMAINPARTS && pp < _res.dnsrch + MAXDFLSRCH;
n--) { n--)
{
cp = index(cp, '.'); cp = index(cp, '.');
*pp++ = ++cp; *pp++ = ++cp;
} }
*pp++ = 0; *pp++ = 0;
} }
/* default search order to bind only */ /* default search order to bind only */
if (norder == 0) { if (norder == 0)
{
_res.order[0] = RES_SERVICE_BIND; _res.order[0] = RES_SERVICE_BIND;
_res.order[1] = RES_SERVICE_NONE; _res.order[1] = RES_SERVICE_NONE;
} }
BIN
View File
Binary file not shown.
+11 -10
View File
@@ -14,21 +14,22 @@ dn_skipname(comp_dn, eom)
register int n; register int n;
cp = comp_dn; cp = comp_dn;
while (cp < eom && (n = *cp++)) { while (cp < eom && (n = *cp++))
{
/* /*
* check for indirection * check for indirection
*/ */
switch (n & INDIR_MASK) { switch (n & INDIR_MASK)
case 0: /* normal case, n == len */ {
cp += n; case 0: /* normal case, n == len */
continue; cp += n;
default: /* illegal type */ continue;
return (-1); default: /* illegal type */
case INDIR_MASK: /* indirection */ return (-1);
cp++; case INDIR_MASK: /* indirection */
cp++;
} }
break; break;
} }
return (cp - comp_dn); return (cp - comp_dn);
} }
+89 -83
View File
@@ -1,5 +1,6 @@
/************************************************************************ /************************************************************************
* IRC - Internet Relay Chat, ircd/s_auth.c /************************************************************************
* Unreal Internet Relay Chat Daemon, src/s_auth.c
* Copyright (C) 1992 Darren Reed * Copyright (C) 1992 Darren Reed
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@@ -18,7 +19,7 @@
*/ */
#ifndef lint #ifndef lint
static char sccsid[] = "@(#)s_auth.c 1.18 4/18/94 (C) 1992 Darren Reed"; static char sccsid[] = "@(#)s_auth.c 1.18 4/18/94 (C) 1992 Darren Reed";
#endif #endif
#include "struct.h" #include "struct.h"
@@ -38,7 +39,7 @@ static char sccsid[] = "@(#)s_auth.c 1.18 4/18/94 (C) 1992 Darren Reed";
#include <io.h> #include <io.h>
#endif #endif
#include <fcntl.h> #include <fcntl.h>
#include "sock.h" /* If FD_ZERO isn't define up to this point, */ #include "sock.h" /* If FD_ZERO isn't define up to this point, */
/* define it (BSD4.2 needs this) */ /* define it (BSD4.2 needs this) */
#include "h.h" #include "h.h"
@@ -52,68 +53,71 @@ ID_CVS("$Id$");
* identifing process fail, it is aborted and the user is given a username * identifing process fail, it is aborted and the user is given a username
* of "unknown". * of "unknown".
*/ */
void start_auth(cptr) void start_auth(cptr)
Reg1 aClient *cptr; aClient *cptr;
{ {
struct sockaddr_in sock; struct SOCKADDR_IN sock;
int addrlen = sizeof(struct sockaddr_in); int addrlen = sizeof(struct SOCKADDR_IN);
Debug((DEBUG_NOTICE,"start_auth(%x) fd %d status %d", #ifdef NO_IDENT_CHECKING
cptr, cptr->fd, cptr->status)); cptr->flags &= ~(FLAGS_WRAUTH | FLAGS_AUTH);
if ((cptr->authfd = socket(AF_INET, SOCK_STREAM, 0)) == -1) return;
{ #endif
Debug((DEBUG_NOTICE, "start_auth(%x) fd %d status %d",
cptr, cptr->fd, cptr->status));
if ((cptr->authfd = socket(AFINET, SOCK_STREAM, 0)) == -1)
{
#ifdef USE_SYSLOG #ifdef USE_SYSLOG
syslog(LOG_ERR, "Unable to create auth socket for %s:%m", syslog(LOG_ERR, "Unable to create auth socket for %s:%m",
get_client_name(cptr,TRUE)); get_client_name(cptr, TRUE));
#endif #endif
Debug((DEBUG_ERROR, "Unable to create auth socket for %s:%s", Debug((DEBUG_ERROR, "Unable to create auth socket for %s:%s",
get_client_name(cptr, TRUE), get_client_name(cptr, TRUE), strerror(get_sockerr(cptr))));
strerror(get_sockerr(cptr))));
if (!DoingDNS(cptr)) if (!DoingDNS(cptr))
SetAccess(cptr); SetAccess(cptr);
ircstp->is_abad++; ircstp->is_abad++;
return; return;
} }
#ifndef _WIN32 #ifndef _WIN32
if (cptr->authfd >= (MAXCONNECTIONS - 3)) if (cptr->authfd >= (MAXCONNECTIONS - 3))
{ {
sendto_ops("Can't allocate fd for auth on %s", sendto_ops("Can't allocate fd for auth on %s",
get_client_name(cptr, TRUE)); get_client_name(cptr, TRUE));
(void)close(cptr->authfd); (void)close(cptr->authfd);
return; return;
} }
#endif #endif
#ifdef SHOWCONNECTINFO #ifdef SHOWCONNECTINFO
#ifndef _WIN32 #ifndef _WIN32
write(cptr->fd, REPORT_DO_ID, R_do_id); write(cptr->fd, REPORT_DO_ID, R_do_id);
#else #else
send(cptr->fd, REPORT_DO_ID, R_do_id,0); send(cptr->fd, REPORT_DO_ID, R_do_id, 0);
#endif #endif
#endif #endif
set_non_blocking(cptr->authfd, cptr); set_non_blocking(cptr->authfd, cptr);
getsockname(cptr->fd, (struct sockaddr *)&sock, &addrlen); getsockname(cptr->fd, (struct SOCKADDR *)&sock, &addrlen);
sock.sin_port = 0; sock.SIN_PORT = 0;
sock.sin_family = AF_INET; /* redundant? */ sock.SIN_FAMILY = AFINET; /* redundant? */
(void)bind(cptr->authfd, (struct sockaddr *)&sock, sizeof(sock)); (void)bind(cptr->authfd, (struct SOCKADDR *)&sock, sizeof(sock));
bcopy((char *)&cptr->ip, (char *)&sock.sin_addr, bcopy((char *)&cptr->ip, (char *)&sock.SIN_ADDR,
sizeof(struct in_addr)); sizeof(struct IN_ADDR));
sock.sin_port = htons(113); sock.SIN_PORT = htons(113);
sock.sin_family = AF_INET; sock.SIN_FAMILY = AFINET;
if (connect(cptr->authfd, (struct sockaddr *)&sock, if (connect(cptr->authfd, (struct SOCKADDR *)&sock,
#ifndef _WIN32 #ifndef _WIN32
sizeof(sock)) == -1 && errno != EINPROGRESS) sizeof(sock)) == -1 && errno != EINPROGRESS)
#else #else
sizeof(sock)) == -1 && (WSAGetLastError() != sizeof(sock)) == -1 && (WSAGetLastError() !=
WSAEINPROGRESS && WSAGetLastError() != WSAEWOULDBLOCK)) WSAEINPROGRESS && WSAGetLastError() != WSAEWOULDBLOCK))
#endif #endif
{ {
ircstp->is_abad++; ircstp->is_abad++;
/* /*
* No error report from this... * No error report from this...
@@ -134,8 +138,8 @@ Reg1 aClient *cptr;
#endif #endif
#endif #endif
return; return;
} }
cptr->flags |= (FLAGS_WRAUTH|FLAGS_AUTH); cptr->flags |= (FLAGS_WRAUTH | FLAGS_AUTH);
if (cptr->authfd > highest_fd) if (cptr->authfd > highest_fd)
highest_fd = cptr->authfd; highest_fd = cptr->authfd;
return; return;
@@ -150,39 +154,40 @@ Reg1 aClient *cptr;
* problem since the socket should have a write buffer far greater than * problem since the socket should have a write buffer far greater than
* this message to store it in should problems arise. -avalon * this message to store it in should problems arise. -avalon
*/ */
void send_authports(cptr) void send_authports(cptr)
aClient *cptr; aClient *cptr;
{ {
struct sockaddr_in us, them; struct SOCKADDR_IN us, them;
char authbuf[32]; char authbuf[32];
int ulen, tlen; int ulen, tlen;
Debug((DEBUG_NOTICE,"write_authports(%x) fd %d authfd %d stat %d", Debug((DEBUG_NOTICE, "write_authports(%x) fd %d authfd %d stat %d",
cptr, cptr->fd, cptr->authfd, cptr->status)); cptr, cptr->fd, cptr->authfd, cptr->status));
tlen = ulen = sizeof(us); tlen = ulen = sizeof(us);
if (getsockname(cptr->fd, (struct sockaddr *)&us, &ulen) || if (getsockname(cptr->fd, (struct SOCKADDR *)&us, &ulen) ||
getpeername(cptr->fd, (struct sockaddr *)&them, &tlen)) getpeername(cptr->fd, (struct SOCKADDR *)&them, &tlen))
{ {
#ifdef USE_SYSLOG #ifdef USE_SYSLOG
syslog(LOG_ERR, "auth get{sock,peer}name error for %s:%m", syslog(LOG_ERR, "auth get{sock,peer}name error for %s:%m",
get_client_name(cptr, TRUE)); get_client_name(cptr, TRUE));
#endif #endif
goto authsenderr; goto authsenderr;
} }
(void)sprintf(authbuf, "%u , %u\r\n", (void)ircsprintf(authbuf, "%u , %u\r\n",
(unsigned int)ntohs(them.sin_port), (unsigned int)ntohs(them.SIN_PORT),
(unsigned int)ntohs(us.sin_port)); (unsigned int)ntohs(us.SIN_PORT));
Debug((DEBUG_SEND, "sending [%s] to auth port %s.113", Debug((DEBUG_SEND, "sending [%s] to auth port %s.113",
authbuf, inetntoa((char *)&them.sin_addr))); authbuf, inetntoa((char *)&them.SIN_ADDR)));
#ifndef _WIN32 #ifndef _WIN32
if (write(cptr->authfd, authbuf, strlen(authbuf)) != strlen(authbuf)) if (write(cptr->authfd, authbuf, strlen(authbuf)) != strlen(authbuf))
#else #else
if (send(cptr->authfd, authbuf, strlen(authbuf), 0) != (int)strlen(authbuf)) if (send(cptr->authfd, authbuf, strlen(authbuf),
0) != (int)strlen(authbuf))
#endif #endif
{ {
authsenderr: authsenderr:
ircstp->is_abad++; ircstp->is_abad++;
#ifndef _WIN32 #ifndef _WIN32
(void)close(cptr->authfd); (void)close(cptr->authfd);
@@ -203,7 +208,7 @@ authsenderr:
#endif #endif
if (!DoingDNS(cptr)) if (!DoingDNS(cptr))
SetAccess(cptr); SetAccess(cptr);
} }
cptr->flags &= ~FLAGS_WRAUTH; cptr->flags &= ~FLAGS_WRAUTH;
return; return;
} }
@@ -215,17 +220,17 @@ authsenderr:
* The actual read processijng here is pretty weak - no handling of the reply * The actual read processijng here is pretty weak - no handling of the reply
* if it is fragmented by IP. * if it is fragmented by IP.
*/ */
void read_authports(cptr) void read_authports(cptr)
Reg1 aClient *cptr; aClient *cptr;
{ {
Reg1 char *s, *t; char *s, *t;
Reg2 int len; int len;
char ruser[USERLEN+1], system[8]; char ruser[USERLEN + 1], system[8];
u_short remp = 0, locp = 0; u_short remp = 0, locp = 0;
*system = *ruser = '\0'; *system = *ruser = '\0';
Debug((DEBUG_NOTICE,"read_authports(%x) fd %d authfd %d stat %d", Debug((DEBUG_NOTICE, "read_authports(%x) fd %d authfd %d stat %d",
cptr, cptr->fd, cptr->authfd, cptr->status)); cptr, cptr->fd, cptr->authfd, cptr->status));
/* /*
* Nasty. Cant allow any other reads from client fd while we're * Nasty. Cant allow any other reads from client fd while we're
* waiting on the authfd to return a full valid string. Use the * waiting on the authfd to return a full valid string. Use the
@@ -235,41 +240,42 @@ Reg1 aClient *cptr;
*/ */
#ifndef _WIN32 #ifndef _WIN32
if ((len = read(cptr->authfd, cptr->buffer + cptr->count, if ((len = read(cptr->authfd, cptr->buffer + cptr->count,
sizeof(cptr->buffer) - 1 - cptr->count)) >= 0) sizeof(cptr->buffer) - 1 - cptr->count)) >= 0)
#else #else
if ((len = recv(cptr->authfd, cptr->buffer + cptr->count, if ((len = recv(cptr->authfd, cptr->buffer + cptr->count,
sizeof(cptr->buffer) - 1 - cptr->count, 0)) >= 0) sizeof(cptr->buffer) - 1 - cptr->count, 0)) >= 0)
#endif #endif
{ {
cptr->count += len; cptr->count += len;
cptr->buffer[cptr->count] = '\0'; cptr->buffer[cptr->count] = '\0';
} }
cptr->lasttime = TStime(); cptr->lasttime = TStime();
if ((len > 0) && (cptr->count != (sizeof(cptr->buffer) - 1)) && if ((len > 0) && (cptr->count != (sizeof(cptr->buffer) - 1)) &&
(sscanf(cptr->buffer, "%hd , %hd : USERID : %*[^:]: %10s", (sscanf(cptr->buffer, "%hd , %hd : USERID : %*[^:]: %10s",
&remp, &locp, ruser) == 3)) &remp, &locp, ruser) == 3))
{ {
s = rindex(cptr->buffer, ':'); s = rindex(cptr->buffer, ':');
*s++ = '\0'; *s++ = '\0';
for (t = (rindex(cptr->buffer, ':') + 1); *t; t++) for (t = (rindex(cptr->buffer, ':') + 1); *t; t++)
if (!isspace(*t)) if (!isspace(*t))
break; break;
strncpyzt(system, t, sizeof(system)); strncpyzt(system, t, sizeof(system));
for (t = ruser; *s && *s != '@' && (t < ruser + sizeof(ruser)); s++) for (t = ruser; *s && *s != '@' && (t < ruser + sizeof(ruser));
s++)
if (!isspace(*s) && *s != ':') if (!isspace(*s) && *s != ':')
*t++ = *s; *t++ = *s;
*t = '\0'; *t = '\0';
Debug((DEBUG_INFO,"auth reply ok [%s] [%s]", system, ruser)); Debug((DEBUG_INFO, "auth reply ok [%s] [%s]", system, ruser));
} }
else if (len != 0) else if (len != 0)
{ {
if (!index(cptr->buffer, '\n') && !index(cptr->buffer, '\r')) if (!index(cptr->buffer, '\n') && !index(cptr->buffer, '\r'))
return; return;
Debug((DEBUG_ERROR,"local %d remote %d", locp, remp)); Debug((DEBUG_ERROR, "local %d remote %d", locp, remp));
Debug((DEBUG_ERROR,"bad auth reply in [%s]", cptr->buffer)); Debug((DEBUG_ERROR, "bad auth reply in [%s]", cptr->buffer));
*ruser = '\0'; *ruser = '\0';
} }
#ifndef _WIN32 #ifndef _WIN32
(void)close(cptr->authfd); (void)close(cptr->authfd);
#else #else
@@ -284,7 +290,7 @@ Reg1 aClient *cptr;
if (!DoingDNS(cptr)) if (!DoingDNS(cptr))
SetAccess(cptr); SetAccess(cptr);
if (len > 0) if (len > 0)
Debug((DEBUG_INFO,"ident reply: [%s]", cptr->buffer)); Debug((DEBUG_INFO, "ident reply: [%s]", cptr->buffer));
#ifdef SHOWCONNECTINFO #ifdef SHOWCONNECTINFO
#ifndef _WIN32 #ifndef _WIN32
@@ -295,14 +301,14 @@ Reg1 aClient *cptr;
#endif #endif
if (!locp || !remp || !*ruser) if (!locp || !remp || !*ruser)
{ {
ircstp->is_abad++; ircstp->is_abad++;
return; return;
} }
ircstp->is_asuc++; ircstp->is_asuc++;
strncpyzt(cptr->username, ruser, USERLEN+1); strncpyzt(cptr->username, ruser, USERLEN + 1);
/* if (strncmp(system, "OTHER", 5)) /* if (strncmp(system, "OTHER", 5))
*/ cptr->flags |= FLAGS_GOTID; */ cptr->flags |= FLAGS_GOTID;
Debug((DEBUG_INFO, "got username [%s]", ruser)); Debug((DEBUG_INFO, "got username [%s]", ruser));
return; return;
} }
+1627 -1061
View File
File diff suppressed because it is too large Load Diff
+1553 -1405
View File
File diff suppressed because it is too large Load Diff
+210 -221
View File
@@ -1,5 +1,6 @@
/************************************************************************ /************************************************************************
* IRC - Internet Relay Chat, ircd/s_debug.c /************************************************************************
* Unreal Internet Relay Chat Daemon, src/s_debug.c
* Copyright (C) 1990 Jarkko Oikarinen and * Copyright (C) 1990 Jarkko Oikarinen and
* University of Oulu, Computing Center * University of Oulu, Computing Center
* *
@@ -20,7 +21,8 @@
#ifndef lint #ifndef lint
static char sccsid[] = "@(#)s_debug.c 2.30 1/3/94 (C) 1988 University of Oulu, \ static char sccsid[] =
"@(#)s_debug.c 2.30 1/3/94 (C) 1988 University of Oulu, \
Computing Center and Jarkko Oikarinen"; Computing Center and Jarkko Oikarinen";
#endif #endif
@@ -28,92 +30,84 @@ Computing Center and Jarkko Oikarinen";
/* /*
* Option string. Must be before #ifdef DEBUGMODE. * Option string. Must be before #ifdef DEBUGMODE.
*/ */
char serveropts[] = { char serveropts[] = {
#ifdef SENDQ_ALWAYS #ifdef SENDQ_ALWAYS
'A', 'A',
#endif #endif
#ifdef CHROOTDIR #ifdef CHROOTDIR
'c', 'c',
#endif #endif
#ifdef CMDLINE_CONFIG #ifdef CMDLINE_CONFIG
'C', 'C',
#endif #endif
#ifdef DO_ID #ifdef DO_ID
'd', 'd',
#endif #endif
#ifdef DEBUGMODE #ifdef DEBUGMODE
'D', 'D',
#endif
#ifdef NOTE_FORWARDER
'f',
#endif #endif
#ifndef NO_FDLIST #ifndef NO_FDLIST
'F', 'F',
#endif #endif
#ifdef HUB #ifdef HUB
'h', 'h',
#endif #endif
#ifdef SHOW_INVISIBLE_LUSERS #ifdef SHOW_INVISIBLE_LUSERS
'i', 'i',
#endif #endif
#ifndef NO_DEFAULT_INVISIBLE #ifndef NO_DEFAULT_INVISIBLE
'I', 'I',
#endif #endif
#ifdef LEAST_IDLE #ifdef LEAST_IDLE
'L', 'L',
#endif
#ifdef M4_PREPROC
'm',
#endif #endif
#ifdef IDLE_FROM_MSG #ifdef IDLE_FROM_MSG
'M', 'M',
#endif #endif
#ifdef CRYPT_OPER_PASSWORD #ifdef CRYPT_OPER_PASSWORD
'p', 'p',
#endif #endif
#ifdef CRYPT_LINK_PASSWORD #ifdef CRYPT_LINK_PASSWORD
'P', 'P',
#endif #endif
#ifdef NOSPOOF #ifdef NOSPOOF
'n', 'n',
#endif #endif
#ifdef NPATH #ifdef NPATH
'N', 'N',
#endif
#ifdef SCRIPTINIFIX
's',
#endif #endif
#ifdef ENABLE_SUMMON #ifdef ENABLE_SUMMON
'S', 'S',
#endif
#ifdef IRCII_KLUDGE
'u',
#endif #endif
#ifdef ENABLE_USERS #ifdef ENABLE_USERS
'U', 'U',
#endif #endif
#ifdef VALLOC #ifdef VALLOC
'V', 'V',
#endif #endif
#ifdef REMOVE_ADVERTISING #ifdef REMOVE_ADVERTISING
'R', 'R',
#endif #endif
#ifdef _WIN32 #ifdef _WIN32
'W', 'W',
#endif #endif
#ifdef USE_SYSLOG #ifdef USE_SYSLOG
'Y', 'Y',
#endif
#ifdef V28PlusOnly
'8',
#endif
#ifdef SCRIPTINIFIX
'S',
#endif #endif
#ifdef OPER_NO_HIDING #ifdef OPER_NO_HIDING
'H', 'H',
#endif #endif
'\0'}; #ifdef NO_IDENT_CHECKING
'K',
#endif
#ifdef INET6
'6',
#endif
#ifdef STRIPBADWORDS
'X',
#endif
'\0'
};
#include "numeric.h" #include "numeric.h"
#include "common.h" #include "common.h"
@@ -135,7 +129,7 @@ char serveropts[] = {
# define getrusage(a,b) syscall(SYS_GETRUSAGE, a, b) # define getrusage(a,b) syscall(SYS_GETRUSAGE, a, b)
#endif #endif
#ifdef GETRUSAGE_2 #ifdef GETRUSAGE_2
# ifdef SOL20 # ifdef _SOLARIS
# include <sys/time.h> # include <sys/time.h>
# ifdef RUSAGEH # ifdef RUSAGEH
# include <sys/rusage.h> # include <sys/rusage.h>
@@ -166,60 +160,60 @@ char serveropts[] = {
ID_CVS("$Id$"); ID_CVS("$Id$");
#ifdef DEBUGMODE #ifdef DEBUGMODE
static char debugbuf[1024]; static char debugbuf[1024];
#ifndef USE_VARARGS #ifndef USE_VARARGS
/*VARARGS2*/ /*VARARGS2*/
void debug(level, form, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10) void debug(level, form, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10)
int level; int level;
char *form, *p1, *p2, *p3, *p4, *p5, *p6, *p7, *p8, *p9, *p10; char *form, *p1, *p2, *p3, *p4, *p5, *p6, *p7, *p8, *p9, *p10;
{ {
# ifndef _WIN32 # ifndef _WIN32
int err = errno; int err = errno;
# else # else
int err = WSAGetLastError(); int err = WSAGetLastError();
# endif # endif
#else #else
void debug(level, form, va_alist) void debug(level, form, va_alist)
int level; int level;
char *form; char *form;
va_dcl va_dcl
{ {
va_list vl; va_list vl;
# ifndef _WIN32 # ifndef _WIN32
int err = errno; int err = errno;
# else # else
int err = WSAGetLastError(); int err = WSAGetLastError();
# endif # endif
va_start(vl); va_start(vl);
#endif #endif
if ((debuglevel >= 0) && (level <= debuglevel)) if ((debuglevel >= 0) && (level <= debuglevel))
{ {
#ifndef USE_VARARGS #ifndef USE_VARARGS
(void)sprintf(debugbuf, form, (void)ircsprintf(debugbuf, form,
p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); p1, p2, p3, p4, p5, p6, p7, p8, p9, p10);
#else #else
(void)vsprintf(debugbuf, form, vl); (void)ircvsprintf(debugbuf, form, vl);
#endif #endif
#ifndef _WIN32 #ifndef _WIN32
if (local[2]) if (local[2])
{ {
local[2]->sendM++; local[2]->sendM++;
local[2]->sendB += strlen(debugbuf); local[2]->sendB += strlen(debugbuf);
} }
(void)fprintf(stderr, "%s", debugbuf); (void)fprintf(stderr, "%s", debugbuf);
(void)fputc('\n', stderr); (void)fputc('\n', stderr);
} }
errno = err; errno = err;
#else #else
strcat(debugbuf, "\r"); strcat(debugbuf, "\r");
#ifndef _WIN32GUI #ifndef _WIN32GUI
Cio_Puts(hCio, debugbuf, strlen(debugbuf)); Cio_Puts(hCio, debugbuf, strlen(debugbuf));
#endif #endif
} }
WSASetLastError(err); WSASetLastError(err);
#endif #endif
} }
@@ -231,21 +225,21 @@ va_dcl
* different field names for "struct rusage". * different field names for "struct rusage".
* -avalon * -avalon
*/ */
void send_usage(cptr, nick) void send_usage(cptr, nick)
aClient *cptr; aClient *cptr;
char *nick; char *nick;
{ {
#ifdef GETRUSAGE_2 #ifdef GETRUSAGE_2
struct rusage rus; struct rusage rus;
time_t secs, rup; time_t secs, rup;
#ifdef hz #ifdef hz
# define hzz hz # define hzz hz
#else #else
# ifdef HZ # ifdef HZ
# define hzz HZ # define hzz HZ
# else # else
int hzz = 1; int hzz = 1;
# ifdef HPUX # ifdef HPUX
hzz = (int)sysconf(_SC_CLK_TCK); hzz = (int)sysconf(_SC_CLK_TCK);
# endif # endif
@@ -253,45 +247,44 @@ char *nick;
#endif #endif
if (getrusage(RUSAGE_SELF, &rus) == -1) if (getrusage(RUSAGE_SELF, &rus) == -1)
{ {
#if !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__APPLE__) #if !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__APPLE__)
/* extern char *sys_errlist[]; */ /* extern char *sys_errlist[]; */
#endif #endif
sendto_one(cptr,":%s NOTICE %s :Getruseage error: %s.", sendto_one(cptr, ":%s NOTICE %s :Getruseage error: %s.",
me.name, nick, sys_errlist[errno]); me.name, nick, sys_errlist[errno]);
return; return;
} }
secs = rus.ru_utime.tv_sec + rus.ru_stime.tv_sec; secs = rus.ru_utime.tv_sec + rus.ru_stime.tv_sec;
rup = time(NULL) - me.since; rup = time(NULL) - me.since;
if (secs == 0) if (secs == 0)
secs = 1; secs = 1;
sendto_one(cptr, sendto_one(cptr,
":%s %d %s :CPU Secs %d:%d User %d:%d System %d:%d", ":%s %d %s :CPU Secs %d:%d User %d:%d System %d:%d",
me.name, RPL_STATSDEBUG, nick, secs/60, secs%60, me.name, RPL_STATSDEBUG, nick, secs / 60, secs % 60,
rus.ru_utime.tv_sec/60, rus.ru_utime.tv_sec%60, rus.ru_utime.tv_sec / 60, rus.ru_utime.tv_sec % 60,
rus.ru_stime.tv_sec/60, rus.ru_stime.tv_sec%60); rus.ru_stime.tv_sec / 60, rus.ru_stime.tv_sec % 60);
sendto_one(cptr, ":%s %d %s :RSS %d ShMem %d Data %d Stack %d", sendto_one(cptr, ":%s %d %s :RSS %d ShMem %d Data %d Stack %d",
me.name, RPL_STATSDEBUG, nick, rus.ru_maxrss, me.name, RPL_STATSDEBUG, nick, rus.ru_maxrss,
rus.ru_ixrss / (rup * hzz), rus.ru_idrss / (rup * hzz), rus.ru_ixrss / (rup * hzz), rus.ru_idrss / (rup * hzz),
rus.ru_isrss / (rup * hzz)); rus.ru_isrss / (rup * hzz));
sendto_one(cptr, ":%s %d %s :Swaps %d Reclaims %d Faults %d", sendto_one(cptr, ":%s %d %s :Swaps %d Reclaims %d Faults %d",
me.name, RPL_STATSDEBUG, nick, rus.ru_nswap, me.name, RPL_STATSDEBUG, nick, rus.ru_nswap,
rus.ru_minflt, rus.ru_majflt); rus.ru_minflt, rus.ru_majflt);
sendto_one(cptr, ":%s %d %s :Block in %d out %d", sendto_one(cptr, ":%s %d %s :Block in %d out %d",
me.name, RPL_STATSDEBUG, nick, rus.ru_inblock, me.name, RPL_STATSDEBUG, nick, rus.ru_inblock, rus.ru_oublock);
rus.ru_oublock);
sendto_one(cptr, ":%s %d %s :Msg Rcv %d Send %d", sendto_one(cptr, ":%s %d %s :Msg Rcv %d Send %d",
me.name, RPL_STATSDEBUG, nick, rus.ru_msgrcv, rus.ru_msgsnd); me.name, RPL_STATSDEBUG, nick, rus.ru_msgrcv, rus.ru_msgsnd);
sendto_one(cptr, ":%s %d %s :Signals %d Context Vol. %d Invol %d", sendto_one(cptr, ":%s %d %s :Signals %d Context Vol. %d Invol %d",
me.name, RPL_STATSDEBUG, nick, rus.ru_nsignals, me.name, RPL_STATSDEBUG, nick, rus.ru_nsignals,
rus.ru_nvcsw, rus.ru_nivcsw); rus.ru_nvcsw, rus.ru_nivcsw);
#else #else
# ifdef TIMES_2 # ifdef TIMES_2
struct tms tmsbuf; struct tms tmsbuf;
time_t secs, mins; time_t secs, mins;
int hzz = 1, ticpermin; int hzz = 1, ticpermin;
int umin, smin, usec, ssec; int umin, smin, usec, ssec;
# ifdef HPUX # ifdef HPUX
hzz = sysconf(_SC_CLK_TCK); hzz = sysconf(_SC_CLK_TCK);
@@ -299,57 +292,55 @@ char *nick;
ticpermin = hzz * 60; ticpermin = hzz * 60;
umin = tmsbuf.tms_utime / ticpermin; umin = tmsbuf.tms_utime / ticpermin;
usec = (tmsbuf.tms_utime%ticpermin)/(float)hzz; usec = (tmsbuf.tms_utime % ticpermin) / (float)hzz;
smin = tmsbuf.tms_stime / ticpermin; smin = tmsbuf.tms_stime / ticpermin;
ssec = (tmsbuf.tms_stime%ticpermin)/(float)hzz; ssec = (tmsbuf.tms_stime % ticpermin) / (float)hzz;
secs = usec + ssec; secs = usec + ssec;
mins = (secs/60) + umin + smin; mins = (secs / 60) + umin + smin;
secs %= hzz; secs %= hzz;
if (times(&tmsbuf) == -1) if (times(&tmsbuf) == -1)
{ {
sendto_one(cptr,":%s %d %s :times(2) error: %s.", sendto_one(cptr, ":%s %d %s :times(2) error: %s.",
# ifndef _WIN32 # ifndef _WIN32
me.name, RPL_STATSDEBUG, nick, strerror(errno)); me.name, RPL_STATSDEBUG, nick, strerror(errno));
# else # else
me.name, RPL_STATSDEBUG, nick, me.name, RPL_STATSDEBUG, nick, strerror(WSAGetLastError()));
strerror(WSAGetLastError()));
# endif # endif
return; return;
} }
secs = tmsbuf.tms_utime + tmsbuf.tms_stime; secs = tmsbuf.tms_utime + tmsbuf.tms_stime;
sendto_one(cptr, sendto_one(cptr,
":%s %d %s :CPU Secs %d:%d User %d:%d System %d:%d", ":%s %d %s :CPU Secs %d:%d User %d:%d System %d:%d",
me.name, RPL_STATSDEBUG, nick, mins, secs, umin, usec, me.name, RPL_STATSDEBUG, nick, mins, secs, umin, usec, smin, ssec);
smin, ssec);
# endif # endif
#endif #endif
sendto_one(cptr, ":%s %d %s :Reads %d Writes %d", sendto_one(cptr, ":%s %d %s :Reads %d Writes %d",
me.name, RPL_STATSDEBUG, nick, readcalls, writecalls); me.name, RPL_STATSDEBUG, nick, readcalls, writecalls);
sendto_one(cptr, ":%s %d %s :DBUF alloc %d blocks %d", sendto_one(cptr, ":%s %d %s :DBUF alloc %d blocks %d",
me.name, RPL_STATSDEBUG, nick, dbufalloc, dbufblocks); me.name, RPL_STATSDEBUG, nick, dbufalloc, dbufblocks);
sendto_one(cptr, sendto_one(cptr,
":%s %d %s :Writes: <0 %d 0 %d <16 %d <32 %d <64 %d", ":%s %d %s :Writes: <0 %d 0 %d <16 %d <32 %d <64 %d",
me.name, RPL_STATSDEBUG, nick, me.name, RPL_STATSDEBUG, nick,
writeb[0], writeb[1], writeb[2], writeb[3], writeb[4]); writeb[0], writeb[1], writeb[2], writeb[3], writeb[4]);
sendto_one(cptr, sendto_one(cptr,
":%s %d %s :<128 %d <256 %d <512 %d <1024 %d >1024 %d", ":%s %d %s :<128 %d <256 %d <512 %d <1024 %d >1024 %d",
me.name, RPL_STATSDEBUG, nick, me.name, RPL_STATSDEBUG, nick,
writeb[5], writeb[6], writeb[7], writeb[8], writeb[9]); writeb[5], writeb[6], writeb[7], writeb[8], writeb[9]);
return; return;
} }
#endif #endif
void count_memory(cptr, nick) void count_memory(cptr, nick)
aClient *cptr; aClient *cptr;
char *nick; char *nick;
{ {
extern aChannel *channel; extern aChannel *channel;
extern aClass *classes; extern aClass *classes;
extern aConfItem *conf; extern aConfItem *conf;
extern int flinks; extern int flinks;
extern Link *freelink; extern Link *freelink;
aClient *acptr; aClient *acptr;
Ban *ban; Ban *ban;
@@ -358,78 +349,75 @@ char *nick;
aConfItem *aconf; aConfItem *aconf;
aClass *cltmp; aClass *cltmp;
int lc = 0, /* local clients */ int lc = 0, /* local clients */
ch = 0, /* channels */ ch = 0, /* channels */
lcc = 0, /* local client conf links */ lcc = 0, /* local client conf links */
rc = 0, /* remote clients */ rc = 0, /* remote clients */
us = 0, /* user structs */ us = 0, /* user structs */
chu = 0, /* channel users */ chu = 0, /* channel users */
chi = 0, /* channel invites */ chi = 0, /* channel invites */
chb = 0, /* channel bans */ chb = 0, /* channel bans */
wwu = 0, /* whowas users */ wwu = 0, /* whowas users */
fl = 0, /* free links */ fl = 0, /* free links */
cl = 0, /* classes */ cl = 0, /* classes */
co = 0; /* conf lines */ co = 0; /* conf lines */
int usi = 0, /* users invited */ int usi = 0, /* users invited */
usc = 0, /* users in channels */ usc = 0, /* users in channels */
aw = 0, /* aways set */ aw = 0, /* aways set */
wwa = 0, /* whowas aways */ wwa = 0, /* whowas aways */
wlh = 0, /* watchlist headers */ wlh = 0, /* watchlist headers */
wle = 0; /* watchlist entries */ wle = 0; /* watchlist entries */
u_long chm = 0, /* memory used by channels */ u_long chm = 0, /* memory used by channels */
chbm = 0, /* memory used by channel bans */ chbm = 0, /* memory used by channel bans */
lcm = 0, /* memory used by local clients */ lcm = 0, /* memory used by local clients */
rcm = 0, /* memory used by remote clients */ rcm = 0, /* memory used by remote clients */
awm = 0, /* memory used by aways */ awm = 0, /* memory used by aways */
wwam = 0, /* whowas away memory used */ wwam = 0, /* whowas away memory used */
wwm = 0, /* whowas array memory used */ wwm = 0, /* whowas array memory used */
com = 0, /* memory used by conf lines */ com = 0, /* memory used by conf lines */
wlhm = 0, /* watchlist memory used */ wlhm = 0, /* watchlist memory used */
db = 0, /* memory used by dbufs */ db = 0, /* memory used by dbufs */
rm = 0, /* res memory used */ rm = 0, /* res memory used */
totcl = 0, totcl = 0, totch = 0, totww = 0, tot = 0;
totch = 0,
totww = 0,
tot = 0;
count_whowas_memory(&wwu, &wwa, &wwam); count_whowas_memory(&wwu, &wwam);
count_watch_memory(&wlh, &wlhm); count_watch_memory(&wlh, &wlhm);
wwm = sizeof(aName) * NICKNAMEHISTORYLENGTH; wwm = sizeof(aName) * NICKNAMEHISTORYLENGTH;
for (acptr = client; acptr; acptr = acptr->next) for (acptr = client; acptr; acptr = acptr->next)
{ {
if (MyConnect(acptr)) if (MyConnect(acptr))
{ {
lc++; lc++;
for (link = acptr->confs; link; link = link->next) for (link = acptr->confs; link; link = link->next)
lcc++; lcc++;
wle += acptr->notifies; wle += acptr->notifies;
} }
else else
rc++; rc++;
if (acptr->user) if (acptr->user)
{ {
us++; us++;
for (link = acptr->user->invited; link; for (link = acptr->user->invited; link;
link = link->next) link = link->next)
usi++; usi++;
for (link = acptr->user->channel; link; for (link = acptr->user->channel; link;
link = link->next) link = link->next)
usc++; usc++;
if (acptr->user->away) if (acptr->user->away)
{ {
aw++; aw++;
awm += (strlen(acptr->user->away)+1); awm += (strlen(acptr->user->away) + 1);
} }
} }
} }
lcm = lc * CLIENT_LOCAL_SIZE; lcm = lc * CLIENT_LOCAL_SIZE;
rcm = rc * CLIENT_REMOTE_SIZE; rcm = rc * CLIENT_REMOTE_SIZE;
for (chptr = channel; chptr; chptr = chptr->nextch) for (chptr = channel; chptr; chptr = chptr->nextch)
{ {
ch++; ch++;
chm += (strlen(chptr->chname) + sizeof(aChannel)); chm += (strlen(chptr->chname) + sizeof(aChannel));
for (link = chptr->members; link; link = link->next) for (link = chptr->members; link; link = link->next)
@@ -437,103 +425,104 @@ char *nick;
for (link = chptr->invites; link; link = link->next) for (link = chptr->invites; link; link = link->next)
chi++; chi++;
for (ban = chptr->banlist; ban; ban = ban->next) for (ban = chptr->banlist; ban; ban = ban->next)
{ {
chb++; chb++;
chbm += (strlen(ban->banstr)+1+ chbm += (strlen(ban->banstr) + 1 +
strlen(ban->who)+1+sizeof(Ban)); strlen(ban->who) + 1 + sizeof(Ban));
} }
} }
for (aconf = conf; aconf; aconf = aconf->next) for (aconf = conf; aconf; aconf = aconf->next)
{ {
co++; co++;
com += aconf->host ? strlen(aconf->host)+1 : 0; com += aconf->host ? strlen(aconf->host) + 1 : 0;
com += aconf->passwd ? strlen(aconf->passwd)+1 : 0; com += aconf->passwd ? strlen(aconf->passwd) + 1 : 0;
com += aconf->name ? strlen(aconf->name)+1 : 0; com += aconf->name ? strlen(aconf->name) + 1 : 0;
com += sizeof(aConfItem); com += sizeof(aConfItem);
} }
for (cltmp = classes; cltmp; cltmp = cltmp->next) for (cltmp = classes; cltmp; cltmp = cltmp->next)
cl++; cl++;
sendto_one(cptr, ":%s %d %s :Client Local %d(%d) Remote %d(%d)", sendto_one(cptr, ":%s %d %s :Client Local %d(%d) Remote %d(%d)",
me.name, RPL_STATSDEBUG, nick, lc, lcm, rc, rcm); me.name, RPL_STATSDEBUG, nick, lc, lcm, rc, rcm);
sendto_one(cptr, ":%s %d %s :Users %d(%d) Invites %d(%d)", sendto_one(cptr, ":%s %d %s :Users %d(%d) Invites %d(%d)",
me.name, RPL_STATSDEBUG, nick, us, us*sizeof(anUser), usi, me.name, RPL_STATSDEBUG, nick, us, us * sizeof(anUser), usi,
usi * sizeof(Link)); usi * sizeof(Link));
sendto_one(cptr, ":%s %d %s :User channels %d(%d) Aways %d(%d)", sendto_one(cptr, ":%s %d %s :User channels %d(%d) Aways %d(%d)",
me.name, RPL_STATSDEBUG, nick, usc, usc*sizeof(Link), me.name, RPL_STATSDEBUG, nick, usc, usc * sizeof(Link), aw, awm);
aw, awm);
sendto_one(cptr, ":%s %d %s :WATCH headers %d(%d) entries %d(%d)", sendto_one(cptr, ":%s %d %s :WATCH headers %d(%d) entries %d(%d)",
me.name, RPL_STATSDEBUG, nick, wlh, wlhm, me.name, RPL_STATSDEBUG, nick, wlh, wlhm, wle, wle * sizeof(Link));
wle, wle*sizeof(Link));
sendto_one(cptr, ":%s %d %s :Attached confs %d(%d)", sendto_one(cptr, ":%s %d %s :Attached confs %d(%d)",
me.name, RPL_STATSDEBUG, nick, lcc, lcc*sizeof(Link)); me.name, RPL_STATSDEBUG, nick, lcc, lcc * sizeof(Link));
totcl = lcm + rcm + us*sizeof(anUser) + usc*sizeof(Link) + awm; totcl = lcm + rcm + us * sizeof(anUser) + usc * sizeof(Link) + awm;
totcl += lcc*sizeof(Link) + usi*sizeof(Link) + wlhm; totcl += lcc * sizeof(Link) + usi * sizeof(Link) + wlhm;
totcl += wle*sizeof(Link); totcl += wle * sizeof(Link);
sendto_one(cptr, ":%s %d %s :Conflines %d(%d)", sendto_one(cptr, ":%s %d %s :Conflines %d(%d)",
me.name, RPL_STATSDEBUG, nick, co, com); me.name, RPL_STATSDEBUG, nick, co, com);
sendto_one(cptr, ":%s %d %s :Classes %d(%d)", sendto_one(cptr, ":%s %d %s :Classes %d(%d)",
me.name, RPL_STATSDEBUG, nick, cl, cl*sizeof(aClass)); me.name, RPL_STATSDEBUG, nick, cl, cl * sizeof(aClass));
sendto_one(cptr, ":%s %d %s :Channels %d(%d) Bans %d(%d)", sendto_one(cptr, ":%s %d %s :Channels %d(%d) Bans %d(%d)",
me.name, RPL_STATSDEBUG, nick, ch, chm, chb, chbm); me.name, RPL_STATSDEBUG, nick, ch, chm, chb, chbm);
sendto_one(cptr, ":%s %d %s :Channel membrs %d(%d) invite %d(%d)", sendto_one(cptr, ":%s %d %s :Channel membrs %d(%d) invite %d(%d)",
me.name, RPL_STATSDEBUG, nick, chu, chu*sizeof(Link), me.name, RPL_STATSDEBUG, nick, chu, chu * sizeof(Link),
chi, chi*sizeof(Link)); chi, chi * sizeof(Link));
totch = chm + chbm + chu*sizeof(Link) + chi*sizeof(Link); totch = chm + chbm + chu * sizeof(Link) + chi * sizeof(Link);
sendto_one(cptr, ":%s %d %s :Whowas users %d(%d) away %d(%d)", sendto_one(cptr, ":%s %d %s :Whowas users %d(%d) away %d(%d)",
me.name, RPL_STATSDEBUG, nick, wwu, wwu*sizeof(anUser), me.name, RPL_STATSDEBUG, nick, wwu, wwu * sizeof(anUser),
wwa, wwam); wwa, wwam);
sendto_one(cptr, ":%s %d %s :Whowas array %d(%d)", sendto_one(cptr, ":%s %d %s :Whowas array %d(%d)",
me.name, RPL_STATSDEBUG, nick, NICKNAMEHISTORYLENGTH, wwm); me.name, RPL_STATSDEBUG, nick, NICKNAMEHISTORYLENGTH, wwm);
totww = wwu*sizeof(anUser) + wwam + wwm; totww = wwu * sizeof(anUser) + wwam + wwm;
sendto_one(cptr, ":%s %d %s :Hash: client %d(%d) chan %d(%d) watch %d(%d)", sendto_one(cptr,
me.name, RPL_STATSDEBUG, nick, HASHSIZE, ":%s %d %s :Hash: client %d(%d) chan %d(%d) watch %d(%d)", me.name,
sizeof(aHashEntry) * HASHSIZE, RPL_STATSDEBUG, nick, U_MAX, sizeof(aHashEntry) * U_MAX, CH_MAX,
CHANNELHASHSIZE, sizeof(aHashEntry) * CHANNELHASHSIZE, sizeof(aHashEntry) * CH_MAX, NOTIFYHASHSIZE,
NOTIFYHASHSIZE, sizeof(aNotify *) * NOTIFYHASHSIZE); sizeof(aNotify *) * NOTIFYHASHSIZE);
db = dbufblocks * sizeof(dbufbuf); db = dbufblocks * sizeof(dbufbuf);
sendto_one(cptr, ":%s %d %s :Dbuf blocks %d(%d)", sendto_one(cptr, ":%s %d %s :Dbuf blocks %d(%d)",
me.name, RPL_STATSDEBUG, nick, dbufblocks, db); me.name, RPL_STATSDEBUG, nick, dbufblocks, db);
link=freelink; while(link=link->next) fl++; fl++; link = freelink;
while (link = link->next)
fl++;
fl++;
sendto_one(cptr, ":%s %d %s :Link blocks free %d(%d) total %d(%d)", sendto_one(cptr, ":%s %d %s :Link blocks free %d(%d) total %d(%d)",
me.name, RPL_STATSDEBUG, nick, fl, fl*sizeof(Link), me.name, RPL_STATSDEBUG, nick, fl, fl * sizeof(Link),
flinks, flinks*sizeof(Link)); flinks, flinks * sizeof(Link));
rm = cres_mem(cptr); rm = cres_mem(cptr);
tot = totww + totch + totcl + com + cl*sizeof(aClass) + db + rm; tot = totww + totch + totcl + com + cl * sizeof(aClass) + db + rm;
tot += fl*sizeof(Link); tot += fl * sizeof(Link);
tot += sizeof(aHashEntry) * HASHSIZE; tot += sizeof(aHashEntry) * U_MAX;
tot += sizeof(aHashEntry) * CHANNELHASHSIZE; tot += sizeof(aHashEntry) * CH_MAX;
tot += sizeof(aNotify *) * NOTIFYHASHSIZE; tot += sizeof(aNotify *) * NOTIFYHASHSIZE;
sendto_one(cptr, ":%s %d %s :Total: ww %d ch %d cl %d co %d db %d", sendto_one(cptr, ":%s %d %s :Total: ww %d ch %d cl %d co %d db %d",
me.name, RPL_STATSDEBUG, nick, totww, totch, totcl, com, db); me.name, RPL_STATSDEBUG, nick, totww, totch, totcl, com, db);
#if !defined(_WIN32) && !defined(_AMIGA) #if !defined(_WIN32) && !defined(_AMIGA)
#ifdef LINUX_ALPHA #ifdef __alpha
sendto_one(cptr, ":%s %d %s :TOTAL: %d sbrk(0)-etext: %u", sendto_one(cptr, ":%s %d %s :TOTAL: %d sbrk(0)-etext: %u",
me.name, RPL_STATSDEBUG, nick, tot, me.name, RPL_STATSDEBUG, nick, tot,
(u_int)sbrk((size_t)0)-(u_int)sbrk0); (u_int)sbrk((size_t)0) - (u_int)sbrk0);
#else #else
sendto_one(cptr, ":%s %d %s :TOTAL: %d sbrk(0)-etext: %ul", sendto_one(cptr, ":%s %d %s :TOTAL: %d sbrk(0)-etext: %ul",
me.name, RPL_STATSDEBUG, nick, tot, me.name, RPL_STATSDEBUG, nick, tot,
(u_long)sbrk((size_t)0)-(u_long)sbrk0); (u_long)sbrk((size_t)0) - (u_long)sbrk0);
#endif #endif
#else #else
sendto_one(cptr, ":%s %d %s :TOTAL: %d", sendto_one(cptr, ":%s %d %s :TOTAL: %d",
me.name, RPL_STATSDEBUG, nick, tot); me.name, RPL_STATSDEBUG, nick, tot);
#endif #endif
return; return;
} }
+386 -365
View File
@@ -1,5 +1,6 @@
/************************************************************************ /************************************************************************
* IRC - Internet Relay Chat, ircd/s_err.c /************************************************************************
* Unreal Internet Relay Chat Daemon, src/s_err.c
* Copyright (C) 1992 Darren Reed * Copyright (C) 1992 Darren Reed
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@@ -22,411 +23,431 @@
#include "common.h" #include "common.h"
#ifndef lint #ifndef lint
static char sccsid[] = "@(#)s_err.c 1.12 11/1/93 (C) 1992 Darren Reed"; static char sccsid[] = "@(#)s_err.c 1.12 11/1/93 (C) 1992 Darren Reed";
#endif #endif
ID_CVS("$Id$"); ID_CVS("$Id$");
typedef struct { typedef struct {
int num_val; int num_val;
char *num_form; char *num_form;
} Numeric; } Numeric;
static char *prepbuf PROTO((char *, int, char *)); static char *prepbuf PROTO((char *, int, char *));
static char numbuff[514]; static char numbuff[514];
static char numbers[] = "0123456789"; static char numbers[] = "0123456789";
static Numeric local_replies[] = { static Numeric local_replies[] = {
/* 000 */ 0, (char *)NULL, /* 000 */ 0, (char *)NULL,
/* 001 */ RPL_WELCOME, ":Welcome to the %s IRC Network %s!%s@%s", /* 001 */ RPL_WELCOME, ":Welcome to the %s IRC Network %s!%s@%s",
/* 002 */ RPL_YOURHOST, ":Your host is %s, running version %s", /* 002 */ RPL_YOURHOST, ":Your host is %s, running version %s",
/* 003 */ RPL_CREATED, ":This server was created %s", /* 003 */ RPL_CREATED, ":This server was created %s",
/* 004 */ RPL_MYINFO, "%s %s %s %s", /* 004 */ RPL_MYINFO, "%s %s %s %s",
/* 005 */ RPL_PROTOCTL, "%s :are available on this server", /* 005 */ RPL_PROTOCTL, "%s :are available on this server",
/* 006 */ RPL_MAP, ":%s%-*s\2[Users:%5d] [%2d%%]\2", /* 006 */ RPL_MAP, ":%s%-*s\2[Users:%5d] [%2d%%]\2",
/* 007 */ RPL_MAPEND, ":End of /MAP", /* 007 */ RPL_MAPEND, ":End of /MAP",
0, (char *)NULL 0, (char *)NULL
}; };
static Numeric numeric_errors[] = { static Numeric numeric_errors[] = {
/* 401 */ ERR_NOSUCHNICK, "%s :No such nick/channel", /* 401 */ ERR_NOSUCHNICK, "%s :No such nick/channel",
/* 402 */ ERR_NOSUCHSERVER, "%s :No such server", /* 402 */ ERR_NOSUCHSERVER, "%s :No such server",
/* 403 */ ERR_NOSUCHCHANNEL, "%s :No such channel", /* 403 */ ERR_NOSUCHCHANNEL, "%s :No such channel",
/* 404 */ ERR_CANNOTSENDTOCHAN, "%s :Cannot send to channel (%s)", /* 404 */ ERR_CANNOTSENDTOCHAN, "%s :%s (%s)",
/* 405 */ ERR_TOOMANYCHANNELS, "%s :You have joined too many channels", /* 405 */ ERR_TOOMANYCHANNELS, "%s :You have joined too many channels",
/* 406 */ ERR_WASNOSUCHNICK, "%s :There was no such nickname", /* 406 */ ERR_WASNOSUCHNICK, "%s :There was no such nickname",
/* 407 */ ERR_TOOMANYTARGETS, /* 407 */ ERR_TOOMANYTARGETS,
"%s :Duplicate recipients. No message delivered", "%s :Duplicate recipients. No message delivered",
/* 408 */ ERR_NOSUCHSERVICE, (char *)NULL, /* 408 */ ERR_NOSUCHSERVICE, (char *)NULL,
/* 409 */ ERR_NOORIGIN, ":No origin specified", /* 409 */ ERR_NOORIGIN, ":No origin specified",
0, (char *)NULL, 0, (char *)NULL,
/* 411 */ ERR_NORECIPIENT, ":No recipient given (%s)", /* 411 */ ERR_NORECIPIENT, ":No recipient given (%s)",
/* 412 */ ERR_NOTEXTTOSEND, ":No text to send", /* 412 */ ERR_NOTEXTTOSEND, ":No text to send",
/* 413 */ ERR_NOTOPLEVEL, "%s :No toplevel domain specified", /* 413 */ ERR_NOTOPLEVEL, "%s :No toplevel domain specified",
/* 414 */ ERR_WILDTOPLEVEL, "%s :Wildcard in toplevel Domain", /* 414 */ ERR_WILDTOPLEVEL, "%s :Wildcard in toplevel Domain",
0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL,
0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL,
/* 421 */ ERR_UNKNOWNCOMMAND, "%s :Unknown command", /* 421 */ ERR_UNKNOWNCOMMAND, "%s :Unknown command",
/* 422 */ ERR_NOMOTD, ":MOTD File is missing", /* 422 */ ERR_NOMOTD, ":MOTD File is missing",
/* 423 */ ERR_NOADMININFO, /* 423 */ ERR_NOADMININFO,
"%s :No administrative info available", "%s :No administrative info available",
/* 424 */ ERR_FILEERROR, ":File error doing %s on %s", /* 424 */ ERR_FILEERROR, ":File error doing %s on %s",
/* 425*/ ERR_NOOPERMOTD, ":OPERMOTD File is missing", /* 425*/ ERR_NOOPERMOTD, ":OPERMOTD File is missing",
0, (char *) NULL, 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL,
0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL,
/* 431 */ ERR_NONICKNAMEGIVEN, ":No nickname given", /* 431 */ ERR_NONICKNAMEGIVEN, ":No nickname given",
/* 432 */ ERR_ERRONEUSNICKNAME, "%s :Erroneous Nickname: %s", /* 432 */ ERR_ERRONEUSNICKNAME, "%s :Erroneous Nickname: %s",
/* 433 */ ERR_NICKNAMEINUSE, "%s :Nickname is already in use.", /* 433 */ ERR_NICKNAMEINUSE, "%s :Nickname is already in use.",
/* 434 */ ERR_NORULES, ":RULES File is missing", /* 434 */ ERR_NORULES, ":RULES File is missing",
/* 435 */ ERR_SERVICECONFUSED, (char *)NULL, /* 435 */ ERR_SERVICECONFUSED, (char *)NULL,
/* 436 */ ERR_NICKCOLLISION, "%s :Nickname collision KILL", /* 436 */ ERR_NICKCOLLISION, "%s :Nickname collision KILL",
/* 437 */ ERR_BANNICKCHANGE, /* 437 */ ERR_BANNICKCHANGE,
"%s :Cannot change nickname while banned on channel", "%s :Cannot change nickname while banned on channel",
/* 438 */ ERR_NCHANGETOOFAST, "%s :Nick change too fast. Please wait %d seconds", /* 438 */ ERR_NCHANGETOOFAST,
/* 439 */ ERR_TARGETTOOFAST, "%s :Message target change too fast. Please wait %d seconds", "%s :Nick change too fast. Please wait %d seconds",
/* 440 */ ERR_SERVICESDOWN, "%s :Services are currently down. Please try again later.", /* 439 */ ERR_TARGETTOOFAST,
/* 441 */ ERR_USERNOTINCHANNEL, "%s %s :They aren't on that channel", "%s :Message target change too fast. Please wait %d seconds",
/* 442 */ ERR_NOTONCHANNEL, "%s :You're not on that channel", /* 440 */ ERR_SERVICESDOWN,
/* 443 */ ERR_USERONCHANNEL, "%s %s :is already on channel", "%s :Services are currently down. Please try again later.",
/* 444 */ ERR_NOLOGIN, "%s :User not logged in", /* 441 */ ERR_USERNOTINCHANNEL, "%s %s :They aren't on that channel",
/* 442 */ ERR_NOTONCHANNEL, "%s :You're not on that channel",
/* 443 */ ERR_USERONCHANNEL, "%s %s :is already on channel",
/* 444 */ ERR_NOLOGIN, "%s :User not logged in",
#ifndef ENABLE_SUMMON #ifndef ENABLE_SUMMON
/* 445 */ ERR_SUMMONDISABLED, ":SUMMON has been disabled", /* 445 */ ERR_SUMMONDISABLED, ":SUMMON has been disabled",
#else #else
0, (char *)NULL, 0, (char *)NULL,
#endif #endif
#ifndef ENABLE_USERS #ifndef ENABLE_USERS
/* 446 */ ERR_USERSDISABLED, ":USERS has been disabled", /* 446 */ ERR_USERSDISABLED, ":USERS has been disabled",
#else #else
0, (char *)NULL, 0, (char *)NULL,
#endif #endif
0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL,
0, (char *)NULL, 0, (char *)NULL,
/* 451 */ ERR_NOTREGISTERED, ":You have not registered", /* 451 */ ERR_NOTREGISTERED, ":You have not registered",
0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL,
#ifdef HOSTILENAME #ifdef HOSTILENAME
/* 455 */ ERR_HOSTILENAME, ":Your username %s contained the invalid " /* 455 */ ERR_HOSTILENAME, ":Your username %s contained the invalid "
"character(s) %s and has been changed to %s. " "character(s) %s and has been changed to %s. "
"Please use only the characters 0-9 a-z A-Z _ - " "Please use only the characters 0-9 a-z A-Z _ - "
"or . in your username. Your username is the part " "or . in your username. Your username is the part "
"before the @ in your email address.", "before the @ in your email address.",
#else #else
0, (char *)NULL, 0, (char *)NULL,
#endif #endif
0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL,
/* 459 */ ERR_NOHIDING, "%s :Cannot join channel (+H)", /* 459 */ ERR_NOHIDING, "%s :Cannot join channel (+H)",
/* 460 */ ERR_NOTFORHALFOPS, ":Halfops cannot set mode %c", /* 460 */ ERR_NOTFORHALFOPS, ":Halfops cannot set mode %c",
/* 461 */ ERR_NEEDMOREPARAMS, "%s :Not enough parameters", /* 461 */ ERR_NEEDMOREPARAMS, "%s :Not enough parameters",
/* 462 */ ERR_ALREADYREGISTRED, ":You may not reregister", /* 462 */ ERR_ALREADYREGISTRED, ":You may not reregister",
/* 463 */ ERR_NOPERMFORHOST, ":Your host isn't among the privileged", /* 463 */ ERR_NOPERMFORHOST, ":Your host isn't among the privileged",
/* 464 */ ERR_PASSWDMISMATCH, ":Password Incorrect", /* 464 */ ERR_PASSWDMISMATCH, ":Password Incorrect",
/* 465 */ ERR_YOUREBANNEDCREEP, ":You are banned from this server. Mail %s for more information", /* 465 */ ERR_YOUREBANNEDCREEP,
/* 466 */ ERR_YOUWILLBEBANNED, (char *)NULL, ":You are banned from this server. Mail %s for more information",
/* 467 */ ERR_KEYSET, "%s :Channel key already set", /* 466 */ ERR_YOUWILLBEBANNED, (char *)NULL,
/* 468 */ ERR_ONLYSERVERSCANCHANGE, "%s :Only servers can change that mode", /* 467 */ ERR_KEYSET, "%s :Channel key already set",
/* 469 */ ERR_LINKSET, "%s :Channel link already set", /* 468 */ ERR_ONLYSERVERSCANCHANGE,
/* 470 */ ERR_LINKCHANNEL, "[Link] %s has become full, so you are automatically being transferred to the linked channel %s", "%s :Only servers can change that mode",
/* 471 */ ERR_CHANNELISFULL, "%s :Cannot join channel (+l)", /* 469 */ ERR_LINKSET, "%s :Channel link already set",
/* 472 */ ERR_UNKNOWNMODE , "%c :is unknown mode char to me", /* 470 */ ERR_LINKCHANNEL,
/* 473 */ ERR_INVITEONLYCHAN, "%s :Cannot join channel (+i)", "[Link] %s has become full, so you are automatically being transferred to the linked channel %s",
/* 474 */ ERR_BANNEDFROMCHAN, "%s :Cannot join channel (+b)", /* 471 */ ERR_CHANNELISFULL, "%s :Cannot join channel (+l)",
/* 475 */ ERR_BADCHANNELKEY, "%s :Cannot join channel (+k)", /* 472 */ ERR_UNKNOWNMODE, "%c :is unknown mode char to me",
/* 476 */ ERR_BADCHANMASK, "%s :Bad Channel Mask", /* 473 */ ERR_INVITEONLYCHAN, "%s :Cannot join channel (+i)",
/* 477 */ ERR_NEEDREGGEDNICK, "%s :You need a registered nick to join that channel.", /* 474 */ ERR_BANNEDFROMCHAN, "%s :Cannot join channel (+b)",
/* 478 */ ERR_BANLISTFULL, "%s %s :Channel ban/ignore list is full", /* 475 */ ERR_BADCHANNELKEY, "%s :Cannot join channel (+k)",
/* 479 */ ERR_LINKFAIL, "%s :Sorry, the channel has an invalid channel link set.", /* 476 */ ERR_BADCHANMASK, "%s :Bad Channel Mask",
/* 480 */ ERR_CANNOTKNOCK, ":Cannot knock on %s (%s)", /* 477 */ ERR_NEEDREGGEDNICK,
/* 481 */ ERR_NOPRIVILEGES, ":Permission Denied- You do not have the correct IRC operator privileges", "%s :You need a registered nick to join that channel.",
/* 482 */ ERR_CHANOPRIVSNEEDED, "%s :You're not channel operator", /* 478 */ ERR_BANLISTFULL, "%s %s :Channel ban/ignore list is full",
/* 483 */ ERR_CANTKILLSERVER, ":You cant kill a server!", /* 479 */ ERR_LINKFAIL,
/* 484 */ ERR_ATTACKDENY, "%s :Cannot kick protected user %s.", "%s :Sorry, the channel has an invalid channel link set.",
/* 485 */ ERR_KILLDENY, ":Cannot kill protected user %s.", /* 480 */ ERR_CANNOTKNOCK, ":Cannot knock on %s (%s)",
0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, /* 481 */ ERR_NOPRIVILEGES,
0, (char *)NULL, 0, (char *)NULL, ":Permission Denied- You do not have the correct IRC operator privileges",
/* 491 */ ERR_NOOPERHOST, ":No O-lines for your host", /* 482 */ ERR_CHANOPRIVSNEEDED, "%s :You're not channel operator",
/* 492 */ ERR_NOSERVICEHOST, (char *)NULL, /* 483 */ ERR_CANTKILLSERVER, ":You cant kill a server!",
0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, /* 484 */ ERR_ATTACKDENY, "%s :Cannot kick protected user %s.",
0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, /* 485 */ ERR_KILLDENY, ":Cannot kill protected user %s.",
0, (char *)NULL, 0, (char *)NULL, /* 486 */ ERR_HTMDISABLED,
/* 501 */ ERR_UMODEUNKNOWNFLAG, ":Unknown MODE flag", ":%s is currently disabled, please try again later.",
/* 502 */ ERR_USERSDONTMATCH, ":Cant change mode for other users", 0, (char *)NULL, 0, (char *)NULL,
0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL,
0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, /* 491 */ ERR_NOOPERHOST, ":No O-lines for your host",
0, (char *)NULL, 0, (char *)NULL, /* 492 */ ERR_NOSERVICEHOST, (char *)NULL,
/* 511 */ ERR_SILELISTFULL, "%s :Your silence list is full", 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL,
/* 512 */ ERR_TOOMANYWATCH, "%s :Maximum size for WATCH-list is 128 entries", 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL,
/* 513 */ ERR_NEEDPONG, ":To connect, type /QUOTE PONG %lX", 0, (char *)NULL, 0, (char *)NULL,
0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, /* 501 */ ERR_UMODEUNKNOWNFLAG, ":Unknown MODE flag",
0, (char *)NULL, /* 502 */ ERR_USERSDONTMATCH, ":Cant change mode for other users",
518, ":Cannot invite (+I) at channel", 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL,
519, ":Cannot join channel (Admin only)", 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL,
520, ":Cannot join channel (IRCops only)", 0, (char *)NULL, 0, (char *)NULL,
/* 521 */ ERR_LISTSYNTAX, "Bad list syntax, type /quote list ? or /raw list ?" /* 511 */ ERR_SILELISTFULL, "%s :Your silence list is full",
/* 512 */ ERR_TOOMANYWATCH,
"%s :Maximum size for WATCH-list is 128 entries",
/* 513 */ ERR_NEEDPONG, ":To connect, type /QUOTE PONG %lX",
0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL,
0, (char *)NULL,
518, ":Cannot invite (+I) at channel",
519, ":Cannot join channel (Admin only)",
520, ":Cannot join channel (IRCops only)",
/* 521 */ ERR_LISTSYNTAX,
"Bad list syntax, type /quote list ? or /raw list ?"
}; };
static Numeric numeric_replies[] = { static Numeric numeric_replies[] = {
/* 300 */ RPL_NONE, (char *)NULL, /* 300 */ RPL_NONE, (char *)NULL,
/* 301 */ RPL_AWAY, "%s :%s", /* 301 */ RPL_AWAY, "%s :%s",
/* 302 */ RPL_USERHOST, ":", /* 302 */ RPL_USERHOST, ":",
/* 303 */ RPL_ISON, ":", /* 303 */ RPL_ISON, ":",
/* 304 */ RPL_TEXT, (char *)NULL, /* 304 */ RPL_TEXT, (char *)NULL,
/* 305 */ RPL_UNAWAY, ":You are no longer marked as being away", /* 305 */ RPL_UNAWAY, ":You are no longer marked as being away",
/* 306 */ RPL_NOWAWAY, ":You have been marked as being away", /* 306 */ RPL_NOWAWAY, ":You have been marked as being away",
/* 307 */ RPL_WHOISREGNICK, "%s :is a registered nick", /* 307 */ RPL_WHOISREGNICK, "%s :is a registered nick",
/* 308 */ RPL_RULESSTART, ":- %s Server Rules - ", /* 308 */ RPL_RULESSTART, ":- %s Server Rules - ",
/* 309 */ RPL_ENDOFRULES, ":End of RULES command.", /* 309 */ RPL_ENDOFRULES, ":End of RULES command.",
/* 310 */ RPL_WHOISHELPOP, "%s :is available for help.", /* 310 */ RPL_WHOISHELPOP, "%s :is available for help.",
/* 311 */ RPL_WHOISUSER, "%s %s %s * :%s", /* 311 */ RPL_WHOISUSER, "%s %s %s * :%s",
/* 312 */ RPL_WHOISSERVER, "%s %s :%s", /* 312 */ RPL_WHOISSERVER, "%s %s :%s",
/* 313 */ RPL_WHOISOPERATOR, "%s :is %s on %s", /* 313 */ RPL_WHOISOPERATOR, "%s :is %s on %s",
/* 314 */ RPL_WHOWASUSER, "%s %s %s * :%s", /* 314 */ RPL_WHOWASUSER, "%s %s %s * :%s",
/* 315 */ RPL_ENDOFWHO, "%s :End of /WHO list.", /* 315 */ RPL_ENDOFWHO, "%s :End of /WHO list.",
/* 316 */ RPL_WHOISCHANOP, (char *)NULL, /* 316 */ RPL_WHOISCHANOP, (char *)NULL,
/* 317 */ RPL_WHOISIDLE, "%s %ld %ld :seconds idle, signon time", /* 317 */ RPL_WHOISIDLE, "%s %ld %ld :seconds idle, signon time",
/* 318 */ RPL_ENDOFWHOIS, "%s :End of /WHOIS list.", /* 318 */ RPL_ENDOFWHOIS, "%s :End of /WHOIS list.",
/* 319 */ RPL_WHOISCHANNELS, "%s :%s", /* 319 */ RPL_WHOISCHANNELS, "%s :%s",
RPL_WHOISSPECIAL, "%s :%s", RPL_WHOISSPECIAL, "%s :%s",
/* 321 */ RPL_LISTSTART, "Channel :Users Name", /* 321 */ RPL_LISTSTART, "Channel :Users Name",
/* 322 */ RPL_LIST, "%s %d :%s", /* 322 */ RPL_LIST, "%s %d :%s",
/* 323 */ RPL_LISTEND, ":End of /LIST", /* 323 */ RPL_LISTEND, ":End of /LIST",
/* 324 */ RPL_CHANNELMODEIS, "%s %s %s", /* 324 */ RPL_CHANNELMODEIS, "%s %s %s",
0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL,
0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL,
/* 329 */ RPL_CREATIONTIME, "%s %lu", /* 329 */ RPL_CREATIONTIME, "%s %lu",
0, (char *)NULL, 0, (char *)NULL,
/* 331 */ RPL_NOTOPIC, "%s :No topic is set.", /* 331 */ RPL_NOTOPIC, "%s :No topic is set.",
/* 332 */ RPL_TOPIC, "%s :%s", /* 332 */ RPL_TOPIC, "%s :%s",
/* 333 */ RPL_TOPICWHOTIME, "%s %s %lu", /* 333 */ RPL_TOPICWHOTIME, "%s %s %lu",
/* 334 */ RPL_LISTSYNTAX, ":%s", /* 334 */ RPL_LISTSYNTAX, ":%s",
/* 335 */ RPL_WHOISBOT, "%s :is a \2Bot\2 on %s", /* 335 */ RPL_WHOISBOT, "%s :is a \2Bot\2 on %s",
0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL,
0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL,
/* 341 */ RPL_INVITING, "%s %s", /* 341 */ RPL_INVITING, "%s %s",
/* 342 */ RPL_SUMMONING, "%s :User summoned to irc", /* 342 */ RPL_SUMMONING, "%s :User summoned to irc",
0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL,
0, (char *)NULL, 0, (char *)NULL,
RPL_INVITELIST, "%s %s", RPL_INVITELIST, "%s %s",
RPL_ENDOFINVITELIST, "%s :End of Channel Invite List", RPL_ENDOFINVITELIST, "%s :End of Channel Invite List",
RPL_EXLIST, "%s %s %s %lu", RPL_EXLIST, "%s %s %s %lu",
RPL_ENDOFEXLIST, "%s :End of Channel Exception List", RPL_ENDOFEXLIST, "%s :End of Channel Exception List",
0, (char *)NULL, 0, (char *)NULL,
/* 351 */ RPL_VERSION, "%s(%s).%s %s :%s [%s=%li%s]", /* 351 */ RPL_VERSION, "%s(%s).%s %s :%s [%s=%li%s]",
/* 352 */ RPL_WHOREPLY, "%s %s %s %s %s %s :%d %s", /* 352 */ RPL_WHOREPLY, "%s %s %s %s %s %s :%d %s",
/* 353 */ RPL_NAMREPLY, "%s", /* 353 */ RPL_NAMREPLY, "%s",
354, ":Reserved for Undernet", 354, ":Reserved for Undernet",
0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL,
0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL,
0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL,
/* 361 */ RPL_KILLDONE, (char *)NULL, /* 361 */ RPL_KILLDONE, (char *)NULL,
/* 362 */ RPL_CLOSING, "%s :Closed. Status = %d", /* 362 */ RPL_CLOSING, "%s :Closed. Status = %d",
/* 363 */ RPL_CLOSEEND, "%d: Connections Closed", /* 363 */ RPL_CLOSEEND, "%d: Connections Closed",
/* 364 */ RPL_LINKS, "%s %s :%d %s", /* 364 */ RPL_LINKS, "%s %s :%d %s",
/* 365 */ RPL_ENDOFLINKS, "%s :End of /LINKS list.", /* 365 */ RPL_ENDOFLINKS, "%s :End of /LINKS list.",
/* 366 */ RPL_ENDOFNAMES, "%s :End of /NAMES list.", /* 366 */ RPL_ENDOFNAMES, "%s :End of /NAMES list.",
/* 367 */ RPL_BANLIST, "%s %s %s %lu", /* 367 */ RPL_BANLIST, "%s %s %s %lu",
/* 368 */ RPL_ENDOFBANLIST, "%s :End of Channel Ban List", /* 368 */ RPL_ENDOFBANLIST, "%s :End of Channel Ban List",
/* 369 */ RPL_ENDOFWHOWAS, "%s :End of WHOWAS", /* 369 */ RPL_ENDOFWHOWAS, "%s :End of WHOWAS",
0, (char *)NULL, 0, (char *)NULL,
/* 371 */ RPL_INFO, ":%s", /* 371 */ RPL_INFO, ":%s",
/* 372 */ RPL_MOTD, ":- %s", /* 372 */ RPL_MOTD, ":- %s",
/* 373 */ RPL_INFOSTART, ":Server INFO", /* 373 */ RPL_INFOSTART, ":Server INFO",
/* 374 */ RPL_ENDOFINFO, ":End of /INFO list.", /* 374 */ RPL_ENDOFINFO, ":End of /INFO list.",
/* 375 */ RPL_MOTDSTART, ":- %s Message of the Day - ", /* 375 */ RPL_MOTDSTART, ":- %s Message of the Day - ",
/* 376 */ RPL_ENDOFMOTD, ":End of /MOTD command.", /* 376 */ RPL_ENDOFMOTD, ":End of /MOTD command.",
0, (char *)NULL, 0, (char *)NULL,
/* 378 */ RPL_WHOISHOST, "%s :is connecting from *@%s", /* 378 */ RPL_WHOISHOST, "%s :is connecting from *@%s",
/* 379 */ RPL_WHOISMODES, "%s is using modes %s", /* 379 */ RPL_WHOISMODES, "%s is using modes %s",
0, (char *)NULL, 0, (char *)NULL,
/* 381 */ RPL_YOUREOPER, ":You are now an IRC Operator", /* 381 */ RPL_YOUREOPER, ":You are now an IRC Operator",
/* 382 */ RPL_REHASHING, "%s :Rehashing", /* 382 */ RPL_REHASHING, "%s :Rehashing",
/* 383 */ RPL_YOURESERVICE, (char *)NULL, /* 383 */ RPL_YOURESERVICE, (char *)NULL,
/* 384 */ RPL_MYPORTIS, "%d :Port to local server is\r\n", /* 384 */ RPL_MYPORTIS, "%d :Port to local server is\r\n",
/* 385 */ RPL_NOTOPERANYMORE, (char *)NULL, /* 385 */ RPL_NOTOPERANYMORE, (char *)NULL,
0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, /* 356 */ RPL_QLIST, "%s %s",
0, (char *)NULL, 0, (char *)NULL, /* 387 */ RPL_ENDOFQLIST, "%s :End of Channel Owner List",
/* 391 */ RPL_TIME, "%s :%s", /* 388 */ RPL_ALIST, "%s %s",
/* 389 */ RPL_ENDOFALIST, "%s :End of Protected User List",
0, (char *)NULL,
/* 391 */ RPL_TIME, "%s :%s",
#ifdef ENABLE_USERS #ifdef ENABLE_USERS
/* 392 */ RPL_USERSSTART, ":UserID Terminal Host", /* 392 */ RPL_USERSSTART, ":UserID Terminal Host",
/* 393 */ RPL_USERS, ":%-8s %-9s %-8s", /* 393 */ RPL_USERS, ":%-8s %-9s %-8s",
/* 394 */ RPL_ENDOFUSERS, ":End of Users", /* 394 */ RPL_ENDOFUSERS, ":End of Users",
/* 395 */ RPL_NOUSERS, ":Nobody logged in.", /* 395 */ RPL_NOUSERS, ":Nobody logged in.",
#else #else
0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL,
0, (char *)NULL, 0, (char *)NULL,
#endif #endif
0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL,
0, (char *)NULL, 0, (char *)NULL,
/* 200 */ RPL_TRACELINK, "Link %s%s %s %s", /* 200 */ RPL_TRACELINK, "Link %s%s %s %s",
/* 201 */ RPL_TRACECONNECTING, "Attempt %d %s", /* 201 */ RPL_TRACECONNECTING, "Attempt %d %s",
/* 202 */ RPL_TRACEHANDSHAKE, "Handshaking %d %s", /* 202 */ RPL_TRACEHANDSHAKE, "Handshaking %d %s",
/* 203 */ RPL_TRACEUNKNOWN, "???? %d %s", /* 203 */ RPL_TRACEUNKNOWN, "???? %d %s",
/* 204 */ RPL_TRACEOPERATOR, "Operator %d %s [%s] %ld", /* 204 */ RPL_TRACEOPERATOR, "Operator %d %s [%s] %ld",
/* 205 */ RPL_TRACEUSER, "User %d %s [%s] %ld", /* 205 */ RPL_TRACEUSER, "User %d %s [%s] %ld",
/* 206 */ RPL_TRACESERVER, "Server %d %dS %dC %s %s!%s@%s %ld", /* 206 */ RPL_TRACESERVER, "Server %d %dS %dC %s %s!%s@%s %ld",
/* 207 */ RPL_TRACESERVICE, "Service %d %s", /* 207 */ RPL_TRACESERVICE, "Service %d %s",
/* 208 */ RPL_TRACENEWTYPE, "<newtype> 0 %s", /* 208 */ RPL_TRACENEWTYPE, "<newtype> 0 %s",
/* 209 */ RPL_TRACECLASS, "Class %d %d", /* 209 */ RPL_TRACECLASS, "Class %d %d",
0, (char *)NULL, 0, (char *)NULL,
/* 211 */ RPL_STATSLINKINFO, (char *)NULL, /* 211 */ RPL_STATSLINKINFO, (char *)NULL,
#ifdef DEBUGMODE #ifdef DEBUGMODE
/* 212 */ RPL_STATSCOMMANDS, "%s %u %u %u %u %u %u", /* 212 */ RPL_STATSCOMMANDS, "%s %u %u %u %u %u %u",
#else #else
/* 212 */ RPL_STATSCOMMANDS, "%s %u %u", /* 212 */ RPL_STATSCOMMANDS, "%s %u %u",
#endif #endif
/* 213 */ RPL_STATSCLINE, "%c %s * %s %d %d", /* 213 */ RPL_STATSCLINE, "%c %s * %s %d %d",
/* 214 */ RPL_STATSNLINE, "%c %s * %s %d %d", 0, (char *)NULL,
/* 215 */ RPL_STATSILINE, "%c %s * %s %d %d", /* 215 */ RPL_STATSILINE, "%c %s * %s %d %d",
/* 216 */ RPL_STATSKLINE, "%c %s %s %s %d %d", /* 216 */ RPL_STATSKLINE, "%c %s %s %s %d %d",
/* 217 */ RPL_STATSQLINE, "%c %s %s %s %d %d", /* 217 */ RPL_STATSQLINE, "%c %s %s %s %d %d",
/* 218 */ RPL_STATSYLINE, "%c %d %d %d %d %ld", /* 218 */ RPL_STATSYLINE, "%c %d %d %d %d %ld",
/* 219 */ RPL_ENDOFSTATS, "%c :End of /STATS report", /* 219 */ RPL_ENDOFSTATS, "%c :End of /STATS report",
/* 220 */ RPL_STATSBLINE, "%c %s %s %s %d %d", /* 220 */ RPL_STATSBLINE, "%c %s %s %s %d %d",
/* 221 */ RPL_UMODEIS, "%s", /* 221 */ RPL_UMODEIS, "%s",
/* 222 */ RPL_SQLINE_NICK, "%s :%s", /* 222 */ RPL_SQLINE_NICK, "%s :%s",
/* 223 */ RPL_STATSGLINE, "%c %s@%s %li %li %s :%s", /* 223 */ RPL_STATSGLINE, "%c %s@%s %li %li %s :%s",
/* 224 */ RPL_STATSTLINE, "T %s %s %s", /* 224 */ RPL_STATSTLINE, "T %s %s %s",
0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, /* 225 */ RPL_STATSELINE, "e %s %s %s",
0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, /* 226 */ RPL_STATSNLINE, "n %s %s",
/* 231 */ RPL_SERVICEINFO, (char *)NULL, 0, (char *)NULL,
/* 232 */ RPL_RULES, ":- %s", 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL,
/* 233 */ RPL_SERVICE, (char *)NULL, /* 231 */ RPL_SERVICEINFO, (char *)NULL,
/* 234 */ RPL_SERVLIST, (char *)NULL, /* 232 */ RPL_RULES, ":- %s",
/* 235 */ RPL_SERVLISTEND, (char *)NULL, /* 233 */ RPL_SERVICE, (char *)NULL,
0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, /* 234 */ RPL_SERVLIST, (char *)NULL,
0, (char *)NULL, 0, (char *)NULL, /* 235 */ RPL_SERVLISTEND, (char *)NULL,
/* 241 */ RPL_STATSLLINE, "%c %s * %s %d %d", 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL,
/* 242 */ RPL_STATSUPTIME, ":Server Up %d days, %d:%02d:%02d", 0, (char *)NULL, 0, (char *)NULL,
/* 243 */ RPL_STATSOLINE, "%c %s * %s %s %d", /* 241 */ RPL_STATSLLINE, "%c %s * %s %d %d",
/* 244 */ RPL_STATSHLINE, "%c %s * %s %d %d", /* 242 */ RPL_STATSUPTIME, ":Server Up %d days, %d:%02d:%02d",
/* 245 */ RPL_STATSSLINE, "%c %s * %s %d %d", /* 243 */ RPL_STATSOLINE, "%c %s * %s %s %d",
0, (char *)NULL, /* 244 */ RPL_STATSHLINE, "%c %s * %s %d %d",
/* 247 */ RPL_STATSXLINE, "X %s %d", /* 245 */ RPL_STATSSLINE, "%c %s * %s %d %d",
/* 248 */ RPL_STATSULINE, "%c %s * %s %d %d", 0, (char *)NULL,
0, (char *)NULL, /* 247 */ RPL_STATSXLINE, "X %s %d",
/* 250 */ RPL_STATSCONN, /* 248 */ RPL_STATSULINE, "%c %s * %s %d %d",
":Highest connection count: %d (%d clients)", 0, (char *)NULL,
/* 251 */ RPL_LUSERCLIENT, /* 250 */ RPL_STATSCONN,
":There are %d users and %d invisible on %d servers", ":Highest connection count: %d (%d clients)",
/* 252 */ RPL_LUSEROP, "%d :operator(s) online", /* 251 */ RPL_LUSERCLIENT,
/* 253 */ RPL_LUSERUNKNOWN, "%d :unknown connection(s)", ":There are %d users and %d invisible on %d servers",
/* 254 */ RPL_LUSERCHANNELS, "%d :channels formed", /* 252 */ RPL_LUSEROP, "%d :operator(s) online",
/* 255 */ RPL_LUSERME, ":I have %d clients and %d servers", /* 253 */ RPL_LUSERUNKNOWN, "%d :unknown connection(s)",
/* 256 */ RPL_ADMINME, ":Administrative info about %s", /* 254 */ RPL_LUSERCHANNELS, "%d :channels formed",
/* 257 */ RPL_ADMINLOC1, ":%s", /* 255 */ RPL_LUSERME, ":I have %d clients and %d servers",
/* 258 */ RPL_ADMINLOC2, ":%s", /* 256 */ RPL_ADMINME, ":Administrative info about %s",
/* 259 */ RPL_ADMINEMAIL, ":%s", /* 257 */ RPL_ADMINLOC1, ":%s",
0, (char *)NULL, /* 258 */ RPL_ADMINLOC2, ":%s",
/* 261 */ RPL_TRACELOG, "File %s %d", /* 259 */ RPL_ADMINEMAIL, ":%s",
0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL,
/* 265 */ RPL_LOCALUSERS, ":Current Local Users: %d Max: %d", /* 261 */ RPL_TRACELOG, "File %s %d",
/* 266 */ RPL_GLOBALUSERS, ":Current Global Users: %d Max: %d", 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL,
0, (char *)NULL, /* 265 */ RPL_LOCALUSERS, ":Current Local Users: %d Max: %d",
0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, /* 266 */ RPL_GLOBALUSERS, ":Current Global Users: %d Max: %d",
/* 271 */ RPL_SILELIST, "%s %s", 0, (char *)NULL,
/* 272 */ RPL_ENDOFSILELIST, ":End of Silence List", 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL,
0, (char *)NULL, 0, (char *)NULL, /* 271 */ RPL_SILELIST, "%s %s",
/* 275 */ RPL_STATSDLINE, "%c %s %s", /* 272 */ RPL_ENDOFSILELIST, ":End of Silence List",
0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL,
0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, /* 275 */ RPL_STATSDLINE, "%c %s %s",
0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL,
0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL,
0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL,
0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL,
/* 294 */ RPL_HELPFWD, ":Your help-request has been forwarded to Help Operators", 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL,
/* 295 */ RPL_HELPIGN, ":Your address has been ignored from forwarding" 0, (char *)NULL, 0, (char *)NULL, 0, (char *)NULL,
/* 294 */ RPL_HELPFWD,
":Your help-request has been forwarded to Help Operators",
/* 295 */ RPL_HELPIGN, ":Your address has been ignored from forwarding"
}; };
/* /*
* NOTE: Unlike the others, this one goes strait through, 600-799 * NOTE: Unlike the others, this one goes strait through, 600-799
*/ */
static Numeric numeric_replies2[] = { static Numeric numeric_replies2[] = {
/* 600 */ RPL_LOGON, "%s %s %s %d :logged online", /* 600 */ RPL_LOGON, "%s %s %s %d :logged online",
/* 601 */ RPL_LOGOFF, "%s %s %s %d :logged offline", /* 601 */ RPL_LOGOFF, "%s %s %s %d :logged offline",
/* 602 */ RPL_WATCHOFF, "%s %s %s %d :stopped watching", /* 602 */ RPL_WATCHOFF, "%s %s %s %d :stopped watching",
/* 603 */ RPL_WATCHSTAT, ":You have %d and are on %d WATCH entries", /* 603 */ RPL_WATCHSTAT, ":You have %d and are on %d WATCH entries",
/* 604 */ RPL_NOWON, "%s %s %s %d :is online", /* 604 */ RPL_NOWON, "%s %s %s %d :is online",
/* 605 */ RPL_NOWOFF, "%s %s %s %d :is offline", /* 605 */ RPL_NOWOFF, "%s %s %s %d :is offline",
/* 606 */ RPL_WATCHLIST, ":%s", /* 606 */ RPL_WATCHLIST, ":%s",
/* 607 */ RPL_ENDOFWATCHLIST, ":End of WATCH %c", /* 607 */ RPL_ENDOFWATCHLIST, ":End of WATCH %c",
/* 610 */ RPL_MAPMORE, ":%s%-*s --> *more*", /* 610 */ RPL_MAPMORE, ":%s%-*s --> *more*",
/* 611 */ 0, (char *)NULL, /* 611 */ 0, (char *)NULL,
/* 612 */ 0, (char *)NULL, /* 612 */ 0, (char *)NULL,
/* 613 */ 0, (char *)NULL, /* 613 */ 0, (char *)NULL,
/* 614 */ 0, (char *)NULL, /* 614 */ 0, (char *)NULL,
/* 615 */ 0, (char *)NULL, /* 615 */ 0, (char *)NULL,
/* 616 */ 0, (char *)NULL, /* 616 */ 0, (char *)NULL,
/* 617 */ 0, (char *)NULL, /* 617 */ 0, (char *)NULL,
/* 618 */ 0, (char *)NULL, /* 618 */ 0, (char *)NULL,
/* 619 */ 0, (char *)NULL, /* 619 */ 0, (char *)NULL,
/* 620 */ 0,(char *) NULL, /* 620 */ 0, (char *)NULL,
/* 621 */ 0,(char *) NULL, /* 621 */ 0, (char *)NULL,
/* 622 */ 0,(char *) NULL, /* 622 */ 0, (char *)NULL,
0,(char *) NULL, 0, (char *)NULL,
0,(char *) NULL, 0, (char *)NULL,
0,(char *) NULL, 0, (char *)NULL,
0,(char *) NULL, 0, (char *)NULL,
0,(char *) NULL, 0, (char *)NULL,
0,(char *) NULL, 0, (char *)NULL,
0,(char *) NULL, 0, (char *)NULL,
0,(char *) NULL, 0, (char *)NULL,
0,(char *) NULL, 0, (char *)NULL,
0,(char *) NULL, 0, (char *)NULL,
0,(char *) NULL, 0, (char *)NULL,
0,(char *) NULL, 0, (char *)NULL,
0,(char *) NULL, 0, (char *)NULL,
0,(char *) NULL, 0, (char *)NULL,
0,(char *) NULL, 0, (char *)NULL,
0,(char *) NULL, 0, (char *)NULL,
0,(char *) NULL, 0, (char *)NULL,
/* 640 */ RPL_DUMPING, ":Dumping clients matching %s", /* 640 */ RPL_DUMPING, ":Dumping clients matching %s",
/* 641 */ RPL_DUMPRPL, "%s %s %s %s %s%s%s%s", /* 641 */ RPL_DUMPRPL, "%s %s %s %s %s%s%s%s",
/* 642 */ RPL_EODUMP, ":End of /dusers - %i", /* 642 */ RPL_EODUMP, ":End of /dusers - %i",
0, (char *) NULL, 0, (char *)NULL,
0, (char *)NULL 0, (char *)NULL
}; };
char *err_str(numeric) char *err_str(numeric)
int numeric; int numeric;
{ {
Reg1 Numeric *nptr; Numeric *nptr;
Reg2 int num = numeric; int num = numeric;
num -= numeric_errors[0].num_val; num -= numeric_errors[0].num_val;
if (num < 0 || num > ERR_NEEDPONG) if (num < 0 || num > ERR_NEEDPONG)
(void)sprintf(numbuff, (void)ircsprintf(numbuff,
":%%s %d %%s :INTERNAL ERROR: BAD NUMERIC! %d", ":%%s %d %%s :INTERNAL ERROR: BAD NUMERIC! %d",
numeric, num); numeric, num);
else else
{ {
nptr = &numeric_errors[num]; nptr = &numeric_errors[num];
if (!nptr->num_form || !nptr->num_val) if (!nptr->num_form || !nptr->num_val)
(void)sprintf(numbuff, (void)ircsprintf(numbuff,
":%%s %d %%s :NO ERROR FOR NUMERIC ERROR %d", ":%%s %d %%s :NO ERROR FOR NUMERIC ERROR %d",
numeric, num); numeric, num);
else else
(void)prepbuf(numbuff, nptr->num_val, nptr->num_form); (void)prepbuf(numbuff, nptr->num_val, nptr->num_form);
} }
return numbuff; return numbuff;
} }
char *rpl_str(numeric) char *rpl_str(numeric)
int numeric; int numeric;
{ {
Reg1 Numeric *nptr; Numeric *nptr;
Reg2 int num = numeric; int num = numeric;
if (num > 99) if (num > 99)
num -= (num > 300) ? 300 : 100; num -= (num > 300) ? 300 : 100;
if ((num < 0 || num > 200) && (num < 300 || num > 499)) if ((num < 0 || num > 200) && (num < 300 || num > 499))
(void)sprintf(numbuff, (void)ircsprintf(numbuff,
":%%s %d %%s :INTERNAL REPLY ERROR: BAD NUMERIC! %d", ":%%s %d %%s :INTERNAL REPLY ERROR: BAD NUMERIC! %d",
numeric, num); numeric, num);
else else
{ {
if (numeric > 599) { if (numeric > 599)
{
num -= 300; num -= 300;
nptr = &numeric_replies2[num]; nptr = &numeric_replies2[num];
} }
@@ -435,33 +456,33 @@ int numeric;
else else
nptr = &local_replies[num]; nptr = &local_replies[num];
Debug((DEBUG_NUM, "rpl_str: numeric %d num %d nptr %x %d %x", Debug((DEBUG_NUM, "rpl_str: numeric %d num %d nptr %x %d %x",
numeric, num, nptr, nptr->num_val, nptr->num_form)); numeric, num, nptr, nptr->num_val, nptr->num_form));
if (!nptr->num_form || !nptr->num_val) if (!nptr->num_form || !nptr->num_val)
(void)sprintf(numbuff, (void)ircsprintf(numbuff,
":%%s %d %%s :NO REPLY FOR NUMERIC ERROR %d", ":%%s %d %%s :NO REPLY FOR NUMERIC ERROR %d",
numeric, num); numeric, num);
else else
(void)prepbuf(numbuff, nptr->num_val, nptr->num_form); (void)prepbuf(numbuff, nptr->num_val, nptr->num_form);
} }
return numbuff; return numbuff;
} }
static char *prepbuf(buffer, num, tail) static char *prepbuf(buffer, num, tail)
char *buffer; char *buffer;
Reg1 int num; int num;
char *tail; char *tail;
{ {
Reg1 char *s; char *s;
(void)strcpy(buffer, ":%s "); (void)strcpy(buffer, ":%s ");
s = buffer + 4; s = buffer + 4;
*s++ = numbers[num/100]; *s++ = numbers[num / 100];
num %= 100; num %= 100;
*s++ = numbers[num/10]; *s++ = numbers[num / 10];
*s++ = numbers[num%10]; *s++ = numbers[num % 10];
(void)strcpy(s, " %s "); (void)strcpy(s, " %s ");
(void)strcpy(s+4, tail); (void)strcpy(s + 4, tail);
return buffer; return buffer;
} }
+470 -285
View File
File diff suppressed because it is too large Load Diff
+430 -366
View File
File diff suppressed because it is too large Load Diff
+368 -335
View File
File diff suppressed because it is too large Load Diff
+59 -56
View File
@@ -1,5 +1,6 @@
/************************************************************************ /************************************************************************
* IRC - Internet Relay Chat, ircd/s_numeric.c /************************************************************************
* Unreal Internet Relay Chat Daemon, src/s_numeric.c
* Copyright (C) 1990 Jarkko Oikarinen * Copyright (C) 1990 Jarkko Oikarinen
* *
* Numerous fixes by Markku Savela * Numerous fixes by Markku Savela
@@ -20,13 +21,14 @@
*/ */
#ifndef lint #ifndef lint
static char sccsid[] = "@(#)s_numeric.c 2.14 1/30/94 (C) 1988 University of Oulu, \ static char sccsid[] =
"@(#)s_numeric.c 2.14 1/30/94 (C) 1988 University of Oulu, \
Computing Center and Jarkko Oikarinen"; Computing Center and Jarkko Oikarinen";
#endif #endif
#include "struct.h" #include "struct.h"
#include "common.h" #include "common.h"
#include "sys.h" #include "sys.h"
#include "numeric.h" #include "numeric.h"
#include "h.h" #include "h.h"
@@ -49,16 +51,16 @@ static char buffer[1024];
** sending back a neat error message -- big danger of creating ** sending back a neat error message -- big danger of creating
** a ping pong error message... ** a ping pong error message...
*/ */
int do_numeric(numeric, cptr, sptr, parc, parv) int do_numeric(numeric, cptr, sptr, parc, parv)
int numeric; int numeric;
aClient *cptr, *sptr; aClient *cptr, *sptr;
int parc; int parc;
char *parv[]; char *parv[];
{ {
aClient *acptr; aClient *acptr;
aChannel *chptr; aChannel *chptr;
char *nick, *p; char *nick, *p;
int i; int i;
if (parc < 1 || !IsServer(sptr)) if (parc < 1 || !IsServer(sptr))
return 0; return 0;
@@ -66,68 +68,69 @@ char *parv[];
if (numeric < 100) if (numeric < 100)
numeric += 100; numeric += 100;
/* /*
** Prepare the parameter portion of the message into 'buffer'. ** Prepare the parameter portion of the message into 'buffer'.
** (Because the buffer is twice as large as the message buffer ** (Because the buffer is twice as large as the message buffer
** for the socket, no overflow can occur here... ...on current ** for the socket, no overflow can occur here... ...on current
** assumptions--bets are off, if these are changed --msa) ** assumptions--bets are off, if these are changed --msa)
** Note: if buffer is non-empty, it will begin with SPACE. ** Note: if buffer is non-empty, it will begin with SPACE.
*/ */
buffer[0] = '\0'; buffer[0] = '\0';
if (parc > 2) if (parc > 2)
{ {
for (i = 2; i < (parc - 1); i++) for (i = 2; i < (parc - 1); i++)
{ {
(void)strcat(buffer, " "); (void)strcat(buffer, " ");
(void)strcat(buffer, parv[i]); (void)strcat(buffer, parv[i]);
} }
(void)strcat(buffer, " :"); (void)strcat(buffer, " :");
(void)strcat(buffer, parv[parc-1]); (void)strcat(buffer, parv[parc - 1]);
} else sendto_realops("do_numeric( %i, %s, %s, %i, { %s, %s } )!", }
numeric, cptr->name, sptr->name, parc, else
parv[0], parv[1]?parv[1]:"<null>"); sendto_realops("do_numeric( %i, %s, %s, %i, { %s, %s } )!",
numeric, cptr->name, sptr->name, parc,
parv[0], parv[1] ? parv[1] : "<null>");
for (; (nick = strtoken(&p, parv[1], ",")); parv[1] = NULL) for (; (nick = strtoken(&p, parv[1], ",")); parv[1] = NULL)
{ {
if ((acptr = find_client(nick, (aClient *)NULL))) if ((acptr = find_client(nick, (aClient *)NULL)))
{ {
/* /*
** Drop to bit bucket if for me... ** Drop to bit bucket if for me...
** ...one might consider sendto_ops ** ...one might consider sendto_ops
** here... --msa ** here... --msa
** And so it was done. -avalon ** And so it was done. -avalon
** And regretted. Dont do it that way. Make sure ** And regretted. Dont do it that way. Make sure
** it goes only to non-servers. -avalon ** it goes only to non-servers. -avalon
** Check added to make sure servers don't try to loop ** Check added to make sure servers don't try to loop
** with numerics which can happen with nick collisions. ** with numerics which can happen with nick collisions.
** - Avalon ** - Avalon
*/ */
if (!IsMe(acptr) && IsPerson(acptr)) if (!IsMe(acptr) && IsPerson(acptr))
{ {
/* Added for .U3.2. drop remote 'You are not on /* Added for .U3.2. drop remote 'You are not on
** that channel', we should be synced anyway, ** that channel', we should be synced anyway,
** and this is an annoying message with TSpre7 ** and this is an annoying message with TSpre7
** still on the net; would result in numeric 442 for ** still on the net; would result in numeric 442 for
** every KICK... Can be removed when TSpre7 is gone. ** every KICK... Can be removed when TSpre7 is gone.
** --Run ** --Run
*/ if (numeric==ERR_NOTONCHANNEL) return 0;
if (numeric==ERR_NOTONCHANNEL) return 0; */
sendto_prefix_one(acptr, sptr,":%s %d %s%s", sendto_prefix_one(acptr, sptr, ":%s %d %s%s",
parv[0], numeric, nick, buffer); parv[0], numeric, nick, buffer);
} }
else if (IsServer(acptr) && acptr->from != cptr) else if (IsServer(acptr) && acptr->from != cptr)
sendto_prefix_one(acptr, sptr,":%s %d %s%s", sendto_prefix_one(acptr, sptr, ":%s %d %s%s",
parv[0], numeric, nick, buffer); parv[0], numeric, nick, buffer);
} }
else if ((acptr = find_server(nick, (aClient *)NULL))) else if ((acptr = find_server(nick, (aClient *)NULL)))
{ {
if (!IsMe(acptr) && acptr->from != cptr) if (!IsMe(acptr) && acptr->from != cptr)
sendto_prefix_one(acptr, sptr,":%s %d %s%s", sendto_prefix_one(acptr, sptr, ":%s %d %s%s",
parv[0], numeric, nick, buffer); parv[0], numeric, nick, buffer);
} }
else if ((chptr = find_channel(nick, (aChannel *)NULL))) else if ((chptr = find_channel(nick, (aChannel *)NULL)))
sendto_channel_butone(cptr,sptr,chptr,":%s %d %s%s", sendto_channel_butone(cptr, sptr, chptr, ":%s %d %s%s",
parv[0], parv[0], numeric, chptr->chname, buffer);
numeric, chptr->chname, buffer); }
}
return 0; return 0;
} }
+3035 -2622
View File
File diff suppressed because it is too large Load Diff
+79 -72
View File
@@ -1,25 +1,25 @@
/* UltimateIRCd - Ultimate Internet Relay Chat Daemon, src/s_socks.c /************************************************************************
** /************************************************************************
** Written for UltimateIRCd by ShadowRealm Creations. * Unreal Internet Relay Chat Daemon, src/s_socks.c
** Copyright (C) 1997-1999 Infomedia Inc. * Copyright (C) 1998 Lucas Madar
** *
** This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 1, or (at your option) * the Free Software Foundation; either version 1, or (at your option)
** any later version. * any later version.
** *
** This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details. * GNU General Public License for more details.
** *
** You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifndef lint #ifndef lint
static char sccsid[] = "@(#)s_socks.c 1.0 28/9/98 (C) 1998 InfoMedia Inc."; static char sccsid[] = "@(#)s_socks.c 1.0 28/9/98 ";
#endif #endif
@@ -45,7 +45,7 @@ static char sccsid[] = "@(#)s_socks.c 1.0 28/9/98 (C) 1998 InfoMedia Inc.";
#include <io.h> #include <io.h>
#endif #endif
#include <fcntl.h> #include <fcntl.h>
#include "sock.h" /* If FD_ZERO isn't define up to this point, */ #include "sock.h" /* If FD_ZERO isn't define up to this point, */
/* define it (BSD4.2 needs this) */ /* define it (BSD4.2 needs this) */
#include "h.h" #include "h.h"
#ifdef SOCKSPORT #ifdef SOCKSPORT
@@ -63,7 +63,7 @@ static unsigned char socksid[12];
void init_socks(aClient *cptr) void init_socks(aClient *cptr)
{ {
unsigned short sport = SOCKSPORT; unsigned short sport = SOCKSPORT;
struct sockaddr_in sin; struct SOCKADDR_IN sin;
socksid[0] = 4; socksid[0] = 4;
socksid[1] = 1; socksid[1] = 1;
@@ -71,16 +71,20 @@ void init_socks(aClient *cptr)
socksid[3] = LOCHAR(sport); socksid[3] = LOCHAR(sport);
socksid[8] = 0; socksid[8] = 0;
if ((cptr->socksfd = socket(AF_INET, SOCK_STREAM, 0)) == -1) if ((cptr->socksfd = socket(AFINET, SOCK_STREAM, 0)) == -1)
return; return;
set_non_blocking(cptr->socksfd, cptr); set_non_blocking(cptr->socksfd, cptr);
sin.sin_addr.s_addr = INADDR_ANY; #ifdef INET6
sin.sin_port = htons(sport); sin.SIN_ADDR = in6addr_any;
sin.sin_family = AF_INET; #else
sin.SIN_ADDR.S_ADDR = INADDR_ANY;
#endif
sin.SIN_PORT = htons(sport);
sin.SIN_FAMILY = AFINET;
if(bind(cptr->socksfd, (struct sockaddr *)&sin, sizeof(sin))) if (bind(cptr->socksfd, (struct SOCKADDR *)&sin, sizeof(sin)))
{ {
#ifdef _WIN32 #ifdef _WIN32
closesocket(cptr->socksfd); closesocket(cptr->socksfd);
@@ -94,7 +98,7 @@ void init_socks(aClient *cptr)
listen(cptr->socksfd, LISTEN_SIZE); listen(cptr->socksfd, LISTEN_SIZE);
/* Socks lietening port is now set up */ /* Socks lietening port is now set up */
/* Similar to discard port */ /* Similar to discard port */
} }
/* /*
@@ -105,53 +109,56 @@ void init_socks(aClient *cptr)
* otherwise, the connection is checked to see if it is a "secure" * otherwise, the connection is checked to see if it is a "secure"
* socks4+ server * socks4+ server
*/ */
void start_socks(cptr) void start_socks(cptr)
aClient *cptr; aClient *cptr;
{ {
struct sockaddr_in sin; struct SOCKADDR_IN sin;
int sinlen = sizeof(struct sockaddr_in); int sinlen = sizeof(struct SOCKADDR_IN);
if ((cptr->socksfd = socket(AF_INET, SOCK_STREAM, 0)) == -1) if ((cptr->socksfd = socket(AFINET, SOCK_STREAM, 0)) == -1)
{ {
Debug((DEBUG_ERROR, "Unable to create socks socket for %s:%s", Debug((DEBUG_ERROR, "Unable to create socks socket for %s:%s",
get_client_name(cptr, TRUE), get_client_name(cptr, TRUE), strerror(get_sockerr(cptr))));
strerror(get_sockerr(cptr))));
return; return;
} }
#ifndef _WIN32 /* this is here in s_auth.c, so I guess it breaks win */ #ifndef _WIN32 /* this is here in s_auth.c, so I guess it breaks win */
if (cptr->socksfd >= (MAXCONNECTIONS - 3)) if (cptr->socksfd >= (MAXCONNECTIONS - 3))
{ {
sendto_ops("Can't allocate fd for socks on %s", sendto_ops("Can't allocate fd for socks on %s",
get_client_name(cptr, TRUE)); get_client_name(cptr, TRUE));
close(cptr->socksfd); close(cptr->socksfd);
cptr->socksfd = -1; cptr->socksfd = -1;
return; return;
} }
#endif
#ifndef INET6
if (find_socksexcept((char *)inetntoa((char *)&cptr->ip)))
#else
if (find_socksexcept((char *)inet_ntop(AF_INET6, (char *)&cptr->ip,
mydummy, MYDUMMY_SIZE)))
#endif #endif
if (find_socksexcept((char *)inetntoa((char *) &cptr->ip)))
goto skip_socks; goto skip_socks;
#ifdef SHOWCONNECTINFO #ifdef SHOWCONNECTINFO
#ifndef _WIN32 #ifndef _WIN32
write(cptr->fd, REPORT_DO_SOCKS, R_do_socks); write(cptr->fd, REPORT_DO_SOCKS, R_do_socks);
#else #else
send(cptr->fd, REPORT_DO_SOCKS, R_do_socks,0); send(cptr->fd, REPORT_DO_SOCKS, R_do_socks, 0);
#endif #endif
#endif #endif
set_non_blocking(cptr->socksfd, cptr); set_non_blocking(cptr->socksfd, cptr);
sin.sin_port = htons(1080); sin.SIN_PORT = htons(1080);
sin.sin_family = AF_INET; sin.SIN_FAMILY = AFINET;
bcopy((char *)&cptr->ip, (char *)&sin.sin_addr, bcopy((char *)&cptr->ip, (char *)&sin.SIN_ADDR, sizeof(struct IN_ADDR));
sizeof(struct in_addr));
if (connect(cptr->socksfd, (struct sockaddr *)&sin, if (connect(cptr->socksfd, (struct SOCKADDR *)&sin,
#ifndef _WIN32 #ifndef _WIN32
sinlen) == -1 && errno != EINPROGRESS) sinlen) == -1 && errno != EINPROGRESS)
#else #else
sinlen) == -1 && (WSAGetLastError() != sinlen) == -1 && (WSAGetLastError() !=
WSAEINPROGRESS && WSAGetLastError() != WSAEWOULDBLOCK)) WSAEINPROGRESS && WSAGetLastError() != WSAEWOULDBLOCK))
#endif #endif
{ {
/* we have no socks server! */ /* we have no socks server! */
@@ -165,17 +172,17 @@ aClient *cptr;
#ifndef _WIN32 #ifndef _WIN32
write(cptr->fd, REPORT_NO_SOCKS, R_no_socks); write(cptr->fd, REPORT_NO_SOCKS, R_no_socks);
#else #else
send(cptr->fd, REPORT_NO_SOCKS, R_no_socks,0); send(cptr->fd, REPORT_NO_SOCKS, R_no_socks, 0);
#endif #endif
#endif #endif
return; return;
} }
cptr->flags |= (FLAGS_WRSOCKS|FLAGS_SOCKS); cptr->flags |= (FLAGS_WRSOCKS | FLAGS_SOCKS);
if (cptr->socksfd > highest_fd) if (cptr->socksfd > highest_fd)
highest_fd = cptr->socksfd; highest_fd = cptr->socksfd;
return; return;
skip_socks: skip_socks:
#ifndef _WIN32 #ifndef _WIN32
close(cptr->socksfd); close(cptr->socksfd);
#else #else
@@ -187,7 +194,7 @@ skip_socks:
#ifndef _WIN32 #ifndef _WIN32
write(cptr->fd, REPORT_NO_SOCKS, R_no_socks); write(cptr->fd, REPORT_NO_SOCKS, R_no_socks);
#else #else
send(cptr->fd, REPORT_NO_SOCKS, R_no_socks,0); send(cptr->fd, REPORT_NO_SOCKS, R_no_socks, 0);
#endif #endif
#endif #endif
return; return;
@@ -198,20 +205,20 @@ skip_socks:
* *
* send the socks server a query to see if it's open. * send the socks server a query to see if it's open.
*/ */
void send_socksquery(cptr) void send_socksquery(cptr)
aClient *cptr; aClient *cptr;
{ {
struct sockaddr_in sin; struct SOCKADDR_IN sin;
int sinlen = sizeof(struct sockaddr_in); int sinlen = sizeof(struct SOCKADDR_IN);
unsigned char socksbuf[12]; unsigned char socksbuf[12];
unsigned long theip; unsigned long theip;
bcopy((char *)&socksid, (char *)&socksbuf, 9); bcopy((char *)&socksid, (char *)&socksbuf, 9);
getsockname(cptr->fd, (struct sockaddr *)&sin, &sinlen); getsockname(cptr->fd, (struct SOCKADDR *)&sin, &sinlen);
theip = htonl(sin.SIN_ADDR.S_ADDR);
theip = htonl(sin.sin_addr.s_addr);
socksbuf[4] = (theip >> 24); socksbuf[4] = (theip >> 24);
socksbuf[5] = (theip >> 16) & 0xFF; socksbuf[5] = (theip >> 16) & 0xFF;
socksbuf[6] = (theip >> 8) & 0xFF; socksbuf[6] = (theip >> 8) & 0xFF;
@@ -233,7 +240,7 @@ aClient *cptr;
#ifndef _WIN32 #ifndef _WIN32
write(cptr->fd, REPORT_NO_SOCKS, R_no_socks); write(cptr->fd, REPORT_NO_SOCKS, R_no_socks);
#else #else
send(cptr->fd, REPORT_NO_SOCKS, R_no_socks,0); send(cptr->fd, REPORT_NO_SOCKS, R_no_socks, 0);
#endif #endif
#endif #endif
} }
@@ -247,11 +254,11 @@ aClient *cptr;
* process the socks reply. * process the socks reply.
*/ */
void read_socks(cptr) void read_socks(cptr)
aClient *cptr; aClient *cptr;
{ {
unsigned char socksbuf[12]; unsigned char socksbuf[12];
int len; int len;
len = recv(cptr->socksfd, socksbuf, 9, 0); len = recv(cptr->socksfd, socksbuf, 9, 0);
@@ -266,19 +273,19 @@ aClient *cptr;
cptr->socksfd = -1; cptr->socksfd = -1;
ClearSocks(cptr); ClearSocks(cptr);
if(len < 4) if (len < 4)
{ {
#ifdef SHOWCONNECTINFO #ifdef SHOWCONNECTINFO
#ifndef _WIN32 #ifndef _WIN32
write(cptr->fd, REPORT_NO_SOCKS, R_no_socks); write(cptr->fd, REPORT_NO_SOCKS, R_no_socks);
#else #else
send(cptr->fd, REPORT_NO_SOCKS, R_no_socks,0); send(cptr->fd, REPORT_NO_SOCKS, R_no_socks, 0);
#endif #endif
#endif #endif
return; return;
} }
if(socksbuf[1] == 90) if (socksbuf[1] == 90)
{ {
cptr->flags |= FLAGS_GOTSOCKS; cptr->flags |= FLAGS_GOTSOCKS;
return; return;
@@ -288,9 +295,9 @@ aClient *cptr;
#ifndef _WIN32 #ifndef _WIN32
write(cptr->fd, REPORT_GOOD_SOCKS, R_good_socks); write(cptr->fd, REPORT_GOOD_SOCKS, R_good_socks);
#else #else
send(cptr->fd, REPORT_GOOD_SOCKS, R_good_socks,0); send(cptr->fd, REPORT_GOOD_SOCKS, R_good_socks, 0);
#endif #endif
#endif #endif
return; return;
} }
#endif #endif
+971 -672
View File
File diff suppressed because it is too large Load Diff
+3072 -2704
View File
File diff suppressed because it is too large Load Diff
+773 -561
View File
File diff suppressed because it is too large Load Diff
+24 -16
View File
@@ -52,34 +52,38 @@ static char *rcsid = "$NetBSD: strtoul.c,v 1.9 1996/07/20 01:00:57 jtc Exp $";
* Ignores `locale' stuff. Assumes that the upper and lower case * Ignores `locale' stuff. Assumes that the upper and lower case
* alphabets and digits are each contiguous. * alphabets and digits are each contiguous.
*/ */
unsigned long unsigned long strtoul(nptr, endptr, base)
strtoul(nptr, endptr, base)
char *nptr; char *nptr;
char **endptr; char **endptr;
int base; int base;
{ {
char *s; char *s;
unsigned long acc, cutoff; unsigned long acc, cutoff;
int c; int c;
int neg, any, cutlim; int neg, any, cutlim;
/* /*
* See strtol for comments as to the logic used. * See strtol for comments as to the logic used.
*/ */
s = nptr; s = nptr;
do { do
c = (unsigned char) *s++; {
} while (isspace(c)); c = (unsigned char)*s++;
if (c == '-') { }
while (isspace(c));
if (c == '-')
{
neg = 1; neg = 1;
c = *s++; c = *s++;
} else { }
else
{
neg = 0; neg = 0;
if (c == '+') if (c == '+')
c = *s++; c = *s++;
} }
if ((base == 0 || base == 16) && if ((base == 0 || base == 16) && c == '0' && (*s == 'x' || *s == 'X'))
c == '0' && (*s == 'x' || *s == 'X')) { {
c = s[1]; c = s[1];
s += 2; s += 2;
base = 16; base = 16;
@@ -89,7 +93,8 @@ strtoul(nptr, endptr, base)
cutoff = ULONG_MAX / (unsigned long)base; cutoff = ULONG_MAX / (unsigned long)base;
cutlim = ULONG_MAX % (unsigned long)base; cutlim = ULONG_MAX % (unsigned long)base;
for (acc = 0, any = 0;; c = (unsigned char) *s++) { for (acc = 0, any = 0;; c = (unsigned char)*s++)
{
if (isdigit(c)) if (isdigit(c))
c -= '0'; c -= '0';
else if (isalpha(c)) else if (isalpha(c))
@@ -100,11 +105,14 @@ strtoul(nptr, endptr, base)
break; break;
if (any < 0) if (any < 0)
continue; continue;
if (acc > cutoff || acc == cutoff && c > cutlim) { if (acc > cutoff || acc == cutoff && c > cutlim)
{
any = -1; any = -1;
acc = ULONG_MAX; acc = ULONG_MAX;
errno = ERANGE; errno = ERANGE;
} else { }
else
{
any = 1; any = 1;
acc *= (unsigned long)base; acc *= (unsigned long)base;
acc += c; acc += c;
@@ -113,6 +121,6 @@ strtoul(nptr, endptr, base)
if (neg && any > 0) if (neg && any > 0)
acc = -acc; acc = -acc;
if (endptr != 0) if (endptr != 0)
*endptr = (char *) (any ? s - 1 : nptr); *endptr = (char *)(any ? s - 1 : nptr);
return (acc); return (acc);
} }
+296 -218
View File
@@ -1,5 +1,6 @@
/************************************************************************ /************************************************************************
* IRC - Internet Relay Chat, common/support.c /************************************************************************
* Unreal Internet Relay Chat Daemon, src/support.c
* Copyright (C) 1990, 1991 Armin Gruner * Copyright (C) 1990, 1991 Armin Gruner
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@@ -18,7 +19,7 @@
*/ */
#ifndef lint #ifndef lint
static char sccsid[] = "@(#)support.c 2.21 4/13/94 1990, 1991 Armin Gruner;\ static char sccsid[] = "@(#)support.c 2.21 4/13/94 1990, 1991 Armin Gruner;\
1992, 1993 Darren Reed"; 1992, 1993 Darren Reed";
#endif #endif
@@ -36,9 +37,9 @@ static char sccsid[] = "@(#)support.c 2.21 4/13/94 1990, 1991 Armin Gruner;\
ID_CVS("$Id$"); ID_CVS("$Id$");
extern int errno; /* ...seems that errno.h doesn't define this everywhere */ extern int errno; /* ...seems that errno.h doesn't define this everywhere */
#endif #endif
extern void outofmemory(); extern void outofmemory();
#ifdef NEED_STRTOKEN #ifdef NEED_STRTOKEN
/* /*
@@ -50,33 +51,33 @@ extern void outofmemory();
*/ */
char *strtoken(save, str, fs) char *strtoken(save, str, fs)
char **save; char **save;
char *str, *fs; char *str, *fs;
{ {
char *pos = *save; /* keep last position across calls */ char *pos = *save; /* keep last position across calls */
Reg1 char *tmp; char *tmp;
if (str) if (str)
pos = str; /* new string scan */ pos = str; /* new string scan */
while (pos && *pos && index(fs, *pos) != NULL) while (pos && *pos && index(fs, *pos) != NULL)
pos++; /* skip leading separators */ pos++; /* skip leading separators */
if (!pos || !*pos) if (!pos || !*pos)
return (pos = *save = NULL); /* string contains only sep's */ return (pos = *save = NULL); /* string contains only sep's */
tmp = pos; /* now, keep position of the token */ tmp = pos; /* now, keep position of the token */
while (*pos && index(fs, *pos) == NULL) while (*pos && index(fs, *pos) == NULL)
pos++; /* skip content of the token */ pos++; /* skip content of the token */
if (*pos) if (*pos)
*pos++ = '\0'; /* remove first sep after the token */ *pos++ = '\0'; /* remove first sep after the token */
else else
pos = NULL; /* end of string */ pos = NULL; /* end of string */
*save = pos; *save = pos;
return(tmp); return (tmp);
} }
#endif /* NEED_STRTOKEN */ #endif /* NEED_STRTOKEN */
@@ -86,11 +87,11 @@ char *str, *fs;
*/ */
char *strtok2(str, fs) char *strtok2(str, fs)
char *str, *fs; char *str, *fs;
{ {
static char *pos; static char *pos;
return strtoken(&pos, str, fs); return strtoken(&pos, str, fs);
} }
#endif /* NEED_STRTOK */ #endif /* NEED_STRTOK */
@@ -104,33 +105,33 @@ char *str, *fs;
*/ */
char *strerror(err_no) char *strerror(err_no)
int err_no; int err_no;
{ {
extern char *sys_errlist[]; /* Sigh... hopefully on all systems */ extern char *sys_errlist[]; /* Sigh... hopefully on all systems */
extern int sys_nerr; extern int sys_nerr;
static char buff[40]; static char buff[40];
char *errp; char *errp;
errp = (err_no > sys_nerr ? (char *)NULL : sys_errlist[err_no]); errp = (err_no > sys_nerr ? (char *)NULL : sys_errlist[err_no]);
if (errp == (char *)NULL) if (errp == (char *)NULL)
{ {
errp = buff; errp = buff;
#ifndef _WIN32 #ifndef _WIN32
(void) sprintf(errp, "Unknown Error %d", err_no); (void)ircsprintf(errp, "Unknown Error %d", err_no);
#else #else
switch (err_no) switch (err_no)
{ {
case WSAECONNRESET: case WSAECONNRESET:
sprintf(errp, "Connection reset by peer"); ircsprintf(errp, "Connection reset by peer");
break; break;
default: default:
sprintf(errp, "Unknown Error %d", err_no); ircsprintf(errp, "Unknown Error %d", err_no);
break; break;
} }
#endif #endif
} }
return errp; return errp;
} }
@@ -147,18 +148,18 @@ int err_no;
** $Id$ ** $Id$
*/ */
char *inetntoa(in) char *inetntoa(in)
char *in; char *in;
{ {
static char buf[16]; static char buf[16];
Reg1 u_char *s = (u_char *)in; u_char *s = (u_char *)in;
Reg2 int a,b,c,d; int a, b, c, d;
a = (int)*s++; a = (int)*s++;
b = (int)*s++; b = (int)*s++;
c = (int)*s++; c = (int)*s++;
d = (int)*s++; d = (int)*s++;
(void) sprintf(buf, "%d.%d.%d.%d", a,b,c,d ); (void)ircsprintf(buf, "%d.%d.%d.%d", a, b, c, d);
return buf; return buf;
} }
@@ -171,31 +172,32 @@ char *in;
** **
*/ */
int inet_netof(in) int inet_netof(in)
struct in_addr in; struct IN_ADDR in;
{ {
int addr = in.s_net; int addr = in.s_net;
if (addr & 0x80 == 0) if (addr & 0x80 == 0)
return ((int) in.s_net); return ((int)in.s_net);
if (addr & 0x40 == 0) if (addr & 0x40 == 0)
return ((int) in.s_net * 256 + in.s_host); return ((int)in.s_net * 256 + in.s_host);
return ((int) in.s_net * 256 + in.s_host * 256 + in.s_lh); return ((int)in.s_net * 256 + in.s_host * 256 + in.s_lh);
} }
#endif /* NEED_INET_NETOF */ #endif /* NEED_INET_NETOF */
#if defined(DEBUGMODE) #if defined(DEBUGMODE)
void dumpcore(msg, p1, p2, p3, p4, p5, p6, p7, p8, p9) void dumpcore(msg, p1, p2, p3, p4, p5, p6, p7, p8, p9)
char *msg, *p1, *p2, *p3, *p4, *p5, *p6, *p7, *p8, *p9; char *msg, *p1, *p2, *p3, *p4, *p5, *p6, *p7, *p8, *p9;
{ {
static time_t lastd = 0; static time_t lastd = 0;
static int dumps = 0; static int dumps = 0;
char corename[12]; char corename[12];
time_t now; time_t now;
int p; int p;
now = time(NULL); now = time(NULL);
@@ -204,43 +206,43 @@ char *msg, *p1, *p2, *p3, *p4, *p5, *p6, *p7, *p8, *p9;
else if (now - lastd < 60 && dumps > 2) else if (now - lastd < 60 && dumps > 2)
(void)s_die(); (void)s_die();
if (now - lastd > 60) if (now - lastd > 60)
{ {
lastd = now; lastd = now;
dumps = 1; dumps = 1;
} }
else else
dumps++; dumps++;
#if !defined(_WIN32) && !defined(_AMIGA) #if !defined(_WIN32) && !defined(_AMIGA)
p = getpid(); p = getpid();
if (fork()>0) { if (fork() > 0)
{
kill(p, 3); kill(p, 3);
kill(p, 9); kill(p, 9);
} }
write_pidfile(); write_pidfile();
(void)sprintf(corename, "core.%d", p); (void)ircsprintf(corename, "core.%d", p);
(void)rename("core", corename); (void)rename("core", corename);
Debug((DEBUG_FATAL, "Dumped core : core.%d", p)); Debug((DEBUG_FATAL, "Dumped core : core.%d", p));
sendto_ops("Dumped core : core.%d", p); sendto_ops("Dumped core : core.%d", p);
#endif #endif
Debug((DEBUG_FATAL, msg, p1, p2, p3, p4, p5, p6, p7, p8, p9)); Debug((DEBUG_FATAL, msg, p1, p2, p3, p4, p5, p6, p7, p8, p9));
sendto_ops(msg, p1, p2, p3, p4, p5, p6, p7, p8, p9); sendto_ops(msg, p1, p2, p3, p4, p5, p6, p7, p8, p9);
(void)s_die(); (void)s_die();
} }
static char *marray[20000]; static char *marray[20000];
static int mindex = 0; static int mindex = 0;
#define SZ_EX (sizeof(char *) + sizeof(size_t) + 4) #define SZ_EX (sizeof(char *) + sizeof(size_t) + 4)
#define SZ_CHST (sizeof(char *) + sizeof(size_t)) #define SZ_CHST (sizeof(char *) + sizeof(size_t))
#define SZ_CH (sizeof(char *)) #define SZ_CH (sizeof(char *))
#define SZ_ST (sizeof(size_t)) #define SZ_ST (sizeof(size_t))
char *MyMalloc(x)
char *MyMalloc(x) size_t x;
size_t x;
{ {
register int i; int i;
register char **s; char **s;
char *ret; char *ret;
#ifndef _WIN32 #ifndef _WIN32
ret = (char *)malloc(x + (size_t)SZ_EX); ret = (char *)malloc(x + (size_t)SZ_EX);
@@ -249,34 +251,34 @@ size_t x;
#endif #endif
if (!ret) if (!ret)
{ {
outofmemory(); outofmemory();
} }
bzero(ret, (int)x + SZ_EX); bzero(ret, (int)x + SZ_EX);
bcopy((char *)&ret, ret, SZ_CH); bcopy((char *)&ret, ret, SZ_CH);
bcopy((char *)&x, ret + SZ_CH, SZ_ST); bcopy((char *)&x, ret + SZ_CH, SZ_ST);
bcopy("VAVA", ret + SZ_CHST + (int)x, 4); bcopy("VAVA", ret + SZ_CHST + (int)x, 4);
Debug((DEBUG_MALLOC, "MyMalloc(%ld) = %#x", x, ret+8)); Debug((DEBUG_MALLOC, "MyMalloc(%ld) = %#x", x, ret + 8));
for(i = 0, s = marray; *s && i < mindex; i++, s++) for (i = 0, s = marray; *s && i < mindex; i++, s++)
; ;
if (i < 20000) if (i < 20000)
{ {
*s = ret; *s = ret;
if (i == mindex) if (i == mindex)
mindex++; mindex++;
} }
return ret + SZ_CHST; return ret + SZ_CHST;
} }
char *MyRealloc(x, y) char *MyRealloc(x, y)
char *x; char *x;
size_t y; size_t y;
{ {
register int l; int l;
register char **s; char **s;
char *ret, *cp; char *ret, *cp;
size_t i; size_t i;
int k; int k;
x -= SZ_CHST; x -= SZ_CHST;
bcopy(x, (char *)&cp, SZ_CH); bcopy(x, (char *)&cp, SZ_CH);
@@ -287,42 +289,44 @@ size_t y;
#ifndef _WIN32 #ifndef _WIN32
ret = (char *)realloc(x, y + (size_t)SZ_EX); ret = (char *)realloc(x, y + (size_t)SZ_EX);
#else #else
ret = (char *)GlobalReAlloc(x, y + (size_t)SZ_EX, GMEM_MOVEABLE|GMEM_ZEROINIT); ret =
(char *)GlobalReAlloc(x, y + (size_t)SZ_EX,
GMEM_MOVEABLE | GMEM_ZEROINIT);
#endif #endif
if (!ret) if (!ret)
{ {
outofmemory(); outofmemory();
} }
bcopy((char *)&ret, ret, SZ_CH); bcopy((char *)&ret, ret, SZ_CH);
bcopy((char *)&y, ret + SZ_CH, SZ_ST); bcopy((char *)&y, ret + SZ_CH, SZ_ST);
bcopy("VAVA", ret + SZ_CHST + (int)y, 4); bcopy("VAVA", ret + SZ_CHST + (int)y, 4);
Debug((DEBUG_NOTICE, "MyRealloc(%#x,%ld) = %#x", x, y, ret + SZ_CHST)); Debug((DEBUG_NOTICE, "MyRealloc(%#x,%ld) = %#x", x, y, ret + SZ_CHST));
for(l = 0, s = marray; *s != x && l < mindex; l++, s++) for (l = 0, s = marray; *s != x && l < mindex; l++, s++)
; ;
if (l < mindex) if (l < mindex)
*s = NULL; *s = NULL;
else if (l == mindex) else if (l == mindex)
Debug((DEBUG_MALLOC, "%#x !found", x)); Debug((DEBUG_MALLOC, "%#x !found", x));
for(l = 0, s = marray; *s && l < mindex; l++,s++) for (l = 0, s = marray; *s && l < mindex; l++, s++)
; ;
if (l < 20000) if (l < 20000)
{ {
*s = ret; *s = ret;
if (l == mindex) if (l == mindex)
mindex++; mindex++;
} }
return ret + SZ_CHST; return ret + SZ_CHST;
} }
void MyFree(x) void MyFree(x)
char *x; char *x;
{ {
size_t i; size_t i;
char *j; char *j;
u_char k[4]; u_char k[4];
register int l; int l;
register char **s; char **s;
if (!x) if (!x)
return; return;
@@ -334,7 +338,7 @@ char *x;
if (bcmp((char *)k, "VAVA", 4) || (j != x)) if (bcmp((char *)k, "VAVA", 4) || (j != x))
dumpcore("MyFree %#x %ld %#x %#x", x, i, j, dumpcore("MyFree %#x %ld %#x %#x", x, i, j,
(k[3]<<24) | (k[2]<<16) | (k[1]<<8) | k[0]); (k[3] << 24) | (k[2] << 16) | (k[1] << 8) | k[0]);
#undef free #undef free
#ifndef _WIN32 #ifndef _WIN32
@@ -343,7 +347,7 @@ char *x;
(void)GlobalFree(x); (void)GlobalFree(x);
#endif #endif
#define free(x) MyFree(x) #define free(x) MyFree(x)
Debug((DEBUG_MALLOC, "MyFree(%#x)",x + SZ_CHST)); Debug((DEBUG_MALLOC, "MyFree(%#x)", x + SZ_CHST));
for (l = 0, s = marray; *s != x && l < mindex; l++, s++) for (l = 0, s = marray; *s != x && l < mindex; l++, s++)
; ;
@@ -354,8 +358,8 @@ char *x;
} }
#else #else
char *MyMalloc(x) char *MyMalloc(x)
size_t x; size_t x;
{ {
#ifndef _WIN32 #ifndef _WIN32
char *ret = (char *)malloc(x); char *ret = (char *)malloc(x);
@@ -364,137 +368,211 @@ size_t x;
#endif #endif
if (!ret) if (!ret)
{ {
outofmemory(); outofmemory();
} }
return ret; return ret;
} }
char *MyRealloc(x, y) char *MyRealloc(x, y)
char *x; char *x;
size_t y; size_t y;
{ {
#ifndef _WIN32 #ifndef _WIN32
char *ret = (char *)realloc(x, y); char *ret = (char *)realloc(x, y);
#else #else
char *ret = (char *)GlobalReAlloc(x, y, GMEM_MOVEABLE|GMEM_ZEROINIT); char *ret = (char *)GlobalReAlloc(x, y, GMEM_MOVEABLE | GMEM_ZEROINIT);
#endif #endif
if (!ret) if (!ret)
{ {
outofmemory(); outofmemory();
} }
return ret; return ret;
} }
#endif #endif
/* /*
** read a string terminated by \r or \n in from a fd * * read a string terminated by \r or \n in from a fd *
** *
** Created: Sat Dec 12 06:29:58 EST 1992 by avalon * Created: Sat Dec 12 06:29:58 EST 1992 by avalon * Returns: * 0 - EOF *
** Returns: * -1 - error on read * >0 - number of bytes returned (<=num) *
** 0 - EOF * After opening a fd, it is necessary to init dgets() by calling it as *
** -1 - error on read * dgets(x,y,0); * to mark the buffer as being empty.
** >0 - number of bytes returned (<=num) *
** After opening a fd, it is necessary to init dgets() by calling it as * cleaned up by - Dianora aug 7 1997 *argh*
** dgets(x,y,0); */
** to mark the buffer as being empty. int dgets(int fd, char *buf, int num)
*/
int dgets(fd, buf, num)
int fd, num;
char *buf;
{ {
static char dgbuf[8192]; static char dgbuf[8192];
static char *head = dgbuf, *tail = dgbuf; static char *head = dgbuf, *tail = dgbuf;
register char *s, *t; char *s, *t;
register int n, nr; int n, nr;
/* /*
** Sanity checks. * * Sanity checks.
*/ */
if (head == tail) if (head == tail)
*head = '\0'; *head = '\0';
if (!num) if (!num)
{ {
head = tail = dgbuf; head = tail = dgbuf;
*head = '\0'; *head = '\0';
return 0; return 0;
} }
if (num > sizeof(dgbuf) - 1) if (num > sizeof(dgbuf) - 1)
num = sizeof(dgbuf) - 1; num = sizeof(dgbuf) - 1;
dgetsagain:
if (head > dgbuf) for (;;) /* FOREVER */
{ {
for (nr = tail - head, s = head, t = dgbuf; nr > 0; nr--) if (head > dgbuf)
*t++ = *s++; {
tail = t; for (nr = tail - head, s = head, t = dgbuf; nr > 0;
head = dgbuf; nr--)
} *t++ = *s++;
/* tail = t;
** check input buffer for EOL and if present return string. head = dgbuf;
*/ }
if (head < tail && /*
((s = index(head, '\n')) || (s = index(head, '\r'))) && s < tail) * * check input buffer for EOL and if present return string.
{ */
n = MIN(s - head + 1, num); /* at least 1 byte */ if (head < tail &&
dgetsreturnbuf: ((s = (char *)strchr(head, '\n'))
bcopy(head, buf, n); || (s = (char *)strchr(head, '\r'))) && s < tail)
head += n; {
if (head == tail) n = MIN(s - head + 1, num); /*
* at least 1 byte
*/
memcpy(buf, head, n);
head += n;
if (head == tail)
head = tail = dgbuf;
return n;
}
if (tail - head >= num)
{ /*
* dgets buf is big enough
*/
n = num;
memcpy(buf, head, n);
head += n;
if (head == tail)
head = tail = dgbuf;
return n;
}
n = sizeof(dgbuf) - (tail - dgbuf) - 1;
nr = read(fd, tail, n);
if (nr == -1)
{
head = tail = dgbuf; head = tail = dgbuf;
return n; return -1;
} }
if (tail - head >= num) /* dgets buf is big enough */ if (!nr)
{ {
n = num; if (tail > head)
goto dgetsreturnbuf; {
} n = MIN(tail - head, num);
memcpy(buf, head, n);
head += n;
if (head == tail)
head = tail = dgbuf;
return n;
}
head = tail = dgbuf;
return 0;
}
n = sizeof(dgbuf) - (tail - dgbuf) - 1; tail += nr;
nr = read(fd, tail, n); *tail = '\0';
if (nr == -1)
{ for (t = head; (s = (char *)strchr(t, '\n'));)
head = tail = dgbuf; {
return -1; if ((s > head) && (s > dgbuf))
} {
if (!nr) t = s - 1;
{ for (nr = 0; *t == '\\'; nr++)
if (head < tail) t--;
{ if (nr & 1)
n = MIN(tail - head, num); {
goto dgetsreturnbuf; t = s + 1;
} s--;
head = tail = dgbuf; nr = tail - t;
return 0; while (nr--)
} *s++ = *t++;
tail += nr; tail -= 2;
*tail = '\0'; *tail = '\0';
for (t = head; (s = index(t, '\n')); ) }
{ else
if ((s > head) && (s > dgbuf)) s++;
{ }
t = s-1;
for (nr = 0; *t == '\\'; nr++)
t--;
if (nr & 1)
{
t = s+1;
s--;
nr = tail - t;
while (nr--)
*s++ = *t++;
tail -= 2;
*tail = '\0';
}
else else
s++; s++;
} t = s;
else }
s++; *tail = '\0';
t = s; }
}
*tail = '\0';
goto dgetsagain;
} }
#ifdef INET6
/*
* inetntop: return the : notation of a given IPv6 internet number.
* make sure the compressed representation (rfc 1884) isn't used.
*/
char *inetntop(af, in, out, the_size)
int af;
const void *in;
char *out;
size_t the_size;
{
static char local_dummy[MYDUMMY_SIZE];
inet_ntop(af, in, local_dummy, the_size);
if (strstr(local_dummy, "::"))
{
char cnt = 0, *cp = local_dummy, *op = out;
while (*cp)
{
if (*cp == ':')
cnt += 1;
if (*cp++ == '.')
{
cnt += 1;
break;
}
}
cp = local_dummy;
while (*cp)
{
*op++ = *cp++;
if (*(cp - 1) == ':' && *cp == ':')
{
if ((cp - 1) == local_dummy)
{
op--;
*op++ = '0';
*op++ = ':';
}
*op++ = '0';
while (cnt++ < 7)
{
*op++ = ':';
*op++ = '0';
}
}
}
if (*(op - 1) == ':')
*op++ = '0';
*op = '\0';
Debug((DEBUG_DNS, "Expanding `%s' -> `%s'", local_dummy, out));
}
else
bcopy(local_dummy, out, 64);
return out;
}
#endif
+294 -239
View File
@@ -1,8 +1,9 @@
/****************************************************************************
/**************************************************************************** /****************************************************************************
* Userload module by Michael L. VanLoon (mlv) <michaelv@iastate.edu> * Userload module by Michael L. VanLoon (mlv) <michaelv@iastate.edu>
* Written 2/93. Originally grafted into irc2.7.2g 4/93. * Written 2/93. Originally grafted into irc2.7.2g 4/93.
* *
* IRC - Internet Relay Chat, ircd/userload.c * Unreal Internet Relay Chat Daemon, src/userload.c
* Copyright (C) 1990 University of Oulu, Computing Center * Copyright (C) 1990 University of Oulu, Computing Center
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@@ -43,325 +44,379 @@ ID_CVS("$Id$");
struct current_load_struct current_load_data; struct current_load_struct current_load_data;
struct load_entry *load_list_head = NULL, *load_list_tail = NULL, struct load_entry *load_list_head = NULL, *load_list_tail = NULL,
*load_free_head = NULL, *load_free_tail = NULL; *load_free_head = NULL, *load_free_tail = NULL;
#ifdef DEBUGMODE #ifdef DEBUGMODE
clock_t clock_last = 0; clock_t clock_last = 0;
#endif #endif
void update_load() void update_load()
{ {
static struct timeval now, last; static struct timeval now, last;
register struct load_entry *cur_load_entry; struct load_entry *cur_load_entry;
/* This seems to get polluted on startup by an exit_client() /* This seems to get polluted on startup by an exit_client()
* before any connections have been recorded. * before any connections have been recorded.
*/ */
if (current_load_data.local_count > MAXCONNECTIONS || if (current_load_data.local_count > MAXCONNECTIONS ||
current_load_data.client_count > MAXCONNECTIONS || current_load_data.client_count > MAXCONNECTIONS ||
current_load_data.conn_count > MAXCONNECTIONS) current_load_data.conn_count > MAXCONNECTIONS)
bzero(&current_load_data, sizeof(struct current_load_struct)); bzero(&current_load_data, sizeof(struct current_load_struct));
memcpy(&last, &now, sizeof(struct timeval)); memcpy(&last, &now, sizeof(struct timeval));
#ifndef _WIN32 #ifndef _WIN32
if (gettimeofday(&now, NULL) != 0) if (gettimeofday(&now, NULL) != 0)
return; /* error getting time of day--can't calculate time diff */ return; /* error getting time of day--can't calculate time diff */
#else #else
/* Well, since the windows libs don't have gettimeofday() we have /* Well, since the windows libs don't have gettimeofday() we have
* to improvise a bit, hopefully this will achieve close to the * to improvise a bit, hopefully this will achieve close to the
* same result. -Cabal95 * same result. -Cabal95
*/ */
now.tv_sec = TStime(); now.tv_sec = TStime();
#endif #endif
if (load_free_tail == NULL) { if (load_free_tail == NULL)
if ((cur_load_entry = {
(struct load_entry *) MyMalloc(sizeof(struct load_entry))) == NULL) if ((cur_load_entry =
return; (struct load_entry *)MyMalloc(sizeof(struct load_entry))) ==
/* printf("malloc pointer: %x\n", cur_load_entry); */ NULL)
} else { return;
cur_load_entry = load_free_tail; /* printf("malloc pointer: %x\n", cur_load_entry); */
load_free_tail = cur_load_entry->prev; }
if (load_free_tail == NULL) else
load_free_head = NULL; {
/* printf("free pointer: %x\n", cur_load_entry); */ cur_load_entry = load_free_tail;
} load_free_tail = cur_load_entry->prev;
if (load_list_tail != NULL) { if (load_free_tail == NULL)
load_free_head = NULL;
/* printf("free pointer: %x\n", cur_load_entry); */
}
if (load_list_tail != NULL)
{
#ifndef _WIN32 #ifndef _WIN32
cur_load_entry->time_incr = ((now.tv_sec * 1000 + now.tv_usec / 1000 + 5) cur_load_entry->time_incr =
- (last.tv_sec * 1000 + last.tv_usec / 1000)) / 10; ((now.tv_sec * 1000 + now.tv_usec / 1000 + 5) -
(last.tv_sec * 1000 + last.tv_usec / 1000)) / 10;
#else #else
/* Don't even use *.tv_usec since its an unknown value. -Cabal95 */ /* Don't even use *.tv_usec since its an unknown value. -Cabal95 */
cur_load_entry->time_incr = ((now.tv_sec * 1000 + 5) cur_load_entry->time_incr = ((now.tv_sec * 1000 + 5)
- last.tv_sec * 1000) / 10; - last.tv_sec * 1000) / 10;
#endif #endif
cur_load_entry->local_count = current_load_data.local_count; cur_load_entry->local_count = current_load_data.local_count;
cur_load_entry->client_count = current_load_data.client_count; cur_load_entry->client_count = current_load_data.client_count;
cur_load_entry->conn_count = current_load_data.conn_count; cur_load_entry->conn_count = current_load_data.conn_count;
#ifdef DEBUGMODE #ifdef DEBUGMODE
cur_load_entry->cpu_usage = (clock()-clock_last); cur_load_entry->cpu_usage = (clock() - clock_last);
clock_last = clock(); clock_last = clock();
#endif #endif
} else { }
load_list_head = cur_load_entry; else
bzero(cur_load_entry, sizeof(struct load_entry)); {
cur_load_entry->time_incr = 1; load_list_head = cur_load_entry;
} bzero(cur_load_entry, sizeof(struct load_entry));
cur_load_entry->prev = load_list_tail; cur_load_entry->time_incr = 1;
load_list_tail = cur_load_entry; }
cur_load_entry->prev = load_list_tail;
load_list_tail = cur_load_entry;
} }
void calc_load(sptr, parv) void calc_load(sptr, parv)
aClient *sptr; aClient *sptr;
char *parv; /* we only get passed the original parv[0] */ char *parv; /* we only get passed the original parv[0] */
{ {
register struct load_entry *cur_load_entry; struct load_entry *cur_load_entry;
struct load_entry *last; struct load_entry *last;
#ifdef DEBUGMODE #ifdef DEBUGMODE
u_long secs = 0, adj_secs, total[4], adj[4];/*[local,client,conn,cpu]*/ u_long secs = 0, adj_secs, total[4], adj[4]; /*[local,client,conn,cpu] */
int i; int i;
u_int times[5][4]; /* [min,hour,day,Yest,YYest][local,client,conn,cpu] */ u_int times[5][4]; /* [min,hour,day,Yest,YYest][local,client,conn,cpu] */
char what[4][HOSTLEN + 1]; char what[4][HOSTLEN + 1];
bzero(total, 4 * sizeof(u_long)); bzero(total, 4 * sizeof(u_long));
#else #else
u_long secs = 0, adj_secs, total[3], adj[3];/*[local,client,conn]*/ u_long secs = 0, adj_secs, total[3], adj[3]; /*[local,client,conn] */
int i, times[5][3]; /* [min,hour,day,Yest,YYest][local,client,conn] */ int i, times[5][3]; /* [min,hour,day,Yest,YYest][local,client,conn] */
char what[3][HOSTLEN + 1]; char what[3][HOSTLEN + 1];
bzero(total, 3 * sizeof(u_long)); bzero(total, 3 * sizeof(u_long));
#endif #endif
current_load_data.entries = 0; current_load_data.entries = 0;
update_load(); /* we want stats accurate as of *now* */ update_load(); /* we want stats accurate as of *now* */
for (cur_load_entry = load_list_tail; (secs < 6000) && for (cur_load_entry = load_list_tail; (secs < 6000) &&
(cur_load_entry != NULL); cur_load_entry = cur_load_entry->prev) { (cur_load_entry != NULL); cur_load_entry = cur_load_entry->prev)
u_long time_incr = cur_load_entry->time_incr; {
total[0] += time_incr * cur_load_entry->local_count; u_long time_incr = cur_load_entry->time_incr;
total[1] += time_incr * cur_load_entry->client_count; total[0] += time_incr * cur_load_entry->local_count;
total[2] += time_incr * cur_load_entry->conn_count; total[1] += time_incr * cur_load_entry->client_count;
total[2] += time_incr * cur_load_entry->conn_count;
#ifdef DEBUGMODE #ifdef DEBUGMODE
total[3] += cur_load_entry->cpu_usage; total[3] += cur_load_entry->cpu_usage;
#endif #endif
last = cur_load_entry; last = cur_load_entry;
secs += cur_load_entry->time_incr; secs += cur_load_entry->time_incr;
current_load_data.entries++; current_load_data.entries++;
} }
if ((secs > 6000) && (last != NULL)) { if ((secs > 6000) && (last != NULL))
adj_secs = secs - 6000; {
adj[0] = adj_secs * last->local_count; adj_secs = secs - 6000;
adj[1] = adj_secs * last->client_count; adj[0] = adj_secs * last->local_count;
adj[2] = adj_secs * last->conn_count; adj[1] = adj_secs * last->client_count;
adj[2] = adj_secs * last->conn_count;
#ifdef DEBUGMODE #ifdef DEBUGMODE
times[0][3] = total[3]-(last->cpu_usage*(double)adj_secs/last->time_incr); times[0][3] =
} else { total[3] -
adj_secs = adj[0] = adj[1] = adj[2] = adj[3] = 0; (last->cpu_usage * (double)adj_secs / last->time_incr);
times[0][3] = total[3]; }
} else
{
adj_secs = adj[0] = adj[1] = adj[2] = adj[3] = 0;
times[0][3] = total[3];
}
#else #else
} else }
adj_secs = adj[0] = adj[1] = adj[2] = 0; else
adj_secs = adj[0] = adj[1] = adj[2] = 0;
#endif #endif
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++)
times[0][i] = ((total[i] - adj[i]) * 1000 / (secs - adj_secs) + 5) / 10; {
} times[0][i] =
((total[i] - adj[i]) * 1000 / (secs - adj_secs) + 5) / 10;
}
secs = (secs + 5) / 10; secs = (secs + 5) / 10;
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
total[i] = (total[i] + 5) / 10; total[i] = (total[i] + 5) / 10;
for ( ; (secs < 36000) && (cur_load_entry != NULL); secs += for (; (secs < 36000) && (cur_load_entry != NULL); secs +=
(cur_load_entry->time_incr + 5) / 10, cur_load_entry = (cur_load_entry->time_incr + 5) / 10, cur_load_entry =
cur_load_entry->prev, current_load_data.entries++) { cur_load_entry->prev, current_load_data.entries++)
u_long time_incr = (cur_load_entry->time_incr + 5) / 10; {
total[0] += time_incr * cur_load_entry->local_count; u_long time_incr = (cur_load_entry->time_incr + 5) / 10;
total[1] += time_incr * cur_load_entry->client_count; total[0] += time_incr * cur_load_entry->local_count;
total[2] += time_incr * cur_load_entry->conn_count; total[1] += time_incr * cur_load_entry->client_count;
total[2] += time_incr * cur_load_entry->conn_count;
#ifdef DEBUGMODE #ifdef DEBUGMODE
total[3] += cur_load_entry->cpu_usage; total[3] += cur_load_entry->cpu_usage;
#endif #endif
last = cur_load_entry; last = cur_load_entry;
} }
if ((secs > 36000) && (last != NULL)) { if ((secs > 36000) && (last != NULL))
adj_secs = secs - 36000; {
adj[0] = adj_secs * last->local_count; adj_secs = secs - 36000;
adj[1] = adj_secs * last->client_count; adj[0] = adj_secs * last->local_count;
adj[2] = adj_secs * last->conn_count; adj[1] = adj_secs * last->client_count;
adj[2] = adj_secs * last->conn_count;
#ifdef DEBUGMODE #ifdef DEBUGMODE
times[1][3] = total[3]-(last->cpu_usage*(double)adj_secs/last->time_incr); times[1][3] =
} else { total[3] -
adj_secs = adj[0] = adj[1] = adj[2] = adj[3] = 0; (last->cpu_usage * (double)adj_secs / last->time_incr);
times[1][3] = total[3]; }
} else
{
adj_secs = adj[0] = adj[1] = adj[2] = adj[3] = 0;
times[1][3] = total[3];
}
#else #else
} else }
adj_secs = adj[0] = adj[1] = adj[2] = 0; else
adj_secs = adj[0] = adj[1] = adj[2] = 0;
#endif #endif
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++)
times[1][i] = ((total[i] - adj[i]) * 100 / (secs - adj_secs) + 5) / 10; {
} times[1][i] =
((total[i] - adj[i]) * 100 / (secs - adj_secs) + 5) / 10;
}
secs = (secs + 5) / 10; secs = (secs + 5) / 10;
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
total[i] = (total[i] + 5) / 10; total[i] = (total[i] + 5) / 10;
for ( ; (secs < 86400) && (cur_load_entry != NULL); secs += for (; (secs < 86400) && (cur_load_entry != NULL); secs +=
(cur_load_entry->time_incr + 50) / 100, cur_load_entry = (cur_load_entry->time_incr + 50) / 100, cur_load_entry =
cur_load_entry->prev, current_load_data.entries++) { cur_load_entry->prev, current_load_data.entries++)
u_long time_incr = (cur_load_entry->time_incr + 50) / 100; {
total[0] += time_incr * cur_load_entry->local_count; u_long time_incr = (cur_load_entry->time_incr + 50) / 100;
total[1] += time_incr * cur_load_entry->client_count; total[0] += time_incr * cur_load_entry->local_count;
total[2] += time_incr * cur_load_entry->conn_count; total[1] += time_incr * cur_load_entry->client_count;
total[2] += time_incr * cur_load_entry->conn_count;
#ifdef DEBUGMODE #ifdef DEBUGMODE
total[3] += cur_load_entry->cpu_usage; total[3] += cur_load_entry->cpu_usage;
#endif #endif
last = cur_load_entry; last = cur_load_entry;
} }
if ((secs > 86400) && (last != NULL)) { if ((secs > 86400) && (last != NULL))
adj_secs = secs - 86400; {
adj[0] = adj_secs * last->local_count; adj_secs = secs - 86400;
adj[1] = adj_secs * last->client_count; adj[0] = adj_secs * last->local_count;
adj[2] = adj_secs * last->conn_count; adj[1] = adj_secs * last->client_count;
adj[2] = adj_secs * last->conn_count;
#ifdef DEBUGMODE #ifdef DEBUGMODE
times[2][3] = total[3]-(last->cpu_usage*(double)adj_secs/last->time_incr); times[2][3] =
} else { total[3] -
adj_secs = adj[0] = adj[1] = adj[2] = adj[3] = 0; (last->cpu_usage * (double)adj_secs / last->time_incr);
times[2][3] = total[3]; }
} else
{
adj_secs = adj[0] = adj[1] = adj[2] = adj[3] = 0;
times[2][3] = total[3];
}
#else #else
} else }
adj_secs = adj[0] = adj[1] = adj[2] = 0; else
adj_secs = adj[0] = adj[1] = adj[2] = 0;
#endif #endif
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++)
times[2][i] = ((total[i] - adj[i]) * 10 / (secs - adj_secs) + 5) / 10; {
} times[2][i] =
((total[i] - adj[i]) * 10 / (secs - adj_secs) + 5) / 10;
}
#ifdef DEBUGMODE #ifdef DEBUGMODE
bzero(total, 4 * sizeof(u_long)); bzero(total, 4 * sizeof(u_long));
#else #else
bzero(total, 3 * sizeof(u_long)); bzero(total, 3 * sizeof(u_long));
#endif #endif
for (secs = 1 ; (secs < 86400) && (cur_load_entry != NULL); secs += for (secs = 1; (secs < 86400) && (cur_load_entry != NULL); secs +=
(cur_load_entry->time_incr + 50) / 100, cur_load_entry = (cur_load_entry->time_incr + 50) / 100, cur_load_entry =
cur_load_entry->prev, current_load_data.entries++) { cur_load_entry->prev, current_load_data.entries++)
u_long time_incr = (cur_load_entry->time_incr + 50) / 100; {
total[0] += time_incr * cur_load_entry->local_count; u_long time_incr = (cur_load_entry->time_incr + 50) / 100;
total[1] += time_incr * cur_load_entry->client_count; total[0] += time_incr * cur_load_entry->local_count;
total[2] += time_incr * cur_load_entry->conn_count; total[1] += time_incr * cur_load_entry->client_count;
total[2] += time_incr * cur_load_entry->conn_count;
#ifdef DEBUGMODE #ifdef DEBUGMODE
total[3] += cur_load_entry->cpu_usage; total[3] += cur_load_entry->cpu_usage;
#endif #endif
last = cur_load_entry; last = cur_load_entry;
} }
if ((secs > 86400) && (last != NULL)) { if ((secs > 86400) && (last != NULL))
adj_secs = secs - 86400; {
adj[0] = adj_secs * last->local_count; adj_secs = secs - 86400;
adj[1] = adj_secs * last->client_count; adj[0] = adj_secs * last->local_count;
adj[2] = adj_secs * last->conn_count; adj[1] = adj_secs * last->client_count;
adj[2] = adj_secs * last->conn_count;
#ifdef DEBUGMODE #ifdef DEBUGMODE
times[3][3] = total[3]-(last->cpu_usage*(double)adj_secs/last->time_incr); times[3][3] =
} else { total[3] -
adj_secs = adj[0] = adj[1] = adj[2] = adj[3] = 0; (last->cpu_usage * (double)adj_secs / last->time_incr);
times[3][3] = total[3]; }
} else
{
adj_secs = adj[0] = adj[1] = adj[2] = adj[3] = 0;
times[3][3] = total[3];
}
#else #else
} else }
adj_secs = adj[0] = adj[1] = adj[2] = 0; else
adj_secs = adj[0] = adj[1] = adj[2] = 0;
#endif #endif
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++)
times[3][i] = ((total[i] - adj[i]) * 10 / (secs - adj_secs) + 5) / 10; {
} times[3][i] =
((total[i] - adj[i]) * 10 / (secs - adj_secs) + 5) / 10;
}
#ifdef DEBUGMODE #ifdef DEBUGMODE
bzero(total, 4 * sizeof(u_long)); bzero(total, 4 * sizeof(u_long));
#else #else
bzero(total, 3 * sizeof(u_long)); bzero(total, 3 * sizeof(u_long));
#endif #endif
for (secs = 1 ; (secs < 86400) && (cur_load_entry != NULL); secs += for (secs = 1; (secs < 86400) && (cur_load_entry != NULL); secs +=
(cur_load_entry->time_incr + 50) / 100, cur_load_entry = (cur_load_entry->time_incr + 50) / 100, cur_load_entry =
cur_load_entry->prev, current_load_data.entries++) { cur_load_entry->prev, current_load_data.entries++)
u_long time_incr = (cur_load_entry->time_incr + 50) / 100; {
total[0] += time_incr * cur_load_entry->local_count; u_long time_incr = (cur_load_entry->time_incr + 50) / 100;
total[1] += time_incr * cur_load_entry->client_count; total[0] += time_incr * cur_load_entry->local_count;
total[2] += time_incr * cur_load_entry->conn_count; total[1] += time_incr * cur_load_entry->client_count;
total[2] += time_incr * cur_load_entry->conn_count;
#ifdef DEBUGMODE #ifdef DEBUGMODE
total[3] += cur_load_entry->cpu_usage; total[3] += cur_load_entry->cpu_usage;
#endif #endif
last = cur_load_entry; last = cur_load_entry;
} }
if ((secs > 86400) && (last != NULL)) { if ((secs > 86400) && (last != NULL))
adj_secs = secs - 86400; {
adj[0] = adj_secs * last->local_count; adj_secs = secs - 86400;
adj[1] = adj_secs * last->client_count; adj[0] = adj_secs * last->local_count;
adj[2] = adj_secs * last->conn_count; adj[1] = adj_secs * last->client_count;
adj[2] = adj_secs * last->conn_count;
#ifdef DEBUGMODE #ifdef DEBUGMODE
times[4][3] = total[3]-(last->cpu_usage*(double)adj_secs/last->time_incr); times[4][3] =
} else { total[3] -
adj_secs = adj[0] = adj[1] = adj[2] = adj[3] = 0; (last->cpu_usage * (double)adj_secs / last->time_incr);
times[4][3] = total[3]; }
} else
{
adj_secs = adj[0] = adj[1] = adj[2] = adj[3] = 0;
times[4][3] = total[3];
}
#else #else
} else }
adj_secs = adj[0] = adj[1] = adj[2] = 0; else
adj_secs = adj[0] = adj[1] = adj[2] = 0;
#endif #endif
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++)
times[4][i] = ((total[i] - adj[i]) * 10 / (secs - adj_secs) + 5) / 10; {
} times[4][i] =
((total[i] - adj[i]) * 10 / (secs - adj_secs) + 5) / 10;
}
if ((cur_load_entry != NULL) && (cur_load_entry->prev != NULL) && if ((cur_load_entry != NULL) && (cur_load_entry->prev != NULL) &&
(secs > 86400)) { /* have nodes to free -- more than 3 days old */ (secs > 86400))
struct load_entry *cur_free_entry = load_free_head; { /* have nodes to free -- more than 3 days old */
struct load_entry *cur_free_entry = load_free_head;
load_free_head = load_list_head; load_free_head = load_list_head;
load_list_head = cur_load_entry; load_list_head = cur_load_entry;
if (cur_free_entry != NULL) if (cur_free_entry != NULL)
cur_free_entry->prev = cur_load_entry->prev; cur_free_entry->prev = cur_load_entry->prev;
else else
load_free_tail = cur_load_entry->prev; load_free_tail = cur_load_entry->prev;
/* printf("freeing: %x (head: %x, tail: %x)\n", cur_load_entry->prev, /* printf("freeing: %x (head: %x, tail: %x)\n", cur_load_entry->prev,
load_free_head, load_free_tail); */ load_free_head, load_free_tail); */
cur_load_entry->prev = NULL; cur_load_entry->prev = NULL;
} }
strcpy(what[0], DOMAINNAME); strcpy(what[0], DOMAINNAME);
strcat(what[0], " clients"); strcat(what[0], " clients");
strcpy(what[1], "total clients"); strcpy(what[1], "total clients");
strcpy(what[2], "total connections"); strcpy(what[2], "total connections");
#ifdef DEBUGMODE #ifdef DEBUGMODE
strcpy(what[3], "CPU usage"); strcpy(what[3], "CPU usage");
#endif #endif
sendto_one(sptr, sendto_one(sptr,
":%s NOTICE %s :Minute Hour Day Yest. YYest. Userload for:", ":%s NOTICE %s :Minute Hour Day Yest. YYest. Userload for:",
me.name, parv); me.name, parv);
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
sendto_one(sptr, sendto_one(sptr,
":%s NOTICE %s :%3d.%02d %3d.%01d %3d %3d %3d %s", ":%s NOTICE %s :%3d.%02d %3d.%01d %3d %3d %3d %s",
me.name, parv, times[0][i] / 100, times[0][i] % 100, times[1][i] / 10, me.name, parv, times[0][i] / 100, times[0][i] % 100,
times[1][i] % 10, times[2][i], times[3][i], times[4][i], what[i]); times[1][i] / 10, times[1][i] % 10, times[2][i],
times[3][i], times[4][i], what[i]);
#ifdef DEBUGMODE #ifdef DEBUGMODE
sendto_one(sptr, sendto_one(sptr,
":%s NOTICE %s :%6.2f%% %5.1f%% %3d%% %3d%% %3d%% %s", ":%s NOTICE %s :%6.2f%% %5.1f%% %3d%% %3d%% %3d%% %s",
me.name, parv, me.name, parv,
(double)((double)times[0][3]/(0.6*CLOCKS_PER_SEC)), (double)((double)times[0][3] / (0.6 * CLOCKS_PER_SEC)),
(double)((double)times[1][3]/(36*CLOCKS_PER_SEC)), (double)((double)times[1][3] / (36 * CLOCKS_PER_SEC)),
(int)((double)times[2][3]/(864*CLOCKS_PER_SEC)), (int)((double)times[2][3] / (864 * CLOCKS_PER_SEC)),
(int)((double)times[3][3]/(864*CLOCKS_PER_SEC)), (int)((double)times[3][3] / (864 * CLOCKS_PER_SEC)),
(int)((double)times[4][3]/(864*CLOCKS_PER_SEC)), (int)((double)times[4][3] / (864 * CLOCKS_PER_SEC)), what[3]);
what[3]);
#endif #endif
} }
void initload() void initload()
{ {
bzero(&current_load_data, sizeof(struct current_load_struct)); bzero(&current_load_data, sizeof(struct current_load_struct));
update_load(); /* Initialize the load list */ update_load(); /* Initialize the load list */
} }
+51 -25
View File
@@ -21,7 +21,6 @@ else
fi fi
generation=`expr $generation + 1` generation=`expr $generation + 1`
creation=`date | \ creation=`date | \
awk '{if (NF == 6) \ awk '{if (NF == 6) \
{ print $1 " " $2 " " $3 " " $6 " at " $4 " " $5 } \ { print $1 " " $2 " " $3 " " $6 " at " $4 " " $5 } \
@@ -81,10 +80,6 @@ char *unrealcredits[] =
" about IRC stuff, getting me more and more into IRCd business", " about IRC stuff, getting me more and more into IRCd business",
" thanks for the *.tspre.org domain as well :)", " thanks for the *.tspre.org domain as well :)",
"", "",
"\37Local Irelands (http://www.local.ie)\37",
"- Thanks for sponsoring UnrealIRCd, test facilities,",
" supporting UnrealIRCd, many new ideas, thanks for making",
" Unreal what it is today:)",
"Mick and Sp^", "Mick and Sp^",
"- Amiga port of Unreal (UnrealIRCd/Amiga), continually strange", "- Amiga port of Unreal (UnrealIRCd/Amiga), continually strange",
" comments on #UnrealIRCd, being great supporters of Unreal", " comments on #UnrealIRCd, being great supporters of Unreal",
@@ -92,6 +87,13 @@ char *unrealcredits[] =
"DrBin (Dave) drbin@tspre.org", "DrBin (Dave) drbin@tspre.org",
"- Recoded & made the new UnrealIRCd/32 code, support," "- Recoded & made the new UnrealIRCd/32 code, support,"
" finding bugs, and tonnes of other stuff:)", " finding bugs, and tonnes of other stuff:)",
"Headbang (Melle Visser)",
"- Donation of ircsystems.net, hardware for Stskeeps, and for",
" being a great supporter of Unreal, and helping out at the",
" support channel",
"WonderWal (Alan Wolff)",
"- Sending Stskeeps Slackware 7, and Visual Studio",
" helping out in the help channel, and a lot of other stuff",
"{X} (Laurie) x@tspre.org", "{X} (Laurie) x@tspre.org",
"- Making the main code/design of UnrealIRCd/32 gui", "- Making the main code/design of UnrealIRCd/32 gui",
" bugfounds, etc", " bugfounds, etc",
@@ -102,6 +104,8 @@ char *unrealcredits[] =
" \37Donations to Unreal:\37", " \37Donations to Unreal:\37",
"BlueFlame^", "BlueFlame^",
" - the first UnrealIRCd donation :)", " - the first UnrealIRCd donation :)",
"Thanks to Headbang and WonderWal too for hardware+software",
"donations",
" (yes your name can be here too;)", " (yes your name can be here too;)",
"", "",
" \37These people have helped alpha/betatesting\37", " \37These people have helped alpha/betatesting\37",
@@ -127,9 +131,12 @@ char *unrealcredits[] =
" and many other stuff. You'll always be in my heart,", " and many other stuff. You'll always be in my heart,",
" sorry for all the things I did or maybe didn't", " sorry for all the things I did or maybe didn't",
" love you :(", " love you :(",
"KUFO John MacKenzie", "SL7 Steve Lake sl7@global-irc.net",
" - Support, helping me always with getting through my life", " - Bug testing, comments, lotsa ideas, wierd reactions,",
" shells, etc etc ;)", " making Apollo, supporting Unreal and other freakout",
" thingies, being a general wierdoe etc. ",
"Dark-Prince",
" - Systray code, sharing ideas, code, bugs, and a lot of stuff",
"Sporty_McFly Cedric", "Sporty_McFly Cedric",
" - Comments, helping me when I got problems with my life and so on", " - Comments, helping me when I got problems with my life and so on",
" *toh* to him - Thanks!", " *toh* to him - Thanks!",
@@ -158,11 +165,11 @@ char *unrealcredits[] =
"Enforcer, Andy Church, Mick, Sp^, ShadowMastr, Almaris", "Enforcer, Andy Church, Mick, Sp^, ShadowMastr, Almaris",
"}{, Erik/Dr|zzt, Hedge, Kyle, MissKel, jfc, Fish, kore, Syndicate, Bagge,", "}{, Erik/Dr|zzt, Hedge, Kyle, MissKel, jfc, Fish, kore, Syndicate, Bagge,",
"#Coder-Com@Undernet, ^NeVeR^, flygirl^, DannyM, JuliuZ, wah-wah^, Lisa,", "#Coder-Com@Undernet, ^NeVeR^, flygirl^, DannyM, JuliuZ, wah-wah^, Lisa,",
"Melisa, NonMortal, Andryan, TomaHawk, Lushes, Skywalker, Merlin, Sporty_McFly,", "Melisa, Dukemaster, NonMortal, Andryan, TomaHawk, Lushes, Skywalker, Merlin, Sporty_McFly,",
"zero9000, #wIRCd@DALnet, comstud, dog3, Dianora, Isomer, and others who arent listed here:)", "zero9000, #wIRCd@DALnet, comstud, dog3, Dianora, Isomer, and others who arent listed here:)",
"", "",
"------------------------------------------------------", "------------------------------------------------------",
"Unreal 3.0 and up is dedicated to Morrigan - Julie Frederiksen", "Unreal 3.0, and 3.1 and up is dedicated to Morrigan - Julie Frederiksen",
"- a girl who have helped me through anything in my life, hugging", "- a girl who have helped me through anything in my life, hugging",
"me at the right times, a definate dedication. Thanks for the kisses", "me at the right times, a definate dedication. Thanks for the kisses",
"long phonetalks, waste of my mobilephone ;), crying together", "long phonetalks, waste of my mobilephone ;), crying together",
@@ -174,21 +181,39 @@ char *unrealcredits[] =
"when I was down", "when I was down",
0 0
}; };
char *unrealcreditsold[] = char unreallogo[] =
{ {
"------------------------------------------------------", 32,95,32,32,32,95,32,32,32,32,32,
"Unreal 3.0 and up is dedicated to Morrigan - Julie Frederiksen", 32,32,32,32,32,32,32,32,32,32,32,
"- a girl who have helped me through anything in my life, hugging", 32,32,32,32,32,32,95,32,95,95,95,
"me at the right times, a definate dedication. Thanks for the kisses", 95,95,95,95,95,95,95,95,32,32,95,
"long phonetalks, waste of my mobilephone ;), crying together", 95,95,95,95,32,32,32,32,32,95,32,
"and making life go on for us both. I will never forget you", 10,124,32,124,32,124,32,124,32,32,32,
"never leave you, love ya forever", 32,32,32,32,32,32,32,32,32,32,32,
"------------------------------------------------------", 32,32,32,32,32,32,124,32,124,95,32,
"This IRCd is dedicated to the love that has always been", 32,32,95,124,32,95,95,95,32,92,47,
"and will always be there - Thanks to the girls & friends that kept me up", 32,32,95,95,32,92,32,32,32,124,32,
"when I was down", 124,10,124,32,124,32,124,32,124,95,32,
0 95,95,32,32,95,32,95,95,32,95,95,
}; 95,32,32,95,95,32,95,124,32,124,32,
124,32,124,32,124,32,124,95,47,32,47,
124,32,47,32,32,92,47,32,95,95,124,
32,124,10,124,32,124,32,124,32,124,32,
39,95,32,92,124,32,39,95,95,47,32,
95,32,92,47,32,95,96,32,124,32,124,
32,124,32,124,32,124,32,32,32,32,47,
32,124,32,124,32,32,32,32,47,32,95,
96,32,124,10,124,32,124,95,124,32,124,
32,124,32,124,32,124,32,124,32,124,32,
32,95,95,47,32,40,95,124,32,124,32,
124,95,124,32,124,95,124,32,124,92,32,
92,32,124,32,92,95,95,47,92,32,40,
95,124,32,124,10,32,92,95,95,95,47,
124,95,124,32,124,95,124,95,124,32,32,
92,95,95,95,124,92,95,95,44,95,124,
95,124,92,95,95,95,47,92,95,124,32,
92,95,124,32,92,95,95,95,95,47,92,
95,95,44,95,124,10,0};
char *dalinfotext[] = char *dalinfotext[] =
{ {
@@ -206,7 +231,8 @@ char *dalinfotext[] =
"Potvin Chris Wolkowski potvin@acestar.org", "Potvin Chris Wolkowski potvin@acestar.org",
"RogerY Roger Y. rogery@austnet.org", "RogerY Roger Y. rogery@austnet.org",
"GZ gz@starchat.net", "GZ gz@starchat.net",
"binary", "binary ",
"Roar Thronaas <roart@nvg.ntnu.no> added IPv6 support.",
"", "",
"", "",
"The following people have helped in making the DALnet ircd", "The following people have helped in making the DALnet ircd",
+224 -218
View File
@@ -1,266 +1,272 @@
/************************************************************************ /************************************************************************
* IRC - Internet Relay Chat, ircd/whowas.c * IRC - Internet Relay Chat, src/whowas.c
* Copyright (C) 1990 Markku Savela * Copyright (C) 1990 Markku Savela
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 1, or (at your option) * the Free Software Foundation; either version 1, or (at your option)
* any later version. * any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/*
* --- avalon --- 6th April 1992
* rewritten to scrap linked lists and use a table of structures which
* is referenced like a circular loop. Should be faster and more efficient.
*/
#ifndef lint
static char sccsid[] = "@(#)whowas.c 2.16 08 Nov 1993 (C) 1988 Markku Savela";
#endif
#include "struct.h" #include "struct.h"
#include "common.h" #include "common.h"
#include "sys.h" #include "sys.h"
#include "numeric.h" #include "numeric.h"
#include "whowas.h"
#include "h.h" #include "h.h"
#include "hash.h"
#ifndef lint
static char *rcs_version =
"$Id$";
#endif
ID_CVS("$Id$"); /* externally defined functions */
unsigned int hash_whowas_name(char *); /* defined in hash.c */
static aName was[NICKNAMEHISTORYLENGTH]; /* internally defined function */
static int ww_index = 0; static void add_whowas_to_clist(aWhowas **, aWhowas *);
static void del_whowas_from_clist(aWhowas **, aWhowas *);
static void add_whowas_to_list(aWhowas **, aWhowas *);
static void del_whowas_from_list(aWhowas **, aWhowas *);
void add_history(cptr) aWhowas WHOWAS[NICKNAMEHISTORYLENGTH];
Reg1 aClient *cptr; aWhowas *WHOWASHASH[WW_MAX];
int whowas_next = 0;
#define AllocCpy(x,y) x = (char *) MyMalloc(strlen(y) + 1); strcpy(x,y)
#define SafeFree(x) if (x) { MyFree((x)); (x) = NULL; }
void add_history(aClient *cptr, int online)
{ {
aName ntmp; aWhowas *new;
Reg2 aName *np = &ntmp, *np2;
Link *lp;
strncpyzt(np->ww_nick, cptr->name, NICKLEN+1); new = &WHOWAS[whowas_next];
strncpyzt(np->ww_info, cptr->info, REALLEN+1);
np->ww_user = cptr->user;
np->ww_logout = TStime();
np->ww_online = (cptr->from != NULL) ? cptr : NULL;
np->ww_user->refcnt++;
np2 = &was[ww_index]; if (new->hashv != -1)
if (np2->ww_user) {
free_user(np2->ww_user, np2->ww_online); SafeFree(new->name);
/* SafeFree(new->hostname);
* New whowas handling, we keep a list of what whowas entries SafeFree(new->virthost);
* are "used" by a client, in its cptr structure. This means SafeFree(new->realname);
* that when we overwrite a whowas entry, we have to remove the SafeFree(new->username);
* relative pointer in the client. -Cabal95 SafeFree(new->away);
*/ new->servername = NULL;
if (np2->ww_online) {
Link *last = NULL;
for (lp = np2->ww_online->history; lp; if (new->online)
last = lp, lp = lp->next) del_whowas_from_clist(&(new->online->whowas), new);
if (lp->value.whowas == np2) del_whowas_from_list(&WHOWASHASH[new->hashv], new);
break;
if (lp) { /* Sanity check, never trust anything */
if (last)
last->next = lp->next;
else
np2->ww_online->history = lp->next;
free_link(lp);
}
} }
new->hashv = hash_whowas_name(cptr->name);
new->logoff = TStime();
new->umodes = cptr->umodes;
AllocCpy(new->name, cptr->name);
AllocCpy(new->username, cptr->user->username);
AllocCpy(new->hostname, cptr->user->realhost);
AllocCpy(new->virthost, cptr->user->virthost);
if (cptr->user->away)
{
AllocCpy(new->away, cptr->user->away);
}
else
new->away = NULL;
new->servername = cptr->user->server;
AllocCpy(new->realname, cptr->info);
bcopy((char *)&ntmp, (char *)np2, sizeof(aName)); /* Its not string copied, a pointer to the scache hash is copied
-Dianora
/*
* Add this whowas entry into the clients history list
*/ */
lp = make_link(); /* strncpyzt(new->servername, cptr->user->server,HOSTLEN); */
lp->value.whowas = np2; new->servername = cptr->user->server;
lp->next = cptr->history;
cptr->history = lp;
ww_index++; if (online)
if (ww_index >= NICKNAMEHISTORYLENGTH) {
ww_index = 0; new->online = cptr;
return; add_whowas_to_clist(&(cptr->whowas), new);
}
else
new->online = NULL;
add_whowas_to_list(&WHOWASHASH[new->hashv], new);
whowas_next++;
if (whowas_next == NICKNAMEHISTORYLENGTH)
whowas_next = 0;
} }
/* void off_history(aClient *cptr)
** get_history
** Return the current client that was using the given
** nickname within the timelimit. Returns NULL, if no
** one found...
*/
aClient *get_history(nick, timelimit)
char *nick;
time_t timelimit;
{ {
Reg1 aName *wp, *wp2; aWhowas *temp, *next;
Reg2 int i = 0;
if (ww_index == 0) for (temp = cptr->whowas; temp; temp = next)
wp = wp2 = &was[NICKNAMEHISTORYLENGTH - 1]; {
else next = temp->cnext;
wp = wp2 = &was[ww_index - 1]; temp->online = NULL;
timelimit = TStime()-timelimit; del_whowas_from_clist(&(cptr->whowas), temp);
}
}
do { aClient *get_history(char *nick, time_t timelimit)
if (!mycmp(nick, wp->ww_nick) && wp->ww_logout >= timelimit) {
break; aWhowas *temp;
if (wp == was) int blah;
timelimit = TStime() - timelimit;
blah = hash_whowas_name(nick);
temp = WHOWASHASH[blah];
for (; temp; temp = temp->next)
{
if (mycmp(nick, temp->name))
continue;
if (temp->logoff < timelimit)
continue;
return temp->online;
}
return NULL;
}
void count_whowas_memory(int *wwu, u_long *wwum)
{
aWhowas *tmp;
int i;
int u = 0;
u_long um = 0;
u_long uam = 0;
/* count the number of used whowas structs in 'u' */
/* count up the memory used of whowas structs in um */
for (i = 0, tmp = &WHOWAS[0]; i < NICKNAMEHISTORYLENGTH; i++, tmp++)
if (tmp->hashv != -1)
{ {
i = 1; u++;
wp = &was[NICKNAMEHISTORYLENGTH - 1]; um += sizeof(aWhowas);
if (tmp->away)
uam += (strlen(tmp->away) + 1);
} }
else *wwu = u;
wp--; *wwum = um;
} while (wp != wp2);
if (wp != wp2 || !i)
return (wp->ww_online);
return (NULL);
}
void off_history(cptr)
Reg3 aClient *cptr;
{
Reg1 Link *lp;
Reg2 Link *next;
for (lp = cptr->history; lp; lp = next) {
next = lp->next;
lp->value.whowas->ww_online = NULL;
free_link(lp);
}
cptr->history = NULL;
return; return;
} }
void initwhowas()
{
Reg1 int i;
for (i = 0; i < NICKNAMEHISTORYLENGTH; i++)
bzero((char *)&was[i], sizeof(aName));
return;
}
/* /*
** m_whowas ** m_whowas
** parv[0] = sender prefix ** parv[0] = sender prefix
** parv[1] = nickname queried ** parv[1] = nickname queried
*/ */
int m_whowas(cptr, sptr, parc, parv) int m_whowas(aClient *cptr, aClient *sptr, int parc, char *parv[])
aClient *cptr, *sptr;
int parc;
char *parv[];
{ {
Reg1 aName *wp, *wp2 = NULL; aWhowas *temp;
Reg2 int j = 0; int cur = 0;
Reg3 anUser *up = NULL; int max = -1, found = 0;
int max = -1; char *p, *nick, *s;
char *p, *nick, *s; static time_t last_used = 0L;
static int last_count = 0;
if (parc < 2) if (parc < 2)
{ {
sendto_one(sptr, err_str(ERR_NONICKNAMEGIVEN), sendto_one(sptr, err_str(ERR_NONICKNAMEGIVEN),
me.name, parv[0]); me.name, parv[0]);
return 0; return 0;
} }
if (parc > 2) if (parc > 2)
max = atoi(parv[2]); max = atoi(parv[2]);
if (parc > 3) if (parc > 3)
if (hunt_server(cptr,sptr,":%s WHOWAS %s %s :%s", 3,parc,parv)) if (hunt_server(cptr, sptr, ":%s WHOWAS %s %s :%s", 3, parc,
parv))
return 0; return 0;
for (s = parv[1]; (nick = strtoken(&p, s, ",")); s = NULL) if (!MyConnect(sptr) && (max > 20))
{ max = 20;
wp = wp2 = &was[ww_index - 1];
do { p = (char *)strchr(parv[1], ',');
if (wp < was) if (p)
wp = &was[NICKNAMEHISTORYLENGTH - 1]; *p = '\0';
if (mycmp(nick, wp->ww_nick) == 0) nick = parv[1];
{ temp = WHOWASHASH[hash_whowas_name(nick)];
up = wp->ww_user; found = 0;
sendto_one(sptr, rpl_str(RPL_WHOWASUSER), for (; temp; temp = temp->next)
me.name, parv[0], wp->ww_nick, {
up->username, if (!mycmp(nick, temp->name))
(IsOper(sptr) ? {
up->realhost : sendto_one(sptr, rpl_str(RPL_WHOWASUSER),
(up->virthost[0] != '\0') ? me.name, parv[0], temp->name,
up->virthost : up->realhost), temp->username,
wp->ww_info); (IsOper(sptr) ? temp->hostname :
sendto_one(sptr, rpl_str(RPL_WHOISSERVER), (*temp->virthost !=
me.name, parv[0], wp->ww_nick, '\0') ? temp->virthost : temp->hostname),
up->server, myctime(wp->ww_logout)); temp->realname);
if (up->away) sendto_one(sptr, rpl_str(RPL_WHOISSERVER), me.name,
sendto_one(sptr, rpl_str(RPL_AWAY), parv[0], temp->name, temp->servername,
me.name, parv[0], myctime(temp->logoff));
wp->ww_nick, up->away); if (temp->away)
j++; sendto_one(sptr, rpl_str(RPL_AWAY),
} me.name, parv[0], temp->name, temp->away);
if (max > 0 && j >= max) cur++;
break; found++;
wp--; }
} while (wp != wp2); if (max > 0 && cur >= max)
break;
}
if (!found)
sendto_one(sptr, err_str(ERR_WASNOSUCHNICK),
me.name, parv[0], nick);
if (up == NULL)
sendto_one(sptr, err_str(ERR_WASNOSUCHNICK),
me.name, parv[0], nick);
up=NULL;
if (p)
p[-1] = ',';
}
sendto_one(sptr, rpl_str(RPL_ENDOFWHOWAS), me.name, parv[0], parv[1]); sendto_one(sptr, rpl_str(RPL_ENDOFWHOWAS), me.name, parv[0], parv[1]);
return 0; return 0;
} }
void initwhowas()
void count_whowas_memory(wwu, wwa, wwam)
int *wwu, *wwa;
u_long *wwam;
{ {
Reg1 anUser *tmp; int i;
Reg2 int i, j;
int u = 0, a = 0;
u_long am = 0;
for (i = 0; i < NICKNAMEHISTORYLENGTH; i++) for (i = 0; i < NICKNAMEHISTORYLENGTH; i++)
if ((tmp = was[i].ww_user)) {
if (!was[i].ww_online) bzero((char *)&WHOWAS[i], sizeof(aWhowas));
{ WHOWAS[i].hashv = -1;
for (j = 0; j < i; j++) }
if (was[j].ww_user == tmp) for (i = 0; i < WW_MAX; i++)
break; WHOWASHASH[i] = NULL;
if (j < i) }
continue;
u++;
if (tmp->away) static void add_whowas_to_clist(aWhowas ** bucket, aWhowas * whowas)
{ {
a++; whowas->cprev = NULL;
am += (strlen(tmp->away)+1); if ((whowas->cnext = *bucket) != NULL)
} whowas->cnext->cprev = whowas;
} *bucket = whowas;
*wwu = u; }
*wwa = a;
*wwam = am; static void del_whowas_from_clist(aWhowas ** bucket, aWhowas * whowas)
{
return; if (whowas->cprev)
whowas->cprev->cnext = whowas->cnext;
else
*bucket = whowas->cnext;
if (whowas->cnext)
whowas->cnext->cprev = whowas->cprev;
}
static void add_whowas_to_list(aWhowas ** bucket, aWhowas * whowas)
{
whowas->prev = NULL;
if ((whowas->next = *bucket) != NULL)
whowas->next->prev = whowas;
*bucket = whowas;
}
static void del_whowas_from_list(aWhowas ** bucket, aWhowas * whowas)
{
if (whowas->prev)
whowas->prev->next = whowas->next;
else
*bucket = whowas->next;
if (whowas->next)
whowas->next->prev = whowas->prev;
} }