[
  {
    "path": ".editorconfig",
    "content": "# http://editorconfig.org\n\nroot = true\n\n[*]\ncharset = utf-8\nindent_style = tab\ninsert_final_newline = true\ntrim_trailing_whitespace = true\n\n[*.yaml]\nindent_style = space\nindent_size = 2\n"
  },
  {
    "path": ".gitattributes",
    "content": "* text=auto\n"
  },
  {
    "path": ".github/dependabot.yml",
    "content": "version: 2\nupdates:\n  - package-ecosystem: \"github-actions\"\n    directory: \"/\"\n    schedule:\n      interval: \"weekly\"\n    ignore:\n      - dependency-name: \"*\"\n        update-types: [\"version-update:semver-minor\", \"version-update:semver-patch\"]\n"
  },
  {
    "path": ".github/workflows/ci.yml",
    "content": "name: CI\n\npermissions:\n  contents: read\n\non: [push]\n\njobs:\n  php:\n    runs-on: ubuntu-latest\n    strategy:\n      matrix:\n        php: ['8.3', '8.4', '8.5']\n\n    steps:\n    - name: Setup PHP\n      uses: shivammathur/setup-php@v2\n      with:\n        php-version: ${{ matrix.php }}\n\n    - name: Checkout\n      uses: actions/checkout@v6\n\n    - name: Install dependencies\n      run: composer install --no-interaction --no-progress\n\n    - name: Run tests\n      run: composer run phpunit\n\n    - name: Run phpstan\n      run: composer run phpstan\n"
  },
  {
    "path": ".gitignore",
    "content": "vendor/\nTests/.phpunit.cache/\n"
  },
  {
    "path": "CONTRIBUTING.md",
    "content": "* **This library is intended for software developers**, if you do not know how write code in PHP, please do not create issues.\n* Please do not create issues when you are unable to retrieve information from a server *(e.g. issues with UDP connectivity)*, unless you can prove that there is a bug within the library.\n"
  },
  {
    "path": "Examples/Example.php",
    "content": "<?php\ndeclare(strict_types=1);\n\nrequire __DIR__ . '/../vendor/autoload.php';\n\nuse xPaw\\SourceQuery\\SourceQuery;\n\n// For the sake of this example\nheader( 'Content-Type: text/plain' );\nheader( 'X-Content-Type-Options: nosniff' );\n\n// Edit this ->\ndefine( 'SQ_SERVER_ADDR', 'localhost' );\ndefine( 'SQ_SERVER_PORT', 27015 );\ndefine( 'SQ_TIMEOUT',     1 );\ndefine( 'SQ_ENGINE',      SourceQuery::SOURCE );\n// Edit this <-\n\n$Query = new SourceQuery( );\n\ntry\n{\n\t$Query->Connect( SQ_SERVER_ADDR, SQ_SERVER_PORT, SQ_TIMEOUT, SQ_ENGINE );\n\n\tprint_r( $Query->GetInfo( ) );\n\tprint_r( $Query->GetPlayers( ) );\n\tprint_r( $Query->GetRules( ) );\n}\ncatch( Exception $e )\n{\n\techo $e->getMessage( );\n}\nfinally\n{\n\t$Query->Disconnect( );\n}\n"
  },
  {
    "path": "Examples/RconExample.php",
    "content": "<?php\ndeclare(strict_types=1);\n\nrequire __DIR__ . '/../vendor/autoload.php';\n\nuse xPaw\\SourceQuery\\SourceQuery;\n\n// For the sake of this example\nheader( 'Content-Type: text/plain' );\nheader( 'X-Content-Type-Options: nosniff' );\n\n// Edit this ->\ndefine( 'SQ_SERVER_ADDR', 'localhost' );\ndefine( 'SQ_SERVER_PORT', 27015 );\ndefine( 'SQ_TIMEOUT',     1 );\ndefine( 'SQ_ENGINE',      SourceQuery::SOURCE );\n// Edit this <-\n\n$Query = new SourceQuery( );\n\ntry\n{\n\t$Query->Connect( SQ_SERVER_ADDR, SQ_SERVER_PORT, SQ_TIMEOUT, SQ_ENGINE );\n\n\t$Query->SetRconPassword( 'my_awesome_password' );\n\n\tvar_dump( $Query->Rcon( 'say hello' ) );\n}\ncatch( Exception $e )\n{\n\techo $e->getMessage( );\n}\nfinally\n{\n\t$Query->Disconnect( );\n}\n"
  },
  {
    "path": "Examples/View.php",
    "content": "<?php\n\tdeclare(strict_types=1);\n\n\trequire __DIR__ . '/../vendor/autoload.php';\n\n\tuse xPaw\\SourceQuery\\SourceQuery;\n\n\t// Edit this ->\n\tdefine( 'SQ_SERVER_ADDR', 'localhost' );\n\tdefine( 'SQ_SERVER_PORT', 27015 );\n\tdefine( 'SQ_TIMEOUT',     3 );\n\tdefine( 'SQ_ENGINE',      SourceQuery::SOURCE );\n\t// Edit this <-\n\n\t$Timer = microtime( true );\n\n\t$Query = new SourceQuery( );\n\n\t$Info    = null;\n\t$Rules   = [];\n\t$Players = [];\n\t$Exception = null;\n\n\ttry\n\t{\n\t\t$Query->Connect( SQ_SERVER_ADDR, SQ_SERVER_PORT, SQ_TIMEOUT, SQ_ENGINE );\n\t\t//$Query->SetUseOldGetChallengeMethod( true ); // Use this when players/rules retrieval fails on games like Starbound\n\n\t\t$Info    = $Query->GetInfo( );\n\t\t$Players = $Query->GetPlayers( );\n\t\t$Rules   = $Query->GetRules( );\n\t}\n\tcatch( Exception $e )\n\t{\n\t\t$Exception = $e;\n\t}\n\tfinally\n\t{\n\t\t$Query->Disconnect( );\n\t}\n\n\t$Timer = number_format( microtime( true ) - $Timer, 4, '.', '' );\n?>\n<!DOCTYPE html>\n<html>\n<head>\n\t<meta charset=\"utf-8\">\n\t<title>Source Query PHP Library</title>\n\n\t<link rel=\"stylesheet\" href=\"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css\">\n\t<style type=\"text/css\">\n\t\t.table {\n\t\t\ttable-layout: fixed;\n\t\t\tborder-top-color: #428BCA;\n\t\t}\n\n\t\t.table td {\n\t\t\toverflow-x: auto;\n\t\t}\n\n\t\t.table thead th {\n\t\t\tbackground-color: #428BCA;\n\t\t\tborder-color: #428BCA !important;\n\t\t\tcolor: #FFF;\n\t\t}\n\n\t\t.info-column {\n\t\t\twidth: 120px;\n\t\t}\n\n\t\t.frags-column {\n\t\t\twidth: 80px;\n\t\t}\n\t</style>\n</head>\n\n<body>\n\t<div class=\"jumbotron\">\n\t\t<div class=\"container\">\n\t\t\t<h1>Source Query PHP Library</h1>\n\n\t\t\t<p class=\"lead\">This library was created to query game server which use the Source (Steamworks) query protocol.</p>\n\n\t\t\t<p>\n\t\t\t\t<a class=\"btn btn-large btn-primary\" href=\"https://xpaw.me\">Made by xPaw</a>\n\t\t\t\t<a class=\"btn btn-large btn-primary\" href=\"https://github.com/xPaw/PHP-Source-Query\">View on GitHub</a>\n\t\t\t\t<a class=\"btn btn-large btn-danger\" href=\"https://github.com/xPaw/PHP-Source-Query/blob/master/LICENSE\">LGPL v2.1</a>\n\t\t\t</p>\n\t\t</div>\n\t</div>\n\n\t<div class=\"container\">\n<?php if( $Exception !== null ): ?>\n\t\t<div class=\"panel panel-error\">\n\t\t\t<pre class=\"panel-body\"><?php echo htmlspecialchars( $Exception->__toString( ) ); ?></pre>\n\t\t</div>\n<?php endif; ?>\n\t\t<div class=\"row\">\n\t\t\t<div class=\"col-sm-6\">\n\t\t\t\t<table class=\"table table-bordered table-striped\">\n\t\t\t\t\t<thead>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<th class=\"info-column\">Server Info</th>\n\t\t\t\t\t\t\t<th><span class=\"label label-<?php echo $Timer > 1.0 ? 'danger' : 'success'; ?>\"><?php echo $Timer; ?>s</span></th>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</thead>\n\t\t\t\t\t<tbody>\n<?php if( $Info !== null ): ?>\n<?php foreach( $Info as $InfoKey => $InfoValue ): ?>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td><?php echo htmlspecialchars( $InfoKey ); ?></td>\n\t\t\t\t\t\t\t<td><?php\n\tif( is_array( $InfoValue ) )\n\t{\n\t\techo \"<pre>\";\n\t\tprint_r( $InfoValue );\n\t\techo \"</pre>\";\n\t}\n\telse\n\t{\n\t\tif( $InfoValue === true )\n\t\t{\n\t\t\techo 'true';\n\t\t}\n\t\telse if( $InfoValue === false )\n\t\t{\n\t\t\techo 'false';\n\t\t}\n\t\telse\n\t\t{\n\t\t\techo htmlspecialchars( (string)$InfoValue );\n\t\t}\n\t}\n?></td>\n\t\t\t\t\t\t</tr>\n<?php endforeach; ?>\n<?php else: ?>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td colspan=\"2\">No information received</td>\n\t\t\t\t\t\t</tr>\n<?php endif; ?>\n\t\t\t\t\t</tbody>\n\t\t\t\t</table>\n\t\t\t</div>\n\t\t\t<div class=\"col-sm-6\">\n\t\t\t\t<table class=\"table table-bordered table-striped\">\n\t\t\t\t\t<thead>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<th>Player <span class=\"label label-info\"><?php echo count( $Players ); ?></span></th>\n\t\t\t\t\t\t\t<th class=\"frags-column\">Frags</th>\n\t\t\t\t\t\t\t<th class=\"frags-column\">Time</th>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</thead>\n\t\t\t\t\t<tbody>\n<?php if( count( $Players ) > 0 ): ?>\n<?php foreach( $Players as $Player ): ?>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td><?php echo htmlspecialchars( $Player[ 'Name' ] ); ?></td>\n\t\t\t\t\t\t\t<td><?php echo $Player[ 'Frags' ]; ?></td>\n\t\t\t\t\t\t\t<td><?php echo $Player[ 'TimeF' ]; ?></td>\n\t\t\t\t\t\t</tr>\n<?php endforeach; ?>\n<?php else: ?>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td colspan=\"3\">No players received</td>\n\t\t\t\t\t\t</tr>\n<?php endif; ?>\n\t\t\t\t\t</tbody>\n\t\t\t\t</table>\n\t\t\t</div>\n\t\t</div>\n\t\t<div class=\"row\">\n\t\t\t<div class=\"col-sm-12\">\n\t\t\t\t<table class=\"table table-bordered table-striped\">\n\t\t\t\t\t<thead>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<th colspan=\"2\">Rules <span class=\"label label-info\"><?php echo count( $Rules ); ?></span></th>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</thead>\n\t\t\t\t\t<tbody>\n<?php if( count( $Rules ) > 0 ): ?>\n<?php foreach( $Rules as $Rule => $Value ): ?>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td><?php echo htmlspecialchars( $Rule ); ?></td>\n\t\t\t\t\t\t\t<td><?php echo htmlspecialchars( $Value ); ?></td>\n\t\t\t\t\t\t</tr>\n<?php endforeach; ?>\n<?php else: ?>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td colspan=\"2\">No rules received</td>\n\t\t\t\t\t\t</tr>\n<?php endif; ?>\n\t\t\t\t\t</tbody>\n\t\t\t\t</table>\n\t\t\t</div>\n\t\t</div>\n\t</div>\n</body>\n</html>\n"
  },
  {
    "path": "LICENSE",
    "content": "GNU LESSER GENERAL PUBLIC LICENSE\n                       Version 2.1, February 1999\n\n Copyright (C) 1991, 1999 Free Software Foundation, Inc.\n 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n(This is the first released version of the Lesser GPL.  It also counts\n as the successor of the GNU Library Public License, version 2, hence\n the version number 2.1.)\n\n                            Preamble\n\n  The licenses for most software are designed to take away your\nfreedom to share and change it.  By contrast, the GNU General Public\nLicenses are intended to guarantee your freedom to share and change\nfree software--to make sure the software is free for all its users.\n\n  This license, the Lesser General Public License, applies to some\nspecially designated software packages--typically libraries--of the\nFree Software Foundation and other authors who decide to use it.  You\ncan use it too, but we suggest you first think carefully about whether\nthis license or the ordinary General Public License is the better\nstrategy to use in any particular case, based on the explanations below.\n\n  When we speak of free software, we are referring to freedom of use,\nnot price.  Our General Public Licenses are designed to make sure that\nyou have the freedom to distribute copies of free software (and charge\nfor this service if you wish); that you receive source code or can get\nit if you want it; that you can change the software and use pieces of\nit in new free programs; and that you are informed that you can do\nthese things.\n\n  To protect your rights, we need to make restrictions that forbid\ndistributors to deny you these rights or to ask you to surrender these\nrights.  These restrictions translate to certain responsibilities for\nyou if you distribute copies of the library or if you modify it.\n\n  For example, if you distribute copies of the library, whether gratis\nor for a fee, you must give the recipients all the rights that we gave\nyou.  You must make sure that they, too, receive or can get the source\ncode.  If you link other code with the library, you must provide\ncomplete object files to the recipients, so that they can relink them\nwith the library after making changes to the library and recompiling\nit.  And you must show them these terms so they know their rights.\n\n  We protect your rights with a two-step method: (1) we copyright the\nlibrary, and (2) we offer you this license, which gives you legal\npermission to copy, distribute and/or modify the library.\n\n  To protect each distributor, we want to make it very clear that\nthere is no warranty for the free library.  Also, if the library is\nmodified by someone else and passed on, the recipients should know\nthat what they have is not the original version, so that the original\nauthor's reputation will not be affected by problems that might be\nintroduced by others.\n\n  Finally, software patents pose a constant threat to the existence of\nany free program.  We wish to make sure that a company cannot\neffectively restrict the users of a free program by obtaining a\nrestrictive license from a patent holder.  Therefore, we insist that\nany patent license obtained for a version of the library must be\nconsistent with the full freedom of use specified in this license.\n\n  Most GNU software, including some libraries, is covered by the\nordinary GNU General Public License.  This license, the GNU Lesser\nGeneral Public License, applies to certain designated libraries, and\nis quite different from the ordinary General Public License.  We use\nthis license for certain libraries in order to permit linking those\nlibraries into non-free programs.\n\n  When a program is linked with a library, whether statically or using\na shared library, the combination of the two is legally speaking a\ncombined work, a derivative of the original library.  The ordinary\nGeneral Public License therefore permits such linking only if the\nentire combination fits its criteria of freedom.  The Lesser General\nPublic License permits more lax criteria for linking other code with\nthe library.\n\n  We call this license the \"Lesser\" General Public License because it\ndoes Less to protect the user's freedom than the ordinary General\nPublic License.  It also provides other free software developers Less\nof an advantage over competing non-free programs.  These disadvantages\nare the reason we use the ordinary General Public License for many\nlibraries.  However, the Lesser license provides advantages in certain\nspecial circumstances.\n\n  For example, on rare occasions, there may be a special need to\nencourage the widest possible use of a certain library, so that it becomes\na de-facto standard.  To achieve this, non-free programs must be\nallowed to use the library.  A more frequent case is that a free\nlibrary does the same job as widely used non-free libraries.  In this\ncase, there is little to gain by limiting the free library to free\nsoftware only, so we use the Lesser General Public License.\n\n  In other cases, permission to use a particular library in non-free\nprograms enables a greater number of people to use a large body of\nfree software.  For example, permission to use the GNU C Library in\nnon-free programs enables many more people to use the whole GNU\noperating system, as well as its variant, the GNU/Linux operating\nsystem.\n\n  Although the Lesser General Public License is Less protective of the\nusers' freedom, it does ensure that the user of a program that is\nlinked with the Library has the freedom and the wherewithal to run\nthat program using a modified version of the Library.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.  Pay close attention to the difference between a\n\"work based on the library\" and a \"work that uses the library\".  The\nformer contains code derived from the library, whereas the latter must\nbe combined with the library in order to run.\n\n                  GNU LESSER GENERAL PUBLIC LICENSE\n   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION\n\n  0. This License Agreement applies to any software library or other\nprogram which contains a notice placed by the copyright holder or\nother authorized party saying it may be distributed under the terms of\nthis Lesser General Public License (also called \"this License\").\nEach licensee is addressed as \"you\".\n\n  A \"library\" means a collection of software functions and/or data\nprepared so as to be conveniently linked with application programs\n(which use some of those functions and data) to form executables.\n\n  The \"Library\", below, refers to any such software library or work\nwhich has been distributed under these terms.  A \"work based on the\nLibrary\" means either the Library or any derivative work under\ncopyright law: that is to say, a work containing the Library or a\nportion of it, either verbatim or with modifications and/or translated\nstraightforwardly into another language.  (Hereinafter, translation is\nincluded without limitation in the term \"modification\".)\n\n  \"Source code\" for a work means the preferred form of the work for\nmaking modifications to it.  For a library, complete source code means\nall the source code for all modules it contains, plus any associated\ninterface definition files, plus the scripts used to control compilation\nand installation of the library.\n\n  Activities other than copying, distribution and modification are not\ncovered by this License; they are outside its scope.  The act of\nrunning a program using the Library is not restricted, and output from\nsuch a program is covered only if its contents constitute a work based\non the Library (independent of the use of the Library in a tool for\nwriting it).  Whether that is true depends on what the Library does\nand what the program that uses the Library does.\n\n  1. You may copy and distribute verbatim copies of the Library's\ncomplete source code as you receive it, in any medium, provided that\nyou conspicuously and appropriately publish on each copy an\nappropriate copyright notice and disclaimer of warranty; keep intact\nall the notices that refer to this License and to the absence of any\nwarranty; and distribute a copy of this License along with the\nLibrary.\n\n  You may charge a fee for the physical act of transferring a copy,\nand you may at your option offer warranty protection in exchange for a\nfee.\n\n  2. You may modify your copy or copies of the Library or any portion\nof it, thus forming a work based on the Library, and copy and\ndistribute such modifications or work under the terms of Section 1\nabove, provided that you also meet all of these conditions:\n\n    a) The modified work must itself be a software library.\n\n    b) You must cause the files modified to carry prominent notices\n    stating that you changed the files and the date of any change.\n\n    c) You must cause the whole of the work to be licensed at no\n    charge to all third parties under the terms of this License.\n\n    d) If a facility in the modified Library refers to a function or a\n    table of data to be supplied by an application program that uses\n    the facility, other than as an argument passed when the facility\n    is invoked, then you must make a good faith effort to ensure that,\n    in the event an application does not supply such function or\n    table, the facility still operates, and performs whatever part of\n    its purpose remains meaningful.\n\n    (For example, a function in a library to compute square roots has\n    a purpose that is entirely well-defined independent of the\n    application.  Therefore, Subsection 2d requires that any\n    application-supplied function or table used by this function must\n    be optional: if the application does not supply it, the square\n    root function must still compute square roots.)\n\nThese requirements apply to the modified work as a whole.  If\nidentifiable sections of that work are not derived from the Library,\nand can be reasonably considered independent and separate works in\nthemselves, then this License, and its terms, do not apply to those\nsections when you distribute them as separate works.  But when you\ndistribute the same sections as part of a whole which is a work based\non the Library, the distribution of the whole must be on the terms of\nthis License, whose permissions for other licensees extend to the\nentire whole, and thus to each and every part regardless of who wrote\nit.\n\nThus, it is not the intent of this section to claim rights or contest\nyour rights to work written entirely by you; rather, the intent is to\nexercise the right to control the distribution of derivative or\ncollective works based on the Library.\n\nIn addition, mere aggregation of another work not based on the Library\nwith the Library (or with a work based on the Library) on a volume of\na storage or distribution medium does not bring the other work under\nthe scope of this License.\n\n  3. You may opt to apply the terms of the ordinary GNU General Public\nLicense instead of this License to a given copy of the Library.  To do\nthis, you must alter all the notices that refer to this License, so\nthat they refer to the ordinary GNU General Public License, version 2,\ninstead of to this License.  (If a newer version than version 2 of the\nordinary GNU General Public License has appeared, then you can specify\nthat version instead if you wish.)  Do not make any other change in\nthese notices.\n\n  Once this change is made in a given copy, it is irreversible for\nthat copy, so the ordinary GNU General Public License applies to all\nsubsequent copies and derivative works made from that copy.\n\n  This option is useful when you wish to copy part of the code of\nthe Library into a program that is not a library.\n\n  4. You may copy and distribute the Library (or a portion or\nderivative of it, under Section 2) in object code or executable form\nunder the terms of Sections 1 and 2 above provided that you accompany\nit with the complete corresponding machine-readable source code, which\nmust be distributed under the terms of Sections 1 and 2 above on a\nmedium customarily used for software interchange.\n\n  If distribution of object code is made by offering access to copy\nfrom a designated place, then offering equivalent access to copy the\nsource code from the same place satisfies the requirement to\ndistribute the source code, even though third parties are not\ncompelled to copy the source along with the object code.\n\n  5. A program that contains no derivative of any portion of the\nLibrary, but is designed to work with the Library by being compiled or\nlinked with it, is called a \"work that uses the Library\".  Such a\nwork, in isolation, is not a derivative work of the Library, and\ntherefore falls outside the scope of this License.\n\n  However, linking a \"work that uses the Library\" with the Library\ncreates an executable that is a derivative of the Library (because it\ncontains portions of the Library), rather than a \"work that uses the\nlibrary\".  The executable is therefore covered by this License.\nSection 6 states terms for distribution of such executables.\n\n  When a \"work that uses the Library\" uses material from a header file\nthat is part of the Library, the object code for the work may be a\nderivative work of the Library even though the source code is not.\nWhether this is true is especially significant if the work can be\nlinked without the Library, or if the work is itself a library.  The\nthreshold for this to be true is not precisely defined by law.\n\n  If such an object file uses only numerical parameters, data\nstructure layouts and accessors, and small macros and small inline\nfunctions (ten lines or less in length), then the use of the object\nfile is unrestricted, regardless of whether it is legally a derivative\nwork.  (Executables containing this object code plus portions of the\nLibrary will still fall under Section 6.)\n\n  Otherwise, if the work is a derivative of the Library, you may\ndistribute the object code for the work under the terms of Section 6.\nAny executables containing that work also fall under Section 6,\nwhether or not they are linked directly with the Library itself.\n\n  6. As an exception to the Sections above, you may also combine or\nlink a \"work that uses the Library\" with the Library to produce a\nwork containing portions of the Library, and distribute that work\nunder terms of your choice, provided that the terms permit\nmodification of the work for the customer's own use and reverse\nengineering for debugging such modifications.\n\n  You must give prominent notice with each copy of the work that the\nLibrary is used in it and that the Library and its use are covered by\nthis License.  You must supply a copy of this License.  If the work\nduring execution displays copyright notices, you must include the\ncopyright notice for the Library among them, as well as a reference\ndirecting the user to the copy of this License.  Also, you must do one\nof these things:\n\n    a) Accompany the work with the complete corresponding\n    machine-readable source code for the Library including whatever\n    changes were used in the work (which must be distributed under\n    Sections 1 and 2 above); and, if the work is an executable linked\n    with the Library, with the complete machine-readable \"work that\n    uses the Library\", as object code and/or source code, so that the\n    user can modify the Library and then relink to produce a modified\n    executable containing the modified Library.  (It is understood\n    that the user who changes the contents of definitions files in the\n    Library will not necessarily be able to recompile the application\n    to use the modified definitions.)\n\n    b) Use a suitable shared library mechanism for linking with the\n    Library.  A suitable mechanism is one that (1) uses at run time a\n    copy of the library already present on the user's computer system,\n    rather than copying library functions into the executable, and (2)\n    will operate properly with a modified version of the library, if\n    the user installs one, as long as the modified version is\n    interface-compatible with the version that the work was made with.\n\n    c) Accompany the work with a written offer, valid for at\n    least three years, to give the same user the materials\n    specified in Subsection 6a, above, for a charge no more\n    than the cost of performing this distribution.\n\n    d) If distribution of the work is made by offering access to copy\n    from a designated place, offer equivalent access to copy the above\n    specified materials from the same place.\n\n    e) Verify that the user has already received a copy of these\n    materials or that you have already sent this user a copy.\n\n  For an executable, the required form of the \"work that uses the\nLibrary\" must include any data and utility programs needed for\nreproducing the executable from it.  However, as a special exception,\nthe materials to be distributed need not include anything that is\nnormally distributed (in either source or binary form) with the major\ncomponents (compiler, kernel, and so on) of the operating system on\nwhich the executable runs, unless that component itself accompanies\nthe executable.\n\n  It may happen that this requirement contradicts the license\nrestrictions of other proprietary libraries that do not normally\naccompany the operating system.  Such a contradiction means you cannot\nuse both them and the Library together in an executable that you\ndistribute.\n\n  7. You may place library facilities that are a work based on the\nLibrary side-by-side in a single library together with other library\nfacilities not covered by this License, and distribute such a combined\nlibrary, provided that the separate distribution of the work based on\nthe Library and of the other library facilities is otherwise\npermitted, and provided that you do these two things:\n\n    a) Accompany the combined library with a copy of the same work\n    based on the Library, uncombined with any other library\n    facilities.  This must be distributed under the terms of the\n    Sections above.\n\n    b) Give prominent notice with the combined library of the fact\n    that part of it is a work based on the Library, and explaining\n    where to find the accompanying uncombined form of the same work.\n\n  8. You may not copy, modify, sublicense, link with, or distribute\nthe Library except as expressly provided under this License.  Any\nattempt otherwise to copy, modify, sublicense, link with, or\ndistribute the Library is void, and will automatically terminate your\nrights under this License.  However, parties who have received copies,\nor rights, from you under this License will not have their licenses\nterminated so long as such parties remain in full compliance.\n\n  9. You are not required to accept this License, since you have not\nsigned it.  However, nothing else grants you permission to modify or\ndistribute the Library or its derivative works.  These actions are\nprohibited by law if you do not accept this License.  Therefore, by\nmodifying or distributing the Library (or any work based on the\nLibrary), you indicate your acceptance of this License to do so, and\nall its terms and conditions for copying, distributing or modifying\nthe Library or works based on it.\n\n  10. Each time you redistribute the Library (or any work based on the\nLibrary), the recipient automatically receives a license from the\noriginal licensor to copy, distribute, link with or modify the Library\nsubject to these terms and conditions.  You may not impose any further\nrestrictions on the recipients' exercise of the rights granted herein.\nYou are not responsible for enforcing compliance by third parties with\nthis License.\n\n  11. If, as a consequence of a court judgment or allegation of patent\ninfringement or for any other reason (not limited to patent issues),\nconditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot\ndistribute so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you\nmay not distribute the Library at all.  For example, if a patent\nlicense would not permit royalty-free redistribution of the Library by\nall those who receive copies directly or indirectly through you, then\nthe only way you could satisfy both it and this License would be to\nrefrain entirely from distribution of the Library.\n\nIf any portion of this section is held invalid or unenforceable under any\nparticular circumstance, the balance of the section is intended to apply,\nand the section as a whole is intended to apply in other circumstances.\n\nIt is not the purpose of this section to induce you to infringe any\npatents or other property right claims or to contest validity of any\nsuch claims; this section has the sole purpose of protecting the\nintegrity of the free software distribution system which is\nimplemented by public license practices.  Many people have made\ngenerous contributions to the wide range of software distributed\nthrough that system in reliance on consistent application of that\nsystem; it is up to the author/donor to decide if he or she is willing\nto distribute software through any other system and a licensee cannot\nimpose that choice.\n\nThis section is intended to make thoroughly clear what is believed to\nbe a consequence of the rest of this License.\n\n  12. If the distribution and/or use of the Library is restricted in\ncertain countries either by patents or by copyrighted interfaces, the\noriginal copyright holder who places the Library under this License may add\nan explicit geographical distribution limitation excluding those countries,\nso that distribution is permitted only in or among countries not thus\nexcluded.  In such case, this License incorporates the limitation as if\nwritten in the body of this License.\n\n  13. The Free Software Foundation may publish revised and/or new\nversions of the Lesser General Public License from time to time.\nSuch new versions will be similar in spirit to the present version,\nbut may differ in detail to address new problems or concerns.\n\nEach version is given a distinguishing version number.  If the Library\nspecifies a version number of this License which applies to it and\n\"any later version\", you have the option of following the terms and\nconditions either of that version or of any later version published by\nthe Free Software Foundation.  If the Library does not specify a\nlicense version number, you may choose any version ever published by\nthe Free Software Foundation.\n\n  14. If you wish to incorporate parts of the Library into other free\nprograms whose distribution conditions are incompatible with these,\nwrite to the author to ask for permission.  For software which is\ncopyrighted by the Free Software Foundation, write to the Free\nSoftware Foundation; we sometimes make exceptions for this.  Our\ndecision will be guided by the two goals of preserving the free status\nof all derivatives of our free software and of promoting the sharing\nand reuse of software generally.\n\n                            NO WARRANTY\n\n  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO\nWARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.\nEXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR\nOTHER PARTIES PROVIDE THE LIBRARY \"AS IS\" WITHOUT WARRANTY OF ANY\nKIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE\nLIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME\nTHE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN\nWRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY\nAND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU\nFOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR\nCONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE\nLIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING\nRENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A\nFAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF\nSUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\nDAMAGES.\n\n                     END OF TERMS AND CONDITIONS\n\n           How to Apply These Terms to Your New Libraries\n\n  If you develop a new library, and you want it to be of the greatest\npossible use to the public, we recommend making it free software that\neveryone can redistribute and change.  You can do so by permitting\nredistribution under these terms (or, alternatively, under the terms of the\nordinary General Public License).\n\n  To apply these terms, attach the following notices to the library.  It is\nsafest to attach them to the start of each source file to most effectively\nconvey the exclusion of warranty; and each file should have at least the\n\"copyright\" line and a pointer to where the full notice is found.\n\n    {description}\n    Copyright (C) {year} {fullname}\n\n    This library is free software; you can redistribute it and/or\n    modify it under the terms of the GNU Lesser General Public\n    License as published by the Free Software Foundation; either\n    version 2.1 of the License, or (at your option) any later version.\n\n    This library is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n    Lesser General Public License for more details.\n\n    You should have received a copy of the GNU Lesser General Public\n    License along with this library; if not, write to the Free Software\n    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301\n    USA\n\nAlso add information on how to contact you by electronic and paper mail.\n\nYou should also get your employer (if you work as a programmer) or your\nschool, if any, to sign a \"copyright disclaimer\" for the library, if\nnecessary.  Here is a sample; alter the names:\n\n  Yoyodyne, Inc., hereby disclaims all copyright interest in the\n  library `Frob' (a library for tweaking knobs) written by James Random\n  Hacker.\n\n  {signature of Ty Coon}, 1 April 1990\n  Ty Coon, President of Vice\n\nThat's all there is to it!\n"
  },
  {
    "path": "README.md",
    "content": "# PHP Source Query\n\n[![Packagist Downloads](https://img.shields.io/packagist/dt/xpaw/php-source-query-class.svg)](https://packagist.org/packages/xpaw/php-source-query-class)\n[![Packagist Version](https://img.shields.io/packagist/v/xpaw/php-source-query-class.svg)](https://packagist.org/packages/xpaw/php-source-query-class)\n\nThis class was created to query game server which use the Source query protocol, this includes all source games, and all the games that implement Steamworks.\n\nThe class also allows you to query servers using RCON although this only works for half-life 1 and source engine games.\n\n[Minecraft](http://www.minecraft.net) also uses Source RCON protocol, and this means you can use this class to send commands to your minecraft server while having engine set to Source engine.\n\n**:warning: Do not send me emails if this does not work for you, I will not help you.**\n\n## Requirements\n* [Modern PHP version](https://php.net/supported-versions.php)\n* 64-bit PHP or [gmp module](https://secure.php.net/manual/en/book.gmp.php)\n* Your server must allow UDP connections\n\n## Protocol Specifications\n* https://developer.valvesoftware.com/wiki/Server_queries\n* https://developer.valvesoftware.com/wiki/Source_RCON_Protocol\n\n## Supported Games\nAppID | Game | Query | RCON | Notes\n----- | ---- | :---: | :--: | ----\n~ | All HL1/HL2 games and mods | :white_check_mark: | :white_check_mark: | \n10 | [Counter-Strike 1.6](http://store.steampowered.com/app/10/) | :white_check_mark: | :white_check_mark: | \n440 | [Team Fortress 2](http://store.steampowered.com/app/440/) | :white_check_mark: | :white_check_mark: | \n550 | [Left 4 Dead 2](http://store.steampowered.com/app/550/) | :white_check_mark: | :white_check_mark: | \n730 | [Counter-Strike 2](http://store.steampowered.com/app/730/) | :white_check_mark: | :white_check_mark: | `host_name_store 1; host_info_show 2; host_players_show 2`\n1002 | [Rag Doll Kung Fu](http://store.steampowered.com/app/1002/) | :white_check_mark: | :white_check_mark: | \n2400 | [The Ship](http://store.steampowered.com/app/2400/) | :white_check_mark: | :white_check_mark: | \n4000 | [Garry's Mod](http://store.steampowered.com/app/4000/) | :white_check_mark: | :white_check_mark: | \n17710 | [Nuclear Dawn](http://store.steampowered.com/app/17710/) | :white_check_mark: | :white_check_mark: | \n70000 | [Dino D-Day](http://store.steampowered.com/app/70000/) | :white_check_mark: | :white_check_mark: | \n107410 | [Arma 3](http://store.steampowered.com/app/107410/) | :white_check_mark: | :x: | Add +1 to the server port\n115300 | [Call of Duty: Modern Warfare 3](http://store.steampowered.com/app/115300/) | :white_check_mark: | :white_check_mark: | \n162107 | [DeadPoly](https://store.steampowered.com/app/1621070/) | :white_check_mark: | :x: |\n211820 | [Starbound](http://store.steampowered.com/app/211820/) | :white_check_mark: | :white_check_mark: | Call `SetUseOldGetChallengeMethod` method after connecting\n244850 | [Space Engineers](http://store.steampowered.com/app/244850/) | :white_check_mark: | :x: | Add +1 to the server port\n304930 | [Unturned](https://store.steampowered.com/app/304930/) | :white_check_mark: | :x: | Add +1 to the server port\n251570 | [7 Days to Die](http://store.steampowered.com/app/251570) | :white_check_mark: | :x: |\n252490 | [Rust](http://store.steampowered.com/app/252490/) | :white_check_mark: | :x: |\n282440 | [Quake Live](http://store.steampowered.com/app/282440) | :white_check_mark: | :x: | Quake Live uses the ZMQ messaging queue protocol for rcon control.\n346110 | [ARK: Survival Evolved](http://store.steampowered.com/app/346110/) | :white_check_mark: | :white_check_mark: | \n~ | [Minecraft](http://www.minecraft.net/) | :x: | :white_check_mark: | \n108600 | [Project: Zomboid](https://store.steampowered.com/app/108600/) | :white_check_mark: | :white_check_mark: \n1874880 | [Arma Reforger](https://store.steampowered.com/app/1874880/) | :white_check_mark: | :white_check_mark: \n\nOpen a pull request if you know another game which supports Source Query and/or RCON protocols.\n\n## How to tell if the game supports Source Query Protocol?\n\nAdd your server to your favourites in Steam server browser, and if Steam can display information about your server, then the protocol is supported.\n\n## Functions\n<table>\n\t<tr>\n\t\t<td>Connect( $Ip, $Port, $Timeout, $Engine )</td>\n\t\t<td>Opens connection to a server</td>\n\t</tr>\n\t<tr>\n\t\t<td>Disconnect( )</td>\n\t\t<td>Closes all open connections</td>\n\t</tr>\n\t<tr>\n\t\t<td>Ping( )</td>\n\t\t<td>Ping the server to see if it exists<br><b>Warning:</b> Source engine may not answer to this</td>\n\t</tr>\n\t<tr>\n\t\t<td>GetInfo( )</td>\n\t\t<td>Returns server info in an array</td>\n\t</tr>\n\t<tr>\n\t\t<td>GetPlayers( )</td>\n\t\t<td>Returns players on the server in an array</td>\n\t</tr>\n\t<tr>\n\t\t<td>GetRules( )</td>\n\t\t<td>Returns public rules <i>(cvars)</i> in an array</td>\n\t</tr>\n\t<tr>\n\t\t<td>SetRconPassword( $Password )</td>\n\t\t<td>Sets rcon password for later use with <i>Rcon()</i></td>\n\t</tr>\n\t<tr>\n\t\t<td>Rcon( $Command )</td>\n\t\t<td>Execute rcon command on the server</td>\n\t</tr>\n</table>\n\nAlso refer to [examples folder](Examples/) to work things out.\n\n## License\n    PHP Source Query\n    Copyright (C) 2012-2025 Pavel Djundik\n\n    This library is free software; you can redistribute it and/or\n    modify it under the terms of the GNU Lesser General Public\n    License as published by the Free Software Foundation; either\n    version 2.1 of the License, or (at your option) any later version.\n\n    This library is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n    Lesser General Public License for more details.\n\n    You should have received a copy of the GNU Lesser General Public\n    License along with this library; if not, write to the Free Software\n    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA\n"
  },
  {
    "path": "SourceQuery/BaseRcon.php",
    "content": "<?php\ndeclare(strict_types=1);\n\n/**\n * @author Pavel Djundik\n *\n * @link https://xpaw.me\n * @link https://github.com/xPaw/PHP-Source-Query\n *\n * @license GNU Lesser General Public License, version 2.1\n *\n * @internal\n */\n\nnamespace xPaw\\SourceQuery;\n\n/**\n * Base RCON interface\n */\nabstract class BaseRcon\n{\n\tabstract public function Close( ) : void;\n\tabstract public function Open( ) : void;\n\tabstract public function Write( int $Header, string $String = '' ) : bool;\n\tabstract public function Read( ) : Buffer;\n\tabstract public function Command( string $Command ) : string;\n\tabstract public function Authorize( string $Password ) : void;\n}\n"
  },
  {
    "path": "SourceQuery/BaseSocket.php",
    "content": "<?php\ndeclare(strict_types=1);\n\n/**\n * @author Pavel Djundik\n *\n * @link https://xpaw.me\n * @link https://github.com/xPaw/PHP-Source-Query\n *\n * @license GNU Lesser General Public License, version 2.1\n *\n * @internal\n */\n\nnamespace xPaw\\SourceQuery;\n\nuse xPaw\\SourceQuery\\Exception\\InvalidPacketException;\nuse xPaw\\SourceQuery\\Exception\\SocketException;\n\n/**\n * Base socket interface\n */\nabstract class BaseSocket\n{\n\t/** @var ?resource */\n\tpublic $Socket;\n\tpublic int $Engine;\n\n\tpublic string $Address;\n\tpublic int $Port;\n\tpublic int $Timeout;\n\n\tpublic function __destruct( )\n\t{\n\t\t$this->Close( );\n\t}\n\n\tabstract public function Close( ) : void;\n\tabstract public function Open( string $Address, int $Port, int $Timeout, int $Engine ) : void;\n\tabstract public function Write( int $Header, string $String = '' ) : bool;\n\tabstract public function Read( ) : Buffer;\n\n\tprotected function ReadInternal( Buffer $Buffer, callable $SherlockFunction ) : Buffer\n\t{\n\t\tif( $Buffer->Remaining( ) === 0 )\n\t\t{\n\t\t\tthrow new InvalidPacketException( 'Failed to read any data from socket', InvalidPacketException::BUFFER_EMPTY );\n\t\t}\n\n\t\t$Header = $Buffer->ReadInt32( );\n\n\t\tif( $Header === -1 ) // Single packet\n\t\t{\n\t\t\t// We don't have to do anything\n\t\t}\n\t\telse if( $Header === -2 ) // Split packet\n\t\t{\n\t\t\t$Packets      = [];\n\t\t\t$IsCompressed = false;\n\t\t\t$ReadMore     = false;\n\t\t\t$PacketChecksum = null;\n\n\t\t\tdo\n\t\t\t{\n\t\t\t\t$RequestID = $Buffer->ReadInt32( );\n\t\t\t\t$PacketCount = 0;\n\t\t\t\t$PacketNumber = 0;\n\n\t\t\t\tswitch( $this->Engine )\n\t\t\t\t{\n\t\t\t\t\tcase SourceQuery::GOLDSOURCE:\n\t\t\t\t\t{\n\t\t\t\t\t\t$PacketCountAndNumber = $Buffer->ReadByte( );\n\t\t\t\t\t\t$PacketCount          = $PacketCountAndNumber & 0xF;\n\t\t\t\t\t\t$PacketNumber         = $PacketCountAndNumber >> 4;\n\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase SourceQuery::SOURCE:\n\t\t\t\t\t{\n\t\t\t\t\t\t$IsCompressed         = ( $RequestID & 0x80000000 ) !== 0;\n\t\t\t\t\t\t$PacketCount          = $Buffer->ReadByte( );\n\t\t\t\t\t\t$PacketNumber         = $Buffer->ReadByte( ) + 1;\n\n\t\t\t\t\t\tif( $IsCompressed )\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$Buffer->ReadInt32( ); // Split size\n\n\t\t\t\t\t\t\t$PacketChecksum = $Buffer->ReadUInt32( );\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$Buffer->ReadInt16( ); // Split size\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tdefault:\n\t\t\t\t\t{\n\t\t\t\t\t\tthrow new SocketException( 'Unknown engine.', SocketException::INVALID_ENGINE );\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t$Packets[ $PacketNumber ] = $Buffer->Read( );\n\n\t\t\t\t$ReadMore = $PacketCount > sizeof( $Packets );\n\t\t\t}\n\t\t\twhile( $ReadMore && $SherlockFunction( $Buffer ) );\n\n\t\t\t$Data = implode( $Packets );\n\n\t\t\t// TODO: Test this\n\t\t\tif( $IsCompressed )\n\t\t\t{\n\t\t\t\t// Let's make sure this function exists, it's not included in PHP by default\n\t\t\t\tif( !function_exists( 'bzdecompress' ) )\n\t\t\t\t{\n\t\t\t\t\tthrow new \\RuntimeException( 'Received compressed packet, PHP doesn\\'t have Bzip2 library installed, can\\'t decompress.' );\n\t\t\t\t}\n\n\t\t\t\t$Data = bzdecompress( $Data );\n\n\t\t\t\tif( !is_string( $Data ) || crc32( $Data ) !== $PacketChecksum )\n\t\t\t\t{\n\t\t\t\t\tthrow new InvalidPacketException( 'CRC32 checksum mismatch of uncompressed packet data.', InvalidPacketException::CHECKSUM_MISMATCH );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t$Buffer->Set( substr( $Data, 4 ) );\n\t\t}\n\t\telse\n\t\t{\n\t\t\tthrow new InvalidPacketException( 'Socket read: Raw packet header mismatch. (0x' . dechex( $Header ) . ')', InvalidPacketException::PACKET_HEADER_MISMATCH );\n\t\t}\n\n\t\treturn $Buffer;\n\t}\n}\n"
  },
  {
    "path": "SourceQuery/Buffer.php",
    "content": "<?php\ndeclare(strict_types=1);\n\n/**\n * @author Pavel Djundik\n *\n * @link https://xpaw.me\n * @link https://github.com/xPaw/PHP-Source-Query\n *\n * @license GNU Lesser General Public License, version 2.1\n *\n * @internal\n */\n\nnamespace xPaw\\SourceQuery;\n\nuse xPaw\\SourceQuery\\Exception\\InvalidPacketException;\n\n/**\n * Class Buffer\n */\nclass Buffer\n{\n\t/**\n\t * Buffer\n\t */\n\tprivate string $Buffer = '';\n\n\t/**\n\t * Buffer length\n\t */\n\tprivate int $Length = 0;\n\n\t/**\n\t * Current position in buffer\n\t */\n\tprivate int $Position = 0;\n\n\t/**\n\t * Sets buffer\n\t */\n\tpublic function Set( string $Buffer ) : void\n\t{\n\t\t$this->Buffer   = $Buffer;\n\t\t$this->Length   = strlen( $Buffer );\n\t\t$this->Position = 0;\n\t}\n\n\t/**\n\t * Get remaining bytes\n\t *\n\t * @return int Remaining bytes in buffer\n\t *\n\t * @phpstan-impure\n\t */\n\tpublic function Remaining( ) : int\n\t{\n\t\treturn $this->Length - $this->Position;\n\t}\n\n\t/**\n\t * Reads the specified number of bytes.\n\t *\n\t * @param int $Length Bytes to read\n\t */\n\tpublic function Read( int $Length = -1 ) : string\n\t{\n\t\tif( $Length === 0 )\n\t\t{\n\t\t\treturn '';\n\t\t}\n\n\t\t$Remaining = $this->Remaining( );\n\n\t\tif( $Length === -1 )\n\t\t{\n\t\t\t$Length = $Remaining;\n\t\t}\n\t\telse if( $Length > $Remaining )\n\t\t{\n\t\t\treturn '';\n\t\t}\n\n\t\t$Data = substr( $this->Buffer, $this->Position, $Length );\n\n\t\t$this->Position += $Length;\n\n\t\treturn $Data;\n\t}\n\n\t/**\n\t * Reads the next byte.\n\t */\n\tpublic function ReadByte( ) : int\n\t{\n\t\tif( $this->Remaining( ) < 1 )\n\t\t{\n\t\t\treturn 0;\n\t\t}\n\n\t\treturn ord( $this->Read( 1 ) );\n\t}\n\n\t/**\n\t * Reads a 2-byte signed integer.\n\t */\n\tpublic function ReadInt16( ) : int\n\t{\n\t\tif( $this->Remaining( ) < 2 )\n\t\t{\n\t\t\tthrow new InvalidPacketException( 'Not enough data to unpack.', InvalidPacketException::BUFFER_EMPTY );\n\t\t}\n\n\t\t$Data = unpack( 'v', $this->Read( 2 ) );\n\n\t\tif( $Data === false )\n\t\t{\n\t\t\tthrow new InvalidPacketException( 'Failed to unpack.', InvalidPacketException::UNPACK_FAILED );\n\t\t}\n\n\t\treturn (int)$Data[ 1 ];\n\t}\n\n\t/**\n\t * Reads a 4-byte signed integer.\n\t */\n\tpublic function ReadInt32( ) : int\n\t{\n\t\tif( $this->Remaining( ) < 4 )\n\t\t{\n\t\t\tthrow new InvalidPacketException( 'Not enough data to unpack.', InvalidPacketException::BUFFER_EMPTY );\n\t\t}\n\n\t\t$Data = unpack( 'l', $this->Read( 4 ) );\n\n\t\tif( $Data === false )\n\t\t{\n\t\t\tthrow new InvalidPacketException( 'Failed to unpack.', InvalidPacketException::UNPACK_FAILED );\n\t\t}\n\n\t\treturn (int)$Data[ 1 ];\n\t}\n\n\t/**\n\t * Reads a 4-byte floating point value.\n\t */\n\tpublic function ReadFloat32( ) : float\n\t{\n\t\tif( $this->Remaining( ) < 4 )\n\t\t{\n\t\t\tthrow new InvalidPacketException( 'Not enough data to unpack.', InvalidPacketException::BUFFER_EMPTY );\n\t\t}\n\n\t\t$Data = unpack( 'f', $this->Read( 4 ) );\n\n\t\tif( $Data === false )\n\t\t{\n\t\t\tthrow new InvalidPacketException( 'Failed to unpack.', InvalidPacketException::UNPACK_FAILED );\n\t\t}\n\n\t\treturn (float)$Data[ 1 ];\n\t}\n\n\t/**\n\t * Reads a 4-byte unsigned integer.\n\t */\n\tpublic function ReadUInt32( ) : int\n\t{\n\t\tif( $this->Remaining( ) < 4 )\n\t\t{\n\t\t\tthrow new InvalidPacketException( 'Not enough data to unpack.', InvalidPacketException::BUFFER_EMPTY );\n\t\t}\n\n\t\t$Data = unpack( 'V', $this->Read( 4 ) );\n\n\t\tif( $Data === false )\n\t\t{\n\t\t\tthrow new InvalidPacketException( 'Failed to unpack.', InvalidPacketException::UNPACK_FAILED );\n\t\t}\n\n\t\treturn (int)$Data[ 1 ];\n\t}\n\n\t/**\n\t * Read a null-terminated string.\n\t */\n\tpublic function ReadNullTermString( ) : string\n\t{\n\t\t$ZeroBytePosition = strpos( $this->Buffer, \"\\0\", $this->Position );\n\n\t\tif( $ZeroBytePosition === false )\n\t\t{\n\t\t\treturn '';\n\t\t}\n\n\t\t$String = $this->Read( $ZeroBytePosition - $this->Position );\n\n\t\t$this->Position++;\n\n\t\treturn $String;\n\t}\n}\n"
  },
  {
    "path": "SourceQuery/Exception/AuthenticationException.php",
    "content": "<?php\ndeclare(strict_types=1);\n\n/**\n * @author Pavel Djundik\n *\n * @link https://xpaw.me\n * @link https://github.com/xPaw/PHP-Source-Query\n *\n * @license GNU Lesser General Public License, version 2.1\n *\n * @internal\n */\n\nnamespace xPaw\\SourceQuery\\Exception;\n\nclass AuthenticationException extends SourceQueryException\n{\n\tconst BAD_PASSWORD = 1;\n\tconst BANNED = 2;\n}\n"
  },
  {
    "path": "SourceQuery/Exception/InvalidArgumentException.php",
    "content": "<?php\ndeclare(strict_types=1);\n\n/**\n * @author Pavel Djundik\n *\n * @link https://xpaw.me\n * @link https://github.com/xPaw/PHP-Source-Query\n *\n * @license GNU Lesser General Public License, version 2.1\n *\n * @internal\n */\n\nnamespace xPaw\\SourceQuery\\Exception;\n\nclass InvalidArgumentException extends SourceQueryException\n{\n\tconst TIMEOUT_NOT_INTEGER = 1;\n}\n"
  },
  {
    "path": "SourceQuery/Exception/InvalidPacketException.php",
    "content": "<?php\ndeclare(strict_types=1);\n\n/**\n * @author Pavel Djundik\n *\n * @link https://xpaw.me\n * @link https://github.com/xPaw/PHP-Source-Query\n *\n * @license GNU Lesser General Public License, version 2.1\n *\n * @internal\n */\n\nnamespace xPaw\\SourceQuery\\Exception;\n\nclass InvalidPacketException extends SourceQueryException\n{\n\tconst PACKET_HEADER_MISMATCH = 1;\n\tconst BUFFER_EMPTY = 2;\n\tconst BUFFER_NOT_EMPTY = 3;\n\tconst CHECKSUM_MISMATCH = 4;\n\tconst UNPACK_FAILED = 5;\n}\n"
  },
  {
    "path": "SourceQuery/Exception/SocketException.php",
    "content": "<?php\ndeclare(strict_types=1);\n\n/**\n * @author Pavel Djundik\n *\n * @link https://xpaw.me\n * @link https://github.com/xPaw/PHP-Source-Query\n *\n * @license GNU Lesser General Public License, version 2.1\n *\n * @internal\n */\n\nnamespace xPaw\\SourceQuery\\Exception;\n\nclass SocketException extends SourceQueryException\n{\n\tconst COULD_NOT_CREATE_SOCKET = 1;\n\tconst NOT_CONNECTED = 2;\n\tconst CONNECTION_FAILED = 3;\n\tconst INVALID_ENGINE = 4;\n}\n"
  },
  {
    "path": "SourceQuery/Exception/SourceQueryException.php",
    "content": "<?php\ndeclare(strict_types=1);\n\n/**\n * @author Pavel Djundik\n *\n * @link https://xpaw.me\n * @link https://github.com/xPaw/PHP-Source-Query\n *\n * @license GNU Lesser General Public License, version 2.1\n *\n * @internal\n */\n\nnamespace xPaw\\SourceQuery\\Exception;\n\nabstract class SourceQueryException extends \\Exception\n{\n\t// Base exception class\n}\n"
  },
  {
    "path": "SourceQuery/GoldSourceRcon.php",
    "content": "<?php\ndeclare(strict_types=1);\n\n/**\n * @author Pavel Djundik\n *\n * @link https://xpaw.me\n * @link https://github.com/xPaw/PHP-Source-Query\n *\n * @license GNU Lesser General Public License, version 2.1\n *\n * @internal\n */\n\nnamespace xPaw\\SourceQuery;\n\nuse xPaw\\SourceQuery\\Exception\\AuthenticationException;\nuse xPaw\\SourceQuery\\Exception\\InvalidPacketException;\nuse xPaw\\SourceQuery\\Exception\\SocketException;\n\n/**\n * Class GoldSourceRcon\n */\nclass GoldSourceRcon extends BaseRcon\n{\n\t/**\n\t * Points to socket class\n\t */\n\tprivate BaseSocket $Socket;\n\n\tprivate string $RconPassword = '';\n\tprivate string $RconChallenge = '';\n\n\tpublic function __construct( BaseSocket $Socket )\n\t{\n\t\t$this->Socket = $Socket;\n\t}\n\n\tpublic function Close( ) : void\n\t{\n\t\t$this->RconChallenge = '';\n\t\t$this->RconPassword  = '';\n\t}\n\n\tpublic function Open( ) : void\n\t{\n\t\t//\n\t}\n\n\tpublic function Write( int $Header, string $String = '' ) : bool\n\t{\n\t\tif( $this->Socket->Socket === null )\n\t\t{\n\t\t\tthrow new SocketException( 'Not connected.', SocketException::NOT_CONNECTED );\n\t\t}\n\n\t\t$Command = pack( 'cccca*', 0xFF, 0xFF, 0xFF, 0xFF, $String );\n\t\t$Length  = strlen( $Command );\n\n\t\treturn $Length === fwrite( $this->Socket->Socket, $Command, $Length );\n\t}\n\n\t/**\n\t * @throws AuthenticationException\n\t */\n\tpublic function Read( ) : Buffer\n\t{\n\t\t// GoldSource RCON has same structure as Query\n\t\t$Buffer = $this->Socket->Read( );\n\n\t\t$StringBuffer = '';\n\t\t$ReadMore = false;\n\n\t\t// There is no indentifier of the end, so we just need to continue reading\n\t\tdo\n\t\t{\n\t\t\t$ReadMore = $Buffer->Remaining( ) > 0;\n\n\t\t\tif( $ReadMore )\n\t\t\t{\n\t\t\t\tif( $Buffer->ReadByte( ) !== SourceQuery::S2A_RCON )\n\t\t\t\t{\n\t\t\t\t\tthrow new InvalidPacketException( 'Invalid rcon response.', InvalidPacketException::PACKET_HEADER_MISMATCH );\n\t\t\t\t}\n\n\t\t\t\t$Packet = $Buffer->Read( );\n\t\t\t\t$StringBuffer .= $Packet;\n\t\t\t\t//$StringBuffer .= SubStr( $Packet, 0, -2 );\n\n\t\t\t\t// Let's assume if this packet is not long enough, there are no more after this one\n\t\t\t\t$ReadMore = strlen( $Packet ) > 1000; // use 1300?\n\n\t\t\t\tif( $ReadMore )\n\t\t\t\t{\n\t\t\t\t\t$Buffer = $this->Socket->Read( );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\twhile( $ReadMore );\n\n\t\t$Trimmed = trim( $StringBuffer );\n\n\t\tif( $Trimmed === 'Bad rcon_password.' )\n\t\t{\n\t\t\tthrow new AuthenticationException( $Trimmed, AuthenticationException::BAD_PASSWORD );\n\t\t}\n\t\telse if( $Trimmed === 'You have been banned from this server.' )\n\t\t{\n\t\t\tthrow new AuthenticationException( $Trimmed, AuthenticationException::BANNED );\n\t\t}\n\n\t\t$Buffer->Set( $Trimmed );\n\n\t\treturn $Buffer;\n\t}\n\n\tpublic function Command( string $Command ) : string\n\t{\n\t\tif( !$this->RconChallenge )\n\t\t{\n\t\t\tthrow new AuthenticationException( 'Tried to execute a RCON command before successful authorization.', AuthenticationException::BAD_PASSWORD );\n\t\t}\n\n\t\t$this->Write( 0, 'rcon ' . $this->RconChallenge . ' \"' . $this->RconPassword . '\" ' . $Command . \"\\0\" );\n\t\t$Buffer = $this->Read( );\n\n\t\treturn $Buffer->Read( );\n\t}\n\n\tpublic function Authorize( string $Password ) : void\n\t{\n\t\t$this->RconPassword = $Password;\n\n\t\t$this->Write( 0, 'challenge rcon' );\n\t\t$Buffer = $this->Socket->Read( );\n\n\t\tif( $Buffer->Read( 14 ) !== 'challenge rcon' )\n\t\t{\n\t\t\tthrow new AuthenticationException( 'Failed to get RCON challenge.', AuthenticationException::BAD_PASSWORD );\n\t\t}\n\n\t\t$this->RconChallenge = trim( $Buffer->Read( ) );\n\t}\n}\n"
  },
  {
    "path": "SourceQuery/Socket.php",
    "content": "<?php\ndeclare(strict_types=1);\n\n/**\n * @author Pavel Djundik\n *\n * @link https://xpaw.me\n * @link https://github.com/xPaw/PHP-Source-Query\n *\n * @license GNU Lesser General Public License, version 2.1\n *\n * @internal\n */\n\nnamespace xPaw\\SourceQuery;\n\nuse xPaw\\SourceQuery\\Exception\\InvalidPacketException;\nuse xPaw\\SourceQuery\\Exception\\SocketException;\n\n/**\n * Class Socket\n */\nclass Socket extends BaseSocket\n{\n\tpublic function Close( ) : void\n\t{\n\t\tif( is_resource( $this->Socket ) )\n\t\t{\n\t\t\tfclose( $this->Socket );\n\n\t\t\t$this->Socket = null;\n\t\t}\n\t}\n\n\tpublic function Open( string $Address, int $Port, int $Timeout, int $Engine ) : void\n\t{\n\t\t$this->Timeout = $Timeout;\n\t\t$this->Engine  = $Engine;\n\t\t$this->Port    = $Port;\n\t\t$this->Address = $Address;\n\n\t\t$Socket = @fsockopen( 'udp://' . $Address, $Port, $ErrNo, $ErrStr, $Timeout );\n\n\t\tif( $ErrNo || $Socket === false )\n\t\t{\n\t\t\tthrow new SocketException( 'Could not create socket: ' . $ErrStr, SocketException::COULD_NOT_CREATE_SOCKET );\n\t\t}\n\n\t\t$this->Socket = $Socket;\n\t\tstream_set_timeout( $this->Socket, $Timeout );\n\t\tstream_set_blocking( $this->Socket, true );\n\t}\n\n\tpublic function Write( int $Header, string $String = '' ) : bool\n\t{\n\t\tif( $this->Socket === null )\n\t\t{\n\t\t\tthrow new SocketException( 'Not connected.', SocketException::NOT_CONNECTED );\n\t\t}\n\n\t\t$Command = pack( 'ccccca*', 0xFF, 0xFF, 0xFF, 0xFF, $Header, $String );\n\t\t$Length  = strlen( $Command );\n\n\t\treturn $Length === fwrite( $this->Socket, $Command, $Length );\n\t}\n\n\tprivate const MaxPacketLength = 1 << 16;\n\n\t/**\n\t * Reads from socket and returns Buffer.\n\t *\n\t * @throws InvalidPacketException\n\t */\n\tpublic function Read( ) : Buffer\n\t{\n\t\tif( $this->Socket === null )\n\t\t{\n\t\t\tthrow new SocketException( 'Not connected.', SocketException::NOT_CONNECTED );\n\t\t}\n\n\t\t$Data = fread( $this->Socket, self::MaxPacketLength );\n\t\t$Buffer = new Buffer( );\n\t\t$Buffer->Set( $Data === false ? '' : $Data );\n\n\t\t$this->ReadInternal( $Buffer, [ $this, 'Sherlock' ] );\n\n\t\treturn $Buffer;\n\t}\n\n\tpublic function Sherlock( Buffer $Buffer ) : bool\n\t{\n\t\tif( $this->Socket === null )\n\t\t{\n\t\t\tthrow new SocketException( 'Not connected.', SocketException::NOT_CONNECTED );\n\t\t}\n\n\t\t$Data = fread( $this->Socket, self::MaxPacketLength );\n\n\t\tif( $Data === false || strlen( $Data ) < 4 )\n\t\t{\n\t\t\treturn false;\n\t\t}\n\n\t\t$Buffer->Set( $Data );\n\n\t\treturn $Buffer->ReadInt32( ) === -2;\n\t}\n}\n"
  },
  {
    "path": "SourceQuery/SourceQuery.php",
    "content": "<?php\ndeclare(strict_types=1);\n\n/**\n * This class provides the public interface to the PHP-Source-Query library.\n *\n * @author Pavel Djundik\n *\n * @link https://xpaw.me\n * @link https://github.com/xPaw/PHP-Source-Query\n *\n * @license GNU Lesser General Public License, version 2.1\n */\n\nnamespace xPaw\\SourceQuery;\n\nuse xPaw\\SourceQuery\\Exception\\AuthenticationException;\nuse xPaw\\SourceQuery\\Exception\\InvalidArgumentException;\nuse xPaw\\SourceQuery\\Exception\\InvalidPacketException;\nuse xPaw\\SourceQuery\\Exception\\SocketException;\n\n/**\n * Class SourceQuery\n */\nclass SourceQuery\n{\n\t/**\n\t * Engines\n\t */\n\tconst GOLDSOURCE = 0;\n\tconst SOURCE     = 1;\n\n\t/**\n\t * Packets sent\n\t */\n\tconst A2A_PING      = 0x69;\n\tconst A2S_INFO      = 0x54;\n\tconst A2S_PLAYER    = 0x55;\n\tconst A2S_RULES     = 0x56;\n\tconst A2S_SERVERQUERY_GETCHALLENGE = 0x57;\n\n\t/**\n\t * Packets received\n\t */\n\tconst A2A_ACK       = 0x6A;\n\tconst S2C_CHALLENGE = 0x41;\n\tconst S2A_INFO_SRC  = 0x49;\n\tconst S2A_INFO_OLD  = 0x6D; // Old GoldSource, HLTV uses it (actually called S2A_INFO_DETAILED)\n\tconst S2A_PLAYER    = 0x44;\n\tconst S2A_RULES     = 0x45;\n\tconst S2A_RCON      = 0x6C;\n\n\t/**\n\t * Source rcon sent\n\t */\n\tconst SERVERDATA_REQUESTVALUE   = 0;\n\tconst SERVERDATA_EXECCOMMAND    = 2;\n\tconst SERVERDATA_AUTH           = 3;\n\n\t/**\n\t * Source rcon received\n\t */\n\tconst SERVERDATA_RESPONSE_VALUE = 0;\n\tconst SERVERDATA_AUTH_RESPONSE  = 2;\n\n\t/**\n\t * Points to rcon class\n\t */\n\tprivate ?BaseRcon $Rcon = null;\n\n\t/**\n\t * Points to socket class\n\t */\n\tprivate BaseSocket $Socket;\n\n\t/**\n\t * True if connection is open, false if not\n\t */\n\tprivate bool $Connected = false;\n\n\t/**\n\t * Contains challenge\n\t */\n\tprivate string $Challenge = '';\n\n\t/**\n\t * Use old method for getting challenge number\n\t */\n\tprivate bool $UseOldGetChallengeMethod = false;\n\n\tpublic function __construct( ?BaseSocket $Socket = null )\n\t{\n\t\t$this->Socket = $Socket ?? new Socket( );\n\t}\n\n\tpublic function __destruct( )\n\t{\n\t\t$this->Disconnect( );\n\t}\n\n\t/**\n\t * Opens connection to server\n\t *\n\t * @param string $Address Server ip\n\t * @param int $Port Server port\n\t * @param int $Timeout Timeout period\n\t * @param int $Engine Engine the server runs on (goldsource, source)\n\t *\n\t * @throws InvalidArgumentException\n\t * @throws SocketException\n\t */\n\tpublic function Connect( string $Address, int $Port, int $Timeout = 3, int $Engine = self::SOURCE ) : void\n\t{\n\t\t$this->Disconnect( );\n\n\t\tif( $Timeout < 0 )\n\t\t{\n\t\t\tthrow new InvalidArgumentException( 'Timeout must be a positive integer.', InvalidArgumentException::TIMEOUT_NOT_INTEGER );\n\t\t}\n\n\t\t$this->Socket->Open( $Address, $Port, $Timeout, $Engine );\n\n\t\t$this->Connected = true;\n\t}\n\n\t/**\n\t * Forces GetChallenge to use old method for challenge retrieval because some games use outdated protocol (e.g Starbound)\n\t *\n\t * @param bool $Value Set to true to force old method\n\t *\n\t * @return bool Previous value\n\t */\n\tpublic function SetUseOldGetChallengeMethod( bool $Value ) : bool\n\t{\n\t\t$Previous = $this->UseOldGetChallengeMethod;\n\n\t\t$this->UseOldGetChallengeMethod = $Value === true;\n\n\t\treturn $Previous;\n\t}\n\n\t/**\n\t * Closes all open connections\n\t */\n\tpublic function Disconnect( ) : void\n\t{\n\t\t$this->Connected = false;\n\t\t$this->Challenge = '';\n\n\t\t$this->Socket->Close( );\n\n\t\tif( $this->Rcon !== null )\n\t\t{\n\t\t\t$this->Rcon->Close( );\n\n\t\t\t$this->Rcon = null;\n\t\t}\n\t}\n\n\t/**\n\t * Sends ping packet to the server\n\t * NOTE: This may not work on some games (TF2 for example)\n\t *\n\t * @throws InvalidPacketException\n\t * @throws SocketException\n\t *\n\t * @return bool True on success, false on failure\n\t */\n\tpublic function Ping( ) : bool\n\t{\n\t\tif( !$this->Connected )\n\t\t{\n\t\t\tthrow new SocketException( 'Not connected.', SocketException::NOT_CONNECTED );\n\t\t}\n\n\t\t$this->Socket->Write( self::A2A_PING );\n\t\t$Buffer = $this->Socket->Read( );\n\n\t\treturn $Buffer->ReadByte( ) === self::A2A_ACK;\n\t}\n\n\t/**\n\t * Get server information\n\t *\n\t * @throws InvalidPacketException\n\t * @throws SocketException\n\t *\n\t * @return array{\n\t *     Protocol: int,\n\t *     HostName: string,\n\t *     Map: string,\n\t *     ModDir: string,\n\t *     ModDesc: string,\n\t *     AppID?: int,\n\t *     Players: int,\n\t *     MaxPlayers: int,\n\t *     Bots: int,\n\t *     Dedicated: string,\n\t *     Os: string,\n\t *     Password: bool,\n\t *     Secure: bool,\n\t *     Version?: string,\n\t *     ExtraDataFlags?: int,\n\t *     GamePort?: int,\n\t *     SteamID?: string|int,\n\t *     SpecPort?: int,\n\t *     SpecName?: string,\n\t *     GameTags?: string,\n\t *     GameID?: int,\n\t *     Address?: string,\n\t *     IsMod?: bool,\n\t *     Mod?: array{\n\t *         Url: string,\n\t *         Download: string,\n\t *         Version: int,\n\t *         Size: int,\n\t *         ServerSide: bool,\n\t *         CustomDLL: bool\n\t *     },\n\t *     GameMode?: int,\n\t *     WitnessCount?: int,\n\t *     WitnessTime?: int\n\t * } Returns an array with server information on success\n\t */\n\tpublic function GetInfo( ) : array\n\t{\n\t\tif( !$this->Connected )\n\t\t{\n\t\t\tthrow new SocketException( 'Not connected.', SocketException::NOT_CONNECTED );\n\t\t}\n\n\t\tif( $this->Challenge )\n\t\t{\n\t\t\t$this->Socket->Write( self::A2S_INFO, \"Source Engine Query\\0\" . $this->Challenge );\n\t\t}\n\t\telse\n\t\t{\n\t\t\t$this->Socket->Write( self::A2S_INFO, \"Source Engine Query\\0\" );\n\t\t}\n\n\t\t$Buffer = $this->Socket->Read( );\n\t\t$Type = $Buffer->ReadByte( );\n\t\t$Server = [];\n\n\t\tif( $Type === self::S2C_CHALLENGE )\n\t\t{\n\t\t\t$this->Challenge = $Buffer->Read( 4 );\n\n\t\t\t$this->Socket->Write( self::A2S_INFO, \"Source Engine Query\\0\" . $this->Challenge );\n\t\t\t$Buffer = $this->Socket->Read( );\n\t\t\t$Type = $Buffer->ReadByte( );\n\t\t}\n\n\t\t// Old GoldSource protocol, HLTV still uses it\n\t\tif( $Type === self::S2A_INFO_OLD && $this->Socket->Engine === self::GOLDSOURCE )\n\t\t{\n\t\t\t/**\n\t\t\t * If we try to read data again, and we get the result with type S2A_INFO (0x49)\n\t\t\t * That means this server is running dproto,\n\t\t\t * Because it sends answer for both protocols\n\t\t\t */\n\n\t\t\t$Server[ 'Address' ]    = $Buffer->ReadNullTermString( );\n\t\t\t$Server[ 'HostName' ]   = $Buffer->ReadNullTermString( );\n\t\t\t$Server[ 'Map' ]        = $Buffer->ReadNullTermString( );\n\t\t\t$Server[ 'ModDir' ]     = $Buffer->ReadNullTermString( );\n\t\t\t$Server[ 'ModDesc' ]    = $Buffer->ReadNullTermString( );\n\t\t\t$Server[ 'Players' ]    = $Buffer->ReadByte( );\n\t\t\t$Server[ 'MaxPlayers' ] = $Buffer->ReadByte( );\n\t\t\t$Server[ 'Protocol' ]   = $Buffer->ReadByte( );\n\t\t\t$Server[ 'Dedicated' ]  = chr( $Buffer->ReadByte( ) );\n\t\t\t$Server[ 'Os' ]         = chr( $Buffer->ReadByte( ) );\n\t\t\t$Server[ 'Password' ]   = $Buffer->ReadByte( ) === 1;\n\t\t\t$Server[ 'IsMod' ]      = $Buffer->ReadByte( ) === 1;\n\n\t\t\tif( $Server[ 'IsMod' ] )\n\t\t\t{\n\t\t\t\t$Mod = [];\n\t\t\t\t$Mod[ 'Url' ]        = $Buffer->ReadNullTermString( );\n\t\t\t\t$Mod[ 'Download' ]   = $Buffer->ReadNullTermString( );\n\t\t\t\t$Buffer->Read( 1 ); // NULL byte\n\t\t\t\t$Mod[ 'Version' ]    = $Buffer->ReadInt32( );\n\t\t\t\t$Mod[ 'Size' ]       = $Buffer->ReadInt32( );\n\t\t\t\t$Mod[ 'ServerSide' ] = $Buffer->ReadByte( ) === 1;\n\t\t\t\t$Mod[ 'CustomDLL' ]  = $Buffer->ReadByte( ) === 1;\n\t\t\t\t$Server[ 'Mod' ] = $Mod;\n\t\t\t}\n\n\t\t\t$Server[ 'Secure' ]   = $Buffer->ReadByte( ) === 1;\n\t\t\t$Server[ 'Bots' ]     = $Buffer->ReadByte( );\n\n\t\t\treturn $Server;\n\t\t}\n\n\t\tif( $Type !== self::S2A_INFO_SRC )\n\t\t{\n\t\t\tthrow new InvalidPacketException( 'GetInfo: Packet header mismatch. (0x' . dechex( $Type ) . ')', InvalidPacketException::PACKET_HEADER_MISMATCH );\n\t\t}\n\n\t\t$Server[ 'Protocol' ]   = $Buffer->ReadByte( );\n\t\t$Server[ 'HostName' ]   = $Buffer->ReadNullTermString( );\n\t\t$Server[ 'Map' ]        = $Buffer->ReadNullTermString( );\n\t\t$Server[ 'ModDir' ]     = $Buffer->ReadNullTermString( );\n\t\t$Server[ 'ModDesc' ]    = $Buffer->ReadNullTermString( );\n\t\t$Server[ 'AppID' ]      = $Buffer->ReadInt16( );\n\t\t$Server[ 'Players' ]    = $Buffer->ReadByte( );\n\t\t$Server[ 'MaxPlayers' ] = $Buffer->ReadByte( );\n\t\t$Server[ 'Bots' ]       = $Buffer->ReadByte( );\n\t\t$Server[ 'Dedicated' ]  = chr( $Buffer->ReadByte( ) );\n\t\t$Server[ 'Os' ]         = chr( $Buffer->ReadByte( ) );\n\t\t$Server[ 'Password' ]   = $Buffer->ReadByte( ) === 1;\n\t\t$Server[ 'Secure' ]     = $Buffer->ReadByte( ) === 1;\n\n\t\t// The Ship (they violate query protocol spec by modifying the response)\n\t\tif( $Server[ 'AppID' ] === 2400 )\n\t\t{\n\t\t\t$Server[ 'GameMode' ]     = $Buffer->ReadByte( );\n\t\t\t$Server[ 'WitnessCount' ] = $Buffer->ReadByte( );\n\t\t\t$Server[ 'WitnessTime' ]  = $Buffer->ReadByte( );\n\t\t}\n\n\t\t$Server[ 'Version' ] = $Buffer->ReadNullTermString( );\n\n\t\t// Extra Data Flags\n\t\tif( $Buffer->Remaining( ) > 0 )\n\t\t{\n\t\t\t$Server[ 'ExtraDataFlags' ] = $Flags = $Buffer->ReadByte( );\n\n\t\t\t// S2A_EXTRA_DATA_HAS_GAME_PORT - Next 2 bytes include the game port.\n\t\t\tif( $Flags & 0x80 )\n\t\t\t{\n\t\t\t\t$Server[ 'GamePort' ] = $Buffer->ReadInt16( );\n\t\t\t}\n\n\t\t\t// S2A_EXTRA_DATA_HAS_STEAMID - Next 8 bytes are the steamID\n\t\t\t// Want to play around with this?\n\t\t\t// You can use https://github.com/xPaw/SteamID.php\n\t\t\tif( $Flags & 0x10 )\n\t\t\t{\n\t\t\t\t$SteamIDLower    = $Buffer->ReadUInt32( );\n\t\t\t\t$SteamIDInstance = $Buffer->ReadUInt32( ); // This gets shifted by 32 bits, which should be steamid instance\n\t\t\t\t$SteamID = 0;\n\n\t\t\t\tif( PHP_INT_SIZE === 4 )\n\t\t\t\t{\n\t\t\t\t\tif( extension_loaded( 'gmp' ) )\n\t\t\t\t\t{\n\t\t\t\t\t\t$SteamIDLower    = gmp_abs( $SteamIDLower );\n\t\t\t\t\t\t$SteamIDInstance = gmp_abs( $SteamIDInstance );\n\t\t\t\t\t\t$SteamID         = gmp_strval( gmp_or( $SteamIDLower, gmp_mul( $SteamIDInstance, gmp_pow( 2, 32 ) ) ) );\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tthrow new \\RuntimeException( 'Either 64-bit PHP installation or \"gmp\" module is required to correctly parse server\\'s steamid.' );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\t$SteamID = $SteamIDLower | ( $SteamIDInstance << 32 );\n\t\t\t\t}\n\n\t\t\t\t$Server[ 'SteamID' ] = $SteamID;\n\n\t\t\t\tunset( $SteamIDLower, $SteamIDInstance, $SteamID );\n\t\t\t}\n\n\t\t\t// S2A_EXTRA_DATA_HAS_SPECTATOR_DATA - Next 2 bytes include the spectator port, then the spectator server name.\n\t\t\tif( $Flags & 0x40 )\n\t\t\t{\n\t\t\t\t$Server[ 'SpecPort' ] = $Buffer->ReadInt16( );\n\t\t\t\t$Server[ 'SpecName' ] = $Buffer->ReadNullTermString( );\n\t\t\t}\n\n\t\t\t// S2A_EXTRA_DATA_HAS_GAMETAG_DATA - Next bytes are the game tag string\n\t\t\tif( $Flags & 0x20 )\n\t\t\t{\n\t\t\t\t$Server[ 'GameTags' ] = $Buffer->ReadNullTermString( );\n\t\t\t}\n\n\t\t\t// S2A_EXTRA_DATA_GAMEID - Next 8 bytes are the gameID of the server\n\t\t\tif( $Flags & 0x01 )\n\t\t\t{\n\t\t\t\t$Server[ 'GameID' ] = $Buffer->ReadUInt32( ) | ( $Buffer->ReadUInt32( ) << 32 );\n\t\t\t}\n\n\t\t\tif( $Buffer->Remaining( ) > 0 )\n\t\t\t{\n\t\t\t\tthrow new InvalidPacketException( 'GetInfo: unread data? ' . $Buffer->Remaining( ) . ' bytes remaining in the buffer. Please report it to the library developer.',\n\t\t\t\t\tInvalidPacketException::BUFFER_NOT_EMPTY );\n\t\t\t}\n\t\t}\n\n\t\treturn $Server;\n\t}\n\n\t/**\n\t * Get players on the server\n\t *\n\t * @throws InvalidPacketException\n\t * @throws SocketException\n\t *\n\t * @return array<int, array{Id: int, Name: string, Frags: int, Time: int, TimeF: string}> Returns an array with players on success\n\t */\n\tpublic function GetPlayers( ) : array\n\t{\n\t\tif( !$this->Connected )\n\t\t{\n\t\t\tthrow new SocketException( 'Not connected.', SocketException::NOT_CONNECTED );\n\t\t}\n\n\t\t$this->GetChallenge( self::A2S_PLAYER, self::S2A_PLAYER );\n\n\t\t$this->Socket->Write( self::A2S_PLAYER, $this->Challenge );\n\t\t$Buffer = $this->Socket->Read( );\n\n\t\t$Type = $Buffer->ReadByte( );\n\n\t\tif( $Type !== self::S2A_PLAYER )\n\t\t{\n\t\t\tthrow new InvalidPacketException( 'GetPlayers: Packet header mismatch. (0x' . dechex( $Type ) . ')', InvalidPacketException::PACKET_HEADER_MISMATCH );\n\t\t}\n\n\t\t$Players = [];\n\t\t$Count   = $Buffer->ReadByte( );\n\n\t\twhile( $Count-- > 0 && $Buffer->Remaining( ) > 0 )\n\t\t{\n\t\t\t$Player = [];\n\t\t\t$Player[ 'Id' ]    = $Buffer->ReadByte( ); // PlayerID, is it just always 0?\n\t\t\t$Player[ 'Name' ]  = $Buffer->ReadNullTermString( );\n\t\t\t$Player[ 'Frags' ] = $Buffer->ReadInt32( );\n\t\t\t$Player[ 'Time' ]  = (int)$Buffer->ReadFloat32( );\n\t\t\t$Player[ 'TimeF' ] = gmdate( ( $Player[ 'Time' ] > 3600 ? 'H:i:s' : 'i:s' ), $Player[ 'Time' ] );\n\n\t\t\t$Players[ ] = $Player;\n\t\t}\n\n\t\treturn $Players;\n\t}\n\n\t/**\n\t * Get rules (cvars) from the server\n\t *\n\t * @throws InvalidPacketException\n\t * @throws SocketException\n\t *\n\t * @return array<string, string> Returns an array with rules on success\n\t */\n\tpublic function GetRules( ) : array\n\t{\n\t\tif( !$this->Connected )\n\t\t{\n\t\t\tthrow new SocketException( 'Not connected.', SocketException::NOT_CONNECTED );\n\t\t}\n\n\t\t$this->GetChallenge( self::A2S_RULES, self::S2A_RULES );\n\n\t\t$this->Socket->Write( self::A2S_RULES, $this->Challenge );\n\t\t$Buffer = $this->Socket->Read( );\n\n\t\t$Type = $Buffer->ReadByte( );\n\n\t\tif( $Type !== self::S2A_RULES )\n\t\t{\n\t\t\tthrow new InvalidPacketException( 'GetRules: Packet header mismatch. (0x' . dechex( $Type ) . ')', InvalidPacketException::PACKET_HEADER_MISMATCH );\n\t\t}\n\n\t\t$Rules = [];\n\t\t$Count = $Buffer->ReadInt16( );\n\n\t\twhile( $Count-- > 0 && $Buffer->Remaining( ) > 0 )\n\t\t{\n\t\t\t$Rule  = $Buffer->ReadNullTermString( );\n\t\t\t$Value = $Buffer->ReadNullTermString( );\n\n\t\t\tif( strlen( $Rule ) > 0 )\n\t\t\t{\n\t\t\t\t$Rules[ $Rule ] = $Value;\n\t\t\t}\n\t\t}\n\n\t\treturn $Rules;\n\t}\n\n\t/**\n\t * Get challenge (used for players/rules packets)\n\t *\n\t * @throws InvalidPacketException\n\t */\n\tprivate function GetChallenge( int $Header, int $ExpectedResult ) : void\n\t{\n\t\tif( $this->Challenge )\n\t\t{\n\t\t\treturn;\n\t\t}\n\n\t\tif( $this->UseOldGetChallengeMethod )\n\t\t{\n\t\t\t$Header = self::A2S_SERVERQUERY_GETCHALLENGE;\n\t\t}\n\n\t\t$this->Socket->Write( $Header, \"\\xFF\\xFF\\xFF\\xFF\" );\n\t\t$Buffer = $this->Socket->Read( );\n\n\t\t$Type = $Buffer->ReadByte( );\n\n\t\tswitch( $Type )\n\t\t{\n\t\t\tcase self::S2C_CHALLENGE:\n\t\t\t{\n\t\t\t\t$this->Challenge = $Buffer->Read( 4 );\n\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase $ExpectedResult:\n\t\t\t{\n\t\t\t\t// Goldsource (HLTV)\n\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase 0:\n\t\t\t{\n\t\t\t\tthrow new InvalidPacketException( 'GetChallenge: Failed to get challenge.' );\n\t\t\t}\n\t\t\tdefault:\n\t\t\t{\n\t\t\t\tthrow new InvalidPacketException( 'GetChallenge: Packet header mismatch. (0x' . dechex( $Type ) . ')', InvalidPacketException::PACKET_HEADER_MISMATCH );\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Sets rcon password, for future use in Rcon()\n\t *\n\t * @param string $Password Rcon Password\n\t *\n\t * @throws AuthenticationException\n\t * @throws InvalidPacketException\n\t * @throws SocketException\n\t */\n\tpublic function SetRconPassword( string $Password ) : void\n\t{\n\t\tif( !$this->Connected )\n\t\t{\n\t\t\tthrow new SocketException( 'Not connected.', SocketException::NOT_CONNECTED );\n\t\t}\n\n\t\tswitch( $this->Socket->Engine )\n\t\t{\n\t\t\tcase SourceQuery::GOLDSOURCE:\n\t\t\t{\n\t\t\t\t$this->Rcon = new GoldSourceRcon( $this->Socket );\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SourceQuery::SOURCE:\n\t\t\t{\n\t\t\t\t$this->Rcon = new SourceRcon( $this->Socket );\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t{\n\t\t\t\tthrow new SocketException( 'Unknown engine.', SocketException::INVALID_ENGINE );\n\t\t\t}\n\t\t}\n\n\t\tif( $this->Rcon === null ) // This should not happen, but makes phpstan happy.\n\t\t{\n\t\t\tthrow new SocketException( 'Something went wrong.', SocketException::INVALID_ENGINE );\n\t\t}\n\n\t\t$this->Rcon->Open( );\n\t\t$this->Rcon->Authorize( $Password );\n\t}\n\n\t/**\n\t * Sends a command to the server for execution.\n\t *\n\t * @param string $Command Command to execute\n\t *\n\t * @throws AuthenticationException\n\t * @throws InvalidPacketException\n\t * @throws SocketException\n\t *\n\t * @return string Answer from server in string\n\t */\n\tpublic function Rcon( string $Command ) : string\n\t{\n\t\tif( !$this->Connected )\n\t\t{\n\t\t\tthrow new SocketException( 'Not connected.', SocketException::NOT_CONNECTED );\n\t\t}\n\n\t\tif( $this->Rcon === null )\n\t\t{\n\t\t\tthrow new SocketException( 'You must set a RCON password before trying to execute a RCON command.', SocketException::NOT_CONNECTED );\n\t\t}\n\n\t\treturn $this->Rcon->Command( $Command );\n\t}\n}\n"
  },
  {
    "path": "SourceQuery/SourceRcon.php",
    "content": "<?php\ndeclare(strict_types=1);\n\n/**\n * @author Pavel Djundik\n *\n * @link https://xpaw.me\n * @link https://github.com/xPaw/PHP-Source-Query\n *\n * @license GNU Lesser General Public License, version 2.1\n *\n * @internal\n */\n\nnamespace xPaw\\SourceQuery;\n\nuse xPaw\\SourceQuery\\Exception\\AuthenticationException;\nuse xPaw\\SourceQuery\\Exception\\InvalidPacketException;\nuse xPaw\\SourceQuery\\Exception\\SocketException;\n\n/**\n * Class SourceRcon\n */\nclass SourceRcon extends BaseRcon\n{\n\t/**\n\t * Points to socket class\n\t */\n\tprivate BaseSocket $Socket;\n\n\t/** @var ?resource */\n\tprivate $RconSocket;\n\tprivate int $RconRequestId = 0;\n\n\tpublic function __construct( BaseSocket $Socket )\n\t{\n\t\t$this->Socket = $Socket;\n\t}\n\n\tpublic function Close( ) : void\n\t{\n\t\tif( $this->RconSocket )\n\t\t{\n\t\t\tfclose( $this->RconSocket );\n\n\t\t\t$this->RconSocket = null;\n\t\t}\n\n\t\t$this->RconRequestId = 0;\n\t}\n\n\tpublic function Open( ) : void\n\t{\n\t\tif( !$this->RconSocket )\n\t\t{\n\t\t\t$RconSocket = @fsockopen( $this->Socket->Address, $this->Socket->Port, $ErrNo, $ErrStr, $this->Socket->Timeout );\n\n\t\t\tif( $ErrNo || !$RconSocket )\n\t\t\t{\n\t\t\t\tthrow new SocketException( 'Can\\'t connect to RCON server: ' . $ErrStr, SocketException::CONNECTION_FAILED );\n\t\t\t}\n\n\t\t\t$this->RconSocket = $RconSocket;\n\t\t\tstream_set_timeout( $this->RconSocket, $this->Socket->Timeout );\n\t\t\tstream_set_blocking( $this->RconSocket, true );\n\t\t}\n\t}\n\n\tpublic function Write( int $Header, string $String = '' ) : bool\n\t{\n\t\tif( $this->RconSocket === null )\n\t\t{\n\t\t\tthrow new SocketException( 'Not connected.', SocketException::NOT_CONNECTED );\n\t\t}\n\n\t\t// Pack the packet together\n\t\t$Command = pack( 'VV', ++$this->RconRequestId, $Header ) . $String . \"\\x00\\x00\";\n\n\t\t// Prepend packet length\n\t\t$Command = pack( 'V', strlen( $Command ) ) . $Command;\n\t\t$Length  = strlen( $Command );\n\n\t\treturn $Length === fwrite( $this->RconSocket, $Command, $Length );\n\t}\n\n\tpublic function Read( ) : Buffer\n\t{\n\t\tif( $this->RconSocket === null )\n\t\t{\n\t\t\tthrow new SocketException( 'Not connected.', SocketException::NOT_CONNECTED );\n\t\t}\n\n\t\t$Data = fread( $this->RconSocket, 4 );\n\t\t$Buffer = new Buffer( );\n\t\t$Buffer->Set( $Data === false ? '' : $Data );\n\n\t\tif( $Buffer->Remaining( ) < 4 )\n\t\t{\n\t\t\tthrow new InvalidPacketException( 'Rcon read: Failed to read any data from socket', InvalidPacketException::BUFFER_EMPTY );\n\t\t}\n\n\t\t$PacketSize = $Buffer->ReadInt32( );\n\n\t\tif( $PacketSize <= 0 )\n\t\t{\n\t\t\tthrow new InvalidPacketException( 'Rcon read: Packet size was empty', InvalidPacketException::BUFFER_EMPTY );\n\t\t}\n\n\t\t$Data = fread( $this->RconSocket, $PacketSize );\n\t\t$Buffer->Set( $Data === false ? '' : $Data );\n\n\t\t$Data = $Buffer->Read( );\n\n\t\t$Remaining = $PacketSize - strlen( $Data );\n\n\t\twhile( $Remaining > 0 )\n\t\t{\n\t\t\t$Data2 = fread( $this->RconSocket, $Remaining );\n\n\t\t\tif( $Data2 === false || strlen( $Data2 ) === 0 )\n\t\t\t{\n\t\t\t\tthrow new InvalidPacketException( 'Read ' . strlen( $Data ) . ' bytes from socket, ' . $Remaining . ' remaining', InvalidPacketException::BUFFER_EMPTY );\n\t\t\t}\n\n\t\t\t$Data .= $Data2;\n\t\t\t$Remaining -= strlen( $Data2 );\n\t\t}\n\n\t\t$Buffer->Set( $Data );\n\n\t\treturn $Buffer;\n\t}\n\n\tpublic function Command( string $Command ) : string\n\t{\n\t\t$this->Write( SourceQuery::SERVERDATA_EXECCOMMAND, $Command );\n\t\t$Buffer = $this->Read( );\n\n\t\t$Buffer->ReadInt32( ); // RequestID\n\n\t\t$Type = $Buffer->ReadInt32( );\n\n\t\tif( $Type === SourceQuery::SERVERDATA_AUTH_RESPONSE )\n\t\t{\n\t\t\tthrow new AuthenticationException( 'Bad rcon_password.', AuthenticationException::BAD_PASSWORD );\n\t\t}\n\t\telse if( $Type !== SourceQuery::SERVERDATA_RESPONSE_VALUE )\n\t\t{\n\t\t\tthrow new InvalidPacketException( 'Invalid rcon response.', InvalidPacketException::PACKET_HEADER_MISMATCH );\n\t\t}\n\n\t\t$Data = $Buffer->Read( );\n\n\t\t// We do this stupid hack to handle split packets\n\t\t// See https://developer.valvesoftware.com/wiki/Source_RCON_Protocol#Multiple-packet_Responses\n\t\tif( strlen( $Data ) >= 4000 )\n\t\t{\n\t\t\t$this->Write( SourceQuery::SERVERDATA_REQUESTVALUE );\n\n\t\t\tdo\n\t\t\t{\n\t\t\t\t$Buffer = $this->Read( );\n\n\t\t\t\t$Buffer->ReadInt32( ); // RequestID\n\n\t\t\t\tif( $Buffer->ReadInt32( ) !== SourceQuery::SERVERDATA_RESPONSE_VALUE )\n\t\t\t\t{\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\t$Data2 = $Buffer->Read( );\n\n\t\t\t\tif( $Data2 === \"\\x00\\x01\\x00\\x00\\x00\\x00\" )\n\t\t\t\t{\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\t$Data .= $Data2;\n\t\t\t}\n\t\t\twhile( true );\n\t\t}\n\n\t\treturn rtrim( $Data, \"\\0\" );\n\t}\n\n\tpublic function Authorize( string $Password ) : void\n\t{\n\t\t$this->Write( SourceQuery::SERVERDATA_AUTH, $Password );\n\t\t$Buffer = $this->Read( );\n\n\t\t$RequestID = $Buffer->ReadInt32( );\n\t\t$Type      = $Buffer->ReadInt32( );\n\n\t\t// If we receive SERVERDATA_RESPONSE_VALUE, then we need to read again\n\t\t// More info: https://developer.valvesoftware.com/wiki/Source_RCON_Protocol#Additional_Comments\n\n\t\tif( $Type === SourceQuery::SERVERDATA_RESPONSE_VALUE )\n\t\t{\n\t\t\t$Buffer = $this->Read( );\n\n\t\t\t$RequestID = $Buffer->ReadInt32( );\n\t\t\t$Type      = $Buffer->ReadInt32( );\n\t\t}\n\n\t\tif( $RequestID === -1 || $Type !== SourceQuery::SERVERDATA_AUTH_RESPONSE )\n\t\t{\n\t\t\tthrow new AuthenticationException( 'RCON authorization failed.', AuthenticationException::BAD_PASSWORD );\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "Tests/Info/csgo.json",
    "content": "{\n    \"Protocol\": 17,\n    \"HostName\": \"BombGame by xPaw & Co.\",\n    \"Map\": \"de_dust2\",\n    \"ModDir\": \"csgo\",\n    \"ModDesc\": \"Counter-Strike: Global Offensive\",\n    \"AppID\": 730,\n    \"Players\": 0,\n    \"MaxPlayers\": 16,\n    \"Bots\": 0,\n    \"Dedicated\": \"d\",\n    \"Os\": \"l\",\n    \"Password\": false,\n    \"Secure\": true,\n    \"Version\": \"1.35.0.7\",\n    \"ExtraDataFlags\": 177,\n    \"GamePort\": 27036,\n    \"SteamID\": 90097713628897284,\n    \"GameTags\": \"empty,*grp:1105381i,bombgame,secure\",\n    \"GameID\": 730\n}\n"
  },
  {
    "path": "Tests/Info/csgo.raw",
    "content": "ffffffff4911426f6d6247616d652062792078506177202620436f2e0064655f6475737432006373676f00436f756e7465722d537472696b653a20476c6f62616c204f6666656e7369766500da02001000646c0001312e33352e302e3700b19c6904e0eca764174001656d7074792c2a6772703a31313035333831692c626f6d6267616d652c73656375726500da02000000000000\n"
  },
  {
    "path": "Tests/Info/gmod_cyrillic.json",
    "content": "{\n    \"Protocol\": 17,\n    \"HostName\": \"Город Инноваций | Русский DarkRP\",\n    \"Map\": \"rp_bangclaw\",\n    \"ModDir\": \"garrysmod\",\n    \"ModDesc\": \"DarkRP\",\n    \"AppID\": 4000,\n    \"Players\": 33,\n    \"MaxPlayers\": 40,\n    \"Bots\": 0,\n    \"Dedicated\": \"d\",\n    \"Os\": \"l\",\n    \"Password\": false,\n    \"Secure\": true,\n    \"Version\": \"15.08.10\",\n    \"ExtraDataFlags\": 177,\n    \"GamePort\": 27015,\n    \"SteamID\": 90097724371517447,\n    \"GameTags\": \" gm:darkrp\",\n    \"GameID\": 4000\n}\n"
  },
  {
    "path": "Tests/Info/gmod_cyrillic.raw",
    "content": "ffffffff4911d093d0bed180d0bed0b420d098d0bdd0bdd0bed0b2d0b0d186d0b8d0b9207c20d0a0d183d181d181d0bad0b8d0b9204461726b52500072705f62616e67636c6177006761727279736d6f64004461726b525000a00f212800646c000131352e30382e313000b1876907403c286717400120676d3a6461726b727000a00f000000000000\n"
  },
  {
    "path": "Tests/Info/hltv.json",
    "content": "{\n    \"Address\": \"192.168.1.197:27020\",\n    \"HostName\": \"Castle Mortimus:0\",\n    \"Map\": \"op4_kbase\",\n    \"ModDir\": \"gearbox\",\n    \"ModDesc\": \"HLTV\",\n    \"Players\": 0,\n    \"MaxPlayers\": 1,\n    \"Protocol\": 48,\n    \"Dedicated\": \"p\",\n    \"Os\": \"w\",\n    \"Password\": false,\n    \"IsMod\": false,\n    \"Secure\": false,\n    \"Bots\": 0\n}\n"
  },
  {
    "path": "Tests/Info/hltv.raw",
    "content": "ffffffff6d3139322e3136382e312e3139373a323730323000436173746c65204d6f7274696d75733a30006f70345f6b626173650067656172626f7800484c5456000001307077000000\n"
  },
  {
    "path": "Tests/Info/svencoop_nonsteam.json",
    "content": "{\n    \"Address\": \"127.0.0.1:27015\",\n    \"HostName\": \"ClanSC #3 - Engage [Logros]\",\n    \"Map\": \"sc_doc\",\n    \"ModDir\": \"svencoop\",\n    \"ModDesc\": \"Sven Co-op 4.8\",\n    \"Players\": 0,\n    \"MaxPlayers\": 16,\n    \"Protocol\": 47,\n    \"Dedicated\": \"d\",\n    \"Os\": \"w\",\n    \"Password\": true,\n    \"IsMod\": true,\n    \"Secure\": false,\n    \"Bots\": 0,\n    \"Mod\": {\n        \"Url\": \"\",\n        \"Download\": \"\",\n        \"Version\": 1,\n        \"Size\": 0,\n        \"ServerSide\": true,\n        \"CustomDLL\": false\n    }\n}\n"
  },
  {
    "path": "Tests/Info/svencoop_nonsteam.raw",
    "content": "ffffffff6d3132372e302e302e313a323730313500436c616e5343202333202d20456e67616765205b4c6f67726f735d0073635f646f63007376656e636f6f70005376656e20436f2d6f7020342e380000102f64770101000000010000000000000001000000\n"
  },
  {
    "path": "Tests/Info/tf2.json",
    "content": "{\n    \"Protocol\": 17,\n    \"HostName\": \" FirePowered.org | Unusual Trade | !jackpot\",\n    \"Map\": \"trade_unusual_center_v3\",\n    \"ModDir\": \"tf\",\n    \"ModDesc\": \"Unusual Trading\",\n    \"AppID\": 440,\n    \"Players\": 32,\n    \"MaxPlayers\": 32,\n    \"Bots\": 0,\n    \"Dedicated\": \"d\",\n    \"Os\": \"l\",\n    \"Password\": false,\n    \"Secure\": true,\n    \"Version\": \"3032525\",\n    \"ExtraDataFlags\": 241,\n    \"GamePort\": 27045,\n    \"SteamID\": 85568392920039468,\n    \"SpecPort\": 27050,\n    \"SpecName\": \"ScamCam\",\n    \"GameTags\": \"FirePowered,alltalk,backpack.tf,increased_maxplayers,no_ads,noads,nopinion,norespawntime,trade,trading,unusual\",\n    \"GameID\": 440\n}\n"
  },
  {
    "path": "Tests/Info/tf2.raw",
    "content": "ffffffff49112046697265506f77657265642e6f7267207c20556e757375616c205472616465207c20216a61636b706f740074726164655f756e757375616c5f63656e7465725f763300746600556e757375616c2054726164696e6700b801202000646c00013330333235323500f1a5692c00000000003001aa695363616d43616d0046697265506f77657265642c616c6c74616c6b2c6261636b7061636b2e74662c696e637265617365645f6d6178706c61796572732c6e6f5f6164732c6e6f6164732c6e6f70696e696f6e2c6e6f7265737061776e74696d652c74726164652c74726164696e672c756e757375616c00b801000000000000\n"
  },
  {
    "path": "Tests/Info/theship.json",
    "content": "{\n    \"Protocol\": 7,\n    \"HostName\": \"RKSzone.com | US Chicago | The Ship | Hunt\",\n    \"Map\": \"atalanta\",\n    \"ModDir\": \"ship\",\n    \"ModDesc\": \"The Ship\",\n    \"AppID\": 2400,\n    \"Players\": 27,\n    \"MaxPlayers\": 32,\n    \"Bots\": 16,\n    \"Dedicated\": \"d\",\n    \"Os\": \"w\",\n    \"Password\": false,\n    \"Secure\": true,\n    \"GameMode\": 0,\n    \"WitnessCount\": 2,\n    \"WitnessTime\": 5,\n    \"Version\": \"1.0.0.16\"\n}\n"
  },
  {
    "path": "Tests/Info/theship.raw",
    "content": "ffffffff4907524b537a6f6e652e636f6d207c205553204368696361676f207c205468652053686970207c2048756e74006174616c616e746100736869700054686520536869700060091b201064770001000205312e302e302e313600\n"
  },
  {
    "path": "Tests/Players/csgo.json",
    "content": "[\n    {\n        \"Id\": 0,\n        \"Name\": \"Zien\",\n        \"Frags\": 0,\n        \"Time\": 11538,\n        \"TimeF\": \"03:12:18\"\n    },\n    {\n        \"Id\": 0,\n        \"Name\": \"Ｄｏｆｆｙ\",\n        \"Frags\": 0,\n        \"Time\": 8919,\n        \"TimeF\": \"02:28:39\"\n    },\n    {\n        \"Id\": 0,\n        \"Name\": \"丶↑뮈지 这是什么鬼\",\n        \"Frags\": 0,\n        \"Time\": 8804,\n        \"TimeF\": \"02:26:44\"\n    },\n    {\n        \"Id\": 0,\n        \"Name\": \"LiGGleS\",\n        \"Frags\": 0,\n        \"Time\": 7561,\n        \"TimeF\": \"02:06:01\"\n    },\n    {\n        \"Id\": 0,\n        \"Name\": \"☣[AGC]Michael J. Caboose☣\",\n        \"Frags\": 0,\n        \"Time\": 5675,\n        \"TimeF\": \"01:34:35\"\n    },\n    {\n        \"Id\": 0,\n        \"Name\": \"decision <vancity_dv>\",\n        \"Frags\": 0,\n        \"Time\": 5339,\n        \"TimeF\": \"01:28:59\"\n    },\n    {\n        \"Id\": 0,\n        \"Name\": \"Mime ❝Matheo❞\",\n        \"Frags\": 0,\n        \"Time\": 4296,\n        \"TimeF\": \"01:11:36\"\n    },\n    {\n        \"Id\": 0,\n        \"Name\": \"Szp@n3r\",\n        \"Frags\": 0,\n        \"Time\": 3880,\n        \"TimeF\": \"01:04:40\"\n    },\n    {\n        \"Id\": 0,\n        \"Name\": \"Foxy | D:<\",\n        \"Frags\": 0,\n        \"Time\": 3746,\n        \"TimeF\": \"01:02:26\"\n    },\n    {\n        \"Id\": 0,\n        \"Name\": \"Giguli\",\n        \"Frags\": 0,\n        \"Time\": 3599,\n        \"TimeF\": \"59:59\"\n    },\n    {\n        \"Id\": 0,\n        \"Name\": \"Erkxalle\",\n        \"Frags\": 0,\n        \"Time\": 2860,\n        \"TimeF\": \"47:40\"\n    },\n    {\n        \"Id\": 0,\n        \"Name\": \"[GlobalEdgelite]DaC0p#fuckturks\",\n        \"Frags\": 0,\n        \"Time\": 2666,\n        \"TimeF\": \"44:26\"\n    },\n    {\n        \"Id\": 0,\n        \"Name\": \"Aluminiu\",\n        \"Frags\": 0,\n        \"Time\": 2634,\n        \"TimeF\": \"43:54\"\n    },\n    {\n        \"Id\": 0,\n        \"Name\": \"BlackLounge-ZombieSOAD TwinBROS\",\n        \"Frags\": 0,\n        \"Time\": 2499,\n        \"TimeF\": \"41:39\"\n    },\n    {\n        \"Id\": 0,\n        \"Name\": \"Captain Buster\",\n        \"Frags\": 0,\n        \"Time\": 2420,\n        \"TimeF\": \"40:20\"\n    },\n    {\n        \"Id\": 0,\n        \"Name\": \"thirty seven\",\n        \"Frags\": 0,\n        \"Time\": 2395,\n        \"TimeF\": \"39:55\"\n    },\n    {\n        \"Id\": 0,\n        \"Name\": \"!Bastardo!\",\n        \"Frags\": 0,\n        \"Time\": 2274,\n        \"TimeF\": \"37:54\"\n    },\n    {\n        \"Id\": 0,\n        \"Name\": \"Saibot™\",\n        \"Frags\": 0,\n        \"Time\": 2240,\n        \"TimeF\": \"37:20\"\n    },\n    {\n        \"Id\": 0,\n        \"Name\": \"OG W i l l y\",\n        \"Frags\": 0,\n        \"Time\": 2182,\n        \"TimeF\": \"36:22\"\n    },\n    {\n        \"Id\": 0,\n        \"Name\": \"TriXterR\",\n        \"Frags\": 0,\n        \"Time\": 2034,\n        \"TimeF\": \"33:54\"\n    },\n    {\n        \"Id\": 0,\n        \"Name\": \"ToadsMansion\",\n        \"Frags\": 0,\n        \"Time\": 1974,\n        \"TimeF\": \"32:54\"\n    },\n    {\n        \"Id\": 0,\n        \"Name\": \"Moxshi™\",\n        \"Frags\": 0,\n        \"Time\": 1924,\n        \"TimeF\": \"32:04\"\n    },\n    {\n        \"Id\": 0,\n        \"Name\": \"bish\",\n        \"Frags\": 0,\n        \"Time\": 1831,\n        \"TimeF\": \"30:31\"\n    },\n    {\n        \"Id\": 0,\n        \"Name\": \"Arakismo\",\n        \"Frags\": 0,\n        \"Time\": 1811,\n        \"TimeF\": \"30:11\"\n    },\n    {\n        \"Id\": 0,\n        \"Name\": \"Just_Dank\",\n        \"Frags\": 0,\n        \"Time\": 1753,\n        \"TimeF\": \"29:13\"\n    },\n    {\n        \"Id\": 0,\n        \"Name\": \"Aftersh0ck\",\n        \"Frags\": 0,\n        \"Time\": 1724,\n        \"TimeF\": \"28:44\"\n    },\n    {\n        \"Id\": 0,\n        \"Name\": \"Saibaman\",\n        \"Frags\": 0,\n        \"Time\": 1635,\n        \"TimeF\": \"27:15\"\n    },\n    {\n        \"Id\": 0,\n        \"Name\": \"The Ultimate Gamer\",\n        \"Frags\": 0,\n        \"Time\": 1610,\n        \"TimeF\": \"26:50\"\n    },\n    {\n        \"Id\": 0,\n        \"Name\": \"Butter Kaya no Peanut\",\n        \"Frags\": 0,\n        \"Time\": 1549,\n        \"TimeF\": \"25:49\"\n    },\n    {\n        \"Id\": 0,\n        \"Name\": \"Lugiia\",\n        \"Frags\": 0,\n        \"Time\": 1488,\n        \"TimeF\": \"24:48\"\n    },\n    {\n        \"Id\": 0,\n        \"Name\": \"Hoang Bao\",\n        \"Frags\": 0,\n        \"Time\": 1387,\n        \"TimeF\": \"23:07\"\n    },\n    {\n        \"Id\": 0,\n        \"Name\": \"Eldo Prezidento\",\n        \"Frags\": 0,\n        \"Time\": 1344,\n        \"TimeF\": \"22:24\"\n    },\n    {\n        \"Id\": 0,\n        \"Name\": \"Sky[C.Y.R]\",\n        \"Frags\": 0,\n        \"Time\": 1306,\n        \"TimeF\": \"21:46\"\n    },\n    {\n        \"Id\": 0,\n        \"Name\": \"PunckChop\",\n        \"Frags\": 0,\n        \"Time\": 995,\n        \"TimeF\": \"16:35\"\n    },\n    {\n        \"Id\": 0,\n        \"Name\": \"Elmoradian\",\n        \"Frags\": 0,\n        \"Time\": 968,\n        \"TimeF\": \"16:08\"\n    },\n    {\n        \"Id\": 0,\n        \"Name\": \"friendshipz\",\n        \"Frags\": 0,\n        \"Time\": 967,\n        \"TimeF\": \"16:07\"\n    },\n    {\n        \"Id\": 0,\n        \"Name\": \"Guardios\",\n        \"Frags\": 0,\n        \"Time\": 897,\n        \"TimeF\": \"14:57\"\n    },\n    {\n        \"Id\": 0,\n        \"Name\": \"Samuel Luz\",\n        \"Frags\": 0,\n        \"Time\": 779,\n        \"TimeF\": \"12:59\"\n    },\n    {\n        \"Id\": 0,\n        \"Name\": \"LordMerkx\",\n        \"Frags\": 0,\n        \"Time\": 756,\n        \"TimeF\": \"12:36\"\n    },\n    {\n        \"Id\": 0,\n        \"Name\": \"zeroyjk\",\n        \"Frags\": 0,\n        \"Time\": 698,\n        \"TimeF\": \"11:38\"\n    },\n    {\n        \"Id\": 0,\n        \"Name\": \"[yellow][@Rainbow@][blue](moon)\",\n        \"Frags\": 0,\n        \"Time\": 633,\n        \"TimeF\": \"10:33\"\n    },\n    {\n        \"Id\": 0,\n        \"Name\": \"XiaoJim(Newbie)\",\n        \"Frags\": 0,\n        \"Time\": 588,\n        \"TimeF\": \"09:48\"\n    },\n    {\n        \"Id\": 0,\n        \"Name\": \"George Costanza\",\n        \"Frags\": 0,\n        \"Time\": 568,\n        \"TimeF\": \"09:28\"\n    },\n    {\n        \"Id\": 0,\n        \"Name\": \"Boring Bob\",\n        \"Frags\": 0,\n        \"Time\": 565,\n        \"TimeF\": \"09:25\"\n    },\n    {\n        \"Id\": 0,\n        \"Name\": \"Chris\",\n        \"Frags\": 0,\n        \"Time\": 559,\n        \"TimeF\": \"09:19\"\n    },\n    {\n        \"Id\": 0,\n        \"Name\": \"NLVN\",\n        \"Frags\": 0,\n        \"Time\": 554,\n        \"TimeF\": \"09:14\"\n    },\n    {\n        \"Id\": 0,\n        \"Name\": \"Dan Rampage\",\n        \"Frags\": 0,\n        \"Time\": 518,\n        \"TimeF\": \"08:38\"\n    },\n    {\n        \"Id\": 0,\n        \"Name\": \"Kikerini\",\n        \"Frags\": 0,\n        \"Time\": 477,\n        \"TimeF\": \"07:57\"\n    },\n    {\n        \"Id\": 0,\n        \"Name\": \"waxor123\",\n        \"Frags\": 0,\n        \"Time\": 382,\n        \"TimeF\": \"06:22\"\n    },\n    {\n        \"Id\": 0,\n        \"Name\": \"Uzu\",\n        \"Frags\": 0,\n        \"Time\": 286,\n        \"TimeF\": \"04:46\"\n    },\n    {\n        \"Id\": 0,\n        \"Name\": \"chewin'_ma_BIC #FREE KAKAROT\",\n        \"Frags\": 0,\n        \"Time\": 265,\n        \"TimeF\": \"04:25\"\n    },\n    {\n        \"Id\": 0,\n        \"Name\": \"Milk Tea.\",\n        \"Frags\": 0,\n        \"Time\": 218,\n        \"TimeF\": \"03:38\"\n    },\n    {\n        \"Id\": 0,\n        \"Name\": \"Inglorious Bastard\",\n        \"Frags\": 0,\n        \"Time\": 208,\n        \"TimeF\": \"03:28\"\n    },\n    {\n        \"Id\": 0,\n        \"Name\": \"Bloody Wolf\",\n        \"Frags\": 0,\n        \"Time\": 184,\n        \"TimeF\": \"03:04\"\n    },\n    {\n        \"Id\": 0,\n        \"Name\": \"YurMum\",\n        \"Frags\": 0,\n        \"Time\": 161,\n        \"TimeF\": \"02:41\"\n    },\n    {\n        \"Id\": 0,\n        \"Name\": \"Modica\",\n        \"Frags\": 0,\n        \"Time\": 113,\n        \"TimeF\": \"01:53\"\n    },\n    {\n        \"Id\": 0,\n        \"Name\": \"[P].R.O.T.O.T.Y.P.E\",\n        \"Frags\": 0,\n        \"Time\": 109,\n        \"TimeF\": \"01:49\"\n    },\n    {\n        \"Id\": 0,\n        \"Name\": \"69@War\",\n        \"Frags\": 0,\n        \"Time\": 33,\n        \"TimeF\": \"00:33\"\n    }\n]\n"
  },
  {
    "path": "Tests/Players/csgo.raw",
    "content": "feffffffff8400000200a404ffffffff443a005a69656e0000000000d948344600efbca4efbd8fefbd86efbd86efbd9900000000007a5c0b4600e4b8b6e28691ebae88eca78020e8bf99e698afe4bb80e4b988e9acbc00000000003a920946004c6947476c655300000000005348ec4500e298a35b4147435d4d69636861656c204a2e204361626f6f7365e298a30000000000905ab145006465636973696f6e203c76616e636974795f64763e00000000004edfa645004d696d6520e29d9d4d617468656fe29d9e00000000001940864500537a70406e33720000000000898c724500466f7879207c20443a3c0000000000622c6a4500476967756c690000000000ebfb60450045726b78616c6c65000000000048c93245005b476c6f62616c456467656c6974655d4461433070236675636b7475726b73000000000087a5264500416c756d696e69750000000000c6ac244500426c61636b4c6f756e67652d5a6f6d626965534f4144205477696e42524f530000000000c6381c45004361707461696e204275737465720000000000ac4917450074686972747920736576656e00000000006eb315450021426173746172646f210000000000ed260e4500536169626f74e284a20000000000ae000c45004f4720572069206c206c20790000000000836508450054726958746572520000000000855afe4400546f6164734d616e73696f6e000000000003d1f644004d6f78736869e284a200000000000483f0440062697368000000000096efe444004172616b69736d6f00000000009769e244004a7573745f44616e6b00000000009d27db44004166746572736830636b00000000002680d7440053616962616d616e00000000009274cc440054686520556c74696d6174652047616d65720000000000934bc94400427574746572204b617961206e6f205065616e7574000000000075a0c144004c75676969610000000000fd02ba4400486f616e672042616f0000000000677aad4400456c646f205072657a6964656e746f00000000006612a84400536b795b432e592e525d0000000000e758a3440050756e636b43686f7000000000007bee784400456c6d6f72616469616e00000000008e0b724400667269656e64736869707a000000000090d37144004775617264696f7300000000008e4a60440053616d75656c204c757a0000000000cbdb4244004c6f72644d65726b780000000000c9123d44007a65726f796a6b000000000083a92e44005b79656c6c6f775d5b405261696e626f77405d5b626c75655d286d6f6f6e29000000000088401e44005869616f4a696d284e6577626965290000000000a33c13440047656f72676520436f7374616e7a610000000000af040e4400426f72696e6720426f620000000000b7600d440043687269730000000000b6fa0b44004e4c564e0000000000b0870a440044616e2052616d7061676500000000008d900144004b696b6572696e690000000000dae3ee43007761786f723132330000000000d713bf4300557a750000000000276b8f430063686577696e275f6d615f424943202346524545204b414b41524f5400000000000df78443004d696c6b205465612e00000000002a025a4300496e676c6f72696f75732042617374617264000000000052\nfeffffffff8400000201a4040e504300426c6f6f647920576f6c66000000000014583843005975724d756d0000000000f6452143004d6f64696361000000000041e7e242005b505d2e522e4f2e542e4f2e542e592e502e4500000000005db8da4200363940576172000000000018f00742\n"
  },
  {
    "path": "Tests/Rules/tf2_sourcemod.json",
    "content": "{\n    \"anti_f2p_version\": \"2.1.0\",\n    \"backpack_tf_version\": \"2.11.1A\",\n    \"backpack_viewer_version\": \"1.1.2A\",\n    \"bethehorsemann_version\": \"1.1\",\n    \"connect_method_version\": \"1.2.0A\",\n    \"connect_version\": \"1.2.0\",\n    \"coop\": \"0\",\n    \"custom_chat_colors_mysql_version\": \"1.1.3A\",\n    \"custom_chat_colors_toggle_version\": \"2.0.0A\",\n    \"custom_chat_colors_version\": \"3.1.0A\",\n    \"deathmatch\": \"1\",\n    \"decalfrequency\": \"10\",\n    \"dynamicmotd_version\": \"2.2.3s\",\n    \"enhanced_items_version\": \"1.1.0A\",\n    \"falsemessages_version\": \"3.1\",\n    \"goto_version\": \"1.2\",\n    \"impersonate_version\": \"1.5.0\",\n    \"kartify_version\": \"1.5.0A\",\n    \"local_item_server_version\": \"1.1.5A\",\n    \"metamod_version\": \"1.10.6-devV\",\n    \"mp_allowNPCs\": \"1\",\n    \"mp_autocrosshair\": \"1\",\n    \"mp_autoteambalance\": \"0\",\n    \"mp_disable_respawn_times\": \"1\",\n    \"mp_fadetoblack\": \"0\",\n    \"mp_falldamage\": \"0\",\n    \"mp_flashlight\": \"0\",\n    \"mp_footsteps\": \"1\",\n    \"mp_forceautoteam\": \"0\",\n    \"mp_forcerespawn\": \"1\",\n    \"mp_fraglimit\": \"0\",\n    \"mp_friendlyfire\": \"0\",\n    \"mp_highlander\": \"0\",\n    \"mp_holiday_nogifts\": \"0\",\n    \"mp_match_end_at_timelimit\": \"1\",\n    \"mp_maxrounds\": \"0\",\n    \"mp_respawnwavetime\": \"10.0\",\n    \"mp_scrambleteams_auto\": \"0\",\n    \"mp_scrambleteams_auto_windifference\": \"3\",\n    \"mp_stalemate_enable\": \"0\",\n    \"mp_stalemate_meleeonly\": \"0\",\n    \"mp_teamlist\": \"hgrunt;scientist\",\n    \"mp_teamplay\": \"0\",\n    \"mp_timelimit\": \"300\",\n    \"mp_tournament\": \"0\",\n    \"mp_tournament_readymode\": \"0\",\n    \"mp_tournament_readymode_countdown\": \"10\",\n    \"mp_tournament_readymode_min\": \"2\",\n    \"mp_tournament_readymode_team_size\": \"0\",\n    \"mp_tournament_stopwatch\": \"1\",\n    \"mp_weaponstay\": \"0\",\n    \"mp_windifference\": \"0\",\n    \"mp_windifference_min\": \"0\",\n    \"mp_winlimit\": \"0\",\n    \"nextlevel\": \"\",\n    \"no_enemy_in_spawn_version\": \"1.2.1A\",\n    \"player_analytics_version\": \"1.3.1A\",\n    \"rainbowize_version\": \"1.7.0A\",\n    \"rplayer_version\": \"1.1\",\n    \"r_AirboatViewDampenDamp\": \"1.0\",\n    \"r_AirboatViewDampenFreq\": \"7.0\",\n    \"r_AirboatViewZHeight\": \"0.0\",\n    \"r_JeepViewDampenDamp\": \"1.0\",\n    \"r_JeepViewDampenFreq\": \"7.0\",\n    \"r_JeepViewZHeight\": \"10.0\",\n    \"r_VehicleViewDampen\": \"1\",\n    \"sbchecker_version\": \"1.0.2\",\n    \"sb_version\": \"1.4.11\",\n    \"scp_version\": \"2.1.0A\",\n    \"setuber_version\": \"1.3\",\n    \"smdj_version\": \"2.6.1\",\n    \"sm_adminsmite_version\": \"2.1\",\n    \"sm_aimnames_version\": \"0.8\",\n    \"sm_al_version\": \"1.0\",\n    \"sm_ammopackspawner_version\": \"1.0.0\",\n    \"sm_anticolorabuse_version\": \"1.0.0\",\n    \"sm_bgod_version\": \"1.0.1\",\n    \"sm_bhs_version\": \"1.0.0\",\n    \"sm_bleed_version\": \"1.0.0\",\n    \"sm_destroy_version\": \"1.2.0\",\n    \"sm_disco_version\": \"0.3.0\",\n    \"sm_fakegifts_version\": \"1.0.1\",\n    \"sm_fakeitem_version\": \"1.3.0\",\n    \"sm_fcvar_version\": \"1.1\",\n    \"sm_fia_version\": \"2.2.4\",\n    \"sm_funcommandsx_version\": \"2.2\",\n    \"sm_godmode_version\": \"2.3.1\",\n    \"sm_healthpack_spawner_version\": \"1.0.0\",\n    \"sm_horsemann_version\": \"1.1\",\n    \"sm_merasmus_version\": \"1.4.2\",\n    \"sm_monospawn_version\": \"1.1.1\",\n    \"sm_mutecheck_version\": \"1.9.2A\",\n    \"sm_nextmap\": \"trade_unusual_center_v3\",\n    \"sm_noisemaker_version\": \"2.2.0\",\n    \"sm_powerplay_version\": \"1.5.3m\",\n    \"sm_raffle_version\": \"0.9\",\n    \"sm_regen_version\": \"1.0\",\n    \"sm_resize_version\": \"1.2.0\",\n    \"sm_rweapons_version\": \"1.3\",\n    \"sm_setammo_version\": \"1.1.0\",\n    \"sm_setclass_chat\": \"1\",\n    \"sm_setclass_log\": \"1\",\n    \"sm_setclass_version\": \"1.2.0\",\n    \"sm_setspeed_chat\": \"1\",\n    \"sm_setspeed_log\": \"1\",\n    \"sm_setspeed_version\": \"1.3.1\",\n    \"sm_shutdown_countdown_version\": \"1.6.2A\",\n    \"sm_spray_version\": \"5.8a\",\n    \"sm_stunmod_version\": \"1.4.4.7\",\n    \"sm_taunt_version\": \"0.3\",\n    \"sm_tidychat_version\": \"0.4\",\n    \"sm_traderep_version\": \"1.0.2A\",\n    \"sm_updater_version\": \"1.2.2\",\n    \"sourcecomms_version\": \"0.9.266\",\n    \"sourcemod_version\": \"1.7.3-dev+5240\",\n    \"steamrep_checker_version\": \"1.2.0A\",\n    \"steamtools_version\": \"0.9.0+d5d0838\",\n    \"stripper_version\": \"1.2.2\",\n    \"st_gamedesc_override_version\": \"1.1.3A\",\n    \"sv_accelerate\": \"10\",\n    \"sv_airaccelerate\": \"10\",\n    \"sv_alltalk\": \"1\",\n    \"sv_bounce\": \"0\",\n    \"sv_cheats\": \"0\",\n    \"sv_contact\": \"service@firepoweredgaming.com\",\n    \"sv_footsteps\": \"1\",\n    \"sv_friction\": \"4\",\n    \"sv_gravity\": \"800\",\n    \"sv_maxspeed\": \"320\",\n    \"sv_maxusrcmdprocessticks\": \"24\",\n    \"sv_noclipaccelerate\": \"5\",\n    \"sv_noclipspeed\": \"5\",\n    \"sv_password\": \"0\",\n    \"sv_pausable\": \"0\",\n    \"sv_registration_message\": \"No account specified\",\n    \"sv_registration_successful\": \"0\",\n    \"sv_rollangle\": \"0\",\n    \"sv_rollspeed\": \"200\",\n    \"sv_specaccelerate\": \"5\",\n    \"sv_specnoclip\": \"1\",\n    \"sv_specspeed\": \"3\",\n    \"sv_steamgroup\": \"\",\n    \"sv_stepsize\": \"18\",\n    \"sv_stopspeed\": \"100\",\n    \"sv_tags\": \"FirePowered,alltalk,backpack.tf,increased_maxplayers,no_ads,noads,nopinion,norespawntime,trade,trading,unusual\",\n    \"sv_voiceenable\": \"1\",\n    \"sv_vote_quorum_ratio\": \"0.6\",\n    \"sv_wateraccelerate\": \"10\",\n    \"sv_waterfriction\": \"1\",\n    \"teamswitch_version\": \"1.3\",\n    \"tf2items_giveweapon_version\": \"3.14159\",\n    \"tf2items_manager\": \"1\",\n    \"tf2items_manager_version\": \"1.4.1\",\n    \"tf2items_version\": \"1.6.2\",\n    \"tfh_aprilfools\": \"0\",\n    \"tfh_birthday\": \"1\",\n    \"tfh_enabled\": \"1\",\n    \"tfh_endoftheline\": \"0\",\n    \"tfh_fullmoon\": \"1\",\n    \"tfh_halloween\": \"0\",\n    \"tfh_normalhealth\": \"0\",\n    \"tfh_valentines\": \"0\",\n    \"tfh_version\": \"1.10.2\",\n    \"tfh_winter\": \"1\",\n    \"tf_allow_player_use\": \"0\",\n    \"tf_arena_change_limit\": \"1\",\n    \"tf_arena_first_blood\": \"1\",\n    \"tf_arena_force_class\": \"0\",\n    \"tf_arena_max_streak\": \"3\",\n    \"tf_arena_override_cap_enable_time\": \"-1\",\n    \"tf_arena_preround_time\": \"10\",\n    \"tf_arena_round_time\": \"0\",\n    \"tf_arena_use_queue\": \"1\",\n    \"tf_beta_content\": \"0\",\n    \"tf_birthday\": \"0\",\n    \"tf_bot_count\": \"0\",\n    \"tf_classlimit\": \"0\",\n    \"tf_ctf_bonus_time\": \"10\",\n    \"tf_damage_disablespread\": \"1\",\n    \"tf_force_holidays_off\": \"0\",\n    \"tf_gamemode_arena\": \"0\",\n    \"tf_gamemode_cp\": \"0\",\n    \"tf_gamemode_ctf\": \"0\",\n    \"tf_gamemode_mvm\": \"0\",\n    \"tf_gamemode_passtime\": \"0\",\n    \"tf_gamemode_payload\": \"0\",\n    \"tf_gamemode_pd\": \"0\",\n    \"tf_gamemode_rd\": \"0\",\n    \"tf_gamemode_sd\": \"0\",\n    \"tf_max_charge_speed\": \"750\",\n    \"tf_medieval\": \"0\",\n    \"tf_medieval_autorp\": \"1\",\n    \"tf_mm_servermode\": \"1\",\n    \"tf_mm_strict\": \"0\",\n    \"tf_mm_trusted\": \"0\",\n    \"tf_mvm_death_penalty\": \"0\",\n    \"tf_mvm_min_players_to_start\": \"3\",\n    \"tf_overtime_nag\": \"0\",\n    \"tf_passtime_ball_carrier_regen_dmgtime\": \"3\",\n    \"tf_passtime_ball_carrier_regen_interval\": \"1\",\n    \"tf_passtime_ball_carrier_regen_maxpct\": \"1\",\n    \"tf_passtime_ball_carrier_regen_scale\": \"0.1f\",\n    \"tf_passtime_ball_damping_scale\": \"0.01f\",\n    \"tf_passtime_ball_drag_coefficient\": \"0.01f\",\n    \"tf_passtime_ball_inertia_scale\": \"1.0f\",\n    \"tf_passtime_ball_mass\": \"1.0f\",\n    \"tf_passtime_ball_model\": \"models/passtime/ball/passtime_ball.mdl\",\n    \"tf_passtime_ball_radius\": \"7.2f\",\n    \"tf_passtime_ball_reset_time\": \"15\",\n    \"tf_passtime_ball_rotdamping_scale\": \"1.0f\",\n    \"tf_passtime_ball_seek_range\": \"128\",\n    \"tf_passtime_ball_seek_speed_factor\": \"1.5f\",\n    \"tf_passtime_ball_takedamage\": \"1\",\n    \"tf_passtime_ball_takedamage_force\": \"800.0f\",\n    \"tf_passtime_flinch_boost\": \"0\",\n    \"tf_passtime_mode_homing_lock_sec\": \"1.5f\",\n    \"tf_passtime_mode_homing_speed\": \"1000.0f\",\n    \"tf_passtime_player_reticles_enemies\": \"1\",\n    \"tf_passtime_player_reticles_friends\": \"2\",\n    \"tf_passtime_score_crit_sec\": \"5.0f\",\n    \"tf_passtime_speedboost_on_get_ball_time\": \"2.0f\",\n    \"tf_passtime_steal_on_melee\": \"1\",\n    \"tf_passtime_teammate_steal_time\": \"45\",\n    \"tf_passtime_throwarc_demoman\": \"0.3f\",\n    \"tf_passtime_throwarc_engineer\": \"0.3f\",\n    \"tf_passtime_throwarc_heavy\": \"0.3f\",\n    \"tf_passtime_throwarc_medic\": \"0.3f\",\n    \"tf_passtime_throwarc_pyro\": \"0.3f\",\n    \"tf_passtime_throwarc_scout\": \"0.3f\",\n    \"tf_passtime_throwarc_sniper\": \"0.3f\",\n    \"tf_passtime_throwarc_soldier\": \"0.3f\",\n    \"tf_passtime_throwarc_spy\": \"0.3f\",\n    \"tf_passtime_throwspeed_demoman\": \"1000.0f\",\n    \"tf_passtime_throwspeed_engineer\": \"1000.0f\",\n    \"tf_passtime_throwspeed_heavy\": \"1000.0f\",\n    \"tf_passtime_throwspeed_medic\": \"1000.0f\",\n    \"tf_passtime_throwspeed_pyro\": \"1000.0f\",\n    \"tf_passtime_throwspeed_scout\": \"1000.0f\",\n    \"tf_passtime_throwspeed_sniper\": \"1000.0f\",\n    \"tf_passtime_throwspeed_soldier\": \"1000.0f\",\n    \"tf_passtime_throwspeed_spy\": \"1000.0f\",\n    \"tf_passtime_throwspeed_velocity_scale\": \"0\",\n    \"tf_playergib\": \"1\",\n    \"tf_player_name_change_time\": \"60\",\n    \"tf_powerup_mode\": \"0\",\n    \"tf_server_identity_disable_quickplay\": \"0\",\n    \"tf_spec_xray\": \"1\",\n    \"tf_spells_enabled\": \"0\",\n    \"tf_teamtalk\": \"1\",\n    \"tf_use_fixed_weaponspreads\": \"0\",\n    \"tf_weapon_criticals\": \"1\",\n    \"tf_weapon_criticals_melee\": \"1\",\n    \"thirdperson_version\": \"2.1.0\",\n    \"tidykick_version\": \"1.1.5A\",\n    \"tv_enable\": \"1\",\n    \"tv_password\": \"1\",\n    \"tv_relaypassword\": \"0\",\n    \"uberpunisher_version\": \"1.5.2\",\n    \"ufov_version\": \"1.2.0A\",\n    \"voiceannounce_ex_version\": \"2.0.0\",\n    \"votekick_switcher_version\": \"1.3.0A\"\n}\n"
  },
  {
    "path": "Tests/Rules/tf2_sourcemod.raw",
    "content": "feffffff570100000600e004ffffffff450501616e74695f6632705f76657273696f6e00322e312e30006261636b7061636b5f74665f76657273696f6e00322e31312e3141006261636b7061636b5f7669657765725f76657273696f6e00312e312e3241006265746865686f7273656d616e6e5f76657273696f6e00312e3100636f6e6e6563745f6d6574686f645f76657273696f6e00312e322e304100636f6e6e6563745f76657273696f6e00312e322e3000636f6f70003000637573746f6d5f636861745f636f6c6f72735f6d7973716c5f76657273696f6e00312e312e334100637573746f6d5f636861745f636f6c6f72735f746f67676c655f76657273696f6e00322e302e304100637573746f6d5f636861745f636f6c6f72735f76657273696f6e00332e312e30410064656174686d61746368003100646563616c6672657175656e63790031300064796e616d69636d6f74645f76657273696f6e00322e322e337300656e68616e6365645f6974656d735f76657273696f6e00312e312e30410066616c73656d657373616765735f76657273696f6e00332e3100676f746f5f76657273696f6e00312e3200696d706572736f6e6174655f76657273696f6e00312e352e30006b6172746966795f76657273696f6e00312e352e3041006c6f63616c5f6974656d5f7365727665725f76657273696f6e00312e312e3541006d6574616d6f645f76657273696f6e00312e31302e362d64657656006d705f616c6c6f774e5043730031006d705f6175746f63726f7373686169720031006d705f6175746f7465616d62616c616e63650030006d705f64697361626c655f7265737061776e5f74696d65730031006d705f66616465746f626c61636b0030006d705f66616c6c64616d6167650030006d705f666c6173686c696768740030006d705f666f6f7473746570730031006d705f666f7263656175746f7465616d0030006d705f666f7263657265737061776e0031006d705f667261676c696d69740030006d705f667269656e646c79666972650030006d705f686967686c616e6465720030006d705f686f6c696461795f6e6f67696674730030006d705f6d617463685f656e645f61745f74696d656c696d69740031006d705f6d6178726f756e64730030006d705f7265737061776e7761766574696d650031302e30006d705f736372616d626c657465616d735f6175746f0030006d705f736372616d626c657465616d735f6175746f5f77696e646966666572656e63650033006d705f7374616c656d6174655f656e61626c650030006d705f7374616c656d6174655f6d656c65656f6e6c790030006d705f7465616d6c69737400686772756e743b736369656e74697374006d705f7465616d706c61790030006d705f74696d656c696d697400333030006d705f746f75726e616d656e740030006d705f746f75726e616d656e745f72656164796d6f64650030006d705f746f75726e616d656e745f72656164796d6f64655f636f756e74646f776e003130006d705f746f75726e616d656e745f72656164796d6f64655f6d696e0032006d705f746f75726e616d656e745f72656164796d6f64655f7465616d5f73697a650030006d705f746f75726e616d656e745f73746f7077617463680031006d705f776561706f6e737461790030006d705f77696e646966666572656e63650030006d705f77696e646966666572656e63655f6d696e0030\nfeffffff570100000601e004006d705f77696e6c696d69740030006e6578746c6576656c00006e6f5f656e656d795f696e5f737061776e5f76657273696f6e00312e322e314100706c617965725f616e616c79746963735f76657273696f6e00312e332e3141007261696e626f77697a655f76657273696f6e00312e372e30410072706c617965725f76657273696f6e00312e3100725f416972626f61745669657744616d70656e44616d7000312e3000725f416972626f61745669657744616d70656e4672657100372e3000725f416972626f6174566965775a48656967687400302e3000725f4a6565705669657744616d70656e44616d7000312e3000725f4a6565705669657744616d70656e4672657100372e3000725f4a656570566965775a4865696768740031302e3000725f56656869636c655669657744616d70656e0031007362636865636b65725f76657273696f6e00312e302e320073625f76657273696f6e00312e342e3131007363705f76657273696f6e00322e312e304100736574756265725f76657273696f6e00312e3300736d646a5f76657273696f6e00322e362e3100736d5f61646d696e736d6974655f76657273696f6e00322e3100736d5f61696d6e616d65735f76657273696f6e00302e3800736d5f616c5f76657273696f6e00312e3000736d5f616d6d6f7061636b737061776e65725f76657273696f6e00312e302e3000736d5f616e7469636f6c6f7261627573655f76657273696f6e00312e302e3000736d5f62676f645f76657273696f6e00312e302e3100736d5f6268735f76657273696f6e00312e302e3000736d5f626c6565645f76657273696f6e00312e302e3000736d5f64657374726f795f76657273696f6e00312e322e3000736d5f646973636f5f76657273696f6e00302e332e3000736d5f66616b6567696674735f76657273696f6e00312e302e3100736d5f66616b656974656d5f76657273696f6e00312e332e3000736d5f66637661725f76657273696f6e00312e3100736d5f6669615f76657273696f6e00322e322e3400736d5f66756e636f6d6d616e6473785f76657273696f6e00322e3200736d5f676f646d6f64655f76657273696f6e00322e332e3100736d5f6865616c74687061636b5f737061776e65725f76657273696f6e00312e302e3000736d5f686f7273656d616e6e5f76657273696f6e00312e3100736d5f6d657261736d75735f76657273696f6e00312e342e3200736d5f6d6f6e6f737061776e5f76657273696f6e00312e312e3100736d5f6d757465636865636b5f76657273696f6e00312e392e324100736d5f6e6578746d61700074726164655f756e757375616c5f63656e7465725f763300736d5f6e6f6973656d616b65725f76657273696f6e00322e322e3000736d5f706f776572706c61795f76657273696f6e00312e352e336d00736d5f726166666c655f76657273696f6e00302e3900736d5f726567656e5f76657273696f6e00312e3000736d5f726573697a655f76657273696f6e00312e322e3000736d5f72776561706f6e735f76657273696f6e00312e3300736d5f736574616d6d6f5f76657273696f6e00312e312e3000736d5f736574636c6173735f63686174003100736d5f736574636c6173735f6c6f67003100736d5f736574636c6173735f76657273696f6e00312e322e3000736d5f73657473706565645f63686174003100736d5f736574737065\nfeffffff570100000602e00465645f6c6f67003100736d5f73657473706565645f76657273696f6e00312e332e3100736d5f73687574646f776e5f636f756e74646f776e5f76657273696f6e00312e362e324100736d5f73707261795f76657273696f6e00352e386100736d5f7374756e6d6f645f76657273696f6e00312e342e342e3700736d5f7461756e745f76657273696f6e00302e3300736d5f74696479636861745f76657273696f6e00302e3400736d5f74726164657265705f76657273696f6e00312e302e324100736d5f757064617465725f76657273696f6e00312e322e3200736f75726365636f6d6d735f76657273696f6e00302e392e32363600736f757263656d6f645f76657273696f6e00312e372e332d6465762b3532343000737465616d7265705f636865636b65725f76657273696f6e00312e322e304100737465616d746f6f6c735f76657273696f6e00302e392e302b643564303833380073747269707065725f76657273696f6e00312e322e320073745f67616d65646573635f6f766572726964655f76657273696f6e00312e312e33410073765f616363656c65726174650031300073765f616972616363656c65726174650031300073765f616c6c74616c6b00310073765f626f756e636500300073765f63686561747300300073765f636f6e7461637400736572766963654066697265706f776572656467616d696e672e636f6d0073765f666f6f74737465707300310073765f6672696374696f6e00340073765f67726176697479003830300073765f6d61787370656564003332300073765f6d6178757372636d6470726f636573737469636b730032340073765f6e6f636c6970616363656c657261746500350073765f6e6f636c6970737065656400350073765f70617373776f726400300073765f7061757361626c6500300073765f726567697374726174696f6e5f6d657373616765004e6f206163636f756e74207370656369666965640073765f726567697374726174696f6e5f7375636365737366756c00300073765f726f6c6c616e676c6500300073765f726f6c6c7370656564003230300073765f73706563616363656c657261746500350073765f737065636e6f636c697000310073765f73706563737065656400330073765f737465616d67726f7570000073765f7374657073697a650031380073765f73746f707370656564003130300073765f746167730046697265506f77657265642c616c6c74616c6b2c6261636b7061636b2e74662c696e637265617365645f6d6178706c61796572732c6e6f5f6164732c6e6f6164732c6e6f70696e696f6e2c6e6f7265737061776e74696d652c74726164652c74726164696e672c756e757375616c0073765f766f696365656e61626c6500310073765f766f74655f71756f72756d5f726174696f00302e360073765f7761746572616363656c65726174650031300073765f77617465726672696374696f6e0031007465616d7377697463685f76657273696f6e00312e33007466326974656d735f67697665776561706f6e5f76657273696f6e00332e3134313539007466326974656d735f6d616e616765720031007466326974656d735f6d616e616765725f76657273696f6e00312e342e31007466326974656d735f76657273696f6e00312e362e32007466685f617072696c666f6f6c730030007466685f62697274686461790031007466685f65\nfeffffff570100000603e0046e61626c65640031007466685f656e646f667468656c696e650030007466685f66756c6c6d6f6f6e0031007466685f68616c6c6f7765656e0030007466685f6e6f726d616c6865616c74680030007466685f76616c656e74696e65730030007466685f76657273696f6e00312e31302e32007466685f77696e74657200310074665f616c6c6f775f706c617965725f75736500300074665f6172656e615f6368616e67655f6c696d697400310074665f6172656e615f66697273745f626c6f6f6400310074665f6172656e615f666f7263655f636c61737300300074665f6172656e615f6d61785f73747265616b00330074665f6172656e615f6f766572726964655f6361705f656e61626c655f74696d65002d310074665f6172656e615f707265726f756e645f74696d650031300074665f6172656e615f726f756e645f74696d6500300074665f6172656e615f7573655f717565756500310074665f626574615f636f6e74656e7400300074665f626972746864617900300074665f626f745f636f756e7400300074665f636c6173736c696d697400300074665f6374665f626f6e75735f74696d650031300074665f64616d6167655f64697361626c6573707265616400310074665f666f7263655f686f6c69646179735f6f666600300074665f67616d656d6f64655f6172656e6100300074665f67616d656d6f64655f637000300074665f67616d656d6f64655f63746600300074665f67616d656d6f64655f6d766d00300074665f67616d656d6f64655f7061737374696d6500300074665f67616d656d6f64655f7061796c6f616400300074665f67616d656d6f64655f706400300074665f67616d656d6f64655f726400300074665f67616d656d6f64655f736400300074665f6d61785f6368617267655f7370656564003735300074665f6d6564696576616c00300074665f6d6564696576616c5f6175746f727000310074665f6d6d5f7365727665726d6f646500310074665f6d6d5f73747269637400300074665f6d6d5f7472757374656400300074665f6d766d5f64656174685f70656e616c747900300074665f6d766d5f6d696e5f706c61796572735f746f5f737461727400330074665f6f76657274696d655f6e616700300074665f7061737374696d655f62616c6c5f636172726965725f726567656e5f646d6774696d6500330074665f7061737374696d655f62616c6c5f636172726965725f726567656e5f696e74657276616c00310074665f7061737374696d655f62616c6c5f636172726965725f726567656e5f6d617870637400310074665f7061737374696d655f62616c6c5f636172726965725f726567656e5f7363616c6500302e31660074665f7061737374696d655f62616c6c5f64616d70696e675f7363616c6500302e3031660074665f7061737374696d655f62616c6c5f647261675f636f656666696369656e7400302e3031660074665f7061737374696d655f62616c6c5f696e65727469615f7363616c6500312e30660074665f7061737374696d655f62616c6c5f6d61737300312e30660074665f7061737374696d655f62616c6c5f6d6f64656c006d6f64656c732f7061737374696d652f62616c6c2f7061737374696d655f62616c6c2e6d646c0074665f7061737374696d655f62616c6c5f72616469757300372e32660074665f7061737374696d655f62616c6c5f7265736574\nfeffffff570100000604e0045f74696d650031350074665f7061737374696d655f62616c6c5f726f7464616d70696e675f7363616c6500312e30660074665f7061737374696d655f62616c6c5f7365656b5f72616e6765003132380074665f7061737374696d655f62616c6c5f7365656b5f73706565645f666163746f7200312e35660074665f7061737374696d655f62616c6c5f74616b6564616d61676500310074665f7061737374696d655f62616c6c5f74616b6564616d6167655f666f726365003830302e30660074665f7061737374696d655f666c696e63685f626f6f737400300074665f7061737374696d655f6d6f64655f686f6d696e675f6c6f636b5f73656300312e35660074665f7061737374696d655f6d6f64655f686f6d696e675f737065656400313030302e30660074665f7061737374696d655f706c617965725f72657469636c65735f656e656d69657300310074665f7061737374696d655f706c617965725f72657469636c65735f667269656e647300320074665f7061737374696d655f73636f72655f637269745f73656300352e30660074665f7061737374696d655f7370656564626f6f73745f6f6e5f6765745f62616c6c5f74696d6500322e30660074665f7061737374696d655f737465616c5f6f6e5f6d656c656500310074665f7061737374696d655f7465616d6d6174655f737465616c5f74696d650034350074665f7061737374696d655f7468726f776172635f64656d6f6d616e00302e33660074665f7061737374696d655f7468726f776172635f656e67696e65657200302e33660074665f7061737374696d655f7468726f776172635f686561767900302e33660074665f7061737374696d655f7468726f776172635f6d6564696300302e33660074665f7061737374696d655f7468726f776172635f7079726f00302e33660074665f7061737374696d655f7468726f776172635f73636f757400302e33660074665f7061737374696d655f7468726f776172635f736e6970657200302e33660074665f7061737374696d655f7468726f776172635f736f6c6469657200302e33660074665f7061737374696d655f7468726f776172635f73707900302e33660074665f7061737374696d655f7468726f7773706565645f64656d6f6d616e00313030302e30660074665f7061737374696d655f7468726f7773706565645f656e67696e65657200313030302e30660074665f7061737374696d655f7468726f7773706565645f686561767900313030302e30660074665f7061737374696d655f7468726f7773706565645f6d6564696300313030302e30660074665f7061737374696d655f7468726f7773706565645f7079726f00313030302e30660074665f7061737374696d655f7468726f7773706565645f73636f757400313030302e30660074665f7061737374696d655f7468726f7773706565645f736e6970657200313030302e30660074665f7061737374696d655f7468726f7773706565645f736f6c6469657200313030302e30660074665f7061737374696d655f7468726f7773706565645f73707900313030302e30660074665f7061737374696d655f7468726f7773706565645f76656c6f636974795f7363616c6500300074665f706c6179657267696200310074665f706c617965725f6e616d655f6368616e67655f74696d650036300074665f706f77657275705f6d6f646500300074665f\nfeffffff570100000605e0047365727665725f6964656e746974795f64697361626c655f717569636b706c617900300074665f737065635f7872617900310074665f7370656c6c735f656e61626c656400300074665f7465616d74616c6b00310074665f7573655f66697865645f776561706f6e7370726561647300300074665f776561706f6e5f637269746963616c7300310074665f776561706f6e5f637269746963616c735f6d656c65650031007468697264706572736f6e5f76657273696f6e00322e312e3000746964796b69636b5f76657273696f6e00312e312e35410074765f656e61626c6500310074765f70617373776f726400310074765f72656c617970617373776f72640030007562657270756e69736865725f76657273696f6e00312e352e320075666f765f76657273696f6e00312e322e304100766f696365616e6e6f756e63655f65785f76657273696f6e00322e302e3000766f74656b69636b5f73776974636865725f76657273696f6e00312e332e304100\n"
  },
  {
    "path": "Tests/Tests.php",
    "content": "<?php\ndeclare(strict_types=1);\n\n\tuse PHPUnit\\Framework\\Attributes\\DataProvider;\n\tuse xPaw\\SourceQuery\\BaseSocket;\n\tuse xPaw\\SourceQuery\\SourceQuery;\n\tuse xPaw\\SourceQuery\\Buffer;\n\n\tclass TestableSocket extends BaseSocket\n\t{\n\t\t/** @var \\SplQueue<string> */\n\t\tprivate \\SplQueue $PacketQueue;\n\n\t\tpublic function __construct( )\n\t\t{\n\t\t\t$this->PacketQueue = new \\SplQueue();\n\t\t\t$this->PacketQueue->setIteratorMode( \\SplDoublyLinkedList::IT_MODE_DELETE );\n\n\t\t}\n\n\t\tpublic function Queue( string $Data ) : void\n\t\t{\n\t\t\t$this->PacketQueue->push( $Data );\n\t\t}\n\n\t\tpublic function Close( ) : void\n\t\t{\n\t\t\t//\n\t\t}\n\n\t\tpublic function Open( string $Address, int $Port, int $Timeout, int $Engine ) : void\n\t\t{\n\t\t\t$this->Timeout = $Timeout;\n\t\t\t$this->Engine  = $Engine;\n\t\t\t$this->Port    = $Port;\n\t\t\t$this->Address = $Address;\n\t\t}\n\n\t\tpublic function Write( int $Header, string $String = '' ) : bool\n\t\t{\n\t\t\treturn true;\n\t\t}\n\n\t\tpublic function Read( ) : Buffer\n\t\t{\n\t\t\t$Buffer = new Buffer( );\n\t\t\t$Buffer->Set( $this->PacketQueue->shift() );\n\n\t\t\t$this->ReadInternal( $Buffer, [ $this, 'Sherlock' ] );\n\n\t\t\treturn $Buffer;\n\t\t}\n\n\t\tpublic function Sherlock( Buffer $Buffer ) : bool\n\t\t{\n\t\t\tif( $this->PacketQueue->isEmpty() )\n\t\t\t{\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t$Buffer->Set( $this->PacketQueue->shift() );\n\n\t\t\treturn $Buffer->ReadInt32( ) === -2;\n\t\t}\n\t}\n\n\tclass Tests extends \\PHPUnit\\Framework\\TestCase\n\t{\n\t\tprivate TestableSocket $Socket;\n\t\tprivate SourceQuery $SourceQuery;\n\n\t\tpublic function setUp() : void\n\t\t{\n\t\t\t$this->Socket = new TestableSocket();\n\t\t\t$this->SourceQuery = new SourceQuery( $this->Socket );\n\t\t\t$this->SourceQuery->Connect( '', 2 );\n\t\t}\n\n\t\tpublic function tearDown() : void\n\t\t{\n\t\t\t$this->SourceQuery->Disconnect();\n\n\t\t\tunset( $this->Socket, $this->SourceQuery );\n\t\t}\n\n\t\tpublic function testInvalidTimeout() : void\n\t\t{\n\t\t\t$this->expectException( xPaw\\SourceQuery\\Exception\\InvalidArgumentException::class );\n\t\t\t$SourceQuery = new SourceQuery( );\n\t\t\t$SourceQuery->Connect( '', 2, -1 );\n\t\t}\n\n\t\tpublic function testNotConnectedGetInfo() : void\n\t\t{\n\t\t\t$this->expectException( xPaw\\SourceQuery\\Exception\\SocketException::class );\n\t\t\t$this->SourceQuery->Disconnect();\n\t\t\t$this->SourceQuery->GetInfo();\n\t\t}\n\n\t\tpublic function testNotConnectedPing() : void\n\t\t{\n\t\t\t$this->expectException( xPaw\\SourceQuery\\Exception\\SocketException::class );\n\t\t\t$this->SourceQuery->Disconnect();\n\t\t\t$this->SourceQuery->Ping();\n\t\t}\n\n\t\tpublic function testNotConnectedGetPlayers() : void\n\t\t{\n\t\t\t$this->expectException( xPaw\\SourceQuery\\Exception\\SocketException::class );\n\t\t\t$this->SourceQuery->Disconnect();\n\t\t\t$this->SourceQuery->GetPlayers();\n\t\t}\n\n\t\tpublic function testNotConnectedGetRules() : void\n\t\t{\n\t\t\t$this->expectException( xPaw\\SourceQuery\\Exception\\SocketException::class );\n\t\t\t$this->SourceQuery->Disconnect();\n\t\t\t$this->SourceQuery->GetRules();\n\t\t}\n\n\t\tpublic function testNotConnectedSetRconPassword() : void\n\t\t{\n\t\t\t$this->expectException( xPaw\\SourceQuery\\Exception\\SocketException::class );\n\t\t\t$this->SourceQuery->Disconnect();\n\t\t\t$this->SourceQuery->SetRconPassword('a');\n\t\t}\n\n\t\tpublic function testNotConnectedRcon() : void\n\t\t{\n\t\t\t$this->expectException( xPaw\\SourceQuery\\Exception\\SocketException::class );\n\t\t\t$this->SourceQuery->Disconnect();\n\t\t\t$this->SourceQuery->Rcon('a');\n\t\t}\n\n\t\tpublic function testRconWithoutPassword() : void\n\t\t{\n\t\t\t$this->expectException( xPaw\\SourceQuery\\Exception\\SocketException::class );\n\t\t\t$this->SourceQuery->Rcon('a');\n\t\t}\n\n\t\t#[DataProvider( 'InfoProvider' )]\n\t\tpublic function testGetInfo( string $RawInput, array $ExpectedOutput ) : void\n\t\t{\n\t\t\tif( isset( $ExpectedOutput[ 'IsMod' ] ) )\n\t\t\t{\n\t\t\t\t$this->Socket->Engine = SourceQuery::GOLDSOURCE;\n\t\t\t}\n\n\t\t\t$this->Socket->Queue( $RawInput );\n\n\t\t\t$RealOutput = $this->SourceQuery->GetInfo();\n\n\t\t\tself::assertEquals( $ExpectedOutput, $RealOutput );\n\t\t}\n\n\t\tpublic static function InfoProvider() : array\n\t\t{\n\t\t\t$DataProvider = [];\n\n\t\t\t$Files = glob( __DIR__ . '/Info/*.raw', GLOB_ERR );\n\n\t\t\tif( $Files === false )\n\t\t\t{\n\t\t\t\tthrow new Exception();\n\t\t\t}\n\n\t\t\tforeach( $Files as $File )\n\t\t\t{\n\t\t\t\t$DataProvider[] =\n\t\t\t\t[\n\t\t\t\t\thex2bin( trim( (string)file_get_contents( $File ) ) ),\n\t\t\t\t\tjson_decode( (string)file_get_contents( str_replace( '.raw', '.json', $File ) ), true )\n\t\t\t\t];\n\t\t\t}\n\n\t\t\treturn $DataProvider;\n\t\t}\n\n\t\t#[DataProvider( 'BadPacketProvider' )]\n\t\tpublic function testBadGetInfo( string $Data ) : void\n\t\t{\n\t\t\t$this->expectException( xPaw\\SourceQuery\\Exception\\InvalidPacketException::class );\n\t\t\t$this->Socket->Queue( $Data );\n\n\t\t\t$this->SourceQuery->GetInfo();\n\t\t}\n\n\t\t#[DataProvider( 'BadPacketProvider' )]\n\t\tpublic function testBadGetChallengeViaPlayers( string $Data ) : void\n\t\t{\n\t\t\t$this->expectException( xPaw\\SourceQuery\\Exception\\InvalidPacketException::class );\n\t\t\t$this->Socket->Queue( $Data );\n\n\t\t\t$this->SourceQuery->GetPlayers();\n\t\t}\n\n\t\t#[DataProvider( 'BadPacketProvider' )]\n\t\tpublic function testBadGetPlayersAfterCorrectChallenge( string $Data ) : void\n\t\t{\n\t\t\t$this->expectException( xPaw\\SourceQuery\\Exception\\InvalidPacketException::class );\n\t\t\t$this->Socket->Queue( \"\\xFF\\xFF\\xFF\\xFF\\x41\\x11\\x11\\x11\\x11\" );\n\t\t\t$this->Socket->Queue( $Data );\n\n\t\t\t$this->SourceQuery->GetPlayers();\n\t\t}\n\n\t\t#[DataProvider( 'BadPacketProvider' )]\n\t\tpublic function testBadGetRulesAfterCorrectChallenge( string $Data ) : void\n\t\t{\n\t\t\t$this->expectException( xPaw\\SourceQuery\\Exception\\InvalidPacketException::class );\n\t\t\t$this->Socket->Queue( \"\\xFF\\xFF\\xFF\\xFF\\x41\\x11\\x11\\x11\\x11\" );\n\t\t\t$this->Socket->Queue( $Data );\n\n\t\t\t$this->SourceQuery->GetRules();\n\t\t}\n\n\t\tpublic static function BadPacketProvider( ) : array\n\t\t{\n\t\t\treturn\n\t\t\t[\n\t\t\t\t[ \"\" ],\n\t\t\t\t[ \"\\xff\\xff\\xff\\xff\" ], // No type\n\t\t\t\t[ \"\\xff\\xff\\xff\\xff\\x49\" ], // Correct type, but no data after\n\t\t\t\t[ \"\\xff\\xff\\xff\\xff\\x6D\" ], // Old info packet, but tests are done for source\n\t\t\t\t[ \"\\xff\\xff\\xff\\xff\\x11\" ], // Wrong type\n\t\t\t\t[ \"\\x11\\x11\\x11\\x11\" ], // Wrong header\n\t\t\t\t[ \"\\xff\" ], // Should be 4 bytes, but it's 1\n\t\t\t];\n\t\t}\n\n\t\tpublic function testGetChallengeTwice( ) : void\n\t\t{\n\t\t\t$this->Socket->Queue( \"\\xFF\\xFF\\xFF\\xFF\\x41\\x11\\x11\\x11\\x11\" );\n\t\t\t$this->Socket->Queue( \"\\xFF\\xFF\\xFF\\xFF\\x45\\x01\\x00ayy\\x00lmao\\x00\" );\n\t\t\tself::assertEquals( [ 'ayy' => 'lmao' ], $this->SourceQuery->GetRules() );\n\n\t\t\t$this->Socket->Queue( \"\\xFF\\xFF\\xFF\\xFF\\x45\\x01\\x00wow\\x00much\\x00\" );\n\t\t\tself::assertEquals( [ 'wow' => 'much' ], $this->SourceQuery->GetRules() );\n\t\t}\n\n\t\t/** @param array<string> $RawInput */\n\t\t#[DataProvider( 'RulesProvider' )]\n\t\tpublic function testGetRules( array $RawInput, array $ExpectedOutput ) : void\n\t\t{\n\t\t\t$this->Socket->Queue( (string)hex2bin( \"ffffffff4104fce20e\" ) ); // Challenge\n\n\t\t\tforeach( $RawInput as $Packet )\n\t\t\t{\n\t\t\t\t$this->Socket->Queue( (string)hex2bin( $Packet ) );\n\t\t\t}\n\n\t\t\t$RealOutput = $this->SourceQuery->GetRules();\n\n\t\t\tself::assertEquals( $ExpectedOutput, $RealOutput );\n\t\t}\n\n\t\tpublic static function RulesProvider() : array\n\t\t{\n\t\t\t$DataProvider = [];\n\n\t\t\t$Files = glob( __DIR__ . '/Rules/*.raw', GLOB_ERR );\n\n\t\t\tif( $Files === false )\n\t\t\t{\n\t\t\t\tthrow new Exception();\n\t\t\t}\n\n\t\t\tforeach( $Files as $File )\n\t\t\t{\n\t\t\t\t$DataProvider[] =\n\t\t\t\t[\n\t\t\t\t\tfile( $File, FILE_SKIP_EMPTY_LINES | FILE_IGNORE_NEW_LINES ),\n\t\t\t\t\tjson_decode( (string)file_get_contents( str_replace( '.raw', '.json', $File ) ), true )\n\t\t\t\t];\n\t\t\t}\n\n\t\t\treturn $DataProvider;\n\t\t}\n\n\t\t/** @param array<string> $RawInput */\n\t\t#[DataProvider( 'PlayersProvider' )]\n\t\tpublic function testGetPlayers( array $RawInput, array $ExpectedOutput ) : void\n\t\t{\n\t\t\t$this->Socket->Queue( (string)hex2bin( \"ffffffff4104fce20e\" ) ); // Challenge\n\n\t\t\tforeach( $RawInput as $Packet )\n\t\t\t{\n\t\t\t\t$this->Socket->Queue( (string)hex2bin( $Packet ) );\n\t\t\t}\n\n\t\t\t$RealOutput = $this->SourceQuery->GetPlayers();\n\n\t\t\tself::assertEquals( $ExpectedOutput, $RealOutput );\n\t\t}\n\n\t\tpublic static function PlayersProvider() : array\n\t\t{\n\t\t\t$DataProvider = [];\n\n\t\t\t$Files = glob( __DIR__ . '/Players/*.raw', GLOB_ERR );\n\n\t\t\tif( $Files === false )\n\t\t\t{\n\t\t\t\tthrow new Exception();\n\t\t\t}\n\n\t\t\tforeach( $Files as $File )\n\t\t\t{\n\t\t\t\t$DataProvider[] =\n\t\t\t\t[\n\t\t\t\t\tfile( $File, FILE_SKIP_EMPTY_LINES | FILE_IGNORE_NEW_LINES ),\n\t\t\t\t\tjson_decode( (string)file_get_contents( str_replace( '.raw', '.json', $File ) ), true )\n\t\t\t\t];\n\t\t\t}\n\n\t\t\treturn $DataProvider;\n\t\t}\n\n\t\tpublic function testPing() : void\n\t\t{\n\t\t\t$this->Socket->Queue( \"\\xFF\\xFF\\xFF\\xFF\\x6A\\x00\");\n\t\t\tself::assertTrue( $this->SourceQuery->Ping() );\n\n\t\t\t$this->Socket->Queue( \"\\xFF\\xFF\\xFF\\xFF\\xEE\");\n\t\t\tself::assertFalse( $this->SourceQuery->Ping() );\n\t\t}\n\t}\n"
  },
  {
    "path": "Tests/phpunit.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<phpunit xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" colors=\"true\" xsi:noNamespaceSchemaLocation=\"https://schema.phpunit.de/12.0/phpunit.xsd\" cacheDirectory=\".phpunit.cache\">\n  <testsuites>\n    <testsuite name=\"Tests\">\n      <file>./Tests.php</file>\n    </testsuite>\n  </testsuites>\n  <source>\n    <include>\n      <directory suffix=\".php\">../SourceQuery</directory>\n    </include>\n  </source>\n</phpunit>\n"
  },
  {
    "path": "composer.json",
    "content": "{\n\t\"name\": \"xpaw/php-source-query-class\",\n\t\"description\": \"PHP library to query and send RCON commands to servers based on \\\"Source Engine Query\\\" protocol\",\n\t\"homepage\": \"https://github.com/xPaw/PHP-Source-Query\",\n\t\"type\": \"library\",\n\t\"license\": \"LGPL-2.1\",\n\t\"funding\": [\n        {\n            \"type\": \"github\",\n            \"url\": \"https://github.com/sponsors/xPaw\"\n        }\n\t],\n\t\"keywords\":\n\t[\n\t\t\"rcon\",\n\t\t\"minecraft\",\n\t\t\"csgo\",\n\t\t\"counter-strike\",\n\t\t\"team fortress\",\n\t\t\"starbound\",\n\t\t\"rust\",\n\t\t\"ark\",\n\t\t\"gmod\"\n\t],\n\t\"scripts\":\n\t{\n\t\t\"test\":\n\t\t[\n\t\t\t\"@phpunit\",\n\t\t\t\"@phpstan\"\n\t\t],\n\t\t\"phpunit\": \"phpunit --configuration Tests/phpunit.xml --fail-on-warning\",\n\t\t\"phpunit:coverage\": \"phpunit --configuration Tests/phpunit.xml --fail-on-warning --coverage-clover build/logs/clover.xml\",\n\t\t\"phpstan\": \"phpstan\"\n\t},\n\t\"require\":\n\t{\n\t\t\"php\": \">=8.3\"\n\t},\n\t\"require-dev\":\n\t{\n\t\t\"phpunit/phpunit\": \"^12.0\",\n\t\t\"phpstan/phpstan\": \"^2.0\",\n\t\t\"phpstan/phpstan-strict-rules\": \"^2.0\"\n\t},\n\t\"autoload\":\n\t{\n\t\t\"psr-4\":\n\t\t{\n\t\t\t\"xPaw\\\\SourceQuery\\\\\": \"SourceQuery/\"\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "phpstan.neon",
    "content": "includes:\n    - vendor/phpstan/phpstan-strict-rules/rules.neon\nparameters:\n\tcheckFunctionNameCase: true\n\tlevel: max\n\tpaths:\n\t\t- .\n\texcludePaths:\n\t\t- vendor\n\tstrictRules:\n\t\tbooleansInConditions: false\n\tignoreErrors:\n\t\t- identifier: missingType.iterableValue\n\t\t  path: Tests/Tests.php\n\t\t- identifier: cast.int\n\t\t  path: SourceQuery/Buffer.php\n\t\t- identifier: cast.double\n\t\t  path: SourceQuery/Buffer.php\n"
  },
  {
    "path": "psalm.xml",
    "content": "<?xml version=\"1.0\"?>\n<psalm\n    errorLevel=\"1\"\n    resolveFromConfigFile=\"true\"\n    findUnusedBaselineEntry=\"true\"\n    findUnusedCode=\"true\"\n    errorBaseline=\"Tests/psalm-baseline.xml\"\n    xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n    xmlns=\"https://getpsalm.org/schema/config\"\n    xsi:schemaLocation=\"https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd\"\n>\n    <projectFiles>\n        <directory name=\"SourceQuery\" />\n        <directory name=\"Tests\" />\n        <ignoreFiles>\n            <directory name=\"vendor\" />\n        </ignoreFiles>\n    </projectFiles>\n</psalm>\n"
  }
]