Configuring custom NWProtocolFramer.Options

Is it possible to pass in custom configuration options to an instance of NWProtocolFramerImplementation that it can use while it is handshaking (i.e. before calling .markReady())? I can’t see any way to do it, currently.

For example, I have written a framer to handle a STARTTLS handshake for SMTP. Before calling prependApplicationProtocol to start TLS, I set up some custom NWProtocolTLS.Options. It works, but only if I hard-code those custom TLS options. If, for example, I wanted to be able to allow the user to select a minimum TLS version, I don’t see a clean way currently to pass in that custom configuration to my instance of NWProtocolFramerImplementation.

Any thoughts? Or should I file an enhancement request?

Similar problem as found here: https://developer.apple.com/forums/thread/130498

Thank you!
Jonathan
There isn't a built-in way to pass per-connection custom options via Swift framers. You can certainly have a lookup table on the side for which options to use, but that doesn't fall into the "clean" category.

In C, the framer is defined by a block, and you can actually have one block that captures unique state per connection if you want.

Code Block C
block nw_protocol_options_t tls_options = ...
nw_protocol_definition_t definition = nw_framer_create_definition("my_framer", NW_FRAMER_CREATE_FLAGS_DEFAULT, ^nw_framer_start_result_t(nw_framer_t framer) {
nw_framer_set_input_handler(framer, ^size_t(nw_framer_t parser) {
...
/* Use tls_options */
});
nw_framer_set_output_handler(framer, ^(nw_framer_t writer, unused nw_framer_message_t message, size_t message_length, __unused bool is_complete) {
...
});
return nw_framer_start_result_will_mark_ready;
});
... nw_framer_create_options(definition);


Please feel free to file an enhancement for the Swift version!
Thank you for your help!
Configuring custom NWProtocolFramer.Options
 
 
Q