Official cwtch.im peer and server implementations. https://cwtch.im
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

39 строки
1023B

  1. package main
  2. import (
  3. app2 "cwtch.im/cwtch/app"
  4. "cwtch.im/cwtch/app/utils"
  5. "cwtch.im/cwtch/event"
  6. "git.openprivacy.ca/openprivacy/libricochet-go/connectivity"
  7. "git.openprivacy.ca/openprivacy/libricochet-go/log"
  8. "os"
  9. "path"
  10. )
  11. func main() {
  12. // System Setup, We need Tor and Logging up and Running
  13. log.AddEverythingFromPattern("peer/alice")
  14. log.SetLevel(log.LevelDebug)
  15. acn, err := connectivity.StartTor(path.Join(".", ".cwtch"), "")
  16. if err != nil {
  17. log.Errorf("\nError connecting to Tor: %v\n", err)
  18. os.Exit(1)
  19. }
  20. app := app2.NewApp(acn, ".")
  21. app.CreatePeer("alice", "be gay, do crimes")
  22. alice := utils.WaitGetPeer(app, "alice")
  23. app.LaunchPeers()
  24. eventBus := app.GetEventBus(alice.GetProfile().Onion)
  25. queue := event.NewQueue()
  26. eventBus.Subscribe(event.NewMessageFromPeer, queue)
  27. // For every new Data Packet Alice received she will Print it out.
  28. for {
  29. event := queue.Next()
  30. log.Printf(log.LevelInfo, "Received %v from %v: %s", event.EventType, event.Data["Onion"], event.Data["Data"])
  31. }
  32. }