2018-10-04 19:15:03 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2019-06-21 21:50:43 +00:00
|
|
|
app2 "cwtch.im/cwtch/app"
|
|
|
|
"cwtch.im/cwtch/app/utils"
|
2020-02-10 22:09:24 +00:00
|
|
|
"git.openprivacy.ca/openprivacy/connectivity/tor"
|
|
|
|
"git.openprivacy.ca/openprivacy/log"
|
2019-01-04 21:44:21 +00:00
|
|
|
"os"
|
|
|
|
"path"
|
2018-10-04 19:15:03 +00:00
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2019-01-04 21:44:21 +00:00
|
|
|
|
|
|
|
// System Boilerplate, We need Tor Up and Running
|
2018-12-04 02:52:11 +00:00
|
|
|
log.AddEverythingFromPattern("peer/bob")
|
2019-01-04 21:44:21 +00:00
|
|
|
log.SetLevel(log.LevelDebug)
|
2020-02-10 22:09:24 +00:00
|
|
|
acn, err := tor.NewTorACN(path.Join(".", ".cwtch"), "")
|
2019-01-04 21:44:21 +00:00
|
|
|
if err != nil {
|
|
|
|
log.Errorf("\nError connecting to Tor: %v\n", err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
|
2019-06-21 21:50:43 +00:00
|
|
|
app := app2.NewApp(acn, ".")
|
|
|
|
app.CreatePeer("bob", "be gay, do crimes")
|
|
|
|
bob := utils.WaitGetPeer(app, "bob")
|
2018-10-04 19:15:03 +00:00
|
|
|
|
2019-01-04 21:44:21 +00:00
|
|
|
// Add Alice's Onion Here (It changes run to run)
|
|
|
|
bob.PeerWithOnion("upiztu7myymjf2dn4x4czhagp7axlnqjvf5zwfegbhtpkqb6v3vgu5yd")
|
2018-10-04 19:15:03 +00:00
|
|
|
|
2019-01-04 21:44:21 +00:00
|
|
|
// Send the Message...
|
2018-12-04 02:52:11 +00:00
|
|
|
log.Infof("Waiting for Bob to Connect to Alice...")
|
2019-01-04 21:44:21 +00:00
|
|
|
bob.SendMessageToPeer("upiztu7myymjf2dn4x4czhagp7axlnqjvf5zwfegbhtpkqb6v3vgu5yd", "Hello Alice!!!")
|
2018-10-04 19:15:03 +00:00
|
|
|
|
|
|
|
// Wait a while...
|
2019-01-04 21:44:21 +00:00
|
|
|
// Everything is run in a goroutine so the main thread has to stay active
|
2018-10-04 19:15:03 +00:00
|
|
|
time.Sleep(time.Second * 100)
|
|
|
|
|
|
|
|
}
|