[Unbound-users] outgoing-interface config option
W.C.A. Wijngaards
wouter at nlnetlabs.nl
Thu Jan 26 10:39:12 UTC 2012
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi Nicholas,
Thanks for the patch, applied it and fixed up memory leak in patch (if
alloc fails, of dupped strs).
I have turned the patch into this:
Index: util/config_file.c
===================================================================
- --- util/config_file.c (revision 2595)
+++ util/config_file.c (working copy)
@@ -409,7 +409,18 @@
else S_STR("control-cert-file:", control_cert_file)
else S_STR("module-config:", module_conf)
else S_STR("python-script:", python_script)
- - else {
+ else if (strcmp(opt, "outgoing-interface:") == 0) {
+ char* d = strdup(val);
+ char** oi = (char**)malloc((cfg->num_out_ifs+1)*sizeof(char*));
+ if(!d || !oi) { free(d); free(oi); return -1; }
+ if(cfg->out_ifs && cfg->num_out_ifs) {
+ memmove(oi, cfg->out_ifs, cfg->num_out_ifs*sizeof(char*));
+ free(cfg->out_ifs);
+ }
+ oi[cfg->num_out_ifs] = d;
+ cfg->num_out_ifs++;
+ cfg->out_ifs = oi;
+ } else {
/* unknown or unsupported (from the set_option interface):
* interface, outgoing-interface, access-control,
* stub-zone, name, stub-addr, stub-host, stub-prime
Best regards,
Wouter
On 01/25/2012 08:51 PM, Николай Брыскин wrote:
> Hello, I'm using libunbound in my application (proxy server), and
> I need to configure libunbound with specific outgoing interface for
> DNS requests. I've wrote this patch (tested with libunbound 1.4.9
> and 1.4.12):
>
> Index: unbound-1.4.12/util/config_file.c
> ===================================================================
>
>
- --- unbound-1.4.12.orig/util/config_file.c 2012-01-25
> 23:15:15.000000000 +0400 +++ unbound-1.4.12/util/config_file.c
> 2012-01-25 23:15:31.000000000 +0400 @@ -403,6 +403,16 @@ else
> S_STR("control-cert-file:", control_cert_file) else
> S_STR("module-config:", module_conf) else S_STR("python-script:",
> python_script) + else if (strcmp(opt, "outgoing-interface:") ==
> 0) { + if (cfg->num_out_ifs == 0) + cfg->out_ifs
> = calloc(1, sizeof(char*)); + else + cfg->out_ifs
> = realloc(cfg->out_ifs, (cfg->num_out_ifs+1)*sizeof(char*)); +
> if(!cfg->out_ifs) + return -1; + else +
> cfg->out_ifs[cfg->num_out_ifs++] = strdup(val); + } else { /*
> unknown or unsupported (from the set_option interface): *
> interface, outgoing-interface, access-control,
>
> I have not found functions like S_STR for this functionality, so
> it looks quite ugly. Could you add this or similar patch to the
> upstream?
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iQIcBAEBAgAGBQJPIS1PAAoJEJ9vHC1+BF+NZSYP/0lc1m2k1q+2HSVzr88DjcDT
apyRiBIZyAA2Em7bP+oTiZkfJvIDOlQlcscQCtNUH728POetV72E6JTtHRGNZ7uG
l86FFV9iTgSuTPCg7dzibkSWYgXk6XIjRXfwdnv00SC/3z2NszaQCM8WsDRD7aRm
VDUFpcgScLUd654S2LQtPEmU8ieJWZwg1MqbBJm0COPh0qQ4/5OyevizyVFwfqKw
Wijo3g8WoeEXIg4rKe5cnZSEGI3Ny7Dsk4Zy2Ll3kj/5q6xOoaWVMVd7oI+f+YNj
IsEIzJq2ym2fhHz0ThLg1ZNi+7D0IunBB8keB5CihVBq0dMfM8eAMrU91roW0rFc
PlqafOYda9wXK/C1dKcRjc8QC8YV55Vvk7IQ/J6hPjlXiuQIoQkC3QhdyQ5K9Z70
leQLKulFV6VkAqSBXJJ3kidg7WKnXwGd/N/QKnwfVAJOEeL6gdQQuJF6AYwFOThp
9Oc75VNtpJkxQVdzILTmZfYlMHygMoNremmuEvqkPu19Ip35dAkMKQtMlzez3Mu/
XtDtRAPmJlOgcRbVShIRuina/AftL9S5S50ZaI95YVt2lCEh8qED8bf3WvfjOWbP
Mr2jNzum0TDboeiHie2UWax2NaDu4+/GoVXQPyCJuHjqv65a4BpyV4DuHw30OpKN
/NBzNWwf9Y8knnIyAInT
=LI/A
-----END PGP SIGNATURE-----
More information about the Unbound-users
mailing list