forked from cwtch.im/cwtch
autogen private_key in unavailable
This commit is contained in:
parent
f1d0a8e900
commit
a1f0ee7b9f
|
@ -10,7 +10,8 @@ import (
|
|||
"github.com/s-rah/go-ricochet/channels"
|
||||
"github.com/s-rah/go-ricochet/utils"
|
||||
"log"
|
||||
//"time"
|
||||
|
||||
"io/ioutil"
|
||||
)
|
||||
|
||||
type Server struct {
|
||||
|
@ -21,7 +22,14 @@ func (s *Server) Run(privateKeyFile string) {
|
|||
pk, err := utils.LoadPrivateKeyFromFile(privateKeyFile)
|
||||
|
||||
if err != nil {
|
||||
log.Fatalf("error reading private key file: %v", err)
|
||||
log.Printf("no private key found!")
|
||||
log.Printf("generating new private key...")
|
||||
var pk_err error = nil
|
||||
pk, pk_err = utils.GeneratePrivateKey()
|
||||
if pk_err != nil {
|
||||
log.Fatalf("error generating new private key: %v", err)
|
||||
}
|
||||
ioutil.WriteFile(privateKeyFile, []byte(utils.PrivateKeyToString(pk)), 0400)
|
||||
}
|
||||
|
||||
l, err := application.SetupOnion("127.0.0.1:9051", "tcp4", "", pk, 9878)
|
||||
|
|
Loading…
Reference in New Issue