1

如何读取和解析从 HLDS(半衰期专用服务器)远程发送的服务器日志?

我的理解是,您可以使用命令指定服务器将日志传递到何处log_address。在此之后,服务器应该通过 UDP 传递日志。

如何使用 PHP 或 ASP.NET C# 来监听这些日志?我不知道我是否应该监听传入的数据包,或者向 HLDS 发送数据包请求。我尝试使用 监视我的 UDP 连接netstat -a,但似乎无法弄清楚这一点。

注意:我想使用 log_address 实现,因为我无法在服务器上安装任何第三方模块来协助记录过程。我也知道 HLSW,我不是在寻找这样的客户端应用程序。

谢谢你。

4

2 回答 2

0

你应该看看Steam HLDS Log Parser gem。

它在 Ruby 中并且像这样工作:

  • 在您的 hlds 上,使用ip 在哪里以及logaddress xxx.xxx.xxx.xxx yyyy您的端口将使用 UDP 发送日志xy
  • 获取 gem,并检查示例:它接收并解析日志,并显示内容。

当我说display时,实际上你可以用返回的内容做你想做的事情(推送到 irc,写入数据库......)。只需编写自己的“显示器”

我几天前发布了这个宝石,请随时尝试和贡献。我最近添加了对英语和法语翻译的 i18n 支持。

问候。

于 2013-07-30T11:02:32.513 回答
0

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.

于 2012-08-26T17:44:13.243 回答