1- # Application Protocol Description
1+ # Application Protocol Design
22
33## Overview
44
@@ -7,34 +7,80 @@ The application communicates via ZeroMQ Pub/Sub pattern, exchanging binary messa
77This approach replaces plain JSON messaging with efficient zero-copy serialization, reducing message size and CPU overhead.
88Supported Actions & Message Structures
99
10+ Check src/bin/utils.rs for debugging binary message sending
11+
1012Messages are sent as binary blobs representing the following Rust struct:
1113
12- #[ derive(Archive, Serialize, Deserialize, Clone, Debug)]
13- pub struct Message {
14- pub conn_id: UuidWrapper,
15- pub action: Action,
16- pub tag: ArchivedTagSimple,
17- pub wg: Option<WgParam >,
18- pub password: Option<String >,
19- }
20-
21- #[ derive(Archive, Serialize, Deserialize, Debug, Clone)]
22- pub enum Action {
23- Create,
24- Update,
25- Delete,
26- ResetStat,
27- }
28-
29- CREATE/UPDATE/DELETE Connection
14+ #[derive(Archive, Serialize, Deserialize, Clone, Debug)]
15+ pub struct Message {
16+ pub conn_id: UuidWrapper,
17+ pub action: Action,
18+ pub tag: ProtoTag,
19+ pub wg: Option<Param>,
20+ pub password: Option<String>,
21+ }
22+
23+ #[derive(Archive, Serialize, Deserialize, Debug, Clone)]
24+ pub enum Action {
25+ Create,
26+ Update,
27+ Delete,
28+ ResetStat,
29+ }
30+
31+ #[derive(
32+ Archive,
33+ Clone,
34+ Debug,
35+ RkyvDeserialize,
36+ RkyvSerialize,
37+ Deserialize,
38+ Serialize,
39+ PartialEq,
40+ Eq,
41+ Hash,
42+ Copy,
43+ ToSql,
44+ FromSql,
45+ )]
46+ #[archive_attr(derive(Clone, Debug))]
47+ #[archive(check_bytes)]
48+ #[postgres(name = "proto", rename_all = "snake_case")]
49+ pub enum ProtoTag {
50+ #[serde(rename = "VlessXtls")]
51+ VlessXtls,
52+ #[serde(rename = "VlessGrpc")]
53+ VlessGrpc,
54+ #[serde(rename = "Vmess")]
55+ Vmess,
56+ #[serde(rename = "Shadowsocks")]
57+ Shadowsocks,
58+ #[serde(rename = "Wireguard")]
59+ Wireguard,
60+ }
61+
62+ #[derive(
63+ Archive, Clone, Debug, Serialize, Deserialize, RkyvDeserialize, RkyvSerialize, PartialEq,
64+ )]
65+ pub struct Param {
66+ pub keys: Keys,
67+ pub address: IpAddrMaskSerializable,
68+ }
69+
70+
71+
72+ Note: password field only for Shadowsocks
73+ wg fileds only for wireguard
74+
75+ ## CREATE/UPDATE/DELETE/ResetStat Connection
3076
3177Connections represent individual tunnels (WireGuard, Shadowsocks, VLESS, etc.) and are managed similarly.
3278
3379Binary message includes:
3480
3581 conn_id: Connection UUID
3682
37- action: Create/Update/Delete
83+ action: Create/Update/Delete/ResetStat
3884
3985 tag: Protocol type string ("Wireguard", "Shadowsocks", "VlessXtls", etc.)
4086
@@ -73,6 +119,9 @@ Create
73119 "password": null
74120 }
75121
122+ Display output — binary message printed
123+ 17865be5-e18b-40d6-b5af-e1c4d51ff50a | Create | Wireguard | privkey: LY8D/CyB/JT1uiFhK1yVKxBB3VMZeA0DzOAJEvgQw50= pubkey: a4uH3iSdV6Ifc7thKL8IHTM8PkL/yPBUztN9xuoA2Do= address: 10.10.0.24/32 | -
124+
76125Update
77126
78127 {
@@ -92,6 +141,9 @@ Update
92141 "password": null
93142 }
94143
144+ Display output — binary message printed
145+ 17865be5-e18b-40d6-b5af-e1c4d51ff50a | Update | Wireguard | privkey: NEW_PRIVATE_KEY_BASE64 pubkey: NEW_PUBLIC_KEY_BASE64 address: 10.10.0.25/32 | -
146+
95147Delete
96148
97149 {
@@ -101,3 +153,7 @@ Delete
101153 "wg": null,
102154 "password": null
103155 }
156+
157+
158+ Display output — binary message printed
159+ 17865be5-e18b-40d6-b5af-e1c4d51ff50a | Delete | Wireguard | - | -
0 commit comments