Commit Graph

108 Commits

Author SHA1 Message Date
Yim Lee 1a140b8c06
Add .spi.yml for Swift Package Index DocC support (#166) 2022-12-03 07:54:09 +00:00
Cory Benfield e676b1f044
Expose multicast service type (#165)
Motivation

As we've rolled out support for multicast on Linux, it makes sense to
add equivalent configuration for swift-nio-transport-services. The two
features aren't one-to-one, as Network.framework has substantially more
capability than the Linux functionality.

Modifications

- Expose a multipathServiceType channel option
- Add a test to confirm we use it properly

Result

Multicast service types are available.
2022-11-09 11:00:20 +00:00
carolinacass d3345ffc2a
Use #fileID/#filePath instead of #file (#164)
Motivation:

#fileID introduced in Swift 5.3, so no longer need to use #file anywhere

Modifications:

Changed #file to #filePath or #fileID depending on situation
2022-10-31 11:59:12 +00:00
David Nadoba c0d9a144cf
Allow retrieval of metadata from `NWConnection` (#163)
* Allow retrieval of metadata for a specific protocol from the underlying `NWConnection`

* Address review comments

* Address review comment

* Add availability annotation to tests

* Rename `NIOTSChannelIsNotATransportServicesChannel ` to `NIOTSChannelIsNotANIOTSConnectionChannel `
2022-10-19 15:59:33 +01:00
David Nadoba de5ea3d0b4
Fix Swift 5.5 (#162) 2022-10-13 14:47:28 +01:00
David Nadoba 330f4ee104
Remove `#if compiler(>=5.5)` (#161) 2022-10-13 12:50:25 +01:00
George Barnett 8fda939e1b
Raise minimum supported Swift version from 5.4 to 5.5 (#158)
Motivation:

SwiftNIO periodically drops support for older Swift versions. Now that
5.7 has been released, 5.4 will be dropped.

Modifications:

- Remove 5.4 specific Package.swift and docker-compose
- Update the 5.7 docker-compose to use the released 5.7 and move from
  focal (2004) to jammy (2204)
- Update docs

Results:

Minimum Swift version is 5.5
2022-09-29 01:23:09 -07:00
George Barnett b6e37a0d44
Add missing availability annotation to NIOTSConnectionBootstrap (#160)
Motivation:

- NIOTSConnectionBootstrap was extended to be marked as non-Sendable,
  this extenion missed the availability annotations.

Modifications:

- Add appropriate availability annotation

Result:

Resolves #159
2022-09-28 16:04:35 +01:00
Cory Benfield b39e53ad42
Replace Lock with NIOLock (#157)
Motivation:

Lock has been deprecated in favour of NIOLock. Warnings aren't great.

Modifications:

- Replace Lock with NIOLock
- Update the minimum required NIO version to 2.42.0.

Result:

Everything builds cleanly
2022-09-27 13:48:00 +01:00
carolinacass 5cd6fd45f7
Launching Services with existing NWConnection or NWListener objects (#156)
NIO Transport Services is not capable of launching services with existing NWConnection or NWListener objects. Being able to get
an existing NWConnection through a connection bootstrap and into a channel is a useful capability for advanced use cases.

Modifications:
* Added an option to bootstrap with existing NWListener and NWConnection
* Completed promise connection earlier within NIOTSChannels when AlreadyConfigured is called
* Added test with new NWConnection and NWListener to register Channels

Result:
Able to create and register a channel using an existing NWListener and NWConnection
2022-09-21 10:52:08 +01:00
David Nadoba c2e373fec5
Adopt `Sendable` (#155)
* Adopt `Sendable`

* Workaround Swift 5.4 compiler bug
2022-08-31 16:22:32 +01:00
Cory Benfield 4e02d9cf35
Use Docc for documentation (#154)
Motivation

Documentation is nice, and we can help support users by providing useful
clear docs.

Modifications

Add Docc to 5.6 and later builds
Make sure symbol references work
Add overview docs

Result

Nice rendering docs
2022-07-29 15:02:01 +01:00
David Nadoba 94645c8fcd
Use `swift-atomics` instead of `NIOAtomics` (#153) 2022-07-07 17:50:28 +01:00
Cory Benfield 605f7a4c55
Add defensive lifetime management for security metadata (#152)
Motivation:

Right now we're playing a little fast and loose with the lifetimes of
the sec_protocol_metadata_t. As a practical matter it is highly likely
that this is owned (and so kept alive by) the NWConnection, but rather
than risk that we should tighten up the lifetime management.

Modifications:

Use withExtendedLifetime to extend the lifetime.

Result:

Better lifetime management.
2022-07-05 09:25:11 +01:00
Cory Benfield acb6425a09
Use 5.7 nightlies. (#151) 2022-06-13 04:04:36 -07:00
George Barnett 2cb54f91dd
Remove outdated docs from README (#150)
Motivation:

We no longer support Cocoapods and `swift package generate-xcodeproj` is
deprecated, so we shouldn't advertise their usage in the README.

Modifications:

Remove Cocoapods and `swift package generate-xcodeproj` sections from
the README.

Result:

More up-to-date README
2022-06-09 14:46:12 +01:00
Cory Benfield 7d09200afa
Don't close when waiting unless we were asked to. (#149)
Motivation:

When we're waiting for connectivity, the user might tell us that they
aren't interested in waiting. In that case we take advantage of the
signal and close early.

However, the code as-written had a bug: we didn't care whether the user
told us they _didn't_ want to wait, or they _did_: we just closed
because they had an opinion! That's no good! We should only close if
they don't want to wait.

Modifications:

- Only close if the user doesn't want to wait.
- Add tests

Result:

We won't close if users don't want us to.
2022-06-07 14:36:37 +01:00
František Mikš e90ac29391
change NIOTSNetworkEvent initializers visibility to pubilc level (#148) 2022-06-06 03:35:54 -07:00
Cory Benfield 5a7a9b7875
Tweak testConnectingInvolvesWaiting to avoid invoking Private Relay (#146)
Motivation:

Private Relay kicks in to secure unencrypted data transfers, and
connections to port 80 are a good signal. As a result, the current
construction of this test will invoke Private Relay and attempt to route
over it.

While Private Relay is in beta this is a bad outcome, as it risks
causing bugs in unusual network scenarios. So let's tell Private Relay
we don't need it.

Modifications:

Pretend we're gonna connect to 443 instead.

Result:

More reliable test.
2022-05-25 07:41:33 -07:00
George Barnett 936bc0487a
Remove build_podspec.sh (#144)
Motivation:

We no longer support Cocoapods

Modifications:

- Remove build_podspec.sh

Result:

Fewer unused files
2022-05-04 11:03:16 +01:00
George Barnett cf4cd97ec2
Update podspec script (#143)
Motivation:

To workaround https://github.com/apple/swift-nio/issues/2073 we must
list all transitive dependencies when building podspecs.

Modifications:

- Include transitive dependencies in the build_podspec script
- The list of dependencies was generated using
  the `list_transitive_dependencies.py` from the NIO repo.

Result:

Podspec generation script includes transitive dependencies.
2022-05-03 09:58:06 +01:00
Fabian Fett 1a4692acb8
Fix warnings, that appeared after requiring Swift 5.4 (#142) 2022-04-21 09:12:31 -07:00
Fabian Fett b559a7303a
Drop support for Swift 5.2 and 5.3 (#141)
As outlined in a [Swift forums post in November ’21](https://forums.swift.org/t/swiftnio-swift-version-support/53232), SwiftNIO will only support the latest non-patch Swift release and the 2 immediately prior non-patch versions.

- drop support for Swift 5.2 and 5.3. 
- update CI for Swift 5.4 to run on bionic instead of focal to ensure that we still test bionic. 
- add a CI job for Swift 5.7
2022-04-20 08:54:39 +02:00
Cory Benfield 22d92ad93c
Add 5.6 nightly CI (#140)
* Add 5.6 nightly CI

The 5.6 nightly images are available, let's use them.

* Add 5.5 as well
2022-01-18 09:37:53 +00:00
George Barnett 8ab824b140
Explicitly retain timer source when scheduling tasks (#138)
Motivation:

When a task is scheduled using a `DispatchTimerSource` on a `NIOTSEventLoop`
the source is retain via a callback on the promise associated with the
scheduled task. This stops the source from deinit'd before the task is
run. However, the callback being added is an implementation details of
`Scheduled` and the retain cycle is incidental.

If that detail chnaged (such as in
https://github.com/apple/swift-nio/pull/2011) then tasks may not run and
the promise could be leaked.

Modifications:

- Explicitly add a retain cycle between the future and the timer source
  which is broken by the promise being completed and callbacks run.

Result:

The timer source is kept alive until the event fires.
2022-01-12 10:37:50 +00:00
Cory Benfield e7f5278a26
Clean up imports and dependencies. (#130)
Motivation:

With NIO 2.32.0 we broke the core NIO module up into modules that split
apart the POSIX layer and the core abstractions. As a result, this
package no longer needs to express a hard dependency on the POSIX layer.

Modifications:

- Rewrote imports of NIO to NIOCore.
- Added NIOEmbedded imports where necessary in tests.
- Note that the main package still _depends_ on NIO, which is necessary
  for backwards-compatibility reasons. This dependency is unused.

Result:

No need to use NIOPosix.
2021-09-14 10:06:42 +01:00
Peter Adams 9571a61d23
Move check for event loop shutdown into taskQueue (#127)
Motivation:

The event loop state is not protected for access on different threads.
This means it must only be accessed from the task queue.

Modifications:

Move check for event loop shutdown into taskQueue

Result:

Event Loop state only accessed from the task queue.
2021-08-19 10:57:47 +01:00
George Barnett 5fd5ba4d3e
Use non-deprecated API for removing handlers (#125)
Motivation:

`removeHandlers(channel:)` was deprecated in NIO 2.32.0.

Modifications:

- Raise minimum required NIO version to 2.32.0
- Use `removeHandlers(pipeline:)`

Result:

We don't use deprecated API.
2021-08-17 18:01:25 +01:00
David Evans 39587bcecc
Update NIO to 2.30 (#123) 2021-06-23 14:16:15 +01:00
David Evans 0aecfe8b3a
Remove Swift 5.0 and 5.1 support, and add CI config (#122)
* Setup CI and update Package

* Rename sanity to soundness

* Apply suggestions from code review

Co-authored-by: Cory Benfield <lukasa@apple.com>

* Fix nightly docker config

Co-authored-by: Cory Benfield <lukasa@apple.com>
2021-06-23 08:57:00 +01:00
Johannes Weiss 188a295ee3
docker setup for main nightlies (#114) 2021-06-22 18:47:35 +01:00
Johannes Weiss 47fddadf83
stop publishing the executable products (#119) 2021-06-08 14:04:45 +01:00
George Barnett 657537c2cf
Add support for syncOptions to NIOTSListenerChannel and NIOTSConnectionChannel (#117)
Motivation:

NIO 2.27.0 added optional support for synchronous channel options.
NIOTSListenerChannel and NIOTSConnectionChannel should support this.

Modifications:

- Add synchronous options for NIOTSConnectionChannel and
  NIOTSListenerChannel
- Avoid an allocation in 'getOption' for each channel if the caller is
  already on the right event loop by using 'makeSucceededFuture'
- Remove a no longer used internal function and an already dead private
  helper

Result:

- Support for sync options and fewer allocations
2021-03-16 08:38:47 +00:00
George Barnett b9fd95b8d5
Add SECURITY.md (#116) 2021-03-09 11:14:29 +00:00
Johannes Weiss 1d28d48e07
update code of conduct to version 1.4 (#115) 2021-02-17 14:16:51 +00:00
Cory Benfield 5c90846c1b
Tolerate out-of-band ports. (#112)
Motivation:

We shouldn't crash if the user gives us a bad port.

Modifications:

- Check the ports are in-band before we move on.

Result:

We won't crash.
2021-01-27 14:37:00 +00:00
George Barnett 9fc0d32e07
Remove a redundant availability check (#109)
Motivation:

xcodebuild complains during Cocapods validation (which fails as a
result) about a redundant availability check. It's redundant because for
watchOS the availability guard on the outer scope has the same
conditions (for other platforms the conditions are tighter in the
inner scope). We never hit this before because we only recently added
watchOS to the supported platforms for Cocapods.

Modifications:

- Remove a redundant availability check

Result:

- Cocapods can validate without error
2020-11-27 09:27:39 +00:00
Cory Benfield 5a352330c0
Remove agressive precondition in zero-length-writes. (#108)
Motivation:

The zero-length writes handler will crash if it receives channelInactive
before channelActive. Sadly, that's totally possible if a channel is
closed from the connect promise.

Modifications:

- Tone back the preconditions a bit.
- Add a test that triggers this path.

Result:

Channel handler behaves better on early close
2020-11-24 13:21:50 +00:00
George Barnett 18c17b9ae0
Add watchOS deployment to PodSpec build script (#107)
Motivation:

We support watchOS 6+ with SwiftNIO Transport Services; as such we should
include watchOS as a deployment target for our CocoaPods.

Modifications:

- Add a watchOS deployment target to `build_podspecs.sh`

Result:

Users can deploy to watchOS 6+ with CocoaPods.
2020-10-19 10:11:40 +01:00
Cory Benfield 698e0eed47
We use the main branch now. (#105) 2020-09-24 16:28:15 +01:00
Cory Benfield bb56586c4c
Avoid crashing when connecting to empty host. (#103)
Motivation:

Network.framework will crash when we attempt to connect to the host
string "". That's not ideal, so we should detect that case and avoid it.

Modifications:

- Add code to detect the empty host string.

Result:

No crashes when accidentally connecting to "".
2020-08-11 10:10:17 +01:00
Peter Adams 71dbab3f12
Fix docker shell to use correct image. (#102)
Motivation:

Docker shell was incorrectly using the swift-nio docker image
rather than the swift-nio-transport-services one.

Modifications:

Change docker compose file to use the correct image.

Result:

Correct image will be used for docker shell.
2020-08-04 09:23:12 +01:00
Peter Adams d40a5e34e5
Add docker config for swift-nio-transport-services (#99)
Motivation:

It's important that transport-services compiles and does nothing
on linux so it can be used in builds which just do the right thing
on all platforms.

Modifications:

Add basic docker-compose files based on those from swift-nio

Result:

It's possible to run docker on this repo to run the tests.
2020-07-24 08:39:46 +01:00
Peter Adams cd49a10c4f
Directly support the allowLocalEndpointReuse channel option (#82)
Motivation:

The NetworkFramework directly supports the concept of allowLocalEndPointReuse. Currently to get through the nio system, this is mapped to the SO_REUSEADDR option.

Now there is a shorthand option for this, it is sad to map from allowLocalEndPointReuse to SO_REUSEADDR and back again.

Modifications:

Add a new NIOTS channel option for this setting.
Set the underlying based on any of new setting, reuseAddr or reusePort.
Add a override to interpret the shorthand option directly into the new option.
Add shorthand options for client with tests of equivalence to long options.

Result:

Behaviour is identical but we can feel happier that the option mapping is less confusing.
2020-07-01 14:51:31 +01:00
Cory Benfield f9a95e9bbb
Update watchOS availability. (#98)
Motivation:

In a patch where we added some metadata options, we accidentally set the
availability wrong. This is a compile-time error, so we broke watchOS
compilation.

Modifications:

Update the availability of some types on watchOS.

Result:

Users can build on watchOS again.
2020-06-19 10:19:47 +01:00
Johannes Weiss 9f7dff10ad
silence #file to #filePath differently (#96)
Motivation:

only works if done when _calling_ a function, not when defining one :|.

- https://github.com/apple/swift/pull/32445
- https://bugs.swift.org/browse/SR-12936
- https://bugs.swift.org/browse/SR-12934
- https://bugs.swift.org/browse/SR-13041

Modifications:

Silence #file to #filePath differently.

Result:

Hopefully at some point we get this working.
2020-06-18 13:09:01 +01:00
George Barnett 7eeb0ca94c
Update build_podspec.sh to not use exact dependency versions (#93)
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 13:07:45 +01:00
Cory Benfield 2937017e27
Add user event fired when waiting for connectivity. (#95)
Motivation:

On Apple's devices it is considered a best practice to wait for network
connectivity in cases when a connection request cannot immediately be
satisfied, rather than erroring out. This reflects the dynamic and fluid
network environment on Apple devices, with their many network interfaces
and complex interactions between radios, VPNs, and network devices.

While NIOTS supports this model of interaction (and indeed uses it out
of the box), and supports configuring it (by setting
`NIOTSChannelOptions.waitForActivity`), a key pillar is missing:
observability. Right now we don't actually _tell_ the user when we're
waiting for connectivity. This makes it difficult to act on this
information.

Modifications:

- Added a user event, `NIOTSNetworkEvents.WaitingForConnectivity` that
  is fired when connectivity could not be established, but the situation
  may change in future.

Result:

Our users can tell their users when they're waiting for something!
2020-06-17 09:38:07 +01:00
Johannes Weiss 2ac8fde712
silence #file to #filePath warning (#91) 2020-06-08 17:50:28 +01:00
Pasi Salenius 7e330732f2
New channel options exposing properties of underlying NWConnection (#90)
* Initial draft implementation of new channel options for NWConnection.currentPath, metadata for a given NWProtocol, establishment report and data transfer report. Add a new error for not existing connection. Add tests for all of these. The data transfer report option has to be implemented in another way, as the collection of the final data transfer report does not seem very straightforward.

* Fix incorrect available attributes. Make the Value of NIOTSEstablishmentReportOption an EventLoopFuture returning an optional report. Move handling of NIOTSEstablishmentReportOption and NIOTSDataTransferReportOption to getOption0. Remove nwConnection0().

* Use full type on currentPath too.

* Add a DispatchQueue to do collect of the pending data transfer report, use a DispatchGroup to wait for completion of report collection. Remove redundant attribute. Fix nits related to spacing and file header.

* Fix available attributes for tests too.
2020-06-01 11:52:56 +01:00