lgwrelay - send message to logiweb server and print response
lgwrelay host port homeurl ip request
The Logiweb relay allows a user to play with a Logiweb server (c.f. logiweb(1) ) in a user friendly style using a web browser. The Logiweb relay is designed to be called from a CGI-script but may also be run as an ordinary user command provided the user is prepared to read html. For a sample CGI-script, see the EXAMPLES section.
The audience of the Logiweb relay are programmers of Logiweb clients and servers who want to play with a Logiweb server in order to learn the details of the Logiweb protocol (c.f. logiweb(7) ).
The Logiweb relay sends the given ip and request to the Logiweb server listening at the given tcp port of the given host and then prints the response to standard output. If the Logiweb relay is invoked from a CGI-script, then the pipeline comprising web browser, CGI-script, lgwrelay, and the tcp port of the Logiweb server adds syntactic sugar to the Logiweb protocol. For raw hexadecimal communication using the servers udp port use lgwping(1) instead.
The pipeline is self-documenting. Invoking lgwrelay with the empty string as request (typically by looking up something like http://logiweb.eu/logiweb/server/relay in a web browser) gives all explanations needed.
Suppose lgwrelay is situated in /usr/bin/lgwrelay. Suppose the following script is situated in /var/www/logiweb/65535 with execute permissions set:
#!/bin/bash /usr/bin/lgwrelay logiweb.eu $0 http://logiweb.eu/logiweb \ $REMOTE_ADDR "$PATH_INFO"
Further suppose the configuration files of the local web server maps http://my.domain/logiweb/server/ to /var/www/logiweb/, e.g. by having ScriptAlias /logiweb/server/ "/var/www/logiweb/" in a configuration file such as /etc/httpd/conf.d/logiweb.conf.
Under these assumptions, if you look up http://logiweb.eu/logiweb/server/xyzzy in your browser somewhere in the world then lgwrelay will send your IP and /xyzzy to tcp port 65535 of the Logiweb server at logiweb.eu. The response from that tcp port will be sent back to your web browser.
The REMOTE_ADDR and PATH_INFO environment variables are set by the web server when it invokes the CGI-script. See a CGI primer for details.
PATH_INFO is in quotes above for the sake of situations where PATH_INFO is the empty string.
If the server runs behind a proxy, consider replacing REMOTE_ADDR above by HTTP_X_FORWARDED_FOR. Otherwise, all requests will seem to come from the proxy.
Klaus Grue, http://logiweb.eu/
logiweb(1) , logiweb(7) , lgwping(1)