Commit Graph

1012 Commits

Author SHA1 Message Date
Brian Warner
c84939744f oops, fix it properly 2017-04-23 16:33:42 -04:00
Brian Warner
876dea8297 transit: ignore new data in "hung up" state
Apparently there's an intermittent condition in tests that follows this path.
We used to ignore unrecognized states, but to improve test coverage I added a
clause to catch them, and now that clause is happening where I didn't expect
it.
2017-04-23 16:31:26 -04:00
Brian Warner
ebe9df312e signal errors to w.when_code() waiters too
This fixes the case where "wormhole send" would wait forever (upon network
error) instead of terminating with a useful error message.

Testing this will have to wait until we land the branch that abandons the
wormhole if the first connection fails, since that's the easiest way to
provoke a network error before when_code() has fired.
2017-04-23 16:07:07 -04:00
Brian Warner
d6d6669b23 cli._dispatch_command: improve test coverage 2017-04-23 16:01:05 -04:00
Brian Warner
77bb7f5be7 test_wormhole: improve tests of derive_key() 2017-04-19 10:50:52 -04:00
Brian Warner
654bba4d3e test_wormhole: use assertRaises as context manager 2017-04-19 10:50:46 -04:00
Brian Warner
d0fb7a834d tests: exercise DelegatedWormhole 2017-04-19 10:50:31 -04:00
Brian Warner
ef56336eab fix DelegatedWormhole 2017-04-19 10:50:24 -04:00
Brian Warner
323d5a896f debug_set_trace: include _SortedKey 2017-04-19 10:50:18 -04:00
Brian Warner
f541930110 tests: exercise set_trace 2017-04-19 10:49:12 -04:00
Brian Warner
5a3f389bd3 improve debug timeline data and visualization 2017-04-18 14:05:46 -04:00
Brian Warner
0774ac8c36 test_wormhole: more coverage 2017-04-18 14:05:46 -04:00
Brian Warner
16c47de61b test_util.py: fully cover util.py 2017-04-18 14:05:46 -04:00
Brian Warner
556ae663cb test_transit: fully cover transit.py 2017-04-18 14:05:46 -04:00
Brian Warner
afe9f7152d test_transit: improve coverage
and fix py2/py3-isms in ipaddr tests
2017-04-18 14:05:39 -04:00
Brian Warner
478405cb6a test_cli: exercise -0 mode 2017-04-18 13:43:07 -04:00
Brian Warner
1bb4e9278a CLI: remove log.err(), remove flushLoggedErrors from tests
I think we're better off without this: the CLI commands propagate the Failure
up to their callers (rather than eating it silently), the callers are using
task.react (which reacts to Failures by exiting with rc!=0), so nothing
should get lost. And doing an extra log.err() just creates more cleanup work
for test cases to flush, and makes the CLI commands double-print the any
errors (maybe task.react also points logging at stderr?).
2017-04-16 16:45:09 -04:00
Brian Warner
b4e39edb3f cmd_receive: rename TwistedReceiver to just Receiver 2017-04-16 16:28:46 -04:00
Brian Warner
9dde091f2b test_wormhole.py: remove dead code 2017-04-16 10:56:17 -04:00
Brian Warner
e6b9cf18be update to match new (private) Automat tracing API 2017-04-13 16:51:04 -04:00
Brian Warner
c2a71e7240 delete leftover/unused/unimportable codes.py
refs #146
2017-04-10 11:33:46 -07:00
Brian Warner
469c94dc4e test_cli: on win32, force en_US.UTF-8 rather than running locale -e 2017-04-07 11:18:32 -07:00
Brian Warner
781d791e03 test server-reconnection: it worked already
Cool, it actually worked without changes. Closes #42
2017-04-07 09:48:48 -07:00
Brian Warner
992db1846c minor TODO comments 2017-04-06 19:44:27 -07:00
Brian Warner
6aa7fe7c82 Welcome: handle local dev versions (with +, not -) correctly
The Welcome class prints a message if the server recommends a CLI version
that's newer than what the client is currently using, but only if the client
is running a "release" version, not a "local" development one. "local"
versions have a "+" in them (at least when Versioneer creates it), but
Welcome was looking for "-" as an indicator. So it was printing the warning
when it shouldn't be.
2017-04-06 19:32:05 -07:00
Brian Warner
1a7b3baaf2 rewrite waiting-for-sender pacifier messages
re-enable the test, and add an extra one

