Compare commits

...

2 Commits

2 changed files with 44 additions and 3 deletions

View File

@ -1,13 +1,18 @@
package goRicochetMobile
import (
"github.com/s-rah/go-ricochet/application"
"github.com/s-rah/go-ricochet/utils"
"log"
"net/http"
"time"
"github.com/yawning/bulb/utils/pkcs1"
"crypto/rsa"
"github.com/ricochet-im/ricochet-go/core/config"
"os"
ricochet "github.com/ricochet-im/ricochet-go/core"
)
var (
CONFIG_PATH string = "identity.json"
)
@ -30,6 +35,33 @@ func GetOnionAddress(privateKey string) string {
return addr
}
/*************** ricochet-go *****************/
// https://stackoverflow.com/questions/33815541/golang-gomobile-app-cannot-generate-files
// Writing and reading from files should apparently work if
// <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
// is in the manifest and gomobile build is using hte manifest
func StartBackend() error {
cfg, err := config.LoadConfigFile(CONFIG_PATH)
if err != nil && os.IsNotExist(err) {
cfg, err = config.NewConfigFile(CONFIG_PATH)
}
if err != nil {
return err
}
log.Println(cfg)
core := new(ricochet.Ricochet)
if err := core.Init(cfg); err != nil {
return err
}
log.Println("tor address: ", core.Config.Read().Identity)
return nil
}
/******** Testing by standing up an echobot ******/
@ -42,6 +74,8 @@ func TestNet() (ok bool, ex error) {
return true, nil
}
// TODO: update EchoBot test
/*
func EchoBot(privateKeyData string) {
privateKey, err := utils.ParsePrivateKey([]byte(privateKeyData))
if err != nil {
@ -63,4 +97,4 @@ func EchoBot(privateKeyData string) {
})
log.Printf("echobot started on %s", l.Addr().String())
echobot.Run(l)
}
}*/

7
goRicochetMobile_test.go Normal file
View File

@ -0,0 +1,7 @@
package goRicochetMobile
import "testing"
func TestStartBackend(t *testing.T) {
StartBackend()
}