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
This is part of an effort to remove strict PolicyEngine definitions from our public SDKs. By doing so, we can rapidly iterate changes to the PolicyEngine without having to update client definitions every single time. The backend has already been updated to support policy-as-string, so now the SDK needs to be updated.
Note
The required backend changes are still under review and are not yet part of production ngrok.
How
The protobuf definition was updated to contain a new
TrafficPolicy
field of typestring
. In theconfig/policy.go
file, a new type was defined on top ofstring
, adding functionality that adheres to the various required interfaces for our various connection types. These functions do nothing more than populate the newTrafficPolicy
field with the provided string representation, which will eventually get passed to the appropriate backend service.Additionally, to support backwards compatibility,
WithPolicy
was updated to convert the original, structured definition into an appropriate string. While this won't work forever, it should allow users who upgrade their SDK version to not have to change anything until we do the larger, phased-based cutover in the future. A printout was added to warn users about the upcoming deprecation ofWithPolicy
.Validation
Unit tests were updated, checking that:
WithPolicy
are properly converted to a policy string and placed inTrafficPolicy
.Tunnels were started using both
WithPolicy
andWithPolicyString
. Both started without error and applied the correct policy.traffic-policy-demo.mp4