Changeset - 853f2417ae5a
[Not reviewed]
default
0 1 0
Tyler Durden (virii) - 11 years ago 2014-01-22 20:11:02
virii@c3l.lu
Bridge recognition fixxed
1 file changed with 5 insertions and 2 deletions:
0 comments (0 inline, 0 general)
Scripts/update_server.pl
Show inline comments
 
@@ -22,34 +22,35 @@ if (-e '/etc/ennstatus_updater.conf') {
 
        		$ennstatus_url = $1 if /^ennstatus_url = (.+)/i;
 
    		}
 
	close ennstatus;
 
} else {
 
	$ennstatus_url = $API_url;
 
}
 
######## [loop through configs] ########
 
for (1..scalar @configs) {
 
    open config, "<", "/etc/tor/" . $configs[$_ -1] || die "Cannot open $configs[$_ -1]\n";
 
        while (<config>) {
 
            $server_name = $1       if /^Nickname (\w+)/i;
 
            $server_type = 'Exit'   if /^ExitPolicy accept \*:\*/i;
 
            $server_type = 'Relay'  if /^ExitPolicy reject \*:\*/i;
 
            $server_type = 'Relay'  if /^ExitPolicy reject \*:\*/i and $server_type ne 'Bridge';
 
            $server_type = 'Bridge' if /^BridgeRelay 1/i;
 
            $data_dir    = $1       if /^DataDirectory (.*)/i;
 
            $pidfile     = $1       if /^PidFile (.*)/i;
 
            $obfs        = 'True'   if /^ServerTransportPlugin obfs2,obfs3/i;
 
            $ip          = $1       if /^OutboundBindAddress (\d+\.\d+\.\d+\.\d+)/i;
 
        }
 
    close config;
 
######## [obfs check] ########  
 
    $obfs = 'False' if ($obfs ne "True" and $server_type == 'Bridge');
 
    $obfs = 'False' if $obfs ne 'True' and $server_type eq 'Bridge';
 
print $obfs . "\n";
 
######## [ip check] ########    
 
    if ($ip == "") {
 
        $socket = new IO::Socket::INET ( PeerAddr => "google.com",
 
                                         PeerPort => 80,
 
                                         Proto => 'tcp');
 
        $ip = $socket->sockhost;
 
        close $socket;
 
    }
 
######## [fingerprint] ######## 
 
    open fingerprint, "<", $data_dir . '/fingerprint';
 
        $read_in = <fingerprint>;
 
        $fingerprint = $1 if $read_in =~ /^\w+ (\w{40})/i;
 
@@ -84,12 +85,14 @@ if ($server_type eq "Bridge") {
 
######## [Send to server] ########
 
$request = HTTP::Tiny->new->request('POST', $ennstatus_url . '/api/update',
 
                    {
 
                      content => $json_string,
 
                      headers => { 'content-type' => 'application/json' }
 
                    }
 
                                    );
 

	
 
print $request->{content};
 
######## [end of loop] ########
 
}
 

	
 

	
 

	
0 comments (0 inline, 0 general)