… | |
… | |
51 | printf $fh "(%.1f bytes/s)\n", $::written / ($::NOW - $last_ts); |
51 | printf $fh "(%.1f bytes/s)\n", $::written / ($::NOW - $last_ts); |
52 | ($last_ts, $::written) = ($::NOW, 0); |
52 | ($last_ts, $::written) = ($::NOW, 0); |
53 | } elsif ($cmd eq "refresh") { |
53 | } elsif ($cmd eq "refresh") { |
54 | do "config.pl"; |
54 | do "config.pl"; |
55 | print $fh "config.pl: $@\n" if $@; |
55 | print $fh "config.pl: $@\n" if $@; |
|
|
56 | %statdata_cache = (); |
56 | read_blocklist; |
57 | read_blockuri; |
|
|
58 | read_blockref; |
57 | } elsif ($cmd eq "restart") { |
59 | } elsif ($cmd eq "restart") { |
58 | $::RESTART = 1; |
60 | $::RESTART = 1; |
59 | unloop; |
61 | unloop; |
60 | print $fh "restarting, cu!\n"; |
62 | print $fh "restarting, cu!\n"; |
61 | last; |
63 | last; |
62 | } elsif ($cmd eq "country") { |
64 | } elsif ($cmd eq "country") { |
63 | print $fh ip_request($_), "\n"; |
65 | print $fh netgeo::ip_request($_), "\n"; |
64 | } |
66 | } |
65 | } else { |
67 | } else { |
66 | print $fh "try one of @commands\n"; |
68 | print $fh "try one of @commands\n"; |
67 | } |
69 | } |
68 | } |
70 | } |
69 | } |
71 | } |
70 | |
72 | |
71 | # bind to tcp port |
73 | # bind to tcp port |
72 | if ($CMDSHELL_PORT) { |
74 | if ($CMDSHELL_PORT) { |
73 | my $port = new Coro::Socket |
75 | my $port = new Coro::Socket |
74 | LocalAddr => "127.0.0.1", |
76 | #LocalAddr => "127.0.0.1", |
75 | LocalPort => $CMDSHELL_PORT, |
77 | LocalPort => $CMDSHELL_PORT, |
76 | ReuseAddr => 1, |
78 | ReuseAddr => 1, |
77 | Listen => 1, |
79 | Listen => 1, |
78 | or die "unable to bind cmdshell port: $!"; |
80 | or die "unable to bind cmdshell port: $!"; |
79 | |
81 | |