From cc91341547566c1df3983da7dde5592b470ac02c Mon Sep 17 00:00:00 2001 From: mr Date: Mon, 18 Nov 2024 14:58:26 +0100 Subject: [PATCH] public key bug --- main.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index e68762a..af906b0 100644 --- a/main.go +++ b/main.go @@ -67,14 +67,16 @@ func generateSelfPeer() error { } // check if peer already exists p := oclib.Search(nil, strconv.Itoa(peer.SELF.EnumIndex()), oclib.LibDataEnum(oclib.PEER)) + file := "" if len(p.Data) > 0 { // check public key with the one in the database f, err := os.ReadFile(conf.GetConfig().PublicKeyPath) if err != nil { return err } + file = string(f) // compare the public key from file with the one in the database - if !strings.Contains(string(f), p.Data[0].(*peer.Peer).PublicKey) { + if !strings.Contains(file, p.Data[0].(*peer.Peer).PublicKey) { return errors.New("public key is different from the one in the database") } return nil @@ -86,7 +88,7 @@ func generateSelfPeer() error { AbstractObject: utils.AbstractObject{ Name: o.GetStringDefault("NAME", "local"), }, - PublicKey: conf.GetConfig().PublicKeyPath, + PublicKey: file, State: peer.SELF, } data := oclib.StoreOne(oclib.LibDataEnum(oclib.PEER), peer.Serialize())