Commit Graph

49 Commits

Author SHA1 Message Date
Brian Warner
c482c248ff server: add "watch" endpoint, deprecate non-ES "get"
I'm planning to leave non-EventSource "/get" in until after 0.6.0, then
remove it. I think it's cleaner for the logs to have the two
forms (EventSource and immediate) use different URLs.
2015-11-23 16:43:25 -08:00
Brian Warner
47d3eee6fe server: treat missing moods (from older clients) as "quiet" 2015-11-15 10:34:40 -08:00
Brian Warner
4f0dde9529 server: summarize transfers, store in DB 2015-11-15 10:34:29 -08:00
Brian Warner
26c7008c23 DB: use 'messages' to track allocations, not 'allocations'
This removes the 'allocations' table entirely, and cleans up the way we
prune old messages. This should make it easier to summarize each
connection (for usage stats) when it gets deallocated, as well as making
pruning more reliable.
2015-11-13 18:24:36 -08:00
Brian Warner
bb97729a23 server: more refactoring
flattening some attribute access paths
2015-11-13 18:20:47 -08:00
Brian Warner
0b9f858761 server: internal refactoring 2015-11-13 18:12:47 -08:00
Brian Warner
b83062701d server: give old 0.4.0 senders a "you must upgrade" error
Without this, old senders will throw a messy 404 traceback when talking
to a modern server.

Unfortunately 0.4.0 receivers don't make API calls in the right order,
so they throw a 404 before seeing our "you need to upgrade" message.
2015-11-11 17:06:33 -08:00
Brian Warner
df3aee2a86 fix EventSource (server and parsers)
I was really confused about the Server-Sent Events syntax. This new one
is compatible with actual web browsers and the spec:

 http://www.w3.org/TR/eventsource/
2015-10-07 16:31:45 -07:00
Brian Warner
574d5f2314 scope channelids to the appid, change API and DB schema
This requires a DB delete/recreate when upgrading. It changes the server
protocol, and app IDs, so clients cannot interoperate with each other
across this change, nor with the server. Flag day for everyone!

Now apps do not share channel IDs, so a lot of usage of app1 will not
cause the wormhole codes for app2 to get longer.
2015-10-06 19:21:53 -07:00
Brian Warner
fc30fa6cd4 rename channel-id to channelid. changes DB schema. 2015-10-06 19:12:41 -07:00
Brian Warner
2da94d5069 move channel-pruning responsibility down into Relay 2015-10-04 15:49:06 -07:00
Brian Warner
b2336591a7 relay.py: rename to relay_server.py 2015-10-04 12:46:09 -07:00
Brian Warner
0fa0abfbb1 server: split into separate files 2015-10-04 12:40:12 -07:00
Brian Warner
617bb03ad5 rewrite server API
This removes "side" and "msgnum" from the URLs, and puts them in a JSON
request body instead. The server now maintains a simple set of messages
for each channel-id, and isn't responsible for removing duplicates.

The client now fetches all messages, and just ignores everything it sent
itself. This removes the "reflection attack".

Deallocate now returns JSON, for consistency. DB and API use "phase" and
"body" instead of msgnum/message.

This changes the DB schema, so delete the DB before upgrading the server.
2015-10-03 17:38:31 -07:00
Brian Warner
b088747ae3 rename to ServerEndpointService, for consistency with Twisted 2015-09-28 16:23:00 -07:00
Brian Warner
540fceb795 add py3.4 compatibility
The "bytes % bytes" syntax only appeared on py3.5, so don't use it.

Updated travis to expect py3.4 works.

The twisted side is probably even more broken for py3.4 than it is for
py3.5.
2015-09-28 16:15:55 -07:00
Brian Warner
6614783c43 make relay work under py3
Current twisted.web wants bytes in most places (this will probably
change when twisted.web is properly ported to py3).
2015-09-28 00:24:00 -07:00
Brian Warner
e8626fcea2 relay: deliver EventSource as utf-8
This allows the client (requests.py) to produce unicode fields and
lines, instead of binary, which is necessary for py3 compatibility.
2015-09-27 14:35:10 -07:00
Brian Warner
2b37c62150 server: add -n/--no-daemon, to run on py3
The twisted.python.logfile in Twisted-15.4.0 is not yet compatible with
py3, but can be bypassed by not daemonizing the server (so it doesn't
write to a logfile). This has been fixed in twisted trunk, so when
15.4.1 or 15.5.0 comes out, this will no longer be needed. But I think
we'll leave it in place, since sometimes it's handy to run a server
without daemonization.
2015-09-27 14:24:03 -07:00
Brian Warner
be124e686a relay: avoid using Twisted strports
strports aren't ported to py3 yet, so we stick with Endpoints and
Services, which have been.
2015-09-26 18:15:35 -07:00
Brian Warner
4c4b5d081b RelayServer: use in-memory DB for tests
This avoids problems where a leftover DB from one run causes "wrong
code" errors in the next.
2015-09-26 17:44:20 -07:00
Brian Warner
894da44244 relay: make it possible to omit the Transit server 2015-06-21 21:08:21 -07:00
Brian Warner
d7415b7053 minor expiration cleanups 2015-05-04 18:28:54 -07:00
Brian Warner
183303e11e rework expiration, prune after 3 days, check every 2 hours 2015-05-04 18:28:04 -07:00
Brian Warner
dc3f2eee43 server: build ChannelList from db, not self.channels 2015-05-04 18:25:52 -07:00
Brian Warner
1aab908091 allocate_channel_id: use DB to get list of previous allocations 2015-05-04 18:24:23 -07:00
Brian Warner
a03fb3900e relay: track allocations through DB 2015-05-04 18:24:23 -07:00
Brian Warner
043392ee2a relay: add database, not used yet 2015-05-04 18:24:23 -07:00
Brian Warner
c3b048a4d3 relay: remove/disable unused code, hush pyflakes 2015-04-20 18:34:45 -07:00
Brian Warner
c393e09e8a server: add --advertise-version option 2015-04-20 18:34:13 -07:00
Brian Warner
790ae9a0dc change channel-allocation web API (incompatibly)
This will make it easier to manage channel allocation later, when we
switch to a database.
2015-04-10 22:03:08 -05:00
Brian Warner
3aa7e22708 relay: don't require allocate(): first message creates the Channel
this enables pre-generated (human-offline-created) codes, as long as
they use a channel id high enough to avoid colliding with any allocated
ones.
2015-04-09 22:46:18 -05:00
Brian Warner
c8d2fc8750 relay: improve the way we allocate channels
Now the server allocates a channel randomly from set of available ids
with the shortest possible length. So concurrency=1 will always yield a
channel-id between 1 and 9 (inclusive). If we have 9 simultaneous
sessions, we'll start allocating channels from 10 to 99. 100
simultaneous connections kicks us into the 100-999 bucket, etc.
2015-04-09 22:45:04 -05:00
Brian Warner
ecc04ff675 display message-of-the-day, if the server offers one 2015-04-09 12:45:12 -07:00
Brian Warner
e881d169a6 error out if server gives a "sorry we're closed" error 2015-04-09 12:29:26 -07:00
Brian Warner
782214813b server+client: fix SSE alternate-event-type handling
I think the server needs to put blank lines after *every* field, not
just the data: fields.
2015-04-09 11:37:50 -07:00
Brian Warner
9d7cd1d7de server: add "welcome message" to all responses, including server version 2015-04-08 21:03:27 -07:00
Brian Warner
dc9bc0c575 Use "wormhole server start" to launch a relay server. 2015-04-08 18:39:33 -07:00
Brian Warner
0217a13da6 change relay URL: use more distinctive path prefix
This might make it easier for an application's web site to include a
relay, without competing with some other resource named "relay".
2015-03-25 16:51:55 -07:00
Brian Warner
717bfa3b0b move public relays to new hostnames and ports 2015-03-25 14:46:35 -07:00
Brian Warner
fd3e4f3508 change relay URL scheme, allow arbitrary relay-phase messages 2015-03-22 11:45:16 -07:00
Brian Warner
315d7c5614 make rendezvous happen in real-time: replace polling with EventSource 2015-03-12 23:07:47 -07:00
Brian Warner
8741d5adaa relay: refactor in anticipation of a realtime EventSource-based protocol 2015-03-12 19:44:31 -07:00
Brian Warner
cda5634b1d relay.py: minor refactoring in anticipation of multi-pass rendezvous 2015-03-12 19:22:34 -07:00
Brian Warner
8b3e5836ee relay: log total bytes sent in each direction 2015-03-12 16:25:34 -07:00
Brian Warner
c9e0246266 relay: reset channel-id to 1 when all channels are idle 2015-03-02 22:04:58 -08:00
Brian Warner
9a11f355ea relay: expire any rendezvous channel after one hour 2015-03-02 21:22:56 -08:00
Brian Warner
5682ddff8e fix transit relay
stop using web setup for now
2015-03-02 00:09:17 -08:00
Brian Warner
e3964cd797 rearrange source tree 2015-02-15 09:29:28 -08:00