Skip to content

Commit

Permalink
Merge pull request #119 from ngrok/mo/update_uaf_naming
Browse files Browse the repository at this point in the history
update user agent filter flags to be consistent
  • Loading branch information
jrobsonchase authored Sep 14, 2023
2 parents 90456bf + ad52483 commit f71bef1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
12 changes: 6 additions & 6 deletions config/user_agent_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type userAgentFilter struct {
Deny []string
}

// WithAllowUserAgentFilter adds user agent filtering to the endpoint.
// WithAllowUserAgent adds user agent filtering to the endpoint.
//
// The allow argument is a regular expressions for the user-agent
// header to allow
Expand All @@ -23,14 +23,14 @@ type userAgentFilter struct {
// ERR_NGROK_2090 for invalid allow/deny on connect.
// ERR_NGROK_3211 The server does not authorize requests from your user-agent
// ERR_NGROK_9022 Your account is not authorized to use user agent filtering.
func WithAllowUserAgentFilter(allow ...string) HTTPEndpointOption {
return userAgentFilter{
func WithAllowUserAgent(allow ...string) HTTPEndpointOption {
return &userAgentFilter{
// slice of regex strings for allowed user agents
Allow: allow,
}
}

// WithDenyUserAgentFilter adds user agent filtering to the endpoint.
// WithDenyUserAgent adds user agent filtering to the endpoint.
//
// The deny argument is a regular expressions to
// deny, with allows taking precedence over denies.
Expand All @@ -41,8 +41,8 @@ func WithAllowUserAgentFilter(allow ...string) HTTPEndpointOption {
// ERR_NGROK_2090 for invalid allow/deny on connect.
// ERR_NGROK_3211 The server does not authorize requests from your user-agent
// ERR_NGROK_9022 Your account is not authorized to use user agent filtering.
func WithDenyUserAgentFilter(deny ...string) HTTPEndpointOption {
return userAgentFilter{
func WithDenyUserAgent(deny ...string) HTTPEndpointOption {
return &userAgentFilter{
// slice of regex strings for denied user agents
Deny: deny,
}
Expand Down
16 changes: 8 additions & 8 deletions config/user_agent_filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func testUserAgentFilter[T tunnelConfigPrivate, O any, OT any](t *testing.T,
{
name: "test allow",
opts: optsFunc(
WithAllowUserAgentFilter(`(Pingdom\.com_bot_version_)(\d+)\.(\d+)`),
WithAllowUserAgent(`(Pingdom\.com_bot_version_)(\d+)\.(\d+)`),
),
expectOpts: func(t *testing.T, opts *O) {
actual := getUserAgentFilter(opts)
Expand All @@ -43,7 +43,7 @@ func testUserAgentFilter[T tunnelConfigPrivate, O any, OT any](t *testing.T,
{
name: "test deny",
opts: optsFunc(
WithDenyUserAgentFilter(`(Pingdom\.com_bot_version_)(\d+)\.(\d+)`),
WithDenyUserAgent(`(Pingdom\.com_bot_version_)(\d+)\.(\d+)`),
),
expectOpts: func(t *testing.T, opts *O) {
actual := getUserAgentFilter(opts)
Expand All @@ -58,8 +58,8 @@ func testUserAgentFilter[T tunnelConfigPrivate, O any, OT any](t *testing.T,
{
name: "test allow and deny",
opts: optsFunc(
WithAllowUserAgentFilter(`(Pingdom\.com_bot_version_)(\d+)\.(\d+)`),
WithDenyUserAgentFilter(`(Pingdom\.com_bot_version_)(\d+)\.(\d+)`),
WithAllowUserAgent(`(Pingdom\.com_bot_version_)(\d+)\.(\d+)`),
WithDenyUserAgent(`(Pingdom\.com_bot_version_)(\d+)\.(\d+)`),
),
expectOpts: func(t *testing.T, opts *O) {
actual := getUserAgentFilter(opts)
Expand All @@ -73,10 +73,10 @@ func testUserAgentFilter[T tunnelConfigPrivate, O any, OT any](t *testing.T,
{
name: "test multiple",
opts: optsFunc(
WithAllowUserAgentFilter(`(Pingdom\.com_bot_version_)(\d+)\.(\d+)`),
WithDenyUserAgentFilter(`(Pingdom\.com_bot_version_)(\d+)\.(\d+)`),
WithAllowUserAgentFilter(`(Pingdom2\.com_bot_version_)(\d+)\.(\d+)`),
WithDenyUserAgentFilter(`(Pingdom2\.com_bot_version_)(\d+)\.(\d+)`),
WithAllowUserAgent(`(Pingdom\.com_bot_version_)(\d+)\.(\d+)`),
WithDenyUserAgent(`(Pingdom\.com_bot_version_)(\d+)\.(\d+)`),
WithAllowUserAgent(`(Pingdom2\.com_bot_version_)(\d+)\.(\d+)`),
WithDenyUserAgent(`(Pingdom2\.com_bot_version_)(\d+)\.(\d+)`),
),
expectOpts: func(t *testing.T, opts *O) {
actual := getUserAgentFilter(opts)
Expand Down

0 comments on commit f71bef1

Please sign in to comment.