diff options
author | Alexander Sulfrian <alex@spline.inf.fu-berlin.de> | 2016-06-21 02:42:25 +0200 |
---|---|---|
committer | Alexander Sulfrian <alex@spline.inf.fu-berlin.de> | 2016-06-21 02:42:25 +0200 |
commit | 339312c92a71a0943ae34aab27b1026bb3479d0d (patch) | |
tree | cea49efa50ec436b517a25dc1d1ff90f575e2f18 /srs | |
parent | d9ba41806745b830fd229b4cbcd8b5386203af27 (diff) | |
download | srs-339312c92a71a0943ae34aab27b1026bb3479d0d.tar.gz srs-339312c92a71a0943ae34aab27b1026bb3479d0d.tar.bz2 srs-339312c92a71a0943ae34aab27b1026bb3479d0d.zip |
Make subclasses of Net::Server
Spline::Socketmap is now a subclasses of Net::Server and
Spline::Socketmap::Srs is a subclass of Spline::Socketmap. This way the
Srs stuff is completly independent of the postfix-socketmap protocol
handling.
The config is located in the instances and configurable with Net::Server
command line options or config file.
Diffstat (limited to 'srs')
-rwxr-xr-x | srs | 27 |
1 files changed, 17 insertions, 10 deletions
@@ -4,18 +4,25 @@ use warnings; use FindBin; use lib $FindBin::Bin; -use Spline::Socketmap; -use Spline::Srs; +use English; + +use Spline::Socketmap::Srs; -$Spline::Socketmap::timeout = 10; -$Spline::Socketmap::handler = sub { - my ($map, $key) = @_; - Spline::Srs::handle($map, $key); +my $defaults = { + syslog_ident => 'srs', + log_level => 1, }; -Spline::Socketmap->run({ - syslog_ident => 'srs', - conf_file => ($< == 0 ? '' : $ENV{"HOME"}) . '/etc/srs.conf', -}); +# Load config file by default if it exists +my $config_file = '/etc/srs.conf'; +$config_file = $ENV{HOME} . $config_file if $UID != 0; +$defaults->{conf_file} = $config_file if -e $config_file; + +# Default to current user (if not root) +$defaults->{user} = $EUID if $EUID != 0; +$defaults->{group} = $EGID if $EGID != 0; + +my $server = Spline::Socketmap::Srs->new(); +$server->run($defaults); # vim: set et ts=4: |