//require_once("/var/www/web3/share/util/libexec/main.sql.php"); //require_once("/var/www/web3/share/util/libexec/lib.iref.php"); //$ipref_out = "
Sonic server: plugin daemon |
Introduction
$gallery_pics
Sonic is a PHP CLI (command line) executable that is able to thread (or rotate instances of) services via custom loaded modules. the daemon itself is function orientated which handles forks (or sequential instances) of configured sonic-stream modules which are object orientated. stream modules can be either standalone or standalone with a preloaded listening socket connection. there are two example plug-in sonic stream modules packaged with the daemon for test and learning purposes. there are also currently 4 separate (but branded) stream module projects that demonstrate the generic polymorphic capabilities of Sonic. ie.
Sonic can be useful for a few things, eg. anything you need forked, or forked with socket handling. eg. you could use the two packaged example stream modules (local and remote) to start your own cron and net-cat replacement (for insanities sake). Requirements
a PHP CLI enviroment installed, setup and a reason. There is a *nix shell and winblowz batch confgiuration script to help loading the main Sonic executable (which may need some tweaking on custom Sonic/PHP installs).
Install Sonic
Unpack then check the environment configuration script in the bin directory, the Sonic ini configuration file in the conf directory, then run.
Example Usage
-v 3
Run Sonic daemon with verbose output sent to log
\$ bin/sonic-daemon.sh -v 3 > /path/to/log/file.txt
-q Launch Sonic daemon into the background process (no logging)
\$ bin/sonic-daemon.sh -q &
--tcp_echo Run Sonic daemon with debug output of tcp stream sent to self on port 1234. mirror input back to server on same socket
\$ bin/sonic-daemon.sh -S t1 --s-t1-stream=remote --s-t1-port=1234 --s-t1-tcp_echo=On
--service-NAME-socket_protocol SOL_UDP Run Sonic daemon with raw output of udp stream sent to self on port 1234
\$ bin/sonic-daemon.sh -v 3 -S u1 --s-u1-stream=remote --s-u1-socket_type=SOCK_DGRAM --s-u1-socket_protocol=udp --s-u1-port=1234
-S Launch Sonic with ini supplied WWW server and runtime supplied source relay setup (temporary virtual hosting) --stream exec --exec stunnel --stream www --port 80 --stunnel_log path/to/stunnel.log stunnel port 443 (and forward) and sonic port 80 stunnel4 in -> 0.0.0.0:443 -> out -> 0.0.0.0:80 sonic-w1 in -> 0.0.0.0:80 -> out -> peername Run Sonic daemon initating stunnel pairing with www stream on port 80 as a SSL web-server (different 'Host:') Run Sonic daemon initating stunnel pairing with www stream on host 192.168.0.22 via non-stantard port 8081 and as a SSL web-server on non-standard port 8082 with virtual host setup for single address 192.168.0.22:8082 --stream src_relay --tcp_echo streamming debug/sanity/dump/mux test in -> 192.168.0.10:1234 -> 192.168.0.10:2234 -> out -> 192.168.0.50:1234 Run tcp echo on self port 2234. take inbound udp stream from server sending on port 1234, pass stream (with source stamp 192.168.0.10) via tcp to self running tcp_echo on port 2234. then push tcp_echo reply via udp stream (with source stamp 192.168.0.10) to 192.168.0.50 on port 1234. Development
This was written circa 2004, dusted off and taken off the shelf in 2008. If anyone wants to get carried away with the daemon list below, or some stream modules eg. proxy,
TODO (daemon)
man sonic: Ping aka icmp echo/PongIntroduction
PHP Ping
Example Configuration Example Usage
--stream ping --host localhost
Run Sonic daemon and ping localhost
\$ bin/sonic-daemon.sh -S p1 --s-p1-stream=ping --s-p1-host=127.0.0.1
Development
doc sonic::stream::ping: src_relay aka Proxy RelayIntroduction
The proxy relay connects to the destination server/end-point on behalf of the connected client. the proxy relay can also have all or one of its interfaces/ip-addresses bound to the connection(s) ie. allows alternate source addressing. if the server end-point is a tcp connection, the relay can also re-route the return replies.
Example Configuration Example Usage
--stream src_relay --port 8022 --dst_host localhost --dst_port 22
port open and forward in -> 0.0.0.0:8022 -> out -> 127.0.0.1:22 Run Sonic daemon exporting local only sshd service port on 8022
\$ bin/sonic-daemon.sh -q -S s1 --s-s1-stream=src_relay --s-s1-port=8022 --s-s1-dst_host=127.0.0.1 --s-s1-dst_port=22
--stream src_relay --port 1234 --dst_host broadcast --dst_port 1235 port open and forward in -> 0.0.0.0:1234 -> out -> 192.168.0.255:1235 Run Sonic daemon re-routing incomming stream on port 1234 to broadcast range on port 1235 Development
doc sonic::stream::src_relay: www aka Web ServerIntroduction
The web server serves files and dynamic php content to a clients web browser. seeing most php/cgi scripts arent expecting to be run in cli mode with cgi emulation, some logic in your php code you want interpreted may need some case handling for sonic www. ie. pretty much any code that will result in an uncontrolled ob_flush() or header buffer alteration. eg. premature exiting, error handling, setting cookies etc. as well as the pseudo cgi environment, your top level main php file that is being executed, will now be a second level include under the main sonic stream module class. ie. some functions may need to be preparsed top most of file, aswell as re-scoping most top level variables to globals. there is a small (and probably outdated) compatibility list to preview before attempting to auto-patch with the supplied script.
Example Configuration Development
doc sonic::stream::www: |