Difference between revisions of "Directory Game Server Protocol"

From ASSS Wiki
Jump to: navigation, search
(content from cypher's page)
 
m (Validating the zone name: the grammer must cannot exist)
 
(6 intermediate revisions by 4 users not shown)
Line 1: Line 1:
ABSTRACT: This document will explain the details needed to send zone data to the directory server.
+
== Introduction ==
 +
[[Zone|Game Servers]] such as [[subgame2]] and [[ASSS]] register their prescence on [[Directory server|Directory Servers]]. This page describes the portion of the '''directory server protocol''' that game servers use.
  
Some background information, this system relies on the UDP protocol, port 4991. Max length of the packet is only limited to the directory server software itself (so it varies from each application). However, the specific lengths of fields are pretty much final, the zone description should be the only length that varies. The following is based off examination of the open-source Directory Server by Catid; and discussions with him about this topic.
+
This system uses UDP packets, most commonly over port 4991. Maximum length of the packet is only limited to the directory server software itself, so it varies from each application. The specific lengths of most fields are static, with the zone description field being the only value that varies its length.
  
    Offset Length Description
+
== Protocol ==
    ===================================
+
<pre>
    0×00 [ 0] 4 IP address. (Must be NULL: 00 00 00 00)
+
g2d
    0×04 [ 4] 2 Server Port
 
    0×06 [ 6] 2 Population
 
    0×08 [ 8] 2 Scoring? (0×00 - no; 0×01 - yes)
 
    0×0A [ 10] 4 Version (134)
 
    0×0E [ 14] 32 Zone Name (31 characters, null-terminated.) Must also be a valid name.
 
    0×2E [ 46] 16 Zone Password (15 characters, null-terminated.)
 
    0×3E [ 62] 32 Unknown NULL field. (*** see discussion)
 
    0×5E [ 94] VARIES Zone Description (varied length, null-terminated.)
 
  
* Offsets are given in HEX [ DEC].
+
register game server
 +
offset size comment
 +
0      4    ip (leave this set to 0?)
 +
4      2    port
 +
6      2    player count
 +
8      2    saving scores? (boolean)
 +
10    4    version (set this to 134)
 +
14    32  zone name (null terminated)
 +
46    16  password (null terminated)
 +
62    32  reserved (suggested to set this to 0)
 +
94    ?    description (must be null terminated)
 +
</pre>
  
- 32 byte NULL field Discussion -
+
== Notes on Priit's dirserv ==
I was surprised to see this in the validation function of Catid’s directory server. After some discussion with him, he assures me there is a 32 length NULL field. As of Catids Distributed Directory Server build 4, these 32 bytes MUST BE NULL. It is enforced. However, after some testing done by 2dragons - having non-null bytes in this section does not affect the directory server writen by PriitK. Later thoughts were that VIE may have planned on adding more fields into the directory server protocol; but never got around to it.
+
Descriptions are recorded to the stats file with a max length of 490 bytes. The reserved field can be filled with any random data, as the directory server ignores this field completely.
  
- Further Discussion -
+
== Notes on Catid's dirserv ==
PriitK’s directory server records descriptions to the stats file with a max length of 490 bytes.
 
  
- Validation -
+
=== Validating the packet ===
The following are conditions that I took apart from Catid’s validating function as well.
+
* The length of the packet must be greater than 95/0×5F bytes. Basically this means the description can be blank but must be null terminated.
 +
* The first 4 bytes (the IP field) must be zeroed.
 +
* The reserved field must be zeroed.
 +
* The name, password and description must be null terminated.
 +
* The "save scores" field must be either 0 or 1.
  
The length of the packet must be greater than 0×5F
+
=== Validating the zone name ===
The first 4 bytes must be null, or zero.
+
* Name must be at least one character long.
The last byte of the packet must be NULL (0×00)
+
* First and last characters must not be a space.
The byte[0×2D] must be 0×00
+
* No more than one space in a row.
The byte[0×3D] must be 0×00
+
* Only ASCII characters between ‘ ‘ [0x20] and ‘~’ [0x7E], inclusive.
The byte[0×08] must be either 0×00, or 0×01
 
The byte[0×3E] to byte[0×5D]
 
  
*** Validating Name ***
+
== Notes on zone.dat ==
There are also conditions on what determines a validName, etc. This part may or may not be correct. I just threw it in here quickly.
+
Due to the format of zone.dat used to store your favourite zones, zone names should not begin with '#' [0x23] or contain any ',' [0x2C].
  
Catids Directory Server says:
+
== See also ==
validName would be:
+
* [http://cypherjf.sscentral.com/articles/game-server-to-directory-server/ CypherJF's original document]
len(name) > 0
+
* [http://web.archive.org/web/*/http://www4.ncsu.edu/~rniyenga/subspace/old/dprotocol.html Hammuravi's page]
no leading spaces
+
* [http://asss.yi.org/asss/ ASSS Source]: src/directory.c
no more than 1 space in a row
+
* [[Directory Client Protocol]]
Any character between ‘ ‘ and ‘~’
+
 
No trailing spaces
+
[[Category: Protocol]]

Latest revision as of 10:36, 12 January 2007

Introduction

Game Servers such as subgame2 and ASSS register their prescence on Directory Servers. This page describes the portion of the directory server protocol that game servers use.

This system uses UDP packets, most commonly over port 4991. Maximum length of the packet is only limited to the directory server software itself, so it varies from each application. The specific lengths of most fields are static, with the zone description field being the only value that varies its length.

Protocol

g2d

register game server
offset size comment
0      4    ip (leave this set to 0?)
4      2    port
6      2    player count
8      2    saving scores? (boolean)
10     4    version (set this to 134)
14     32   zone name (null terminated)
46     16   password (null terminated)
62     32   reserved (suggested to set this to 0)
94     ?    description (must be null terminated)

Notes on Priit's dirserv

Descriptions are recorded to the stats file with a max length of 490 bytes. The reserved field can be filled with any random data, as the directory server ignores this field completely.

Notes on Catid's dirserv

Validating the packet

  • The length of the packet must be greater than 95/0×5F bytes. Basically this means the description can be blank but must be null terminated.
  • The first 4 bytes (the IP field) must be zeroed.
  • The reserved field must be zeroed.
  • The name, password and description must be null terminated.
  • The "save scores" field must be either 0 or 1.

Validating the zone name

  • Name must be at least one character long.
  • First and last characters must not be a space.
  • No more than one space in a row.
  • Only ASCII characters between ‘ ‘ [0x20] and ‘~’ [0x7E], inclusive.

Notes on zone.dat

Due to the format of zone.dat used to store your favourite zones, zone names should not begin with '#' [0x23] or contain any ',' [0x2C].

See also