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
9621d9a8
Commit
9621d9a8
authored
Jan 11, 2017
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
the hosts.add() method may only be called in vcl_init
parent
1a4d6532
Pipeline
#108
skipped
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
1 deletion
+32
-1
add.vtc
src/tests/add.vtc
+25
-0
vmod_hoailona.c
src/vmod_hoailona.c
+7
-1
No files found.
src/tests/add.vtc
View file @
9621d9a8
...
...
@@ -18,6 +18,31 @@ varnish v1 -vcl {
}
} -start
varnish v1 -vcl {
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();
}
sub vcl_recv {
h.add("example.com", "p");
}
}
client c1 {
txreq
rxresp
} -run
logexpect l1 -v v1 -d 1 -g vxid -q "VCL_Error" {
expect 0 * Begin req
expect * = VCL_Error "^vmod hoailona error: h.add.. may only be called in vcl_init$"
expect * = End
} -run
varnish v1 -errvcl {vmod hoailona error: host is empty in h.add()} {
import hoailona from "${vmod_topbuild}/src/.libs/libvmod_hoailona.so";
backend b { .host = "${bad_ip}"; }
...
...
src/vmod_hoailona.c
View file @
9621d9a8
...
...
@@ -51,6 +51,8 @@
#define ERRNOMEM(ctx, msg) \
ERR((ctx), msg ", out of space")
#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) \
...
...
@@ -322,7 +324,6 @@ valid_hostname(VRT_CTX, const char * restrict const hostname)
return
1
;
}
/* XXX only legal in init */
VCL_VOID
vmod_hosts_add
(
VRT_CTX
,
struct
vmod_hoailona_hosts
*
hosts
,
struct
vmod_priv
*
init_task
,
VCL_STRING
hostname
,
...
...
@@ -341,6 +342,11 @@ vmod_hosts_add(VRT_CTX, struct vmod_hoailona_hosts *hosts,
CHECK_OBJ_NOTNULL
(
ctx
->
ws
,
WS_MAGIC
);
CHECK_OBJ_NOTNULL
(
hosts
,
VMOD_HOAILONA_HOSTS_MAGIC
);
AN
(
init_task
);
if
(
!
INIT
(
ctx
))
{
VERR
(
ctx
,
"%s.add() may only be called in vcl_init"
,
hosts
->
vcl_name
);
return
;
}
if
(
hostname
==
NULL
||
hostname
[
0
]
==
'\0'
)
{
VERR
(
ctx
,
"host is empty in %s.add()"
,
hosts
->
vcl_name
);
return
;
...
...
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