Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for TrafficPolicy #170

Merged
merged 2 commits into from
Jul 10, 2024

Conversation

TheConcierge
Copy link
Contributor

@TheConcierge TheConcierge commented Jun 25, 2024

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 type string. In the config/policy.go file, a new type was defined on top of string, adding functionality that adheres to the various required interfaces for our various connection types. These functions do nothing more than populate the new TrafficPolicy 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 of WithPolicy.

Validation

Unit tests were updated, checking that:

  • YAML policy strings are validated
  • JSON policy strings are validated
  • policies specified by WithPolicy are properly converted to a policy string and placed in TrafficPolicy.

Tunnels were started using both WithPolicy and WithPolicyString. Both started without error and applied the correct policy.

traffic-policy-demo.mp4

@TheConcierge TheConcierge force-pushed the ngrok/ryan/add-traffic-policy-support branch 3 times, most recently from eca5e26 to 34c92f9 Compare June 25, 2024 05:46
@TheConcierge TheConcierge marked this pull request as ready for review June 25, 2024 05:48
Copy link
Contributor

@nikolay-ngrok nikolay-ngrok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@TheConcierge TheConcierge force-pushed the ngrok/ryan/add-traffic-policy-support branch from 0b5e86d to 1e9fb15 Compare July 10, 2024 22:50
@TheConcierge TheConcierge merged commit c8bde68 into main Jul 10, 2024
2 checks passed
@TheConcierge TheConcierge deleted the ngrok/ryan/add-traffic-policy-support branch July 10, 2024 22:56
@TheConcierge TheConcierge restored the ngrok/ryan/add-traffic-policy-support branch July 12, 2024 02:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants