upptime / upptime

⬆️ GitHub Actions uptime monitor & status page by @AnandChowdhary
https://upptime.js.org
MIT License
14.95k stars 843 forks source link

Failed to tcp-ping on IPv6-only host #976

Open marek22k opened 1 week ago

marek22k commented 1 week ago

Describe the bug Hello, I recently discovered upptime and think the project is great. I have a few IPv6-only VMs that I would like to monitor. For this I have set a tcp-ping on port 22. However, despite the IPv6 flag being set, Upptime reports that the host is down.

To Reproduce

Example: Report: https://github.com/marek22k/uptime/issues/1 Configuration: https://github.com/marek22k/uptime/blob/938dae4bd246547ab02cb2543dc4629cb914ac87/.upptimerc.yml#L25

Expected behavior It is not displayed as Down.

AnandChowdhary commented 6 days ago

From the logs I can see (https://github.com/marek22k/uptime/actions/runs/9723560406/job/26838810660#step:3:103):

ERROR Got pinging error Error: all attempts failed
    at performTestOnce (/home/runner/work/_actions/upptime/uptime-monitor/v1.36.4/webpack:/@upptime/uptime-monitor/dist/update.js:166:1)

Do you have any idea why all attempts to pinging would have failed, like a bot check on your end?

marek22k commented 5 days ago

No, I allow TCP on 22 in my host firewall without a rate limit or anything similar. I also run fail2ban on reseau.mk16.de, palerme.mk16.de and laplace.mk16.de. But not on the others. Furthermore, the hosts are also hosted by different providers in two different countries: mikhail.mk16.de - Vodafone (Germany) laplace.mk16.de, grisha.mk16.de - O2 (Telefonia) (Germany) palerme.mk16.de, reseau.mk16.de - LGP CORP (France)

TCP ping seems to work from my computer:

$ scamper -I "ping -c 4 -d 22 -P TCP-syn $(dig palerme.mk16.de AAAA +short)"
ping 2a01:c23:91b7:c701:ce12:612e:ebba:794f to 2a01:cb05:944a:b8ff:e4a6:adff:fe95:4e75: 60 byte packets
64 bytes from 2a01:cb05:944a:b8ff:e4a6:adff:fe95:4e75, seq=0 tcp=open ttl=249 time=34.318 ms
64 bytes from 2a01:cb05:944a:b8ff:e4a6:adff:fe95:4e75, seq=1 tcp=open ttl=249 time=34.611 ms
64 bytes from 2a01:cb05:944a:b8ff:e4a6:adff:fe95:4e75, seq=2 tcp=open ttl=249 time=34.151 ms
64 bytes from 2a01:cb05:944a:b8ff:e4a6:adff:fe95:4e75, seq=3 tcp=open ttl=249 time=34.176 ms
--- 2a01:cb05:944a:b8ff:e4a6:adff:fe95:4e75 ping statistics ---
4 packets transmitted, 4 packets received, 0% packet loss
round-trip min/avg/max/stddev = 34.151/34.314/34.611/0.182 ms

I have also activated a TCP port ping in my Uptime Kuma instance as a test. It works there too: Screenshot_2024-06-29_16-16-51 Screenshot_2024-06-29_16-17-00

Personally, I also find it interesting that the TCP port scan only does not work with IPv6-only hosts.

AnandChowdhary commented 5 days ago

Hmm that's annoying indeed, sorry about that. We use the npm package tcp-ping to make this request: https://github.com/upptime/uptime-monitor/blob/master/src/helpers/ping.ts. Would you be able to try to run this locally and see if you find any obvious errors that we can fix? https://github.com/upptime/uptime-monitor/blob/2735e1b2bb69e63b987844dd8db29a0315e66b33/src/update.ts#L174

marek22k commented 3 days ago

Unfortunately, I'm not familiar with NodeJS at all. Can you tell me exactly what I should run?

AnandChowdhary commented 3 days ago

I have created a Replit here: https://replit.com/@AnandChowdhary/ImaginaryFavorableComment. From my testing, the exact same code seems to work correctly. Maybe the culprit is port and replaceEnvironmentVariables? I'll have to investigate a little more to be sure.

CleanShot 2024-07-02 at 11 48 42@2x

marek22k commented 3 days ago

p2p-node.de is also not an IPv6-only host (you can try on reseau.mk16.de, mikhail.mk16.de, grisha.mk16.de, laplace.mk16.de or palerme.mk16.de).

marek22k commented 2 days ago

I have tried the script with all IPv6-only hosts and it seems to work:

Personal computer at home:

$ node index.js 
{
  address: 'reseau.mk16.de',
  port: 22,
  attempts: 1,
  avg: 36.380369,
  max: 36.380369,
  min: 36.380369,
  results: [ { seq: 0, time: 36.380369 } ]
}
{
  address: 'palerme.mk16.de',
  port: 22,
  attempts: 1,
  avg: 43.412046,
  max: 43.412046,
  min: 43.412046,
  results: [ { seq: 0, time: 43.412046 } ]
}
{
  address: 'grisha.mk16.de',
  port: 22,
  attempts: 1,
  avg: 142.348125,
  max: 142.348125,
  min: 142.348125,
  results: [ { seq: 0, time: 142.348125 } ]
}
{
  address: 'mikhail.mk16.de',
  port: 22,
  attempts: 1,
  avg: 192.753556,
  max: 192.753556,
  min: 192.753556,
  results: [ { seq: 0, time: 192.753556 } ]
}
{
  address: 'laplace.mk16.de',
  port: 22,
  attempts: 1,
  avg: 276.145985,
  max: 276.145985,
  min: 276.145985,
  results: [ { seq: 0, time: 276.145985 } ]
}

VM at netcup:

$ node index.js 
{
  address: 'reseau.mk16.de',
  port: 22,
  attempts: 1,
  avg: 32.774304,
  max: 32.774304,
  min: 32.774304,
  results: [ { seq: 0, time: 32.774304 } ]
}
{
  address: 'palerme.mk16.de',
  port: 22,
  attempts: 1,
  avg: 45.698692,
  max: 45.698692,
  min: 45.698692,
  results: [ { seq: 0, time: 45.698692 } ]
}
{
  address: 'mikhail.mk16.de',
  port: 22,
  attempts: 1,
  avg: 424.710776,
  max: 424.710776,
  min: 424.710776,
  results: [ { seq: 0, time: 424.710776 } ]
}
{
  address: 'grisha.mk16.de',
  port: 22,
  attempts: 1,
  avg: 828.59476,
  max: 828.59476,
  min: 828.59476,
  results: [ { seq: 0, time: 828.59476 } ]
}
{
  address: 'laplace.mk16.de',
  port: 22,
  attempts: 1,
  avg: 1153.011911,
  max: 1153.011911,
  min: 1153.011911,
  results: [ { seq: 0, time: 1153.011911 } ]
}