diff options
| author | panaut0lordv <panaut0lordv@gmail.com> | 2009-03-20 22:17:39 +0100 |
|---|---|---|
| committer | panaut0lordv <panaut0lordv@gmail.com> | 2009-03-20 22:17:39 +0100 |
| commit | e409fb63e9fd47f4c586ab43ca4b42b9ca58b423 (patch) | |
| tree | 760385782ea4fc140e62c6f127509f77d691a47a /src/trinityrealm | |
| parent | f3a543bef3690dae643653ff97120db17ba13d34 (diff) | |
mangosd->trinitycore & realmd->trinityrealm
--HG--
branch : trunk
Diffstat (limited to 'src/trinityrealm')
| -rw-r--r-- | src/trinityrealm/AuthCodes.h | 11 | ||||
| -rw-r--r-- | src/trinityrealm/AuthSocket.cpp | 1 | ||||
| -rw-r--r-- | src/trinityrealm/AuthSocket.h | 5 | ||||
| -rw-r--r-- | src/trinityrealm/CMakeLists.txt | 14 | ||||
| -rw-r--r-- | src/trinityrealm/Main.cpp | 48 | ||||
| -rw-r--r-- | src/trinityrealm/Makefile.am | 59 | ||||
| -rw-r--r-- | src/trinityrealm/RealmList.cpp | 4 | ||||
| -rw-r--r-- | src/trinityrealm/RealmList.h | 8 | ||||
| -rw-r--r-- | src/trinityrealm/TrinityRealm.ico | bin | 0 -> 136606 bytes | |||
| -rw-r--r-- | src/trinityrealm/realmd.rc | 85 | ||||
| -rw-r--r-- | src/trinityrealm/resource.h | 3 | ||||
| -rw-r--r-- | src/trinityrealm/trinityrealm.conf.dist | 122 |
12 files changed, 311 insertions, 49 deletions
diff --git a/src/trinityrealm/AuthCodes.h b/src/trinityrealm/AuthCodes.h index defa513dede..9a38712af83 100644 --- a/src/trinityrealm/AuthCodes.h +++ b/src/trinityrealm/AuthCodes.h @@ -1,7 +1,7 @@ -/* - * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/> +/* + * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/> * - * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> + * Copyright (C) 2008-2009 Trinity <http://www.trinitycore.org/> * * 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 @@ -68,9 +68,8 @@ enum LoginResult // we need to stick to 1 version or half of the stuff will work for someone // others will not and opposite -// will only support WoW and WoW:TBC 2.4.3 client build 8606... +// will only support WoW, WoW:TBC and WoW:WotLK 3.0.9 client build 9551... -#define EXPECTED_TRINITY_CLIENT_BUILD {8606, 0} +#define EXPECTED_TRINITY_CLIENT_BUILD {9551, 0} #endif - diff --git a/src/trinityrealm/AuthSocket.cpp b/src/trinityrealm/AuthSocket.cpp index dd7bc31e45b..c5c81593737 100644 --- a/src/trinityrealm/AuthSocket.cpp +++ b/src/trinityrealm/AuthSocket.cpp @@ -1092,4 +1092,3 @@ Patcher::~Patcher() for(Patches::iterator i = _patches.begin(); i != _patches.end(); i++ ) delete i->second; } - diff --git a/src/trinityrealm/AuthSocket.h b/src/trinityrealm/AuthSocket.h index 73aa1b280e2..3cae54c7789 100644 --- a/src/trinityrealm/AuthSocket.h +++ b/src/trinityrealm/AuthSocket.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/> + * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/> * - * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> + * Copyright (C) 2008-2009 Trinity <http://www.trinitycore.org/> * * 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 @@ -84,4 +84,3 @@ class AuthSocket: public TcpSocket }; #endif /// @} - diff --git a/src/trinityrealm/CMakeLists.txt b/src/trinityrealm/CMakeLists.txt index f883259bbf5..cddea04ea47 100644 --- a/src/trinityrealm/CMakeLists.txt +++ b/src/trinityrealm/CMakeLists.txt @@ -9,24 +9,18 @@ RealmList.cpp RealmList.h ) -SET(trinity-realm_LINK_FLAGS "") - add_executable(trinity-realm ${trinity-realm_SRCS}) add_definitions( -D_TRINITY_REALM_CONFIG='"${CONF_DIR}/trinityrealm.conf"' ) IF (DO_MYSQL) - SET(trinity-realm_LINK_FLAGS "-pthread ${trinity-realm_LINK_FLAGS}") + #SET_TARGET_PROPERTIES(mangos-realmd PROPERTIES LINK_FLAGS ${MYSQL_LIBS}) + SET_TARGET_PROPERTIES(trinity-realm PROPERTIES LINK_FLAGS "-pthread") ENDIF(DO_MYSQL) IF (DO_POSTGRE) - SET(trinity-realm_LINK_FLAGS "${POSTGRE_LIBS} ${trinity-realm_LINK_FLAGS}") + SET_TARGET_PROPERTIES(trinity-realmd PROPERTIES LINK_FLAGS ${POSTGRE_LIBS}) ENDIF(DO_POSTGRE) -IF (CMAKE_SYSTEM_NAME MATCHES "Darwin") - SET(trinity-realm_LINK_FLAGS "-framework Carbon ${trinity-realm_LINK_FLAGS}") -ENDIF (CMAKE_SYSTEM_NAME MATCHES "Darwin") - -SET_TARGET_PROPERTIES(trinity-realm PROPERTIES LINK_FLAGS "${trinity-realm_LINK_FLAGS}") target_link_libraries( trinity-realm @@ -40,11 +34,11 @@ ZThread zlib ${SSLLIB} ${MYSQL_LIBRARIES} -${OSX_LIBS} ) install(TARGETS trinity-realm DESTINATION bin) + ########### install files ############### install(FILES trinityrealm.conf.dist DESTINATION etc) diff --git a/src/trinityrealm/Main.cpp b/src/trinityrealm/Main.cpp index 8c2c199b2f4..bd318779f83 100644 --- a/src/trinityrealm/Main.cpp +++ b/src/trinityrealm/Main.cpp @@ -31,7 +31,6 @@ #include "sockets/ListenSocket.h" #include "AuthSocket.h" #include "SystemConfig.h" -#include "revision.h" #include "Util.h" // Format is YYYYMMDDRR where RR is the change in the conf file @@ -41,12 +40,12 @@ #endif #ifndef _TRINITY_REALM_CONFIG -# define _TRINITY_REALM_CONFIG "trinityrealm.conf" +# define _TRINITY_REALM_CONFIG "TrinityRealm.conf" #endif //_TRINITY_REALM_CONFIG #ifdef WIN32 #include "ServiceWin32.h" -char serviceName[] = "realmd"; +char serviceName[] = "TrinityRealm"; char serviceLongName[] = "Trinity realm service"; char serviceDescription[] = "Massive Network Game Object Server"; /* @@ -58,7 +57,7 @@ char serviceDescription[] = "Massive Network Game Object Server"; int m_ServiceStatus = -1; #endif -bool StartDB(std::string &dbstring); +bool StartDB(); void UnhookSignals(); void HookSignals(); @@ -71,7 +70,6 @@ DatabaseType LoginDatabase; ///< Accessor to the void usage(const char *prog) { sLog.outString("Usage: \n %s [<options>]\n" - " --version print version and exit\n\r" " -c config_file use config_file as configuration file\n\r" #ifdef WIN32 " Running as service functions:\n\r" @@ -102,12 +100,6 @@ extern int main(int argc, char **argv) cfg_file = argv[c]; } - if( strcmp(argv[c],"--version") == 0) - { - printf("%s\n", _FULLVERSION); - return 0; - } - #ifdef WIN32 //////////// //Services// @@ -187,10 +179,18 @@ extern int main(int argc, char **argv) } ///- Initialize the database connection - std::string dbstring; - if(!StartDB(dbstring)) + if(!StartDB()) return 1; + ///- Initialize the log database + if(sConfig.GetBoolDefault("EnableLogDB", false)) + { + // everything successful - set var to enable DB logging once startup finished. + sLog.SetLogDBLater(true); + // ensure we've set realm to 0 (realmd realmid) + sLog.SetRealmID(0); + } + ///- Get the list of realms for the server m_realmList.Initialize(sConfig.GetIntDefault("RealmsStateUpdateDelay", 20)); if (m_realmList.size() == 0) @@ -243,7 +243,7 @@ extern int main(int argc, char **argv) sLog.outError("Can't set used processors (hex): %x", curAff); } } - sLog.outString(); + sLog.outString(""); } bool Prio = sConfig.GetBoolDefault("ProcessPriority", false); @@ -254,7 +254,7 @@ extern int main(int argc, char **argv) sLog.outString("TrinityRealm process priority class set to HIGH"); else sLog.outError("ERROR: Can't set realmd process priority class."); - sLog.outString(); + sLog.outString(""); } } #endif @@ -263,6 +263,15 @@ extern int main(int argc, char **argv) uint32 numLoops = (sConfig.GetIntDefault( "MaxPingTime", 30 ) * (MINUTE * 1000000 / 100000)); uint32 loopCounter = 0; + // possibly enable db logging; avoid massive startup spam by doing it here. + if (sLog.GetLogDBLater()) + { + sLog.outString("Enabling database logging..."); + sLog.SetLogDBLater(false); + // login db needs thread for logging + sLog.SetLogDB(true); + } + ///- Wait for termination signal while (!stopEvent) { @@ -282,6 +291,7 @@ extern int main(int argc, char **argv) } ///- Wait for the delay thread to exit + LoginDatabase.ThreadEnd(); LoginDatabase.HaltDelayThread(); ///- Remove signal handling before leaving @@ -312,20 +322,21 @@ void OnSignal(int s) } /// Initialize connection to the database -bool StartDB(std::string &dbstring) +bool StartDB() { - if(!sConfig.GetString("LoginDatabaseInfo", &dbstring)) + std::string dbstring = sConfig.GetStringDefault("LoginDatabaseInfo", ""); + if(dbstring.empty()) { sLog.outError("Database not specified"); return false; } - sLog.outString("Database: %s", dbstring.c_str() ); if(!LoginDatabase.Initialize(dbstring.c_str())) { sLog.outError("Cannot connect to database"); return false; } + LoginDatabase.ThreadStart(); return true; } @@ -351,4 +362,3 @@ void UnhookSignals() } /// @} - diff --git a/src/trinityrealm/Makefile.am b/src/trinityrealm/Makefile.am new file mode 100644 index 00000000000..a14b50c847a --- /dev/null +++ b/src/trinityrealm/Makefile.am @@ -0,0 +1,59 @@ +# Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/> +# +# Copyright (C) 2008-2009 Trinity <http://www.trinitycore.org/> +# +# 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 2 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +## Process this file with automake to produce Makefile.in + +## CPP flags for includes, defines, etc. +AM_CPPFLAGS = $(TRINI_INCLUDES) -I$(top_builddir)/src/shared -I$(srcdir)/../../dep/include -I$(srcdir)/../framework -I$(srcdir)/../shared -I$(srcdir) -DSYSCONFDIR=\"$(sysconfdir)/\" + +## Build realm list daemon as standalone program +bin_PROGRAMS = trinity-realmd +trinity_realmd_SOURCES = \ + AuthCodes.h \ + AuthSocket.cpp \ + AuthSocket.h \ + Main.cpp \ + RealmList.cpp \ + RealmList.h + +## Link realm list daemon against the shared library +trinity_realmd_LDADD = ../shared/Database/libmangosdatabase.a ../shared/Config/libmangosconfig.a ../shared/Auth/libmangosauth.a ../shared/libmangosshared.a ../framework/libmangosframework.a ../../dep/src/sockets/libmangossockets.a ../../dep/src/zthread/libZThread.la +trinity_realmd_LDFLAGS = -L../../dep/src/sockets -L../../dep/src/zthread -L$(libdir) $(TRINI_LIBS) + +## Additional files to include when running 'make dist' +# Include realm list daemon configuration +EXTRA_DIST = \ + realmd.conf.dist + +## Additional files to install +sysconf_DATA = \ + realmd.conf.dist + +install-data-hook: + @list='$(sysconf_DATA)'; for p in $$list; do \ + dest=`echo $$p | sed -e s/.dist//`; \ + if test -f $(DESTDIR)$(sysconfdir)/$$dest; then \ + echo "$@ will not overwrite existing $(DESTDIR)$(sysconfdir)/$$dest"; \ + else \ + echo " $(INSTALL_DATA) $$p $(DESTDIR)$(sysconfdir)/$$dest"; \ + $(INSTALL_DATA) $$p $(DESTDIR)$(sysconfdir)/$$dest; \ + fi; \ + done + +clean-local: + rm -f $(sysconf_DATA) diff --git a/src/trinityrealm/RealmList.cpp b/src/trinityrealm/RealmList.cpp index 692f457b1a8..936f7bcd703 100644 --- a/src/trinityrealm/RealmList.cpp +++ b/src/trinityrealm/RealmList.cpp @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/> * * Copyright (C) 2008-2009 Trinity <http://www.trinitycore.org/> @@ -50,7 +50,6 @@ void RealmList::UpdateRealm( uint32 ID, const std::string& name, const std::stri Realm& realm = m_realms[name]; realm.m_ID = ID; - realm.name = name; realm.icon = icon; realm.color = color; realm.timezone = timezone; @@ -100,4 +99,3 @@ void RealmList::UpdateRealms(bool init) delete result; } } - diff --git a/src/trinityrealm/RealmList.h b/src/trinityrealm/RealmList.h index 31690a19eb3..b830a0827a7 100644 --- a/src/trinityrealm/RealmList.h +++ b/src/trinityrealm/RealmList.h @@ -1,7 +1,7 @@ -/* - * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/> +/* + * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/> * - * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> + * Copyright (C) 2008-2009 Trinity <http://www.trinitycore.org/> * * 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 @@ -30,7 +30,6 @@ /// Storage object for a realm struct Realm { - std::string name; std::string address; uint8 icon; uint8 color; @@ -66,4 +65,3 @@ class RealmList }; #endif /// @} - diff --git a/src/trinityrealm/TrinityRealm.ico b/src/trinityrealm/TrinityRealm.ico Binary files differnew file mode 100644 index 00000000000..da318f48a8c --- /dev/null +++ b/src/trinityrealm/TrinityRealm.ico diff --git a/src/trinityrealm/realmd.rc b/src/trinityrealm/realmd.rc new file mode 100644 index 00000000000..bcd37f240c5 --- /dev/null +++ b/src/trinityrealm/realmd.rc @@ -0,0 +1,85 @@ +/* + * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/> + * + * 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 2 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "windows.h" //"afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_APPICON ICON "TrinityRealm.ico" + +///////////////////////////////////////////////////////////////////////////// +// Neutre (Par défaut système) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEUSD) +#ifdef _WIN32 +LANGUAGE LANG_NEUTRAL, SUBLANG_SYS_DEFAULT +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 0,4,6743,685 + PRODUCTVERSION 0,4,6743,685 + FILEFLAGSMASK 0x17L +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x0L + FILETYPE 0x0L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "080004b0" + BEGIN + VALUE "FileDescription", "TrinityRealm" + VALUE "FileVersion", "0, 4, 6743, 685" + VALUE "InternalName", "TrinityRealm" + VALUE "LegalCopyright", "Copyright (C) 2008" + VALUE "OriginalFilename", "TrinityRealm.exe" + VALUE "ProductName", "TrinityRealm" + VALUE "ProductVersion", "0, 4, 6743, 685" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x800, 1200 + END +END +#endif diff --git a/src/trinityrealm/resource.h b/src/trinityrealm/resource.h index fbc730320b4..7e7d8e4b76f 100644 --- a/src/trinityrealm/resource.h +++ b/src/trinityrealm/resource.h @@ -4,7 +4,7 @@ // // Next default values for new objects -// +// #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 101 @@ -13,4 +13,3 @@ #define _APS_NEXT_SYMED_VALUE 101 #endif #endif - diff --git a/src/trinityrealm/trinityrealm.conf.dist b/src/trinityrealm/trinityrealm.conf.dist new file mode 100644 index 00000000000..439f7f21200 --- /dev/null +++ b/src/trinityrealm/trinityrealm.conf.dist @@ -0,0 +1,122 @@ +########################################## +# Trinity Core realmd configuration file # +########################################## +ConfVersion=2007062001 + +################################################################################################################### +# REALMD SETTINGS +# +# LoginDatabaseInfo +# Database connection settings for the realm server. +# Default: hostname;port;username;password;database +# .;somenumber;username;password;database - use named pipes at Windows +# Named pipes: mySQL required adding "enable-named-pipe" to [mysqld] section my.ini +# .;/path/to/unix_socket;username;password;database - use Unix sockets at Unix/Linux +# Unix sockets: experimental, not tested +# +# LogsDir +# Logs directory setting. +# Important: Logs dir must exists, or all logs be disable +# Default: "" - no log directory prefix, if used log names isn't absolute path then logs will be +# stored in current directory for run program. +# +# MaxPingTime +# Settings for maximum database-ping interval (minutes between pings) +# +# RealmServerPort +# Default RealmServerPort +# +# BindIP +# Bind Realm Server to IP/hostname +# +# PidFile +# Realmd daemon PID file +# Default: "" - do not create PID file +# "./realmd.pid" - create PID file (recommended name) +# +# LogLevel +# Server console level of logging +# 0 = Minimum; 1 = Basic; 2 = Detail; 3 = Full/Debug +# Default: 0 +# +# LogFile +# Logfile name +# Default: "realmd.log" +# "" - empty name disable creating log file +# +# LogTimestamp +# Logfile with timestamp of server start in name +# Default: 0 - no timestamp in name +# 1 - add timestamp in name in form Logname_YYYY-MM-DD_HH-MM-SS.Ext for Logname.Ext +# +# LogFileLevel +# Server file level of logging +# 0 = Minimum; 1 = Basic; 2 = Detail; 3 = Full/Debug +# Default: 0 +# +# LogColors +# Color for messages (format "normal error basic detail debug") +# Colors: 0 - BLACK, 1 - RED, 2 - GREEN, 3 - BROWN, 4 - BLUE, 5 - MAGENTA, 6 - CYAN, 7 - GREY, +# 8 - YELLOW, 9 - LRED, 10 - LGREEN, 11 - LBLUE, 12 - LMAGENTA, 13 - LCYAN, 14 - WHITE +# Default: "" - none colors +# Example: "13 7 11 9 5" +# +# EnableLogDB +# Enable/disable logging to database (LogDatabaseInfo). +# Default: 0 - disabled +# 1 - enabled +# +# DBLogLevel +# Log level of DB logging. +# 0 = Minimum; 1 = Basic; 2 = Detail; 3 = Full/Debug +# Default: 3 +# +# UseProcessors +# Used processors mask for multi-processors system (Used only at Windows) +# Default: 0 (selected by OS) +# number (bitmask value of selected processors) +# +# ProcessPriority +# Process proirity setting (Used only at Windows) +# Default: 1 (HIGH) +# 0 (Normal) +# +# RealmsStateUpdateDelay +# Realm list Update up delay (updated at realm list request if delay expired). +# Default: 20 +# 0 (Disabled) +# +# WrongPass.MaxCount +# Number of login attemps with wrong password before the account or IP is banned +# Default: 0 (Never ban) +# +# WrongPass.BanTime +# Duration of the ban in seconds (0 means permanent ban) +# Default: 600 +# +# WrongPass.BanType +# Ban the IP or account on which login is attempted +# Default: 0 (Ban IP) +# 1 (Ban Account) +# +################################################################################################################### + +LoginDatabaseInfo = "127.0.0.1;3306;trinity;trinity;realmd" +LogsDir = "" +MaxPingTime = 30 +RealmServerPort = 3724 +BindIP = "0.0.0.0" +PidFile = "" +LogLevel = 0 +LogFile = "realmd.log" +LogTimestamp = 0 +LogFileLevel = 0 +UseProcessors = 0 +ProcessPriority = 1 +RealmsStateUpdateDelay = 20 +WrongPass.MaxCount = 0 +WrongPass.BanTime = 600 +WrongPass.BanType = 0 +LogColors = "" +EnableLogDB = 0 +DBLogLevel = 1 |
