Skip to content

Commit 693c05b

Browse files
authored
Merge pull request #2 from NullNet-ai/dev
Update JavaScript clients
2 parents 15a0e07 + 5388b51 commit 693c05b

33 files changed

+410
-271
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ node_modules
44
dist
55
.idea
66
token.txt
7+
app_id.txt
8+
app_secret.txt
9+
firewall_defaults.json
10+
uuid.txt
711
.env
812
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
913

client_common/package-lock.json

Lines changed: 20 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client_common/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
"dependencies": {
2424
"@grpc/grpc-js": "^1.3.2",
2525
"@grpc/proto-loader": "^0.6.2",
26-
"dotenv": "^16.5.0"
26+
"dotenv": "^16.5.0",
27+
"uuid": "^11.1.0"
2728
},
2829
"husky": {
2930
"hooks": {

client_common/proto/appguard.proto

Lines changed: 15 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ syntax = "proto3";
22

33
package appguard;
44

5+
import "google/protobuf/empty.proto";
6+
import "commands.proto";
7+
58
service AppGuard {
6-
// Authentication
7-
rpc Heartbeat (HeartbeatRequest) returns (stream HeartbeatResponse);
8-
// Firewall
9-
rpc UpdateFirewall (AppGuardFirewall) returns (Empty);
9+
// Control channel
10+
rpc ControlChannel(stream appguard_commands.ClientMessage)
11+
returns (stream appguard_commands.ServerMessage);
1012
// Logs
11-
rpc HandleLogs (Logs) returns (Empty);
13+
rpc HandleLogs (Logs) returns (google.protobuf.Empty);
1214
// TCP
1315
rpc HandleTcpConnection (AppGuardTcpConnection) returns (AppGuardTcpResponse);
1416
// HTTP
@@ -17,33 +19,8 @@ service AppGuard {
1719
// SMTP
1820
rpc HandleSmtpRequest (AppGuardSmtpRequest) returns (AppGuardResponse);
1921
rpc HandleSmtpResponse (AppGuardSmtpResponse) returns (AppGuardResponse);
20-
}
21-
22-
// Authentication ------------------------------------------------------------------------------------------------------
23-
24-
message HeartbeatRequest {
25-
string app_id = 1;
26-
string app_secret = 2;
27-
}
28-
29-
enum DeviceStatus {
30-
DRAFT = 0;
31-
ACTIVE = 1;
32-
ARCHIVED = 2;
33-
DELETED = 3;
34-
DS_UNKNOWN = 4;
35-
}
36-
37-
message HeartbeatResponse {
38-
string token = 1;
39-
DeviceStatus status = 2;
40-
}
41-
42-
// Firewall ------------------------------------------------------------------------------------------------------------
43-
44-
message AppGuardFirewall {
45-
string token = 1;
46-
string firewall = 2;
22+
// Other
23+
rpc FirewallDefaultsRequest (Token) returns (appguard_commands.FirewallDefaults);
4724
}
4825

4926
// Logs ----------------------------------------------------------------------------------------------------------------
@@ -124,18 +101,16 @@ message AppGuardSmtpResponse {
124101

125102
// Response ------------------------------------------------------------------------------------------------------------
126103

127-
message Empty {}
128-
129104
message AppGuardResponse {
130-
FirewallPolicy policy = 2;
105+
appguard_commands.FirewallPolicy policy = 2;
131106
}
132107

133108
message AppGuardTcpResponse {
134109
AppGuardTcpInfo tcp_info = 1;
135110
}
136111

137-
enum FirewallPolicy {
138-
UNKNOWN = 0;
139-
ALLOW = 1;
140-
DENY = 2;
141-
}
112+
// Other --------------------------------------------------------------------------------------
113+
114+
message Token {
115+
string token = 1;
116+
}

client_common/proto/commands.proto

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
syntax = "proto3";
2+
3+
package appguard_commands;
4+
5+
import "google/protobuf/empty.proto";
6+
7+
message AuthorizationRequest {
8+
string uuid = 1;
9+
string code = 2;
10+
string category = 3;
11+
string type = 4;
12+
string target_os = 5;
13+
}
14+
15+
message Authentication {
16+
string app_id = 1;
17+
string app_secret = 2;
18+
}
19+
20+
message ClientMessage {
21+
oneof message {
22+
AuthorizationRequest authorization_request = 1;
23+
Authentication authentication = 2;
24+
}
25+
}
26+
27+
message AuthenticationData {
28+
optional string app_id = 1;
29+
optional string app_secret = 2;
30+
}
31+
32+
message ServerMessage {
33+
oneof message {
34+
string update_token_command = 1;
35+
36+
FirewallDefaults set_firewall_defaults = 2;
37+
38+
google.protobuf.Empty heartbeat = 3;
39+
40+
AuthenticationData device_authorized = 4;
41+
google.protobuf.Empty device_deauthorized = 5;
42+
google.protobuf.Empty authorization_rejected = 6;
43+
}
44+
}
45+
46+
message FirewallDefaults {
47+
uint32 timeout = 1;
48+
FirewallPolicy policy = 2;
49+
}
50+
51+
enum FirewallPolicy {
52+
UNKNOWN = 0;
53+
ALLOW = 1;
54+
DENY = 2;
55+
}

0 commit comments

Comments
 (0)