X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;f=src%2Fio%2FrecordHandler.cpp;h=f8c2185f395bdcba617e32d5e5410af74947549f;hb=e0713d1539887566e0ea7d85942c305ec727c9dd;hp=2d58be0b7d1e195e62350ebaadd4cc9191074b4f;hpb=eac5817fe5ed5052599bbfb1ab3f6ade426010d0;p=cassiopeia.git diff --git a/src/io/recordHandler.cpp b/src/io/recordHandler.cpp index 2d58be0..f8c2185 100644 --- a/src/io/recordHandler.cpp +++ b/src/io/recordHandler.cpp @@ -67,30 +67,23 @@ public: rh.command = static_cast( res ); rh.flags = 0; rh.command_count = 0; // TODO i++ - rh.totalLength = payload.size(); sendCommand( rh, payload, io ); } void work() { - std::string content = io->readLine(); - try { RecordHeader head; - std::string payload = parseCommand( head, content ); - execute( head, payload ); - } catch( const char* msg ) { - logger::error( "ERROR: ", msg ); + std::string all = parseCommandChunked( head, io ); + execute( static_cast( head.command ), all ); + } catch( const std::exception& msg ) { + logger::error( "ERROR: ", msg.what() ); parent->reset(); return; } } - void execute( RecordHeader& head, std::string data ) { - if( head.totalLength != head.payloadLength || head.offset != 0 ) { - throw "Error, chunking not supported yet"; - } - - switch( static_cast( head.command )) { + void execute( RecordHeader::SignerCommand command, std::string data ) { + switch( command ) { case RecordHeader::SignerCommand::SET_CSR: tbs->csr_content = data; tbs->csr_type = "CSR"; @@ -214,7 +207,7 @@ public: break; default: - throw "Unimplemented"; + throw std::runtime_error("Unimplemented"); } } }; @@ -235,7 +228,7 @@ void DefaultRecordHandler::handle() { } try { currentSession->work(); - } catch( EOFException e ){ + } catch( eof_exception e ){ reset(); } }