cwtch/app/peer/bob/bob.go

40 lines
1.0 KiB
Go
Raw Normal View History

2018-10-04 19:15:03 +00:00
package main
import (
app2 "cwtch.im/cwtch/app"
"cwtch.im/cwtch/app/utils"
"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)
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)
}
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)
}