mirror of
https://github.com/nillerusr/source-engine.git
synced 2026-08-08 01:39:36 +00:00
1
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//=============================================================================//
|
||||
// stdafx.cpp : source file that includes just the standard includes
|
||||
// vmpi_ping.pch will be the pre-compiled header
|
||||
// stdafx.obj will contain the pre-compiled type information
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
// TODO: reference any additional headers you need in STDAFX.H
|
||||
// and not in this file
|
||||
@@ -0,0 +1,30 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//=============================================================================//
|
||||
// stdafx.h : include file for standard system include files,
|
||||
// or project specific include files that are used frequently, but
|
||||
// are changed infrequently
|
||||
//
|
||||
|
||||
#if !defined(AFX_STDAFX_H__04B9E767_FE9B_4F2A_84A3_D6B85737214E__INCLUDED_)
|
||||
#define AFX_STDAFX_H__04B9E767_FE9B_4F2A_84A3_D6B85737214E__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
|
||||
// TODO: reference additional headers your program requires here
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_STDAFX_H__04B9E767_FE9B_4F2A_84A3_D6B85737214E__INCLUDED_)
|
||||
@@ -0,0 +1,196 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//=============================================================================//
|
||||
// vmpi_ping.cpp : Defines the entry point for the console application.
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "iphelpers.h"
|
||||
#include "vmpi.h"
|
||||
#include "tier0/platform.h"
|
||||
#include "bitbuf.h"
|
||||
#include <conio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
const char* FindArg( int argc, char **argv, const char *pName, const char *pDefault = "" )
|
||||
{
|
||||
for ( int i=0; i < argc; i++ )
|
||||
{
|
||||
if ( stricmp( argv[i], pName ) == 0 )
|
||||
{
|
||||
if ( (i+1) < argc )
|
||||
return argv[i+1];
|
||||
else
|
||||
return pDefault;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
CUtlVector<CIPAddr> addrs;
|
||||
|
||||
printf( "\n" );
|
||||
printf( "vmpi_ping <option>\n" );
|
||||
printf( "option can be:\n" );
|
||||
printf( " -stop .. stop any VMPI services\n" );
|
||||
printf( " -kill .. kill any processes being run by VMPI\n" );
|
||||
printf( " -patch <timeout> .. stops VMPI services for <timeout> seconds\n" );
|
||||
printf( " -mpi_pw <password> .. only talk to services with the specified password\n" );
|
||||
printf( " -dns .. enable DNS lookups (slows the listing down)\n" );
|
||||
printf( " -ShowConsole .. show the console window\n" );
|
||||
printf( " -HideConsole .. hide the console window\n" );
|
||||
|
||||
//Scary to show these to users...
|
||||
//printf( " -ShowCache .. show the cache directory and its capacity\n" );
|
||||
//printf( " -FlushCache .. flush the cache of ALL VMPI services\n" );
|
||||
|
||||
printf( "\n" );
|
||||
|
||||
|
||||
ISocket *pSocket = CreateIPSocket();
|
||||
if ( !pSocket->BindToAny( 0 ) )
|
||||
{
|
||||
printf( "Error binding to a port!\n" );
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char *pPassword = FindArg( argc, argv, "-mpi_pw" );
|
||||
|
||||
|
||||
// Figure out which action they want to take.
|
||||
int timeout = 0;
|
||||
char cRequest = VMPI_PING_REQUEST;
|
||||
if ( FindArg( argc, argv, "-Stop" ) )
|
||||
{
|
||||
cRequest = VMPI_STOP_SERVICE;
|
||||
}
|
||||
else if ( FindArg( argc, argv, "-Kill" ) )
|
||||
{
|
||||
cRequest = VMPI_KILL_PROCESS;
|
||||
}
|
||||
/*
|
||||
else if ( FindArg( argc, argv, "-ShowConsole" ) )
|
||||
{
|
||||
cRequest = VMPI_SHOW_CONSOLE_WINDOW;
|
||||
}
|
||||
else if ( FindArg( argc, argv, "-HideConsole" ) )
|
||||
{
|
||||
cRequest = VMPI_HIDE_CONSOLE_WINDOW;
|
||||
}
|
||||
*/
|
||||
else if ( FindArg( argc, argv, "-ShowCache" ) )
|
||||
{
|
||||
cRequest = VMPI_GET_CACHE_INFO;
|
||||
}
|
||||
else if ( FindArg( argc, argv, "-FlushCache" ) )
|
||||
{
|
||||
cRequest = VMPI_FLUSH_CACHE;
|
||||
}
|
||||
else
|
||||
{
|
||||
const char *pTimeout = FindArg( argc, argv, "-patch", "60" );
|
||||
if ( pTimeout )
|
||||
{
|
||||
if ( isdigit( pTimeout[0] ) )
|
||||
{
|
||||
cRequest = VMPI_SERVICE_PATCH;
|
||||
timeout = atoi( pTimeout );
|
||||
printf( "Patching with timeout of %d seconds.\n", timeout );
|
||||
}
|
||||
else
|
||||
{
|
||||
printf( "-patch requires a timeout parameter.\n" );
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int nMachines = 0;
|
||||
printf( "Pinging VMPI Services... press a key to stop.\n\n" );
|
||||
while ( !kbhit() )
|
||||
{
|
||||
for ( int i=VMPI_SERVICE_PORT; i <= VMPI_LAST_SERVICE_PORT; i++ )
|
||||
{
|
||||
unsigned char data[256];
|
||||
bf_write buf( data, sizeof( data ) );
|
||||
buf.WriteByte( VMPI_PROTOCOL_VERSION );
|
||||
buf.WriteString( pPassword );
|
||||
buf.WriteByte( cRequest );
|
||||
|
||||
if ( cRequest == VMPI_SERVICE_PATCH )
|
||||
buf.WriteLong( timeout );
|
||||
|
||||
pSocket->Broadcast( data, buf.GetNumBytesWritten(), i );
|
||||
}
|
||||
|
||||
while ( 1 )
|
||||
{
|
||||
CIPAddr ipFrom;
|
||||
char in[256];
|
||||
int len = pSocket->RecvFrom( in, sizeof( in ), &ipFrom );
|
||||
if ( len == -1 )
|
||||
break;
|
||||
|
||||
if ( len >= 2 &&
|
||||
in[0] == VMPI_PROTOCOL_VERSION &&
|
||||
in[1] == VMPI_PING_RESPONSE &&
|
||||
addrs.Find( ipFrom ) == -1 )
|
||||
{
|
||||
char *pStateString = "(unknown)";
|
||||
if ( len >= 3 )
|
||||
{
|
||||
if ( in[2] )
|
||||
pStateString = "(running)";
|
||||
else
|
||||
pStateString = "(idle) ";
|
||||
}
|
||||
|
||||
++nMachines;
|
||||
char nameStr[256];
|
||||
|
||||
if ( FindArg( argc, argv, "-dns" ) && ConvertIPAddrToString( &ipFrom, nameStr, sizeof( nameStr ) ) )
|
||||
{
|
||||
printf( "%02d. %s - %s:%d (%d.%d.%d.%d)",
|
||||
nMachines, pStateString, nameStr, ipFrom.port,
|
||||
ipFrom.ip[0], ipFrom.ip[1], ipFrom.ip[2], ipFrom.ip[3] );
|
||||
}
|
||||
else
|
||||
{
|
||||
printf( "%02d. %s - %d.%d.%d.%d:%d",
|
||||
nMachines, pStateString, ipFrom.ip[0], ipFrom.ip[1], ipFrom.ip[2], ipFrom.ip[3], ipFrom.port );
|
||||
}
|
||||
|
||||
if ( cRequest == VMPI_GET_CACHE_INFO )
|
||||
{
|
||||
// Next var is a 64-bit int with the size of the cache.
|
||||
char *pCur = &in[3];
|
||||
__int64 cacheSize = *((__int64*)pCur);
|
||||
pCur += sizeof( __int64 );
|
||||
|
||||
char *pCacheDir = pCur;
|
||||
|
||||
__int64 nMegs = cacheSize / (1024*1024);
|
||||
printf( "\n\tCache dir: %s, size: %d megs", pCur, nMegs );
|
||||
}
|
||||
|
||||
printf( "\n" );
|
||||
|
||||
addrs.AddToTail( ipFrom );
|
||||
}
|
||||
}
|
||||
|
||||
Sleep( 1000 );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,249 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="vmpi_ping"
|
||||
ProjectGUID="{D6F83A58-89A2-4F57-9761-32208BD95E83}"
|
||||
SccProjectName=""
|
||||
SccAuxPath=""
|
||||
SccLocalPath=""
|
||||
SccProvider="">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory=".\Debug"
|
||||
IntermediateDirectory=".\Debug"
|
||||
ConfigurationType="1"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\..\common,..\..\..\common,..\..\..\public,..\..\..\public\tier1,.."
|
||||
PreprocessorDefinitions="_DEBUG;WIN32;_CONSOLE;PROTECTED_THINGS_DISABLE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="5"
|
||||
UsePrecompiledHeader="3"
|
||||
PrecompiledHeaderThrough="stdafx.h"
|
||||
PrecompiledHeaderFile=".\Debug/vmpi_ping.pch"
|
||||
AssemblerListingLocation=".\Debug/"
|
||||
ObjectFile=".\Debug/"
|
||||
ProgramDataBaseFileName=".\Debug/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"
|
||||
DebugInformationFormat="4"
|
||||
CompileAs="0"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
CommandLine="if exist ..\..\..\..\game\bin\vmpi_ping.exe attrib -r ..\..\..\..\game\bin\vmpi_ping.exe
|
||||
copy "$(TargetPath)" ..\..\..\..\game\bin
|
||||
"
|
||||
Outputs="..\..\..\..\game\bin\vmpi_ping.exe"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="ws2_32.lib odbc32.lib odbccp32.lib"
|
||||
OutputFile=".\Debug/vmpi_ping.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile=".\Debug/vmpi_ping.pdb"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TypeLibraryName=".\Debug/vmpi_ping.tlb"
|
||||
HeaderFileName=""/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="1033"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory=".\Release"
|
||||
IntermediateDirectory=".\Release"
|
||||
ConfigurationType="1"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
AdditionalIncludeDirectories="..\..\common,..\..\..\common,..\..\..\public,..\..\..\public\tier1,.."
|
||||
PreprocessorDefinitions="NDEBUG;WIN32;_CONSOLE;PROTECTED_THINGS_DISABLE"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="4"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
UsePrecompiledHeader="3"
|
||||
PrecompiledHeaderThrough="stdafx.h"
|
||||
PrecompiledHeaderFile=".\Release/vmpi_ping.pch"
|
||||
AssemblerListingLocation=".\Release/"
|
||||
ObjectFile=".\Release/"
|
||||
ProgramDataBaseFileName=".\Release/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"
|
||||
CompileAs="0"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
CommandLine="if exist ..\..\..\..\game\bin\vmpi_ping.exe attrib -r ..\..\..\..\game\bin\vmpi_ping.exe
|
||||
copy "$(TargetPath)" ..\..\..\..\game\bin
|
||||
"
|
||||
Outputs="..\..\..\..\game\bin\vmpi_ping.exe"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="ws2_32.lib odbc32.lib odbccp32.lib"
|
||||
OutputFile=".\Release/vmpi_ping.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
ProgramDatabaseFile=".\Release/vmpi_ping.pdb"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TypeLibraryName=".\Release/vmpi_ping.tlb"
|
||||
HeaderFileName=""/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="1033"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
|
||||
<File
|
||||
RelativePath="..\iphelpers.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\public\tier0\memoverride.cpp">
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
UsePrecompiledHeader="0"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
UsePrecompiledHeader="0"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="StdAfx.cpp">
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
UsePrecompiledHeader="1"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
UsePrecompiledHeader="1"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="vmpi_ping.cpp">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl">
|
||||
<File
|
||||
RelativePath="..\..\common\iphelpers.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="StdAfx.h">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
|
||||
</Filter>
|
||||
<File
|
||||
RelativePath="ReadMe.txt">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\lib\public\tier0.lib">
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
Description=""
|
||||
CommandLine=""/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
Description=""
|
||||
CommandLine=""/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\lib\public\tier1.lib">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\lib\public\vstdlib.lib">
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
Description=""
|
||||
CommandLine=""/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
Description=""
|
||||
CommandLine=""/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
Reference in New Issue
Block a user