Implements tls self-sign usage and cleans up listener setup
This commit is contained in:
@@ -31,7 +31,6 @@ struct ConnectionArguments
|
|||||||
//! If true then the server will use stdout to log things.
|
//! If true then the server will use stdout to log things.
|
||||||
bool use_stdout { true };
|
bool use_stdout { true };
|
||||||
spdlog::level::level_enum log_level { spdlog::level::info };
|
spdlog::level::level_enum log_level { spdlog::level::info };
|
||||||
bool listen_localhost_only { true };
|
|
||||||
|
|
||||||
std::string format() const;
|
std::string format() const;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -159,15 +159,21 @@ ServerContext::ServerContext( const ConnectionArguments& arguments ) :
|
|||||||
|
|
||||||
app.setFileTypes( { "html", "wasm", "svg", "js", "png", "jpg" } );
|
app.setFileTypes( { "html", "wasm", "svg", "js", "png", "jpg" } );
|
||||||
|
|
||||||
if ( arguments.listen_localhost_only )
|
const bool use_ssl { config::get< bool >( "host", "use_ssl", true ) };
|
||||||
|
|
||||||
|
const auto ipv4_listener { config::get< std::string >( "host", "ipv4_listen", "127.0.0.1" ) };
|
||||||
|
const auto ipv6_listener { config::get< std::string >( "host", "ipv6_listen", "::1" ) };
|
||||||
|
|
||||||
|
if ( use_ssl )
|
||||||
{
|
{
|
||||||
app.addListener( "127.0.0.1", IDHAN_DEFAULT_PORT );
|
const auto server_cert_path { config::get< std::string >( "host", "server_cert_path", "./server.crt" ) };
|
||||||
app.addListener( "::1", IDHAN_DEFAULT_PORT );
|
const auto server_key_path { config::get< std::string >( "host", "server_key_path", "./server.key" ) };
|
||||||
}
|
|
||||||
else
|
if ( !ipv4_listener.empty() )
|
||||||
{
|
app.addListener( ipv4_listener, IDHAN_DEFAULT_PORT, use_ssl, server_cert_path, server_key_path );
|
||||||
app.addListener( "0.0.0.0", IDHAN_DEFAULT_PORT );
|
|
||||||
app.addListener( "::", IDHAN_DEFAULT_PORT );
|
if ( !ipv6_listener.empty() )
|
||||||
|
app.addListener( ipv6_listener, IDHAN_DEFAULT_PORT, use_ssl, server_cert_path, server_key_path );
|
||||||
}
|
}
|
||||||
|
|
||||||
drogon::orm::PostgresConfig config {};
|
drogon::orm::PostgresConfig config {};
|
||||||
|
|||||||
@@ -58,10 +58,6 @@ int main( int argc, char** argv )
|
|||||||
config_location.setDefaultValue( "./config.json" );
|
config_location.setDefaultValue( "./config.json" );
|
||||||
parser.addOption( config_location );
|
parser.addOption( config_location );
|
||||||
|
|
||||||
QCommandLineOption localhost_only { "localhost_only", "Only listens on localhost", "localhost_only" };
|
|
||||||
localhost_only.setDefaultValue( "true" );
|
|
||||||
parser.addOption( localhost_only );
|
|
||||||
|
|
||||||
QCoreApplication app { argc, argv };
|
QCoreApplication app { argc, argv };
|
||||||
app.setApplicationName( "IDHAN" );
|
app.setApplicationName( "IDHAN" );
|
||||||
|
|
||||||
@@ -126,20 +122,6 @@ int main( int argc, char** argv )
|
|||||||
spdlog::info( "Using stdout for logging" );
|
spdlog::info( "Using stdout for logging" );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( parser.isSet( localhost_only ) )
|
|
||||||
{
|
|
||||||
const auto parser_value = parser.value( localhost_only );
|
|
||||||
|
|
||||||
if ( parser_value == "false" || parser_value == "0" )
|
|
||||||
{
|
|
||||||
arguments.listen_localhost_only = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
arguments.listen_localhost_only = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
{
|
||||||
std::locale locale { "" };
|
std::locale locale { "" };
|
||||||
const auto name { locale.name() };
|
const auto name { locale.name() };
|
||||||
|
|||||||
Reference in New Issue
Block a user