mirror of
https://github.com/gravitl/netmaker.git
synced 2024-11-10 17:48:25 +08:00
addresses review comments
This commit is contained in:
parent
95b9444325
commit
ad79f2ea1f
5 changed files with 4 additions and 77 deletions
|
@ -41,7 +41,7 @@ const PEERS_TABLE_NAME = "peers"
|
|||
// SERVERCONF_TABLE_NAME - stores server conf
|
||||
const SERVERCONF_TABLE_NAME = "serverconf"
|
||||
|
||||
// SERVER_UUID_TABLE_NAME - stores
|
||||
// SERVER_UUID_TABLE_NAME - stores unique netmaker server data
|
||||
const SERVER_UUID_TABLE_NAME = "serveruuid"
|
||||
|
||||
// SERVER_UUID_RECORD_KEY - telemetry thing
|
||||
|
|
|
@ -60,8 +60,8 @@ func GetSortedNetworkServerNodes(network string) ([]models.Node, error) {
|
|||
|
||||
// GetServerNodes - gets the server nodes of a network
|
||||
func GetServerNodes(network string) []models.Node {
|
||||
var nodes, err = GetNetworkNodes(network)
|
||||
var serverNodes = make([]models.Node, 0)
|
||||
var nodes, err = GetNetworkNodes(network)
|
||||
if err != nil {
|
||||
return serverNodes
|
||||
}
|
||||
|
|
|
@ -167,6 +167,7 @@ type ServerUpdateData struct {
|
|||
}
|
||||
|
||||
// Telemetry - contains UUID of the server and timestamp of last send to posthog
|
||||
// also contains assymetrical encryption pub/priv keys for any server traffic
|
||||
type Telemetry struct {
|
||||
UUID string `json:"uuid" bson:"uuid"`
|
||||
LastSend int64 `json:"lastsend" bson:"lastsend"`
|
||||
|
|
|
@ -594,77 +594,3 @@ func BoxDecrypt(encrypted []byte, senderPublicKey *[32]byte, recipientPrivateKey
|
|||
}
|
||||
return decrypted, nil
|
||||
}
|
||||
|
||||
// DestructMessage - reconstruct original message through chunks
|
||||
// func DestructMessage(builtMsg string, priv *rsa.PrivateKey) []byte {
|
||||
// var chunks = strings.Split(builtMsg, splitKey)
|
||||
// var totalMessage = make([]byte, len(builtMsg))
|
||||
// for _, chunk := range chunks {
|
||||
// var bytes = decryptWithPrivateKey([]byte(chunk), priv)
|
||||
// if bytes == nil {
|
||||
// return nil
|
||||
// }
|
||||
// totalMessage = append(totalMessage, bytes...)
|
||||
// }
|
||||
// return totalMessage
|
||||
// }
|
||||
|
||||
// // BuildMessage Build a message for publishing
|
||||
// func BuildMessage(originalMessage []byte, pub *rsa.PublicKey) string {
|
||||
// chunks := getSliceChunks(originalMessage, 228)
|
||||
// var message = ""
|
||||
// for i := 0; i < len(chunks); i++ {
|
||||
// var encryptedText, encryptErr = encryptWithPublicKey(chunks[i], pub)
|
||||
// if encryptErr != nil {
|
||||
// fmt.Printf("encrypt err: %v \n", encryptErr)
|
||||
// return ""
|
||||
// }
|
||||
|
||||
// message += string(encryptedText)
|
||||
// if i < len(chunks)-1 {
|
||||
// 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 {
|
||||
// lastByte := i + chunkSize
|
||||
|
||||
// if lastByte > len(slice) {
|
||||
// lastByte = len(slice)
|
||||
// }
|
||||
|
||||
// chunks = append(chunks, slice[i:lastByte])
|
||||
// }
|
||||
|
||||
// return chunks
|
||||
// }
|
||||
|
||||
// // encryptWithPublicKey encrypts data with public key
|
||||
// func encryptWithPublicKey(msg []byte, pub *rsa.PublicKey) ([]byte, error) {
|
||||
// if pub == nil {
|
||||
// return nil, errors.New("invalid public key when decrypting")
|
||||
// }
|
||||
// hash := sha512.New()
|
||||
// ciphertext, err := rsa.EncryptOAEP(hash, crand.Reader, pub, msg, []byte(""))
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
|
||||
// return ciphertext, nil
|
||||
// }
|
||||
|
||||
// // decryptWithPrivateKey decrypts data with private key
|
||||
// func decryptWithPrivateKey(ciphertext []byte, priv *rsa.PrivateKey) []byte {
|
||||
// hash := sha512.New()
|
||||
// plaintext, err := rsa.DecryptOAEP(hash, crand.Reader, priv, ciphertext, []byte(""))
|
||||
// if err != nil {
|
||||
// return nil
|
||||
// }
|
||||
// return plaintext
|
||||
// }
|
||||
|
|
|
@ -15,7 +15,7 @@ import (
|
|||
|
||||
const netmakerProcessName = "netmaker"
|
||||
|
||||
// InitServerNetclient - intializes the server netclient
|
||||
// InitIPTables - intializes the server iptables
|
||||
func InitIPTables() error {
|
||||
_, err := exec.LookPath("iptables")
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue