mirror of
https://github.com/pissnet/pissircd.git
synced 2025-07-28 14:02:27 +01:00
Various fixes and changes
This commit is contained in:
parent
53f0297b8c
commit
af289c8687
14 changed files with 414 additions and 116 deletions
6
Changes
6
Changes
|
@ -2628,3 +2628,9 @@ seen. gmtime warning still there
|
|||
- Partial cleanup of m_part (hopefully I didn't destroy anything).
|
||||
- Minor stats compile warning fixed
|
||||
- Started some work on the remote include system
|
||||
- Fixed a bug with set::who-limit sending multiple error notices, reported by doh
|
||||
- Fixed a bug with the configure script reported by doh where Unreal would ignore the
|
||||
manually specified directory for OpenSSL (and also Zlib)
|
||||
- Made the ./configure --help display a bit cleaner
|
||||
- Added include/types.h to hold any new datatypes we create
|
||||
- A lot more work on the remote include system
|
||||
|
|
11
autoconf/aclocal.m4
vendored
11
autoconf/aclocal.m4
vendored
|
@ -349,12 +349,10 @@ dnl the following 2 macros are based on CHECK_SSL by Mark Ethan Trostler <trostl
|
|||
AC_DEFUN([CHECK_SSL],
|
||||
[
|
||||
AC_ARG_ENABLE(ssl,
|
||||
[ --enable-ssl enable ssl [will check /usr/local/ssl
|
||||
/usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr ]
|
||||
],
|
||||
[AC_HELP_STRING([--enable-ssl=],[enable ssl will check /usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr])],
|
||||
[
|
||||
AC_MSG_CHECKING(for openssl)
|
||||
for dir in $withval /usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr; do
|
||||
for dir in $enableval /usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr; do
|
||||
ssldir="$dir"
|
||||
if test -f "$dir/include/openssl/ssl.h"; then
|
||||
AC_MSG_RESULT(found in $ssldir/include/openssl)
|
||||
|
@ -384,11 +382,10 @@ AC_DEFINE(USE_SSL)
|
|||
AC_DEFUN([CHECK_ZLIB],
|
||||
[
|
||||
AC_ARG_ENABLE(ziplinks,
|
||||
[ --enable-ziplinks enable ziplinks [will check /usr/local /usr /usr/pkg ]
|
||||
],
|
||||
[AC_HELP_STRING([--enable-ziplinks],[enable ziplinks will check /usr/local /usr /usr/pkg])],
|
||||
[
|
||||
AC_MSG_CHECKING(for zlib)
|
||||
for dir in $withval /usr/local /usr /usr/pkg; do
|
||||
for dir in $enableval /usr/local /usr /usr/pkg; do
|
||||
zlibdir="$dir"
|
||||
if test -f "$dir/include/zlib.h"; then
|
||||
AC_MSG_RESULT(found in $zlibdir)
|
||||
|
|
|
@ -316,33 +316,32 @@ AC_SUBST(REGEX)
|
|||
AC_SUBST(STRTOUL)
|
||||
AC_SUBST(CRYPTOLIB)
|
||||
AC_SUBST(MODULEFLAGS)
|
||||
AC_ARG_WITH(listen, [ --with-listen=backlog Specify the listen backlog value],
|
||||
AC_ARG_WITH(listen, [AC_HELP_STRING([--with-listen=backlog],[Specify the listen backlog value])],
|
||||
AC_DEFINE_UNQUOTED(LISTEN_SIZE,$withval),AC_DEFINE(LISTEN_SIZE,5))
|
||||
AC_ARG_WITH(nick-history, [ --with-nick-history=length Specify the length of the nickname history],
|
||||
AC_ARG_WITH(nick-history, [AC_HELP_STRING([--with-nick-history=length],[Specify the length of the nickname history])],
|
||||
AC_DEFINE_UNQUOTED(NICKNAMEHISTORYLENGTH,$withval), AC_DEFINE(NICKNAMEHISTORYLENGTH,2000))
|
||||
AC_ARG_WITH(sendq, [ --with-sendq=maxsendq Specify the max sendq for the server],
|
||||
AC_ARG_WITH(sendq, [AC_HELP_STRING([--with-sendq=maxsendq],[Specify the max sendq for the server])],
|
||||
AC_DEFINE_UNQUOTED(MAXSENDQLENGTH,$withval),AC_DEFINE(MAXSENDQLENGTH,3000000))
|
||||
AC_ARG_WITH(bufferpool, [ --with-bufferpool=size Specify the size of the buffer pool],
|
||||
AC_ARG_WITH(bufferpool, [AC_HELP_STRING([--with-bufferpool=size],[Specify the size of the buffer pool])],
|
||||
AC_DEFINE_UNQUOTED(BUFFERPOOL,[($withval * MAXSENDQLENGTH)]),AC_DEFINE(BUFFERPOOL,[(18 * MAXSENDQLENGTH)]))
|
||||
|
||||
AC_ARG_WITH(hostname, [ --with-hostname=host Specify the local hostname of the server], AC_DEFINE_UNQUOTED(DOMAINNAME,"$withval"),AC_DEFINE_UNQUOTED(DOMAINNAME,"`hostname`"))
|
||||
AC_ARG_WITH(hostname, [AC_HELP_STRING([--with-hostname=host],[Specify the local hostname of the server])], AC_DEFINE_UNQUOTED(DOMAINNAME,"$withval"),AC_DEFINE_UNQUOTED(DOMAINNAME,"`hostname`"))
|
||||
AC_DEFINE_UNQUOTED(MYOSNAME,"`uname -a`")
|
||||
AC_ARG_WITH(permissions, [ --with-permissions=permissions Specify the default permissions for
|
||||
configuration files], AC_DEFINE_UNQUOTED(DEFAULT_PERMISSIONS,$withval), AC_DEFINE(DEFAULT_PERMISSIONS, 0600))
|
||||
AC_ARG_WITH(dpath, [ --with-dpath=path Specify the path where configuration files are stored],
|
||||
AC_ARG_WITH(permissions, [AC_HELP_STRING([--with-permissions=permissions],[Specify the default permissions for
|
||||
configuration files])], AC_DEFINE_UNQUOTED(DEFAULT_PERMISSIONS,$withval), AC_DEFINE(DEFAULT_PERMISSIONS, 0600))
|
||||
AC_ARG_WITH(dpath, [AC_HELP_STRING([--with-dpath=path],[Specify the path where configuration files are stored])],
|
||||
AC_DEFINE_UNQUOTED(DPATH, "$withval") IRCDDIR="$withval"; mkdir $withval/tmp, AC_DEFINE_UNQUOTED(DPATH,"`pwd`") IRCDDIR="`pwd`" mkdir `pwd`/tmp)
|
||||
AC_ARG_WITH(fd-setsize, [ --with-fd-setsize=size Specify the max file descriptors to use],
|
||||
AC_ARG_WITH(fd-setsize, [AC_HELP_STRING([--with-fd-setsize=size],[Specify the max file descriptors to use])],
|
||||
ac_fd=$withval, ac_fd=1024)
|
||||
AC_DEFINE_UNQUOTED(MAXCONNECTIONS, $ac_fd)
|
||||
AC_ARG_WITH(spath, [ --with-spath Specify the location of the executable],
|
||||
AC_ARG_WITH(spath, [AC_HELP_STRING([--with-spath],[Specify the location of the executable])],
|
||||
AC_DEFINE_UNQUOTED(SPATH,"$withval") BINDIR="$withval",AC_DEFINE_UNQUOTED(SPATH,"`pwd`/src/ircd") BINDIR="`pwd`/src/ircd")
|
||||
AC_ARG_ENABLE(nospoof, [ --enable-nospoof Enable spoofing protection], AC_DEFINE(NOSPOOF))
|
||||
AC_ARG_ENABLE(prefixaq, [ --enable-prefixaq Enable chanadmin and chanprot prefixes], AC_DEFINE(PREFIX_AQ))
|
||||
AC_ARG_ENABLE(hub, [ --enable-hub Compile as a hub server], AC_DEFINE(HUB))
|
||||
AC_ARG_ENABLE(nospoof, [AC_HELP_STRING([--enable-nospoof],[Enable spoofing protection])], AC_DEFINE(NOSPOOF))
|
||||
AC_ARG_ENABLE(prefixaq, [AC_HELP_STRING([--enable-prefixaq],[Enable chanadmin and chanowner prefixes])], AC_DEFINE(PREFIX_AQ))
|
||||
AC_ARG_ENABLE(hub, [AC_HELP_STRING([--enable-hub],[Compile as a hub server])], AC_DEFINE(HUB))
|
||||
CHECK_SSL
|
||||
CHECK_ZLIB
|
||||
AC_ARG_ENABLE(dynamic-linking, [ --enable-dynamic-linking Make the IRCd dynamically link shared objects rather than statically ], AC_ENABLE_DYN, AC_DEFINE(STATIC_LINKING))
|
||||
AC_ARG_ENABLE(inet6, [ --enable-inet6 Make the IRCd support IPv6 ], AC_ENABLE_INET6)
|
||||
AC_ARG_ENABLE(dynamic-linking, [AC_HELP_STRING([--enable-dynamic-linking],[Make the IRCd dynamically link shared objects rather than statically])], AC_ENABLE_DYN, AC_DEFINE(STATIC_LINKING))
|
||||
AC_ARG_ENABLE(inet6, [AC_HELP_STRING([--enable-inet6],[Make the IRCd support IPv6])], AC_ENABLE_INET6)
|
||||
AC_SUBST(IRCDDIR)
|
||||
AC_SUBST(BINDIR)
|
||||
AC_MSG_CHECKING(if FD_SETSIZE is large enough to allow $ac_fd file descriptors)
|
||||
|
|
48
configure
vendored
48
configure
vendored
|
@ -822,30 +822,33 @@ if test -n "$ac_init_help"; then
|
|||
Optional Features:
|
||||
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
|
||||
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
|
||||
--enable-nospoof Enable spoofing protection
|
||||
--enable-prefixaq Enable chanadmin and chanprot prefixes
|
||||
--enable-hub Compile as a hub server
|
||||
--enable-ssl enable ssl will check /usr/local/ssl
|
||||
/usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr
|
||||
|
||||
--enable-ziplinks enable ziplinks will check /usr/local /usr /usr/pkg
|
||||
|
||||
--enable-dynamic-linking Make the IRCd dynamically link shared objects rather than statically
|
||||
--enable-inet6 Make the IRCd support IPv6
|
||||
--enable-nospoof Enable spoofing protection
|
||||
--enable-prefixaq Enable chanadmin and chanowner prefixes
|
||||
--enable-hub Compile as a hub server
|
||||
--enable-ssl= enable ssl will check /usr/local/ssl /usr/lib/ssl
|
||||
/usr/ssl /usr/pkg /usr/local /usr
|
||||
--enable-ziplinks enable ziplinks will check /usr/local /usr /usr/pkg
|
||||
--enable-dynamic-linking
|
||||
Make the IRCd dynamically link shared objects rather
|
||||
than statically
|
||||
--enable-inet6 Make the IRCd support IPv6
|
||||
|
||||
Optional Packages:
|
||||
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
|
||||
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
|
||||
--with-listen=backlog Specify the listen backlog value
|
||||
--with-nick-history=length Specify the length of the nickname history
|
||||
--with-sendq=maxsendq Specify the max sendq for the server
|
||||
--with-bufferpool=size Specify the size of the buffer pool
|
||||
--with-hostname=host Specify the local hostname of the server
|
||||
--with-permissions=permissions Specify the default permissions for
|
||||
configuration files
|
||||
--with-dpath=path Specify the path where configuration files are stored
|
||||
--with-fd-setsize=size Specify the max file descriptors to use
|
||||
--with-spath Specify the location of the executable
|
||||
--with-listen=backlog Specify the listen backlog value
|
||||
--with-nick-history=length
|
||||
Specify the length of the nickname history
|
||||
--with-sendq=maxsendq Specify the max sendq for the server
|
||||
--with-bufferpool=size Specify the size of the buffer pool
|
||||
--with-hostname=host Specify the local hostname of the server
|
||||
--with-permissions=permissions
|
||||
Specify the default permissions for configuration
|
||||
files
|
||||
--with-dpath=path Specify the path where configuration files are
|
||||
stored
|
||||
--with-fd-setsize=size Specify the max file descriptors to use
|
||||
--with-spath Specify the location of the executable
|
||||
|
||||
Some influential environment variables:
|
||||
CC C compiler command
|
||||
|
@ -9411,7 +9414,6 @@ _ACEOF
|
|||
|
||||
fi;
|
||||
|
||||
|
||||
# Check whether --with-hostname or --without-hostname was given.
|
||||
if test "${with_hostname+set}" = set; then
|
||||
withval="$with_hostname"
|
||||
|
@ -9514,7 +9516,7 @@ if test "${enable_ssl+set}" = set; then
|
|||
|
||||
echo "$as_me:$LINENO: checking for openssl" >&5
|
||||
echo $ECHO_N "checking for openssl... $ECHO_C" >&6
|
||||
for dir in $withval /usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr; do
|
||||
for dir in $enableval /usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr; do
|
||||
ssldir="$dir"
|
||||
if test -f "$dir/include/openssl/ssl.h"; then
|
||||
echo "$as_me:$LINENO: result: found in $ssldir/include/openssl" >&5
|
||||
|
@ -9554,7 +9556,7 @@ if test "${enable_ziplinks+set}" = set; then
|
|||
|
||||
echo "$as_me:$LINENO: checking for zlib" >&5
|
||||
echo $ECHO_N "checking for zlib... $ECHO_C" >&6
|
||||
for dir in $withval /usr/local /usr /usr/pkg; do
|
||||
for dir in $enableval /usr/local /usr /usr/pkg; do
|
||||
zlibdir="$dir"
|
||||
if test -f "$dir/include/zlib.h"; then
|
||||
echo "$as_me:$LINENO: result: found in $zlibdir" >&5
|
||||
|
|
|
@ -20,13 +20,11 @@
|
|||
*/
|
||||
#ifndef MODULES_H
|
||||
#define MODULES_H
|
||||
#include "types.h"
|
||||
#define MOD_VERSION "3.2-b5-1"
|
||||
#define MOD_WE_SUPPORT "3.2-b5*"
|
||||
#define MAXCUSTOMHOOKS 30
|
||||
#define MAXHOOKTYPES 70
|
||||
typedef void (*vFP)(); /* Void function pointer */
|
||||
typedef int (*iFP)(); /* Integer function pointer */
|
||||
typedef char (*cFP)(); /* char * function pointer */
|
||||
#if defined(_WIN32)
|
||||
#define DLLFUNC _declspec(dllexport)
|
||||
#define irc_dlopen(x,y) LoadLibrary(x)
|
||||
|
|
|
@ -634,6 +634,8 @@ struct aloopStruct {
|
|||
unsigned do_bancheck : 1;
|
||||
unsigned ircd_rehashing : 1;
|
||||
unsigned tainted : 1;
|
||||
aClient *rehash_save_cptr, *rehash_save_sptr;
|
||||
int rehash_save_sig;
|
||||
};
|
||||
|
||||
typedef struct Whowas {
|
||||
|
@ -1178,12 +1180,17 @@ struct _configitem_alias_format {
|
|||
regex_t expr;
|
||||
};
|
||||
|
||||
#define INCLUDE_NOTLOADED 1
|
||||
#define INCLUDE_NOTLOADED 0x1
|
||||
#define INCLUDE_REMOTE 0x2
|
||||
#define INCLUDE_DLQUEUED 0x4
|
||||
|
||||
struct _configitem_include {
|
||||
ConfigItem *prev, *next;
|
||||
ConfigFlag_ban flag;
|
||||
char *file;
|
||||
#ifdef USE_LIBCURL
|
||||
char *url;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct _configitem_help {
|
||||
|
|
27
include/types.h
Normal file
27
include/types.h
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* Unreal Internet Relay Chat Daemon, src/url.c
|
||||
* (C) 2003 The UnrealIRCd Team
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef TYPES_H
|
||||
#define TYPES_H
|
||||
|
||||
typedef void (*vFP)(); /* Void function pointer */
|
||||
typedef int (*iFP)(); /* Integer function pointer */
|
||||
typedef char (*cFP)(); /* char * function pointer */
|
||||
|
||||
#endif
|
|
@ -855,6 +855,9 @@ int InitwIRCD(int argc, char *argv[])
|
|||
bzero(&StatsZ, sizeof(StatsZ));
|
||||
setup_signals();
|
||||
init_ircstats();
|
||||
#ifdef USE_LIBCURL
|
||||
url_init();
|
||||
#endif
|
||||
umode_init();
|
||||
#ifdef EXTCMODE
|
||||
extcmode_init();
|
||||
|
|
|
@ -612,7 +612,7 @@ matchok:
|
|||
if (WHOLIMIT && !IsAnOper(sptr) && ++i > WHOLIMIT)
|
||||
{
|
||||
sendto_one(sptr, rpl_str(ERR_WHOLIMEXCEED), me.name, sptr->name, WHOLIMIT);
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
|
||||
channel = first_visible_channel(sptr, acptr, &flg);
|
||||
|
|
|
@ -1649,7 +1649,9 @@ int read_message(time_t delay, fdlist *listp)
|
|||
#ifdef _WIN32
|
||||
FD_ZERO(&excpt_set);
|
||||
#endif
|
||||
|
||||
#ifdef USE_LIBCURL
|
||||
url_do_transfers_async();
|
||||
#endif
|
||||
#ifdef NO_FDLIST
|
||||
for (i = LastSlot; i >= 0; i--)
|
||||
#else
|
||||
|
|
322
src/s_conf.c
322
src/s_conf.c
|
@ -18,6 +18,7 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
#include "struct.h"
|
||||
#include "url.h"
|
||||
#include "common.h"
|
||||
#include "sys.h"
|
||||
#include "numeric.h"
|
||||
|
@ -378,6 +379,14 @@ ConfigFile *conf = NULL;
|
|||
int config_error_flag = 0;
|
||||
int config_verbose = 0;
|
||||
|
||||
void add_include(char *);
|
||||
#ifdef USE_LIBCURL
|
||||
void add_remote_include(char *, char *);
|
||||
#endif
|
||||
void unload_notloaded_includes(void);
|
||||
void load_includes(void);
|
||||
void unload_loaded_includes(void);
|
||||
|
||||
/* Pick out the ip address and the port number from a string.
|
||||
* The string syntax is: ip:port. ip must be enclosed in brackets ([]) if its an ipv6
|
||||
* address because they contain colon (:) separators. The ip part is optional. If the string
|
||||
|
@ -1358,8 +1367,6 @@ aCommand *cmptr = find_Command_simple("PART");
|
|||
|
||||
int init_conf(char *rootconf, int rehash)
|
||||
{
|
||||
ConfigItem_include *inc, *next;
|
||||
|
||||
config_status("Loading IRCd configuration ..");
|
||||
if (conf)
|
||||
{
|
||||
|
@ -1381,15 +1388,7 @@ int init_conf(char *rootconf, int rehash)
|
|||
#ifndef STATIC_LINKING
|
||||
Unload_all_testing_modules();
|
||||
#endif
|
||||
for (inc = conf_include; inc; inc = next)
|
||||
{
|
||||
next = (ConfigItem_include *)inc->next;
|
||||
if (inc->flag.type != INCLUDE_NOTLOADED)
|
||||
continue;
|
||||
ircfree(inc->file);
|
||||
DelListItem(inc, conf_include);
|
||||
MyFree(inc);
|
||||
}
|
||||
unload_notloaded_includes();
|
||||
config_free(conf);
|
||||
conf = NULL;
|
||||
free_iConf(&tempiConf);
|
||||
|
@ -1404,19 +1403,11 @@ int init_conf(char *rootconf, int rehash)
|
|||
#else
|
||||
RunHook0(HOOKTYPE_REHASH);
|
||||
#endif
|
||||
for (inc = conf_include; inc; inc = next)
|
||||
{
|
||||
next = (ConfigItem_include *)inc->next;
|
||||
if (inc->flag.type == INCLUDE_NOTLOADED)
|
||||
continue;
|
||||
ircfree(inc->file);
|
||||
DelListItem(inc, conf_include);
|
||||
MyFree(inc);
|
||||
}
|
||||
|
||||
unload_loaded_includes();
|
||||
}
|
||||
#ifndef STATIC_LINKING
|
||||
Init_all_testing_modules();
|
||||
load_includes();
|
||||
#else
|
||||
if (!rehash) {
|
||||
ModuleInfo ModCoreInfo;
|
||||
|
@ -1426,11 +1417,6 @@ int init_conf(char *rootconf, int rehash)
|
|||
l_commands_Init(&ModCoreInfo);
|
||||
}
|
||||
#endif
|
||||
for (inc = conf_include; inc; inc = (ConfigItem_include *)inc->next)
|
||||
{
|
||||
if (inc->flag.type == INCLUDE_NOTLOADED)
|
||||
inc->flag.type = 0;
|
||||
}
|
||||
if (config_run() < 0)
|
||||
{
|
||||
config_error("Bad case of config errors. Server will now die. This really shouldn't happen");
|
||||
|
@ -1444,15 +1430,6 @@ int init_conf(char *rootconf, int rehash)
|
|||
}
|
||||
else
|
||||
{
|
||||
for (inc = conf_include; inc; inc = next)
|
||||
{
|
||||
next = (ConfigItem_include *)inc->next;
|
||||
if (inc->flag.type != INCLUDE_NOTLOADED)
|
||||
continue;
|
||||
ircfree(inc->file);
|
||||
DelListItem(inc, conf_include);
|
||||
MyFree(inc);
|
||||
}
|
||||
config_error("IRCd configuration failed to load");
|
||||
config_free(conf);
|
||||
conf = NULL;
|
||||
|
@ -1480,7 +1457,6 @@ int load_conf(char *filename)
|
|||
ConfigFile *cfptr, *cfptr2, **cfptr3;
|
||||
ConfigEntry *ce;
|
||||
int ret;
|
||||
ConfigItem_include *includes;
|
||||
|
||||
if (config_verbose > 0)
|
||||
config_status("Loading config file %s ..", filename);
|
||||
|
@ -1509,19 +1485,6 @@ int load_conf(char *filename)
|
|||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
if (stricmp(filename, CPATH)) {
|
||||
for (includes = conf_include; includes; includes = (ConfigItem_include *)includes->next) {
|
||||
if (includes->flag.type == INCLUDE_NOTLOADED &&
|
||||
!stricmp(includes->file, filename))
|
||||
break;
|
||||
}
|
||||
if (!includes) {
|
||||
includes = MyMalloc(sizeof(ConfigItem_include));
|
||||
includes->file = strdup(filename);
|
||||
includes->flag.type = INCLUDE_NOTLOADED;
|
||||
AddListItem(includes, conf_include);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
|
@ -2480,6 +2443,10 @@ int _conf_include(ConfigFile *conf, ConfigEntry *ce)
|
|||
ce->ce_varlinenum);
|
||||
return -1;
|
||||
}
|
||||
#ifdef USE_LIBCURL
|
||||
if (url_is_valid(ce->ce_vardata))
|
||||
return remote_include(ce);
|
||||
#endif
|
||||
#if !defined(_WIN32) && !defined(_AMIGA) && DEFAULT_PERMISSIONS != 0
|
||||
chmod(ce->ce_vardata, DEFAULT_PERMISSIONS);
|
||||
#endif
|
||||
|
@ -2503,6 +2470,7 @@ int _conf_include(ConfigFile *conf, ConfigEntry *ce)
|
|||
globfree(&files);
|
||||
return ret;
|
||||
}
|
||||
add_include(files.gl_pathv[i]);
|
||||
}
|
||||
globfree(&files);
|
||||
#elif defined(_WIN32)
|
||||
|
@ -2526,15 +2494,23 @@ int _conf_include(ConfigFile *conf, ConfigEntry *ce)
|
|||
strcpy(path,cPath);
|
||||
strcat(path,FindData.cFileName);
|
||||
ret = load_conf(path);
|
||||
if (ret >= 0)
|
||||
add_include(path);
|
||||
free(path);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = load_conf(FindData.cFileName);
|
||||
if (ret >= 0)
|
||||
add_include(FindData.cFileName);
|
||||
}
|
||||
if (ret < 0)
|
||||
{
|
||||
FindClose(hFind);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
while (FindNextFile(hFind, &FindData) != 0) {
|
||||
if (cPath) {
|
||||
|
@ -2542,18 +2518,32 @@ int _conf_include(ConfigFile *conf, ConfigEntry *ce)
|
|||
strcpy(path,cPath);
|
||||
strcat(path,FindData.cFileName);
|
||||
ret = load_conf(path);
|
||||
free(path);
|
||||
if (ret < 0)
|
||||
if (ret >= 0)
|
||||
{
|
||||
add_include(path);
|
||||
free(path);
|
||||
}
|
||||
else
|
||||
{
|
||||
free(path);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = load_conf(FindData.cFileName);
|
||||
if (ret >= 0)
|
||||
add_include(FindData.cFileName);
|
||||
}
|
||||
}
|
||||
FindClose(hFind);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
#else
|
||||
return (load_conf(ce->ce_vardata));
|
||||
ret = load_conf(ce->ce_vardata);
|
||||
if (ret >= 0)
|
||||
add_include(ce->ce_vardata);
|
||||
return ret;
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
@ -6937,10 +6927,88 @@ int _test_deny(ConfigFile *conf, ConfigEntry *ce)
|
|||
return errors;
|
||||
}
|
||||
|
||||
#ifdef USE_LIBCURL
|
||||
static void conf_download_complete(char *url, char *file, char *errorbuf, int cached)
|
||||
{
|
||||
ConfigItem_include *inc;
|
||||
if (!loop.ircd_rehashing)
|
||||
{
|
||||
remove(file);
|
||||
return;
|
||||
}
|
||||
if (!file && !cached)
|
||||
{
|
||||
config_error("Error downloading %s: %s", url, errorbuf);
|
||||
loop.ircd_rehashing = 0;
|
||||
unload_notloaded_includes();
|
||||
return;
|
||||
}
|
||||
for (inc = conf_include; inc; inc = (ConfigItem_include *)inc->next)
|
||||
{
|
||||
if (!(inc->flag.type & INCLUDE_REMOTE))
|
||||
continue;
|
||||
if (inc->flag.type & INCLUDE_NOTLOADED)
|
||||
continue;
|
||||
if (!stricmp(url, inc->url))
|
||||
{
|
||||
inc->flag.type &= ~INCLUDE_DLQUEUED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (cached)
|
||||
{
|
||||
char *urlfile = url_getfilename(url);
|
||||
char *tmp = unreal_mktemp("tmp", urlfile);
|
||||
free(urlfile);
|
||||
unreal_copyfile(inc->file, tmp);
|
||||
add_remote_include(tmp, url);
|
||||
}
|
||||
else
|
||||
add_remote_include(file, url);
|
||||
for (inc = conf_include; inc; inc = (ConfigItem_include *)inc->next)
|
||||
{
|
||||
if (inc->flag.type & INCLUDE_DLQUEUED)
|
||||
return;
|
||||
}
|
||||
rehash_internal(loop.rehash_save_cptr, loop.rehash_save_sptr, loop.rehash_save_sig);
|
||||
}
|
||||
#endif
|
||||
|
||||
int rehash(aClient *cptr, aClient *sptr, int sig)
|
||||
{
|
||||
#ifdef USE_LIBCURL
|
||||
ConfigItem_include *inc;
|
||||
if (loop.ircd_rehashing)
|
||||
{
|
||||
if (!sig)
|
||||
sendto_one(sptr, ":%s NOTICE %s :A rehash is already in progress",
|
||||
me.name, sptr->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
loop.ircd_rehashing = 1;
|
||||
loop.rehash_save_cptr = cptr;
|
||||
loop.rehash_save_sptr = sptr;
|
||||
loop.rehash_save_sig = sig;
|
||||
for (inc = conf_include; inc; inc = (ConfigItem_include *)inc->next)
|
||||
{
|
||||
struct stat sb;
|
||||
if (!(inc->flag.type & INCLUDE_REMOTE))
|
||||
continue;
|
||||
if (inc->flag.type & INCLUDE_NOTLOADED)
|
||||
continue;
|
||||
stat(inc->file, &sb);
|
||||
download_file_async(inc->url, sb.st_ctime, conf_download_complete);
|
||||
inc->flag.type |= INCLUDE_DLQUEUED;
|
||||
}
|
||||
return 0;
|
||||
#else
|
||||
return rehash_internal(cptr, sptr, sig);
|
||||
#endif
|
||||
}
|
||||
|
||||
int rehash_internal(aClient *cptr, aClient *sptr, int sig)
|
||||
{
|
||||
flush_connections(&me);
|
||||
if (sig == 1)
|
||||
{
|
||||
|
@ -6995,3 +7063,153 @@ void listen_cleanup()
|
|||
if (i)
|
||||
close_listeners();
|
||||
}
|
||||
|
||||
#ifdef USE_LIBCURL
|
||||
char *find_remote_include(char *url)
|
||||
{
|
||||
ConfigItem_include *inc;
|
||||
for (inc = conf_include; inc; inc = (ConfigItem_include *)inc->next)
|
||||
{
|
||||
if (!(inc->flag.type & INCLUDE_NOTLOADED))
|
||||
continue;
|
||||
if (!(inc->flag.type & INCLUDE_REMOTE))
|
||||
continue;
|
||||
if (!stricmp(url, inc->url))
|
||||
return inc->file;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int remote_include(ConfigEntry *ce)
|
||||
{
|
||||
char *file = find_remote_include(ce->ce_vardata);
|
||||
int ret;
|
||||
if (!loop.ircd_rehashing || (loop.ircd_rehashing && !file))
|
||||
{
|
||||
char *error;
|
||||
if (config_verbose > 0)
|
||||
config_status("Downloading %s", ce->ce_vardata);
|
||||
file = download_file(ce->ce_vardata, &error);
|
||||
if (!file)
|
||||
{
|
||||
config_error("%s:%i: include: error downloading '%s': %s",
|
||||
ce->ce_fileptr->cf_filename, ce->ce_varlinenum,
|
||||
ce->ce_vardata, error);
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((ret = load_conf(file)) >= 0)
|
||||
add_remote_include(file, ce->ce_vardata);
|
||||
free(file);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (config_verbose > 0)
|
||||
config_status("Loading %s from download", ce->ce_vardata);
|
||||
if ((ret = load_conf(file)) >= 0)
|
||||
add_remote_include(file, ce->ce_vardata);
|
||||
return ret;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
void add_include(char *file)
|
||||
{
|
||||
ConfigItem_include *inc;
|
||||
if (!stricmp(file, CPATH))
|
||||
return;
|
||||
|
||||
for (inc = conf_include; inc; inc = (ConfigItem_include *)inc->next)
|
||||
{
|
||||
if (!(inc->flag.type & INCLUDE_NOTLOADED))
|
||||
continue;
|
||||
if (!stricmp(file, inc->file))
|
||||
return;
|
||||
}
|
||||
inc = MyMallocEx(sizeof(ConfigItem_include));
|
||||
inc->file = strdup(file);
|
||||
inc->flag.type = INCLUDE_NOTLOADED;
|
||||
AddListItem(inc, conf_include);
|
||||
}
|
||||
|
||||
#ifdef USE_LIBCURL
|
||||
void add_remote_include(char *file, char *url)
|
||||
{
|
||||
ConfigItem_include *inc;
|
||||
|
||||
for (inc = conf_include; inc; inc = (ConfigItem_include *)inc->next)
|
||||
{
|
||||
if (!(inc->flag.type & INCLUDE_REMOTE))
|
||||
continue;
|
||||
if (!(inc->flag.type & INCLUDE_NOTLOADED))
|
||||
continue;
|
||||
if (!stricmp(url, inc->url))
|
||||
return;
|
||||
}
|
||||
inc = MyMallocEx(sizeof(ConfigItem_include));
|
||||
inc->file = strdup(file);
|
||||
inc->url = strdup(url);
|
||||
inc->flag.type = (INCLUDE_NOTLOADED|INCLUDE_REMOTE);
|
||||
AddListItem(inc, conf_include);
|
||||
}
|
||||
#endif
|
||||
|
||||
void unload_notloaded_includes(void)
|
||||
{
|
||||
ConfigItem_include *inc, *next;
|
||||
|
||||
for (inc = conf_include; inc; inc = next)
|
||||
{
|
||||
next = (ConfigItem_include *)inc->next;
|
||||
if (inc->flag.type & INCLUDE_NOTLOADED)
|
||||
{
|
||||
#ifdef USE_LIBCURL
|
||||
if (inc->flag.type & INCLUDE_REMOTE)
|
||||
{
|
||||
remove(inc->file);
|
||||
free(inc->url);
|
||||
}
|
||||
#endif
|
||||
free(inc->file);
|
||||
DelListItem(inc, conf_include);
|
||||
free(inc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void unload_loaded_includes(void)
|
||||
{
|
||||
ConfigItem_include *inc, *next;
|
||||
|
||||
for (inc = conf_include; inc; inc = next)
|
||||
{
|
||||
next = (ConfigItem_include *)inc->next;
|
||||
if (inc->flag.type & INCLUDE_NOTLOADED)
|
||||
continue;
|
||||
#ifdef USE_LIBCURL
|
||||
if (inc->flag.type & INCLUDE_REMOTE)
|
||||
{
|
||||
remove(inc->file);
|
||||
free(inc->url);
|
||||
}
|
||||
#endif
|
||||
free(inc->file);
|
||||
DelListItem(inc, conf_include);
|
||||
free(inc);
|
||||
}
|
||||
}
|
||||
|
||||
void load_includes(void)
|
||||
{
|
||||
ConfigItem_include *inc;
|
||||
|
||||
/* Doing this for all the modules should actually be faster
|
||||
* than only doing it for modules that are not-loaded
|
||||
*/
|
||||
for (inc = conf_include; inc; inc = (ConfigItem_include *)inc->next)
|
||||
inc->flag.type &= ~INCLUDE_NOTLOADED;
|
||||
}
|
||||
|
|
14
src/s_serv.c
14
src/s_serv.c
|
@ -2915,6 +2915,12 @@ CMD_FUNC(m_rehash)
|
|||
#endif
|
||||
if (parv[2] == NULL)
|
||||
{
|
||||
if (loop.ircd_rehashing)
|
||||
{
|
||||
sendto_one(sptr, ":%s NOTICE %s :A rehash is already in progress",
|
||||
me.name, sptr->name);
|
||||
return 0;
|
||||
}
|
||||
sendto_serv_butone(&me,
|
||||
":%s GLOBOPS :%s is remotely rehashing server config file",
|
||||
me.name, sptr->name);
|
||||
|
@ -2999,7 +3005,15 @@ CMD_FUNC(m_rehash)
|
|||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (loop.ircd_rehashing)
|
||||
{
|
||||
sendto_one(sptr, ":%s NOTICE %s :A rehash is already in progress",
|
||||
me.name, sptr->name);
|
||||
return 0;
|
||||
}
|
||||
sendto_ops("%s is rehashing server config file", parv[0]);
|
||||
}
|
||||
|
||||
/* Normal rehash, rehash motds&rules too, just like the on in the tld block will :p */
|
||||
reread_motdsandrules();
|
||||
|
|
|
@ -1750,7 +1750,7 @@ int unreal_copyfile(char *src, char *dest)
|
|||
if (srcfd < 0)
|
||||
return 0;
|
||||
|
||||
destfd = open(dest, O_WRONLY|O_CREAT, S_IRUSR|S_IXUSR);
|
||||
destfd = open(dest, O_WRONLY|O_CREAT, DEFAULT_PERMISSIONS);
|
||||
|
||||
if (destfd < 0)
|
||||
{
|
||||
|
|
47
src/url.c
47
src/url.c
|
@ -108,7 +108,8 @@ static size_t do_download(void *ptr, size_t size, size_t nmemb, void *stream)
|
|||
* knowledge of how libcurl works. If the function succeeds, the
|
||||
* filename the file was downloaded to is returned. Otherwise NULL
|
||||
* is returned and the string pointed to by error contains the error
|
||||
* message.
|
||||
* message. The returned filename is malloc'ed and must be freed by
|
||||
* the caller.
|
||||
*/
|
||||
char *download_file(char *url, char **error)
|
||||
{
|
||||
|
@ -116,7 +117,8 @@ char *download_file(char *url, char **error)
|
|||
CURL *curl = curl_easy_init();
|
||||
CURLcode res;
|
||||
char *file = url_getfilename(url);
|
||||
char *tmp = unreal_mktemp("tmp", file ? file : "download.conf");
|
||||
char *filename = unreal_getfilename(file);
|
||||
char *tmp = unreal_mktemp("tmp", filename ? filename : "download.conf");
|
||||
if (curl)
|
||||
{
|
||||
FILE *fd = fopen(tmp, "wb");
|
||||
|
@ -133,7 +135,7 @@ char *download_file(char *url, char **error)
|
|||
free(file);
|
||||
curl_easy_cleanup(curl);
|
||||
if (res == CURLE_OK)
|
||||
return tmp;
|
||||
return strdup(tmp);
|
||||
else
|
||||
{
|
||||
remove(tmp);
|
||||
|
@ -145,8 +147,9 @@ char *download_file(char *url, char **error)
|
|||
/*
|
||||
* Initializes the URL system
|
||||
*/
|
||||
void url_init()
|
||||
void url_init(void)
|
||||
{
|
||||
curl_global_init(CURL_GLOBAL_ALL);
|
||||
multihandle = curl_multi_init();
|
||||
}
|
||||
|
||||
|
@ -157,17 +160,21 @@ void url_init()
|
|||
* called when the download completes, or the download fails. The
|
||||
* callback function is defined as:
|
||||
*
|
||||
* void callback(char *filename, char *errorbuf);
|
||||
* void callback(char *url, char *filename, char *errorbuf, int cached);
|
||||
* url will contain the URL that was downloaded
|
||||
* filename will contain the name of the file (if successful, NULL otherwise)
|
||||
* errorbuf will contain the error message (if failed, NULL otherwise)
|
||||
* cached 1 if the specified cachetime is >= the current file on the server,
|
||||
* if so, both filename and errorbuf will be NULL
|
||||
*/
|
||||
void download_file_async(char *url, vFP callback)
|
||||
void download_file_async(char *url, time_t cachetime, vFP callback)
|
||||
{
|
||||
CURL *curl = curl_easy_init();
|
||||
if (curl)
|
||||
{
|
||||
char *file = url_getfilename(url);
|
||||
char *tmp = unreal_mktemp("tmp", file ? file : "download.conf");
|
||||
char *filename = unreal_getfilename(file);
|
||||
char *tmp = unreal_mktemp("tmp", filename ? filename : "download.conf");
|
||||
FileHandle *handle = malloc(sizeof(FileHandle));
|
||||
if (file)
|
||||
free(file);
|
||||
|
@ -181,6 +188,12 @@ void download_file_async(char *url, vFP callback)
|
|||
bzero(handle->errorbuf, CURL_ERROR_SIZE);
|
||||
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, handle->errorbuf);
|
||||
curl_easy_setopt(curl, CURLOPT_PRIVATE, (char *)handle);
|
||||
if (cachetime)
|
||||
{
|
||||
curl_easy_setopt(curl, CURLOPT_TIMECONDITION, CURL_TIMECOND_IFMODSINCE);
|
||||
curl_easy_setopt(curl, CURLOPT_TIMEVALUE, cachetime);
|
||||
}
|
||||
|
||||
curl_multi_add_handle(multihandle, curl);
|
||||
}
|
||||
}
|
||||
|
@ -189,7 +202,7 @@ void download_file_async(char *url, vFP callback)
|
|||
* Called in the select loop. Handles the transferring of any
|
||||
* queued asynchronous transfers.
|
||||
*/
|
||||
void url_do_transfers_async()
|
||||
void url_do_transfers_async(void)
|
||||
{
|
||||
int cont;
|
||||
int msgs_left;
|
||||
|
@ -228,13 +241,25 @@ void url_do_transfers_async()
|
|||
if (msg->msg == CURLMSG_DONE)
|
||||
{
|
||||
FileHandle *handle;
|
||||
char *url;
|
||||
long code;
|
||||
curl_easy_getinfo(msg->easy_handle, CURLINFO_RESPONSE_CODE, &code);
|
||||
curl_easy_getinfo(msg->easy_handle, CURLINFO_PRIVATE, (char*)&handle);
|
||||
fclose(handle->fd);
|
||||
curl_easy_getinfo(msg->easy_handle, CURLINFO_EFFECTIVE_URL, &url);
|
||||
fclose(handle->fd);
|
||||
if (msg->data.result == CURLE_OK)
|
||||
handle->callback(handle->filename, NULL);
|
||||
{
|
||||
if (code == 304)
|
||||
{
|
||||
handle->callback(url, NULL, NULL, 1);
|
||||
remove(handle->filename);
|
||||
}
|
||||
else
|
||||
handle->callback(url, handle->filename, NULL, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
handle->callback(NULL, handle->errorbuf);
|
||||
handle->callback(url, NULL, handle->errorbuf, 0);
|
||||
remove(handle->filename);
|
||||
}
|
||||
free(handle);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue