mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-26 22:37:45 +00:00
Merge pull request #322 from goaaats/ini_network_fixes
zone, lobby, api: Streamline network configuration for new INI config
This commit is contained in:
commit
2de00dc70a
8 changed files with 36 additions and 22 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -118,3 +118,6 @@ src/servers/Scripts/*/ScriptLoader.cpp
|
|||
# cotire generated files/folders
|
||||
cotire/
|
||||
*_cotire.cmake
|
||||
|
||||
*objects.txt
|
||||
*exports.def
|
|
@ -2,7 +2,7 @@
|
|||
Host = 127.0.0.1
|
||||
Port = 3306
|
||||
Database = sapphire
|
||||
Username = sapphire
|
||||
Username = root
|
||||
Password =
|
||||
SyncThreads = 2
|
||||
AsyncThreads = 2
|
||||
|
@ -12,6 +12,7 @@ ServerSecret = default
|
|||
DataPath = C:\\SquareEnix\\FINAL FANTASY XIV - A Realm Reborn\\game\\sqpack
|
||||
|
||||
[GlobalNetwork]
|
||||
; Values definining how Users and other servers will access - these have to be set to your public IP when running a public server
|
||||
ZoneHost = 127.0.0.1
|
||||
ZonePort = 54992
|
||||
|
||||
|
|
|
@ -2,3 +2,7 @@
|
|||
WorldID = 67
|
||||
AllowNoSessionConnect = false
|
||||
WorldName = Sapphire
|
||||
|
||||
[LobbyNetwork]
|
||||
ListenIp = 0.0.0.0
|
||||
ListenPort = 54994
|
|
@ -1,2 +1,6 @@
|
|||
[CharacterCreation]
|
||||
DefaultGMRank = 255
|
||||
|
||||
[RestNetwork]
|
||||
ListenIp = 0.0.0.0
|
||||
ListenPort = 80
|
|
@ -9,6 +9,10 @@ HotSwap = true
|
|||
[Network]
|
||||
DisconnectTimeout = 20
|
||||
|
||||
[ZoneNetwork]
|
||||
ListenIp = 0.0.0.0
|
||||
ListenPort = 54992
|
||||
|
||||
[General]
|
||||
; Sent on login - each line must be shorter than 307 characters, split lines with ';'
|
||||
MotD = Welcome to Sapphire!;This is a very good server;You can change these messages by editing General.MotD in config/zone.ini
|
|
@ -95,12 +95,11 @@ bool loadSettings( int32_t argc, char* argv[] )
|
|||
|
||||
if( arg == "ip" )
|
||||
{
|
||||
// todo: ip addr in config
|
||||
m_pConfig->setValue< std::string >( "GlobalNetwork.RestHost", val );
|
||||
m_pConfig->setValue< std::string >( "RestNetwork.ListenIp", val );
|
||||
}
|
||||
else if( arg == "p" || arg == "port" )
|
||||
{
|
||||
m_pConfig->setValue< std::string >( "GlobalNetwork.RestPort", val );
|
||||
m_pConfig->setValue< std::string >( "RestNetwork.ListenPort", val );
|
||||
}
|
||||
else if( arg == "exdpath" || arg == "datapath" )
|
||||
{
|
||||
|
@ -164,7 +163,8 @@ bool loadSettings( int32_t argc, char* argv[] )
|
|||
if( !loader.initDbs() )
|
||||
return false;
|
||||
|
||||
server.config.port = static_cast< uint16_t >( std::stoul( m_pConfig->getValue< std::string >( "GlobalNetwork.RestPort", "80" ) ) );
|
||||
server.config.port = static_cast< uint16_t >( std::stoul( m_pConfig->getValue< std::string >( "RestNetwork.ListenPort", "80" ) ) );
|
||||
server.config.address = m_pConfig->getValue< std::string >( "RestNetwork.ListenIp", "0.0.0.0" );
|
||||
|
||||
g_log.info( "Database: Connected to " + info.host + ":" + std::to_string( info.port ) );
|
||||
|
||||
|
@ -756,9 +756,6 @@ int main( int argc, char* argv[] )
|
|||
if( !loadSettings( argc, argv ) )
|
||||
throw std::exception();
|
||||
|
||||
server.config.port = stoi( m_pConfig->getValue< std::string >( "GlobalNetwork.RestPort", "80" ) );
|
||||
g_log.info( "Starting API server at port " + m_pConfig->getValue< std::string >( "GlobalNetwork.RestPort", "80" ) + "..." );
|
||||
|
||||
server.resource["^/ZoneName/([0-9]+)$"]["GET"] = &getZoneName;
|
||||
server.resource["^/sapphire-api/lobby/createAccount"]["POST"] = &createAccount;
|
||||
server.resource["^/sapphire-api/lobby/login"]["POST"] = &login;
|
||||
|
@ -781,6 +778,8 @@ int main( int argc, char* argv[] )
|
|||
server.start();
|
||||
} );
|
||||
|
||||
g_log.info( "API server running on " + m_pConfig->getValue< std::string >( "RestNetwork.ListenIp", "0.0.0.0" ) + ":" + m_pConfig->getValue< std::string >( "RestNetwork.ListenPort", "80" ) );
|
||||
|
||||
//Wait for server to start so that the client can connect
|
||||
this_thread::sleep_for( chrono::seconds( 1 ) );
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ namespace Core {
|
|||
Network::HivePtr hive( new Network::Hive() );
|
||||
Network::addServerToHive< Network::GameConnection >( m_ip, m_port, hive );
|
||||
|
||||
g_log.info( "Lobbyserver ready for connections." );
|
||||
g_log.info( "Lobby server running on " + m_pConfig->getValue< std::string >( "LobbyNetwork.ListenIp", "0.0.0.0" ) + ":" + m_pConfig->getValue< std::string >( "LobbyNetwork.ListenPort", "80" ) );
|
||||
|
||||
boost::thread_group worker_threads;
|
||||
worker_threads.create_thread( boost::bind( &Network::Hive::Run, hive.get() ) );
|
||||
|
@ -109,11 +109,11 @@ namespace Core {
|
|||
if( arg == "ip" )
|
||||
{
|
||||
// todo: ip addr in config
|
||||
m_pConfig->setValue< std::string >( "GlobalNetwork.LobbyHost", val );
|
||||
m_pConfig->setValue< std::string >( "LobbyNetwork.ListenIp", val );
|
||||
}
|
||||
else if( arg == "p" || arg == "port" )
|
||||
{
|
||||
m_pConfig->setValue< std::string >( "GlobalNetwork.LobbyPort", val );
|
||||
m_pConfig->setValue< std::string >( "LobbyNetwork.LobbyPort", val );
|
||||
}
|
||||
else if( arg == "worldip" || arg == "worldip" )
|
||||
{
|
||||
|
@ -131,8 +131,8 @@ namespace Core {
|
|||
}
|
||||
}
|
||||
|
||||
m_port = m_pConfig->getValue< uint16_t >( "GlobalNetwork.LobbyPort", 54994 );
|
||||
m_ip = m_pConfig->getValue< std::string >( "GlobalNetwork.LobbyHost", "0.0.0.0" );
|
||||
m_port = m_pConfig->getValue< uint16_t >( "LobbyNetwork.ListenPort", 54994 );
|
||||
m_ip = m_pConfig->getValue< std::string >( "LobbyNetwork.ListenIp", "0.0.0.0" );
|
||||
|
||||
g_restConnector.restHost = m_pConfig->getValue< std::string >( "GlobalNetwork.RestHost" ) + ":" + m_pConfig->getValue< std::string >( "GlobalNetwork.RestPort" );
|
||||
g_restConnector.serverSecret = m_pConfig->getValue< std::string >( "GlobalParameters.ServerSecret" );
|
||||
|
|
|
@ -85,11 +85,11 @@ bool Core::ServerZone::loadSettings( int32_t argc, char* argv[] )
|
|||
if( arg == "ip" )
|
||||
{
|
||||
// todo: ip addr in config
|
||||
pConfig->setValue< std::string >( "GlobalNetwork.ZoneIP", val );
|
||||
pConfig->setValue< std::string >( "ZoneNetwork.ListenIp", val );
|
||||
}
|
||||
else if( arg == "p" || arg == "port" )
|
||||
{
|
||||
pConfig->setValue< std::string >( "GlobalNetwork.ZonePort", val );
|
||||
pConfig->setValue< std::string >( "ZoneNetwork.ListenPort", val );
|
||||
}
|
||||
else if( arg == "exdpath" || arg == "datapath" )
|
||||
{
|
||||
|
@ -145,8 +145,8 @@ bool Core::ServerZone::loadSettings( int32_t argc, char* argv[] )
|
|||
if( !loader.initDbs() )
|
||||
return false;
|
||||
|
||||
m_port = pConfig->getValue< uint16_t >( "GlobalNetwork.ZonePort", 54992 );
|
||||
m_ip = pConfig->getValue< std::string >( "GlobalNetwork.ZoneIP", "0.0.0.0" );
|
||||
m_port = pConfig->getValue< uint16_t >( "ZoneNetwork.ListenPort", 54992 );
|
||||
m_ip = pConfig->getValue< std::string >( "ZoneNetwork.ListenIp", "0.0.0.0" );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -184,8 +184,7 @@ void Core::ServerZone::run( int32_t argc, char* argv[] )
|
|||
std::vector< std::thread > thread_list;
|
||||
thread_list.emplace_back( std::thread( std::bind( &Network::Hive::Run, hive.get() ) ) );
|
||||
|
||||
pLog->info( "Server listening on port: " + std::to_string( m_port ) );
|
||||
pLog->info( "Ready for connections..." );
|
||||
pLog->info( "Zone server running on " + m_ip + ":" + std::to_string( m_port ) );
|
||||
|
||||
mainLoop();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue