mirror of
https://github.com/gravitl/netmaker.git
synced 2024-09-20 23:36:18 +08:00
edited chunk size
This commit is contained in:
parent
7c29f2454e
commit
c40c905b3b
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue