sustenet_shared/
packets.rs

1pub mod master {
2    #[repr(u8)]
3    pub enum FromUnknown {
4        /// Sends a list of names and IPs to whoever requested it.
5        RequestClusters,
6        /// Just a way to gracefully disconnect the client.
7        JoinCluster,
8
9        /// They send the name of the cluster's key to the Master Server.
10        /// If the key doesn't exist, the server will do nothing but
11        /// stay silent. If it does exist, it will send a generated
12        /// passphrase that's encrypted with AES.
13        BecomeCluster,
14        /// When they send the decrypted key back to the Master Server.
15        AnswerCluster,
16    }
17    #[repr(u8)]
18    pub enum ToUnknown {
19        /// Sends a list of cluster servers containing their name, ip, and port.
20        SendClusters,
21
22        /// Generates a passphrase that's encrypted with AES and sends
23        /// it waiting for it to be sent back. It's stored in their name.
24        VerifyCluster,
25        /// Once validated, the cluster is moved to the cluster list and
26        /// notifies them that they're now a cluster.
27        CreateCluster,
28        
29        // Cluster things go here.
30    }
31}
32
33pub mod cluster {
34    pub enum FromClient {
35        /// Sends a list of names and IPs to whoever requested it.
36        RequestClusters,
37        /// Gracefully disconnect the client and connects to the new cluster.
38        JoinCluster,
39        /// Gracefully disconnect the client.
40        LeaveCluster,
41
42        /// Only works if the server doesn't have a domain config. Sends the pub key.
43        /// Ran if the cache key doesn't match.
44        RequestKey,
45        /// Encrypts the password and sends it.
46        SendPassword,
47
48        /// Moves the player's position.
49        Move
50    }
51
52    pub enum ToClient {
53        /// Sends a list of cluster servers containing their name, ip, and port.
54        SendClusters,
55        /// Disconnects the client from the cluster.
56        DisconnectCluster,
57        /// Disconnects the client from the cluster.
58        LeaveCluster,
59
60        // Sends the cached version of the key.
61        VersionOfKey,
62        /// Sends the public key to the client. This only works if "domain_pub_key"
63        /// is not set in the Config.
64        SendPubKey,
65        /// This sends back the status to the user. It'll have a status code.
66        /// 20 = 200, 44 = 404, 40 = 400, 50 = 500.
67        /// If 20, it will send the user their ID (this was assigned on initial connection).
68        Authenticate,
69
70        /// Sends the player's new position.
71        Move
72    }
73}