mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-11-10 07:12:03 +00:00
Document the hole punching protocol
This commit is contained in:
parent
df59f3580d
commit
eab8f99eab
2 changed files with 38 additions and 0 deletions
34
doc/Holepunch-Protocol.txt
Normal file
34
doc/Holepunch-Protocol.txt
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
Bird's Hole Punching Protocol
|
||||||
|
|
||||||
|
|
||||||
|
Hole punch - a mechanism to bypass a firewall
|
||||||
|
Server - a third party which is not behind a firewall
|
||||||
|
Client - anything contacting the server
|
||||||
|
Magic - the four bytes 00 52 EB 11
|
||||||
|
Address - an IPv4 address
|
||||||
|
|
||||||
|
|
||||||
|
0 1 2 3 4 5 6 7 8 9
|
||||||
|
+-------+-------+----+
|
||||||
|
| Magic |Address|Port|
|
||||||
|
+-------+-------+----+
|
||||||
|
Relay Packet
|
||||||
|
|
||||||
|
|
||||||
|
A client that expects to be the target of a hole punch
|
||||||
|
must contact the server frequently, to keep a UDP
|
||||||
|
"connection" open, so that the server may relay hole
|
||||||
|
punching requests to them.
|
||||||
|
|
||||||
|
A client makes a hole punching request to another client
|
||||||
|
by sending a Relay Packet to the server. The server then
|
||||||
|
sends another Relay Packet to the client described by the
|
||||||
|
first packet. The second packet is filled with the source
|
||||||
|
address and port of the first packet.
|
||||||
|
|
||||||
|
Once a client receives a Relay Packet, this protocol's
|
||||||
|
purpose is fulfilled and the client is aware that another
|
||||||
|
client requests a hole punch.
|
||||||
|
|
||||||
|
|
||||||
|
vim: noai
|
|
@ -241,6 +241,7 @@ static size_t broadcastaddresses = 0;
|
||||||
static boolean nodeconnected[MAXNETNODES+1];
|
static boolean nodeconnected[MAXNETNODES+1];
|
||||||
static mysockaddr_t banned[MAXBANS];
|
static mysockaddr_t banned[MAXBANS];
|
||||||
static UINT8 bannedmask[MAXBANS];
|
static UINT8 bannedmask[MAXBANS];
|
||||||
|
/* See ../doc/Holepunch-Protocol.txt */
|
||||||
static const INT32 hole_punch_magic = MSBF_LONG (0x52eb11);
|
static const INT32 hole_punch_magic = MSBF_LONG (0x52eb11);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -600,6 +601,7 @@ void Command_Numnodes(void)
|
||||||
#ifndef NONET
|
#ifndef NONET
|
||||||
static boolean hole_punch(ssize_t c)
|
static boolean hole_punch(ssize_t c)
|
||||||
{
|
{
|
||||||
|
/* See ../doc/Holepunch-Protocol.txt */
|
||||||
if (cv_rendezvousserver.string[0] &&
|
if (cv_rendezvousserver.string[0] &&
|
||||||
c == 10 && holepunchpacket->magic == hole_punch_magic)
|
c == 10 && holepunchpacket->magic == hole_punch_magic)
|
||||||
{
|
{
|
||||||
|
@ -1408,6 +1410,8 @@ static SINT8 SOCK_NetMakeNodewPort(const char *address, const char *port)
|
||||||
return newnode;
|
return newnode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* See ../doc/Holepunch-Protocol.txt */
|
||||||
|
|
||||||
static void rendezvous(int size)
|
static void rendezvous(int size)
|
||||||
{
|
{
|
||||||
char *addrs = strdup(cv_rendezvousserver.string);
|
char *addrs = strdup(cv_rendezvousserver.string);
|
||||||
|
|
Loading…
Reference in a new issue