X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;f=src%2Fapps%2Fsigner.cpp;h=2b6798c935aa2f15893c5c059ed5135d640797e3;hb=284fe577c65bbdda151d80e2261617a4c7119ed5;hp=ec85009c90a1f3ab5f3b67b7724cb46656283ad9;hpb=e914bd7cac4990c3596bc21956943221a8e84d9b;p=cassiopeia.git diff --git a/src/apps/signer.cpp b/src/apps/signer.cpp index ec85009..2b6798c 100644 --- a/src/apps/signer.cpp +++ b/src/apps/signer.cpp @@ -1,17 +1,19 @@ #include #include #include +#include -#include "database.h" -#include "mysql.h" -#include "simpleOpensslSigner.h" +#include "db/database.h" +#include "db/mysql.h" +#include "crypto/simpleOpensslSigner.h" +#include "crypto/remoteSigner.h" +#include "crypto/sslUtil.h" +#include "io/bios.h" +#include "io/slipBio.h" +#include "io/recordHandler.h" +#include "log/logger.hpp" #include "util.h" -#include "bios.h" -#include "slipBio.h" -#include "remoteSigner.h" -#include "sslUtil.h" #include "config.h" -#include "recordHandler.h" #ifdef NO_DAEMON #define DAEMON false @@ -19,12 +21,9 @@ #define DAEMON true #endif -int handlermain( int argc, const char* argv[] ); - extern std::string serialPath; -extern std::vector profiles; -int main( int argc, const char* argv[] ) { +int main( int argc, const char* argv[] ) try { ( void ) argc; ( void ) argv; @@ -37,29 +36,42 @@ int main( int argc, const char* argv[] ) { #endif if( parseConfig( path ) != 0 ) { + logger::fatal( "Could not parse configuration file." ); return -1; } std::shared_ptr ssl_lib = ssl_lib_ref; if( serialPath == "" ) { - std::cout << "Error: no serial device is given" << std::endl; + logger::fatal( "Error: No device for the serial connection was given." ); return -1; } std::shared_ptr conn = openSerial( serialPath ); std::shared_ptr slip1( BIO_new( toBio() ), BIO_free ); - ( ( SlipBIO* )slip1->ptr )->setTarget( std::shared_ptr( new OpensslBIOWrapper( conn ) ) ); + static_cast( slip1->ptr )->setTarget( std::shared_ptr( new OpensslBIOWrapper( conn ) ), true ); - try { - DefaultRecordHandler* dh = new DefaultRecordHandler( std::shared_ptr( new SimpleOpensslSigner( profiles[5] ) ), slip1 ); + DefaultRecordHandler* dh = new DefaultRecordHandler( std::shared_ptr( new SimpleOpensslSigner( ) ), slip1 ); - while( true ) { + logger::note( "Entering mainloop" ); + while( true ) { + try { dh->handle(); + //} catch( const std::exception &ch ) { + //std::cout << "Real exception: " << typeid(ch).name() << ", " << ch.what() << std::endl; + } catch( const std::string& ch ) { + logger::error( "Exception: ", ch ); + } catch( char const* ch ) { + logger::error( "Exception: ", ch ); } - } catch( char const* ch ) { - std::cout << "Exception: " << ch << std::endl; } return -1; + +} catch( std::exception& e ) { + logger::fatalf( "Fatal Error: %s!\n", e.what() ); + return -1; +} catch( ... ) { + logger::fatal( "Fatal Error: Unknown Exception!\n" ); + return -1; }