Commit Graph

1496 Commits

Author SHA1 Message Date
Brian Warner
7a28400586 split transcribe.py into two layers: comms and crypto 2015-10-03 17:51:35 -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
bc3b0f03b9 blocking/transit.py: hush a transient failure
Not entirely sure what's going on here, but this is probably safe.
2015-10-03 16:53:08 -07:00
Brian Warner
ccea1a7d3c py3: don't emit noisy b"" prefix for --verify 2015-09-28 16:59:15 -07:00
Brian Warner
429c5cd962 tests: clean up pairs-of-Deferreds patterns 2015-09-28 16:52:12 -07:00
Brian Warner
8d3ed79ce6 add verifier tests 2015-09-28 16:49:36 -07:00
Brian Warner
5ae1c2d020 tests: switch to defer.gatherResults 2015-09-28 16:44:00 -07:00
Brian Warner
ea51617233 travis: we're now py3.3-compatible too 2015-09-28 16:32:49 -07:00
Brian Warner
336eea5e78 tests: handle argparse on py3.3
which sends --version to stderr, not stdout. This might make the py3.3
tests pass.
2015-09-28 16:31:35 -07:00
Brian Warner
4cd838f410 README: add travis badge (for 'master') 2015-09-28 16:23:19 -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
c261f3e713 py3.5 is now supported, more or less
py3.3/3.4 are broken for various reasons
2015-09-28 01:01:25 -07:00
Brian Warner
0838f9bc43 Merge branch 'py3'
This adds python3 compatibility for blocking.transcribe and
blocking.transit, enough to allow the four
"wormhole (send|receive)-(text|file)" commands to work. These are all
tested by travis (via "trial wormhole").

"wormhole server" runs under py3, but only with --no-daemon (until
twisted.python.logfile is ported).

twisted.transcribe doesn't work yet (it needs twisted.web.client.Agent,
plus more local porting work).
2015-09-28 00:53:35 -07:00
Brian Warner
1522658c9b skip test_twisted on py3 until more of Twisted has been ported 2015-09-28 00:45:33 -07:00
Brian Warner
2d7f701849 eventsource_twisted: return unicode, not bytes
This roughly parallels the way that blocking/eventsource.py and the pypi
"requests" modules work: the server can set the encoding (with
"Content-Type: text/event-stream; charset=utf-8"), and the EventSource
parser will decode accordingly. However eventsource_twisted.py *always*
returns unicode (on both py2/py3), even when the server hasn't set an
encoding. blocking/eventsource.py returns bytes (on py3, and str on py2)
when the server doesn't set an encoding.

In the future, eventsource_twisted.py should return bytes when the
server doesn't set an encoding.

eventsource_twisted.py includes an alternate approach that might be
necessary (a to_unicode() function instead of always using .decode), but
I won't be sure until enough of Twisted has been ported to allow the
EventSourceParser to be tested.

Also fix demo.py for python3.
2015-09-28 00:44:32 -07:00
Brian Warner
b5d470fcda make blocking/send-file work on py3
* declare transit records and handshake keys are bytes, not str
* declare transit connection hints to be str
* use six.moves.socketserver, six.moves.input for Verifier query
* argparse "--version" writes to stderr on py2, stdout on py3
* avoid xrange(), use subprocess.Popen(universal_newlines=True)
2015-09-28 00:24:36 -07:00
Brian Warner
8fe41e135d make blocking/send-text work on py3, add dependency on 'six'
* use modern/portable "next(iter)" instead of "iter.next()"
* use six.moves.input() instead of raw_input()
* tell requests' Response.iter_lines that we want str, not bytes
2015-09-28 00:24:36 -07:00
Brian Warner
a7213d9c9a enforce bytes-vs-str in the API
The main wormhole code is str (unicode in py3, bytes in py2). Most
everything else must be passed as bytes in both py2/py3.

Keep the internal "side" string as a str, to make it easier to merge
with other URL pieces.
2015-09-28 00:24:36 -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
15cc0a1429 test_server: make sure the server is reachable
used to exercise py3 issues with the server
2015-09-28 00:24:00 -07:00
Brian Warner
5d93dccb88 appid and derive_key(purpose=) must be bytes, not unicode 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
e9d87828c2 scripts/runner: make py3-compatible 2015-09-27 13:54:20 -07:00
Brian Warner
2e2bd1bb5f tests: split blocking out to its own file
also clean up the output when pip-e -vs- entrypoint -vs- Versioneer
makes the entrypoint script refuse to run from a version mismatch.
2015-09-27 10:43:25 -07:00
Brian Warner
0cd7471c06 travis: turn on py3 testing (failures allowed) 2015-09-26 18:32:02 -07:00
Brian Warner
adf55175fb test_scripts: wormhole should live next to python
not necessarily beneath the current working directory
2015-09-26 18:29:46 -07:00
Brian Warner
d3ef3aa29a more verbose, to figure out travis failure 2015-09-26 18:21:56 -07:00
Brian Warner
5ee37cab64 test_scripts: make found-wrong-wormhole error more verbose 2015-09-26 18:17:50 -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
b069e69d35 test scripts too (with spawnToThread) 2015-09-26 18:02:02 -07:00
Brian Warner
1e6fc4601e tests: split common code out 2015-09-26 18:02:02 -07:00
Brian Warner
bdb8b395b5 database: make py3-compatible 2015-09-26 17:51:21 -07:00
Brian Warner
cbc40697f7 use "except x as y:" everywhere, for py3 2015-09-26 17:47:13 -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
797074d03e runner.py: cosmetic changes 2015-09-23 18:13:35 -07:00
Brian Warner
9c94871e74 travis: use sudo:false for faster builds 2015-09-22 13:33:04 -07:00
Brian Warner
d76893c07e update docs/api.md for 0.4.0 2015-09-22 01:27:17 -07:00
Brian Warner
bc1142586e add docs for 0.4.0 2015-09-22 01:18:01 -07:00
Brian Warner
262cc960cf Merge branch 'only-symmetric'
magic-wormhole now only uses the "SPAKE2_Symmetric" protocol, which does
not require the two participants to decide ahead of time which one is
which.

Previously, the blocking form used an asymmetric protocol, and the
non-blocking/Twisted form used a symmetric protocol (however it used an
earlier+slower version from SPAKE2-0.2.0, which is not compatible with
the current SPAKE2-0.3.0 one).

This breaks compatibility for the built-in "wormhole" script: a sender
using 0.3.0 will get errors when talking to a recipient running this
version or newer (including the upcoming 0.4.0 release).
2015-09-22 01:10:29 -07:00
Brian Warner
532aa0811c update idSymmetric= to match SPAKE2-0.3 2015-09-22 01:07:46 -07:00
Brian Warner
b97b7ccd8c switch to spake2==0.3, with the faster symmetric algorithm
Note that this breaks compatibility of SymmetricWormhole, which was
previously only used by the Twisted flavor.
2015-09-22 01:03:43 -07:00
Brian Warner
88dab265de test blocking code, using twisted+deferToThread
Unfortunately Twisted still requires python2, so we can't use this to
test the intended python3-compatibility of the blocking code.
2015-09-21 23:21:40 -07:00
Brian Warner
46f1fd2cd0 factor error classes into a common file 2015-09-21 23:21:26 -07:00
Brian Warner
8f1ce1f835 update twisted/demo.py 2015-07-24 18:04:15 -07:00
Brian Warner
aec8b65724 rename twisted/eventsource.py in prep for directory merge 2015-07-24 17:55:23 -07:00
Brian Warner
efd6d27cc6 rename SymmetricWormhole to just "Wormhole"
Update docs too. Now both blocking/ and twisted/ use "Wormhole".
2015-07-24 17:47:46 -07:00
Brian Warner
d8ca850d1a blocking: finish alignment 2015-07-24 17:28:55 -07:00
Brian Warner
2ad65e13fe blocking: more alignment with twisted/transcribe.py 2015-07-24 17:22:02 -07:00