louislam / uptime-kuma

A fancy self-hosted monitoring tool
https://uptime.kuma.pet
MIT License
58.35k stars 5.26k forks source link

Add `givenPortOnly` config for GameDig monitor #2887

Closed shadowgamingyt closed 1 year ago

shadowgamingyt commented 1 year ago

⚠️ Please verify that this bug has NOT been raised before.

🛡️ Security Policy

📝 Describe your problem

some of my servers work loading the up time etc but ones that i am using gamedig to access the servers uptime directly it does not work at all and just says its offline constantly image

🐻 Uptime-Kuma Version

1.20.2

💻 Operating System and Arch

22.04.2 LTS

🌐 Browser

edge

🐋 Docker Version

No response

🟩 NodeJS Version

No response

fletchowns commented 1 year ago

I was having a similar issue with my gamedig monitors. I thought it was related to my firewall rules restricting access to these game servers, meaning that uptime-kuma running in a container on the same server wasn't able to access it. That doesn't seem to be the case though.

As a test, I tried to manually install gamedig in my uptime-kuma container using npm install gamedig, and I'm able to successfully query my game servers:

uptime-kuma@36af169156a9:~$ ./node_modules/.bin/gamedig --type dayz dayz.my-docker-network:2302
{"name":"My DayZ Server...
uptime-kuma@36af169156a9:~$ ./node_modules/.bin/gamedig --type valheim valheim.my-docker-network:2456
{"name":"My Valheim Server...

However the equivalent config through uptime-kuma doesn't seem to work: image

Didn't find anything revealing in the logs:

2023-03-06T23:20:44-08:00 [MONITOR] WARN: Monitor #17 'DayZ': Failing: Failed all 1 attempts | Interval: 60 seconds | Type: gamedig | Down Count: 0 | Resend Interval: 0
chakflying commented 1 year ago

Can you try setting the DayZ port to 27016 in the monitor?

louislam commented 1 year ago

It seems that givenPortOnly set to false, it will work. Or as @chakflying said, using 27016 also works.

https://github.com/louislam/uptime-kuma/blob/2dedc1cfbd2eab61ebcc5793ee4a949532d19405/server/model/monitor.js#L523

I checked the games.txt, there is a value called port_query_offset.

dayz|DayZ (2018)|valve|port=2302,port_query_offset=24714

2302 + 24714 = 2016

What I don't understand here is, what is the point of showing the fake port (2302) instead of 27016?

chakflying commented 1 year ago

I think 2302 is the port that clients actually connect to, while 27015+ is the Valve Server Query Protocol which is used to query the server status. Some info in notes in https://github.com/Yepoleb/python-a2s .

The discussion in #2566 suggested the use of givenPortOnly because server admins would know which port to use. But it seems that now normal users also wanted to use this feature to monitor games they play, and made it confusing.

shadowgamingyt commented 1 year ago

for mordhau ive tried all ports possible even reinstalling the server changing the ports to its recommended to run the server and still nothing and everything is port forwarded. in console it shows its talking but it ant getting data that its up image

image