summaryrefslogtreecommitdiffstats
path: root/tools/omfwd.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2008-08-05 15:02:49 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2008-08-05 15:02:49 +0200
commit15adf8f1fda97b5c744e92390ef7e41ce3d7f3b2 (patch)
tree8a70d11e1c38d74621ef4cdf0abe95c1c9a364ab /tools/omfwd.c
parent87576f85699afd0aba3f8a3716b343f8f568d1f0 (diff)
downloadrsyslog-15adf8f1fda97b5c744e92390ef7e41ce3d7f3b2.tar.gz
rsyslog-15adf8f1fda97b5c744e92390ef7e41ce3d7f3b2.tar.xz
rsyslog-15adf8f1fda97b5c744e92390ef7e41ce3d7f3b2.zip
bugfix: IPv6 addresses could not be specified in forwarding actions
New syntax @[addr]:port introduced to enable that. Root problem was IPv6 addresses contain colons. Also somewhat enhanced debugging messages.
Diffstat (limited to 'tools/omfwd.c')
-rw-r--r--tools/omfwd.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/tools/omfwd.c b/tools/omfwd.c
index 30761a87..df2f0342 100644
--- a/tools/omfwd.c
+++ b/tools/omfwd.c
@@ -509,6 +509,9 @@ CODE_STD_STRING_REQUESTparseSelectorAct(1)
* applies to TCP-based syslog only and is ignored when specified with UDP).
* That is not yet implemented.
* rgerhards, 2006-12-07
+ * In order to support IPv6 addresses, we must introduce an extension to
+ * the hostname. If it is in square brackets, whatever is in them is treated as
+ * the hostname - without any exceptions ;) -- rgerhards, 2008-08-05
*/
if(*p == '(') {
/* at this position, it *must* be an option indicator */
@@ -555,11 +558,22 @@ CODE_STD_STRING_REQUESTparseSelectorAct(1)
*/
errmsg.LogError(0, NO_ERRCODE, "Option block not terminated in forwarding action.");
}
+
/* extract the host first (we do a trick - we replace the ';' or ':' with a '\0')
* now skip to port and then template name. rgerhards 2005-07-06
*/
- for(q = p ; *p && *p != ';' && *p != ':' && *p != '#' ; ++p)
- /* JUST SKIP */;
+ if(*p == '[') { /* everything is hostname upto ']' */
+ ++p; /* skip '[' */
+ for(q = p ; *p && *p != ']' ; ++p)
+ /* JUST SKIP */;
+ if(*p == ']') {
+ *p = '\0'; /* trick to obtain hostname (later)! */
+ ++p; /* eat it */
+ }
+ } else { /* traditional view of hostname */
+ for(q = p ; *p && *p != ';' && *p != ':' && *p != '#' ; ++p)
+ /* JUST SKIP */;
+ }
pData->port = NULL;
if(*p == ':') { /* process port */
@@ -594,6 +608,7 @@ CODE_STD_STRING_REQUESTparseSelectorAct(1)
} else {
CHKmalloc(pData->f_hname = strdup((char*) q));
}
+dbgprintf("hostname '%s', port '%s'\n", pData->f_hname, pData->port);
/* process template */
CHKiRet(cflineParseTemplateName(&p, *ppOMSR, 0, OMSR_NO_RQD_TPL_OPTS,