Compare commits
1 Commits
master
...
identity-c
Author | SHA1 | Date |
---|---|---|
Dan Ballard | cf200dcfe4 |
|
@ -37,6 +37,7 @@ func CreateIdentity(core *Ricochet) (*Identity, error) {
|
||||||
log.Printf("Failed loading identity: %v", err)
|
log.Printf("Failed loading identity: %v", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
log.Println("me: ", me)
|
||||||
|
|
||||||
contactList, err := LoadContactList(core)
|
contactList, err := LoadContactList(core)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -46,6 +47,7 @@ func CreateIdentity(core *Ricochet) (*Identity, error) {
|
||||||
me.contactList = contactList
|
me.contactList = contactList
|
||||||
|
|
||||||
contactList.StartConnections()
|
contactList.StartConnections()
|
||||||
|
log.Println("me: ", me)
|
||||||
go me.publishService(me.privateKey)
|
go me.publishService(me.privateKey)
|
||||||
return me, nil
|
return me, nil
|
||||||
}
|
}
|
||||||
|
@ -53,22 +55,27 @@ func CreateIdentity(core *Ricochet) (*Identity, error) {
|
||||||
func (me *Identity) loadIdentity() error {
|
func (me *Identity) loadIdentity() error {
|
||||||
config := me.core.Config.Read()
|
config := me.core.Config.Read()
|
||||||
|
|
||||||
if keyData := config.Secrets.GetServicePrivateKey(); keyData != nil {
|
keyData := config.Secrets.GetServicePrivateKey();
|
||||||
var err error
|
|
||||||
me.privateKey, _, err = pkcs1.DecodePrivateKeyDER(keyData)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
me.address, err = AddressFromKey(&me.privateKey.PublicKey)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Printf("Loaded identity %s", me.address)
|
if keyData != nil {
|
||||||
} else {
|
|
||||||
log.Printf("Initializing new identity")
|
log.Printf("Initializing new identity")
|
||||||
|
|
||||||
|
privateKey, err := utils.GeneratePrivateKey()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var err error
|
||||||
|
me.privateKey, _, err = pkcs1.DecodePrivateKeyDER(keyData)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
me.address, err = AddressFromKey(&me.privateKey.PublicKey)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Printf("Loaded identity %s", me.address)
|
||||||
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,6 +112,7 @@ func (me *Identity) setPrivateKey(key *rsa.PrivateKey) error {
|
||||||
|
|
||||||
// BUG(special): No error handling for failures under publishService
|
// BUG(special): No error handling for failures under publishService
|
||||||
func (me *Identity) publishService(key *rsa.PrivateKey) {
|
func (me *Identity) publishService(key *rsa.PrivateKey) {
|
||||||
|
log.Println("publishService(", key, ")")
|
||||||
// This call will block until a control connection is available and the
|
// This call will block until a control connection is available and the
|
||||||
// ADD_ONION command has returned. After creating the listener, it will
|
// ADD_ONION command has returned. After creating the listener, it will
|
||||||
// be automatically re-published if the control connection is lost and
|
// be automatically re-published if the control connection is lost and
|
||||||
|
|
Loading…
Reference in New Issue