Commit Graph

23 Commits

Author SHA1 Message Date
Sarah Jamie Lewis 5d767174b1 Brand new API v0.2 2017-05-02 16:33:51 -07:00
John Brooks 860ae9a024 Rework the API around connection events
This is a rework of some parts of the API to make connection management
for applications more sane and reliable.

- The RicochetService interface is split into the ServiceHandler and
  ConnectionHandler interfaces. ServiceHandler is implemented by the
  application to handle inbound connections to a listener.
  ConnectionHandler is implemented to handle events for a single
  OpenConnection. Handler instances should no longer be shared for
  different listeners or connections.

- Instead of automatically starting a processConnection goroutine, the
  application is now responsible for calling OpenConnection.Process in a
  goroutine to act on the connection. This function blocks until the
  connection is closed. This change allows a better application pattern
  for setting the handler of a connection and reacting to connection
  loss.

- It is no longer necessary to have started a listener in order to make
  outbound connections.

- The Ricochet type is removed, because it no longer served any purpose,
  and this avoids having any shared state between different listeners or
  connections.
2016-12-03 16:53:13 -08:00
Sarah Jamie Lewis 9d6592e1e4 Fixing up some comments 2016-11-08 15:05:05 -08:00
Wladimir J. van der Laan c16dce9f60 Make it possible to request stop of message loop
Add a `RequestStopMessageLoop()` method to `Ricochet` to be able to
stop handling new connections. Right now, ProcessMessages is an infinite
loop.
2016-11-03 17:30:38 +01:00
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
John Brooks cc50e0dfe9 Fix buffering in version negotiation
The service-side version negotiation had a buffer overread that would
cause remotely triggerable panic.

Refactor that code to resolve that issue, follow the spec more exactly,
and avoid reading more data from the socket than is used for version
negotiation, in case clients write optimistically.
2016-10-02 17:49:12 -07:00
John Brooks 1c317fc186 Add OnDisconnect event 2016-10-02 17:49:12 -07:00
John Brooks f6d6991f46 Add methods to run protocol over external sockets & listeners
The ServeListener and ConnectOpen methods take an active Listener or
Conn respectively, instead of creating their own.
2016-10-02 17:49:12 -07:00
Sarah Jamie Lewis bfe5b74364 Refactor GoRicochet
* New Service Interface
* Server functionality
* 90% Code Coverage
* Regression Testing of Protocol Compliance
2016-07-02 18:52:28 -07:00
Sarah Jamie Lewis 93754f2916 Refactor to a move event-driven library - incomplete 2016-02-28 16:18:25 -08:00
Sarah Jamie Lewis a411fb8695 More consistent interfaces, better test coverage 2016-02-27 19:24:50 -08:00
Sarah Jamie Lewis 2353fc41e2 Refactor of APIs to make testing easier.
Also travis.ci integration
2016-02-27 16:20:40 -08:00
Sarah Jamie Lewis 91036c918d Fixing up some error handling 2016-01-05 20:42:49 -08:00
Sarah Jamie Lewis 04f99b298f Cleaning up error handling
Getting rid of lots of FATALs, now they can be handled by the calling
function.
2016-01-04 19:53:10 -08:00
Sarah Jamie Lewis 97f5982754 Adding ability to check contact is known 2016-01-03 15:33:10 -08:00
Sarah Jamie Lewis f684fd8694 Fleshing out error cases 2016-01-02 00:47:32 -08:00
Sarah Jamie Lewis 3469935bcb Adding examples 2016-01-01 18:08:28 -08:00
Sarah Jamie Lewis 64d08bdff0 Refactoring to more easily adapt to multiple channels
Also adding chat message support.
2016-01-01 17:44:14 -08:00
Sarah Jamie Lewis 2d93acf065 Add the ability to turn on/off debug logging 2015-10-15 23:27:16 -07:00
Sarah Jamie Lewis 4ff30ee723 Removing Panics 2015-10-15 23:16:37 -07:00
Sarah Jamie Lewis 42f64e94df Adding Hidden Service Resolution
New option to use either hidden service address or localhost
address for who to connect to.
2015-10-15 23:12:12 -07:00
Sarah Jamie Lewis 38bb90b6b5 Adding capability to OpenChannel and SendMessage 2015-10-12 16:04:18 -07:00
Sarah Jamie Lewis dba6ae8097 Initial Commit
This commit provides connection, authentication and the
start of contact requests.
2015-10-10 21:33:07 -07:00