Naydef
12-01-2017, 16:39
UDPCap extension
Version: 0.0.0.1
Description:
Allows plugin developers to catch UDP packets sent to the server with the ability of getting IP, port, length of data, data itself, etc. Also plugins can selectively prevent futher processing of the packets or vice versa. Please notice that the extension is currently only for the Windows OS, although it contains the required gamedata for Linux OSes.
Changelog:
Version 0.0.0.1
First release
Probability of bugs
Only for Windows OS currently
Sample plugin:
The plugin prints the ip address and the country of origin of all TSource Engine Queries
#include <sourcemod>
#include <udpcap>
#include <geoip>
#pragma newdecls required
public Plugin myinfo =
{
name = "UDPCap Example Plugin / Source Query Country Logger",
author = "Naydef",
description = "Example",
version = "0.1",
};
public Action UDPC_ProcessIncomingPacket(const char[] ip, int port, const char[] data, int length, netadrtype_t netaddrtype)
{
if(netaddrtype==NA_IP && length>5 && data[4]=='T')
{
char countryname[64];
if(GeoipCountry(ip, countryname, sizeof(countryname)))
{
PrintToServer("Query from IP %s:%i, located in %s", ip, port, countryname);
}
}
return Plugin_Continue;
}
Compatibility:
The extension is tested and confirmed working on these games/OSes:
TF2/Windows Vista
Credit:
Zephyrus (https://forums.alliedmods.net/member.php?u=79786) - Copypasted some code from Console Cleaner extension at first, but then removed it.
Source Code:
https://github.com/naydef/UDPCap-ext
Bugs/Improvements:
None
Note:
You can only capture UDP packets received by the server, not possible to capture those sent by the server(If requested, might add such functionality)
Gamedata taken from TF2 engine.dll, so gamedata might not work on other Source games
This the first public extension I released.
Feedback is very welcomed!
Files:
Version: 0.0.0.1
Description:
Allows plugin developers to catch UDP packets sent to the server with the ability of getting IP, port, length of data, data itself, etc. Also plugins can selectively prevent futher processing of the packets or vice versa. Please notice that the extension is currently only for the Windows OS, although it contains the required gamedata for Linux OSes.
Changelog:
Version 0.0.0.1
First release
Probability of bugs
Only for Windows OS currently
Sample plugin:
The plugin prints the ip address and the country of origin of all TSource Engine Queries
#include <sourcemod>
#include <udpcap>
#include <geoip>
#pragma newdecls required
public Plugin myinfo =
{
name = "UDPCap Example Plugin / Source Query Country Logger",
author = "Naydef",
description = "Example",
version = "0.1",
};
public Action UDPC_ProcessIncomingPacket(const char[] ip, int port, const char[] data, int length, netadrtype_t netaddrtype)
{
if(netaddrtype==NA_IP && length>5 && data[4]=='T')
{
char countryname[64];
if(GeoipCountry(ip, countryname, sizeof(countryname)))
{
PrintToServer("Query from IP %s:%i, located in %s", ip, port, countryname);
}
}
return Plugin_Continue;
}
Compatibility:
The extension is tested and confirmed working on these games/OSes:
TF2/Windows Vista
Credit:
Zephyrus (https://forums.alliedmods.net/member.php?u=79786) - Copypasted some code from Console Cleaner extension at first, but then removed it.
Source Code:
https://github.com/naydef/UDPCap-ext
Bugs/Improvements:
None
Note:
You can only capture UDP packets received by the server, not possible to capture those sent by the server(If requested, might add such functionality)
Gamedata taken from TF2 engine.dll, so gamedata might not work on other Source games
This the first public extension I released.
Feedback is very welcomed!
Files: