crossroads

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

commit 20aa2d4ef18dc42a0457e38bc3e9f43d794e3f55
parent c01a15c5bbd80be1518f0332b1f1e05edfd6b25d
Author: finwo <finwo@pm.me>
Date:   Sat,  3 Jan 2026 19:33:47 +0100

1.64

Diffstat:
MChangeLog | 13+++++++++++++
MMakefile | 9+++++----
Mdoc/crossroads.html | 431++++++++++++++++++++++++++++++++++++++++++-------------------------------------
Mdoc/crossroads.pdf | 0
Mdoc/main/compiling.yo | 19+++++++++++++++++++
Mdoc/main/intro.yo | 11++++++++++-
Metc/Makefile.def | 2+-
Metc/svnrev.txt | 2+-
Msrc/crossroads-daemon/main.c | 2+-
Msrc/crossroads.h | 20+++++++++++---------
Msrc/crossroads/main.c | 16++++++++--------
Msrc/lib/allocreporter.c | 2+-
Msrc/lib/ansistamp.c | 2+-
Msrc/lib/backendavailable.c | 2+-
Msrc/lib/backendconnect.c | 2+-
Msrc/lib/backendcount.c | 2+-
Asrc/lib/checkservice.c | 83+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/lib/choosebackend.c | 2+-
Asrc/lib/cmdconfigtest.c | 12++++++++++++
Asrc/lib/cmdrestart.c | 24++++++++++++++++++++++++
Asrc/lib/cmdservices.c | 26++++++++++++++++++++++++++
Asrc/lib/cmdstart.c | 29+++++++++++++++++++++++++++++
Asrc/lib/cmdstatus.c | 190+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/lib/cmdstop.c | 35+++++++++++++++++++++++++++++++++++
Asrc/lib/cmdtell.c | 73+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/lib/configread.c | 2+-
Dsrc/lib/configtest.c | 12------------
Msrc/lib/configwrite.c | 2+-
Msrc/lib/copysockets.c | 2+-
Msrc/lib/createcommandlinespace.c | 42++++++++++++++++++++++++------------------
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 | 22++++++++++++----------
Msrc/lib/gmtstamp.c | 2+-
Msrc/lib/hashpjw.c | 6+++---
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 | 22++++++++++++----------
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 | 2+-
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 | 336+++++++++++++++++++++++++++++++++++--------------------------------------------
Msrc/lib/parser.y | 44++++----------------------------------------
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+-
Dsrc/lib/restart.c | 24------------------------
Msrc/lib/runservice.c | 6++++--
Dsrc/lib/serve.c | 29-----------------------------
Msrc/lib/setproctitle.c | 2+-
Msrc/lib/showconfig.c | 2+-
Dsrc/lib/showservices.c | 25-------------------------
Dsrc/lib/showstatus.c | 190-------------------------------------------------------------------------------
Msrc/lib/stagetostring.c | 2+-
Msrc/lib/statetostring.c | 2+-
Dsrc/lib/stopdaemon.c | 35-----------------------------------
Msrc/lib/strcasestr.c | 2+-
Msrc/lib/strexpandformat.c | 2+-
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 | 7++++---
Dsrc/lib/tellservice.c | 73-------------------------------------------------------------------------
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/usage.txt | 10++++++----
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+-
Msrc/shared/parseopt.inc | 5++++-
Mtest/Makefile | 12+++++++++++-
Atest/bad21.conf | 9+++++++++
Atest/hashtest.c | 45+++++++++++++++++++++++++++++++++++++++++++++
137 files changed, 1158 insertions(+), 989 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,6 +1,19 @@ ChangeLog for Crossroads ------------------------------------------------------------------------------ +1.64 [KK 2007-12-27] + - Bugfix in "dispatchmode byclientip" + - Added testing utility test/hashtest + - The parser is stricter. HTTP-related directives are now only + allowed when 'type http' is given. + +1.63 [KK 2007-12-10] + - Cosmetic change to usage text. + - Flag -p implemented. + - Commandline functions (start/stop) etc now in properly named + §sources. + [KK 2007-12-14] Promoted to Stable. + 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 diff --git a/Makefile b/Makefile @@ -9,7 +9,7 @@ foo: local: BASE=$(BASE) $(MAKE) -C src - make -C test + BASE=$(BASE) $(MAKE) -C test install: local BASE=$(BASE) $(MAKE) -C src install @@ -23,14 +23,15 @@ documentation: BASE=$(BASE) $(MAKE) -C doc clean: - BASE=$(BASE) $(MAKE) -C src clean - BASE=$(BASE) $(MAKE) -C doc clean find $(BASE) -type f -name '*~' -exec rm {} \; find $(BASE) -type f -name .gdb_history -exec rm {} \; + BASE=$(BASE) $(MAKE) -C doc clean + BASE=$(BASE) $(MAKE) -C test clean + BASE=$(BASE) $(MAKE) -C src clean distclean: - BASE=$(BASE) $(MAKE) -C src distclean BASE=$(BASE) $(MAKE) -C doc distclean + BASE=$(BASE) $(MAKE) -C src distclean dist: documentation $(BASE)/tools/e-ver ChangeLog $(VER) 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.62</title> +<title>Crossroads 1.64</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.62</h1> +<h1>Crossroads 1.64</h1> <h2>Karel Kubat <br> Maintained by Karel Kubat (karel@kubat.nl)</h2> @@ -36,143 +36,145 @@ <dt><a href="#l5">1.4: Terminology</a></dt> <dt><a href="#l6">1.5: Porting Issues</a></dt> <dl> -<dt><a href="#l7">1.5.1: Porting issues fdor pre-1.50 installations</a></dt> -<dt><a href="#l8">1.5.2: Porting issues for pre-1.43 installations</a></dt> -<dt><a href="#l9">1.5.3: Porting issues for pre-1.21 installations</a></dt> -<dt><a href="#l10">1.5.4: Porting issues for pre-0.26 installations</a></dt> -<dt><a href="#l11">1.5.5: Porting issues for pre-1.08 installations</a></dt> +<dt><a href="#l7">1.5.1: Porting issues for pre-1.63 installations</a></dt> +<dt><a href="#l8">1.5.2: Porting issues for pre-1.50 installations</a></dt> +<dt><a href="#l9">1.5.3: Porting issues for pre-1.43 installations</a></dt> +<dt><a href="#l10">1.5.4: Porting issues for pre-1.21 installations</a></dt> +<dt><a href="#l11">1.5.5: Porting issues for pre-0.26 installations</a></dt> +<dt><a href="#l12">1.5.6: Porting issues for pre-1.08 installations</a></dt> </dl> </dl> -<dt><h3><a href="#l12">2: Installation for the impatient</a></h3></dt> -<dt><h3><a href="#l13">3: Using Crossroads</a></h3></dt> +<dt><h3><a href="#l13">2: Installation for the impatient</a></h3></dt> +<dt><h3><a href="#l14">3: Using Crossroads</a></h3></dt> <dl> -<dt><a href="#l14">3.1: The Balancer: crossroads</a></dt> +<dt><a href="#l15">3.1: The Balancer: crossroads</a></dt> <dl> -<dt><a href="#l15">3.1.1: General Commandline Syntax</a></dt> -<dt><a href="#l16">3.1.2: Status Reporting from the Command Line</a></dt> -<dt><a href="#l17">3.1.3: Logging-related options</a></dt> -<dt><a href="#l18">3.1.4: Reloading Configurations</a></dt> +<dt><a href="#l16">3.1.1: General Commandline Syntax</a></dt> +<dt><a href="#l17">3.1.2: Status Reporting from the Command Line</a></dt> +<dt><a href="#l18">3.1.3: Logging-related options</a></dt> +<dt><a href="#l19">3.1.4: Reloading Configurations</a></dt> </dl> -<dt><a href="#l19">3.2: The Web Frontend: crossroads-mgr</a></dt> +<dt><a href="#l20">3.2: The Web Frontend: crossroads-mgr</a></dt> </dl> -<dt><h3><a href="#l20">4: The configuration</a></h3></dt> +<dt><h3><a href="#l21">4: The configuration</a></h3></dt> <dl> -<dt><a href="#l21">4.1: General language elements</a></dt> +<dt><a href="#l22">4.1: General language elements</a></dt> <dl> -<dt><a href="#l22">4.1.1: Empty lines and comments</a></dt> -<dt><a href="#l23">4.1.2: Preprocessor directives</a></dt> -<dt><a href="#l24">4.1.3: Keywords, numbers, identifiers, generic strings</a></dt> +<dt><a href="#l23">4.1.1: Empty lines and comments</a></dt> +<dt><a href="#l24">4.1.2: Preprocessor directives</a></dt> +<dt><a href="#l25">4.1.3: Keywords, numbers, identifiers, generic strings</a></dt> </dl> -<dt><a href="#l25">4.2: Service definitions</a></dt> +<dt><a href="#l26">4.2: Service definitions</a></dt> <dl> -<dt><a href="#l26">4.2.1: port - Specifying the listen port</a></dt> -<dt><a href="#l27">4.2.2: type - Defining the service type</a></dt> -<dt><a href="#l28">4.2.3: headerinspection - are all HTTP headers inspected</a></dt> -<dt><a href="#l29">4.2.4: bindto - Binding to a specific IP address</a></dt> -<dt><a href="#l30">4.2.5: verbosity - Controlling debug output</a></dt> -<dt><a href="#l31">4.2.6: dispatchmode - How are back ends selected</a></dt> -<dt><a href="#l32">4.2.7: revivinginterval - Back end wakeup calls</a></dt> -<dt><a href="#l33">4.2.8: checkinterval - Periodic back end checks</a></dt> -<dt><a href="#l34">4.2.9: maxconnections - Limiting concurrent clients at service level</a></dt> -<dt><a href="#l35">4.2.10: backlog - The TCP Back Log size</a></dt> -<dt><a href="#l36">4.2.11: shmkey - Shared Memory Access</a></dt> -<dt><a href="#l37">4.2.12: allow* and deny* - Allowing or denying connections</a></dt> -<dt><a href="#l38">4.2.13: useraccount - Limiting the effective ID of external processes</a></dt> +<dt><a href="#l27">4.2.1: port - Specifying the listen port</a></dt> +<dt><a href="#l28">4.2.2: type - Defining the service type</a></dt> +<dt><a href="#l29">4.2.3: headerinspection - are all HTTP headers inspected</a></dt> +<dt><a href="#l30">4.2.4: bindto - Binding to a specific IP address</a></dt> +<dt><a href="#l31">4.2.5: verbosity - Controlling debug output</a></dt> +<dt><a href="#l32">4.2.6: dispatchmode - How are back ends selected</a></dt> +<dt><a href="#l33">4.2.7: revivinginterval - Back end wakeup calls</a></dt> +<dt><a href="#l34">4.2.8: checkinterval - Periodic back end checks</a></dt> +<dt><a href="#l35">4.2.9: maxconnections - Limiting concurrent clients at service level</a></dt> +<dt><a href="#l36">4.2.10: backlog - The TCP Back Log size</a></dt> +<dt><a href="#l37">4.2.11: shmkey - Shared Memory Access</a></dt> +<dt><a href="#l38">4.2.12: allow* and deny* - Allowing or denying connections</a></dt> +<dt><a href="#l39">4.2.13: useraccount - Limiting the effective ID of external processes</a></dt> </dl> -<dt><a href="#l39">4.3: Backend definitions</a></dt> +<dt><a href="#l40">4.3: Backend definitions</a></dt> <dl> -<dt><a href="#l40">4.3.1: server - Specifying the back end address</a></dt> -<dt><a href="#l41">4.3.2: port - Specifying a back end port</a></dt> -<dt><a href="#l42">4.3.3: verbosity - Controlling verbosity at the back end level</a></dt> -<dt><a href="#l43">4.3.4: retries - Specifying allowed failures</a></dt> -<dt><a href="#l44">4.3.5: weight - When a back end is more equal than others</a></dt> -<dt><a href="#l45">4.3.6: decay - Levelling out activity of a back end</a></dt> -<dt><a href="#l46">4.3.7: state - Setting an initial back end state</a></dt> -<dt><a href="#l47">4.3.8: onstart, onend, onfail - Action Hooks</a></dt> -<dt><a href="#l48">4.3.9: trafficlog and throughputlog - Debugging and Performance Aids</a></dt> -<dt><a href="#l49">4.3.10: stickycookie - Back end selection with an HTTP cookie</a></dt> -<dt><a href="#l50">4.3.11: HTTP Header Modification Directives</a></dt> +<dt><a href="#l41">4.3.1: server - Specifying the back end address</a></dt> +<dt><a href="#l42">4.3.2: port - Specifying a back end port</a></dt> +<dt><a href="#l43">4.3.3: verbosity - Controlling verbosity at the back end level</a></dt> +<dt><a href="#l44">4.3.4: retries - Specifying allowed failures</a></dt> +<dt><a href="#l45">4.3.5: weight - When a back end is more equal than others</a></dt> +<dt><a href="#l46">4.3.6: decay - Levelling out activity of a back end</a></dt> +<dt><a href="#l47">4.3.7: state - Setting an initial back end state</a></dt> +<dt><a href="#l48">4.3.8: onstart, onend, onfail - Action Hooks</a></dt> +<dt><a href="#l49">4.3.9: trafficlog and throughputlog - Debugging and Performance Aids</a></dt> +<dt><a href="#l50">4.3.10: stickycookie - Back end selection with an HTTP cookie</a></dt> +<dt><a href="#l51">4.3.11: HTTP Header Modification Directives</a></dt> </dl> </dl> -<dt><h3><a href="#l51">5: Tips, Tricks and Random Remarks</a></h3></dt> +<dt><h3><a href="#l52">5: Tips, Tricks and Random Remarks</a></h3></dt> <dl> -<dt><a href="#l52">5.1: Configuration examples</a></dt> +<dt><a href="#l53">5.1: Configuration examples</a></dt> <dl> -<dt><a href="#l53">5.1.1: A load balancer for three webserver back ends</a></dt> -<dt><a href="#l54">5.1.2: An HTTP forwarder when travelling</a></dt> -<dt><a href="#l55">5.1.3: SSH login with enforced idle logout</a></dt> +<dt><a href="#l54">5.1.1: A load balancer for three webserver back ends</a></dt> +<dt><a href="#l55">5.1.2: An HTTP forwarder when travelling</a></dt> +<dt><a href="#l56">5.1.3: SSH login with enforced idle logout</a></dt> </dl> -<dt><a href="#l56">5.2: How back ends are selected in load balancing</a></dt> +<dt><a href="#l57">5.2: How back ends are selected in load balancing</a></dt> <dl> -<dt><a href="#l57">5.2.1: Bysize, byduration or byconnections?</a></dt> -<dt><a href="#l58">5.2.2: Averaging size and duration</a></dt> -<dt><a href="#l59">5.2.3: Specifying decays</a></dt> -<dt><a href="#l60">5.2.4: Adjusting the weights</a></dt> +<dt><a href="#l58">5.2.1: Bysize, byduration or byconnections?</a></dt> +<dt><a href="#l59">5.2.2: Averaging size and duration</a></dt> +<dt><a href="#l60">5.2.3: Specifying decays</a></dt> +<dt><a href="#l61">5.2.4: Adjusting the weights</a></dt> </dl> -<dt><a href="#l61">5.3: Periodic probes and wake up calls</a></dt> +<dt><a href="#l62">5.3: Periodic probes and wake up calls</a></dt> <dl> -<dt><a href="#l62">5.3.1: Syntax</a></dt> -<dt><a href="#l63">5.3.2: Security Considerations</a></dt> -<dt><a href="#l64">5.3.3: An example</a></dt> +<dt><a href="#l63">5.3.1: Syntax</a></dt> +<dt><a href="#l64">5.3.2: Security Considerations</a></dt> +<dt><a href="#l65">5.3.3: An example</a></dt> </dl> -<dt><a href="#l65">5.4: Throttling the number of concurrent connections</a></dt> -<dt><a href="#l66">5.5: TCP Session Stickiness</a></dt> -<dt><a href="#l67">5.6: HTTP Session Stickiness</a></dt> +<dt><a href="#l66">5.4: Throttling the number of concurrent connections</a></dt> +<dt><a href="#l67">5.5: TCP Session Stickiness</a></dt> +<dt><a href="#l68">5.6: HTTP Session Stickiness</a></dt> <dl> -<dt><a href="#l68">5.6.1: Don't use stickiness!</a></dt> -<dt><a href="#l69">5.6.2: But if you must..</a></dt> +<dt><a href="#l69">5.6.1: Don't use stickiness!</a></dt> +<dt><a href="#l70">5.6.2: But if you must..</a></dt> </dl> -<dt><a href="#l70">5.7: Passing the client's IP address</a></dt> +<dt><a href="#l71">5.7: Passing the client's IP address</a></dt> <dl> -<dt><a href="#l71">5.7.1: Sample Crossroads configuration</a></dt> -<dt><a href="#l72">5.7.2: Sample Apache configuration</a></dt> +<dt><a href="#l72">5.7.1: Sample Crossroads configuration</a></dt> +<dt><a href="#l73">5.7.2: Sample Apache configuration</a></dt> </dl> -<dt><a href="#l73">5.8: Deep or shallow HTTP header inspection</a></dt> -<dt><a href="#l74">5.9: Debugging network traffic</a></dt> -<dt><a href="#l75">5.10: IP filtering: Limiting Access by Client IP Address</a></dt> +<dt><a href="#l74">5.8: Deep or shallow HTTP header inspection</a></dt> +<dt><a href="#l75">5.9: Debugging network traffic</a></dt> +<dt><a href="#l76">5.10: IP filtering: Limiting Access by Client IP Address</a></dt> <dl> -<dt><a href="#l76">5.10.1: General Examples</a></dt> -<dt><a href="#l77">5.10.2: Using External Files</a></dt> -<dt><a href="#l78">5.10.3: Mixing Directives</a></dt> +<dt><a href="#l77">5.10.1: General Examples</a></dt> +<dt><a href="#l78">5.10.2: Using External Files</a></dt> +<dt><a href="#l79">5.10.3: Mixing Directives</a></dt> </dl> -<dt><a href="#l79">5.11: Using an external program to dispatch</a></dt> +<dt><a href="#l80">5.11: Using an external program to dispatch</a></dt> <dl> -<dt><a href="#l80">5.11.1: Configuring the external handler</a></dt> -<dt><a href="#l81">5.11.2: Writing the external handler</a></dt> -<dt><a href="#l82">5.11.3: Examples of external handlers</a></dt> +<dt><a href="#l81">5.11.1: Configuring the external handler</a></dt> +<dt><a href="#l82">5.11.2: Writing the external handler</a></dt> +<dt><a href="#l83">5.11.3: Examples of external handlers</a></dt> </dl> -<dt><a href="#l83">5.12: Linux and ip_conntrack_max</a></dt> -<dt><a href="#l84">5.13: Marking back ends as bad after more than one try</a></dt> -<dt><a href="#l85">5.14: Using the Web Interface crossroads-mgr</a></dt> +<dt><a href="#l84">5.12: Linux and ip_conntrack_max</a></dt> +<dt><a href="#l85">5.13: Marking back ends as bad after more than one try</a></dt> +<dt><a href="#l86">5.14: Using the Web Interface crossroads-mgr</a></dt> <dl> -<dt><a href="#l86">5.14.1: Starting crossroads-mgr</a></dt> +<dt><a href="#l87">5.14.1: Starting crossroads-mgr</a></dt> </dl> -<dt><a href="#l87">5.15: Rendering Crossroads' status in a web page</a></dt> -<dt><a href="#l88">5.16: Crossroads and DNS caching</a></dt> -<dt><a href="#l89">5.17: Managing a Pool of Virtual Back Ends</a></dt> +<dt><a href="#l88">5.15: Rendering Crossroads' status in a web page</a></dt> +<dt><a href="#l89">5.16: Crossroads and DNS caching</a></dt> +<dt><a href="#l90">5.17: Managing a Pool of Virtual Back Ends</a></dt> </dl> -<dt><h3><a href="#l90">6: Benchmarking</a></h3></dt> +<dt><h3><a href="#l91">6: Benchmarking</a></h3></dt> <dl> -<dt><a href="#l91">6.1: Benchmark 1: Accessing a proxy via crossroads or directly</a></dt> +<dt><a href="#l92">6.1: Benchmark 1: Accessing a proxy via crossroads or directly</a></dt> <dl> -<dt><a href="#l92">6.1.1: Results</a></dt> -<dt><a href="#l93">6.1.2: Discussion</a></dt> +<dt><a href="#l93">6.1.1: Results</a></dt> +<dt><a href="#l94">6.1.2: Discussion</a></dt> </dl> -<dt><a href="#l94">6.2: Benchmark 2: Crossroads versus Linux Virtual Server (LVS)</a></dt> +<dt><a href="#l95">6.2: Benchmark 2: Crossroads versus Linux Virtual Server (LVS)</a></dt> <dl> -<dt><a href="#l95">6.2.1: Environment</a></dt> -<dt><a href="#l96">6.2.2: Tests and results</a></dt> +<dt><a href="#l96">6.2.1: Environment</a></dt> +<dt><a href="#l97">6.2.2: Tests and results</a></dt> </dl> </dl> -<dt><h3><a href="#l97">7: Compiling and Installing</a></h3></dt> +<dt><h3><a href="#l98">7: Compiling and Installing</a></h3></dt> <dl> -<dt><a href="#l98">7.1: Prerequisites</a></dt> -<dt><a href="#l99">7.2: Compiling and installing</a></dt> -<dt><a href="#l100">7.3: Configuring crossroads</a></dt> -<dt><a href="#l101">7.4: A boot script</a></dt> +<dt><a href="#l99">7.1: Prerequisites</a></dt> +<dt><a href="#l100">7.2: Compiling and installing</a></dt> +<dt><a href="#l101">7.3: Configuring crossroads</a></dt> +<dt><a href="#l102">7.4: A boot script</a></dt> <dl> -<dt><a href="#l102">7.4.1: SysV Style Startup</a></dt> -<dt><a href="#l103">7.4.2: BSD Style Startup</a></dt> +<dt><a href="#l103">7.4.1: SysV Style Startup</a></dt> +<dt><a href="#l104">7.4.2: BSD Style Startup</a></dt> +<dt><a href="#l105">7.4.3: Linux-related</a></dt> </dl> <p><hr><p> @@ -368,7 +370,17 @@ configuration file of Crossroads, existing configuration files may need to be made suitable for new versions. <p> <a name="l7"></a> -<strong>1.5.1: Porting issues fdor pre-1.50 installations</strong> +<strong>1.5.1: Porting issues for pre-1.63 installations</strong> +<p> +The parser of Crossroads 1.63 has become even + stricter. HTTP-related commands, such as <code>addclientheader</code>, may + only occur when the service type is <code>http</code>. +<p> +Previously such directives were allowed, albeit they would be + ineffective. +<p> +<a name="l8"></a> +<strong>1.5.2: Porting issues for pre-1.50 installations</strong> <p> As of version 1.50, the command <code>crossroads tell</code> has been changed. To set a state, the command must be used as follows: @@ -382,8 +394,8 @@ The keyword <code>state</code> was added. This is because <code>crossroads the like that change the back end states, please modify the commands to suit this. <p> -<a name="l8"></a> -<strong>1.5.2: Porting issues for pre-1.43 installations</strong> +<a name="l9"></a> +<strong>1.5.3: Porting issues for pre-1.43 installations</strong> <p> As of version 1.43, the shared memory key calculations are based on a different algorithm. This key is e.g. necessary when starting @@ -404,8 +416,8 @@ Furthermore, shell-style comment is no longer supported as of your configuration files use shell-style comment, please convert this to <strong>C</strong> or <strong>C++</strong> style. <p> -<a name="l9"></a> -<strong>1.5.3: Porting issues for pre-1.21 installations</strong> +<a name="l10"></a> +<strong>1.5.4: Porting issues for pre-1.21 installations</strong> <p> As of version 1.21, the event-hook directives <code>onsuccess</code> and <code>onfailure</code> no longer exists. @@ -419,8 +431,8 @@ The commands that are run via <code>onstart</code>, <code>onend</code> or <code> are subject to format expansion; e.g., <code>%1w</code> is expanded to the weight of the first back end, etc.. See section <a href="crossroads.html#config">4</a> for details. <p> -<a name="l10"></a> -<strong>1.5.4: Porting issues for pre-0.26 installations</strong> +<a name="l11"></a> +<strong>1.5.5: Porting issues for pre-0.26 installations</strong> <p> As of version 0.26 the syntax of the configuration file has changed. In particular: @@ -438,8 +450,8 @@ Therefore when converting configuration files to the new syntax, <em>session</em> is used strictly in that sense -- and no longer for a TCP connection.) <p> -<a name="l11"></a> -<strong>1.5.5: Porting issues for pre-1.08 installations</strong> +<a name="l12"></a> +<strong>1.5.6: Porting issues for pre-1.08 installations</strong> <p> As of version 1.08, the following directives no longer are supported: @@ -459,7 +471,7 @@ As of version 1.08, the following directives no longer are This incidentally also makes it possible to change the header name (here: <code>XR-Real-IP</code>).</ul> <p> -<a name="l12"></a> +<a name="l13"></a> <h2>2: Installation for the impatient</h2> <a name="impatient"></a> For the impatient, here's the very-quick-but-very-superficial recipy @@ -535,9 +547,9 @@ That's off course assuming that you want to balance HTTP on running, port 1000. </ul> <p> -<a name="l13"></a> +<a name="l14"></a> <h2>3: Using Crossroads</h2> -<a name="using"></a><a name="l14"></a> +<a name="using"></a><a name="l15"></a> <h3>3.1: The Balancer: crossroads</h3> <p> The Crossroads balancer is started from the commandline, and highly depends on @@ -552,7 +564,7 @@ second program called <code>crossroads-daemon</code>. This program is not meant to be started from the command line; it is administered through the front end <code>crossroads</code>. <p> -<a name="l15"></a> +<a name="l16"></a> <strong>3.1.1: General Commandline Syntax</strong> <p> This section shows the most basic usage. As said above, start @@ -588,7 +600,7 @@ This section shows the most basic usage. As said above, start report on back end states. </ul> <p> -<a name="l16"></a> +<a name="l17"></a> <strong>3.1.2: Status Reporting from the Command Line</strong> <p> The command <code>crossroads status</code> shows a verbose human-readable @@ -629,7 +641,7 @@ technical reason for this: the total counter gets updated at a different rate than separate back end counts. This may be fixed in a future release.) <p> -<a name="l17"></a> +<a name="l18"></a> <strong>3.1.3: Logging-related options</strong> <p> Two 'flags' of Crossroads are specifically logging-related. This @@ -672,7 +684,7 @@ That instructs <code>syslogd</code> to send <code>LOG_LOCAL7</code> requests to <li> Finally, monitor <code>/var/log/crossroads.log</code> for Crossroads' messages.</ul> <p> -<a name="l18"></a> +<a name="l19"></a> <strong>3.1.4: Reloading Configurations</strong> <p> Crossroads doesn't support the reloading of a configuration while @@ -683,7 +695,7 @@ However, external lists of allowed or denied IP addresses can be reloaded by sending a signal -1 (<code>SIGHUP</code>) to Crossroads. See section <a href="crossroads.html#servicedef">4.2</a> for the details. <p> -<a name="l19"></a> +<a name="l20"></a> <h3>3.2: The Web Frontend: crossroads-mgr</h3> <p> A web front end for Crossroads is <code>crossroads-mgr</code>. Type @@ -702,7 +714,7 @@ There are lots of other options that can be used with <p> -<a name="l20"></a> +<a name="l21"></a> <h2>4: The configuration</h2> <a name="config"></a>The configuration that crossroads uses is normally stored in the file /etc/crossroads.conf. This location can be overruled using the @@ -711,13 +723,13 @@ command line flag <code>-c</code>. This section explains the syntax of the configuration file, and what all settings do. <p> -<a name="l21"></a> +<a name="l22"></a> <h3>4.1: General language elements</h3> <p> This section describes the general elements of the crossroads configuration language. <p> -<a name="l22"></a> +<a name="l23"></a> <strong>4.1.1: Empty lines and comments</strong> <p> Empty lines are of course allowed in the @@ -733,7 +745,7 @@ best'.&nbsp;(I favor C or C++ comment. My favorite editor <em>emacs</em> can be put in <code>cmode</code> and nicely highlight what's comment and what's not. And as a bonus it will auto-indent the configuration!) <p> -<a name="l23"></a> +<a name="l24"></a> <strong>4.1.2: Preprocessor directives</strong> <p> Similar to <strong>C</strong> or <strong>C++</strong>, the Crossroads grammar knows <code>#include</code> @@ -784,7 +796,7 @@ service web { </pre> <p> -<a name="l24"></a> +<a name="l25"></a> <strong>4.1.3: Keywords, numbers, identifiers, generic strings</strong> <p> In a configuration file, statements are identified by <em>keywords</em>, @@ -874,7 +886,7 @@ Finally, an argument can be a 'boolean' value. Crossroads knows <code>true</code>, <code>yes</code> and <code>on</code> all mean the same and can be used interchangeably; as can the keywords <code>false</code>, <code>no</code> and <code>off</code>. <p> -<a name="l25"></a> +<a name="l26"></a> <h3>4.2: Service definitions</h3> <a name="servicedef"></a> <p> Service definitions are blocks in the configuration file that @@ -898,7 +910,7 @@ identifying names differ. The following list shows possible statements. Each statement must end with a semicolon, except for the <code>backend</code> statement, which has is own block (more on this later). <p> -<a name="conf/port"></a><a name="l26"></a> +<a name="conf/port"></a><a name="l27"></a> <strong>4.2.1: port - Specifying the listen port</strong> <a name="confport - Specifying the listen port"></a> <dl> <p><dt><strong>Description:</strong><dd> The <code>port</code> statement defines to which TCP port a service @@ -912,7 +924,7 @@ Multiple services in one configuration cannot use the same port <p><dt><strong>Default:</strong><dd> There is no default. This is a required setting. </dl> <p> -<a name="conf/type"></a><a name="l27"></a> +<a name="conf/type"></a><a name="l28"></a> <strong>4.2.2: type - Defining the service type</strong> <a name="conftype - Defining the service type"></a> <dl> <p><dt><strong>Description:</strong><dd> The <code>type</code> statement defines how crossroads handles the stated @@ -932,7 +944,7 @@ Unless you really need such special features, use the type <code>any</code> (the <p><dt><strong>Default:</strong><dd> <code>any</code> </dl> <p> -<a name="conf/headerinspection"></a><a name="l28"></a> +<a name="conf/headerinspection"></a><a name="l29"></a> <strong>4.2.3: headerinspection - are all HTTP headers inspected</strong> <a name="confheaderinspection - are all HTTP headers inspected"></a> <dl> <p><dt><strong>Description:</strong><dd> The <code>headerinspection</code> directive defines whether Crossroads @@ -949,7 +961,7 @@ that forms the server's answer, are analyzed. <p><dt><strong>Default:</strong><dd> <code>deep</code> </dl> <p> -<a name="conf/bindto"></a><a name="l29"></a> +<a name="conf/bindto"></a><a name="l30"></a> <strong>4.2.4: bindto - Binding to a specific IP address</strong> <a name="confbindto - Binding to a specific IP address"></a> <dl> <p><dt><strong>Description:</strong><dd> The <code>bindto</code> statement is used in situations where crossroads @@ -963,7 +975,7 @@ that forms the server's answer, are analyzed. <p><dt><strong>Default:</strong><dd> <code>any</code> </dl> <p> -<a name="conf/verbose"></a><a name="l30"></a> +<a name="conf/verbose"></a><a name="l31"></a> <strong>4.2.5: verbosity - Controlling debug output</strong> <a name="confverbosity - Controlling debug output"></a> <dl> <p><dt><strong>Description:</strong><dd> Verbosity statements come in two forms: <code>verbosity on</code> or @@ -980,7 +992,7 @@ that forms the server's answer, are analyzed. <p><dt><strong>Default:</strong><dd> <code>off</code> </dl> <p> -<a name="conf/dispatchmode"></a><a name="l31"></a> +<a name="conf/dispatchmode"></a><a name="l32"></a> <strong>4.2.6: dispatchmode - How are back ends selected</strong> <a name="confdispatchmode - How are back ends selected"></a> <dl> <p><dt><strong>Description:</strong><dd> The dispatch mode controls how crossroads selects a back end from @@ -1067,7 +1079,7 @@ Your 'right' dispatch mode will depend on the type of service. Given <p><dt><strong>Default:</strong><dd> <code>roundrobin</code> </dl> <p> -<a name="conf/revivinginterval"></a><a name="l32"></a> +<a name="conf/revivinginterval"></a><a name="l33"></a> <strong>4.2.7: revivinginterval - Back end wakeup calls</strong> <a name="confrevivinginterval - Back end wakeup calls"></a> <dl> <p><dt><strong>Description:</strong><dd> A reviving interval definition is used when Crossroads @@ -1097,7 +1109,7 @@ An example of the definition is <code>revivinginterval 10</code>. When this <p><dt><strong>Default:</strong><dd> 0 (no wakeup calls) </dl> <p> -<a name="conf/checkinterval"></a><a name="l33"></a> +<a name="conf/checkinterval"></a><a name="l34"></a> <strong>4.2.8: checkinterval - Periodic back end checks</strong> <a name="confcheckinterval - Periodic back end checks"></a> <dl> <p><dt><strong>Description:</strong><dd> When a check interval is stated, Crossroads will periodically @@ -1122,7 +1134,7 @@ The second form activates an external program (see section <p><dt><strong>Default:</strong><dd> 0 (no periodic checks) </dl> <p> -<a name="conf/maxconnections"></a><a name="l34"></a> +<a name="conf/maxconnections"></a><a name="l35"></a> <strong>4.2.9: maxconnections - Limiting concurrent clients at service level</strong> <a name="confmaxconnections - Limiting concurrent clients at service level"></a> <dl> <p><dt><strong>Description:</strong><dd> The maximum number of connections is specified using @@ -1138,7 +1150,7 @@ The second form activates an external program (see section <p><dt><strong>Default:</strong><dd> 0, meaning that all connections will be accepted. </dl> <p> -<a name="conf/backlog"></a><a name="l35"></a> +<a name="conf/backlog"></a><a name="l36"></a> <strong>4.2.10: backlog - The TCP Back Log size</strong> <a name="confbacklog - The TCP Back Log size"></a> <dl> <p><dt><strong>Description:</strong><dd> The TCP back log size is a number that controls how many @@ -1154,7 +1166,7 @@ The second form activates an external program (see section value for socket back log size. </dl> <p> -<a name="conf/shmkey"></a><a name="l36"></a> +<a name="conf/shmkey"></a><a name="l37"></a> <strong>4.2.11: shmkey - Shared Memory Access</strong> <a name="confshmkey - Shared Memory Access"></a> <dl> <p><dt><strong>Description:</strong><dd> Different Crossroads @@ -1175,7 +1187,7 @@ The actual key value doesn't matter much, as long as it's unique own key, based on the service name. </dl> <p> -<a name="conf/allow"></a><a name="l37"></a> +<a name="conf/allow"></a><a name="l38"></a> <strong>4.2.12: allow* and deny* - Allowing or denying connections</strong> <a name="confallow* and deny* - Allowing or denying connections"></a> <dl> <p><dt><strong>Description:</strong><dd> Crossroads can allow or deny @@ -1265,7 +1277,7 @@ allowfrom 192.168.1.24; <p><dt><strong>Default:</strong><dd> In absence of these statements, all client IP's are accepted. </dl> <p> -<a name="conf/useraccount"></a><a name="l38"></a> +<a name="conf/useraccount"></a><a name="l39"></a> <strong>4.2.13: useraccount - Limiting the effective ID of external processes</strong> <a name="confuseraccount - Limiting the effective ID of external processes"></a> <dl> <p><dt><strong>Description:</strong><dd> Using the directive <code>useraccount</code>, the effective user and group @@ -1283,7 +1295,7 @@ allowfrom 192.168.1.24; ID that was in effect when Crossroads was started. </dl> <p> -<a name="l39"></a> +<a name="l40"></a> <h3>4.3: Backend definitions</h3> <p> Inside the service definitions as are described in the previous @@ -1319,7 +1331,7 @@ Crossroads treats the network traffic as a stream of HTTP messages; i.e., when the service is declared with <code>type http</code>. Incase of <code>type any</code>, the HTTP-specific directives have no effect. <p> -<a name="conf/server.yo"></a><a name="l40"></a> +<a name="conf/server.yo"></a><a name="l41"></a> <strong>4.3.1: server - Specifying the back end address</strong> <a name="confserver - Specifying the back end address"></a> <dl> <p><dt><strong>Description:</strong><dd> Each back end must be identified by the network name @@ -1337,7 +1349,7 @@ i.e., when the service is declared with <code>type http</code>. Incase of <p><dt><strong>Default:</strong><dd> There is no default. This is a required setting. </dl> <p> -<a name="conf/backendport.yo"></a><a name="l41"></a> +<a name="conf/backendport.yo"></a><a name="l42"></a> <strong>4.3.2: port - Specifying a back end port</strong> <a name="confport - Specifying a back end port"></a> <dl> <p><dt><strong>Description:</strong><dd> Back ends must be known by their host name and a port. Both can @@ -1349,7 +1361,7 @@ i.e., when the service is declared with <code>type http</code>. Incase of using <code>server</code> or using <code>port</code>. </dl> <p> -<a name="conf/verbose-backend.yo"></a><a name="l42"></a> +<a name="conf/verbose-backend.yo"></a><a name="l43"></a> <strong>4.3.3: verbosity - Controlling verbosity at the back end level</strong> <a name="confverbosity - Controlling verbosity at the back end level"></a> <dl> <p><dt><strong>Description:</strong><dd> Similar to <code>service</code> specifications, a @@ -1363,7 +1375,7 @@ i.e., when the service is declared with <code>type http</code>. Incase of <p><dt><strong>Default:</strong><dd> <code>off</code> </dl> <p> -<a name="conf/retries.yo"></a><a name="l43"></a> +<a name="conf/retries.yo"></a><a name="l44"></a> <strong>4.3.4: retries - Specifying allowed failures</strong> <a name="confretries - Specifying allowed failures"></a> <dl> <p><dt><strong>Description:</strong><dd> Back ends that are 'flaky' or on a less reliable network can be @@ -1378,7 +1390,7 @@ i.e., when the service is declared with <code>type http</code>. Incase of connection. </dl> <p> -<a name="conf/weight"></a><a name="l44"></a> +<a name="conf/weight"></a><a name="l45"></a> <strong>4.3.5: weight - When a back end is more equal than others</strong> <a name="confweight - When a back end is more equal than others"></a> <dl> <p><dt><strong>Description:</strong><dd> To influence how backends are selected, a backend can specify its @@ -1397,7 +1409,7 @@ The weighing mechanism only applies to the dispatch modes <p><dt><strong>Default:</strong><dd> 1; all back ends have equal weight. </dl> <p> -<a name="conf/decay"></a><a name="l45"></a> +<a name="conf/decay"></a><a name="l46"></a> <strong>4.3.6: decay - Levelling out activity of a back end</strong> <a name="confdecay - Levelling out activity of a back end"></a> <dl> <p><dt><strong>Description:</strong><dd> To make sure that a 'spike' of activity doesn't @@ -1419,7 +1431,7 @@ This means that when a given back end is hit, then its usage data <p><dt><strong>Default:</strong><dd> 0, meaning that no decay is applied to usage statistics. </dl> <p> -<a name="conf/state"></a><a name="l46"></a> +<a name="conf/state"></a><a name="l47"></a> <strong>4.3.7: state - Setting an initial back end state</strong> <a name="confstate - Setting an initial back end state"></a> <dl> <p><dt><strong>Description:</strong><dd> Using the <code>state</code> directive a back end can be 'primed' with an @@ -1436,7 +1448,7 @@ This means that when a given back end is hit, then its usage data initial dispatching. </dl> <p> -<a name="conf/onhooks"></a><a name="l47"></a> +<a name="conf/onhooks"></a><a name="l48"></a> <strong>4.3.8: onstart, onend, onfail - Action Hooks</strong> <a name="confonstart, onend, onfail - Action Hooks"></a> <dl> <p><dt><strong>Description:</strong><dd> The three directives <code>onstart</code>, <code>onend</code> and <code>onfail</code> can be @@ -1516,7 +1528,7 @@ The format is always <code>on</code><em>type</em> <em>command</em>. The <em>comm connection, success or failure of a back end. </dl> <p> -<a name="conf/trafficlog"></a><a name="l48"></a> +<a name="conf/trafficlog"></a><a name="l49"></a> <strong>4.3.9: trafficlog and throughputlog - Debugging and Performance Aids</strong> <a name="conftrafficlog and throughputlog - Debugging and Performance Aids"></a> <dl> <p><dt><strong>Description:</strong><dd> Two directives are available @@ -1536,7 +1548,7 @@ The <code>throughputlog</code> statement writes shorthand transmissions to <p><dt><strong>Default:</strong><dd> none </dl> <p> -<a name="conf/stickycookie"></a><a name="l49"></a> +<a name="conf/stickycookie"></a><a name="l50"></a> <strong>4.3.10: stickycookie - Back end selection with an HTTP cookie</strong> <a name="confstickycookie - Back end selection with an HTTP cookie"></a> <dl> <p><dt><strong>Description:</strong><dd> The directive <code>stickycookie</code> <em>value</em> @@ -1576,7 +1588,7 @@ There are basically to provide such cookies to a browser. First, a <p><dt><strong>Default:</strong><dd> There is no default. </dl> <p> -<a name="conf/addclientheader"></a><a name="l50"></a> +<a name="conf/addclientheader"></a><a name="l51"></a> <strong>4.3.11: HTTP Header Modification Directives</strong> <a name="confHTTP Header Modification Directives"></a> <dl> <p><dt><strong>Description:</strong><dd> Crossroads understands the following @@ -1789,16 +1801,16 @@ service ... { <p><dt><strong>Default:</strong><dd> There is no default. </dl> <p> -<a name="l51"></a> +<a name="l52"></a> <h2>5: Tips, Tricks and Random Remarks</h2> <a name="tips"></a>The following sections elaborate on the directives as described in section <a href="crossroads.html#config">4</a> to illustrate how crossroads works and to help you achieve the "optimal" balancing configuration. <p> -<a name="l52"></a> +<a name="l53"></a> <h3>5.1: Configuration examples</h3> <a name="tips/examples"></a> -<a name="l53"></a> +<a name="l54"></a> <strong>5.1.1: A load balancer for three webserver back ends</strong> <p> The following configuration example binds crossroads to port 80 of the @@ -1927,7 +1939,7 @@ service www { </pre> <p> -<a name="l54"></a> +<a name="l55"></a> <strong>5.1.2: An HTTP forwarder when travelling</strong> <p> As another example, here's my /etc/crossroads.conf that I use on my @@ -2016,7 +2028,7 @@ and <code>LocalSquid</code> are both active, then <code>crossroads tell httpprox sshtunnel down</code> will 'take down' the back end <code>SshTunnel</code> -- and will automatically cause crossroads to switch to <code>LocalSquid</code>. <p> -<a name="l55"></a> +<a name="l56"></a> <strong>5.1.3: SSH login with enforced idle logout</strong> <p> The following example shows how crossroads 'throttles' SSH @@ -2042,7 +2054,7 @@ service Ssh { </pre> <p> -<a name="l56"></a> +<a name="l57"></a> <h3>5.2: How back ends are selected in load balancing</h3> <a name="howselected"></a> <a name="tips/howselected"></a>In order to tune your load balancing, you'll need to understand how crossroads computes usage, how weighing works, and so on. In this @@ -2050,7 +2062,7 @@ section we'll focus on the dispatching modes <code>bysize</code>, <code>bydurati and <code>byconnections</code> only. The other dispatching types are self-explanatory. <p> -<a name="l57"></a> +<a name="l58"></a> <strong>5.2.1: Bysize, byduration or byconnections?</strong> <p> As stated before, crossroads doesn't know 'what a service does' and @@ -2100,7 +2112,7 @@ E.g., consider a database connection. What's <p> </ul> <p> -<a name="l58"></a> +<a name="l59"></a> <strong>5.2.2: Averaging size and duration</strong> <p> The configuration statement <code>dispatchmode bysize</code> or <code>byduration</code> @@ -2121,7 +2133,7 @@ In contrast, when e.g. <code>over 3</code> is in effect, then a sudden load does show up -- because it highly contributes to the average of three connections. <p> -<a name="l59"></a> +<a name="l60"></a> <strong>5.2.3: Specifying decays</strong> <p> Decays are also only relevant when crossroads computes the 'next best @@ -2175,7 +2187,7 @@ service soap { </pre> <p> -<a name="l60"></a> +<a name="l61"></a> <strong>5.2.4: Adjusting the weights</strong> <p> The back end modifier <code>weight</code> is useful in situations where your @@ -2229,7 +2241,7 @@ both A and B crash). Note also that A's usage data decay much faster than B's and C's: we're assuming that this big server recovers quicker than its smaller siblings. <p> -<a name="l61"></a> +<a name="l62"></a> <h3>5.3: Periodic probes and wake up calls</h3> <a name="tips/periodic"></a>Crossroads has two methods of periodic back end verifications: <p> @@ -2253,7 +2265,7 @@ than its smaller siblings. <code>checkinterval</code>. During each check, back ends can be marked as available or as unavailable.</ul> <p> -<a name="l62"></a> +<a name="l63"></a> <strong>5.3.1: Syntax</strong> <p> The syntax of both verifications is: @@ -2325,7 +2337,7 @@ The <em>arguments</em> are expanded according to the following table: <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> +<a name="l64"></a> <strong>5.3.2: Security Considerations</strong> <p> When <code>externalhandler</code> is in effect, Crossroads spawns an external @@ -2334,7 +2346,7 @@ a restricted user account. <p> The directive <code>useraccount</code> can be used to accomplish this. <p> -<a name="l64"></a> +<a name="l65"></a> <strong>5.3.3: An example</strong> <p> The following configuration balances SMTP requests to two back @@ -2371,7 +2383,7 @@ service smtp { </pre> <p> -<a name="l65"></a> +<a name="l66"></a> <h3>5.4: Throttling the number of concurrent connections</h3> <a name="tips/throttling"></a>If you suspect that your service may occasionally receive 'spikes' of activity&nbsp;(which you should always assume), then it might be a @@ -2400,7 +2412,7 @@ too much, a situation may occur where that back end is about to be hit. A <code>maxconnections</code> statement on the level of that back may then protect it. <p> -<a name="l66"></a> +<a name="l67"></a> <h3>5.5: TCP Session Stickiness</h3> <a name="tips/tcpstickiness"></a>If you need to make sure that a client that once gets dispatched to a given back end keeps re-visiting the back end, then Crossroads offers @@ -2425,7 +2437,7 @@ If the preferred back end is unavailable, then the action that Crossroads takes is to dispatch as if <code>byconnections</code>: of the available back ends, the one with the least connections is taken. <p> -<a name="l67"></a> +<a name="l68"></a> <h3>5.6: HTTP Session Stickiness</h3> <a name="tips/httpstickiness"></a>This section focuses on HTTP session stickiness. This term refers to the ability of a balancer to route a conversation between browser and @@ -2433,7 +2445,7 @@ a backend farm with webservers always to the same back end. In other words: once a back end is selected by the balancer, it will remain the back end of choice, even for subsequent connections. <p> -<a name="l68"></a> +<a name="l69"></a> <strong>5.6.1: Don't use stickiness!</strong> <p> The rule of thumb as far as the balancer is concerned, is: <strong>Do not @@ -2465,7 +2477,7 @@ that all PHP applications have access to these data. Application servers such as Websphere can be configured to replicate session data between nodes. <p> -<a name="l69"></a> +<a name="l70"></a> <strong>5.6.2: But if you must..</strong> <p> If you really need stickiness, think first whether you might use TCP @@ -2550,7 +2562,7 @@ Note how the cookie names and values in the directives <code>stickycookie</code> and <code>addclientheader</code> match. That is obviously a prerequisite for stickiness. <p> -<a name="l70"></a> +<a name="l71"></a> <h3>5.7: Passing the client's IP address</h3> <a name="tips/clientip"></a>Since Crossroads just shuttles bytes to and fro, meta-information of network connections is lost. As far as the back ends are concerned, @@ -2580,7 +2592,7 @@ header: <code>X-Real-IP</code>, holding the client's IP address. performance will be hampered -- all passing messages will have to be unpacked and analyzed. <p> -<a name="l71"></a> +<a name="l72"></a> <strong>5.7.1: Sample Crossroads configuration</strong> <p> The below sample configuration shows two HTTP back ends that receive @@ -2607,7 +2619,7 @@ service www { </pre> <p> -<a name="l72"></a> +<a name="l73"></a> <strong>5.7.2: Sample Apache configuration</strong> <p> The method by which each back end analyzes the header <code>X-Real-IP</code> @@ -2639,7 +2651,7 @@ LogFormat "%{X-Real-IP}i %l %u %t %D \"%r\" %&gt;s %b" common </pre> <p> -<a name="l73"></a> +<a name="l74"></a> <h3>5.8: Deep or shallow HTTP header inspection</h3> <a name="tips/deeporshallow"></a>The service-level directive <code>headerinspection</code> defines which HTTP headers Crossroads will analyze. Often, several HTTP requests and @@ -2751,7 +2763,7 @@ In these examples, <code>shallow</code> mode is not usable, because the HTTP server signature. All subsequent transactions would still show the HTTP server signature to the world.</ul> <p> -<a name="l74"></a> +<a name="l75"></a> <h3>5.9: Debugging network traffic</h3> <a name="tips/debugging"></a> Incase the traffic between client and backend @@ -2874,9 +2886,9 @@ Summarizing, the throughput times of a client-back end connection analyze the output and to compute round trip times. Such scripts are not (yet) included in Crossroads. <p> -<a name="l75"></a> +<a name="l76"></a> <h3>5.10: IP filtering: Limiting Access by Client IP Address</h3> -<a name="tips/ipfiltering"></a><a name="l76"></a> +<a name="tips/ipfiltering"></a><a name="l77"></a> <strong>5.10.1: General Examples</strong> <p> The directives <code>allowfrom</code>, <code>denyfrom</code>, <code>allowfile</code> and @@ -2913,7 +2925,7 @@ with 192.168.1. The specifier <code>192.168.1/24</code> states that there are three network bytes (192, 168 and 1), and 24 bits (or 3 bytes) are relevant; so that the fourth network byte doesn't matter. <p> -<a name="l77"></a> +<a name="l78"></a> <strong>5.10.2: Using External Files</strong> <p> The directives <code>allowfile</code> and <code>denyfile</code> allow you to specify IP @@ -2945,7 +2957,7 @@ is running, you may edit <code>/tmp/allow.txt</code>, and then issue <code>killa -1 crossroads</code>. The new contents of <code>/tmp/allow.txt</code> will be reloaded. <p> -<a name="l78"></a> +<a name="l79"></a> <strong>5.10.3: Mixing Directives</strong> <p> Crossroads allows to mix all directives in one service @@ -3012,14 +3024,14 @@ Crossroads only performs syntactic checking of the configuration. Some of the above samples are syntactically correct, but make no semantic sense: Crossroads doesn't warn for such situations. <p> -<a name="l79"></a> +<a name="l80"></a> <h3>5.11: Using an external program to dispatch</h3> <a name="externalhandler"></a> <a name="tips/externalhandler"></a>As mentioned before, Crossroads supports several built-in dispatch modes. However, you are always free to hook-in your own dispatch mode that determines the next back end using your own specific algorithm. This section explains how to do it. <p> -<a name="l80"></a> +<a name="l81"></a> <strong>5.11.1: Configuring the external handler</strong> <p> First, the <code>dispatchmode</code> statement needs to inform Crossroads that @@ -3085,7 +3097,7 @@ phase in which an external handler is called, since there is no current back end yet (the job of the handler is to supply one, so at the time of calling, <code>%b</code> is undefined). <p> -<a name="l81"></a> +<a name="l82"></a> <strong>5.11.2: Writing the external handler</strong> <p> The external handler is activated using the arguments that are @@ -3094,7 +3106,7 @@ whatever it wants, but ultimately, it must write a back end name on its <em>stdout</em>. Crossroads reads this, and if the back end is available, uses that back end for the connection. <p> -<a name="l82"></a> +<a name="l83"></a> <strong>5.11.3: Examples of external handlers</strong> <p> This section shows some examples of Crossroads configurations @@ -3521,7 +3533,7 @@ if ($action eq 'dispatch') { </pre> <p> -<a name="l83"></a> +<a name="l84"></a> <h3>5.12: Linux and ip_conntrack_max</h3> <a name="tips/ipconntrackmax"></a>The kernel value of <code>ip_conntrack_max</code> is important for routers and balancers under Linux. Basically it's the maximum number of tracked @@ -3557,7 +3569,7 @@ out yourself. Note however that each count will cause the kernel to reserve 350 bytes. So if you set <code>ip_conntrack_max</code> to 100.000, then you're already taking 33.3Mb off the total available memory. <p> -<a name="l84"></a> +<a name="l85"></a> <h3>5.13: Marking back ends as bad after more than one try</h3> <a name="tips/retries"></a>Crossroads allows you to specify on a per-back end basis how many retries are needed before a back end is considered unavailable. The @@ -3602,7 +3614,7 @@ retry connecting with a small one-second delay in between. A high <code>retries</code> number means also lots of one-second delays, in which time a client is kept waiting. <p> -<a name="l85"></a> +<a name="l86"></a> <h3>5.14: Using the Web Interface crossroads-mgr</h3> <a name="tips/webinterface"></a>The mini-webserver <code>crossroads-mgr</code> provides an intuitive web interface to the state of Crossroads. Once started, an administrator @@ -3653,7 +3665,7 @@ The web interface doesn't offer extra functionality over the command line tools; but all information is available at one glance, and accessible without a shell access to the balancer. <p> -<a name="l86"></a> +<a name="l87"></a> <strong>5.14.1: Starting crossroads-mgr</strong> <p> The basic command to start <code>crossroads-mgr</code> is @@ -3727,7 +3739,7 @@ echo -e 'viewer:showme\nmodifier:changeit' | </pre> <p> -<a name="l87"></a> +<a name="l88"></a> <h3>5.15: Rendering Crossroads' status in a web page</h3> <a name="xmlstatus"></a> <a name="tips/rendering"></a>The Crossroads flag <code>-x</code> causes the status output to be generated as an XML document. This format can be nicely used to render the output @@ -3798,7 +3810,7 @@ somewhat more liberal. There are basically two options: users belonging to the same group as the Crossroads starter can run <code>crossroads status</code>.</ul> <p> -<a name="l88"></a> +<a name="l89"></a> <h3>5.16: Crossroads and DNS caching</h3> <a name="tips/dnscaching"></a> The option <code>-d</code> allows you to control Crossroads' built in DNS @@ -3822,7 +3834,7 @@ Crossroads to use its DNS cache to store results. Each result is stored for up to <em>nsec</em> seconds - after that, a new request for the back end will lead to a new DNS lookup. <p> -<a name="l89"></a> +<a name="l90"></a> <h3>5.17: Managing a Pool of Virtual Back Ends</h3> <a name="tips/virtual"></a>Crossroads can be used as a central dispatcher for computing on demand. E.g., imagine a situation where a web service exists on one or @@ -3907,13 +3919,13 @@ end or to remove one, is left to the reader. The output of states of all back ends, their connections, the total number of available or down back ends, etc.. <p> -<a name="l90"></a> +<a name="l91"></a> <h2>6: Benchmarking</h2> <a name="benchmarking"></a>This section shows how crossroads affects the transmitting of HTML data when used as an intermediate 'station' through which all data travels. <p> -<a name="l91"></a> +<a name="l92"></a> <h3>6.1: Benchmark 1: Accessing a proxy via crossroads or directly</h3> <p> The benchmark was run on a system where the following was varied: @@ -3941,7 +3953,7 @@ service HttpProxy { </pre> <p> -<a name="l92"></a> +<a name="l93"></a> <strong>6.1.1: Results</strong> <p> The results of this test are that crossroads causes a negligible @@ -3964,7 +3976,7 @@ sys 0m0.230s </pre> <p> -<a name="l93"></a> +<a name="l94"></a> <strong>6.1.2: Discussion</strong> <p> The above shown results are quite favorable to crossroads. However, @@ -3996,7 +4008,7 @@ seldom in the real world: back end). Again, this processing time will weigh much heavier than the multiple read/writes.</ul> <p> -<a name="l94"></a> +<a name="l95"></a> <h3>6.2: Benchmark 2: Crossroads versus Linux Virtual Server (LVS)</h3> <p> LVS is a kernel-based balancer that acts like a masquerading @@ -4010,7 +4022,7 @@ LVS isn't aware of downtime of back ends (unless one implements an external heartbeat). Also, crossroads offers more complex balancing than LVS. <p> -<a name="l95"></a> +<a name="l96"></a> <strong>6.2.1: Environment</strong> <p> On the balancer, LVS was run on port 80, its forwarding set up for two @@ -4041,7 +4053,7 @@ service http { </pre> <p> -<a name="l96"></a> +<a name="l97"></a> <strong>6.2.2: Tests and results</strong> <p> In the first test, ports 80 and 81 on the balancer were 'bombed' with @@ -4120,9 +4132,9 @@ are shown in the below table: Again, the results show that crossroads performs just as effectively as LVS, even with large data chunks! <p> -<a name="l97"></a> +<a name="l98"></a> <h2>7: Compiling and Installing</h2> <a name="installation"></a> -<a name="compiling"></a><a name="l98"></a> +<a name="compiling"></a><a name="l99"></a> <h3>7.1: Prerequisites</h3> <p> The creation of crossroads requires: @@ -4141,7 +4153,7 @@ The creation of crossroads requires: Basically a Linux or Apple MacOSX box will do nicely. To compile and install crossroads, follow these steps. <p> -<a name="l99"></a> +<a name="l100"></a> <h3>7.2: Compiling and installing</h3> <p> <ul> @@ -4205,7 +4217,7 @@ crossroads, follow these steps. <p> </ul> <p> -<a name="l100"></a> +<a name="l101"></a> <h3>7.3: Configuring crossroads</h3> <p> Now that the binary is available on your system, you need to create a @@ -4253,13 +4265,13 @@ which crossroads daemons are running. Finally, the tailing of <code>/var/log/messages</code> shows what's going on -- especially if you have <code>verbosity true</code> statements in the configuration. <p> -<a name="l101"></a> +<a name="l102"></a> <h3>7.4: A boot script</h3> <p> Finally, you may want to create a boot-time startup script. The exact procedure depends on the used Unix flavor. <p> -<a name="l102"></a> +<a name="l103"></a> <strong>7.4.1: SysV Style Startup</strong> <p> On SysV style systems, there's a startup script directory @@ -4313,7 +4325,7 @@ If your runlevel is 5, then the right <code>cd</code> command is to <code>/etc/rc.d/rc5.d</code>. Alternatively, you can create the symlinks in both runlevel directories.</ul> <p> -<a name="l103"></a> +<a name="l104"></a> <strong>7.4.2: BSD Style Startup</strong> <p> On BSD style systems, daemons are booted directly from <code>/etc/rc</code> and @@ -4329,5 +4341,24 @@ and add the statement: If your BSD system lacks <code>/etc/rc.local</code>, then you may need to start Crossroads from <code>/etc/rc</code>. Your mileage may vary. <p> +<a name="l105"></a> +<strong>7.4.3: Linux-related</strong> +<p> +When using Crossroads on Linux, the following may be relevant: +<p> +<ul> +<p> +<li> Crossroads supports flag <code>-p</code>, which causes Crossroads not + to modify the process name. In the absence of the flag, Crossroads + alters its process name to something like <code>crossroads</code> <code>-</code> + <code>Service</code> <em>myservice:</em> <code>listening</code>. +<p> +Flag <code>-p</code> may be handy if you want to suppress this + behavior. The process name is then <code>crossroads-daemon</code>. Some + boot scripts use the <code>/proc</code> filesystem to find PID's by + filename; in those cases, flag <code>-p</code> can be used. +<p> +</ul> +<p> </body> </html> diff --git a/doc/crossroads.pdf b/doc/crossroads.pdf Binary files differ. diff --git a/doc/main/compiling.yo b/doc/main/compiling.yo @@ -191,3 +191,22 @@ verb(\ If your BSD system lacks tt(/etc/rc.local), then you may need to start Crossroads from tt(/etc/rc). Your mileage may vary. + + +subsubsect(Linux-related) + +When using Crossroads on Linux, the following may be relevant: + +itemization( + + it() Crossroads supports flag tt(-p), which causes Crossroads not + to modify the process name. In the absence of the flag, Crossroads + alters its process name to something like tt(crossroads) tt(-) + tt(Service) em(myservice:) tt(listening). + + Flag tt(-p) may be handy if you want to suppress this + behavior. The process name is then tt(crossroads-daemon). Some + boot scripts use the tt(/proc) filesystem to find PID's by + filename; in those cases, flag tt(-p) can be used. + +) diff --git a/doc/main/intro.yo b/doc/main/intro.yo @@ -185,7 +185,16 @@ configurations to new versions. Given the changes of the syntax of the configuration file of Crossroads, existing configuration files may need to be made suitable for new versions. -subsubsect(Porting issues fdor pre-1.50 installations) +subsubsect(Porting issues for pre-1.63 installations) + + The parser of Crossroads 1.63 has become even + stricter. HTTP-related commands, such as tt(addclientheader), may + only occur when the service type is tt(http). + + Previously such directives were allowed, albeit they would be + ineffective. + +subsubsect(Porting issues for pre-1.50 installations) As of version 1.50, the command tt(crossroads tell) has been changed. To set a state, the command must be used as follows: 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.62 +VER = 1.64 # Years that Crossroads has been 'round. YEARS = 2005-2007 diff --git a/etc/svnrev.txt b/etc/svnrev.txt @@ -1 +1 @@ -202 +206 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ @@ -316,6 +316,7 @@ EXTERN int gid_org, gid_set; /* original gid, flag: changed? */ EXTERN int iflag_present; /* flag: -i present */ EXTERN int interrupted; /* got a signal? */ EXTERN char *laststring; /* semantic lexer value */ +EXTERN int leave_proctitle; /* don't modify process title flag */ EXTERN int listen_sock; /* servicer listening socket */ EXTERN int log_activity; /* log activy to syslog? */ EXTERN int log_facility; /* openlog(3) facility, -l flag */ @@ -358,11 +359,18 @@ extern char *ansistamp (TmType t, int offset); extern int backend_available (int target); extern int backend_count(void); extern int backend_connect (void); +extern void check_service (Service s); extern void choose_backend (void); +extern int cmd_restart (int ac, char **av); +extern int cmd_services (int ac, char **av); +extern int cmd_status (int ac, char **av); +extern int cmd_start (int ac, char **av); +extern int cmd_stop (int ac, char **av); +extern int cmd_tell (int ac, char **av); +extern int cmd_configtest (int ac, char **av); extern void config_read (int fd); extern void config_write (int fd); extern void copysockets (int clientsock, int serversock); -extern int configtest (int ac, char **av); extern void create_commandline_space (void); extern void decr_client_count (void); extern void dealloc_reporter (Service *s); @@ -371,7 +379,7 @@ 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 unsigned hashpjw (char const *s); extern void http_copy (HttpHeader *h, int src_sock, int dst_sock, CopyDirection dir); extern void http_error (int clientsock); @@ -430,18 +438,13 @@ extern int parser_input (char *buf, int max); extern void parser_run(void); extern void parser_skipchar(void); extern void parser_skipline(void); -extern int restart (int ac, char **av); extern void runservice (void); -extern int serve (int ac, char **av); extern void set_program_title (char const *fmt, ...) __attribute__ ((format (printf, 1, 2))); extern void show_config (void); -extern int show_services (int ac, char **av); -extern int show_status (int ac, char **av); extern char *stage_to_string (Programstage stage); extern char *state_to_string (Backendavail avail); extern Backendavail string_to_state (char const *str); -extern int stop_daemon (int ac, char **av); extern char *str_expand_format (char const *h); extern char *str_printf (char const *fmt, ...) __attribute__ ((format (printf, 1, 2))); @@ -452,7 +455,6 @@ extern void symtab_set (char const *symbol); extern void symtab_start (char const *symbol); extern int sysrun (char const *cmd); extern void tcpserve (int sock); -extern int tell_service (int ac, char **av); extern void thruputlog (unsigned char const *buf, int len, CopyDirection dir); extern void trafficlog (unsigned char const *buf, int len, CopyDirection dir); extern void unlock_reporter (void); diff --git a/src/crossroads/main.c b/src/crossroads/main.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.62, a load balancer and fail over + * This file is part of Crosroads 1.64, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ @@ -19,13 +19,13 @@ int main (int argc, char **argv) { static Handler handler[] = { /* Argument Nr.args Needconf Handler function */ /* -1=no check */ - { "services", 0, 1, show_services }, - { "status", -1, 1, show_status }, - { "stop", 0, 1, stop_daemon }, - { "start", 0, 1, serve }, - { "restart", 0, 1, restart }, - { "tell", 4, 1, tell_service }, - { "configtest", 0, 1, configtest }, + { "services", 0, 1, cmd_services }, + { "status", -1, 1, cmd_status }, + { "stop", 0, 1, cmd_stop }, + { "start", 0, 1, cmd_start }, + { "restart", 0, 1, cmd_restart }, + { "tell", 4, 1, cmd_tell }, + { "configtest", 0, 1, cmd_configtest }, }; /* Remember original ac/av/ep */ diff --git a/src/lib/allocreporter.c b/src/lib/allocreporter.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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/backendavailable.c b/src/lib/backendavailable.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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/checkservice.c b/src/lib/checkservice.c @@ -0,0 +1,83 @@ +/************************************************************************* + * This file is part of Crosroads 1.64, 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 check_service (Service s) { + int i; + + /* Check for port duplicates, bindto duplicates */ + for (i = 0; i < nservice; i++) { + if (service[i].port == s.port) { + if (service[i].bind && s.bind && + !strcmp(service[i].bind, s.bind)) + error ("Services %s and %s cannot bind to same IP %s and " + "port %d", + service[i].name, s.name, + s.bind, s.port); + if (!service[i].bind && s.bind) + error ("Services %s and %s use the same port %d, but " + "%s does not bind to a specific IP", + service[i].name, s.name, + s.port, service[i].name); + if (service[i].bind && !s.bind) + error ("Services %s and %s use the same port %d, but " + "%s does not bind to a specific IP", + service[i].name, s.name, + s.port, s.name); + if (!service[i].bind && !s.bind) + error ("Services %s and %s use the same port without " + "binding to an IP", + service[i].name, s.name); + } + } + + /* Verify the service description, port */ + if (!s.port) + error ("Service %s lacks a port", + s.name); + if (!s.nbackend) + error ("Service %s lacks back ends", + s.name); + if (s.rev_interval && s.check_interval) + error ("Service %s has both a revivinginterval and " + "a checkinterval", s.name); + + /* HTTP modification directives only with "type http" */ + if (s.type != type_http) { + for (i = 0; i < s.nbackend; i++) { + if (s.backend[i].stickycookie && + *s.backend[i].stickycookie) + error ("Backend %s of service %s: sticky cookies " + "only allowed in 'type http'", + s.backend[i].name, s.name); + if (s.backend[i].naddclientheader) + error ("Backend %s of service %s: addclientheader " + "only allowed in 'type http'", + s.backend[i].name, s.name); + if (s.backend[i].nsetclientheader) + error ("Backend %s of service %s: setclientheader " + "only allowed in 'type http'", + s.backend[i].name, s.name); + if (s.backend[i].nappendclientheader) + error ("Backend %s of service %s: appendclientheader " + "only allowed in 'type http'", + s.backend[i].name, s.name); + if (s.backend[i].naddserverheader) + error ("Backend %s of service %s: addserverheader " + "only allowed in 'type http'", + s.backend[i].name, s.name); + if (s.backend[i].nsetserverheader) + error ("Backend %s of service %s: setserverheader " + "only allowed in 'type http'", + s.backend[i].name, s.name); + if (s.backend[i].nappendserverheader) + error ("Backend %s of service %s: appendserverheader " + "only allowed in 'type http'", + s.backend[i].name, s.name); + } + } +} diff --git a/src/lib/choosebackend.c b/src/lib/choosebackend.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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/cmdconfigtest.c b/src/lib/cmdconfigtest.c @@ -0,0 +1,12 @@ +/************************************************************************* + * This file is part of Crosroads 1.64, 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" + +int cmd_configtest (int ac, char **av) { + /* If we got this far, after reading the config: */ + printf ("Configuration '%s' OK.\n", config_file); + return (1); +} diff --git a/src/lib/cmdrestart.c b/src/lib/cmdrestart.c @@ -0,0 +1,24 @@ +/************************************************************************* + * This file is part of Crosroads 1.64, 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" + +int cmd_restart (int ac, char **av) { + + create_commandline_space(); + + /* First run the 'stop' action. */ + if (!cmd_stop (ac, av)) + error ("Daemon stop failed, restart failure"); + + sleep (1); + + /* Now run 'start' */ + if (!cmd_start (ac, av)) + error ("Daemon start failed, restart failure"); + + /* All ok.. */ + return (1); +} diff --git a/src/lib/cmdservices.c b/src/lib/cmdservices.c @@ -0,0 +1,26 @@ +/************************************************************************* + * This file is part of Crosroads 1.64, 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" + +int cmd_services (int ac, char **av) { + int i, j; + + for (i = 0; i < nservice; i++) { + printf ("Service %s (on port %d) %d backends\n", + service[i].name, service[i].port, service[i].nbackend); + if (service[i].allowfile) + printf (" Allow file: %s\n", service[i].allowfile); + if (service[i].denyfile) + printf (" Deny file: %s\n", service[i].denyfile); + for (j = 0; j < service[i].nbackend; j++) + printf (" Backend %s (%s:%d)\n", + service[i].backend[j].name, + service[i].backend[j].initial_server, + service[i].backend[j].initial_port); + } + return (1); +} diff --git a/src/lib/cmdstart.c b/src/lib/cmdstart.c @@ -0,0 +1,29 @@ +/************************************************************************* + * This file is part of Crosroads 1.64, 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" + +int cmd_start (int ac, char **av) { + int i; + FILE *f; + char *cmd; + + cmd = xstrdup (BINDIR "/crossroads-daemon"); + for (i = 1; i < org_argc; i++) { + cmd = xstrcatch (cmd, ' '); + cmd = xstrcat (cmd, org_argv[i]); + } + + msg ("Starting daemon"); + + if (! (f = popen (cmd, "w")) ) + error ("Failed to start %s: %s", cmd, strerror(errno)); + config_write (fileno(f)); + if (pclose (f) == -1) + error ("Crossroads daemon '%s' indicates error", cmd); + + return (1); +} diff --git a/src/lib/cmdstatus.c b/src/lib/cmdstatus.c @@ -0,0 +1,190 @@ +/************************************************************************* + * This file is part of Crosroads 1.64, 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" + +static char *timestr (double nsec) { + static char *buf; + char *tmp; + + free (buf); + buf = 0; + + if (nsec > 3600) { + buf = str_printf ("%uh", (unsigned) (nsec / 3600)); + nsec = fmod (nsec, 3600); + } + if (nsec > 60) { + tmp = str_printf ("%um", (unsigned) (nsec / 60)); + nsec = fmod (nsec, 60); + buf = xstrcat (buf, tmp); + free (tmp); + } + tmp = str_printf ("%.2fs", nsec); + if (!strcmp (tmp + strlen(tmp) - 4, ".00s")) + strcpy (tmp + strlen(tmp) - 4, "s"); + buf = xstrcat (buf, tmp); + free (tmp); + + return (buf); +} + +static char *bytestr (double nbytes) { + static char *buf; + + free (buf); + + if (nbytes > (double)1024*1024*1024*1024) + buf = str_printf ("%.2fTb", + nbytes / ((double) 1024*1024*1024*1024)); + else if (nbytes > 1024*1024*1024) + buf = str_printf ("%.2fGb", + nbytes / ((double) 1024*1024*1024)); + else if (nbytes > 1024*1024) + buf = str_printf ("%.2fMb", + nbytes / ((double) 1024*1024)); + else if (nbytes > 1024) + buf = str_printf ("%.2fKb", + nbytes / (double) 1024); + else + buf = str_printf ("%gb", nbytes); + + return (buf); +} + +int cmd_status (int ac, char **av) { + int i, j, services_shown = 0; + unsigned sec_ago; + int state_count[NR_OF_STATES]; + + if (xml_status) { + printf ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); + if (xml_xslt) + printf ("<?xml-stylesheet type=\"text/xsl\" " + "href=\"%s\"?>\n", xml_xslt); + printf ("<status>\n"); + } + + for (i = 0; i < nservice; i++) { + if (ac > 1 && strcmp (service[i].name, av[0])) + continue; + if (services_shown++) { + if (xml_status) + printf (" </service>\n"); + else + putchar ('\n'); + } + alloc_reporter (service + i, 0); + msg ("Reporting service %s (pid = %d)", + service[i].name, servicereport->pid); + + /* Count the back ends by their state. */ + for (j = 0; j < NR_OF_STATES; j++) + state_count[j] = 0; + for (j = 0; j < service[i].nbackend; j++) + state_count[servicereport->backendstate[j].actual_avail]++; + + if (tabular_status) + printf ("%s ", service[i].name); + else if (xml_status) { + printf (" <service id=\"%d\" name=\"%s\">\n" + " <connections>%d</connections>\n" + " <lastbackend>%d</lastbackend>\n", + i, service[i].name, servicereport->nclients, + servicereport->last_backend); + for (j = 0; j < NR_OF_STATES; j++) + printf (" <backends_%s>%d</backends_%s>\n", + state_to_string ( (Backendavail)j ), + state_count[j], + state_to_string ( (Backendavail)j )); + } else + printf ("Service : %s, %d live connections, " + "last backend %d\n", + service[i].name, servicereport->nclients, + servicereport->last_backend); + for (j = 0; j < service[i].nbackend; j++) { + if (ac > 2 && strcmp (service[i].backend[j].name, av[1])) + continue; + if (! servicereport->backendstate[j].laststamp) + sec_ago = 0; + else + sec_ago = time(0) - servicereport->backendstate[j].laststamp; + if (tabular_status) + printf ("%s=%s ", service[i].backend[j].name, + state_to_string(servicereport->backendstate[j].actual_avail)); + else if (xml_status) { + printf (" <backend id=\"%d\" name=\"%s\">\n" + " <availability id=\"%d\">%s</availability>\n" + " <clients>%u</clients>\n" + " <failures>%lu</failures>\n" + " <connections>%lu</connections>\n" + " <duration sec=\"%g\">%s</duration>\n" + " <throughput bytes=\"%g\">%s</throughput>\n", + j, service[i].backend[j].name, + servicereport->backendstate[j].actual_avail, + state_to_string( + servicereport->backendstate[j].actual_avail), + servicereport->backendstate[j].nclients, + servicereport->backendstate[j].failures, + servicereport->backendstate[j].totuses, + servicereport->backendstate[j].nsec, + timestr (servicereport->backendstate[j].nsec), + servicereport->backendstate[j].nbytes, + bytestr (servicereport->backendstate[j].nbytes)); + printf (" <lastaccess sec=\"%u\">%s</lastaccess>\n" + " <server>%s</server>\n" + " <port>%d</port>\n", + sec_ago, timestr( (double) sec_ago), + servicereport->backendstate[j].actual_server, + servicereport->backendstate[j].actual_port); + if (service[i].type == type_http) + printf (" <sessions>%lu</sessions>\n", + servicereport->backendstate[j].sessions); + printf (" </backend>\n"); + } + else { + printf (" Backend %2d : %s is %s, %u live connections\n" + " Stats : %lu failures out of %lu connections", + j, + service[i].backend[j].name, + state_to_string ( + servicereport->backendstate[j].actual_avail), + servicereport->backendstate[j].nclients, + servicereport->backendstate[j].failures, + servicereport->backendstate[j].totuses); + if (service[i].type == type_http) + printf (", %lu sessions,", + servicereport->backendstate[j].sessions); + printf ("\n" + " usage %s, %s", + timestr (servicereport->backendstate[j].nsec), + bytestr (servicereport->backendstate[j].nbytes)); + if (service[i].dispatchover) + printf (", avg %s, %s", + timestr(servicereport->backendstate[j].avg_nsec), + bytestr(servicereport->backendstate[j].avg_nbytes)); + printf (", last hit %s ago\n" + " address %s:%d\n", + timestr ( (double) sec_ago), + servicereport->backendstate[j].actual_server, + servicereport->backendstate[j].actual_port); + } + } + + if (shmdt (servicereport) < 0) + error ("Failure releasing reporter memory: %s", + strerror(errno)); + } + if (tabular_status) + putchar ('\n'); + else if (xml_status) { + if (services_shown) + printf (" </service>\n"); + printf ("</status>\n"); + } + + return (1); +} diff --git a/src/lib/cmdstop.c b/src/lib/cmdstop.c @@ -0,0 +1,35 @@ +/************************************************************************* + * This file is part of Crosroads 1.64, 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" + +int cmd_stop (int ac, char **av) { + int i, result = 0; + + for (i = 0; i < nservice; i++) { + alloc_reporter (service + i, 0); + msg ("Stopping service %s (daemon pid %d, wakeup handler pid %d)", + service[i].name, servicereport->pid, servicereport->rev_pid); + if (kill (servicereport->pid, SIGINT)) { + warning ("Failed to stop service %s (%s)", + service[i].name, strerror(errno)); + result++; + } else if (servicereport->rev_pid && + kill (servicereport->rev_pid, SIGINT)) { + warning ("Failed to stop wakeup handler of service %s (%s)", + service[i].name, strerror(errno)); + result++; + } + + /* Note: We run the deallocator of shmem here anyway, though the + * signalled listener does it too.. just to make sure.. We do this + * only if above kills have succeeded. + */ + if (!result) + dealloc_reporter (service + i); + } + + return (1); +} diff --git a/src/lib/cmdtell.c b/src/lib/cmdtell.c @@ -0,0 +1,73 @@ +/************************************************************************* + * This file is part of Crosroads 1.64, 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" + +int cmd_tell (int ac, char **av) { + Service *target_service = 0; + int target_backend = -1, i; + Backendavail avail; + int newstate, port; + char *hostname, *cp; + + /* Locate service */ + for (i = 0; i < nservice; i++) + if (!strcasecmp (service[i].name, av[0])) { + target_service = service + i; + break; + } + if (!target_service) + error ("Service '%s' isn't known. " + "Maybe the configuration has changed?", av[0]); + + /* Locate back end */ + for (i = 0; i < target_service->nbackend; i++) + if (!strcasecmp (target_service->backend[i].name, av[1])) { + target_backend = i; + break; + } + if (target_backend == -1) + error ("Backend '%s' of service '%s' isn't known. " + "Maybe the configuration has changed?", av[1], av[0]); + + /* Let's see what we need to tell the back end of that service. */ + if (!strcmp (av[2], "state")) { + /* Locate new state: either the direct number, or alpha name */ + if (sscanf (av[3], "%d", &newstate) > 0) { + avail = (Backendavail) newstate; + if (avail > st_unknown) + error ("Bad state number '%s'", av[3]); + } else if ( (avail = string_to_state (av[3])) == st_unknown ) + error ("Incorrect state '%s'.", av[3]); + + /* Got all data. Poke the new state into shared memory. */ + alloc_reporter (target_service, 0); + servicereport->backendstate[target_backend].actual_avail = avail; + servicereport->backendstate[target_backend].fail = 0; + msg ("Marked backend %s of service %s as %s.", + av[1], av[0], state_to_string (avail)); + } else if (!strcmp (av[2], "server")) { + /* Get the hostname and port part. */ + hostname = av[3]; + if (! (cp = strchr (hostname, ':')) ) + error ("Bad address '%s' (hostname:port expected)", av[3]); + *cp = 0; + if (sscanf (cp + 1, "%d", &port) < 1) + error ("Bad port part in address"); + /* Got all data. Poke the new state into shared memory. */ + alloc_reporter (target_service, 0); + strncpy (servicereport->backendstate[target_backend].actual_server, + hostname, FQDN_LENGTH - 1); + servicereport->backendstate[target_backend].actual_port = port; + msg ("Address for backend %s of service %s set to %s:%d.", + av[1], av[0], hostname, port); + } else { + usage(); + } + /* All done.. success */ + return (1); +} + diff --git a/src/lib/configread.c b/src/lib/configread.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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,12 +0,0 @@ -/************************************************************************* - * 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" - -int configtest (int ac, char **av) { - /* If we got this far, after reading the config: */ - printf ("Configuration '%s' OK.\n", config_file); - return (1); -} diff --git a/src/lib/configwrite.c b/src/lib/configwrite.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ @@ -10,29 +10,35 @@ void create_commandline_space () { int i; /* Here's a dirty hack for Linux systems. We're going to get - * daemonized (unless -f was given) and we'll want to change the + * daemonized and we'll want to change the * program name as it appears in the ps list. * So we re-exec ourselves with a dummy -i flag that creates - * space on the commanedline. + * space on the commanedline. The exec'd process then has more space + * to fiddle around with the process name. */ # if SET_PROC_TITLE_BY_ARGV == 1 - if (! iflag_present) { - msg ("Re-execing for command line space"); - argv = xmalloc ( (org_argc + 2) * sizeof(char*)); + + /* Don't proceed if we are not going to change process titles + * or if -i xxxx was already specified. */ + if (leave_proctitle || iflag_present) + return; + + msg ("Re-execing for command line space"); + argv = xmalloc ( (org_argc + 2) * sizeof(char*)); - argv[0] = org_argv[0]; - argv[1] = "-ixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" - "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; - argv[org_argc + 1] = 0; + argv[0] = org_argv[0]; + argv[1] = "-ixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" + "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; + argv[org_argc + 1] = 0; + + for (i = 1; i < org_argc; i++) + argv[i + 1] = org_argv[i]; + argv[org_argc + 1] = 0; - for (i = 1; i < org_argc; i++) - argv[i + 1] = org_argv[i]; - argv[org_argc + 1] = 0; + execv (argv[0], argv); + execvp (argv[0], argv); + error ("Failed to re-exec program: %s", + strerror(errno)); - execv (argv[0], argv); - execvp (argv[0], argv); - error ("Failed to re-exec program: %s", - strerror(errno)); - } # endif } diff --git a/src/lib/data.c b/src/lib/data.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ @@ -31,15 +31,17 @@ int fork_tcp_servicer (int to_backend) { /* Forked for the second time... */ program_stage = stage_serving; - - if (to_backend >= 0) - setproctitle ("crossroads - Service %s: serving %s to %s", - client_ip, - activeservice->name, - activeservice->backend [current_backend].name); - else - setproctitle ("crossroads - Service %s: serving %s", - activeservice->name, client_ip); + + if (!leave_proctitle) { + if (to_backend >= 0) + setproctitle ("crossroads - Service %s: serving %s to %s", + client_ip, + activeservice->name, + activeservice->backend [current_backend].name); + else + setproctitle ("crossroads - Service %s: serving %s", + activeservice->name, client_ip); + } return (0); } diff --git a/src/lib/gmtstamp.c b/src/lib/gmtstamp.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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/hashpjw.c b/src/lib/hashpjw.c @@ -1,13 +1,13 @@ /************************************************************************* - * This file is part of Crosroads 1.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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" -int hashpjw (char const *str) { - int h = 0, g; +unsigned hashpjw (char const *str) { + unsigned h = 0, g; while (str && *str) { h <<= 4; diff --git a/src/lib/httpcopy.c b/src/lib/httpcopy.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ @@ -32,12 +32,13 @@ int http_serversocket (HttpHeader *m, int *is_continuation) { current_backend = i; if ( (sock = backend_connect ()) >= 0 ) { *is_continuation = 1; - setproctitle ("crossroads - Service %s: serving %s to %s", - activeservice->name, - client_ip, - activeservice->backend[current_backend].name); + if (!leave_proctitle) + setproctitle ("crossroads - Service %s: serving %s to %s", + activeservice->name, + client_ip, + activeservice->backend[current_backend].name); return (sock); - } + } } } @@ -65,10 +66,11 @@ int http_serversocket (HttpHeader *m, int *is_continuation) { if ( (sock = backend_connect ()) >= 0 ) { servicereport->backendstate[current_backend].sessions++; *is_continuation = 0; - setproctitle ("Service %s: serving %s to %s", - activeservice->name, - client_ip, - activeservice->backend[current_backend].name); + if (!leave_proctitle) + setproctitle ("Service %s: serving %s to %s", + activeservice->name, + client_ip, + activeservice->backend[current_backend].name); return (sock); } } diff --git a/src/lib/httpwrite.c b/src/lib/httpwrite.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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/logactivitycontinuation.c b/src/lib/logactivitycontinuation.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ @@ -317,21 +317,21 @@ static const short yyrhs[] = /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const short yyrline[] = { - 0, 158, 161, 165, 225, 230, 241, 244, 248, 253, - 259, 265, 271, 281, 289, 296, 302, 308, 314, 320, - 326, 332, 338, 344, 350, 356, 363, 538, 550, 562, - 571, 578, 583, 596, 600, 606, 615, 617, 619, 623, - 640, 647, 657, 666, 670, 674, 678, 682, 686, 690, - 694, 700, 712, 721, 739, 757, 759, 763, 772, 784, - 796, 808, 820, 832, 837, 841, 847, 859, 864, 868, - 874, 886, 898, 910, 922, 931, 941, 953, 961, 967, - 974, 979, 984, 989, 994, 999, 1004, 1009, 1014, 1019, - 1024, 1029, 1034, 1039, 1044, 1049, 1054, 1059, 1064, 1069, - 1076, 1089, 1101, 1113, 1119, 1131, 1143, 1148, 1152, 1156, - 1162, 1174, 1186, 1198, 1210, 1222, 1231, 1240, 1252, 1261, - 1273, 1285, 1297, 1309, 1321, 1333, 1342, 1347, 1352, 1357, - 1362, 1367, 1372, 1377, 1382, 1387, 1392, 1397, 1402, 1407, - 1412, 1417, 1422, 1427, 1432, 1437 + 0, 158, 161, 165, 189, 194, 205, 208, 212, 217, + 223, 229, 235, 245, 253, 260, 266, 272, 278, 284, + 290, 296, 302, 308, 314, 320, 327, 502, 514, 526, + 535, 542, 547, 560, 564, 570, 579, 581, 583, 587, + 604, 611, 621, 630, 634, 638, 642, 646, 650, 654, + 658, 664, 676, 685, 703, 721, 723, 727, 736, 748, + 760, 772, 784, 796, 801, 805, 811, 823, 828, 832, + 838, 850, 862, 874, 886, 895, 905, 917, 925, 931, + 938, 943, 948, 953, 958, 963, 968, 973, 978, 983, + 988, 993, 998, 1003, 1008, 1013, 1018, 1023, 1028, 1033, + 1040, 1053, 1065, 1077, 1083, 1095, 1107, 1112, 1116, 1120, + 1126, 1138, 1150, 1162, 1174, 1186, 1195, 1204, 1216, 1225, + 1237, 1249, 1261, 1273, 1285, 1297, 1306, 1311, 1316, 1321, + 1326, 1331, 1336, 1341, 1346, 1351, 1356, 1361, 1366, 1371, + 1376, 1381, 1386, 1391, 1396, 1401 }; #endif @@ -1270,61 +1270,25 @@ yyreduce: case 3: #line 170 "parser.y" { - /* Check for port duplicates, bindto duplicates */ - for (i = 0; i < nservice; i++) { - if (service[i].port == cur_service.port) { - if (service[i].bind && cur_service.bind && - !strcmp(service[i].bind, cur_service.bind)) - error ("Services %s and %s cannot bind to same IP %s and " - "port %d", - service[i].name, cur_service.name, - cur_service.bind, cur_service.port); - if (!service[i].bind && cur_service.bind) - error ("Services %s and %s use the same port %d, but " - "%s does not bind to a specific IP", - service[i].name, cur_service.name, - cur_service.port, service[i].name); - if (service[i].bind && !cur_service.bind) - error ("Services %s and %s use the same port %d, but " - "%s does not bind to a specific IP", - service[i].name, cur_service.name, - cur_service.port, cur_service.name); - if (!service[i].bind && !cur_service.bind) - error ("Services %s and %s use the same port without " - "binding to an IP", - service[i].name, cur_service.name); - } - } - - /* Verify the service description, supply defaults - * and so on. - */ - if (!cur_service.port) - error ("Service %s lacks a port", - cur_service.name); - if (!cur_service.nbackend) - error ("Service %s lacks back ends", - cur_service.name); - + /* Check integrity, supply defaults */ + check_service (cur_service); + if (!cur_service.shmkey) cur_service.shmkey = (unsigned) hashpjw (cur_service.name); msg ("Service %s: shared memory key set to 0x%8.8x", cur_service.name, cur_service.shmkey); - if (cur_service.rev_interval && cur_service.check_interval) - error ("Service %s has both a revivinginterval and " - "a checkinterval", cur_service.name); if (!cur_service.check_cmd) cur_service.check_cmd = xstrdup (""); - /* Add to the list. */ + /* Add to the list, reset cur_service for next run */ service = xrealloc (service, ++nservice * sizeof(Service)); service[nservice - 1] = cur_service; memset (&cur_service, 0, sizeof(Service)); ; break;} case 5: -#line 232 "parser.y" +#line 196 "parser.y" { psmsg ("service:", SYMBOL); for (i = 0; i < nservice; i++) @@ -1334,7 +1298,7 @@ case 5: ; break;} case 9: -#line 254 "parser.y" +#line 218 "parser.y" { pimsg ("sevice port:", yyvsp[0].set[0].v.ival); cur_service.port = yyvsp[0].set[0].v.ival; @@ -1342,7 +1306,7 @@ case 9: ; break;} case 10: -#line 260 "parser.y" +#line 224 "parser.y" { psmsg ("service binding:", yyvsp[0].set[0].v.sval); cur_service.bind = yyvsp[0].set[0].v.sval; @@ -1350,7 +1314,7 @@ case 10: ; break;} case 11: -#line 266 "parser.y" +#line 230 "parser.y" { pimsg ("service verbosity:", yyvsp[0].set[0].v.ival); cur_service.verbosity = yyvsp[0].set[0].v.ival; @@ -1358,7 +1322,7 @@ case 11: ; break;} case 12: -#line 272 "parser.y" +#line 236 "parser.y" { pimsg ("service dispatch mode:", yyvsp[0].set[0].v.ival); pimsg ("service dispatch over:", lastovernr); @@ -1370,7 +1334,7 @@ case 12: ; break;} case 13: -#line 282 "parser.y" +#line 246 "parser.y" { pimsg ("service revival interval:", yyvsp[0].set[0].v.ival); psmsg ("service revival cmd:", yyvsp[0].set[1].v.sval); @@ -1380,7 +1344,7 @@ case 13: ; break;} case 14: -#line 290 "parser.y" +#line 254 "parser.y" { pimsg ("service check interval:", yyvsp[0].set[0].v.ival); psmsg ("service check cmd:", yyvsp[0].set[1].v.sval); @@ -1389,7 +1353,7 @@ case 14: ; break;} case 15: -#line 297 "parser.y" +#line 261 "parser.y" { pimsg ("service backlog:", yyvsp[0].set[0].v.ival); cur_service.backlog = yyvsp[0].set[0].v.ival; @@ -1397,7 +1361,7 @@ case 15: ; break;} case 16: -#line 303 "parser.y" +#line 267 "parser.y" { pimsg ("service shmkey:", yyvsp[0].set[0].v.ival); cur_service.shmkey = yyvsp[0].set[0].v.ival; @@ -1405,7 +1369,7 @@ case 16: ; break;} case 17: -#line 309 "parser.y" +#line 273 "parser.y" { pimsg ("connection timout:", yyvsp[0].set[0].v.ival); cur_service.connectiontimeout = yyvsp[0].set[0].v.ival; @@ -1413,7 +1377,7 @@ case 17: ; break;} case 18: -#line 315 "parser.y" +#line 279 "parser.y" { pimsg ("max clients in service:", yyvsp[0].set[0].v.ival); cur_service.maxconnections = yyvsp[0].set[0].v.ival; @@ -1421,7 +1385,7 @@ case 18: ; break;} case 19: -#line 321 "parser.y" +#line 285 "parser.y" { pimsg ("service type: ", yyvsp[0].set[0].v.ival); cur_service.type = yyvsp[0].set[0].v.ival; @@ -1429,7 +1393,7 @@ case 19: ; break;} case 20: -#line 327 "parser.y" +#line 291 "parser.y" { pimsg ("service header inspection: ", yyvsp[0].set[0].v.ival); cur_service.inspection = yyvsp[0].set[0].v.ival; @@ -1437,7 +1401,7 @@ case 20: ; break;} case 21: -#line 333 "parser.y" +#line 297 "parser.y" { psmsg ("allow from: ", yyvsp[0].set[0].v.sval); add_allowfrom (yyvsp[0].set[0].v.sval); @@ -1445,7 +1409,7 @@ case 21: ; break;} case 22: -#line 339 "parser.y" +#line 303 "parser.y" { psmsg ("allow file: ", yyvsp[0].set[0].v.sval); cur_service.allowfile = yyvsp[0].set[0].v.sval; @@ -1453,7 +1417,7 @@ case 22: ; break;} case 23: -#line 345 "parser.y" +#line 309 "parser.y" { psmsg ("deny from: ", yyvsp[0].set[0].v.sval); add_denyfrom (yyvsp[0].set[0].v.sval); @@ -1461,7 +1425,7 @@ case 23: ; break;} case 24: -#line 351 "parser.y" +#line 315 "parser.y" { psmsg ("deny file: ", yyvsp[0].set[0].v.sval); cur_service.denyfile = yyvsp[0].set[0].v.sval; @@ -1469,7 +1433,7 @@ case 24: ; break;} case 25: -#line 357 "parser.y" +#line 321 "parser.y" { psmsg ("user account: ", yyvsp[0].set[0].v.sval); setuseraccount (yyvsp[0].set[0].v.sval); @@ -1478,7 +1442,7 @@ case 25: ; break;} case 26: -#line 364 "parser.y" +#line 328 "parser.y" { pimsg ("converting backend statements, count is", yyvsp[0].n); for (i = 0; i < yyvsp[0].n; i++) @@ -1653,7 +1617,7 @@ case 26: ; break;} case 27: -#line 541 "parser.y" +#line 505 "parser.y" { pimsg ("port statement:", lastnr); yyval.n = 1; @@ -1663,7 +1627,7 @@ case 27: ; break;} case 28: -#line 553 "parser.y" +#line 517 "parser.y" { psmsg ("bindto statement:", laststr); yyval.n = 1; @@ -1673,7 +1637,7 @@ case 28: ; break;} case 29: -#line 564 "parser.y" +#line 528 "parser.y" { setlaststr (laststring); free (laststring); @@ -1681,13 +1645,13 @@ case 29: ; break;} case 30: -#line 573 "parser.y" +#line 537 "parser.y" { setlastnr (SYMBOL); ; break;} case 32: -#line 587 "parser.y" +#line 551 "parser.y" { pimsg ("verbosity statement:", lastnr); yyval.n = 1; @@ -1697,25 +1661,25 @@ case 32: ; break;} case 33: -#line 597 "parser.y" +#line 561 "parser.y" { lastnr = 1; ; break;} case 34: -#line 601 "parser.y" +#line 565 "parser.y" { lastnr = 0; ; break;} case 35: -#line 610 "parser.y" +#line 574 "parser.y" { yyval = yyvsp[-2]; ; break;} case 39: -#line 625 "parser.y" +#line 589 "parser.y" { pimsg ("dispatch mode statement:", lastnr); yyval.n = 1; @@ -1731,13 +1695,13 @@ case 39: ; break;} case 40: -#line 642 "parser.y" +#line 606 "parser.y" { setlastovernr (SYMBOL); ; break;} case 41: -#line 648 "parser.y" +#line 612 "parser.y" { psmsg ("external handler:", laststr); if (lastnr != ds_externalhandler) @@ -1747,7 +1711,7 @@ case 41: ; break;} case 42: -#line 659 "parser.y" +#line 623 "parser.y" { yyval.n = 1; yyval.set = xmalloc (sizeof(Confset)); @@ -1755,55 +1719,55 @@ case 42: ; break;} case 43: -#line 667 "parser.y" +#line 631 "parser.y" { lastnr = ds_roundrobin; ; break;} case 44: -#line 671 "parser.y" +#line 635 "parser.y" { lastnr = ds_random; ; break;} case 45: -#line 675 "parser.y" +#line 639 "parser.y" { lastnr = ds_byduration; ; break;} case 46: -#line 679 "parser.y" +#line 643 "parser.y" { lastnr = ds_bysize; ; break;} case 47: -#line 683 "parser.y" +#line 647 "parser.y" { lastnr = ds_byorder; ; break;} case 48: -#line 687 "parser.y" +#line 651 "parser.y" { lastnr = ds_byconnections; ; break;} case 49: -#line 691 "parser.y" +#line 655 "parser.y" { lastnr = ds_externalhandler; ; break;} case 50: -#line 695 "parser.y" +#line 659 "parser.y" { lastnr = ds_byclientip; ; break;} case 51: -#line 703 "parser.y" +#line 667 "parser.y" { psmsg ("user account statement:", laststr); yyval.n = 1; @@ -1813,7 +1777,7 @@ case 51: ; break;} case 52: -#line 714 "parser.y" +#line 678 "parser.y" { setlaststr (laststring); free (laststring); @@ -1821,7 +1785,7 @@ case 52: ; break;} case 53: -#line 725 "parser.y" +#line 689 "parser.y" { pimsg ("reviving interval statement:", lastnr); yyval.n = 2; @@ -1836,7 +1800,7 @@ case 53: ; break;} case 54: -#line 743 "parser.y" +#line 707 "parser.y" { pimsg ("check interval:", lastnr); yyval.n = 2; @@ -1851,7 +1815,7 @@ case 54: ; break;} case 57: -#line 765 "parser.y" +#line 729 "parser.y" { yyval.n = 1; yyval.set = xmalloc (sizeof(Confset)); @@ -1859,7 +1823,7 @@ case 57: ; break;} case 58: -#line 775 "parser.y" +#line 739 "parser.y" { pimsg ("backlog statement:", lastnr); yyval.n = 1; @@ -1869,7 +1833,7 @@ case 58: ; break;} case 59: -#line 787 "parser.y" +#line 751 "parser.y" { pimsg ("shmkey statement:", lastnr); yyval.n = 1; @@ -1879,7 +1843,7 @@ case 59: ; break;} case 60: -#line 799 "parser.y" +#line 763 "parser.y" { pimsg ("connection timeout statement:", lastnr); yyval.n = 1; @@ -1889,7 +1853,7 @@ case 60: ; break;} case 61: -#line 811 "parser.y" +#line 775 "parser.y" { pimsg ("max clients statement (service):", lastnr); yyval.n = 1; @@ -1899,7 +1863,7 @@ case 61: ; break;} case 62: -#line 823 "parser.y" +#line 787 "parser.y" { pimsg ("service type:", lastnr); yyval.n = 1; @@ -1909,19 +1873,19 @@ case 62: ; break;} case 64: -#line 838 "parser.y" +#line 802 "parser.y" { lastnr = type_any; ; break;} case 65: -#line 842 "parser.y" +#line 806 "parser.y" { lastnr = type_http; ; break;} case 66: -#line 850 "parser.y" +#line 814 "parser.y" { pimsg ("service header inspection: ", lastnr); yyval.n = 1; @@ -1931,19 +1895,19 @@ case 66: ; break;} case 68: -#line 865 "parser.y" +#line 829 "parser.y" { lastnr = ins_deep; ; break;} case 69: -#line 869 "parser.y" +#line 833 "parser.y" { lastnr = ins_shallow; ; break;} case 70: -#line 877 "parser.y" +#line 841 "parser.y" { psmsg ("allow from: ", laststr); yyval.n = 1; @@ -1953,7 +1917,7 @@ case 70: ; break;} case 71: -#line 889 "parser.y" +#line 853 "parser.y" { psmsg ("allow from: ", laststr); yyval.n = 1; @@ -1963,7 +1927,7 @@ case 71: ; break;} case 72: -#line 901 "parser.y" +#line 865 "parser.y" { psmsg ("allow file: ", laststr); yyval.n = 1; @@ -1973,7 +1937,7 @@ case 72: ; break;} case 73: -#line 913 "parser.y" +#line 877 "parser.y" { psmsg ("allow file: ", laststr); yyval.n = 1; @@ -1983,7 +1947,7 @@ case 73: ; break;} case 74: -#line 924 "parser.y" +#line 888 "parser.y" { setlaststr (laststring); free (laststring); @@ -1991,13 +1955,13 @@ case 74: ; break;} case 75: -#line 936 "parser.y" +#line 900 "parser.y" { yyval = yyvsp[-1]; ; break;} case 76: -#line 943 "parser.y" +#line 907 "parser.y" { psmsg ("backend name:", SYMBOL); for (i = 0; i < cur_service.nbackend; i++) @@ -2008,7 +1972,7 @@ case 76: ; break;} case 77: -#line 955 "parser.y" +#line 919 "parser.y" { yyvsp[-1].n++; yyvsp[-1].set = xrealloc (yyvsp[-1].set, yyvsp[-1].n * sizeof(Confset)); @@ -2017,159 +1981,159 @@ case 77: ; break;} case 78: -#line 962 "parser.y" +#line 926 "parser.y" { yyval = yyvsp[0]; ; break;} case 79: -#line 969 "parser.y" +#line 933 "parser.y" { yyval = yyvsp[0]; ; break;} case 80: -#line 975 "parser.y" +#line 939 "parser.y" { psmsg ("backend server:", yyvsp[0].set[0].v.sval); yyval = yyvsp[0]; ; break;} case 81: -#line 980 "parser.y" +#line 944 "parser.y" { pimsg ("backend port:", yyvsp[0].set[0].v.ival); yyval = yyvsp[0]; ; break;} case 82: -#line 985 "parser.y" +#line 949 "parser.y" { pimsg ("backend verbosity:", yyvsp[0].set[0].v.ival); yyval = yyvsp[0]; ; break;} case 83: -#line 990 "parser.y" +#line 954 "parser.y" { psmsg ("backend onstart:", yyvsp[0].set[0].v.sval); yyval = yyvsp[0]; ; break;} case 84: -#line 995 "parser.y" +#line 959 "parser.y" { psmsg ("backend onend:", yyvsp[0].set[0].v.sval); yyval = yyvsp[0]; ; break;} case 85: -#line 1000 "parser.y" +#line 964 "parser.y" { psmsg ("backend onfail:", yyvsp[0].set[0].v.sval); yyval = yyvsp[0]; ; break;} case 86: -#line 1005 "parser.y" +#line 969 "parser.y" { psmsg ("backend trafficlog:", yyvsp[0].set[0].v.sval); yyval = yyvsp[0]; ; break;} case 87: -#line 1010 "parser.y" +#line 974 "parser.y" { psmsg ("backend trafficlog:", yyvsp[0].set[0].v.sval); yyval = yyvsp[0]; ; break;} case 88: -#line 1015 "parser.y" +#line 979 "parser.y" { pimsg ("backend weight:", yyvsp[0].set[0].v.ival); yyval = yyvsp[0]; ; break;} case 89: -#line 1020 "parser.y" +#line 984 "parser.y" { pimsg ("backend decay:", yyvsp[0].set[0].v.ival); yyval = yyvsp[0]; ; break;} case 90: -#line 1025 "parser.y" +#line 989 "parser.y" { pimsg ("backend maxconnections:", yyvsp[0].set[0].v.ival); yyval = yyvsp[0]; ; break;} case 91: -#line 1030 "parser.y" +#line 994 "parser.y" { psmsg ("backend sticky cookie:", yyvsp[0].set[0].v.sval); yyval = yyvsp[0]; ; break;} case 92: -#line 1035 "parser.y" +#line 999 "parser.y" { psmsg ("addclientheader:", yyvsp[0].set[0].v.sval); yyval = yyvsp[0]; ; break;} case 93: -#line 1040 "parser.y" +#line 1004 "parser.y" { psmsg ("setclientheader:", yyvsp[0].set[0].v.sval); yyval = yyvsp[0]; ; break;} case 94: -#line 1045 "parser.y" +#line 1009 "parser.y" { psmsg ("appendclientheader:", yyvsp[0].set[0].v.sval); yyval = yyvsp[0]; ; break;} case 95: -#line 1050 "parser.y" +#line 1014 "parser.y" { psmsg ("addserverheader:", yyvsp[0].set[0].v.sval); yyval = yyvsp[0]; ; break;} case 96: -#line 1055 "parser.y" +#line 1019 "parser.y" { psmsg ("setserverheader:", yyvsp[0].set[0].v.sval); yyval = yyvsp[0]; ; break;} case 97: -#line 1060 "parser.y" +#line 1024 "parser.y" { psmsg ("appendserverheader:", yyvsp[0].set[0].v.sval); yyval = yyvsp[0]; ; break;} case 98: -#line 1065 "parser.y" +#line 1029 "parser.y" { pimsg ("backend retries:", yyvsp[0].set[0].v.ival); yyval = yyvsp[0]; ; break;} case 99: -#line 1070 "parser.y" +#line 1034 "parser.y" { pimsg ("backend state:", yyvsp[0].set[0].v.ival); yyval = yyvsp[0]; ; break;} case 100: -#line 1080 "parser.y" +#line 1044 "parser.y" { psmsg ("server statement:", laststr); yyval.n = 1; @@ -2179,7 +2143,7 @@ case 100: ; break;} case 101: -#line 1092 "parser.y" +#line 1056 "parser.y" { pimsg ("weight statement", lastnr); yyval.n = 1; @@ -2189,7 +2153,7 @@ case 101: ; break;} case 102: -#line 1104 "parser.y" +#line 1068 "parser.y" { pimsg ("decay statement", lastnr); yyval.n = 1; @@ -2199,13 +2163,13 @@ case 102: ; break;} case 103: -#line 1114 "parser.y" +#line 1078 "parser.y" { setlaststr (laststring); ; break;} case 104: -#line 1122 "parser.y" +#line 1086 "parser.y" { pimsg ("retries:", lastnr); yyval.n = 1; @@ -2215,7 +2179,7 @@ case 104: ; break;} case 105: -#line 1134 "parser.y" +#line 1098 "parser.y" { pimsg ("state:", lastnr); yyval.n = 1; @@ -2225,25 +2189,25 @@ case 105: ; break;} case 107: -#line 1149 "parser.y" +#line 1113 "parser.y" { lastnr = st_available; ; break;} case 108: -#line 1153 "parser.y" +#line 1117 "parser.y" { lastnr = st_unavailable; ; break;} case 109: -#line 1157 "parser.y" +#line 1121 "parser.y" { lastnr = st_down; ; break;} case 110: -#line 1165 "parser.y" +#line 1129 "parser.y" { psmsg ("onstart statement:", laststr); yyval.n = 1; @@ -2253,7 +2217,7 @@ case 110: ; break;} case 111: -#line 1177 "parser.y" +#line 1141 "parser.y" { psmsg ("onfail statement:", laststr); yyval.n = 1; @@ -2263,7 +2227,7 @@ case 111: ; break;} case 112: -#line 1189 "parser.y" +#line 1153 "parser.y" { psmsg ("onend statement:", laststr); yyval.n = 1; @@ -2273,7 +2237,7 @@ case 112: ; break;} case 113: -#line 1201 "parser.y" +#line 1165 "parser.y" { psmsg ("trafficlog statement:", laststr); yyval.n = 1; @@ -2283,7 +2247,7 @@ case 113: ; break;} case 114: -#line 1213 "parser.y" +#line 1177 "parser.y" { psmsg ("throughputlog statement:", laststr); yyval.n = 1; @@ -2293,7 +2257,7 @@ case 114: ; break;} case 115: -#line 1224 "parser.y" +#line 1188 "parser.y" { setlaststr (laststring); free (laststring); @@ -2301,7 +2265,7 @@ case 115: ; break;} case 116: -#line 1233 "parser.y" +#line 1197 "parser.y" { setlaststr (laststring); free (laststring); @@ -2309,7 +2273,7 @@ case 116: ; break;} case 117: -#line 1243 "parser.y" +#line 1207 "parser.y" { psmsg ("insertcookie statement:", laststr); yyval.n = 1; @@ -2319,7 +2283,7 @@ case 117: ; break;} case 118: -#line 1254 "parser.y" +#line 1218 "parser.y" { setlaststr (laststring); free (laststring); @@ -2327,7 +2291,7 @@ case 118: ; break;} case 119: -#line 1264 "parser.y" +#line 1228 "parser.y" { psmsg ("addclientheader statement:", laststr); yyval.n = 1; @@ -2337,7 +2301,7 @@ case 119: ; break;} case 120: -#line 1276 "parser.y" +#line 1240 "parser.y" { psmsg ("setclientheader statement:", laststr); yyval.n = 1; @@ -2347,7 +2311,7 @@ case 120: ; break;} case 121: -#line 1288 "parser.y" +#line 1252 "parser.y" { psmsg ("appendclientheader statement:", laststr); yyval.n = 1; @@ -2357,7 +2321,7 @@ case 121: ; break;} case 122: -#line 1300 "parser.y" +#line 1264 "parser.y" { psmsg ("addserverheader statement:", laststr); yyval.n = 1; @@ -2367,7 +2331,7 @@ case 122: ; break;} case 123: -#line 1312 "parser.y" +#line 1276 "parser.y" { psmsg ("setserverheader statement:", laststr); yyval.n = 1; @@ -2377,7 +2341,7 @@ case 123: ; break;} case 124: -#line 1324 "parser.y" +#line 1288 "parser.y" { psmsg ("appendserverheader statement:", laststr); yyval.n = 1; @@ -2387,7 +2351,7 @@ case 124: ; break;} case 125: -#line 1335 "parser.y" +#line 1299 "parser.y" { setlaststr (laststring); free (laststring); @@ -2395,121 +2359,121 @@ case 125: ; break;} case 126: -#line 1342 "parser.y" +#line 1306 "parser.y" { yyerrmsg = "HTTP header specifier expected"; ; break;} case 127: -#line 1347 "parser.y" +#line 1311 "parser.y" { yyerrmsg = "cookie specifier expected"; ; break;} case 128: -#line 1352 "parser.y" +#line 1316 "parser.y" { yyerrmsg = "number expected"; ; break;} case 129: -#line 1357 "parser.y" +#line 1321 "parser.y" { yyerrmsg = "hostname or IP address expected"; ; break;} case 130: -#line 1362 "parser.y" +#line 1326 "parser.y" { yyerrmsg = "'service' expected"; ; break;} case 131: -#line 1367 "parser.y" +#line 1331 "parser.y" { yyerrmsg = "backend definition statement expected"; ; break;} case 132: -#line 1372 "parser.y" +#line 1336 "parser.y" { yyerrmsg = "service body statement expected"; ; break;} case 133: -#line 1377 "parser.y" +#line 1341 "parser.y" { yyerrmsg = "semicolon (;) expected"; ; break;} case 134: -#line 1382 "parser.y" +#line 1346 "parser.y" { yyerrmsg = "'on' or 'off' expetcted"; ; break;} case 135: -#line 1387 "parser.y" +#line 1351 "parser.y" { yyerrmsg = "dispatch method expected"; ; break;} case 136: -#line 1392 "parser.y" +#line 1356 "parser.y" { yyerrmsg = "command line expected"; ; break;} case 137: -#line 1397 "parser.y" +#line 1361 "parser.y" { yyerrmsg = "file name expected"; ; break;} case 138: -#line 1402 "parser.y" +#line 1366 "parser.y" { yyerrmsg = "service name (identifier) expected"; ; break;} case 139: -#line 1407 "parser.y" +#line 1371 "parser.y" { yyerrmsg = "backend name (identifier) expected"; ; break;} case 140: -#line 1412 "parser.y" +#line 1376 "parser.y" { yyerrmsg = "IP address such as 1.2.3.4 or 'any' expected"; ; break;} case 141: -#line 1417 "parser.y" +#line 1381 "parser.y" { yyerrmsg = "Service type expected ('any', 'stickyhttp', ...)"; ; break;} case 142: -#line 1422 "parser.y" +#line 1386 "parser.y" { yyerrmsg = "Header inspection mode mode expected ('shallow' or 'deep')"; ; break;} case 143: -#line 1427 "parser.y" +#line 1391 "parser.y" { yyerrmsg = "IP filter(s) expected"; ; break;} case 144: -#line 1432 "parser.y" +#line 1396 "parser.y" { yyerrmsg = "username expected"; ; break;} case 145: -#line 1437 "parser.y" +#line 1401 "parser.y" { yyerrmsg = "state definition expected"; ; @@ -2747,4 +2711,4 @@ yyreturn: #endif return yyresult; } -#line 1441 "parser.y" +#line 1405 "parser.y" diff --git a/src/lib/parser.y b/src/lib/parser.y @@ -168,54 +168,18 @@ element: '{' servicestatements '}' { - /* Check for port duplicates, bindto duplicates */ - for (i = 0; i < nservice; i++) { - if (service[i].port == cur_service.port) { - if (service[i].bind && cur_service.bind && - !strcmp(service[i].bind, cur_service.bind)) - error ("Services %s and %s cannot bind to same IP %s and " - "port %d", - service[i].name, cur_service.name, - cur_service.bind, cur_service.port); - if (!service[i].bind && cur_service.bind) - error ("Services %s and %s use the same port %d, but " - "%s does not bind to a specific IP", - service[i].name, cur_service.name, - cur_service.port, service[i].name); - if (service[i].bind && !cur_service.bind) - error ("Services %s and %s use the same port %d, but " - "%s does not bind to a specific IP", - service[i].name, cur_service.name, - cur_service.port, cur_service.name); - if (!service[i].bind && !cur_service.bind) - error ("Services %s and %s use the same port without " - "binding to an IP", - service[i].name, cur_service.name); - } - } - - /* Verify the service description, supply defaults - * and so on. - */ - if (!cur_service.port) - error ("Service %s lacks a port", - cur_service.name); - if (!cur_service.nbackend) - error ("Service %s lacks back ends", - cur_service.name); - + /* Check integrity, supply defaults */ + check_service (cur_service); + if (!cur_service.shmkey) cur_service.shmkey = (unsigned) hashpjw (cur_service.name); msg ("Service %s: shared memory key set to 0x%8.8x", cur_service.name, cur_service.shmkey); - if (cur_service.rev_interval && cur_service.check_interval) - error ("Service %s has both a revivinginterval and " - "a checkinterval", cur_service.name); if (!cur_service.check_cmd) cur_service.check_cmd = xstrdup (""); - /* Add to the list. */ + /* Add to the list, reset cur_service for next run */ service = xrealloc (service, ++nservice * sizeof(Service)); service[nservice - 1] = cur_service; memset (&cur_service, 0, sizeof(Service)); diff --git a/src/lib/parserclose.c b/src/lib/parserclose.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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,24 +0,0 @@ -/************************************************************************* - * 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" - -int restart (int ac, char **av) { - - create_commandline_space(); - - /* First run the 'stop' action. */ - if (!stop_daemon (ac, av)) - error ("Daemon stop failed, restart failure"); - - sleep (1); - - /* Now run 'start' */ - if (!serve (ac, av)) - error ("Daemon start failed, restart failure"); - - /* All ok.. */ - return (1); -} diff --git a/src/lib/runservice.c b/src/lib/runservice.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.62, a load balancer and fail over + * This file is part of Crosroads 1.64, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ @@ -37,7 +37,9 @@ void runservice () { } /* Child branch */ - setproctitle ("crossroads - Service %s: listening", activeservice->name); + if (!leave_proctitle) + setproctitle ("crossroads - Service %s: listening", + activeservice->name); close (0); close (1); close (2); diff --git a/src/lib/serve.c b/src/lib/serve.c @@ -1,29 +0,0 @@ -/************************************************************************* - * 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" - -int serve (int ac, char **av) { - int i; - FILE *f; - char *cmd; - - cmd = xstrdup (BINDIR "/crossroads-daemon"); - for (i = 1; i < org_argc; i++) { - cmd = xstrcatch (cmd, ' '); - cmd = xstrcat (cmd, org_argv[i]); - } - - msg ("Starting daemon"); - - if (! (f = popen (cmd, "w")) ) - error ("Failed to start %s: %s", cmd, strerror(errno)); - config_write (fileno(f)); - if (pclose (f) == -1) - error ("Crossroads daemon '%s' indicates error", cmd); - - return (1); -} diff --git a/src/lib/setproctitle.c b/src/lib/setproctitle.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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,25 +0,0 @@ -/************************************************************************* - * 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" - -int show_services (int ac, char **av) { - int i, j; - - for (i = 0; i < nservice; i++) { - printf ("Service %s (on port %d) %d backends\n", - service[i].name, service[i].port, service[i].nbackend); - if (service[i].allowfile) - printf (" Allow file: %s\n", service[i].allowfile); - if (service[i].denyfile) - printf (" Deny file: %s\n", service[i].denyfile); - for (j = 0; j < service[i].nbackend; j++) - printf (" Backend %s (%s:%d)\n", - service[i].backend[j].name, - service[i].backend[j].initial_server, - service[i].backend[j].initial_port); - } - return (1); -} diff --git a/src/lib/showstatus.c b/src/lib/showstatus.c @@ -1,190 +0,0 @@ -/************************************************************************* - * 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" - -static char *timestr (double nsec) { - static char *buf; - char *tmp; - - free (buf); - buf = 0; - - if (nsec > 3600) { - buf = str_printf ("%uh", (unsigned) (nsec / 3600)); - nsec = fmod (nsec, 3600); - } - if (nsec > 60) { - tmp = str_printf ("%um", (unsigned) (nsec / 60)); - nsec = fmod (nsec, 60); - buf = xstrcat (buf, tmp); - free (tmp); - } - tmp = str_printf ("%.2fs", nsec); - if (!strcmp (tmp + strlen(tmp) - 4, ".00s")) - strcpy (tmp + strlen(tmp) - 4, "s"); - buf = xstrcat (buf, tmp); - free (tmp); - - return (buf); -} - -static char *bytestr (double nbytes) { - static char *buf; - - free (buf); - - if (nbytes > (double)1024*1024*1024*1024) - buf = str_printf ("%.2fTb", - nbytes / ((double) 1024*1024*1024*1024)); - else if (nbytes > 1024*1024*1024) - buf = str_printf ("%.2fGb", - nbytes / ((double) 1024*1024*1024)); - else if (nbytes > 1024*1024) - buf = str_printf ("%.2fMb", - nbytes / ((double) 1024*1024)); - else if (nbytes > 1024) - buf = str_printf ("%.2fKb", - nbytes / (double) 1024); - else - buf = str_printf ("%gb", nbytes); - - return (buf); -} - -int show_status (int ac, char **av) { - int i, j, services_shown = 0; - unsigned sec_ago; - int state_count[NR_OF_STATES]; - - if (xml_status) { - printf ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); - if (xml_xslt) - printf ("<?xml-stylesheet type=\"text/xsl\" " - "href=\"%s\"?>\n", xml_xslt); - printf ("<status>\n"); - } - - for (i = 0; i < nservice; i++) { - if (ac > 1 && strcmp (service[i].name, av[0])) - continue; - if (services_shown++) { - if (xml_status) - printf (" </service>\n"); - else - putchar ('\n'); - } - alloc_reporter (service + i, 0); - msg ("Reporting service %s (pid = %d)", - service[i].name, servicereport->pid); - - /* Count the back ends by their state. */ - for (j = 0; j < NR_OF_STATES; j++) - state_count[j] = 0; - for (j = 0; j < service[i].nbackend; j++) - state_count[servicereport->backendstate[j].actual_avail]++; - - if (tabular_status) - printf ("%s ", service[i].name); - else if (xml_status) { - printf (" <service id=\"%d\" name=\"%s\">\n" - " <connections>%d</connections>\n" - " <lastbackend>%d</lastbackend>\n", - i, service[i].name, servicereport->nclients, - servicereport->last_backend); - for (j = 0; j < NR_OF_STATES; j++) - printf (" <backends_%s>%d</backends_%s>\n", - state_to_string ( (Backendavail)j ), - state_count[j], - state_to_string ( (Backendavail)j )); - } else - printf ("Service : %s, %d live connections, " - "last backend %d\n", - service[i].name, servicereport->nclients, - servicereport->last_backend); - for (j = 0; j < service[i].nbackend; j++) { - if (ac > 2 && strcmp (service[i].backend[j].name, av[1])) - continue; - if (! servicereport->backendstate[j].laststamp) - sec_ago = 0; - else - sec_ago = time(0) - servicereport->backendstate[j].laststamp; - if (tabular_status) - printf ("%s=%s ", service[i].backend[j].name, - state_to_string(servicereport->backendstate[j].actual_avail)); - else if (xml_status) { - printf (" <backend id=\"%d\" name=\"%s\">\n" - " <availability id=\"%d\">%s</availability>\n" - " <clients>%u</clients>\n" - " <failures>%lu</failures>\n" - " <connections>%lu</connections>\n" - " <duration sec=\"%g\">%s</duration>\n" - " <throughput bytes=\"%g\">%s</throughput>\n", - j, service[i].backend[j].name, - servicereport->backendstate[j].actual_avail, - state_to_string( - servicereport->backendstate[j].actual_avail), - servicereport->backendstate[j].nclients, - servicereport->backendstate[j].failures, - servicereport->backendstate[j].totuses, - servicereport->backendstate[j].nsec, - timestr (servicereport->backendstate[j].nsec), - servicereport->backendstate[j].nbytes, - bytestr (servicereport->backendstate[j].nbytes)); - printf (" <lastaccess sec=\"%u\">%s</lastaccess>\n" - " <server>%s</server>\n" - " <port>%d</port>\n", - sec_ago, timestr( (double) sec_ago), - servicereport->backendstate[j].actual_server, - servicereport->backendstate[j].actual_port); - if (service[i].type == type_http) - printf (" <sessions>%lu</sessions>\n", - servicereport->backendstate[j].sessions); - printf (" </backend>\n"); - } - else { - printf (" Backend %2d : %s is %s, %u live connections\n" - " Stats : %lu failures out of %lu connections", - j, - service[i].backend[j].name, - state_to_string ( - servicereport->backendstate[j].actual_avail), - servicereport->backendstate[j].nclients, - servicereport->backendstate[j].failures, - servicereport->backendstate[j].totuses); - if (service[i].type == type_http) - printf (", %lu sessions,", - servicereport->backendstate[j].sessions); - printf ("\n" - " usage %s, %s", - timestr (servicereport->backendstate[j].nsec), - bytestr (servicereport->backendstate[j].nbytes)); - if (service[i].dispatchover) - printf (", avg %s, %s", - timestr(servicereport->backendstate[j].avg_nsec), - bytestr(servicereport->backendstate[j].avg_nbytes)); - printf (", last hit %s ago\n" - " address %s:%d\n", - timestr ( (double) sec_ago), - servicereport->backendstate[j].actual_server, - servicereport->backendstate[j].actual_port); - } - } - - if (shmdt (servicereport) < 0) - error ("Failure releasing reporter memory: %s", - strerror(errno)); - } - if (tabular_status) - putchar ('\n'); - else if (xml_status) { - if (services_shown) - printf (" </service>\n"); - printf ("</status>\n"); - } - - return (1); -} diff --git a/src/lib/stagetostring.c b/src/lib/stagetostring.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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,35 +0,0 @@ -/************************************************************************* - * 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" - -int stop_daemon (int ac, char **av) { - int i, result = 0; - - for (i = 0; i < nservice; i++) { - alloc_reporter (service + i, 0); - msg ("Stopping service %s (daemon pid %d, wakeup handler pid %d)", - service[i].name, servicereport->pid, servicereport->rev_pid); - if (kill (servicereport->pid, SIGINT)) { - warning ("Failed to stop service %s (%s)", - service[i].name, strerror(errno)); - result++; - } else if (servicereport->rev_pid && - kill (servicereport->rev_pid, SIGINT)) { - warning ("Failed to stop wakeup handler of service %s (%s)", - service[i].name, strerror(errno)); - result++; - } - - /* Note: We run the deallocator of shmem here anyway, though the - * signalled listener does it too.. just to make sure.. We do this - * only if above kills have succeeded. - */ - if (!result) - dealloc_reporter (service + i); - } - - return (1); -} diff --git a/src/lib/strcasestr.c b/src/lib/strcasestr.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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/stringtostate.c b/src/lib/stringtostate.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, a load balancer and fail over * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL. * Visit http://crossroads.e-tunity.com for information. *************************************************************************/ @@ -27,8 +27,9 @@ void tcpserve (int server_sock) { if ( (pid = fork()) < 0 ) error ("Fork failed: %s", strerror(errno)); else if (!pid) { - setproctitle ("crossroads - Service %s: wakeup", - activeservice->name); + if (!leave_proctitle) + setproctitle ("crossroads - Service %s: wakeup", + activeservice->name); wakeup_handler(); } else { msg ("Service %s: started wakeup handler at pid %d", diff --git a/src/lib/tellservice.c b/src/lib/tellservice.c @@ -1,73 +0,0 @@ -/************************************************************************* - * 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" - -int tell_service (int ac, char **av) { - Service *target_service = 0; - int target_backend = -1, i; - Backendavail avail; - int newstate, port; - char *hostname, *cp; - - /* Locate service */ - for (i = 0; i < nservice; i++) - if (!strcasecmp (service[i].name, av[0])) { - target_service = service + i; - break; - } - if (!target_service) - error ("Service '%s' isn't known. " - "Maybe the configuration has changed?", av[0]); - - /* Locate back end */ - for (i = 0; i < target_service->nbackend; i++) - if (!strcasecmp (target_service->backend[i].name, av[1])) { - target_backend = i; - break; - } - if (target_backend == -1) - error ("Backend '%s' of service '%s' isn't known. " - "Maybe the configuration has changed?", av[1], av[0]); - - /* Let's see what we need to tell the back end of that service. */ - if (!strcmp (av[2], "state")) { - /* Locate new state: either the direct number, or alpha name */ - if (sscanf (av[3], "%d", &newstate) > 0) { - avail = (Backendavail) newstate; - if (avail > st_unknown) - error ("Bad state number '%s'", av[3]); - } else if ( (avail = string_to_state (av[3])) == st_unknown ) - error ("Incorrect state '%s'.", av[3]); - - /* Got all data. Poke the new state into shared memory. */ - alloc_reporter (target_service, 0); - servicereport->backendstate[target_backend].actual_avail = avail; - servicereport->backendstate[target_backend].fail = 0; - msg ("Marked backend %s of service %s as %s.", - av[1], av[0], state_to_string (avail)); - } else if (!strcmp (av[2], "server")) { - /* Get the hostname and port part. */ - hostname = av[3]; - if (! (cp = strchr (hostname, ':')) ) - error ("Bad address '%s' (hostname:port expected)", av[3]); - *cp = 0; - if (sscanf (cp + 1, "%d", &port) < 1) - error ("Bad port part in address"); - /* Got all data. Poke the new state into shared memory. */ - alloc_reporter (target_service, 0); - strncpy (servicereport->backendstate[target_backend].actual_server, - hostname, FQDN_LENGTH - 1); - servicereport->backendstate[target_backend].actual_port = port; - msg ("Address for backend %s of service %s set to %s:%d.", - av[1], av[0], hostname, port); - } else { - usage(); - } - /* All done.. success */ - return (1); -} - diff --git a/src/lib/thruputlog.c b/src/lib/thruputlog.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.txt b/src/lib/usage.txt @@ -23,9 +23,9 @@ Usage: Supported flags: -a: Logs starting and finishing activity to syslog - -b Writes binary configuration to stdout (debugging only) + -b: Writes binary configuration to stdout (debugging only) -B BUFSZ Defines the network buffer size, default %d bytes - -C: Shows compile-time configuration and stops + -C: Shows compile-time configuration and stops -c CONFIG: Uses the named configuration, instead of the default %s -d TTL: Specifies the time to live of cached DNS entries, @@ -35,9 +35,11 @@ Supported flags: for LOG_LOCAL0 to LOG_LOCAL7. -m PERM: Sets permissions for shm access to PERM, which is an octal number. Defaults to 0644. - -s: Sloppy binding to the listen port of each service (if the port + -p: Process title will not be altered; 'ps' will show + 'crossroads-daemon' instead of custom title + -s: Sloppy binding to the listen port of each service (if the port is busy, Crossroads will wait for it to become free). - -t: 'status' output is shown as a tabular availability view + -t: 'status' output is shown as a tabular availability view -x: 'status' output is shown as an XML document -X XSLT: Embed reference to XSLT in 'crossroads -x status' -v: Enables verbosity upon startup. Other verbosity (services diff --git a/src/lib/vsyslog.c b/src/lib/vsyslog.c @@ -1,5 +1,5 @@ /************************************************************************* - * This file is part of Crosroads 1.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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.62, a load balancer and fail over + * This file is part of Crosroads 1.64, 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/shared/parseopt.inc b/src/shared/parseopt.inc @@ -5,7 +5,7 @@ * - doc/main/using.yo * - doc/man/crossroads.yo */ - while ( (opt = getopt (argc, argv, "bB?c:fhvi:Val:stCm:xd:X:")) > 0 ) + while ( (opt = getopt (argc, argv, "bB?c:fhvi:Val:stCm:xd:X:p")) > 0 ) switch (opt) { case 'a': log_activity++; @@ -89,6 +89,9 @@ show_config(); #endif exit (0); + case 'p': + leave_proctitle++; + break; case 'V': puts (VER); exit (0); diff --git a/test/Makefile b/test/Makefile @@ -1,4 +1,7 @@ -foo: +include $(BASE)/etc/Makefile.def +include $(BASE)/etc/Makefile.conf + +foo: hashtest @echo 'Running simplistic tests...' @echo @for f in t*.conf ; do \ @@ -15,4 +18,11 @@ foo: done @echo @echo 'All tests have completed successfully.' + @echo 'Run test/hashtest to test the hashing algorithm.' @echo + +hashtest: hashtest.c + $(CC) $(DEFS) -o hashtest hashtest.c -L../src/lib -lcrossroads + +clean: + rm -f *.o hashtest diff --git a/test/bad21.conf b/test/bad21.conf @@ -0,0 +1,9 @@ +/* HTTP commands with 'type any' */ +service one { + port 80; + backend one { + server 10.1.1.1:80; + addclientheader "X-bla: blerk"; + } +} + diff --git a/test/hashtest.c b/test/hashtest.c @@ -0,0 +1,45 @@ +#include "../src/crossroads.h" + +int hits[100]; + +int main (int argc, char **argv) { + int max, b1, b2, b3, b4, index, n = 0; + char buf[255]; + + if (argc == 2) { + if (! (max = atoi (argv[1])) ) { + fprintf (stderr, "%s is not a number (1..100 required)\n", argv[1]); + exit (1); + } + for (b1 = 1; b1 <= 255; b1++) + for (b2 = 1; b2 <= 255; b2++) + for (b3 = 1; b3 <= 255; b3++) + for (b4 = 1; b4 <= 255; b4++) { + sprintf (buf, "%d.%d.%d.%d", b1, b2, b3, b4); + index = hashpjw (buf) % max; + hits[index]++; + if (! (n % 100000)) { + printf ("\r%-30s %d", buf, index); + fflush (stdout); + n = 0; + } + n++; + } + + for (index = 0; index < max; index++) + printf ("\n\ndone\n" + "index %d: %d hits\n", index, hits[index]); + } else if (argc == 3) { + if (! (max = atoi (argv[1])) ) { + fprintf (stderr, "%s is not a number (1..100 required)\n", argv[1]); + exit (1); + } + printf ("%d\n", hashpjw (argv[2]) % max); + } else { + fprintf (stderr, "Usage: hashtest nbackends [ip-address]\n"); + exit (1); + } + + return (0); +} +