Go to file
John Brooks 47ba383334 Improve packet-layer buffering and parsing logic
SendRicochetPacket now has error handling, correctly encodes channel
ids, accepts any io.Writer, and ensures that all data is written. All
callers should be changed at some point to handle errors also.

RecvRicochetPackets is refactored to return only one packet per call and
avoid reading more data than it will consume, which simplifies the logic
and fixes a number of problems with short reads or large packets. Also
fixed an error in bounds checking that caused a remote panic for invalid
packet sizes. It also now accepts any io.Reader.

Tests are updated and expanded, and now pass.

Changes to Ricochet.processConnection are whitespace-only, because of
the removal of the inner packets loop.
2016-10-02 17:49:12 -07:00
auth Initial Commit 2015-10-10 21:33:07 -07:00
chat Adding capability to OpenChannel and SendMessage 2015-10-12 16:04:18 -07:00
contact Initial Commit 2015-10-10 21:33:07 -07:00
control Initial Commit 2015-10-10 21:33:07 -07:00
examples/echobot Refactor GoRicochet 2016-07-02 18:52:28 -07:00
utils Improve packet-layer buffering and parsing logic 2016-10-02 17:49:12 -07:00
.gitignore Refactor GoRicochet 2016-07-02 18:52:28 -07:00
.travis.yml Refactor GoRicochet 2016-07-02 18:52:28 -07:00
CONTRIBUTING.md Refactor GoRicochet 2016-07-02 18:52:28 -07:00
LICENSE Refactor GoRicochet 2016-07-02 18:52:28 -07:00
Makefile Refactor GoRicochet 2016-07-02 18:52:28 -07:00
README.md Refactor GoRicochet 2016-07-02 18:52:28 -07:00
authhandler.go Refactor GoRicochet 2016-07-02 18:52:28 -07:00
authhandler_test.go Refactor GoRicochet 2016-07-02 18:52:28 -07:00
logo.png Refactor GoRicochet 2016-07-02 18:52:28 -07:00
messagebuilder.go Refactor GoRicochet 2016-07-02 18:52:28 -07:00
messagebuilder_test.go Refactor GoRicochet 2016-07-02 18:52:28 -07:00
openconnection.go Set OpenConnection.OtherHostname after successful auth proof 2016-10-02 17:49:12 -07:00
openconnection_test.go Refactor GoRicochet 2016-07-02 18:52:28 -07:00
private_key Refactor GoRicochet 2016-07-02 18:52:28 -07:00
ricochet.go Improve packet-layer buffering and parsing logic 2016-10-02 17:49:12 -07:00
ricochetservice.go Add OnDisconnect event 2016-10-02 17:49:12 -07:00
standardricochetservice.go Add OnDisconnect event 2016-10-02 17:49:12 -07:00
standardricochetservice_bad_usage_error_test.go Refactor GoRicochet 2016-07-02 18:52:28 -07:00
standardricochetservice_test.go Refactor GoRicochet 2016-07-02 18:52:28 -07:00
standardricochetservice_unauth_test.go Refactor GoRicochet 2016-07-02 18:52:28 -07:00
standardricochetservice_unknown_contact_test.go Refactor GoRicochet 2016-07-02 18:52:28 -07:00

README.md

GoRicochet Build Status

GoRicochet

GoRicochet is an experimental implementation of the Ricochet Protocol in Go.

Features

  • A simple API that you can use to build Automated Ricochet Applications
  • A suite of regression tests that test protocol compliance.

Building an Automated Ricochet Application

Below is a simple echo bot, which responds to any chat message. You can also find this code under examples/echobot

            package main

            import (
                    "github.com/s-rah/go-ricochet"
                    "log"
            )

            type EchoBotService struct {
                    goricochet.StandardRicochetService
            }

            // Always Accept Contact Requests
            func (ts *EchoBotService) IsKnownContact(hostname string) bool {
                    return true
            }

            func (ts *EchoBotService) OnContactRequest(oc *goricochet.OpenConnection, channelID int32, nick string, message string) {
                    ts.StandardRicochetService.OnContactRequest(oc, channelID, nick, message)
                    oc.AckContactRequestOnResponse(channelID, "Accepted")
                    oc.CloseChannel(channelID)
            }

            func (ebs *EchoBotService) OnChatMessage(oc *goricochet.OpenConnection, channelID int32, messageId int32, message string) {
                    log.Printf("Received Message from %s: %s", oc.OtherHostname, message)
                    oc.AckChatMessage(channelID, messageId)
                    if oc.GetChannelType(6) == "none" {
                            oc.OpenChatChannel(6)
                    }
                    oc.SendMessage(6, message)
            }

            func main() {
                    ricochetService := new(EchoBotService)
                    ricochetService.Init("./private_key")
                    ricochetService.Listen(ricochetService, 12345)
            }

Each automated ricochet service can extend of the StandardRicochetService. From there certain functions can be extended to fully build out a complete application.

Currently GoRicochet does not establish a hidden service, so to make this service available to the world you will have to set up a hidden service

Security and Usage Note

This project is experimental and has not been independently reviewed. If you are looking for a quick and easy way to use ricochet please check out Ricochet Protocol.