The comments in cmd_send/cmd_receive now enumerate the four cases where we
might notice that things are taking too long, the three cases where we say
something about it, and the two cases where it might be appropriate to give
up automatically (although we don't do that anywhere yet).
2017-04-06 19:17:11 -07:00
Brian Warner
83e55f1f3e add w.when_key(), fix w.when_verified() to fire later
Previously, w.when_verified() was documented to fire only after a valid
encrypted message was received, but in fact it fired as soon as the shared
key was derived (before any encrypted messages are seen, so no actual
"verification" could occur yet).

This fixes that, and also adds a new w.when_key() API call which fires at the
earlier point. Having something which fires early is useful for the CLI
commands that want to print a pacifier message when the peer is responding
slowly. In particular it helps detect the case where 'wormhole send' has quit
early (after depositing the PAKE message on the server, but before the
receiver has started). In this case, the receiver will compute the shared
key, but then wait forever hoping for a VERSION that will never come. By
starting a timer when w.when_key() fires, and cancelling it when
w.when_verified() fires, we have a good place to tell the user that something
is taking longer than it should have.

This shifts responsibility for notifying Boss.got_verifier, out of Key and
into Receive, since Receive is what notices the first valid encrypted
message. It also shifts the Boss's ordering expectations: it now receives
B.happy() before B.got_verifier(), and consequently got_verifier ought to
arrive in the S2_happy state rather than S1_lonely.
2017-04-06 18:27:41 -07:00
Brian Warner
67d53f1388 wordlist: fix "1-word- TAB" case 2017-04-06 15:05:37 -07:00
Brian Warner
3f878fb981 rename test_scripts to test_cli 2017-04-06 12:30:56 -07:00
Brian Warner
e787d0ffc5 move Welcome into test_scripts, remove test_cli 2017-04-06 12:29:58 -07:00
Brian Warner
9717b67d1b comment out serialize() for now
until it's implemented fully
2017-04-06 12:27:06 -07:00
Brian Warner
f957e9b2fb test_wormhole: check when_verified() being called late 2017-04-06 12:26:52 -07:00
Brian Warner
a063ed2b3b remove unused wordlist.py (now lives in _wordlist.py) 2017-04-06 12:23:25 -07:00
Brian Warner
7c6332b770 wormhole: comments 2017-04-06 12:22:45 -07:00
Brian Warner
3cd4d31c0b journal: add test coverage 2017-04-06 12:22:45 -07:00
Brian Warner
df1b2338b1 tests: exercise Key receiving PAKE before set_code 2017-04-06 12:22:45 -07:00
Brian Warner
0da9cbdeeb remove unused code 2017-04-06 12:22:45 -07:00
Brian Warner
d331c51c03 change completion API
* InputHelper returns full words, not just suffixes. I liked the fact that
  suffixes made it impossible to violate the "all matches will start with
  your prefix" invariant, but in practice it was fiddly to work with.
* add ih.when_wordlist_is_available(), so the frontend can block (after
  claiming the nameplate) until it can return a complete wordlist to
  readline. This helps the user experience, because readline wasn't really
  built to work with completions that change over time
* make the Wordlist responsible for appending hyphens to all non-final word
  completions. InputHelper remains responsible for hyphens on nameplates.
  This makes the frontend simpler, but I may change it again in the future if
  it helps non-readline GUI frontends.
* CodeInputter: after claiming, wait for the wordlist rather than returning
  an empty list
* PGPWordList: change to match

This has the unfortunate side-effect that e.g. typing "3-yucatan-tu TAB"
shows you completions that include the entire phrase: "3-yucatan-tumor
3-yucatan-tunnel", rather than only mentioning the final word. I'd like to
fix this eventually.
2017-04-06 12:22:45 -07:00
Brian Warner
04926d0be8 minor test improvement 2017-04-06 12:22:45 -07:00
Brian Warner
4c7b908024 _rlcompleter: improve debug messages and comments 2017-04-06 12:22:45 -07:00
Brian Warner
7699ed2291 tell wordlist how many words to expect, add hyphens to matches
I'm still undecided about whether to add this to the mailbox
properties (revealing it to attackers) or continue to require non-default
wordcounts to be provided as a --code-length= argument to the receiver. So
for now the only place that says count=2 is in the default argument on
get_completions().
2017-04-06 12:22:45 -07:00
Brian Warner
a1f0d1bbf7 debug_set_trace(): cleanups, remove dead code 2017-04-06 12:22:45 -07:00
Brian Warner
bdef446ad4 get mostly-full coverage for rlcompleter, rename, export 2017-04-06 12:22:45 -07:00
Brian Warner
8882e6f64e merge test_wormhole_new into test_wormhole 2017-04-06 12:22:45 -07:00
Brian Warner
8d47194612 check when_version() can be called late as well as early 2017-04-06 12:22:45 -07:00
Brian Warner
580c5a4712 remove unused channel_monitor.py 2017-04-06 12:22:45 -07:00
Brian Warner
6eae5ecf64 better py2/py3 fix, use locale of C.UTF-8 or en_US.UTF-8
This updates the unit tests to checks the system (by running 'locale -a' just
like Click does) to use a UTF-8 -safe locale. It prefers C.UTF-8 if
available, then en_US.UTF-8, then will fall back to any UTF-8 it can find.

My macOS box has en_US.UTF-8 (but not C.UTF-8), and my linux box has
C.UTF-8 (but not en_US.UTF-8). This change doesn't help normal runtime, but
ought to allow the unit tests to run on either platform correctly.
2017-04-06 12:22:45 -07:00
Brian Warner
d0d2992d44 fix some py2-isms that broke py3
This also changes the can-I-run-wormhole check to use C.UTF-8 instead of
en_US.UTF-8, which seems necessary to hush Click on py3. See issue #127 for
more discusson.
2017-04-06 12:22:45 -07:00
Brian Warner
228e0ed671 set_trace: tolerate an Automat that lacks m.setTrace
wormhole.debug_set_trace() won't work until glyph/automat#56 lands, but this
should let travis do its job in the meantime.
2017-04-06 12:22:45 -07:00
Brian Warner
76f5960517 rewrite welcome handler 2017-04-06 12:22:45 -07:00
Brian Warner
152775c5c0 hush pyflakes 2017-04-06 12:22:45 -07:00
Brian Warner
bbef68c11e remove no-longer-relevant tests 2017-04-06 12:22:45 -07:00
Brian Warner
271efb6025 match new Automat tracing API (in glyph/automat#56 PR) 2017-04-06 12:22:45 -07:00
Brian Warner
d44a5335b4 _mailbox: new Automat forbids code in Input bodies 2017-04-06 12:22:45 -07:00
Brian Warner
3ca2720f11 Input: more debug text 2017-04-06 12:22:45 -07:00
Brian Warner
b38d4c94ca Code: deliver got_code to Boss before Key
So when Key sends got_key to Boss, Boss will be ready for it

test_machines: match new delivery order
2017-04-06 12:22:44 -07:00
Brian Warner
0ed363c894 Key: sort messages to ensure got_code lands before got_pake
Since input_code() sets the nameplate before setting the rest of the code,
and since the sender's PAKE will arrive as soon as the nameplate is set, we
could got_pake before got_code, and Key wasn't prepared to handle that.
2017-04-06 12:22:44 -07:00
Brian Warner
17b4ff9893 rework completion, vaguely works 2017-04-06 12:22:44 -07:00
Brian Warner
351a523d0b disable test_slow_text for now 2017-04-06 12:22:44 -07:00
Brian Warner
9267c204e9 test_wormhole_new: oops, forgot yield on assertFailure
This was breaking the last test that gets run (test_xfer_util) because of the
lingering failures.
2017-04-06 12:22:44 -07:00
Brian Warner
07a49bfaca make progress on rlcompleter, still broken 2017-04-06 12:22:44 -07:00
Brian Warner
1b5a0289a8 cmd_send: finally fix when_verified call 2017-04-06 12:22:44 -07:00
Brian Warner
a446d4333e start on new rlcompleter wrapper function 2017-04-06 12:22:44 -07:00
Brian Warner
f0cab020f4 hush some pyflakes 2017-04-06 12:22:44 -07:00
Brian Warner
e82d705764 unbreak other tests 2017-04-06 12:22:44 -07:00
Brian Warner
53a911cc80 finish Boss tests 2017-04-06 12:22:44 -07:00
Brian Warner
d8d305407b start on Boss tests 2017-04-06 12:22:44 -07:00
Brian Warner
bd974f3801 test Nameplate, Mailbox. refactor a little bit 2017-04-06 12:22:44 -07:00
Brian Warner
3a289f8912 add tests for Send and Terminator 2017-04-06 12:22:44 -07:00
Brian Warner
e66d2df9f1 test and fix wordlist methods 2017-04-06 12:22:44 -07:00
Brian Warner
3873f55d64 make Input tests pass, clarify error cases, cleanups 2017-04-06 12:22:44 -07:00
Brian Warner
175fef2ab4 clean up wordlist handling 2017-04-06 12:22:44 -07:00
Brian Warner
ae95948c17 more tweaks 2017-04-06 12:22:44 -07:00
Brian Warner
4f1b352b2a more work: allocator, input, shift responsibilities 2017-04-06 12:22:44 -07:00
Brian Warner
ae8652daf6 code: internal name changes 2017-04-06 12:22:44 -07:00
Brian Warner
0be5aba77d begin worm on new Code machine 2017-04-06 12:22:44 -07:00
Brian Warner
e2c0f08216 minor renames for code-input helper stuff 2017-04-06 12:22:44 -07:00
Brian Warner
4bd9d3579c go back to "input_code" instead of "type_code" 2017-04-06 12:22:44 -07:00
Brian Warner
276fdd3673 fix tests that exercise failure 2017-04-06 12:22:44 -07:00
Brian Warner
29f467e9d8 CLI: don't hide errors, fuss with verifier API 2017-04-06 12:22:44 -07:00
Brian Warner
921228a702 log errors better 2017-04-06 12:22:44 -07:00
Brian Warner
7c18fb81dd only allow code to be set once 2017-04-06 12:22:44 -07:00
Brian Warner
2054e4c76b test app versions 2017-04-06 12:22:44 -07:00
Brian Warner
5f9894ca63 API updates, make most tests pass, disable others
* finally wire up "application versions"
* remove when_verifier (which used to fire after key establishment, but
  before the VERSION message was received or verified)
* fire when_verified and when_version at the same time (after VERSION is
  verified), but with different args
2017-04-06 12:22:44 -07:00
Brian Warner
e518f2b799 throw KeyFormatError when given a code with spaces 2017-04-06 12:22:44 -07:00
Brian Warner
aebee61816 fix close behavior: Deferreds should errback once closed 2017-04-06 12:22:44 -07:00
Brian Warner
ddb83e9d59 wormhole: handle w.close() after error-induced closure 2017-04-06 12:21:00 -07:00
Brian Warner
2422ee0b88 disable NotWelcome test until signal_error is done 2017-04-06 12:21:00 -07:00
Brian Warner
9ca657a7c6 reenable TorManager 2017-04-06 12:21:00 -07:00
Brian Warner
4234e79161 test_wormhole: fix message-doubling test 2017-04-06 12:21:00 -07:00
Brian Warner
105d9cc59f work on WelcomeHandler, still incomplete 2017-04-06 12:21:00 -07:00
Brian Warner
4c6cb1dddc xfer_util: update to new API 2017-04-06 12:21:00 -07:00
Brian Warner
dfe9fd2395 RC: internal errors during ws_open should halt boss 2017-04-06 12:21:00 -07:00
Brian Warner
6ada8252b7 Code: handle being connected before being told what to do 2017-04-06 12:21:00 -07:00
Brian Warner
8ee342ad82 make cmd_send/cmd_receive basically work again 2017-04-06 12:21:00 -07:00
Brian Warner
e9f3107127 deliver app-versions up to Wormhole 2017-04-06 12:21:00 -07:00
Brian Warner
60a61c995b implement w.derive_key() 2017-04-06 12:21:00 -07:00
Brian Warner
0474c39bab tests: match API change 2017-04-06 12:21:00 -07:00
Brian Warner
c499fce9f5 change API (wormhole.create), start on serialization 2017-04-06 12:21:00 -07:00
Brian Warner
b7b8df17be rename NameplateLister to Lister (unique prefix L) 2017-04-06 12:21:00 -07:00
Brian Warner
9a2d992815 reminder how ConnectionService should fail if first attempt fails 2017-04-06 12:21:00 -07:00
Brian Warner
88cb42f95b test_machines: exercise state machines better 2017-04-06 12:21:00 -07:00
Brian Warner
2dcfb07ba1 Receive does not need access to Key 2017-04-06 12:21:00 -07:00
Brian Warner
db7b24086f set no-cover on all state-definition lines, and set_trace 2017-04-06 12:21:00 -07:00
Brian Warner
610db612ba improve error handling
errors raised while processing a received message will cause the Wormhole to
close-with-error, and any pending Deferreds will be errbacked
2017-04-06 12:21:00 -07:00
Brian Warner
fb92922918 terminator: renaming TODO note 2017-04-06 12:21:00 -07:00
Brian Warner
4222054903 nameplate: tolerate rx_claimed during shutdown 2017-04-06 12:21:00 -07:00
Brian Warner
4793208d4e rewrite debug tracing, add to all machines 2017-04-06 12:21:00 -07:00
Brian Warner
b0c9c9bb4c fix basic test 2017-04-06 12:21:00 -07:00
Brian Warner
1beae97ec4 fix things back to the previous point of not working 2017-04-06 12:21:00 -07:00
Brian Warner
26adaabe18 implement new split nameplate/mailbox/terminator
fails even worse than before, of course
2017-04-06 12:21:00 -07:00
Brian Warner
c8be988801 add some state-machine tracing
needs warner/automat/36-tracing branch
2017-04-06 12:21:00 -07:00
Brian Warner
97d1ff859b logic bug: M.S4B.close() must not re-send RELEASE 2017-04-06 12:21:00 -07:00
Brian Warner
41b7bcfed5 working on fixes 2017-04-06 12:21:00 -07:00
Brian Warner
b7df5e21eb more tests, still failing 2017-04-06 12:21:00 -07:00
Brian Warner
8a2810ba70 test basic code allocation 2017-04-06 12:21:00 -07:00
Brian Warner
ef1904bc52 get null test working (open and immediate close) 2017-04-06 12:21:00 -07:00
Brian Warner
c95b6d402c Code: don't sent tx_allocate until we're connected
So Code needs connected/lost from the RendezvousConnector
2017-04-06 12:21:00 -07:00
Brian Warner
5d6989614b work on top-level stuff 2017-04-06 12:21:00 -07:00
Brian Warner
7e7b43e910 start on top-level driver, wormhole.py 2017-04-06 12:21:00 -07:00
Brian Warner
88775d7f50 states.py: remove old file 2017-04-06 12:21:00 -07:00
Brian Warner
825370fdd2 cleanups, remove misc.py 2017-04-06 12:21:00 -07:00
Brian Warner
d4bedeafbf general fixes 2017-04-06 12:21:00 -07:00
Brian Warner
20814a65f4 rename Wormhole (machine) to Boss, leave room for higher-level thing 2017-04-06 12:21:00 -07:00
Brian Warner
92f2b89d3e journal: fix syntax 2017-04-06 12:21:00 -07:00
Brian Warner
a2ed35ceb8 remove old files, lots of type work 2017-04-06 12:21:00 -07:00
Brian Warner
3101ca51db name cleanup 2017-04-06 12:21:00 -07:00
Brian Warner
80661392b6 build out all state machines
still early: automat is happy (they're syntactically valid), but the Outputs
are not implemented, and there are plenty of type mismatches
2017-04-06 12:21:00 -07:00
Brian Warner
9ae8091ec3 delete old files 2017-04-06 12:21:00 -07:00
Brian Warner
21cb62a4cf move _c2.py out of the way, I might want it later 2017-04-06 12:21:00 -07:00
Brian Warner
b179e66d08 start on machine implementation: _key.py and _send.py 2017-04-06 12:21:00 -07:00
Brian Warner
40e0d6b663 more work, feels better now 2017-04-06 12:21:00 -07:00
Brian Warner
16c477424c more demo work 2017-04-06 12:21:00 -07:00
Brian Warner
693e215d8b sketching out a journal-based demo app 2017-04-06 12:21:00 -07:00
Brian Warner
20b80be342 remove stale machines 2017-04-06 12:21:00 -07:00
Brian Warner
3af375b173 finish Mailbox state machine, including close 2017-04-06 12:21:00 -07:00
Brian Warner
b934192f20 work on Mailbox machine 2017-04-06 12:21:00 -07:00
Brian Warner
11a80f0018 moving to separate machine class 2017-04-06 12:21:00 -07:00
Brian Warner
3bf762b4f7 try coding top-level WormholeMachine 2017-04-06 12:21:00 -07:00
Brian Warner
faab1e87d0 split _machine.py out 2017-04-06 12:21:00 -07:00
Brian Warner
17a90d87ac tweaks 2017-04-06 12:21:00 -07:00
Brian Warner
35324a7911 my StateMachine can now render .dot 2017-04-06 12:21:00 -07:00
Brian Warner
0fe6cfd994 tweaks 2017-04-06 12:21:00 -07:00
Brian Warner
0b05c9ca5a new experimental state-machine language
I think I want to express actions as transient states. _c2.py matches w4.dot
2017-04-06 12:21:00 -07:00
Brian Warner
057f616765 more experimentation 2017-04-06 12:21:00 -07:00
Brian Warner
18f7ab9308 more state-machine work 2017-04-06 12:21:00 -07:00
Brian Warner
63ae3c63fc notes 2017-04-06 12:21:00 -07:00
Brian Warner
9e5bf452e3 rename 2017-04-06 12:21:00 -07:00
Brian Warner
3c9c0e58ab move to _connection.py, add more state machines
Starting on defining manager state machines for nameplates, mailboxes, the
PAKE key-establishment process, and the bit that knows it can drop the
connection when both nameplates and mailboxes have been released.
2017-04-06 12:21:00 -07:00
Brian Warner
14c8e76364 onConnect, start manual tests, doesn't work yet 2017-04-06 12:21:00 -07:00
Brian Warner
b826e8c73c hack args till they work, add ALLOW_CLOSE
the diagram is a lot simpler if the only way to shut things down is to
terminate the whole process
2017-04-06 12:21:00 -07:00
Brian Warner
d136028fa8 try adding args 2017-04-06 12:21:00 -07:00
Brian Warner
73f3d86107 state machine should be complete, I think 2017-04-06 12:21:00 -07:00
Brian Warner
94b1ed8739 starting to draw new state machines 2017-04-06 12:21:00 -07:00
Brian Warner
65db4729cd rendezvous_websocket.py: add idempotency docs 2017-03-03 05:55:39 -08:00
Brian Warner
8d5770d8cc tor_manager: allow port to be a 'long' 2017-03-03 05:49:36 -08:00
Brian Warner
b7ff5f05d5 transit: allow port to be a 'long' 2017-03-03 05:49:30 -08:00
Brian Warner
cf9053637c test_util: free-space can be a 'long' 2017-03-03 05:49:25 -08:00
Brian Warner
71f34e4f5b test/run_trial.py: protect run() with __name__
Without this, any import (e.g. when running "automat-visualize") caused the
tests to be run as a side-effect.
2017-02-22 18:03:33 -08:00
Brian Warner
6889ba088c remove server/runner.py, no longer used 2017-02-22 17:52:14 -08:00
Shannon Mulloy
ffefb5ebdc improve coverage with input mock 2017-02-05 15:42:49 -08:00
Shannon Mulloy
33526b2180 rx: _remove_existing after accept 2017-02-05 13:29:20 -08:00
Shannon Mulloy
56a0a1f584 rx: allow overwrite with --output-file= #73 2017-02-04 19:27:09 -08:00
Brian Warner
20619bcce7 send: set allowZip64=True, to handle large (>2GB) directories
refs #138
2017-02-02 11:40:24 -08:00
Brian Warner
ed674e5ffe transit: increase connection timeout from 15s to 60s
I haven't seen any timeouts yet, but I'm thinking ahead to .onion connections
that might take longer than 15 seconds to establish.
2017-01-16 17:56:16 -05:00
Brian Warner
862820679c don't hang when asked to send a zero-length file
closes #98
2017-01-16 17:29:40 -05:00
Brian Warner
f2704c6ce0 cli: oops, fix ssh args
wish there were some tests for this
2017-01-16 11:34:32 -05:00
Brian Warner
df62e16462 cli: handle tor args in 'ssh' subcommands 2017-01-16 11:29:20 -05:00
Brian Warner
47007273ec rewrite Tor support (py2 only)
The new TorManager adds --launch-tor and --tor-control-port= arguments
(requiring the user to explicitly request a new Tor process, if that's what
they want). The default (when --tor is enabled) looks for a control port in
the usual places (/var/run/tor/control, localhost:9051, localhost:9151), then
falls back to hoping there's a SOCKS port in the usual
place (localhost:9050). (closes #64)

The ssh utilities should now accept the same tor arguments as ordinary
send/receive commands. There are now full tests for TorManager, and basic
tests for how send/receive use it. (closes #97)

Note that Tor is only supported on python2.7 for now, since txsocksx (and
therefore txtorcon) doesn't work on py3. You need to do "pip install
magic-wormhole[tor]" to get Tor support, and that will get you an inscrutable
error on py3 (referencing vcversioner, "install_requires must be a string or
list of strings", and "int object not iterable").

To run tests, you must install with the [dev] extra (to get "mock" and other
libraries). Our setup.py only includes "txtorcon" in the [dev] extra when on
py2, not on py3. Unit tests tolerate the lack of txtorcon (they mock out
everything txtorcon would provide), so they should provide the same coverage
on both py2 and py3.
2017-01-15 22:39:03 -05:00
Brian Warner
203216c0ff cli: move TorArgs out to separate decorator 2017-01-15 22:21:29 -05:00
Brian Warner
aa772858f5 cli: print useful error when --tor is requested but unavailable 2017-01-15 17:35:46 -05:00
Brian Warner
33370bb1b3 transit: mention tor when describing connections that use it 2017-01-15 17:03:40 -05:00
Brian Warner
bcac0c74f3 codes: don't assume 'readline' has a __doc__
This fixes cygwin, which (for some reason) doesn't include docstrings in the
readline module.

closes #111
2017-01-14 17:56:49 -05:00
Brian Warner
b3763f9e78 show "you can use tabs" reminder if code was input without completion
refs #15
2017-01-12 16:14:42 -08:00
Brian Warner
62b069dea6 Wormhole: control stderr 2017-01-12 16:14:42 -08:00
Brian Warner
2e3a0d4a1d change URL of public relay to new DNS names
These point to the same host (same IP address) as before, but the new names
are tied to the project's official domain (magic-wormhole.io), rather than my
personal one, so they can be managed independently.
2017-01-02 23:42:44 -05:00
Brian Warner
92f8c60b31 upgrade to versioneer-0.18 2017-01-01 14:10:57 -05:00
Brian Warner
7d995ca1d5 transit server: respect --blur-usage= by not logging connections 2017-01-01 13:00:35 -05:00
Brian Warner
b2fd899ac9 prioritize relay connections
closes #103
2016-12-31 00:33:00 -05:00
Brian Warner
8b864c3eae parse/transmit/record hint priorities
Use --transit-helper=tcp:HOST:PORT:priority=1.3 to override the default 0.0 .
Larger (positive) priority numbers will be attempted first.
2016-12-31 00:32:42 -05:00
Brian Warner
bc17047983 test_transit: refactor, simplify 2016-12-31 00:31:23 -05:00
Brian Warner
1abe733a81 more coverage: parse_hint_argv 2016-12-31 00:25:15 -05:00
Brian Warner
fe6ff466d8 more coverage: parse_tcp_v1_hint 2016-12-31 00:21:34 -05:00
Brian Warner
511a73c491 improve coverage: Transit._endpoint_from_hint_obj 2016-12-31 00:09:58 -05:00
Brian Warner
7f54d810eb remove unused+uncovered code 2016-12-31 00:08:26 -05:00
Brian Warner
e500f4a100 rx: tolerate duplicate peer messages
closes #121
2016-12-26 15:27:14 -05:00
Brian Warner
8b5d884636 add (failing/hanging) test of receiving duplicate messages
it's a pity this causes a hang, rather than a cleaner exception
2016-12-26 15:21:45 -05:00
Brian Warner
7ddf0d3c2d server: forbid reclaiming previously-closed nameplates
at least by the same side. This forces the contour of claims (by any given
side) to be strictly unclaimed -> claimed -> released. The "claim"
action (unclaimed -> claimed) is idempotent and can be repeated arbitrarily,
as long as they happen on separate websocket connections. Likewise for the
"release" action (unclaimed -> released). But once a side releases a
nameplate, it should never roll so far back that it tries to claim it again,
especially because the first claim causes a mailbox to be allocated, and if
we manage to allocate two different mailboxes for a single nameplate, then
we've thrown idempotency out the window.
2016-12-25 20:09:55 -05:00
Brian Warner
3a4a3f544f server: make close() idempotent
refs #118
2016-12-25 20:09:52 -05:00
Brian Warner
2c8d00e436 rendezvous_websocket.py: make release() idempotent
and make it possible to call release() even though you haven't called claim()
on that particular socket (releasing a claim that was made on some previous
websocket).

This should enable reconnecting clients, as well as intermittently-connected
"offline" clients.

refs #118
2016-12-25 20:09:48 -05:00
Brian Warner
b44fcf77da test_server: improve debug message 2016-12-25 20:00:05 -05:00
Brian Warner
a746ca726a test_server: factor out common utils 2016-12-25 19:13:00 -05:00
Brian Warner
3ad29379b5 server: fix comment 2016-12-25 14:36:50 -05:00
Brian Warner
9f72b72b76 split Transit out of test_server.py 2016-12-24 17:44:40 -05:00
Brian Warner
72dfb6eb1c write progress/status messages to stderr, not stdout
This should leave stdout clean for use in `foo | wormhole send --text=-` and
`wormhole rx CODE >foo`, although the forms that want interactive code entry
probably won't work that way.

closes #99
2016-12-24 00:03:32 -05:00
Brian Warner
fde98b7c7e more coverage 2016-12-23 22:22:39 -05:00
Brian Warner
db968900d9 test_server: improve coverage 2016-12-23 22:22:39 -05:00
Brian Warner
b8313b4595 dedup relays, include our own relay when connecting
* Previously, we only connected to the relay supplied by our partner, which
  meant that if our relay differed from theirs, we'd never connect
* But we must de-duplicate the relays because when our relay *is* the same as
  theirs, we'd have two copies, which means two connections. Now that we
  deliver sided handshakes, we can tolerate that (previously, our two
  connections would be matched with each other), but it's still wasteful.

This also fixes our handling of relay hints to accept multiple specific
endpoints in each RelayHint. The idea here is that we might know multiple
addresses for a single relay (maybe one IPv4, one IPv6, a Tor .onion, and an
I2P address). Any one connection is good enough, and the connections we can
try depend upon what local interfaces we discover. So a clever implementation
could refrain from making some of those connections when it knows the sibling
hints are just as good. However we might still have multiple relays entirely,
for which it is *not* sufficient to connect to just one.

The change is to create and process RelayV1Hint objects properly, and to set
the connection loop to try every endpoint inside each RelayV1Hint. This is
not "clever" (we could nominally make fewer connection attempts), but it's
plenty good for now.

refs #115

fix relay hints
2016-12-23 22:22:39 -05:00
Brian Warner
80ae9236df make RelayV1Hint objects hashable/comparable 2016-12-23 22:22:39 -05:00
Brian Warner
e1546bf03f Transit: send new (sided) handshakes 2016-12-23 22:22:39 -05:00
Brian Warner
5fcea701bb transit server: accept both new (sided) and old (unsided) handshakes 2016-12-22 23:54:36 -05:00
Brian Warner
c7e4d57405 improve relay test 2016-12-22 23:53:29 -05:00
Brian Warner
f2e011bc9c Add --appid to override the APPID, for subprocess-based wrappers.
Tools which use `wormhole send` under the hood should use a distinct
--appid= (setting the same URL-shaped value on both sides, starting with a
domain name related to the tool and/or its author), so wormhole codes used by
those tools won't compete for short channelids with other tools, or the
default text/file/directory-sending tool.

Closes #113
2016-12-22 15:44:13 -05:00
Brian Warner
57c0894774 cmd_send: flush args.stdout, in case it's different 2016-12-17 17:32:12 -08:00
Joey Hess
8bec79289a send: flush stdout after displaying code
Fixes https://github.com/warner/magic-wormhole/issues/108

Apparently python defaults to buffering stdout when not outputting to
the terminal. It would be better IMHO if every line of stdout were
autoflushed, but based on
http://stackoverflow.com/questions/107705/disable-output-buffering
there's not a really good way to accomplish that in python.
2016-12-17 17:20:45 -04:00
Brian Warner
30af04d245 test_scripts: rename mode to be "slow-text" 2016-12-16 01:33:45 -08:00
Brian Warner
face9423dd internals: ensure _API_establish_key is not called twice 2016-12-16 01:33:17 -08:00
laharah
2d1f474c60 rebased and fixed merge error 2016-12-16 01:06:21 -08:00
laharah
6bdaaf368c Moved slow connection notification to stderr
added test for slow connection notifications
2016-12-16 01:06:21 -08:00
laharah
01318d1130 added notification to cmd_receive plus reactor cleanup
Added a try finally block around verify to ensure notification
deferreds are being cleaned out of the reactor
2016-12-16 01:03:01 -08:00
laharah
a2ab1863cf added the new key waiter to be cleaned up on error in wormhole
Also, set new print statment to print to args.stdout
2016-12-16 01:03:01 -08:00
laharah
f786031f40 basic key established hook added to CLI send 2016-12-16 01:03:01 -08:00
laharah
680b01b3fc added api hooks to get notification about key excange
added more coverage to establish key API hook
2016-12-16 01:03:01 -08:00
laharah
33fa6f6ede tests for new establish_key wormhole hook
defered should behave similarly to the `verify` hook
2016-12-16 01:03:01 -08:00
Brian Warner
5c751eb3ed fix tests on windows 2016-12-15 19:52:26 -08:00
Brian Warner
f3e1aab3a1 reject transfers when there isn't enough disk space available
closes #91

Also tweaks an error message: don't say "refusing to clobber pre-existing
file FOO" when we don't check that it's actually a file. Just say "..
pre-existing 'FOO'".
2016-12-15 19:52:26 -08:00
Brian Warner
b57928431a add utility to estimate free disk space 2016-12-15 19:52:26 -08:00
Brian Warner
2596c58e4a ipaddrs: import function from latest Tahoe
I'm hoping this will help with Cygwin (#13), by removing/bypassing the
assert(os.path.isabs) check.
2016-12-10 13:06:27 -08:00
Brian Warner
58f20d79a7 update to versioneer-0.17
This should fix the pyflakes error when running tox on an unpacked sdist.
2016-12-10 10:36:59 -08:00
Brian Warner
f0bfcd7ca4 fix some py2/py3-isms picked up by mypy
These happened to work, but it's probably best to get the types right.
2016-12-08 23:47:53 -08:00
Brian Warner
582cebfb5f rx: don't reveal file-already-exists, just reject transfer
closes #74
2016-12-08 16:59:54 -08:00
Brian Warner
ab972785aa CLI: don't emit traceback for TransferErrors
But do print the message contained therein

refs #74
2016-12-08 16:59:52 -08:00
Brian Warner
58c7639635 CLI: exit with rc=1 upon errors 2016-12-08 16:59:02 -08:00
Antoine Beaupré
e9cd5b5d60 fix capitalization output to match humanize 2016-11-17 11:36:00 -05:00
Antoine Beaupré
342bebbd0e use humanize library instead of custom implementation 2016-11-11 22:01:21 -05:00
Antoine Beaupré
047af4b27d use human-readable sizes more broadly
there was a function to "abbreviate" sizes, but it was somewhat
unclear and incomplete. reuse the sizeof_fmt_* set of functions from
the borg backup project (MIT licensed) to implement a more complete
and flexible display that will scale up to the Yottabyte and
beyond. it also supports non-IEC units (like "kibibyte", AKA 1024
bytes) if you fancy that stuff.

this is a workaround for #91: it allows users to better see the size
of the file that will be transfered.

*some* places are still kept in bytes, most notably when receive fails
to receive all bytes ("got %d bytes, wanted %d") because we may want
more clarity there.

text transfers also use the "bytes" suffix (instead of "B") because it
will commonly not reach beyond the KiB range.

note that the test suite only covers decimal (non-IEC) prefix, but it
is assumed to be sufficient to be considered correct.
2016-11-09 15:14:01 -05:00
Brian Warner
0004315431 transit: tolerate non-ascii bad handshake
I think somebody was port-scanning the server (or pointed some
non-wormhole client at it), and caused some exceptions in the logs.
These are still bad handshakes, but should be logged normally instead of
throwing exceptions.
2016-08-22 23:13:04 -07:00
Tom Lowenthal
9dd1d738e1 Fix small CLI typo
The output for verified copies asks the user to run `wormhole --verify receive`, but the correct argument order is `wormhole receive --verify`.
2016-08-15 17:39:52 -07:00
Brian Warner
f449466f4f update tests 2016-08-15 17:36:55 -07:00
Brian Warner
899e539cb1 cmd_ssh: ~ is not always /home
On OS-X, in particular, ~foo expands to /Users/foo . We delegate
everything to os.path.expanduser(), which should know the local
convention.
2016-08-15 17:35:38 -07:00
Brian Warner
75d362f60a add some basic tests, doesn't cover everything 2016-08-15 17:35:34 -07:00
Brian Warner
d057b91371 xfer_util: work on py2+py3
wormhole.send takes bytes, but the utility functions take strings. So
encode the JSON blob before sending, and decode it on the way back out.
2016-08-15 17:35:34 -07:00
meejah
fe29b3130b 'wormhole ssh' cleanups
- move to 'wormhole ssh' group with accept/invite subcommands
- change names of methods
- check for permissions
- use --user option (instead of --auth-file)
- move implementation to cmd_ssh.py
- if multiple public-keys, ask user
2016-08-15 00:30:39 -06:00
meejah
069b76485b Add 'wormhole ssh-add' and 'wormhole ssh-send' commands 2016-08-14 19:59:20 -06:00
meejah
026c8fd093 Print proper tracebacks when inlineCallbacks + yield involved 2016-08-14 16:50:29 -06:00
meejah
afa123abae make tests work on pypy 2016-08-04 15:57:01 -04:00
David Reid
6aa8a47f9a Use StreamServerEndpointService (available since Twisted 10.2) 2016-08-04 00:23:02 -07:00
Brian Warner
dc6416a257 fix stats-writing bug on py3
refs #67
2016-08-01 16:31:05 -07:00
Daniel Kahn Gillmor
2fafdf34ee help bad spelers
Some of us can never remember the old ditty:

   i before e, except after c
   or when sounding like "a"
   as in neighbor or weigh.

Perhaps magic wormhole can coddle us in our misorthography :)
2016-07-31 18:55:42 -04:00
Brian Warner
0ba59136a0 upgrade to versioneer-0.16 2016-07-27 19:08:12 -07:00
Brian Warner
5542545165 CLI: move most top-level args down into the subcommand
So instead of "wormhole --verify send", use "wormhole send --verify".

The full set of arguments that were moved down:

* --code-length=
* --verify
* --hide-progress
* --no-listen
* --tor

The following remain as top-level arguments (which should appear after
"wormhole" and before the subcommand):

* --relay-url=
* --transit-helper=
* --dump-timing=
* --version
2016-07-27 17:56:03 -07:00
Brian Warner
e6b38ecacc cli: start factoring out args into common sets 2016-07-23 17:54:29 -07:00
Brian Warner
37b8ccbe4f cli: mostly use kwargs/setattr 2016-07-22 19:13:59 -07:00
Brian Warner
1a82846578 cli.Config: remove common attributes
The values set by the base Config constructor could mask Click parsers
that weren't supplying defaults properly, or which were using different
defaults.
2016-07-14 22:37:35 -06:00
Brian Warner
52ef00b46b CLI: refactor to make testing easier
When tests need a Config object, they now call a function which invokes
Click with a mocked-out go() function, and grabs the Config object
before actually doing anything with it.
2016-07-14 22:34:10 -06:00
Brian Warner
cdb5c19010 websockets: turn on autoPingInterval to expire stale connections
With this, both clients and servers will send a PING at least once every
minute, and will drop connections that haven't seen any traffic for 10
minutes.

This should help keep NAT table entries alive, and will drop connections
that are no longer viable because their NAT entries have expired.

closes #60
2016-07-03 21:51:56 -07:00
Brian Warner
4978be6b90 args: fix --no-listen, --tor
Also add tests to check that argv is being parsed properly, and to check
the defaults.

fixes #59
2016-06-27 14:40:51 -07:00
Brian Warner
0f8b98dec5 DB: log schema upgrades 2016-06-26 18:04:00 -07:00
Brian Warner
de8efdb9f9 cmd_send: wait for ack from close()
Without this, the sender drops the connection before the "close" message
has made it to the server, which leaves the mailbox hanging until it
expires. It still lives in a 'd.addBoth()' slot, so it gets closed even
if some error occurrs, but we wait for it's Deferred to fire in both
success and failure cases.
2016-06-26 17:55:28 -07:00
Brian Warner
1d3b22a0b4 server: hard-code --stats-file=stats.json
We already hard-code 'relay.sqlite', so I don't see a lot of value in
making making the stats file configurable too. That said, if it makes
life easier for packagers (e.g. start-stop-daemon or systemd wanting
these files to go into /var/run/something/ , and if it isn't sufficient
to just use /var/run/something/ as the CWD), I'd accept a patch to
add it back.
2016-06-26 17:55:28 -07:00