From c40c905b3b67a0dba1b6451005cbda8600ec03ae Mon Sep 17 00:00:00 2001 From: 0xdcarns Date: Sat, 29 Jan 2022 09:01:33 -0500 Subject: [PATCH] edited chunk size --- database/database.go | 1 - logic/nodes.go | 2 +- netclient/ncutils/netclientutils.go | 8 +++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/database/database.go b/database/database.go index 5e391384..dd9435ab 100644 --- a/database/database.go +++ b/database/database.go @@ -148,7 +148,6 @@ func Insert(key string, value string, tableName string) error { if key != "" && value != "" && IsJSONString(value) { return getCurrentDB()[INSERT].(func(string, string, string) error)(key, value, tableName) } else { - logger.Log(0, "invalid json detected!!") return errors.New("invalid insert " + key + " : " + value) } } diff --git a/logic/nodes.go b/logic/nodes.go index f7c9330f..20ea54c3 100644 --- a/logic/nodes.go +++ b/logic/nodes.go @@ -233,7 +233,7 @@ func CreateNode(node *models.Node) error { if err != nil { return err } - logger.Log(0, "INSERTING: ", node.ID, fmt.Sprintf("pubkey? %v", node.TrafficKeys.Server)) + logger.Log(0, "INSERTING: ", node.ID, fmt.Sprintf("pubkey? %v", node.TrafficKeys)) err = database.Insert(node.ID, string(nodebytes), database.NODES_TABLE_NAME) if err != nil { return err diff --git a/netclient/ncutils/netclientutils.go b/netclient/ncutils/netclientutils.go index 143fed75..6bdab3cc 100644 --- a/netclient/ncutils/netclientutils.go +++ b/netclient/ncutils/netclientutils.go @@ -552,7 +552,7 @@ func ServerAddrSliceContains(slice []models.ServerAddr, item models.ServerAddr) // DestructMessage - reconstruct original message through chunks func DestructMessage(builtMsg string, priv *rsa.PrivateKey) []byte { - var chunks = strings.Split(builtMsg, ",") + var chunks = strings.Split(builtMsg, splitKey) var totalMessage = make([]byte, len(builtMsg)) for _, chunk := range chunks { var bytes = decryptWithPrivateKey([]byte(chunk), priv) @@ -566,7 +566,7 @@ func DestructMessage(builtMsg string, priv *rsa.PrivateKey) []byte { // BuildMessage Build a message for publishing func BuildMessage(originalMessage []byte, pub *rsa.PublicKey) string { - chunks := getSliceChunks(originalMessage, 2048) + chunks := getSliceChunks(originalMessage, 1024) var message = "" for i := 0; i < len(chunks); i++ { var encryptedText, encryptErr = encryptWithPublicKey(chunks[i], pub) @@ -577,12 +577,14 @@ func BuildMessage(originalMessage []byte, pub *rsa.PublicKey) string { message += string(encryptedText) if i < len(chunks)-1 { - message += "," + message += splitKey } } return message } +var splitKey = "|o|" + func getSliceChunks(slice []byte, chunkSize int) [][]byte { var chunks [][]byte for i := 0; i < len(slice); i += chunkSize {