crossroads

Git mirror of https://crossroads.e-tunity.com/
git clone git://git.finwo.net/app/crossroads
Log | Files | Refs | LICENSE

commit c01a15c5bbd80be1518f0332b1f1e05edfd6b25d
parent 1cc8f22e8ff7f5bcbe7a7745c73a49725de46e90
Author: finwo <finwo@pm.me>
Date:   Sat,  3 Jan 2026 19:33:45 +0100

1.62

Diffstat:
MChangeLog | 9++++++++-
Mdoc/crossroads.conf.7 | 145++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------
Mdoc/crossroads.html | 314+++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------
Mdoc/crossroads.pdf | 0
Mdoc/main/conf/addclientheader.yo | 9+++++++++
Mdoc/main/formattable.yo | 64++++++++++++++++++++++++++++++++++++++++++----------------------
Mdoc/main/tips/httpstickiness.yo | 4++++
Metc/Makefile.def | 2+-
Metc/svnrev.txt | 2+-
Msrc/crossroads-daemon/main.c | 2+-
Msrc/crossroads.h | 5+++--
Msrc/crossroads/main.c | 2+-
Msrc/lib/allocreporter.c | 2+-
Msrc/lib/ansistamp.c | 5+++--
Msrc/lib/backendavailable.c | 2+-
Msrc/lib/backendconnect.c | 2+-
Msrc/lib/backendcount.c | 2+-
Msrc/lib/choosebackend.c | 2+-
Msrc/lib/configread.c | 2+-
Msrc/lib/configtest.c | 2+-
Msrc/lib/configwrite.c | 2+-
Msrc/lib/copysockets.c | 2+-
Msrc/lib/createcommandlinespace.c | 2+-
Msrc/lib/data.c | 2+-
Msrc/lib/deallocreporter.c | 2+-
Msrc/lib/decrclientcount.c | 2+-
Msrc/lib/dns.c | 2+-
Msrc/lib/error.c | 2+-
Msrc/lib/forktcpservicer.c | 2+-
Asrc/lib/gmtstamp.c | 26++++++++++++++++++++++++++
Msrc/lib/hashpjw.c | 2+-
Msrc/lib/httpcopy.c | 2+-
Msrc/lib/httperror.c | 2+-
Msrc/lib/httpheaderaddheader.c | 2+-
Msrc/lib/httpheaderappendheader.c | 2+-
Msrc/lib/httpheaderconnectiontype.c | 2+-
Msrc/lib/httpheaderfree.c | 2+-
Msrc/lib/httpheaderhascookie.c | 2+-
Msrc/lib/httpheaderhttpver.c | 2+-
Msrc/lib/httpheadernew.c | 2+-
Msrc/lib/httpheaderread.c | 2+-
Msrc/lib/httpheaderremoveheader.c | 2+-
Msrc/lib/httpheadersetheader.c | 2+-
Msrc/lib/httpheaderval.c | 2+-
Msrc/lib/httpheaderwrite.c | 2+-
Msrc/lib/httpinsertheader.c | 2+-
Msrc/lib/httpserve.c | 2+-
Msrc/lib/httpserversocket.c | 2+-
Msrc/lib/httpwrite.c | 2+-
Msrc/lib/incrclientcount.c | 2+-
Msrc/lib/initsockaddr.c | 2+-
Msrc/lib/interrupt.c | 2+-
Msrc/lib/ipfaddallow.c | 2+-
Msrc/lib/ipfadddeny.c | 2+-
Msrc/lib/ipfallowed.c | 2+-
Msrc/lib/ipfdenied.c | 2+-
Msrc/lib/ipfloadfile.c | 2+-
Msrc/lib/ipfmatch.c | 2+-
Msrc/lib/ipfparse.c | 2+-
Msrc/lib/ishexdigit.c | 2+-
Msrc/lib/isspace.c | 2+-
Msrc/lib/lexer.c | 2+-
Msrc/lib/lockreporter.c | 2+-
Msrc/lib/logactivityany.c | 5+++--
Msrc/lib/logactivitycontinuation.c | 2+-
Msrc/lib/logactivityend.c | 2+-
Msrc/lib/logactivitystart.c | 2+-
Msrc/lib/makesocket.c | 2+-
Msrc/lib/markactivity.c | 2+-
Msrc/lib/msg.c | 2+-
Msrc/lib/msgdumpbuf.c | 2+-
Msrc/lib/netbuffer.c | 2+-
Msrc/lib/netbufread.c | 2+-
Msrc/lib/netcopy.c | 2+-
Msrc/lib/netread.c | 2+-
Msrc/lib/netwrite.c | 2+-
Msrc/lib/parser.c | 2+-
Msrc/lib/parserclose.c | 2+-
Msrc/lib/parserfilename.c | 2+-
Msrc/lib/parserinput.c | 2+-
Msrc/lib/parseropen.c | 2+-
Msrc/lib/parserrun.c | 2+-
Msrc/lib/parserskipchar.c | 2+-
Msrc/lib/parserskipline.c | 2+-
Msrc/lib/restart.c | 2+-
Msrc/lib/runservice.c | 2+-
Msrc/lib/serve.c | 2+-
Msrc/lib/setproctitle.c | 2+-
Msrc/lib/showconfig.c | 2+-
Msrc/lib/showservices.c | 2+-
Msrc/lib/showstatus.c | 2+-
Msrc/lib/stagetostring.c | 2+-
Msrc/lib/statetostring.c | 2+-
Msrc/lib/stopdaemon.c | 2+-
Msrc/lib/strcasestr.c | 2+-
Msrc/lib/strexpandformat.c | 125++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----------------------
Msrc/lib/stringtostate.c | 2+-
Msrc/lib/strlcat.c | 2+-
Msrc/lib/strprintf.c | 2+-
Msrc/lib/strupr.c | 2+-
Msrc/lib/strvprintf.c | 2+-
Msrc/lib/symtabend.c | 2+-
Msrc/lib/symtablookup.c | 2+-
Msrc/lib/symtabset.c | 2+-
Msrc/lib/symtabstart.c | 2+-
Msrc/lib/sysrun.c | 2+-
Msrc/lib/tcpserve.c | 2+-
Msrc/lib/tellservice.c | 2+-
Msrc/lib/thruputlog.c | 2+-
Msrc/lib/trafficlog.c | 2+-
Msrc/lib/uidassume.c | 2+-
Msrc/lib/uidrestore.c | 2+-
Msrc/lib/unlockreporter.c | 2+-
Msrc/lib/usage.c | 2+-
Msrc/lib/vsyslog.c | 2+-
Msrc/lib/wakeuphandler.c | 2+-
Msrc/lib/warning.c | 2+-
Msrc/lib/writelog.c | 2+-
Msrc/lib/xcalloc.c | 2+-
Msrc/lib/xmalloc.c | 2+-
Msrc/lib/xrealloc.c | 2+-
Msrc/lib/xstrcat.c | 2+-
Msrc/lib/xstrcatch.c | 2+-
Msrc/lib/xstrdup.c | 2+-
124 files changed, 598 insertions(+), 337 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,9 +1,16 @@ ChangeLog for Crossroads ------------------------------------------------------------------------------ +1.62 [KK 2007-10-03] + - Extended format specifiers with %g. In time-related modifiers + like %g, %t, %T, the optional number is an offset into the + future (so %3600t is now + 1h). Thanks Gunnar S. for pointing + this out. + 1.61 [KK 2007-10-02] - Added messaging to allowfrom/denyfrom rule handling. Bugfixes - in the parsing and handling of allow/deny rules. + in the parsing and handling of allow/deny rules. Thanks Chris + G. for pointing this out to me. 1.60 [KK 2007-08-29] - upped c-conf to 1.10 diff --git a/doc/crossroads.conf.7 b/doc/crossroads.conf.7 @@ -806,44 +806,61 @@ command is expanded according to the following table: .IP .IP o \f(CW%a\fP is the availability of the current back end, when -a current back end is established; -.IP o -\f(CW%1a\fP is the availability of the first back end (0 when -unavailable, 1 if available); \f(CW%2a\fP is the availability of -the second back end, and so on; +a current back end is established\&. \f(CW%1a\fP is the +availability of the first back end (0 when unavailable, 1 if +available); \f(CW%2a\fP is the availability of the second back +end, and so on\&. +.IP .IP o \f(CW%b\fP is the name of the current back end, when one is -established; -.IP o -\f(CW%1b\fP is the name of the first back end, \f(CW%2b\fP of the -second back end, and so on; +established\&. \f(CW%1b\fP is the name of the first back end, +\f(CW%2b\fP of the second back end, and so on\&. +.IP .IP o \f(CW%e\fP is the count of seconds since start of epoch -(January 1st 1970 GMT); -.IP o -\f(CW%h\fP is the host name of the current back end; +(January 1st 1970 GMT)\&. \f(CW%60e\fP is the count since start of +epoch plus 60, so this is a 1 minute offset into the future\&. +.IP .IP o -\f(CW%1h\fP is the host name of the first back end, \f(CW%2h\fP -of the second back end, and so on; +\f(CW%g\fP is a "GMT-string" representation of the current +time, in the format \fImonthname, day year hh:mm:ss\fP\&. This +format is used in e\&.g\&. cookie expiry\&. \f(CW%600g\fP is the same +representation but of a moment 600 seconds in the future (10 +minutes)\&. +.IP .IP o -\f(CW%p\fP is the TCP port of the current back end; +\f(CW%h\fP is the host name of the current back end\&. \f(CW%1h\fP +is the host name of the first back end, \f(CW%2h\fP of the second +back end, and so on\&. +.IP .IP o -\f(CW%1p\fP is the TCP port of the first back end, \f(CW%2p\fP of -the second back end, and so on; +\f(CW%p\fP is the TCP port of the current back end\&. \f(CW%1p\fP +is the TCP port of the first back end, \f(CW%2p\fP of the second +back end, and so on\&. +.IP .IP o -\f(CW%r\fP is the IP address of the client that requests a -connection and for whom the external dispatcher should compute -a back end; +\f(CW%r\fP is the IP address of the connecting client\&. +.IP .IP o \f(CW%s\fP is the name of the current service that the client -connected to; +connected to\&. +.IP .IP o -\f(CW%t\fP is the current local time in ASCII format, in -\fIYYYY-MM-DD/hhh:mm:ss\fP; +\f(CW%t\fP is the current local time in ANSI format, in +\fIYYYY-MM-DD/hhh:mm:ss\fP\&. \f(CW%1800s\fP is an ANSI stamp of a +moment 1800 seconds in the future (half an hour)\&. +.IP .IP o -\f(CW%T\fP is the current GMT time in ASCIII format; +\f(CW%T\fP is the current GMT time in ANSI format\&. \f(CW%10T\fP +offsets this 10 seconds into the future\&. +.IP .IP o -\f(CW%v\fP is the Crossroads version; +\f(CW%v\fP is the Crossroads version\&. +.IP +.IP o +\f(CW%w\fP is the weight factor of the current back +end\&. \f(CW%1w\fP is the weight factor of the first back end, etc\&.\&. +.IP .IP o Any other chararacter following a \f(CW%\fP sign is taken literally; e\&.g\&. \f(CW%z\fP is just a z\&. @@ -978,44 +995,61 @@ directives: .IP .IP o \f(CW%a\fP is the availability of the current back end, when -a current back end is established; -.IP o -\f(CW%1a\fP is the availability of the first back end (0 when -unavailable, 1 if available); \f(CW%2a\fP is the availability of -the second back end, and so on; +a current back end is established\&. \f(CW%1a\fP is the +availability of the first back end (0 when unavailable, 1 if +available); \f(CW%2a\fP is the availability of the second back +end, and so on\&. +.IP .IP o \f(CW%b\fP is the name of the current back end, when one is -established; -.IP o -\f(CW%1b\fP is the name of the first back end, \f(CW%2b\fP of the -second back end, and so on; +established\&. \f(CW%1b\fP is the name of the first back end, +\f(CW%2b\fP of the second back end, and so on\&. +.IP .IP o \f(CW%e\fP is the count of seconds since start of epoch -(January 1st 1970 GMT); -.IP o -\f(CW%h\fP is the host name of the current back end; +(January 1st 1970 GMT)\&. \f(CW%60e\fP is the count since start of +epoch plus 60, so this is a 1 minute offset into the future\&. +.IP .IP o -\f(CW%1h\fP is the host name of the first back end, \f(CW%2h\fP -of the second back end, and so on; +\f(CW%g\fP is a "GMT-string" representation of the current +time, in the format \fImonthname, day year hh:mm:ss\fP\&. This +format is used in e\&.g\&. cookie expiry\&. \f(CW%600g\fP is the same +representation but of a moment 600 seconds in the future (10 +minutes)\&. +.IP .IP o -\f(CW%p\fP is the TCP port of the current back end; +\f(CW%h\fP is the host name of the current back end\&. \f(CW%1h\fP +is the host name of the first back end, \f(CW%2h\fP of the second +back end, and so on\&. +.IP .IP o -\f(CW%1p\fP is the TCP port of the first back end, \f(CW%2p\fP of -the second back end, and so on; +\f(CW%p\fP is the TCP port of the current back end\&. \f(CW%1p\fP +is the TCP port of the first back end, \f(CW%2p\fP of the second +back end, and so on\&. +.IP .IP o -\f(CW%r\fP is the IP address of the client that requests a -connection and for whom the external dispatcher should compute -a back end; +\f(CW%r\fP is the IP address of the connecting client\&. +.IP .IP o \f(CW%s\fP is the name of the current service that the client -connected to; +connected to\&. +.IP .IP o -\f(CW%t\fP is the current local time in ASCII format, in -\fIYYYY-MM-DD/hhh:mm:ss\fP; +\f(CW%t\fP is the current local time in ANSI format, in +\fIYYYY-MM-DD/hhh:mm:ss\fP\&. \f(CW%1800s\fP is an ANSI stamp of a +moment 1800 seconds in the future (half an hour)\&. +.IP .IP o -\f(CW%T\fP is the current GMT time in ASCIII format; +\f(CW%T\fP is the current GMT time in ANSI format\&. \f(CW%10T\fP +offsets this 10 seconds into the future\&. +.IP .IP o -\f(CW%v\fP is the Crossroads version; +\f(CW%v\fP is the Crossroads version\&. +.IP +.IP o +\f(CW%w\fP is the weight factor of the current back +end\&. \f(CW%1w\fP is the weight factor of the first back end, etc\&.\&. +.IP .IP o Any other chararacter following a \f(CW%\fP sign is taken literally; e\&.g\&. \f(CW%z\fP is just a z\&. @@ -1051,6 +1085,17 @@ subsequent request from the same browser now has that cookie in place; and is therefore sent to the same back end where the its predecessors went\&. .IP +The header which is sent to the client to inject a cookie, can +furthermore be expanded to specify a timeout: +.IP +.nf +addclientheader "Set-Cookie: BalancerID=second; path=/; expires=%1800g"; +.fi + +.IP +The format specifier \f(CW%1800g\fP outputs a GMT-string date 1800 +seconds in the future (half an hour from now)\&. +.IP .IP "Hiding the server software version:" Many servers (e\&.g\&. Apache) advertize their version, as in \f(CWServer: Apache diff --git a/doc/crossroads.html b/doc/crossroads.html @@ -1,12 +1,12 @@ <a name="../crossroads-defs"></a><a name="defs"></a><html><head> -<title>Crossroads 1.61</title> +<title>Crossroads 1.62</title> <link rel="stylesheet" type="text/css" href="http://www.e-tunity.com/css/yodl.css"> <link rel="stylesheet" type="text/css" href="http://www.e-tunity.com/css/yodl.css"> <link rev="made" href="mailto:info@e-tunity.com"> </head> <body> <hr> -<h1>Crossroads 1.61</h1> +<h1>Crossroads 1.62</h1> <h2>Karel Kubat <br> Maintained by Karel Kubat (karel@kubat.nl)</h2> @@ -1456,33 +1456,53 @@ The format is always <code>on</code><em>type</em> <em>command</em>. The <em>comm command is expanded according to the following table: <p> <ul> - <li> <code>%a</code> is the availability of the current back end, when - a current back end is established; - <li> <code>%1a</code> is the availability of the first back end (0 when - unavailable, 1 if available); <code>%2a</code> is the availability of - the second back end, and so on; - <li> <code>%b</code> is the name of the current back end, when one is - established; - <li> <code>%1b</code> is the name of the first back end, <code>%2b</code> of the - second back end, and so on; - <li> <code>%e</code> is the count of seconds since start of epoch - (January 1st 1970 GMT); - <li> <code>%h</code> is the host name of the current back end; - <li> <code>%1h</code> is the host name of the first back end, <code>%2h</code> - of the second back end, and so on; - <li> <code>%p</code> is the TCP port of the current back end; - <li> <code>%1p</code> is the TCP port of the first back end, <code>%2p</code> of - the second back end, and so on; - <li> <code>%r</code> is the IP address of the client that requests a - connection and for whom the external dispatcher should compute - a back end; - <li> <code>%s</code> is the name of the current service that the client - connected to; - <li> <code>%t</code> is the current local time in ASCII format, in - <em>YYYY-MM-DD/hhh:mm:ss</em>; - <li> <code>%T</code> is the current GMT time in ASCIII format; - <li> <code>%v</code> is the Crossroads version; - <li> Any other chararacter following a <code>%</code> sign is taken +<p> +<li> <code>%a</code> is the availability of the current back end, when + a current back end is established. <code>%1a</code> is the + availability of the first back end (0 when unavailable, 1 if + available); <code>%2a</code> is the availability of the second back + end, and so on. +<p> +<li> <code>%b</code> is the name of the current back end, when one is + established. <code>%1b</code> is the name of the first back end, + <code>%2b</code> of the second back end, and so on. +<p> +<li> <code>%e</code> is the count of seconds since start of epoch + (January 1st 1970 GMT). <code>%60e</code> is the count since start of + epoch plus 60, so this is a 1 minute offset into the future. +<p> +<li> <code>%g</code> is a "GMT-string" representation of the current + time, in the format <em>monthname, day year hh:mm:ss</em>. This + format is used in e.g. cookie expiry. <code>%600g</code> is the same + representation but of a moment 600 seconds in the future (10 + minutes). +<p> +<li> <code>%h</code> is the host name of the current back end. <code>%1h</code> + is the host name of the first back end, <code>%2h</code> of the second + back end, and so on. +<p> +<li> <code>%p</code> is the TCP port of the current back end. <code>%1p</code> + is the TCP port of the first back end, <code>%2p</code> of the second + back end, and so on. +<p> +<li> <code>%r</code> is the IP address of the connecting client. +<p> +<li> <code>%s</code> is the name of the current service that the client + connected to. +<p> +<li> <code>%t</code> is the current local time in ANSI format, in + <em>YYYY-MM-DD/hhh:mm:ss</em>. <code>%1800s</code> is an ANSI stamp of a + moment 1800 seconds in the future (half an hour). +<p> +<li> <code>%T</code> is the current GMT time in ANSI format. <code>%10T</code> + offsets this 10 seconds into the future. +<p> +<li> <code>%v</code> is the Crossroads version. +<p> +<li> <code>%w</code> is the weight factor of the current back + end. <code>%1w</code> is the weight factor of the first back end, etc.. +<p> +<li> Any other chararacter following a <code>%</code> sign is taken literally; e.g. <code>%z</code> is just a z.</ul> <p> <p><dt><strong>Syntax:</strong><dd> The syntax of the commands is as follows. @@ -1604,33 +1624,53 @@ The header value may contain one of the following formatting directives: <p> <ul> - <li> <code>%a</code> is the availability of the current back end, when - a current back end is established; - <li> <code>%1a</code> is the availability of the first back end (0 when - unavailable, 1 if available); <code>%2a</code> is the availability of - the second back end, and so on; - <li> <code>%b</code> is the name of the current back end, when one is - established; - <li> <code>%1b</code> is the name of the first back end, <code>%2b</code> of the - second back end, and so on; - <li> <code>%e</code> is the count of seconds since start of epoch - (January 1st 1970 GMT); - <li> <code>%h</code> is the host name of the current back end; - <li> <code>%1h</code> is the host name of the first back end, <code>%2h</code> - of the second back end, and so on; - <li> <code>%p</code> is the TCP port of the current back end; - <li> <code>%1p</code> is the TCP port of the first back end, <code>%2p</code> of - the second back end, and so on; - <li> <code>%r</code> is the IP address of the client that requests a - connection and for whom the external dispatcher should compute - a back end; - <li> <code>%s</code> is the name of the current service that the client - connected to; - <li> <code>%t</code> is the current local time in ASCII format, in - <em>YYYY-MM-DD/hhh:mm:ss</em>; - <li> <code>%T</code> is the current GMT time in ASCIII format; - <li> <code>%v</code> is the Crossroads version; - <li> Any other chararacter following a <code>%</code> sign is taken +<p> +<li> <code>%a</code> is the availability of the current back end, when + a current back end is established. <code>%1a</code> is the + availability of the first back end (0 when unavailable, 1 if + available); <code>%2a</code> is the availability of the second back + end, and so on. +<p> +<li> <code>%b</code> is the name of the current back end, when one is + established. <code>%1b</code> is the name of the first back end, + <code>%2b</code> of the second back end, and so on. +<p> +<li> <code>%e</code> is the count of seconds since start of epoch + (January 1st 1970 GMT). <code>%60e</code> is the count since start of + epoch plus 60, so this is a 1 minute offset into the future. +<p> +<li> <code>%g</code> is a "GMT-string" representation of the current + time, in the format <em>monthname, day year hh:mm:ss</em>. This + format is used in e.g. cookie expiry. <code>%600g</code> is the same + representation but of a moment 600 seconds in the future (10 + minutes). +<p> +<li> <code>%h</code> is the host name of the current back end. <code>%1h</code> + is the host name of the first back end, <code>%2h</code> of the second + back end, and so on. +<p> +<li> <code>%p</code> is the TCP port of the current back end. <code>%1p</code> + is the TCP port of the first back end, <code>%2p</code> of the second + back end, and so on. +<p> +<li> <code>%r</code> is the IP address of the connecting client. +<p> +<li> <code>%s</code> is the name of the current service that the client + connected to. +<p> +<li> <code>%t</code> is the current local time in ANSI format, in + <em>YYYY-MM-DD/hhh:mm:ss</em>. <code>%1800s</code> is an ANSI stamp of a + moment 1800 seconds in the future (half an hour). +<p> +<li> <code>%T</code> is the current GMT time in ANSI format. <code>%10T</code> + offsets this 10 seconds into the future. +<p> +<li> <code>%v</code> is the Crossroads version. +<p> +<li> <code>%w</code> is the weight factor of the current back + end. <code>%1w</code> is the weight factor of the first back end, etc.. +<p> +<li> Any other chararacter following a <code>%</code> sign is taken literally; e.g. <code>%z</code> is just a z.</ul> <p> The following examples show common uses of header modifications. @@ -1664,6 +1704,17 @@ The first request of an HTTP session is balanced to either in place; and is therefore sent to the same back end where the its predecessors went. <p> +The header which is sent to the client to inject a cookie, can + furthermore be expanded to specify a timeout: +<p> +<pre> +addclientheader "Set-Cookie: BalancerID=second; path=/; expires=%1800g"; +</pre> + +<p> +The format specifier <code>%1800g</code> outputs a GMT-string date 1800 + seconds in the future (half an hour from now). +<p> <p><dt><strong>Hiding the server software version:</strong><dd> Many servers (e.g. Apache) advertize their version, as in <code>Server: Apache 1.27</code>. This potentially provides information to attackers. The @@ -2225,33 +2276,53 @@ statuses will mark the back end as unavailable. The <em>arguments</em> are expanded according to the following table: <p> <ul> - <li> <code>%a</code> is the availability of the current back end, when - a current back end is established; - <li> <code>%1a</code> is the availability of the first back end (0 when - unavailable, 1 if available); <code>%2a</code> is the availability of - the second back end, and so on; - <li> <code>%b</code> is the name of the current back end, when one is - established; - <li> <code>%1b</code> is the name of the first back end, <code>%2b</code> of the - second back end, and so on; - <li> <code>%e</code> is the count of seconds since start of epoch - (January 1st 1970 GMT); - <li> <code>%h</code> is the host name of the current back end; - <li> <code>%1h</code> is the host name of the first back end, <code>%2h</code> - of the second back end, and so on; - <li> <code>%p</code> is the TCP port of the current back end; - <li> <code>%1p</code> is the TCP port of the first back end, <code>%2p</code> of - the second back end, and so on; - <li> <code>%r</code> is the IP address of the client that requests a - connection and for whom the external dispatcher should compute - a back end; - <li> <code>%s</code> is the name of the current service that the client - connected to; - <li> <code>%t</code> is the current local time in ASCII format, in - <em>YYYY-MM-DD/hhh:mm:ss</em>; - <li> <code>%T</code> is the current GMT time in ASCIII format; - <li> <code>%v</code> is the Crossroads version; - <li> Any other chararacter following a <code>%</code> sign is taken +<p> +<li> <code>%a</code> is the availability of the current back end, when + a current back end is established. <code>%1a</code> is the + availability of the first back end (0 when unavailable, 1 if + available); <code>%2a</code> is the availability of the second back + end, and so on. +<p> +<li> <code>%b</code> is the name of the current back end, when one is + established. <code>%1b</code> is the name of the first back end, + <code>%2b</code> of the second back end, and so on. +<p> +<li> <code>%e</code> is the count of seconds since start of epoch + (January 1st 1970 GMT). <code>%60e</code> is the count since start of + epoch plus 60, so this is a 1 minute offset into the future. +<p> +<li> <code>%g</code> is a "GMT-string" representation of the current + time, in the format <em>monthname, day year hh:mm:ss</em>. This + format is used in e.g. cookie expiry. <code>%600g</code> is the same + representation but of a moment 600 seconds in the future (10 + minutes). +<p> +<li> <code>%h</code> is the host name of the current back end. <code>%1h</code> + is the host name of the first back end, <code>%2h</code> of the second + back end, and so on. +<p> +<li> <code>%p</code> is the TCP port of the current back end. <code>%1p</code> + is the TCP port of the first back end, <code>%2p</code> of the second + back end, and so on. +<p> +<li> <code>%r</code> is the IP address of the connecting client. +<p> +<li> <code>%s</code> is the name of the current service that the client + connected to. +<p> +<li> <code>%t</code> is the current local time in ANSI format, in + <em>YYYY-MM-DD/hhh:mm:ss</em>. <code>%1800s</code> is an ANSI stamp of a + moment 1800 seconds in the future (half an hour). +<p> +<li> <code>%T</code> is the current GMT time in ANSI format. <code>%10T</code> + offsets this 10 seconds into the future. +<p> +<li> <code>%v</code> is the Crossroads version. +<p> +<li> <code>%w</code> is the weight factor of the current back + end. <code>%1w</code> is the weight factor of the first back end, etc.. +<p> +<li> Any other chararacter following a <code>%</code> sign is taken literally; e.g. <code>%z</code> is just a z.</ul> <p> <a name="l63"></a> @@ -2461,6 +2532,9 @@ service www { server 10.1.1.100:80; stickycookie XRID=100; addclientheader "Set-Cookie: XRID=100; Path=/"; + /* or: XRID=100; Path=/; Expires=%600g + * This would make the session cookie expire in 600 sec (10 mins) + */ } backend two { @@ -2957,33 +3031,53 @@ arguments to your dispatch helper. You use the following special format specifiers in the argument list: <p> <ul> - <li> <code>%a</code> is the availability of the current back end, when - a current back end is established; - <li> <code>%1a</code> is the availability of the first back end (0 when - unavailable, 1 if available); <code>%2a</code> is the availability of - the second back end, and so on; - <li> <code>%b</code> is the name of the current back end, when one is - established; - <li> <code>%1b</code> is the name of the first back end, <code>%2b</code> of the - second back end, and so on; - <li> <code>%e</code> is the count of seconds since start of epoch - (January 1st 1970 GMT); - <li> <code>%h</code> is the host name of the current back end; - <li> <code>%1h</code> is the host name of the first back end, <code>%2h</code> - of the second back end, and so on; - <li> <code>%p</code> is the TCP port of the current back end; - <li> <code>%1p</code> is the TCP port of the first back end, <code>%2p</code> of - the second back end, and so on; - <li> <code>%r</code> is the IP address of the client that requests a - connection and for whom the external dispatcher should compute - a back end; - <li> <code>%s</code> is the name of the current service that the client - connected to; - <li> <code>%t</code> is the current local time in ASCII format, in - <em>YYYY-MM-DD/hhh:mm:ss</em>; - <li> <code>%T</code> is the current GMT time in ASCIII format; - <li> <code>%v</code> is the Crossroads version; - <li> Any other chararacter following a <code>%</code> sign is taken +<p> +<li> <code>%a</code> is the availability of the current back end, when + a current back end is established. <code>%1a</code> is the + availability of the first back end (0 when unavailable, 1 if + available); <code>%2a</code> is the availability of the second back + end, and so on. +<p> +<li> <code>%b</code> is the name of the current back end, when one is + established. <code>%1b</code> is the name of the first back end, + <code>%2b</code> of the second back end, and so on. +<p> +<li> <code>%e</code> is the count of seconds since start of epoch + (January 1st 1970 GMT). <code>%60e</code> is the count since start of + epoch plus 60, so this is a 1 minute offset into the future. +<p> +<li> <code>%g</code> is a "GMT-string" representation of the current + time, in the format <em>monthname, day year hh:mm:ss</em>. This + format is used in e.g. cookie expiry. <code>%600g</code> is the same + representation but of a moment 600 seconds in the future (10 + minutes). +<p> +<li> <code>%h</code> is the host name of the current back end. <code>%1h</code> + is the host name of the first back end, <code>%2h</code> of the second + back end, and so on. +<p> +<li> <code>%p</code> is the TCP port of the current back end. <code>%1p</code> + is the TCP port of the first back end, <code>%2p</code> of the second + back end, and so on. +<p> +<li> <code>%r</code> is the IP address of the connecting client. +<p> +<li> <code>%s</code> is the name of the current service that the client + connected to. +<p> +<li> <code>%t</code> is the current local time in ANSI format, in + <em>YYYY-MM-DD/hhh:mm:ss</em>. <code>%1800s</code> is an ANSI stamp of a + moment 1800 seconds in the future (half an hour). +<p> +<li> <code>%T</code> is the current GMT time in ANSI format. <code>%10T</code> + offsets this 10 seconds into the future. +<p> +<li> <code>%v</code> is the Crossroads version. +<p> +<li> <code>%w</code> is the weight factor of the current back + end. <code>%1w</code> is the weight factor of the first back end, etc.. +<p> +<li> Any other chararacter following a <code>%</code> sign is taken literally; e.g. <code>%z</code> is just a z.</ul> <p> Note that the format specifiers such as <code>%b</code> don't make sense in the diff --git a/doc/crossroads.pdf b/doc/crossroads.pdf Binary files differ. diff --git a/doc/main/conf/addclientheader.yo b/doc/main/conf/addclientheader.yo @@ -74,6 +74,15 @@ service ... { in place; and is therefore sent to the same back end where the its predecessors went. + The header which is sent to the client to inject a cookie, can + furthermore be expanded to specify a timeout: + + verb(\ +addclientheader "Set-Cookie: BalancerID=second; path=/; expires=%1800g";) + + The format specifier tt(%1800g) outputs a GMT-string date 1800 + seconds in the future (half an hour from now). + dit(Hiding the server software version:) Many servers (e.g. Apache) advertize their version, as in tt(Server: Apache 1.27). This potentially provides information to attackers. The diff --git a/doc/main/formattable.yo b/doc/main/formattable.yo @@ -1,29 +1,49 @@ itemization( + it() tt(%a) is the availability of the current back end, when - a current back end is established; - it() tt(%1a) is the availability of the first back end (0 when - unavailable, 1 if available); tt(%2a) is the availability of - the second back end, and so on; + a current back end is established. tt(%1a) is the + availability of the first back end (0 when unavailable, 1 if + available); tt(%2a) is the availability of the second back + end, and so on. + it() tt(%b) is the name of the current back end, when one is - established; - it() tt(%1b) is the name of the first back end, tt(%2b) of the - second back end, and so on; + established. tt(%1b) is the name of the first back end, + tt(%2b) of the second back end, and so on. + it() tt(%e) is the count of seconds since start of epoch - (January 1st 1970 GMT); - it() tt(%h) is the host name of the current back end; - it() tt(%1h) is the host name of the first back end, tt(%2h) - of the second back end, and so on; - it() tt(%p) is the TCP port of the current back end; - it() tt(%1p) is the TCP port of the first back end, tt(%2p) of - the second back end, and so on; - it() tt(%r) is the IP address of the client that requests a - connection and for whom the external dispatcher should compute - a back end; + (January 1st 1970 GMT). tt(%60e) is the count since start of + epoch plus 60, so this is a 1 minute offset into the future. + + it() tt(%g) is a "GMT-string" representation of the current + time, in the format em(monthname, day year hh:mm:ss). This + format is used in e.g. cookie expiry. tt(%600g) is the same + representation but of a moment 600 seconds in the future (10 + minutes). + + it() tt(%h) is the host name of the current back end. tt(%1h) + is the host name of the first back end, tt(%2h) of the second + back end, and so on. + + it() tt(%p) is the TCP port of the current back end. tt(%1p) + is the TCP port of the first back end, tt(%2p) of the second + back end, and so on. + + it() tt(%r) is the IP address of the connecting client. + it() tt(%s) is the name of the current service that the client - connected to; - it() tt(%t) is the current local time in ASCII format, in - em(YYYY-MM-DD/hhh:mm:ss); - it() tt(%T) is the current GMT time in ASCIII format; - it() tt(%v) is the Crossroads version; + connected to. + + it() tt(%t) is the current local time in ANSI format, in + em(YYYY-MM-DD/hhh:mm:ss). tt(%1800s) is an ANSI stamp of a + moment 1800 seconds in the future (half an hour). + + it() tt(%T) is the current GMT time in ANSI format. tt(%10T) + offsets this 10 seconds into the future. + + it() tt(%v) is the Crossroads version. + + it() tt(%w) is the weight factor of the current back + end. tt(%1w) is the weight factor of the first back end, etc.. + it() Any other chararacter following a tt(%) sign is taken literally; e.g. tt(%z) is just a z.) diff --git a/doc/main/tips/httpstickiness.yo b/doc/main/tips/httpstickiness.yo @@ -100,6 +100,9 @@ service www { server 10.1.1.100:80; stickycookie XRID=100; addclientheader "Set-Cookie: XRID=100; Path=/"; + /* or: XRID=100; Path=/; Expires=%600g + * This would make the session cookie expire in 600 sec (10 mins) + */ } backend two { @@ -112,3 +115,4 @@ service www { Note how the cookie names and values in the directives tt(stickycookie) and tt(addclientheader) match. That is obviously a prerequisite for stickiness. + diff --git a/etc/Makefile.def b/etc/Makefile.def @@ -6,7 +6,7 @@ # Versioning. This defines the overall version ID and must match the topmost # entry in the ChangeLog. -VER = 1.61 +VER = 1.62 # Years that Crossroads has been 'round. YEARS = 2005-2007 diff --git a/etc/svnrev.txt b/etc/svnrev.txt @@ -1 +1 @@ -200 +202 diff --git a/src/crossroads-daemon/main.c b/src/crossroads-daemon/main.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/crossroads.h b/src/crossroads.h @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ @@ -354,7 +354,7 @@ EXTERN char *yytext; /* lexical buffer */ // #undef __attribute__ // #define __attribute(x) extern void alloc_reporter (Service *active, int first); -extern char *ansistamp (TmType t); +extern char *ansistamp (TmType t, int offset); extern int backend_available (int target); extern int backend_count(void); extern int backend_connect (void); @@ -370,6 +370,7 @@ extern struct in_addr *dns (char const *hostname); extern void error (char const *fmt, ...) __attribute__ ((format (printf, 1, 2))); extern int fork_tcp_servicer (int to_backend); +extern char *gmtstamp (int offset); extern int hashpjw (char const *s); extern void http_copy (HttpHeader *h, int src_sock, int dst_sock, CopyDirection dir); diff --git a/src/crossroads/main.c b/src/crossroads/main.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/allocreporter.c b/src/lib/allocreporter.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/ansistamp.c b/src/lib/ansistamp.c @@ -1,17 +1,18 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ #include "../crossroads.h" -char *ansistamp (TmType t) { +char *ansistamp (TmType t, int offset) { static char buf[80]; time_t now; struct tm *tmp; time (&now); + now += offset; if (t == tm_localtime) tmp = localtime (&now); else diff --git a/src/lib/backendavailable.c b/src/lib/backendavailable.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/backendconnect.c b/src/lib/backendconnect.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/backendcount.c b/src/lib/backendcount.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/choosebackend.c b/src/lib/choosebackend.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/configread.c b/src/lib/configread.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/configtest.c b/src/lib/configtest.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/configwrite.c b/src/lib/configwrite.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/copysockets.c b/src/lib/copysockets.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/createcommandlinespace.c b/src/lib/createcommandlinespace.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/data.c b/src/lib/data.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/deallocreporter.c b/src/lib/deallocreporter.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/decrclientcount.c b/src/lib/decrclientcount.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/dns.c b/src/lib/dns.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/error.c b/src/lib/error.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/forktcpservicer.c b/src/lib/forktcpservicer.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/gmtstamp.c b/src/lib/gmtstamp.c @@ -0,0 +1,26 @@ +/************************************************************************* + * This file is part of Crosroads 1.62, a load balancer and fail over + * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. + * Visit http://crossroads.e-tunity.com for information. + *************************************************************************/ + +#include "../crossroads.h" + +char *gmtstamp (int offset) { + static char buf[80]; + time_t now; + struct tm *tmp; + static char *monthname[] = { + "January", "February", "March", "April", + "May", "June", "July", "August", "September", + "October", "November", "December" }; + + time (&now); + now += offset; + tmp = gmtime (&now); + + snprintf (buf, sizeof(buf), "%s, %d %4.4d %2.2d:%2.2d:%2.2d", + monthname[tmp->tm_mon], tmp->tm_mday, tmp->tm_year + 1900, + tmp->tm_hour, tmp->tm_min, tmp->tm_sec); + return (buf); +} diff --git a/src/lib/hashpjw.c b/src/lib/hashpjw.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/httpcopy.c b/src/lib/httpcopy.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/httperror.c b/src/lib/httperror.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/httpheaderaddheader.c b/src/lib/httpheaderaddheader.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/httpheaderappendheader.c b/src/lib/httpheaderappendheader.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/httpheaderconnectiontype.c b/src/lib/httpheaderconnectiontype.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/httpheaderfree.c b/src/lib/httpheaderfree.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/httpheaderhascookie.c b/src/lib/httpheaderhascookie.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/httpheaderhttpver.c b/src/lib/httpheaderhttpver.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/httpheadernew.c b/src/lib/httpheadernew.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/httpheaderread.c b/src/lib/httpheaderread.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/httpheaderremoveheader.c b/src/lib/httpheaderremoveheader.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/httpheadersetheader.c b/src/lib/httpheadersetheader.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/httpheaderval.c b/src/lib/httpheaderval.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/httpheaderwrite.c b/src/lib/httpheaderwrite.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/httpinsertheader.c b/src/lib/httpinsertheader.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/httpserve.c b/src/lib/httpserve.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/httpserversocket.c b/src/lib/httpserversocket.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/httpwrite.c b/src/lib/httpwrite.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/incrclientcount.c b/src/lib/incrclientcount.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/initsockaddr.c b/src/lib/initsockaddr.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/interrupt.c b/src/lib/interrupt.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/ipfaddallow.c b/src/lib/ipfaddallow.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/ipfadddeny.c b/src/lib/ipfadddeny.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/ipfallowed.c b/src/lib/ipfallowed.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/ipfdenied.c b/src/lib/ipfdenied.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/ipfloadfile.c b/src/lib/ipfloadfile.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/ipfmatch.c b/src/lib/ipfmatch.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/ipfparse.c b/src/lib/ipfparse.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/ishexdigit.c b/src/lib/ishexdigit.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/isspace.c b/src/lib/isspace.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/lexer.c b/src/lib/lexer.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/lockreporter.c b/src/lib/lockreporter.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/logactivityany.c b/src/lib/logactivityany.c @@ -1,8 +1,9 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ + #include "../crossroads.h" void log_activity_any (char const *action) { @@ -11,7 +12,7 @@ void log_activity_any (char const *action) { if (!logstarted++) openlog ("crossroads", LOG_PID, log_facility); syslog (LOG_NOTICE, "%s %s %s from %s to %s:%d", - ansistamp(tm_localtime), action, activeservice->name, + ansistamp(tm_localtime, 0), action, activeservice->name, client_ip, servicereport->backendstate[current_backend].actual_server, servicereport->backendstate[current_backend].actual_port); diff --git a/src/lib/logactivitycontinuation.c b/src/lib/logactivitycontinuation.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/logactivityend.c b/src/lib/logactivityend.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/logactivitystart.c b/src/lib/logactivitystart.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/makesocket.c b/src/lib/makesocket.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/markactivity.c b/src/lib/markactivity.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/msg.c b/src/lib/msg.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/msgdumpbuf.c b/src/lib/msgdumpbuf.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/netbuffer.c b/src/lib/netbuffer.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/netbufread.c b/src/lib/netbufread.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/netcopy.c b/src/lib/netcopy.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/netread.c b/src/lib/netread.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/netwrite.c b/src/lib/netwrite.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/parser.c b/src/lib/parser.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/parserclose.c b/src/lib/parserclose.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/parserfilename.c b/src/lib/parserfilename.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/parserinput.c b/src/lib/parserinput.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/parseropen.c b/src/lib/parseropen.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/parserrun.c b/src/lib/parserrun.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/parserskipchar.c b/src/lib/parserskipchar.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/parserskipline.c b/src/lib/parserskipline.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/restart.c b/src/lib/restart.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/runservice.c b/src/lib/runservice.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/serve.c b/src/lib/serve.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/setproctitle.c b/src/lib/setproctitle.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/showconfig.c b/src/lib/showconfig.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/showservices.c b/src/lib/showservices.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/showstatus.c b/src/lib/showstatus.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/stagetostring.c b/src/lib/stagetostring.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/statetostring.c b/src/lib/statetostring.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/stopdaemon.c b/src/lib/stopdaemon.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/strcasestr.c b/src/lib/strcasestr.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/strexpandformat.c b/src/lib/strexpandformat.c @@ -1,66 +1,98 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ + #include "../crossroads.h" -char *fmt_expand (char const *s, int *skip, int target_backend) { +char *fmt_expand (char const *s, int *skip, int fmt_number) { static char buf[80]; - char *ret; + int nextnumber; /* Expansion table: * %a - availability of current back end (if any), 0 not available, * %1a = first back end etc. * %b - name of current back end (if any), %1b = first back end etc - * %e - seconds since epoch + * %e - seconds since epoch, number is an addition count + * %g - GMT format timestamp. The time in between is the minutes + * offset into the future, so %30g is now + 1/2 hour + * %h - actual serveraddress of current back end, %h1 = first etc. * %n - nr of clients of current back end, %1n = first back end etc. - * %r - client IP - * %s - name of service - * %t, %T - timestamp of local or GMT time - * %v - Crossroads version + * %p - actual port of current back end, %1p = first etc. + * %r - client IP, number is not interpreted + * %s - name of service, number is not interpreted + * %t, %T - ANSI timestamp of local or GMT time, number is offset in min + * into the future + * %v - Crossroads version, number not interpreted * %w - weight of current back end, %1w = first back end etc. - * %h - hostname of current back end, %1h = first etc. - * %p - port of current back end, %1p = first etc. */ - *skip = 1; + (*skip)++; + /* + msg ("Service %s: Fmt expand [%s], skip=%d, nr=%d", + activeservice->name, s, *skip, fmt_number); + */ + switch (*s) { case 'a': - if (target_backend < 0 || target_backend >= activeservice->nbackend || - !backend_available (target_backend)) + if (!fmt_number) + fmt_number = current_backend; + else + fmt_number--; + if (fmt_number < 0 || fmt_number >= activeservice->nbackend || + !backend_available (fmt_number)) return ("0"); return ("1"); case 'b': - if (target_backend >= 0 && target_backend < activeservice->nbackend) - return (activeservice->backend[target_backend].name); + if (!fmt_number) + fmt_number = current_backend; + else + fmt_number--; + if (fmt_number >= 0 && fmt_number < activeservice->nbackend) + return (activeservice->backend[fmt_number].name); return ("noname"); case 'e': - snprintf (buf, sizeof(buf) - 1, "%u", (unsigned) time(0)); + snprintf (buf, sizeof(buf) - 1, "%u", (unsigned) time(0) + fmt_number); return (buf); + case 'g': + return (gmtstamp (fmt_number)); + case 'h': - if (target_backend < 0 || target_backend >= activeservice->nbackend) + if (!fmt_number) + fmt_number = current_backend; + else + fmt_number--; + if (fmt_number < 0 || fmt_number >= activeservice->nbackend) return ("noname"); - return (servicereport->backendstate[target_backend].actual_server); + return (servicereport->backendstate[fmt_number].actual_server); case 'n': - if (target_backend >= 0 && target_backend < activeservice->nbackend) { + if (!fmt_number) + fmt_number = current_backend; + else + fmt_number--; + if (fmt_number >= 0 && fmt_number < activeservice->nbackend) { snprintf (buf, sizeof(buf) - 1, "%u", (unsigned) - servicereport->backendstate[target_backend].nclients); + servicereport->backendstate[fmt_number].nclients); return (buf); } return ("0"); case 'p': - if (target_backend < 0 || target_backend >= activeservice->nbackend) + if (!fmt_number) + fmt_number = current_backend; + else + fmt_number--; + if (fmt_number < 0 || fmt_number >= activeservice->nbackend) return ("0"); snprintf (buf, sizeof(buf), "%d", - servicereport->backendstate[target_backend].actual_port); + servicereport->backendstate[fmt_number].actual_port); return (buf); case 'r': @@ -72,33 +104,49 @@ char *fmt_expand (char const *s, int *skip, int target_backend) { return (activeservice->name); case 't': - return (ansistamp (tm_localtime)); + return (ansistamp (tm_localtime, fmt_number)); case 'T': - return (ansistamp (tm_gmtime)); + return (ansistamp (tm_gmtime, fmt_number)); case 'v': return (VER); case 'w': - if (target_backend >= 0 && target_backend < activeservice->nbackend) { + if (!fmt_number) + fmt_number = current_backend; + else + fmt_number--; + if (fmt_number >= 0 && fmt_number < activeservice->nbackend) { snprintf (buf, sizeof(buf) - 1, "%u", (unsigned) - activeservice->backend[target_backend].weight); + activeservice->backend[fmt_number].weight); return (buf); } return ("0"); + + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + nextnumber = atoi(s); + while (isdigit (*s)) { + (*skip)++; + s++; + } + (*skip)--; + return (fmt_expand (s, skip, nextnumber)); default: - if (isdigit (*s)) { - ret = fmt_expand (s + 1, skip, *s - '0' - 1); - *skip += 1; - return (ret); - } else { - *buf = *(s + 1); - *(buf + 1) = 0; - return (buf); - } + *buf = *(s + 1); + *(buf + 1) = 0; + return (buf); } } @@ -109,12 +157,17 @@ char *str_expand_format (char const *h) { for (cp = h; cp && *cp; cp++) { if (*cp == '%') { - ret = xstrcat (ret, fmt_expand (cp + 1, &skip, current_backend)); + skip = 0; + ret = xstrcat (ret, fmt_expand (cp + 1, &skip, 0)); cp += skip; } else { ret = xstrcatch (ret, *cp); } } + /* + msg ("Service %s: String [%s] expanded to [%s]", + activeservice->name, h, ret); + */ return (ret); } diff --git a/src/lib/stringtostate.c b/src/lib/stringtostate.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/strlcat.c b/src/lib/strlcat.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/strprintf.c b/src/lib/strprintf.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/strupr.c b/src/lib/strupr.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/strvprintf.c b/src/lib/strvprintf.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/symtabend.c b/src/lib/symtabend.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/symtablookup.c b/src/lib/symtablookup.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/symtabset.c b/src/lib/symtabset.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/symtabstart.c b/src/lib/symtabstart.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/sysrun.c b/src/lib/sysrun.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/tcpserve.c b/src/lib/tcpserve.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/tellservice.c b/src/lib/tellservice.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/thruputlog.c b/src/lib/thruputlog.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/trafficlog.c b/src/lib/trafficlog.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/uidassume.c b/src/lib/uidassume.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/uidrestore.c b/src/lib/uidrestore.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/unlockreporter.c b/src/lib/unlockreporter.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/usage.c b/src/lib/usage.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/vsyslog.c b/src/lib/vsyslog.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/wakeuphandler.c b/src/lib/wakeuphandler.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/warning.c b/src/lib/warning.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/writelog.c b/src/lib/writelog.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/xcalloc.c b/src/lib/xcalloc.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/xmalloc.c b/src/lib/xmalloc.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/xrealloc.c b/src/lib/xrealloc.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/xstrcat.c b/src/lib/xstrcat.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/xstrcatch.c b/src/lib/xstrcatch.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ diff --git a/src/lib/xstrdup.c b/src/lib/xstrdup.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.61, a load balancer and fail over + * This file is part of Crosroads 1.62, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/