public key bug
This commit is contained in:
parent
2a8349b0c7
commit
cc91341547
6
main.go
6
main.go
@ -67,14 +67,16 @@ func generateSelfPeer() error {
|
|||||||
}
|
}
|
||||||
// check if peer already exists
|
// check if peer already exists
|
||||||
p := oclib.Search(nil, strconv.Itoa(peer.SELF.EnumIndex()), oclib.LibDataEnum(oclib.PEER))
|
p := oclib.Search(nil, strconv.Itoa(peer.SELF.EnumIndex()), oclib.LibDataEnum(oclib.PEER))
|
||||||
|
file := ""
|
||||||
if len(p.Data) > 0 {
|
if len(p.Data) > 0 {
|
||||||
// check public key with the one in the database
|
// check public key with the one in the database
|
||||||
f, err := os.ReadFile(conf.GetConfig().PublicKeyPath)
|
f, err := os.ReadFile(conf.GetConfig().PublicKeyPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
file = string(f)
|
||||||
// compare the public key from file with the one in the database
|
// 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 errors.New("public key is different from the one in the database")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@ -86,7 +88,7 @@ func generateSelfPeer() error {
|
|||||||
AbstractObject: utils.AbstractObject{
|
AbstractObject: utils.AbstractObject{
|
||||||
Name: o.GetStringDefault("NAME", "local"),
|
Name: o.GetStringDefault("NAME", "local"),
|
||||||
},
|
},
|
||||||
PublicKey: conf.GetConfig().PublicKeyPath,
|
PublicKey: file,
|
||||||
State: peer.SELF,
|
State: peer.SELF,
|
||||||
}
|
}
|
||||||
data := oclib.StoreOne(oclib.LibDataEnum(oclib.PEER), peer.Serialize())
|
data := oclib.StoreOne(oclib.LibDataEnum(oclib.PEER), peer.Serialize())
|
||||||
|
Loading…
Reference in New Issue
Block a user