X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fextra%2Fm_pgsql.cpp;h=5d267fc1acce29f481a414efc7aa3c12ecaa3201;hb=d556a4f8740b65e635ff7d2b976faaedbdac51d4;hp=b24911bb788542c3f42ff63562c303feb31f798f;hpb=3ae4c96f5424834fa16ce6325f9801911252ae76;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/extra/m_pgsql.cpp b/src/modules/extra/m_pgsql.cpp index b24911bb7..5d267fc1a 100644 --- a/src/modules/extra/m_pgsql.cpp +++ b/src/modules/extra/m_pgsql.cpp @@ -11,23 +11,18 @@ * --------------------------------------------------- */ +#include "inspircd.h" #include #include -#include -#include -#include #include - #include "users.h" #include "channels.h" #include "modules.h" -#include "inspircd.h" #include "configreader.h" - #include "m_sqlv2.h" /* $ModDesc: PostgreSQL Service Provider module for all other m_sql* modules, uses v2 of the SQL API */ -/* $CompileFlags: -Iexec("pg_config --includedir") eval("my $s = `pg_config --version`;$s =~ /^.*?(\d+)\.(\d+)\.(\d+).*?$/;my $v = hex(sprintf("0x%02x%02x%02x", $1, $2, $3));print "-DPGSQL_HAS_ESCAPECONN" if($v >= 0x080104);") */ +/* $CompileFlags: -Iexec("pg_config --includedir") eval("my $s = `pg_config --version`;$s =~ /^.*?(\d+)\.(\d+)\.(\d+).*?$/;my $v = hex(sprintf("0x%02x%02x%02x", $1, $2, $3));print "-DPGSQL_HAS_ESCAPECONN" if(($v >= 0x080104) || ($v >= 0x07030F && $v < 0x070400) || ($v >= 0x07040D && $v < 0x080000) || ($v >= 0x080008 && $v < 0x080100));") */ /* $LinkerFlags: -Lexec("pg_config --libdir") -lpq */ /* $ModDep: m_sqlv2.h */ @@ -803,7 +798,6 @@ class ModulePgSQL : public Module { SQLhost host; int ipvalid; - insp_inaddr blargle; host.id = conf.ReadValue("database", "id", i); host.host = conf.ReadValue("database", "hostname", i); @@ -816,7 +810,18 @@ class ModulePgSQL : public Module if (HasHost(host)) continue; - ipvalid = insp_aton(host.host.c_str(), &blargle); +#ifdef IPV6 + if (strchr(host.host.c_str(),':')) + { + in6_addr blargle; + ipvalid = inet_pton(AF_INET6, host.host.c_str(), &blargle); + } + else +#endif + { + in_addr blargle; + ipvalid = inet_aton(host.host.c_str(), &blargle); + } if(ipvalid > 0) { @@ -975,26 +980,5 @@ void SQLConn::DelayReconnect() ((ModulePgSQL*)us)->ReconnectConn(this); } +MODULE_INIT(ModulePgSQL); -class ModulePgSQLFactory : public ModuleFactory -{ - public: - ModulePgSQLFactory() - { - } - - ~ModulePgSQLFactory() - { - } - - virtual Module * CreateModule(InspIRCd* Me) - { - return new ModulePgSQL(Me); - } -}; - - -extern "C" void * init_module( void ) -{ - return new ModulePgSQLFactory; -}