Commit Graph

147 Commits

Author SHA1 Message Date
meejah
b9c2bbc524 refactor to use IOPump: one test passes 2021-04-02 16:00:11 -06:00
Brian Warner
ca309d5283 post-rebase: update newer tests 2020-05-23 17:50:26 -07:00
Joe Harrison
45824ca5d6 Use StringTransportWithDisconnection for transit server tests.
Replace the use of TCP in the test suite with Twisted's
StringTransport, specifically StringTransportWithDisconnection which
allows us to trigger a disconnect event on the server side during testing.

The `dataReceived` method on the server is now called directly, and any
effects will be realised immediately.
Responses are available to the test client using the `value()` method of
the transport objects, and the buffer can be cleared using `clear()`.

This allows all asynchronous behaviour to be removed from the transit
server test suite.
Furthermore, as we never have to wait for the server, tests no longer
hang if they fail: the errors are encountered immediately.
2020-05-23 17:18:47 -07:00
Brian Warner
ac7415a4d0 Merge branch 'pr13' 2020-05-21 23:08:06 -07:00
Brian Warner
1a7faf0654 tolerate clients who disconnect before sending a complete handshake
If the client connected and then immediately disconnected, or disconnected
before sending enough of a handshake to be classified as good or bad, we
tried to record the usage record as if the connection was complete ("happy"),
which triggered an assertion. This dumps an error to the log and failed to
record the usage record. In May 2020, this happened 55 times in 40 days.
2020-05-21 22:49:14 -07:00
Brian Warner
1242f36624 tolerate data arriving briefly after we hang up
If the file receiver hangs up on an established connection, we do a
`transport.loseConnection()` on the buddy (the file sender). But apparently
it takes a moment (perhaps a roundtrip through the kernel) for the incoming
data to stop, and that used to cause an error. In May 2020 this happened 11
times in 40 days. Now we just ignore this late data.
2020-05-21 22:48:07 -07:00
Joe Harrison
912cfa69b6 maintain python2.7 regex library compatibility 2020-03-08 21:13:49 +00:00
Joe Harrison
0dab7a4c63 restore impatient disconnect when message received after handshake but before sent_ok 2020-03-08 19:57:44 +00:00
Joe Harrison
8f89c8aaff inline handshake parsing and explain MAX_LENGTH for transit server 2020-03-08 19:54:42 +00:00
Joe Harrison
4fdd89cb35 use line receiver to simplify handshake logic 2020-03-07 02:14:04 +00:00
Brian Warner
9758d83279 fix IPv4/IPv6 listening port
whoops, it's "::" (the unspecified address), not "::1" (the loopback address)

refs #12
2019-09-11 00:23:50 -07:00
Brian Warner
42a293213b enable SO_KEEPALIVE on all connections
This timeout is notoriously long (about two hours), but it might eventually
prune stuck connections.

refs #9
2019-09-10 23:14:29 -07:00
Brian Warner
273c4d796c change default port= to listen on both IPv4+IPv6
The default was "tcp:4001", which happens to expand into
"tcp:4001:interface=127.0.0.1", which limits the listening socket to IPv4
connections only.

Changing it to "tcp:4001:interface=\:\:1" means "listen on ::1", which is the
IPv6 name for the loopback interface, and gets us a socket that accepts both
IPv4 and IPv6 connections.

Note: this might cause incompatibilities with IPv4-only hosts, if they don't
accept the "::1" name. For these systems, run the server as `twist
transitrelay --port=tcp:4001" to revert to the old behavior.

closes #12
2019-09-10 23:09:04 -07:00
Brian Warner
6ceecb78bf add TODO for one of the moods 2019-09-10 23:05:22 -07:00
Brian Warner
a9680918b9 test_stats: try more realistic fake time.time()
Maybe windows+py36 was failing because "456" is too small of a value, and the
OS time libraries can't figure out UTC for something back in 1970. Switch to
a fixed timestamp from just a few minutes ago, to see if it likes 2018
better.
2018-02-19 13:23:40 -08:00
Brian Warner
071471a353 test_stats: mock time.time() with a float, to appease windows
For some reason, the appveyor (windows) tests fail on py36 with an OSError
during an internal (twisted.python.log) call to datetime.fromtimestamp().
It's possible that my mock times are too old (I'm using made-up values like
"456"), but maybe it's just that real time.time() returns a float instead of
an integer.
2018-02-19 13:12:14 -08:00
Brian Warner
5a762b16ad call increase_rlimits() when creating the service 2018-02-19 12:28:17 -08:00
Brian Warner
f7b8c5b19a copy increase_rlimits.py from magic-wormhole-mailbox-server
This code was originally in magic-wormhole, embedded in the server startup
code. I carved it out to a separate file (with tests) in mailbox-server, but
it should be used here too.
2018-02-19 12:26:10 -08:00
Brian Warner
098e315624 remove a few lines by using defaultdict() 2018-02-12 17:34:11 -08:00
Brian Warner
73d233a7be comment about updating 'current' row immediately, or waiting for timer 2018-02-12 17:29:27 -08:00
Brian Warner
10e754fc9a update v1 schema comments with new "redundant" mood 2018-02-12 17:04:24 -08:00
Brian Warner
4e9b6c53a9 rework mood tracking, full tests of usage events 2018-02-12 16:57:39 -08:00
Brian Warner
547ead75ba test_transit_server: factor out wait() 2018-02-12 16:55:37 -08:00
Brian Warner
b3100344eb _version.py: hush lgtm.com alert
This needs to be upstreamed into Versioneer, as it will disappear the next
time we upgrade.
2018-01-03 00:26:29 +01:00
Brian Warner
ecf3edb3f7 transit_server.py: remove unnecessary 'pass'
caught by lgtm.com analysis
2018-01-03 00:26:03 +01:00
Brian Warner
05ffcb2d55 test_transit_server: improve coverage 2017-11-09 16:39:44 -08:00
Brian Warner
c270ad6e0b DB: small cleanups, improve test coverage 2017-11-09 16:39:25 -08:00
Brian Warner
54be4cd8d3 database: add open_existing_db() for migration tool 2017-11-07 21:54:59 -06:00
Brian Warner
69d66dd4c1 database: add create-only function, for migration tool 2017-11-07 21:54:53 -06:00
Brian Warner
c6e3347e68 copy test_database from magic-wormhole package
disable the upgrader test for now, since we only have the one schema version
2017-11-07 21:44:57 -06:00
Brian Warner
0b93725709 more test coverage 2017-11-07 21:21:04 -06:00
Brian Warner
fa31777db0 increase test coverage in the bad handshake path 2017-11-07 21:09:12 -06:00
Brian Warner
65b2192e89 replace --log-stdout with --log-fd= 2017-11-07 20:35:29 -06:00
Brian Warner
ff48518e37 handle --blur-usage= correctly, log it 2017-11-07 20:14:54 -06:00
Brian Warner
9ccb0424b0 move docs out of usage and into markdown file in docs/ 2017-11-07 19:50:32 -06:00
Brian Warner
83e1c8acfe make it all basically work, improve test coverage 2017-11-07 19:39:01 -06:00
Brian Warner
a898a65b09 start on usage-db 2017-11-04 12:54:49 -07:00
Brian Warner
d36e0c44bd server_tap.py: minor docs 2017-10-26 11:36:37 +08:00
Brian Warner
849a90f0fa test_stats: more test coverage 2017-09-13 18:26:54 -07:00
Brian Warner
a1333e51cd fix unicode/json on py3 2017-09-13 18:18:29 -07:00
Brian Warner
2e0c97cea8 test_stats: start improving coverage 2017-09-13 18:14:41 -07:00
Brian Warner
b15e955fec get tests to pass 2017-09-13 17:51:55 -07:00
Brian Warner
26efac7da9 transit_server.py: rewrite stats 2017-09-13 17:24:37 -07:00
Brian Warner
ea9e24913c more WIP 2017-09-13 12:29:51 -07:00
Brian Warner
c287175d38 remove unused files
This server won't use a database, just a logfile and statsfile. And it
doesn't have a CLI command, just a twist/twistd plugin.
2017-09-13 00:39:10 -07:00
Brian Warner
0dc3fd5e7e write the twist/twistd plugins and setup code 2017-09-13 00:37:29 -07:00
Brian Warner
46abd75fda move transit-relevant files out from magic-wormhole
These files are copied (with roughly-appropriate changes to the top-level
setup.py, NEWS.md, etc) from magic-wormhole 0.10.3, commit
be166b483c5796ab3a9ad588ccf671b7eabdd96c).
2017-09-12 23:52:21 -07:00