--- googlecode.com/svn/trunk/Meteor/Config.pm 2008/02/04 19:02:49 45 +++ googlecode.com/svn/trunk/Meteor/Config.pm 2008/03/02 22:18:59 57 @@ -42,6 +42,9 @@ use strict; our @DEFAULTS=( +'Template for each line in channelinfo', + ChannelInfoTemplate => '\r\n', + 'Configuration file location on disk (if any)', ConfigFileLocation => '/etc/meteord.conf', @@ -60,16 +63,15 @@ 'Name of index file to serve when a directory is requested from the static file web server', DirectoryIndex => 'index.html', -'Header template, ~server~, ~servertime~ and ~status~ will be replaced by the appropriate values. **NOTE**: It is possible to define more than one HeaderTemplate by appending a number at the end, for example *HeaderTemplate42*. Clients can request a specific header to be used by adding the parameter template= to their GET request. If *HeaderTemplate* is not found, the system will use the default HeaderTemplate (no number)', - HeaderTemplate => 'HTTP/1.1 ~status~\r\nServer: ~server~\r\nContent-Type: text/html; charset=utf-8\r\nPragma: no-cache\r\nCache-Control: no-cache, no-store, must-revalidate\r\nExpires: Thu, 1 Jan 1970 00:00:00 GMT\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n', - -'Template for each line in channelinfo', - - ChannelInfoTemplate => '~name~ ~messageCount~\r\n', +'Header template, ~server~, ~servertime~ and ~status~ will be replaced by the appropriate values.', + HeaderTemplate => 'HTTP/1.1 ~status~\r\nServer: ~server~\r\nContent-Type: text/html; charset=utf-8\r\nPragma: no-cache\r\nCache-Control: no-cache, no-store, must-revalidate\r\nExpires: Thu, 1 Jan 1970 00:00:00 GMT\r\n\r\n', 'Print out this help message', Help => '', +'Format to use for timestamps in syslog: unix or human', + LogTimeFormat => 'human', + 'Maximum age of a message in seconds', MaxMessageAge => 7200, @@ -85,14 +87,13 @@ 'Message template, ~text~, ~id~, ~channel~ and ~timestamp~ will be replaced by the appropriate values', MessageTemplate => '\r\n', -'Interval at which PingMessage is sent to all persistent and identified subscriber connections (ie those including id=someuniqueidentifier in their request, and not specifying persist=0). Must be at least 3 if set higher than zero. Set to zero to disable.', +'Interval at which PingMessage is sent to all persistent subscriber connections. Must be at least 3 if set higher than zero. Set to zero to disable.', PingInterval => 5, -'Persistence of a connection. Note: some modes have this hardcoded!', - +'Persistence of a connection.', Persist => 0, -'Message to be sent to all persistent and identified subscriber connections (see above) every PingInterval seconds', +'Message to be sent to all persistent subscriber connections (see above) every PingInterval seconds', PingMessage => '\r\n', 'IP address for subscriber server (leave empty for all local addresses)', @@ -107,17 +108,23 @@ 'An absolute filesystem path, to be used as the document root for Meteor\'s static file web server. If left empty, no documents will be served.', SubscriberDocumentRoot => '/usr/local/meteor/public_html', -'Since Meteor is capable of serving static pages from a document root as well as streaming events to subscribers, this paramter is used to specify the URI at which the event server can be reached. If set to the root, Meteor will lose the ability to serve static pages.', +'Since Meteor is capable of serving static pages from a document root as well as streaming events to subscribers, this parameter is used to specify the URI at which the event server can be reached. If set to the root, Meteor will lose the ability to serve static pages.', SubscriberDynamicPageAddress => '/push', 'The syslog facility to use', SyslogFacility => 'daemon', + +'IP address for udp server (leave empty for all local addresses)', + UDPIP => '', + +'Port number for udp connections, set to 0 to disable', + UDPPort => 0, + ); our %ConfigFileData=(); our %CommandLine=(); our %Defaults=(); - our %ExtraKeys=(); our %Modes=(); for(my $i=0;$ivalueForKey('Debug'); - print STDERR '-'x79 ."\nParamters:\nSource \tName and Value\n".'-'x79 ."\n" if($debug); + print STDERR '-'x79 ."\nMeteor server v$::VERSION (release date: $::RELEASE_DATE)\r\nLicensed under the terms of the GNU General Public Licence (2.0)\n".'-'x79 ."\n" if($debug); my @keys=(); @@ -144,11 +151,10 @@ next if($DEFAULTS[$i+1] eq 'Help'); push(@keys,$DEFAULTS[$i+1]); } - push(@keys,keys %ExtraKeys); - foreach my $mode ('',keys %Modes) { + print STDERR ($mode) ? "\r\n$mode:\r\n" : "\r\nDefaults:\r\n" if($debug); foreach my $baseKey (@keys) { my $foundValue=0; @@ -175,28 +181,21 @@ next unless($foundValue); - print STDERR "\t$key\t$::CONF{$key}\n" if($debug); + print STDERR "\t$baseKey\t$::CONF{$key}\n" if($debug); # Take care of escapes $::CONF{$key}=~s/\\(.)/ - if($1 eq 'r') - { + if($1 eq 'r') { "\r"; - } - elsif($1 eq 'n') - { + } elsif($1 eq 'n') { "\n"; - } - elsif($1 eq 's') - { + } elsif($1 eq 's') { ' '; - } - elsif($1 eq 't') - { + } elsif($1 eq 't') { "\t"; - } - else - { + } elsif($1 eq '0') { + "\0"; + } else { $1; } /gex; @@ -240,9 +239,9 @@ my $mode=''; - if($k=~s/(\..+)$//) + if($k=~s/(\.(.+))$//) { - $mode=$1; + $mode=$2; $Modes{$mode}=1; } @@ -277,12 +276,6 @@ $key=$p; } } - - if($k=~/^HeaderTemplate(\d+)$/i) - { - $key="HeaderTemplate$1"; - $ExtraKeys{$key}=1; - } &usage("Unknown parameter name '$kOrig'") unless(defined($key)); @@ -325,7 +318,8 @@ if(/^\s*\[\s*([^\]\s]+)\s*\]\s*$/) { - $Modes{".$1"}=1; + $Modes{$1}=1; + $mode = $1; next; } @@ -338,20 +332,13 @@ my $val=$2; $val='' unless(defined($val)); - if($key=~/^HeaderTemplate\d+$/) + unless(exists($Defaults{$key})) { - $ExtraKeys{$key}=1; + &usage("Unknown configuration file parameter name '$key$mode'"); } - else + if($key eq 'ConfigFileLocation') { - unless(exists($Defaults{$key})) - { - &usage("Unknown configuration file parameter name '$key$mode'"); - } - if($key eq 'ConfigFileLocation') - { - &usage("'ConfigFileLocation' parameter not allowed in configuration file!"); - } + &usage("'ConfigFileLocation' parameter not allowed in configuration file!"); } $val=~s/^--/-/; @@ -368,7 +355,7 @@ print STDERR <<"EOT"; $msg; For further help type $::PGM -help -or consult docs at http://www.meteorserver.org/ +or consult docs at http://meteorserver.org/ EOT } else { @@ -400,7 +387,7 @@ $Defaults{'ConfigFileLocation'} For more information and complete documentation, see the Meteor -website at http://www.meteorserver.org/ +website at http://meteorserver.org/ EOT }