summaryrefslogtreecommitdiffstats
path: root/pacredir.c
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2017-05-02 21:54:15 +0200
committerGravatar Christian Hesse <mail@eworm.de>2017-05-02 21:58:19 +0200
commita7cf22d3ec6bc1e6cc34878dbc211b726d143285 (patch)
tree48541519b215ab7963de0b99cabfddb0874a33c4 /pacredir.c
parent2b1c967df2e4c7d72571b3f3eda5a7306e2d3913 (diff)
downloadpacredir-a7cf22d3ec6bc1e6cc34878dbc211b726d143285.tar.gz
pacredir-a7cf22d3ec6bc1e6cc34878dbc211b726d143285.tar.zst
add configuration option for protocol (IPv4 vs. IPv6)
Diffstat (limited to 'pacredir.c')
-rw-r--r--pacredir.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/pacredir.c b/pacredir.c
index 9fc08fd..6453bcf 100644
--- a/pacredir.c
+++ b/pacredir.c
@@ -609,6 +609,7 @@ int main(int argc, char ** argv) {
dictionary * ini;
const char * inistring;
char * values, * value;
+ int8_t use_proto = AVAHI_PROTO_UNSPEC;
uint16_t port;
struct ignore_interfaces * tmp_ignore_interfaces;
AvahiClient *client = NULL;
@@ -670,6 +671,7 @@ int main(int argc, char ** argv) {
/* continue anyway, there is nothing essential in the config file */
} else {
int ini_verbose;
+ const char * tmp;
/* extra verbosity from config */
ini_verbose = iniparser_getint(ini, "general:verbose", 0);
@@ -699,6 +701,22 @@ int main(int argc, char ** argv) {
free(values);
}
+ /* configure protocols to use */
+ if ((tmp = iniparser_getstring(ini, "general:protocol", NULL)) != NULL) {
+ switch(tmp[strlen(tmp) - 1]) {
+ case '4':
+ if (verbose > 0)
+ write_log(stdout, "Using IPv4 only\n");
+ use_proto = AVAHI_PROTO_INET;
+ break;
+ case '6':
+ if (verbose > 0)
+ write_log(stdout, "Using IPv6 only\n");
+ use_proto = AVAHI_PROTO_INET6;
+ break;
+ }
+ }
+
/* add static pacserve hosts */
if ((inistring = iniparser_getstring(ini, "general:pacserve hosts", NULL)) != NULL) {
values = strdup(inistring);
@@ -755,14 +773,14 @@ int main(int argc, char ** argv) {
/* create the service browser for PACSERVE */
if ((pacserve = avahi_service_browser_new(client, AVAHI_IF_UNSPEC,
- AVAHI_PROTO_UNSPEC, PACSERVE, NULL, 0, browse_callback, client)) == NULL) {
+ use_proto, PACSERVE, NULL, 0, browse_callback, client)) == NULL) {
write_log(stderr, "Failed to create service browser: %s\n", avahi_strerror(avahi_client_errno(client)));
goto fail;
}
/* create the service browser for PACDBSERVE */
if ((pacdbserve = avahi_service_browser_new(client, AVAHI_IF_UNSPEC,
- AVAHI_PROTO_UNSPEC, PACDBSERVE, NULL, 0, browse_callback, client)) == NULL) {
+ use_proto, PACDBSERVE, NULL, 0, browse_callback, client)) == NULL) {
write_log(stderr, "Failed to create service browser: %s\n", avahi_strerror(avahi_client_errno(client)));
goto fail;
}