TS-4395 Add new plugin, remap_purge#747
Conversation
|
@reveller Can you review this too please? |
|
FreeBSD build failed! See https://ci.trafficserver.apache.org/job/Github-FreeBSD/356/ for details. |
|
Linux build successful! See https://ci.trafficserver.apache.org/job/Github-Linux/249/ for details. |
|
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) */ |
There was a problem hiding this comment.
Can you pleas file a JIRA to make a API to get the runtime directory?
There was a problem hiding this comment.
Did already: https://issues.apache.org/jira/browse/TS-4595
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
e55a352 to
b76ffb0
Compare
|
FreeBSD build failed! See https://ci.trafficserver.apache.org/job/Github-FreeBSD/389/ for details. |
|
FreeBSD build failed! See https://ci.trafficserver.apache.org/job/Github-FreeBSD/390/ for details. |
|
Linux build successful! See https://ci.trafficserver.apache.org/job/Github-Linux/285/ for details. |
|
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)) { |
There was a problem hiding this comment.
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".
There was a problem hiding this comment.
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 /)
|
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.
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