diff --git a/goRicochetMobile.go b/goRicochetMobile.go index fb663cd..8710a50 100644 --- a/goRicochetMobile.go +++ b/goRicochetMobile.go @@ -8,6 +8,13 @@ import ( "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 +37,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 +// +// 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 ******/ diff --git a/goRicochetMobile_test.go b/goRicochetMobile_test.go new file mode 100644 index 0000000..db94b24 --- /dev/null +++ b/goRicochetMobile_test.go @@ -0,0 +1,7 @@ +package goRicochetMobile + +import "testing" + +func TestStartBackend(t *testing.T) { + StartBackend() +}