updated docs

This commit is contained in:
Erik Ekman 2008-12-07 09:41:06 +00:00 committed by Erik Ekman
parent 8a093efa59
commit 25018c9b15

View File

@ -1,98 +1,68 @@
Detailed specification of protocol in version 00000403 Detailed specification of protocol in version 00000403
====================================================== ======================================================
This protocol varies a lot from earlier ones and will
hopefully give cleaner code and enable more features.
Common header:
7654 3210
+----+----+
|CCCC|UUUU|
+----+----+
CCCC = Command
UUUU = User id
Commands:
0: Version
1: Login
2: Case check
3: Codec switch
4: Data
5: Ping
6: -
7: -
8: -
9: -
A: -Reserved- (So header byte will never encode to a v)
B: -
C: -
D: -
E: -
F: -
CMC = 2 byte Cache Miss Counter, increased every time it is used CMC = 2 byte Cache Miss Counter, increased every time it is used
Version: Version:
Client sends: Client sends:
Command = 0x0, User = 0xF First byte v or V
Data is 4 bytes big endian protocol version Rest encoded with base32:
Ends with CMC 4 bytes big endian protocol version
CMC
Server replies: Server replies:
Command = 0x0, User = userid 4 chars:
Then 4 chars, followed by big endian int:
VACK (version ok), followed by login challenge VACK (version ok), followed by login challenge
VNAK (version differs), followed by server protocol version VNAK (version differs), followed by server protocol version
VFUL (server has no free slots), followed by max users VFUL (server has no free slots), followed by max users
4 byte value: means login challenge/server protocol version/max users
1 byte userid of the new user, or any byte if not VACK
Login: Login:
Command = 0x1, User = userid from version reply
Client sends: Client sends:
First byte l or L
Rest encoded with base32:
1 byte userid
16 bytes MD5 hash of: (first 32 bytes of password) xor (8 repetitions of login challenge) 16 bytes MD5 hash of: (first 32 bytes of password) xor (8 repetitions of login challenge)
Ends with CMC CMC
Server replies: Server replies:
4 chars, then maybe three ints
LACK serverip clientip mtu means login accepted
LNAK means not accepted LNAK means not accepted
x.x.x.x-y.y.y.y-mtu means accepted (server ip, client ip, mtu)
Case check: Case check:
Command = 0x2, User = userid from version reply
Client sends: Client sends:
First byte z or Z
Lots of data that should not be decoded Lots of data that should not be decoded
Server replies: Server replies:
The requested domain copied raw The requested domain copied raw
Switch codec: Switch codec:
Command = 0x03, User = userid
Client sends: Client sends:
One byte, with value 5 or 6, representing number of bits per byte in encoding First byte s or S
One byte ASCII digit, meaning userid
One byte ASCII digit, with value 5 or 6, representing number of bits per byte in encoding
Server sends: Server sends:
Name of codec if accepted. After this all upstream packets must be encoded with the new codec. Name of codec if accepted. After this all upstream data packets must be encoded with the new codec.
BADCODEC if not accepted. Client must then revert to Base64 BADCODEC if not accepted. Client must then revert to Base32
Data: Data:
Command = 0x04, User = userid
Data header: Data header:
76543210 7 6 543210 321 0
+--------+-+-+------+ +---+-+
|SSSSSSSS|L|C|FFFFFF| |UUU|L|
+--------+-+-+------+ +---+-+
SSSSSSSS = Packet sequence number UUU = Userid
L = Last fragment in packet flag L = Last fragment in packet flag
C = Compression used flag
FFFFFF = Fragment index in packet
The data header is used both by the server and the client, followed by a fragment. First 4 bits coded as hex in ASCII.
Packet and fragment numbers are used to detect retransmits by dns relay. Followed by data encoded with the chosen codec.
When a fragment arrives with L bit set, the packet should be pushed to the tun device.
If the C bit is set, it should be decompressed before sent to tun device.
Ping: Ping:
Command = 0x04, User = userid Command = 0x04, User = userid
Client sends: Client sends:
Only a CMC Only a CMC
Server replies:
With a Data packet or 0 bytes.
The server responses to Ping and Data packets is a DNS NULL type response:
If server has nothing to send, data length is 0 bytes.
If server has a packet to send, data length is set and the data is a full raw
unencoded ip packet, prefixed with 32 bits tun data.