OpenMediaVault-Plugin-Developers / openmediavault-autoshutdown

OpenMediaVault plugin to provide frontend for autoshutdown script
35 stars 30 forks source link

Add support for ipv4-mapped ipv6 address in port check #66

Closed nrandon closed 4 years ago

nrandon commented 4 years ago

Add support for ipv4-mapped ipv6 address as the 'ss -n' command will display the ipv4-mapped address as '[::ffff:<ipv4 address]:' rather than just an ipv4 address. Also in such an instance the connection addresses will be similarly formatted and must be adjusted.

Additionally cleanup connection output so all of the ipv4 connection addresses are presented for a port.

ryecoaaron commented 4 years ago

@nrandon Sorry but if you look at the other pull requests for this plugin, I am the worst one to merge or review this. There is a lot of behavior changing that I can't test. I wish someone else would maintain this plugin who actually uses it.

nrandon commented 4 years ago

@ryecoaaron is there anyone that can review this, as caring the change locally is not a grate solution ?

nrandon commented 4 years ago

not ment to close

ryecoaaron commented 4 years ago

@nrandon I would ask on the forum. I'm not sure who could review it.

FernetMenta commented 4 years ago

I tested this change and I think it is correct.

Output of ss -n | grep ESTAB

tcp  ESTAB  0   0  [::ffff:192.168.178.25]:80          [::ffff:192.168.178.53]:52845

The new regex:

ss -n | awk -v regex="^([[]::ffff:)?192.168.178.25[]]?:80$" '$2 ~ /^ESTAB$/ && $5 ~ regex'

catches this:

tcp               ESTAB                  0                   0                                                                          [::ffff:192.168.178.25]:80                                        [::ffff:192.168.178.53]:52845         
tcp               ESTAB                  0                   0                                                                          [::ffff:192.168.178.25]:80                                        [::ffff:192.168.178.53]:52844 

The old one does not and is useless with debian buster even if ipv6 is disabled

FernetMenta commented 4 years ago

fixes https://github.com/OpenMediaVault-Plugin-Developers/openmediavault-autoshutdown/issues/67

MarkusGradl commented 4 years ago

I tested this change too. The Output on my installation is: tcp ESTAB 0 0 [::ffff:192.168.1.89]:80 [::ffff:192.168.1.21]:54264

This is the result in /var/log/autoshutdown.log _check_net_status(): Found active connection on port 80 (HTTP) from 192.168.1.21

I think, the result is correct.

nrandon commented 4 years ago

@ryecoaaron now this has been reviewed and tested independently can it be merged ?