Added database structure, moved planning to notes/
[tpg/opendispense2.git] / notes / proto.txt
1 OpenDispense^2
2 Client/Server Dispense Protocol
3
4 The protocol is ASCII based, similar to the FTP protocol
5 All server responses are on one line and are prefixed by a three digit response code.
6
7 == Response Codes ==
8 100     Information
9 200     Command succeeded, no extra information
10 201     Command succeeded, multiple lines follow (<length>)
11 202     Command succeeded, per-command format
12 400     Unknown Command
13 401     Not Authenticated (or Authentication failure)
14 402     Balance insufficient
15 403     User not allowed to perform this action
16 404     Bad other username
17 406     Bad Item ID
18 407     Invalid arguments
19 500     Unknown Dispense Failure
20 501     Action Rejected
21
22 == Item IDs ==
23 <item_id> represents the item ID
24 Item IDs are allowed to contain any non-whitespace character, but in
25 general they will be limited to the standard alpha-numeric set
26
27 === User Auth ===
28 c       USER <username>\n
29 s       100 SALT <string>\n or 100 User Set\n   (If no salt used)
30 c       PASS <hash>\n   (Hex-Encoded SHA-1 Hash of <username><salt><password>)
31 s       200 Auth OK\n or 401 Auth Failure\n
32 User is now authenticated
33 --- Alternate Method (Implicit Trust Authentication) ---
34 If the client is connecting from a trusted machine on a root port then
35 automatic authentication is allowed
36 c       AUTOAUTH <username>\n
37 s       200 Auth OK\n or 404 Bad Username\n or 401 Untrusted\n
38 --- Set effective user (User in `dispense -u`) ---
39 c       SETEUSER <username>\n
40 s       200 User set\n or 403 Not in coke\n or 404 User not found\n
41
42 === Commands ===
43 --- Dispense an item ---
44 c       DISPENSE <item_id>\n
45 s       200 Dispense OK\n or 402 Poor You\n or 500 Dispense Error\n or 406 Bad Item\n
46 --- Give to another user ---
47 c       GIVE <user> <ammount> <reason>\n
48 s       200 Give OK\n or 402 Poor You\n or 404 Bad User\n
49 --- Alter balance ---
50 c       ADD <user> <ammount> <reason>\n
51 s       200 Add OK\n or 402 No balance\n or 403 Not Coke\n or 404 Bad User\n
52
53 --- Get Item list ---
54 c       ENUM_ITEMS\n
55 s       201 Items <count>\n
56 s       202 Item <item_id> <price> <description>\n
57     ...
58 s       200 List End\n
59 --- Get Item Information ---
60 c       ITEM_INFO <item_id>\n
61 s       202 Item <item_id> <price> <description>\n
62
63 --- Get Users' Balances ---
64  <max balance> and <min balance> can be '-' to indicate "none"
65 c       ENUM_USERS[ <min balance> [<max balance>]]\n
66 s       201 Users <count>\n
67 s       202 User <username> <balance> <flags>\n
68     ...
69 s       200 List End\n
70 --- Get a User's Balance ---
71 c       USER_INFO\n
72 s       202 User <username> <balance> <flags>\n
73
74 --- Add a new user ---
75 c       USER_ADD <username>\n
76 s       200 User Added\n or 403 Not Wheel\n or 404 User Exists\n
77 --- Set user flags ---
78  <flags> is a comma-separated list of flag values (optionally preceded by
79  - to remove the flag) Valid values are: user,coke,wheel,meta,disabled,door
80 c       USER_FLAGS <username> <flags>\n
81 s       200 User Updated\n or 403 Not Wheel\n or 404 Bad User\n or 407 Unknown Flags\n

UCC git Repository :: git.ucc.asn.au