Commit Graph

886 Commits

Author SHA1 Message Date
Brian Warner
e7d0dbbb88 oops, typo 2018-02-21 01:57:07 -08:00
Brian Warner
9ae2307a72 fix tests 2018-02-21 00:38:19 -08:00
Brian Warner
37a7ed7adc WIP: remove unused server tests, minor syntax fixes. still fails. 2018-02-20 23:54:28 -08:00
Brian Warner
9957044a99 WIP: start replacing ServerBase with imported server
doesn't work yet at all
2018-02-20 23:46:29 -08:00
Brian Warner
77201966b4 remove server-related source files, munin plugins
setup.py: pin to magic-wormhole-mailbox-server 0.1.0, the current version
2018-02-20 23:46:29 -08:00
Brian Warner
d42ac47ac8 let tests override KEY_TIMER/VERIFY_TIMER to tolerate slow test hosts
I've seen intermittent failures in
test_cli.PregeneratedCode.test_text_subprocess where the host was slow (or
overloaded) enough that the "Waiting for sender.." pacifier message was
displayed, which flunks the test because we're looking for a specific output
string. We patch this 1-second timer in the non-subprocess tests, but you
can't patch across a process boundary.

This patch adds an undocumented environment variable that lets you override
the timer values. The test then sets it to something large.

For future consideration: another approach would be to change the test to
tolerate the extra message. This would be trickier to validate, though.
2018-02-20 18:14:57 -08:00
Brian Warner
6061ec7869 _key: note places where we should use eventual-send
This will be necessary to avoid reentrancy hazards, in case the application
code makes other wormhole API calls from the callbacks for
get_unverified_key(), get_verifier(), or get_message().
2018-02-14 02:12:33 -08:00
Brian Warner
af406a600e _rlcompleter: use blockingCallFromThread for all Helper APIs
We were missing two (the calls to choose_nameplate() and choose_words() that
happen after the input() function has finished, but while we're still inside
the thread that makes it safe for input() to block). This almost certainly
caused the crash seen in issue #280.

Update the tests to match: CodeInputter.finish must now be called with
deferToThread from inside tests, or the internal blockingCallFromThread must
be stubbed out.
2018-02-14 01:13:30 -08:00
Brian Warner
3847339f43 _input: reject attempts to call Helper from a non-main thread
This causes two threads to use the reactor at the same time, with horrible
results. The _rlcompleter code currently violates this requirement, causing
occasional failures if the messages arrive in just the wrong way (refs #280).
2018-02-14 00:56:18 -08:00
Brian Warner
dce01174eb improve debug_set_trace: add Allocate and Input events
Also log events at the beginning and end of Input.choose_nameplate and
Input.choose_words, since those are the two big locally-driven (UI) triggers
that cause multiple messages to be fired and lots of work to happen.
2018-02-14 00:56:14 -08:00
Brian Warner
c6fbaf5a4d _version.py: hush lgtm.com alert
This needs to be upstreamed into Versioneer, as it will disappear the next
time we upgrade.
2018-01-02 08:19:08 +01:00
Brian Warner
624072c111 hush more lgtm.com -discovered static-analysis problems 2018-01-02 08:18:45 +01:00
Brian Warner
443c402f60 remove WormholeClosedError, simplify control paths in cmd_send/receive
lgtm.com noticed some unreachable code paths, and it turns out that nothing
in the rest of the code base could ever raise WormholeClosedError (I guess it
was leftover from before the big API refactoring). Both sender and receiver
are simpler without the unnecessary checks and state variables.
2018-01-01 16:56:18 +01:00
Brian Warner
e13f3e3e13 hush some unreachable-code errors found by lgtm.com
This comments out some "if 0: debug()" stuff I keep around to investigate
problems, since lgtm thinks of it as accidentally-unreachable code.

I also deleted a server usage command
entirely (src/wormhole/server/cmd_usage.py show_usage) which was disabled
while I rewrote that schema: the new plan is to move the server into a new
repository altogether, and use a completely different approach to the
usage database.
2018-01-01 16:53:18 +01:00
Brian Warner
67253bde55 test_cli: make timers more reliable
A slow Travis-CI host caused one the 1.0s KEY_TIMER to fire by accident,
making the test fail because it wasn't expecting to see the "please be
patient" message. Fixed this by increasing the timeout to a very large value
when we aren't explicitly testing it.
2017-12-19 13:41:05 -08:00
Brian Warner
c7c7c0381c update -0 and --text output too 2017-12-19 12:54:16 -08:00
David Harrigan
9b1f99b994 Change the send command output to help copy and pasting to others
A tiny update to show the command to execute along with the code required on
the same line, rather than split across two lines. This small change helps
when sending the information to others using copy and paste.

Fixes #266

-=david=-
2017-12-14 21:13:12 +00:00
Brian Warner
1bbd756fa6 test_transit: fix the miscaptured-loop-variable bug I always make 2017-12-01 13:00:05 -08:00
Brian Warner
8a7c6faf4a more test simplification with assertNoResult 2017-11-29 16:54:03 -06:00
Brian Warner
8227d963a3 test_transit: simplify by using successResultOf/failureResultOf 2017-11-29 15:03:03 -06:00
Brian Warner
d87792a7c7 finish removing Transit from code and CLI command args 2017-11-13 12:03:21 -08:00
Brian Warner
a804365536 remove most of Transit server, use external package instead 2017-11-13 11:34:17 -08:00
Brian Warner
d1a829d86f server.py: tolerate (disabled) --transit=
We were unconditionally asking the Transit server object for get_stats(),
which doesn't work if there isn't one.
2017-11-07 20:50:40 -06:00
Brian Warner
1c5f29337e add notes, make test TODO instead of SKIP 2017-11-01 17:46:09 -07:00
Brian Warner
d727531e6d send: use normpath() on argument to remove trailing slashes
This ought to help with #251, where bash-on-windows makes it easy to add a
forward-slash, and os.path.normpath() knows how to remove them, but os.sep is
a backslash.
2017-11-01 17:46:09 -07:00
Jaye Doepke
b362adf7ca Relay and transit url conf from env vars
Added the click option to look for relay and transit urls in environment
variables. If you're running your own relay/transit servers (such as
inside a corporate firewall), this will make client's lives easier.
2017-10-04 14:38:00 -05:00
Brian Warner
0aeae9ce10 tor_manager: expose errors when --tor-control-port= is provided
If you pass --tor-control-port= and we can't use it, throw an error that will
kill the whole process, instead of falling back to the default SOCKS port.

If you omit --tor-control-port=, then if all default control port connections
fail, we'll fall back to the default SOCKS port.

Also, test each combination separately, and improve the status messages.
2017-09-14 16:46:26 -07:00
Brian Warner
ed420e0001 tor_manager: pass endpoints to txtorcon.connect(), not descriptors
This was breaking any uses of --tor-control-port=: the client would always
fall back to using the default SOCKS port.
2017-09-14 15:48:35 -07:00
Brian Warner
25afce41fb _rlcompleter: re-raise exception with plain 'raise', not 'raise e' 2017-09-12 16:39:05 -07:00
Brian Warner
b9d1d11b03 server.py: windows doesn't even have the 'resource' module
I thought it might exist, but be empty. But it doesn't even exist on windows,
so we must guard against an ImportError.
2017-07-31 15:56:55 -07:00
Brian Warner
d44c7d2c1a server: increase RLIMIT_NOFILE to let us use more sockets
Linux defaults to a soft limit of 1024, which limits us to 512 simultaneous
non-transit-using connections. The transit relay runs in the same process, so
long-running relayed transfers will compete for those sockets too.

This raises the soft limit to equal the hard limit (if possible), or as much
as we can manage, if the soft limit was less than 10k. If the
resource.setrlimit calls aren't available (e.g. windows), or some other error
happens, this will log a message and continue without changing the limits.

closes #238
2017-07-31 14:16:26 -07:00
Brian Warner
0c679e74ce server.py: move twisted.web.resource out of the way 2017-07-31 14:01:54 -07:00
Brian Warner
8b0a245e19 reject invalid codes with KeyFormatError
refs #212
2017-07-23 00:02:09 -05:00
Brian Warner
de0af837cc test_cli: fix unicode problems
should fix #223
2017-07-22 23:19:43 -05:00
Brian Warner
b3b6e1ba8a test_cli: one more test, with argument split off from the name
This is probably an easier way to pass in JSON with embedded spaces:

 wormhole-server start --websocket-protocol-option 'x=["foo": "bar"]'
2017-07-15 17:39:02 -07:00
Jean-Paul Calderone
ba0e8997c5 accept protocol options and set them on the ws factory 2017-07-15 17:30:59 -07:00
Jean-Paul Calderone
aa7013e6f5 Factor duplicate RelayServer construction out 2017-07-15 17:30:59 -07:00
Jean-Paul Calderone
55b4b333dc accept some options on the cli 2017-07-15 17:30:59 -07:00
Brian Warner
fb03620fe9 test_cli: hush Click unicode_literals warnings 2017-07-15 17:27:11 -07:00
Brian Warner
1ca51168c5 add test for 'wormhole help' 2017-07-15 17:27:11 -07:00
Brian Warner
b34165d4fb 'wormhole help' should print the same thing as 'wormhole --help'
refs #61
2017-07-15 17:27:06 -07:00
Jean-Paul Calderone
efb77443bf Avoid corrupting state if creating a new db fails 2017-07-15 17:05:35 -07:00
Brian Warner
13b4a1793f server: OPEN/CLOSE on crowded mailbox should provoke "crowded" error
The Mailbox object throws CrowdedError, but WebSocketRendezvous wasn't
handling it specifically. The server responded by dropping the connection and
logging an "Unhandled Error", so the client would reconnect and then get the
same error again and again.

This changes WebSocketRendezvous to handle CrowdedError by sending a
"crowded" error response. The client should react to this by giving up on the
connection entirely, and not reconnecting.
2017-07-01 01:17:48 -07:00
Brian Warner
af4df47fe7 rendezvous: fix misleading log message
We only log the internal (sqlite) ID of the nameplate, not the actual
small-integer name. While investigating misbehavior due to overload, I was
confused into thinking that users were getting nameplates in the 15000+
range, when in fact those were merely the internal database row ids.
2017-06-30 12:46:02 -07:00
Johan Lindskogen
97b601276f Make default option of prompt uppercase
Makes it clear what happens when user just presses `Enter`

See: https://stackoverflow.com/questions/7803728/standard-format-for-yes-no-questions-in-the-terminal
2017-06-28 21:36:45 +02:00
Brian Warner
38097847c4 server: manage common args in the same way as client-side CLI
This now shares the _compose() decorator with wormhole.cli.cli, and removes
the arguments_to_config() function in favor of just copying all kwargs into
the Config object.
2017-06-26 23:05:16 +01:00
Jean-Paul Calderone
ec2e305b84 define start-like options just once 2017-06-26 21:38:18 +01:00
Brian Warner
44a44738ec take new args for 'restart' too, fixes test failure 2017-06-26 21:26:32 +01:00
Jean-Paul Calderone
6b20cb760a Take cli args for db and stats paths 2017-06-26 21:26:32 +01:00
Jean-Paul Calderone
777d722b0d Let me use FakeConfig in another test method 2017-06-26 21:26:32 +01:00