Skip to content

TS-4395 Add new plugin, remap_purge - #747

Closed
zwoop wants to merge 2 commits into
apache:masterfrom
zwoop:TS-4395
Closed

TS-4395 Add new plugin, remap_purge#747
zwoop wants to merge 2 commits into
apache:masterfrom
zwoop:TS-4395

Conversation

@zwoop

@zwoop zwoop commented Jun 27, 2016

Copy link
Copy Markdown
Contributor

This is similar to the existing plugin to purge based on a genID stored in a
persistent storage. The difference is that the purging is done exclusively via
a restful API, and has little (no) overhead on performance (since the
generation ID is always in memory).

Example:

map http://example.com/p1 http://p1.example.com
@plugin=remap_purge.so @pparam=--path=secret @pparam=--state=example_p1

And to purge:

$ curl -s -D - -X PURGE http://example.com/p1/__secret__
HTTP/1.1 200 OK
Date: Sat, 30 Apr 2016 00:09:34 GMT
Connection: close
Server: ATS/7.0.0
Content-Length: 39
Content-Type: text/html

PURGED http://example.com/p1

@zwoop zwoop added the Plugins label Jun 27, 2016
@zwoop zwoop added this to the 7.0.0 milestone Jun 27, 2016
@zwoop

zwoop commented Jun 27, 2016

Copy link
Copy Markdown
Contributor Author

@reveller Can you review this too please?

@atsci

atsci commented Jun 27, 2016

Copy link
Copy Markdown

FreeBSD build failed! See https://ci.trafficserver.apache.org/job/Github-FreeBSD/356/ for details.

@atsci

atsci commented Jun 27, 2016

Copy link
Copy Markdown

Linux build successful! See https://ci.trafficserver.apache.org/job/Github-Linux/249/ for details.

@zwoop

zwoop commented Jun 30, 2016

Copy link
Copy Markdown
Contributor Author

Any thoughts on this ?

#include "ts/ink_defs.h"

static const char *PLUGIN_NAME = "remap_purge";
static const char *DEFAULT_DIR = "var/trafficserver"; /* Not perfect, but no better API) */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you pleas file a JIRA to make a API to get the runtime directory?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is similar to the existing plugin to purge based on a genID stored in a
persistent storage. The difference is that the purging is done exclusively via
a restful API, and has little (no) overhead on performance (since the
generation ID is always in memory).

Example:

map http://example.com/p1  http://p1.example.com
  @plugin=remap_purge.so @pparam=--path=__secret__  @pparam=--state=example_p1

And to purge:

  $ curl -s -D - -X PURGE http://example.com/p1/__secret__
  HTTP/1.1 200 OK
  Date: Sat, 30 Apr 2016 00:09:34 GMT
  Connection: close
  Server: ATS/7.0.0
  Content-Length: 39
  Content-Type: text/html

  PURGED http://example.com/p1
@zwoop
zwoop force-pushed the TS-4395 branch 2 times, most recently from e55a352 to b76ffb0 Compare June 30, 2016 18:00
@atsci

atsci commented Jun 30, 2016

Copy link
Copy Markdown

FreeBSD build failed! See https://ci.trafficserver.apache.org/job/Github-FreeBSD/389/ for details.

@atsci

atsci commented Jun 30, 2016

Copy link
Copy Markdown

FreeBSD build failed! See https://ci.trafficserver.apache.org/job/Github-FreeBSD/390/ for details.

@atsci

atsci commented Jun 30, 2016

Copy link
Copy Markdown

Linux build successful! See https://ci.trafficserver.apache.org/job/Github-Linux/285/ for details.

@atsci

atsci commented Jun 30, 2016

Copy link
Copy Markdown

Linux build successful! See https://ci.trafficserver.apache.org/job/Github-Linux/286/ for details.


TSDebug(PLUGIN_NAME, "Checking PATH = %.*s", path_len, path);
if (path && (path_len >= purge->secret_len) &&
!memcmp(path + (path_len - purge->secret_len), purge->secret, purge->secret_len)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggest comparing the secret to the result of strrchr(path, '/') or similar. This would succeed if the secret is "bar" and the URL is "/path/to/foobar".

@zwoop zwoop Jun 30, 2016

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Don't think that would work, then you couldn't use this to purge a remap rule like

map http://example.com http://real.example.com

At least not without modifying the path, or, taking that into account (i.e. a separate case for this situation). Is it really worth that complexity? I sort of envisioned people to pick pretty strong secrets here, e.g. genuuid.

(The path never includes the leading /)

@atsci

atsci commented Jun 30, 2016

Copy link
Copy Markdown

FreeBSD build failed! See https://ci.trafficserver.apache.org/job/Github-FreeBSD/391/ for details.

Testing this process, I will squash this down to a single commit
once reviews are done.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants