Raised This Month: $ Target: $400
 0% 

TF2 logs throws


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 09-24-2013 , 18:04   TF2 logs throws
Reply With Quote #1

I try to create a C/C++ application that handle servers logs by throwing them to my application but I am not sure how to proceed, I've read several valve wiki page about it and I'm just getting confuse about the protocol. Can anyone show me a basic example how I can done this feature?

Further explanation and example: It a bit like HLSW giving you the output of what going on in the server.

Thank you, Nighty's.
Mathias. is offline
psychonic

BAFFLED
Join Date: May 2008
Old 09-24-2013 , 18:38   Re: TF2 logs throws
Reply With Quote #2

Quote:
Originally Posted by Black-Rabbit View Post
I try to create a C/C++ application that handle servers logs by throwing them to my application but I am not sure how to proceed, I've read several valve wiki page about it and I'm just getting confuse about the protocol. Can anyone show me a basic example how I can done this feature?

Further explanation and example: It a bit like HLSW giving you the output of what going on in the server.

Thank you, Nighty's.
There is not much of a protocol. It sends the log data raw through udp, with each packet having a single char prefix, 'R'.

Set log_address to the ip:port for the game server to send logs to and make sure that logging is enabled ("log 1" or "log on"), and it will start streaming the log to the address, just as you would see in the log file (again, with the prefix).

Additionally, for games that support the sv_logsecret cvar, if the cvar is set, the prefix will instead be a single char, 'S', followed by the secret.

ie.:
Code:
RL 01/04/2009 - 12:48:24: server_cvar: "mp_timelimit" "20"
RL 01/04/2009 - 12:49:30: "psychonic<2><STEAM_ID_PENDING><>" connected, address "192.168.5.115:27006"
RL 01/04/2009 - 12:49:31: "psychonic<2><STEAM_0:1:4153990><>" STEAM USERID validated
RL 01/04/2009 - 12:50:02: "psychonic<2><STEAM_0:1:4153990><>" entered the game
or with an sv_logsecret of "jabroni":
Code:
SjabroniL 01/04/2009 - 12:48:24: server_cvar: "mp_timelimit" "20"
SjabroniL 01/04/2009 - 12:49:30: "psychonic<2><STEAM_ID_PENDING><>" connected, address "192.168.5.115:27006"
SjabroniL 01/04/2009 - 12:49:31: "psychonic<2><STEAM_0:1:4153990><>" STEAM USERID validated
SjabroniL 01/04/2009 - 12:50:02: "psychonic<2><STEAM_0:1:4153990><>" entered the game

Last edited by psychonic; 09-24-2013 at 18:39.
psychonic is offline
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 09-24-2013 , 19:05   Re: TF2 logs throws
Reply With Quote #3

that exacly what Im looking for, so how do I create a simple C application handle the logs to a file for example.
Would be really apreciate.

EDIT: I will reformulate my request. How do I create a UDP socket listener to read the logs through network, after googling for hours and read many and different method I am stuck right now, do I have to use datagram or stream method and a simple code example would be really really appreciated. window socket if possible.

Thank you, Nighty's.

Last edited by Mathias.; 09-24-2013 at 23:43.
Mathias. is offline
Sillium
AlliedModders Donor
Join Date: Sep 2008
Location: Germany
Old 09-25-2013 , 01:48   Re: TF2 logs throws
Reply With Quote #4

Since you are trying UDP you should use SOCK_DGRAM:
http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx
__________________
brb, dishes have developed their own language and are talking to the garbage about overthrowing me... i must correct this

www.unterwasserpyromanen.de
Sillium is offline
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 09-25-2013 , 15:42   Re: TF2 logs throws
Reply With Quote #5

what am I doing wrong?

PHP Code:
#pragma once
#pragma comment(lib, "Ws2_32.lib")

#include <WinSock2.h>
#include <Windows.h>
#include <iostream>

using namespace std;

int main()
{
        
WSAData wsaData;
        
WORD DllVersion MAKEWORD(2,2);

        
int startup_RetVal WSAStartup(DllVersion, &wsaData);

        
SOCKET sSocket socket(AF_INETSOCK_DGRAMIPPROTO_UDP);

        
SOCKADDR_IN addr;

        
addr.sin_addr.s_addr inet_addr("127.0.0.1");
        
addr.sin_family AF_INET;
        
addr.sin_port htons(2222);

        
bind(sSocket, (SOCKADDR*)&addrsizeof(addr));

        
char buf[64] = {0};

        
recvfrom(sSocketbuf64NULLNULLNULL);

        
cout << buf << endl;

        
getchar();

        return 
0;

the application compile and run correctly but it does not receive any logs.

my server logaddress_list:

Code:
192.95.xxx.xxx:7130 (hlsw)
192.95.xxx.xxx:2222 (my application)
HLSW receive correctly the log but my application do not receive anything.
Mathias. is offline
Sillium
AlliedModders Donor
Join Date: Sep 2008
Location: Germany
Old 09-26-2013 , 01:00   Re: TF2 logs throws
Reply With Quote #6

I can't test this right now. But since you are not checking the return value of bind() you might not even get the socket created.

Here is a link to the code of a small UPD-receiver:
http://members.tripod.com/frenchwhal...kt/Lesson5.htm
__________________
brb, dishes have developed their own language and are talking to the garbage about overthrowing me... i must correct this

www.unterwasserpyromanen.de
Sillium is offline
psychonic

BAFFLED
Join Date: May 2008
Old 09-26-2013 , 07:58   Re: TF2 logs throws
Reply With Quote #7

You're listening on 127.0.0.1 but sending logs to 192.95.xxx.xxx

Listen on the IP that you're sending logs to, or the internal IP that corresponds to it if you're behind NAT.

Last edited by psychonic; 09-26-2013 at 07:59.
psychonic is offline
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 09-26-2013 , 09:31   Re: TF2 logs throws
Reply With Quote #8

127.0.0.1 isnt local and should grab my public ip automaticly? I will try it later and give you news, I'm leaving for the day and may be back later.

By the way thanks alot for the help guys, it really appreciated that I've receive reply and help from the community that fast.
Mathias. is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 09-26-2013 , 09:57   Re: TF2 logs throws
Reply With Quote #9

Quote:
Originally Posted by Black-Rabbit View Post
127.0.0.1 isnt local and should grab my public ip automaticly?
Networking isn't my strong suit, but my impression is that 127.0.0.1 (or localhost) will only receive traffic if you explicitly send it there. It's not the same as listening on all interfaces.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 09-26-2013 , 13:52   Re: TF2 logs throws
Reply With Quote #10

0.0.0.0 is generally all interfaces, 127.0.0.1 is loopback only.
__________________
asherkin is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 02:23.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode