File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change 187187open (my $log , " < $ha_log " ) or die " Can't read $ha_log : $! " ;
188188seek ($log , $ha_log_size , 0) or die " Can't seek $ha_log to $ha_log_size : $! " ;
189189my %seen ;
190+ my %failed_to_listen_tcp ;
190191while (<$log >) {
191192 $seen {$1 }++ if / (Forwarding TCP from .*? to ((\d .*?|\[ .*?\] ):\d +|\/ [^"]+))/ ;
192193 $seen {$1 }++ if / (Not forwarding TCP .*?:\d +)/ ;
194+ $failed_to_listen_tcp {$2 }=$1 if / (failed to listen tcp: listen tcp (.*?:\d +):[^"]+)/ ;
193195}
194196close $log or die ;
195197
220222 print " 😕 Unexpected log message: $_ \n " ;
221223}
222224
225+ if (%failed_to_listen_tcp ) {
226+ foreach (keys %failed_to_listen_tcp ) {
227+ print " ⚠️ $failed_to_listen_tcp {$_ }\n " ;
228+ }
229+ my @tcp_list = keys %failed_to_listen_tcp ;
230+ if ($Config {osname } eq " darwin" ) {
231+ my @lsof_args = map { " -iTCP\@ $_ " } @tcp_list ;
232+ print ` lsof -P @lsof_args ` ;
233+ } elsif ($Config {osname } eq " linux" ) {
234+ my @lss_args = map { " src = $_ " } @tcp_list ;
235+ my $ss_expression = join (" or " , @lss_args );
236+ print ` sudo ss -lnpt "$ss_expression "` ;
237+ } elsif ($Config {osname } eq " cygwin" ) {
238+ my @awk_args = map { " -e'/$_ /'" } @tcp_list ;
239+ print ` netstat -aon | awk -e'/^ +Proto/' @awk_args ` ;
240+ }
241+ }
242+
223243# Cleanup remaining netcat instances (and port forwards)
224244print $lima " sudo pkill -x nc" ;
225245
You can’t perform that action at this time.
0 commit comments