Lines 117-134
Link Here
|
117 |
my $msg = $opts->{msg}; |
117 |
my $msg = $opts->{msg}; |
118 |
|
118 |
|
119 |
my $countries = ''; |
119 |
my $countries = ''; |
|
|
120 |
my $prev_country = 'Trusted_'; |
121 |
my $country_tokens = ''; |
122 |
|
120 |
my $IP_PRIVATE = IP_PRIVATE; |
123 |
my $IP_PRIVATE = IP_PRIVATE; |
121 |
foreach my $relay (@{$msg->{metadata}->{relays_untrusted}}) { |
124 |
foreach my $relay (@{$msg->{metadata}->{relays_untrusted}}) { |
122 |
my $ip = $relay->{ip}; |
125 |
my $ip = $relay->{ip}; |
123 |
# Private IPs will always be returned as '**' |
126 |
# Private IPs will always be returned as '**' |
124 |
my $cc = $ip =~ /^$IP_PRIVATE$/o ? '**' : $ip_to_cc->($ip); |
127 |
my $cc = $ip =~ /^$IP_PRIVATE$/o ? '**' : $ip_to_cc->($ip); |
125 |
$countries .= $cc." "; |
128 |
$countries .= $cc." "; |
|
|
129 |
if ($cc ne $prev_country && $cc ne "**") { |
130 |
$country_tokens .= $prev_country.$cc." "; |
131 |
if ($prev_country ne 'Trusted_') { |
132 |
$country_tokens .= "deep_".$cc." "; |
133 |
} |
134 |
$prev_country = $cc; |
135 |
} |
136 |
|
126 |
} |
137 |
} |
127 |
|
138 |
|
128 |
chop $countries; |
139 |
chop $countries; |
|
|
140 |
chop $country_tokens; |
129 |
$msg->put_metadata("X-Relay-Countries", $countries); |
141 |
$msg->put_metadata("X-Relay-Countries", $countries); |
130 |
dbg("metadata: X-Relay-Countries: $countries"); |
142 |
dbg("metadata: X-Relay-Countries: $countries"); |
131 |
|
143 |
|
|
|
144 |
$msg->put_metadata("X-Relay-Country-Tokens", $country_tokens); |
145 |
dbg("metadata: X-Relay-Country-Tokens: $country_tokens"); |
146 |
|
132 |
return 1; |
147 |
return 1; |
133 |
} |
148 |
} |
134 |
|
149 |
|
Lines 142-147
Link Here
|
142 |
my @c_list = split(' ', $countries); |
157 |
my @c_list = split(' ', $countries); |
143 |
$opts->{permsgstatus}->set_tag("RELAYCOUNTRY", |
158 |
$opts->{permsgstatus}->set_tag("RELAYCOUNTRY", |
144 |
@c_list == 1 ? $c_list[0] : \@c_list); |
159 |
@c_list == 1 ? $c_list[0] : \@c_list); |
|
|
160 |
my $country_tokens = |
161 |
$opts->{permsgstatus}->get_message->get_metadata('X-Relay-Country-Tokens'); |
162 |
my @ct_list = split(' ', $country_tokens); |
163 |
$opts->{permsgstatus}->set_tag("RELAYCOUNTRYTOKENS", |
164 |
@ct_list == 1 ? $ct_list[0] : \@ct_list); |
145 |
return 1; |
165 |
return 1; |
146 |
} |
166 |
} |
147 |
|
167 |
|