如何以编程方式从 HLDS 读取服务器日志?
如何读取和解析从 HLDS(半条命专用服务器)远程发送的服务器日志?
我的理解是,您可以使用命令log_address
指定服务器将日志传送到的位置。 此后,服务器应该通过 UDP 传送日志。
如何使用 PHP 或 ASP.NET C# 监听这些日志? 我不知道我是否应该监听传入的数据包,或者向 HLDS 发送数据包请求。 我尝试使用 netstat -a
监视我的 UDP 连接,但似乎无法弄清楚这一点。
注意:我想使用 log_address 实现,因为我无法在服务器上安装任何第三方 mod 来协助日志记录过程。 我也了解 HLSW,并且不是在寻找这样的客户端应用程序。
谢谢。
How does one go about reading and parsing server logs sent remotely from HLDS (Half-Life Dedicated Server)?
My understanding is that you can specify where the server delivers logs using the command log_address
. After this, the server is supposed to deliver the logs via UDP.
How can I go about listening for these logs with either PHP or ASP.NET C#? I don't know if I'm supposed to be listening for incoming packets, or send a request to HLDS for packets. I've attempted to monitor my UDP connections using netstat -a
, but cannot seem to figure this out.
Note: I would like to use a log_address implementation, as I cannot install any third-party mods on the server to assist with the logging process. I am also aware of HLSW and am not looking for a client-side application such as this.
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我知道这是一个老问题,但我能找到的任何地方都没有答案。 我不想解释 UDP,因为它已经被一遍又一遍地介绍过。 然而,如果您已经正确地向服务器提供了您的公共 IP 地址和您正在使用 UDP 侦听的同一端口,并且您没有收到任何数据,则实际接收数据包有一个技巧。
您必须通过服务器的标准游戏端口向服务器发送消息。 不管它是什么,它可以是所有服务器关心的“你好”。 之后您应该开始从服务器获取数据。 我不确定这是为什么,但这可能是 Valve 的一个策略,以避免他们的服务器只向任何旧 IP 发送垃圾邮件。
I know this is an old question, but it's not answered anywhere that I can find. I'd rather not explain about UDP since that's been covered over and over. However, if you have properly given the server your public IP address and the same port you're listening to with UDP and you're not getting any data, there is one trick to actually receiving packets.
You have to send a message to the server, on the server's standard gameplay port. It doesn't matter what it is, it can be 'hello' for all the server cares. After that you should start getting data from the server. I'm not sure exactly why this is, but it's probably a strategy by Valve to avoid their server spamming just any old IP.
您应该查看 Steam HLDS Log Parser gem。
它是用 Ruby 编写的,工作原理如下:
logaddress xxx.xxx.xxx.xxx yyyy
,其中x
是 ip,y
将使用 UDP 发送日志的端口当我说
display
时,实际上您可以对返回的内容执行您想要的操作(推送到 irc、写入数据库...)。 只需编写您自己的“显示程序”我几天前发布了这个宝石,请随意尝试并做出贡献。
我最近添加了国际化支持,包括英语和法语翻译。
问候。
You should have a look to the Steam HLDS Log Parser gem.
It's in Ruby and works like that :
logaddress xxx.xxx.xxx.xxx yyyy
wherex
is the ip andy
your port where the logs will be sent using UDPWhen i say
display
, in fact you can do what you want with the returned content (push to irc, write in a database...). Just write your own "displayer"I published this gem few days ago, feel free to try and contribute.
I recently added i18n support with english and french translations.
Regards.