|
|
|
@ -1,11 +1,11 @@
|
|
|
|
|
package testing
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"cwtch.im/cwtch/model"
|
|
|
|
|
"cwtch.im/cwtch/peer"
|
|
|
|
|
"cwtch.im/cwtch/protocol"
|
|
|
|
|
cwtchserver "cwtch.im/cwtch/server"
|
|
|
|
|
"fmt"
|
|
|
|
|
"git.mascherari.press/cwtch/model"
|
|
|
|
|
"git.mascherari.press/cwtch/peer"
|
|
|
|
|
"git.mascherari.press/cwtch/protocol"
|
|
|
|
|
cwtchserver "git.mascherari.press/cwtch/server"
|
|
|
|
|
"github.com/golang/protobuf/proto"
|
|
|
|
|
"github.com/s-rah/go-ricochet"
|
|
|
|
|
"github.com/s-rah/go-ricochet/utils"
|
|
|
|
@ -28,11 +28,11 @@ var (
|
|
|
|
|
func checkAndGenPrivateKey(privateKeyFile string) (generated bool) {
|
|
|
|
|
if _, err := os.Stat(privateKeyFile); os.IsNotExist(err) {
|
|
|
|
|
fmt.Println("generating new private key...")
|
|
|
|
|
pk, pk_err := utils.GeneratePrivateKey()
|
|
|
|
|
if pk_err != nil {
|
|
|
|
|
pk, err := utils.GeneratePrivateKey()
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Fatalf("error generating new private key: %v\n", err)
|
|
|
|
|
}
|
|
|
|
|
err := ioutil.WriteFile(privateKeyFile, []byte(utils.PrivateKeyToString(pk)), 0400)
|
|
|
|
|
err = ioutil.WriteFile(privateKeyFile, []byte(utils.PrivateKeyToString(pk)), 0400)
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Fatalf("error writing new private key to file %s: %v\n", privateKeyFile, err)
|
|
|
|
|
}
|
|
|
|
|