craigwatson / bitcoind-status

PHP application to display status and information from the Bitcoin node daemon.
https://odin.vikingserv.net
Apache License 2.0
82 stars 77 forks source link

IPv6 peer addresses are not stored in $peer_ip correctly #41

Closed jamesmacwhite closed 6 years ago

jamesmacwhite commented 6 years ago

I was reviewing the array structure to hide certain peers from the peer list table and noticed that hiding IPv6 peers didn't work, but IPv4 peers did. I was using this format to hide them.

'peers_to_ignore'           => array(
      'x.x.x.x', // Example peer to hide
      'x.x.x.x' // Example peer to hide
),

Looking at the array output, it looks like IPv6 peers are not stored properly. I dumped the array of a live node that has both v4 and v6 peers connected and this is the output. Notice how all IPv6 addresses are cut off after each semi-colon. Currently I don't think IPv6 peers can be hidden from the list, with this issue.

Array
(
    [0] => [2a00
    [1] => 1398
    [2] => 4
    [3] => 2a00
    [4] => 
    [5] => a1]
    [6] => 50434
)

Array
(
    [0] => [2a01
    [1] => 4f8
    [2] => 121
    [3] => 14f7
    [4] => 
    [5] => 2]
    [6] => 11764
)

Array
(
    [0] => 136.243.139.120
    [1] => 11034
)

Array
(
    [0] => [2a01
    [1] => 4f8
    [2] => 212
    [3] => 3b1f
    [4] => 
    [5] => 2]
    [6] => 58582
)

Array
(
    [0] => 91.121.108.36
    [1] => 8333
)

Array
(
    [0] => 77.249.29.104
    [1] => 8333
)

Array
(
    [0] => 47.54.207.91
    [1] => 8333
)

Array
(
    [0] => 148.251.191.101
    [1] => 8333
)

Array
(
    [0] => 129.13.252.47
    [1] => 60740
)

Array
(
    [0] => [2a00
    [1] => 1398
    [2] => 4
    [3] => 2a00
    [4] => 
    [5] => a5]
    [6] => 56708
)

Array
(
    [0] => 129.13.252.36
    [1] => 53883
)

Array
(
    [0] => [2400
    [1] => 4123
    [2] => a344
    [3] => 1600
    [4] => 8da0
    [5] => 82cf
    [6] => 3244
    [7] => 3884]
    [8] => 60869
)

Array
(
    [0] => 203.59.32.206
    [1] => 54275
)

Array
(
    [0] => 77.178.239.123
    [1] => 32798
)

Array
(
    [0] => 192.168.1.10
    [1] => 47542
)

Array
(
    [0] => [2001
    [1] => 0
    [2] => 9d38
    [3] => 6abd
    [4] => 24fe
    [5] => 3c9b
    [6] => a244
    [7] => 416f]
    [8] => 55922
)

Array
(
    [0] => 91.99.99.204
    [1] => 8333
)

Array
(
    [0] => 70.33.168.27
    [1] => 43959
)

Array
(
    [0] => 89.164.214.136
    [1] => 51046
)

Array
(
    [0] => 188.239.121.120
    [1] => 53946
)

Array
(
    [0] => 75.169.152.193
    [1] => 52276
)

Array
(
    [0] => 202.153.71.3
    [1] => 8333
)

Array
(
    [0] => 2.227.190.195
    [1] => 49467
)

Array
(
    [0] => 173.27.90.112
    [1] => 37294
)

Array
(
    [0] => [2a02
    [1] => 678
    [2] => 528
    [3] => c200
    [4] => 5c38
    [5] => 7464
    [6] => 2b3a
    [7] => 1759]
    [8] => 50593
)

Array
(
    [0] => 71.194.203.200
    [1] => 59749
)

Array
(
    [0] => 72.36.89.11
    [1] => 37888
)

Array
(
    [0] => 202.108.211.56
    [1] => 33689
)

Array
(
    [0] => 84.142.215.179
    [1] => 60978
)

Array
(
    [0] => 70.33.168.27
    [1] => 15814
)

Array
(
    [0] => [2002
    [1] => 2f5f
    [2] => 9078
    [3] => 
    [4] => 2f5f
    [5] => 9078]
    [6] => 8333
)

Array
(
    [0] => 144.76.129.186
    [1] => 8333
)

Array
(
    [0] => 70.33.168.27
    [1] => 10112
)

Array
(
    [0] => 212.35.25.161
    [1] => 58100
)

I'm thinking its likely due to:

https://github.com/craigwatson/bitcoind-status/blob/master/php/functions.php#L193

You are using a colon as essentially the delimiter for the ip:port like 194.168.55.46:8333, but this doesn't take into account the format of an IPv6 peer and breaks the output.