Revertron / Alfis

Alternative Free Identity System
https://alfis.name
GNU Affero General Public License v3.0
298 stars 26 forks source link

Alfis tries to connect to itself as an external peer - is this normal? #8

Open xaozai opened 3 years ago

xaozai commented 3 years ago

It looks like Alfis is trying to connect to itself. "Created connection to peer own_IP:4244" and "Peer connection own_IP:4244 has shut down" repeated in a loop.

It may make sense to determine the addresses of the host on which Alfis is running and do not try to connect to these addresses.

2021-03-30 21:09:32,826 INFO  [alfis::web_ui] Current blockchain height is 14
2021-03-30 21:09:32,827 INFO  [alfis::blockchain::chain] Got zone data {"name":"yy","difficulty":20}
2021-03-30 21:09:32,827 INFO  [alfis::blockchain::chain] Got zone data {"name":"ygg","difficulty":24}
2021-03-30 21:09:32,827 INFO  [alfis::blockchain::chain] Got zone data {"name":"mesh","difficulty":20}
2021-03-30 21:09:33,008 INFO  [alfis::p2p::network] Received block 14
2021-03-30 21:09:33,169 WARN  [alfis::blockchain::chain] Ignoring block 14, we already have it
2021-03-30 21:10:08,972 INFO  [alfis::web_ui] Loaded keystore with key: 268E47DD5268A2EA8BC36668D2E00594E76ACD5CACA7CBBAB9F6E63BF75C4A82
2021-03-30 21:10:11,295 INFO  [alfis::p2p::peers] Created connection to peer 46.229.214.81:4244
2021-03-30 21:10:11,295 INFO  [alfis::p2p::peers] Created connection to peer [202:e220:4a35:c244:3440:83e3:3d2f:e0f4]:4244
2021-03-30 21:10:11,295 INFO  [alfis::p2p::peers] Created connection to peer [219:45d:824:2cb4:fd4f:dd40:fec5:3b7d]:4244
2021-03-30 21:10:11,295 INFO  [alfis::p2p::peers] Created connection to peer [203:8b1a::dae6:8827:90d:790a]:4244
2021-03-30 21:10:16,410 INFO  [alfis::p2p::peers] Created connection to peer 77.247.225.234:4244
2021-03-30 21:10:16,410 INFO  [alfis::p2p::peers] Created connection to peer [220:9b61:5f85:f842:f457:a63d:8c26:e06e]:4244
2021-03-30 21:10:16,426 INFO  [alfis::p2p::peers] Created connection to peer [203:xxxx:741b:42:3214:1234:xxxx:xxxx]:4244 ! Here is my Ygg IP !
2021-03-30 21:10:16,426 WARN  [alfis::p2p::network] Detected connection loop, ignoring IP: 203:xxxx:741b:42:3214:1234:xxxx:xxxx ! Here is my Ygg IP !
2021-03-30 21:10:16,426 WARN  [alfis::p2p::network] Error sending hello Обрыв канала (os error 32)
2021-03-30 21:10:16,426 INFO  [alfis::p2p::peers] Peer connection [203:xxxx:741b:42:3214:1234:xxxx:xxxx]:4244 has shut down ! Here is my Ygg IP !
2021-03-30 21:10:17,051 INFO  [alfis::p2p::peers] Created connection to peer xx.xx.xx.xxx:4244 ! Here is my IP !
2021-03-30 21:10:52,149 INFO  [alfis::p2p::network] Accepted connection from: [219:45d:824:2cb4:fd4f:dd40:fec5:3b7d]:55801 to local IP: [203:xxxx:741b:42:3214:1234:xxxx:xxxx]:4244
2021-03-30 21:11:09,730 INFO  [alfis::p2p::peers] Peer connection [224:aeef:d38b:9fe9:5d47:e9d3:6055:a774]:4244 has shut down
2021-03-30 21:11:18,738 INFO  [alfis::p2p::peers] Created connection to peer [203:xxxx:741b:42:3214:1234:xxxx:xxxx]:4244 ! Here is my Ygg IP !
2021-03-30 21:11:18,738 WARN  [alfis::p2p::network] Detected connection loop, ignoring IP: 203:xxxx:741b:42:3214:1234:xxxx:xxxx ! Here is my Ygg IP !
2021-03-30 21:11:18,738 WARN  [alfis::p2p::network] Error sending hello Обрыв канала (os error 32)
2021-03-30 21:11:18,738 INFO  [alfis::p2p::peers] Peer connection [203:xxxx:741b:42:3214:1234:xxxx:xxxx]:4244 has shut down ! Here is my Ygg IP !
2021-03-30 21:12:13,023 INFO  [alfis::p2p::peers] Created connection to peer [224:aeef:d38b:9fe9:5d47:e9d3:6055:a774]:4244
2021-03-30 21:12:22,030 INFO  [alfis::p2p::peers] Created connection to peer [203:xxxx:741b:42:3214:1234:xxxx:xxxx]:4244 ! Here is my Ygg IP !
2021-03-30 21:12:22,030 WARN  [alfis::p2p::network] Detected connection loop, ignoring IP: 203:xxxx:741b:42:3214:1234:xxxx:xxxx ! Here is my Ygg IP !
2021-03-30 21:12:22,031 WARN  [alfis::p2p::network] Error sending hello Обрыв канала (os error 32)
2021-03-30 21:12:22,031 INFO  [alfis::p2p::peers] Peer connection [203:xxxx:741b:42:3214:1234:xxxx:xxxx]:4244 has shut down ! Here is my Ygg IP !
2021-03-30 21:12:27,554 INFO  [alfis::p2p::peers] Peer connection xx.xx.xx.xxx:4244 has shut down ! Here is my IP !
Revertron commented 3 years ago

This is "normal" for v0.3.4. In v0.3.5 it will try to connect, but will drop the connection and will ignore itself.

xaozai commented 3 years ago

I have the latest version (0.3.5) and it constantly repeats attempts to connect to itself in the loop.

This, of course, is not very critical, but it seems to me that it would be better if there were no such attempts to connect to itself...

Revertron commented 3 years ago

I know. But there is no way to get all IPs of all local interfaces in an OS-independent manner. Additionally, if you are behind the NAT, your external IP will be unknown for ALFIS, and it will try to connect to it anyway. Therefore, I've implemented a trial-and-error approach.

xaozai commented 3 years ago

OK, maybe when Alfis detects a connection loop, add this address to the temporary forbidden list?

12:22,030 WARN  [alfis::p2p::network] Detected connection loop, ignoring IP: 203:xxxx:741b:42:3214:1234:xxxx:xxxx ! Here is my Ygg IP !

After that...