Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why
The
ngrok
backend is now accepting a new field for policy calledTrafficPolicy
. Unlike the originalPolicy
field which was a highly structured protobuf, this new field is simply a string. The SDK therefore needs to be supported to send this new String policy field to the backend.Additionally, we want users who are using the old
Policy
field to still be able to use that until we fully deprecate inbound/outbound so they only have to update their code once. Therefore, this change also serializes the oldPolicy
field as a JSON string and sends it to the backend asTrafficPolicy
.How
The policy field in the proto representation was renamed to
TrafficPolicy
and changed to a new enum type calledPolicyWrapper
. This new enum allows it to be either aString
(new configuration) or aPolicy
(old configuration). For string, this just gets sent as is, over the wire, which works. ForPolicy
, a new serialization method was added to convert it into a string upon serialization. Additionally, the serialization for action configs had to be updated to convert it from aVec<u8>
to aString
.In the BindOpts for each connection type, the
PolicyWrapper
is populated by either theString
or thePolicy
type, depending on what the user set.Validation
Tunnels using the old
Policy
stuff and the newTrafficPolicy
field were opened through theaxum
example. Both successfully started and had working policy.A unit test was added to make sure
Policy
serializes and deserializes as we expect.Why did I update the flake?
I was getting an error from a number of different CI test, stating that the
#[diagnostic]
namespace is experimental. I found this thread stating that it could be caused by using an outdated version of rust nightly. Considering we hadn't updated since Feb, I ran a quicknix flake update
and everything seemed to work.