-
-
Save kousu/f602fe718300f94b8348 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# #!/bin/sh | |
# unrealircd is designed to be VERY GOOD at staying alive | |
# which means it's very hard to kill | |
# ctrl-c'ing it doesn't kill it, but sometimes it restarts it | |
# instead, we background it and translate ctrl-c to a stronger signal, which it will listen to | |
# | |
CONF=$(mktemp ircd.conf.XXXXX) | |
LOG=$(mktemp ircd.log.XXXXXX) | |
# abspath-ify these paths | |
# because other unrealircd has very strong opinions about what to do with them | |
CONF=$(realpath "$CONF") | |
LOG=$(realpath "$LOG") | |
# UnrealIRCd is pretty good, but as far as I can tell it is hardcoded to use /{etc,var/log}/unrealird | |
# To override this behaviour we generate | |
cat > $CONF <<EOF | |
/* Configuration file for UnrealIRCd 4.0 | |
* | |
* Important: All lines, except the opening { line, end with an ; | |
* including };. This is very important, if you miss a ; somewhere then | |
* the configuration file parser will complain and your file will not | |
* be processed correctly! | |
* If this is your first experience with an UnrealIRCd configuration | |
* file then we really recommend you to read a little about the syntax, | |
* this only takes a few minutes and will help you a lot: | |
* https://www.unrealircd.org/docs/Configuration#Configuration_file_syntax | |
* | |
* UnrealIRCd 4 documentation (very extensive!): | |
* https://www.unrealircd.org/docs/UnrealIRCd_4_documentation | |
* | |
* Frequently Asked Questions: | |
* https://www.unrealircd.org/docs/FAQ | |
* | |
*/ | |
/* UnrealIRCd makes heavy use of modules. Modules allow you to completely | |
* customize the featureset you wish to enable in UnrealIRCd. | |
* See: https://www.unrealircd.org/docs/Modules | |
* | |
* By using the include below we instruct the IRCd to read the file | |
* 'modules.default.conf' which will load more than 150 modules | |
* shipped with UnrealIRCd. In other words: this will simply load | |
* all the available features in UnrealIRCd. | |
* If you are setting up UnrealIRCd for the first time we suggest you | |
* use this. Then, when everything is up and running you can come | |
* back later to customize the list (if you wish). | |
*/ | |
include "modules.default.conf"; | |
/* This is the me { } block which basically says who we are. | |
* It defines our server name, some information line and an unique "sid". | |
* The server id (sid) must start with a digit followed by two digits or | |
* letters. The sid must be unique for your IRC network (each server should | |
* have it's own sid). | |
*/ | |
me { | |
name "$(hostname --fqdn)."; | |
info "${USER}'s Test IRC Server"; | |
sid "001"; | |
}; | |
/* The admin { } block defines what users will see if they type /ADMIN. | |
* It normally contains information on how to contact the administrator. | |
*/ | |
admin { | |
"Bob Smith"; | |
"bob"; | |
"[email protected]"; | |
}; | |
/* Clients and servers are put in class { } blocks, we define them here. | |
* Class blocks consist of the following items: | |
* - pingfreq: how often to ping a user / server (in seconds) | |
* - connfreq: how often we try to connect to this server (in seconds) | |
* - sendq: the maximum queue size for a connection | |
* - recvq: maximum receive queue from a connection (flood control) | |
*/ | |
/* Client class with good defaults */ | |
class clients | |
{ | |
pingfreq 90; | |
maxclients 1000; | |
sendq 200k; | |
recvq 8000; | |
}; | |
/* Special class for IRCOps with higher limits */ | |
class opers | |
{ | |
pingfreq 90; | |
maxclients 50; | |
sendq 1M; | |
recvq 8000; | |
}; | |
/* Server class with good defaults */ | |
class servers | |
{ | |
pingfreq 60; | |
connfreq 15; /* try to connect every 15 seconds */ | |
maxclients 10; /* max servers */ | |
sendq 5M; | |
}; | |
/* Allow blocks define which clients may connect to this server. | |
* This allows you to add a server password or restrict the server to | |
* specific IP's only. You also configure the maximum connections | |
* allowed per IP here. | |
* See also: https://www.unrealircd.org/docs/Allow_block | |
*/ | |
/* Allow everyone in, but only 3 connections per IP */ | |
allow { | |
ip *@*; | |
class clients; | |
maxperip 3; | |
password "secret"; | |
}; | |
/* this disables the default throttling for connections from localhost | |
since under test we're going to be doing a lot of that */ | |
except throttle { | |
mask 127.0.0.1; | |
}; | |
/* Oper blocks define your IRC Operators. | |
* IRC Operators are people who have "extra rights" compared to others, | |
* for example they may /KILL other people, initiate server linking, | |
* /JOIN channels even though they are banned, etc. | |
* See also: https://www.unrealircd.org/docs/Oper_block | |
*/ | |
/* Here is an example oper block for 'bobsmith' with password 'test'. | |
* You MUST change this!! | |
*/ | |
oper $USER { | |
class opers; | |
mask *@*; | |
password "oper_secret"; | |
/* Oper permissions are defined in an 'operclass' block. | |
* See https://www.unrealircd.org/docs/Operclass_block | |
* UnrealIRCd ships with a number of default blocks, see | |
* the article for a full list. We choose 'netadmin' here. | |
*/ | |
operclass netadmin; | |
swhois "is a Network Administrator"; | |
/* vhost netadmin.mynet.org; */ | |
}; | |
/* Standard IRC port 6667 */ | |
listen { | |
ip *; | |
port 6667; | |
}; | |
/* Standard IRC SSL/TLS port 6697 */ | |
listen { | |
ip *; | |
port 6697; | |
options { ssl; }; | |
}; | |
/* Special SSL/TLS servers-only port for linking */ | |
listen { | |
ip *; | |
port 6900; | |
options { ssl; serversonly; }; | |
}; | |
/* The log block defines what should be logged and to what file. | |
* See also https://www.unrealircd.org/docs/Log_block | |
*/ | |
/* This is a good default, it logs almost everything */ | |
log "$LOG" { | |
flags { | |
oper; | |
connects; | |
server-connects; | |
kills; | |
errors; | |
sadmin-commands; | |
chg-commands; | |
oper-override; | |
tkl; | |
spamfilter; | |
}; | |
}; | |
/* Network configuration */ | |
set { | |
network-name "${USER}'s test ircd"; | |
default-server "$(hostname)."; | |
services-server "services.disabled"; | |
stats-server "stats.disabled"; | |
help-channel "#Help"; | |
hiddenhost-prefix "Clk"; | |
prefix-quit "Quit"; | |
/* Cloak keys should be the same at all servers on the network. | |
* They are used for generating masked hosts and should be kept secret. | |
* The keys should be 3 random strings of 50-100 characters | |
* and must consist of lowcase (a-z), upcase (A-Z) and digits (0-9). | |
* HINT: On *NIX, you can run './unrealircd gencloak' in your shell to let | |
* UnrealIRCd generate 3 random strings for you. | |
*/ | |
cloak-keys { | |
/* successfully circumvented ircd's stupid password restrictions hooray */ | |
"Andanother3one"; | |
"Andanother2two"; | |
"Andanother1three"; | |
}; | |
}; | |
set { | |
kline-address "root@localhost"; /* e-mail or URL shown when a user is banned */ | |
modes-on-connect "+ixw"; /* when users connect, they will get these user modes */ | |
modes-on-oper "+xwgs"; /* when someone becomes IRCOp they'll get these modes */ | |
maxchannelsperuser 10; /* maximum number of channels a user may /JOIN */ | |
}; | |
EOF | |
cat $CONF | |
echo $CONF | |
unrealircd -f "$CONF" -F -t & | |
export IRCD_PID=$! | |
d() { | |
#echo "caught int. killing $IRCD_PID yesyes" | |
kill $IRCD_PID | |
} | |
trap d INT | |
q() { | |
#echo "Cleaning up" #DEBUG | |
#rm "$CONF" | |
#rm "$LOG" | |
echo -n | |
} | |
trap q EXIT | |
tail -n 1000 -f "$LOG" | |
wait $IRCD_PID #this doesn't reattach, it just waits. This is fine for now, since unrealircd only outputs, but if we needed it to also take input | |
# then again, if it also took input it would probably respect ctrl-c |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment