Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvmod-hoailona
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
libvmod-hoailona
Commits
467c3590
Commit
467c3590
authored
Jan 11, 2017
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
the hosts.policy() method may not be called in vcl_init
parent
9621d9a8
Pipeline
#109
skipped
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
5 deletions
+19
-5
policy_method.vtc
src/tests/policy_method.vtc
+14
-0
vmod_hoailona.c
src/vmod_hoailona.c
+5
-5
No files found.
src/tests/policy_method.vtc
View file @
467c3590
...
...
@@ -379,6 +379,20 @@ client c1 {
} -run
# Usage tests
varnish v1 -errvcl {h.policy() may not be called in vcl_init} {
import hoailona from "${vmod_topbuild}/src/.libs/libvmod_hoailona.so";
backend b { .host = "${bad_ip}"; }
sub vcl_init {
new p = hoailona.policy(OPEN, 1h);
new h = hoailona.hosts();
h.add("example.com", "p");
if (h.policy("example.com", "/foo") != 1) {
return(fail);
}
}
}
varnish v1 -vcl {
import hoailona from "${vmod_topbuild}/src/.libs/libvmod_hoailona.so";
backend b { .host = "${bad_ip}"; }
...
...
src/vmod_hoailona.c
View file @
467c3590
...
...
@@ -53,11 +53,6 @@
#define INIT(ctx) (((ctx)->method & VCL_MET_INIT) != 0)
#define INIT_FINI(ctx) (((ctx)->method & (VCL_MET_INIT | VCL_MET_FINI)) != 0)
#define ILLEGAL(ctx, m) \
ERR((ctx), m " is illegal in vcl_init() and vcl_fini()")
struct
host
{
unsigned
magic
;
#define VMOD_HOAILONA_HOST_MAGIC 0x731af58f
...
...
@@ -483,6 +478,11 @@ vmod_hosts_policy(VRT_CTX, struct vmod_hoailona_hosts *hosts,
CHECK_OBJ_NOTNULL
(
ctx
->
ws
,
WS_MAGIC
);
CHECK_OBJ_NOTNULL
(
hosts
,
VMOD_HOAILONA_HOSTS_MAGIC
);
AN
(
priv_task
);
if
(
INIT
(
ctx
))
{
VERR
(
ctx
,
"%s.policy() may not be called in vcl_init"
,
hosts
->
vcl_name
);
return
-
2
;
}
if
(
hostname
==
NULL
||
hostname
[
0
]
==
'\0'
)
{
VERR
(
ctx
,
"host is empty in %s.policy()"
,
hosts
->
vcl_name
);
return
-
2
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment