131 Commits

Author SHA1 Message Date
Peter Adams
0f878f95f0
Performance testing for NIO PCAP logging (#98)
Motivation:

It's useful to know the overhead we could be adding by including
the PCAP handler.

Modifications:

Add a new executable based on the NIO performance testing executable.

Result:

There is a new executable which runs a short test of sending and receiving
data through the HTTP/1 handler using multiple eventloops and showing
three options.
1) Vanilla
2) With in memory PCAP never written to disk
3) With a disk based PCAP.
2020-08-03 12:13:24 +01:00
gkaindl
d525d3bbd1
Ensures gzip/deflate-compressed responses are properly finalized in all cases (#100)
Motivation:

Previously, when using the response compressor, doing a flush() right before finishing the
response data would cause the final compression chunk to be omitted. Some strict decompressors
(such as gzip or the zlib functionality exported in nodejs) would refuse to decompress the
incomplete response.

With this change, the generated compressed response is properly finalized.

Modifications:

In HTTPResponseCompressor.swift, a channel write is now also generated if no body data is
added, but a flush is required.

Result:

The response is now correct for this edge case, enabling gzip, nodejs, et al., to
decompress it without errors.
1.6.0
2020-07-28 17:33:35 +01:00
David Evans
6740bf98c2
Silence #file warnings (#97)
* Wrap in parentheses

* Revert previous changes
2020-07-24 16:54:32 +01:00
David Evans
1cb9e9e24b
Fix #file warnings (#96)
* Fix #file warnings
2020-07-24 14:54:39 +01:00
Peter Adams
fe17f53108
Capture packets leading upto a user triggered event. (#94)
Motivation:

Capturing all packets is expensive. Recording to a ring buffer and
then outputting on a triggering event allows this cost to be reduced.

Modifications:

Add a new handler - NIOPCAPRingCaptureHandler.
This derives from the existing NIOWritePCAPHandler and generates PCAP recordings.
A ring buffer contained in this handler stores the captured packets until RecordPreviousPackets
is received as a user message at which point they are flushed to the sink.

Result:

There is a new handler capable of outputting packet captured data only in the build up to
a known event.

Co-authored-by: Cory Benfield <lukasa@apple.com>
Co-authored-by: George Barnett <gbrntt@gmail.com>
2020-07-24 13:55:12 +01:00
Fabian Fett
b8fd38c1db
Support decompression of HTTP responses that do not contain a Content… (#93)
Fixes #78

Co-authored-by: Trevör Anne Denise <trevor.annedenise@icloud.com>
2020-07-24 11:12:09 +01:00
Peter Adams
85f13dd3ba
Don't install jazzy on xenial (#95)
Motivation:

Ubuntu 16 ruby is too old to support latest cocoapods gem.

Modifications:

Don't install jazzy when on xenial

Result:

Docker image will now build - you need to use bionic images to build documentation.
2020-07-21 16:05:29 +01:00
Johannes Weiss
68af66e329
link swift-nio-extras in docs (#87) 2020-06-17 16:45:20 +01:00
George Barnett
157853a29b
Update build_podspec.sh to not use exact dependency versions (#91)
Motivation:

The build_podspec.sh script generates a podspec which requires exact
versions of its dependencies. This very quickly turns into unresolvable
dependency graphs.

Modifications:

NIO version passed to script must be in the format MAJOR.MINOR
Podspec dependencies are now '>= MAJOR.MINOR', '< MAJOR+1'

Result:

Looser version requirements for podspecs
2020-06-17 09:32:40 +01:00
Johannes Weiss
7cd24c0efc
WritePCAPHandler: support logging more than 4GiB of data (#85)
Motivation:

Previously, WritePCAPHandler would crash if more than 4GiB of data were
either received or sent through the same instance of the
WritePCAPHandler because of a UInt32 overflow representing the TCP
sequence/ACK numbers.

Modifications:

Make TCP sequence/ACK numbers wrap around correctly.

Result:

- now you can send/receive up to 16 EiB of data :P.
- fixes rdar://61887658
1.5.1
2020-05-18 11:37:20 +01:00
Trevör
f21a87da13
Merge pull request from GHSA-xhhr-p2r9-jmm7
Motivation:
NIOHTTPRequestDecompressor and HTTPResponseDecompressor are both affected by an issue where the decompression limits defined by their DecompressionLimit property wasn't correctly checked when is was set with DecompressionLimit.size(...), allowing denial of service attacks.

Modifications:
- Update DecompressionLimit.size(...) to correctly check the size of the decompressed data.
- Update test cases to avoid future regressions regarding the size checks.

Result:
Prevents DoS attacks though maliciously crafted compressed data.
1.5.0
2020-05-02 09:29:33 +01:00
Adam Fowler
020e322a65
Added NIOHTTPRequestCompressor to compress requests (#88)
* Added NIOHTTPRequestCompressor to compress requests

Also moved common code from request and response compressor into separate NIOHTTPCompression enum.

* Updates after comments from @weissi

Also reinstated public enum HTTPResponseCompressor.CompressionError

* algorithms are now let not var

* Catch situation where head is flushed before anything else comes through

Content-encoding was not being set
Added additional tests for header values

* Added documentation around 5 bytes added to buffer size and add them

* Renaming NIOHTTPCompressionSetting to NIOCompression

Also
NIOHTTPCompressionSetting.CompressionAlgorithm is NIOCompression.Algorithm
NIOHTTPCompressionSetting.CompressionError is NIOCompression.Error
Algorithm now conforms to Equatable

* Forgot to run generate_linux_tests

* Fix typos
2020-04-30 17:28:49 +01:00
George Barnett
0f26138ae4
Let 2020 be an acceptable year in license headers (#89)
Motivation:

It's 2020; our license checking script should believe that that is an
acceptable year.

Modifications:

- Update scripts/sanity.sh

Result:

2020 is okay in license headers.
2020-04-30 16:29:36 +01:00
Johannes Weiss
5e234667a9
fix docker setup (#86)
Motivation:

We were missing the 5.2 & 5.3 docker compose files and also the syntax
wasn't flexible enough to pull in the new nightlies.

Modifications:

- always specify the full image name
- add 5.2 & 5.3

Result:

More CI & newer Swifts.
2020-04-17 18:40:39 +01:00
Shekhar Rajak
4a71e8ad6e
Get rid of do { ... } catch { ... } for expected errors (#84)
Co-authored-by: Cory Benfield <lukasa@apple.com>
2020-03-18 07:53:09 +00:00
tomer doron
64cb1e3bbb
add doc generation script (#80)
motivation: publish api docs for helper modules

changes
* add doc publishing script
* add "shell" docker-compose task to help run document publishing from ci

Co-authored-by: Johannes Weiss <johannesweiss@apple.com>
2020-03-03 10:33:33 +00:00
David Evans
8a48d4d228
Fix typo (#82) 2020-03-02 16:07:23 +01:00
tomer doron
57c869c174
improve docker security (#77)
motivation: more secured ci setup

changes:
* enable :z selinux flag on bind mounts so we can enable selinux on ci
* drop potentially exploitable capabilities from docker-compose
2020-02-04 10:25:56 +00:00
Andy Trevorah
b4dbfacff4 Add syntax highlighting to installation steps (#76) 1.4.0 2020-01-21 11:43:43 +00:00
Johannes Weiss
a98eabea3f
NIOWritePCAPHandler: make pcap issuing configurable (#75) 2020-01-20 15:15:36 +00:00
Johannes Weiss
698f4f7396 WritePCAPHandler: write outbound data on flush not write (#74) 2020-01-17 14:12:34 +00:00
George Barnett
b1d473d476 Update Code of Conduct project maintainer email address (#73)
Motivation:

The code-of-conduct email address is out-of-date.

Modifications:

Update code-of-conduct email address to swift-server-conduct@group.apple.com

Result:

- Code of conduct email address is up-to-date.
2019-12-02 12:19:33 +00:00
Johannes Weiss
53808818c2
don't use @tesable import NIO in test suite (#72)
Motivation:

The test suite for some reason imported NIO as @testable which is
verboten.

Modifications:

Don't do that.

Result:

Feeling better, compatible with the upcoming NIO 2.10.1.
1.3.2
2019-11-13 18:41:37 +00:00
Thomas Krajacic
6d452710b2 Clean up test command in docker config files (#70) 2019-10-30 12:53:35 +01:00
Thomas Krajacic
fa4caf3c93 Add api checker script (#69)
* Add api checker script

* Fix comment to match the tag in the sample command
2019-10-30 12:27:39 +01:00
Thomas Krajacic
12ed4f0f43 Add --sanitize=thread to test invocation (#68) 2019-10-30 10:15:09 +01:00
Johannes Weiss
4a5cd66d63 test runner: add -x to bash invocations (#67)
Motivation:

It's important to see the commands that are run in CI.

Modification:

Add -x to the bash invocations.

Result:

More clarity on what is run.
2019-10-26 02:52:39 -07:00
tomer doron
a8382b8f67 update docker setup (#66)
motivation: use official docker images, fix swift 5.1 ci

changes:
* use official docker images
* include zlib1g-dev since its required for 5.1 ci
2019-10-26 02:34:18 -07:00
Johannes Weiss
f2b9696306 cleanup CI (#63) 2019-10-25 17:10:09 -07:00
Johannes Weiss
64c4d22ba5 follow general parser guidelines, even in tests (#62) 2019-10-25 01:30:08 -07:00
Artem Redkin
ed97628fa3 fix NIO 2.9.0 deprecations (#61)
Motivation:

Usage of deprecated methods is bad.

Modification:

Fix usage of deprecated methods.

Result:

Fewer warnings.
1.3.1
2019-10-23 17:23:34 -07:00
Caleb Kleveter
0584020dca Gzip request decompress (#59)
### Motivation:

There will be times when a client wishes to send larger requests with gzipped bodies to save on network traffic. This PR adds a `NIOHTTPRequestDecompressor` which can be added to the server's channel pipeline so those requests are automatically inflated.

### Modifications:

- Added a `CNIOExtrasZlib_voidPtr_to_BytefPtr` C method.
- Added a `NIOHTTPRequestDecompressor` type.
- Added a `HTTPResponseDecompressorTest` test case.

### Result:

Now you don't have to manually check the `Content-Encoding` header and decompress the body on each incoming request.
1.3.0
2019-10-10 13:51:07 +01:00
Artem Redkin
16fbdf3868 extract common classes for server request decompressor (#60)
* extract common classes for server request decompressor

* review fix: make fields private and make state part of the handler

* review fixes

* review fix: reserve capacity before inflating
2019-10-08 12:23:32 +01:00
Artem Redkin
863c6b55c6 add http client decompressor (#56)
### Motivation:
Many HTTP servers can send compressed responses to clients and it would be a great feature for `AsyncHTTPClient` to support it. But since we want to minizime usage of unsafe APIs in SSWG projects, I propose to consolidate interfacing with zlib to `nio-extras` since it already supports `zlib` compression.

### Modifications:
Added `HTTPResponseDecompressor` and accompanying tests

### Result:
Users (primarily `AsyncHTTPClient`) can now provide automatic response decompression support.
2019-10-02 15:39:46 +01:00
tomer doron
42643c9100 update conduct email group (#55)
motivation: use consistent email across swift server projects

changes: set conduct email address to swift-server-conduct@group.apple.com
2019-08-20 20:31:34 +01:00
Johannes Weiss
5a2fc66068
ServerQuiescingHelper: don't swallow close errors (#54)
Motivation:

ServerQuiescingHelper used to swallow close errors and it shoulnd't do
that.

Modifications:

Don't swallow close errors.

Result:

More correctness.
2019-08-07 18:05:47 +01:00
Johannes Weiss
66f9a509ed
use B2MD verifier (#52)
Motivation:

Use B2MDVerifier for the B2MDs in NIOExtras. Already found one bug,
separetely fixed in #51.

Modifications:

Write a basic validation test for all B2MDs.

Result:

Better test coverage.
1.2.0
2019-05-28 11:28:59 +01:00
George Barnett
3a9ddcaf3e Update target versions in podspec generation script (#50)
Motivation:

The script to generate a podspec used the minimum platform versions for
NIOTS instead of NIO.

Modifications:

Lower the minimum platform version to match those supported by NIO.

Result:

Larger Cocoapods platform support.
2019-05-22 16:42:27 +01:00
Johannes Weiss
c38fb10f50 JSONRPC framing: Content-Length (#53)
Motivation:

JSPN-RPC uses various framing methods, one is Content-Length based
framing. NIOExtras should provide encoder/decoders for this.

Modifications:

Add such codecs.

Result:

NIOExtras more useful
2019-05-13 10:37:25 -07:00
Johannes Weiss
bddf6c5d74 LineBasedFrameDecoder: tolerate drip fed \r\n (#51)
Motivation:

LineBasedFrameDecoder previously would only correctly decode \r\n as a
line-ending iff \r\n were not split apart.

Modifications:

Handle \r\n arriving apart.

Result:

more correct line splitting
2019-05-10 19:04:33 +01:00
Romain Pouclet
1d1e76cf79 Add a podspec for NIOExtras (#48)
Motivation:

https://github.com/apple/swift-nio-extras/issues/45

Modifications:

Add a podspec

Result:

Happy cocoapods users
2019-04-16 20:00:32 +01:00
Johannes Weiss
88530fd1d2 README: Add missing handlers (#47)
Motivation:

README has an overview with the handlers that NIOExtras provides, some
were missing.

Modifications:

Add the missing ones.

Result:

Better README.
2019-04-12 16:53:17 +01:00
Johannes Weiss
96e8335180
write PCAP handler (#46)
Motivation:

Especially with TLS but also without, in real production environments it
can be handy to be able to write pcap files from NIO directly.

Modifications:

add a ChannelHandler that can write a PCAP trace from what's going on in
the ChannelPipeline.

Result:

easier debugging in production
1.1.0
2019-04-12 15:08:10 +01:00
Johannes Weiss
aad5c1ca6a update the readme for NIO2 (#43)
Motivation:

Again, we had some outdated information in the README file.

Modifications:

fix the outdated info.

Result:

more accurate information.
2019-03-27 09:44:25 +00:00
Johannes Weiss
3431d30113 use Swift 5.0 release (#42) 2019-03-26 11:19:43 +00:00
Johannes Weiss
ef608e41a9
use SwiftNIO 2.0.0 (#41) 1.0.0 2019-03-26 09:16:40 +00:00
Johannes Weiss
b7a3549b63
update to latest EmbeddedChannel API (#40)
Motivation:

EmbeddedChannel's API has changed a litle bit, we should update.

Modifications:

update

Result:

code will continue to work
1.0.0-convergence.2
2019-03-22 14:00:12 +00:00
Johannes Weiss
1c39f44412
LineBasedFrameDecoder: Don't discard everything after EOF (#39)
Motivation:

LineBasedFrameDecoder discarded everything after EOF and delivered it in
the left-over bytes error. For the real world however that doesn't make
much sense, you'd want all previously received lines and only receive
the partial lines as left-overs.

Modifications:

deliver lines until there are only partial lines left, even in case of
EOF.

Result:

LineBasedFrameDecoder more useful
2019-03-21 14:55:21 +00:00
Liam Flynn
66c13a41c7 Motivation: (#38)
Fixing a broken link in the readme file.

Modifications:

A single character correction in the readme file.

Result:

Improved pedanticism and/or readability depending upon the readers perspective.
2019-03-20 11:29:40 +00:00
Johannes Weiss
7d42934f15
depend on swift-nio: 2.0.0-convergence.1 (#37)
Motivation:

to tag versions, we shouldn't depend on `.branch("master")`

Modifications:

depend on swift-nio: 2.0.0-convergence.1

Result:

ready to soon tag the first version
1.0.0-convergence.1
2019-03-08 19:17:38 +00:00