Skip to content

Commit b784e24

Browse files
committed
fix: MHFS::Plugin::BitTorrent::Tracker loading, improve publicip handling
1 parent 3a7fc49 commit b784e24

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

App-MHFS/lib/MHFS/Plugin/BitTorrent/Tracker.pm

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,14 +160,9 @@ sub announce {
160160
if($peer ne $ipport) {
161161
my @values = unpack('CCCCCC', $peer);
162162
my $netmap = $request->{'client'}{'server'}{'settings'}{'NETMAP'};
163-
my $pubip = $request->{'client'}{'server'}{'settings'}{'PUBLICIP'};
163+
my $pubip = $self->{pubip};
164164
if($netmap && (($values[0] == $netmap->[1]) && (unpack('C', $ipport) != $netmap->[1])) && $pubip) {
165-
try {
166-
say "HACK converting local peer to public ip";
167-
$peer = pack('Nn', parse_ipv4($pubip), (($values[4] << 8) | $values[5]));
168-
catch ($e) {
169-
say "public ip didn't parse, cannot convert local peer to public ip"
170-
}
165+
$peer = pack('Nn', $pubip, (($values[4] << 8) | $values[5]));
171166
}
172167
say __PACKAGE__.": sending peer ".peertostring($peer);
173168
$pstr .= $peer;
@@ -202,6 +197,11 @@ sub new {
202197
bless $self, $class;
203198
say __PACKAGE__.": announce interval: ".$self->{'announce_interval'};
204199

200+
if (exists $settings->{'PUBLICIP'}) {
201+
try { $self->{pubip} = parse_ipv4($settings->{'PUBLICIP'}); }
202+
catch ($e) {}
203+
}
204+
205205
# load the existing torrents
206206
my $odres = opendir(my $tdh, $settings->{'MHFS_TRACKER_TORRENT_DIR'});
207207
if(! $odres){

0 commit comments

Comments
 (0)