diff --git a/Projs/PD2/internal/client/client.go b/Projs/PD2/internal/client/client.go index f41e223..49a386c 100644 --- a/Projs/PD2/internal/client/client.go +++ b/Projs/PD2/internal/client/client.go @@ -32,7 +32,7 @@ func Run() { switch command { case "send": if flag.NArg() != 3 { - printError("MSG SERVICE: command error!") + printError("MSG SERVICE: command error!") showHelp() os.Exit(1) } @@ -46,7 +46,7 @@ func Run() { case "askqueue": if flag.NArg() > 3 { - printError("MSG SERVICE: command error!") + printError("MSG SERVICE: command error!") showHelp() os.Exit(1) } @@ -72,7 +72,7 @@ func Run() { case "getmsg": if flag.NArg() < 2 { - printError("MSG SERVICE: command error!") + printError("MSG SERVICE: command error!") showHelp() os.Exit(1) } @@ -83,14 +83,14 @@ func Run() { } err = getMsgCommand(clientKeyStore, num) if err != nil { - printError(err.Error()) + printError(err.Error()) } case "help": showHelp() default: - printError("MSG SERVICE: command error!") + printError("MSG SERVICE: command error!") showHelp() } @@ -107,6 +107,7 @@ func sendCommand(clientKeyStore cryptoUtils.KeyStore, plainSubject, plainBody, u return err } + // FIX: adapt to api cl, err := networking.NewClient[protocol.Packet](&clientKeyStore) if err != nil { return err @@ -117,14 +118,17 @@ func sendCommand(clientKeyStore cryptoUtils.KeyStore, plainSubject, plainBody, u if err != nil { return err } - subject, err := clientKeyStore.EncryptMessageContent(receiverCert, plainSubjectBytes) + // NOTE: this will stay the same + subject, err := clientKeyStore.EncryptMessageContent(receiverCert, uid, plainSubjectBytes) if err != nil { return err } - body, err := clientKeyStore.EncryptMessageContent(receiverCert, plainBodyBytes) + body, err := clientKeyStore.EncryptMessageContent(receiverCert, uid, plainBodyBytes) if err != nil { return err } + + // FIX: adapt to api sendMsgPacket := protocol.NewSendMsgPacket(uid, subject, body) if err := cl.Connection.Send(sendMsgPacket); err != nil { return err