Skip to content

Commit 7c46729

Browse files
committed
dev custom rule config
1 parent 0127c60 commit 7c46729

9 files changed

Lines changed: 521 additions & 82 deletions

File tree

Lines changed: 373 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,373 @@
1+
{
2+
"formatVersion": 1,
3+
"database": {
4+
"version": 6,
5+
"identityHash": "3d3db9106a89d6f20ef3fde6e81dbaa9",
6+
"entities": [
7+
{
8+
"tableName": "proxy_groups",
9+
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `userOrder` INTEGER NOT NULL, `ungrouped` INTEGER NOT NULL, `name` TEXT, `type` INTEGER NOT NULL, `subscription` BLOB, `order` INTEGER NOT NULL, `isSelector` INTEGER NOT NULL, `frontProxy` INTEGER NOT NULL, `landingProxy` INTEGER NOT NULL)",
10+
"fields": [
11+
{
12+
"fieldPath": "id",
13+
"columnName": "id",
14+
"affinity": "INTEGER",
15+
"notNull": true
16+
},
17+
{
18+
"fieldPath": "userOrder",
19+
"columnName": "userOrder",
20+
"affinity": "INTEGER",
21+
"notNull": true
22+
},
23+
{
24+
"fieldPath": "ungrouped",
25+
"columnName": "ungrouped",
26+
"affinity": "INTEGER",
27+
"notNull": true
28+
},
29+
{
30+
"fieldPath": "name",
31+
"columnName": "name",
32+
"affinity": "TEXT",
33+
"notNull": false
34+
},
35+
{
36+
"fieldPath": "type",
37+
"columnName": "type",
38+
"affinity": "INTEGER",
39+
"notNull": true
40+
},
41+
{
42+
"fieldPath": "subscription",
43+
"columnName": "subscription",
44+
"affinity": "BLOB",
45+
"notNull": false
46+
},
47+
{
48+
"fieldPath": "order",
49+
"columnName": "order",
50+
"affinity": "INTEGER",
51+
"notNull": true
52+
},
53+
{
54+
"fieldPath": "isSelector",
55+
"columnName": "isSelector",
56+
"affinity": "INTEGER",
57+
"notNull": true
58+
},
59+
{
60+
"fieldPath": "frontProxy",
61+
"columnName": "frontProxy",
62+
"affinity": "INTEGER",
63+
"notNull": true
64+
},
65+
{
66+
"fieldPath": "landingProxy",
67+
"columnName": "landingProxy",
68+
"affinity": "INTEGER",
69+
"notNull": true
70+
}
71+
],
72+
"primaryKey": {
73+
"autoGenerate": true,
74+
"columnNames": [
75+
"id"
76+
]
77+
},
78+
"indices": [],
79+
"foreignKeys": []
80+
},
81+
{
82+
"tableName": "proxy_entities",
83+
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `groupId` INTEGER NOT NULL, `type` INTEGER NOT NULL, `userOrder` INTEGER NOT NULL, `tx` INTEGER NOT NULL, `rx` INTEGER NOT NULL, `status` INTEGER NOT NULL, `ping` INTEGER NOT NULL, `uuid` TEXT NOT NULL, `error` TEXT, `socksBean` BLOB, `httpBean` BLOB, `ssBean` BLOB, `vmessBean` BLOB, `trojanBean` BLOB, `trojanGoBean` BLOB, `mieruBean` BLOB, `naiveBean` BLOB, `hysteriaBean` BLOB, `tuicBean` BLOB, `sshBean` BLOB, `wgBean` BLOB, `shadowTLSBean` BLOB, `anyTLSBean` BLOB, `chainBean` BLOB, `nekoBean` BLOB, `configBean` BLOB)",
84+
"fields": [
85+
{
86+
"fieldPath": "id",
87+
"columnName": "id",
88+
"affinity": "INTEGER",
89+
"notNull": true
90+
},
91+
{
92+
"fieldPath": "groupId",
93+
"columnName": "groupId",
94+
"affinity": "INTEGER",
95+
"notNull": true
96+
},
97+
{
98+
"fieldPath": "type",
99+
"columnName": "type",
100+
"affinity": "INTEGER",
101+
"notNull": true
102+
},
103+
{
104+
"fieldPath": "userOrder",
105+
"columnName": "userOrder",
106+
"affinity": "INTEGER",
107+
"notNull": true
108+
},
109+
{
110+
"fieldPath": "tx",
111+
"columnName": "tx",
112+
"affinity": "INTEGER",
113+
"notNull": true
114+
},
115+
{
116+
"fieldPath": "rx",
117+
"columnName": "rx",
118+
"affinity": "INTEGER",
119+
"notNull": true
120+
},
121+
{
122+
"fieldPath": "status",
123+
"columnName": "status",
124+
"affinity": "INTEGER",
125+
"notNull": true
126+
},
127+
{
128+
"fieldPath": "ping",
129+
"columnName": "ping",
130+
"affinity": "INTEGER",
131+
"notNull": true
132+
},
133+
{
134+
"fieldPath": "uuid",
135+
"columnName": "uuid",
136+
"affinity": "TEXT",
137+
"notNull": true
138+
},
139+
{
140+
"fieldPath": "error",
141+
"columnName": "error",
142+
"affinity": "TEXT",
143+
"notNull": false
144+
},
145+
{
146+
"fieldPath": "socksBean",
147+
"columnName": "socksBean",
148+
"affinity": "BLOB",
149+
"notNull": false
150+
},
151+
{
152+
"fieldPath": "httpBean",
153+
"columnName": "httpBean",
154+
"affinity": "BLOB",
155+
"notNull": false
156+
},
157+
{
158+
"fieldPath": "ssBean",
159+
"columnName": "ssBean",
160+
"affinity": "BLOB",
161+
"notNull": false
162+
},
163+
{
164+
"fieldPath": "vmessBean",
165+
"columnName": "vmessBean",
166+
"affinity": "BLOB",
167+
"notNull": false
168+
},
169+
{
170+
"fieldPath": "trojanBean",
171+
"columnName": "trojanBean",
172+
"affinity": "BLOB",
173+
"notNull": false
174+
},
175+
{
176+
"fieldPath": "trojanGoBean",
177+
"columnName": "trojanGoBean",
178+
"affinity": "BLOB",
179+
"notNull": false
180+
},
181+
{
182+
"fieldPath": "mieruBean",
183+
"columnName": "mieruBean",
184+
"affinity": "BLOB",
185+
"notNull": false
186+
},
187+
{
188+
"fieldPath": "naiveBean",
189+
"columnName": "naiveBean",
190+
"affinity": "BLOB",
191+
"notNull": false
192+
},
193+
{
194+
"fieldPath": "hysteriaBean",
195+
"columnName": "hysteriaBean",
196+
"affinity": "BLOB",
197+
"notNull": false
198+
},
199+
{
200+
"fieldPath": "tuicBean",
201+
"columnName": "tuicBean",
202+
"affinity": "BLOB",
203+
"notNull": false
204+
},
205+
{
206+
"fieldPath": "sshBean",
207+
"columnName": "sshBean",
208+
"affinity": "BLOB",
209+
"notNull": false
210+
},
211+
{
212+
"fieldPath": "wgBean",
213+
"columnName": "wgBean",
214+
"affinity": "BLOB",
215+
"notNull": false
216+
},
217+
{
218+
"fieldPath": "shadowTLSBean",
219+
"columnName": "shadowTLSBean",
220+
"affinity": "BLOB",
221+
"notNull": false
222+
},
223+
{
224+
"fieldPath": "anyTLSBean",
225+
"columnName": "anyTLSBean",
226+
"affinity": "BLOB",
227+
"notNull": false
228+
},
229+
{
230+
"fieldPath": "chainBean",
231+
"columnName": "chainBean",
232+
"affinity": "BLOB",
233+
"notNull": false
234+
},
235+
{
236+
"fieldPath": "nekoBean",
237+
"columnName": "nekoBean",
238+
"affinity": "BLOB",
239+
"notNull": false
240+
},
241+
{
242+
"fieldPath": "configBean",
243+
"columnName": "configBean",
244+
"affinity": "BLOB",
245+
"notNull": false
246+
}
247+
],
248+
"primaryKey": {
249+
"autoGenerate": true,
250+
"columnNames": [
251+
"id"
252+
]
253+
},
254+
"indices": [
255+
{
256+
"name": "groupId",
257+
"unique": false,
258+
"columnNames": [
259+
"groupId"
260+
],
261+
"orders": [],
262+
"createSql": "CREATE INDEX IF NOT EXISTS `groupId` ON `${TABLE_NAME}` (`groupId`)"
263+
}
264+
],
265+
"foreignKeys": []
266+
},
267+
{
268+
"tableName": "rules",
269+
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `name` TEXT NOT NULL, `config` TEXT NOT NULL DEFAULT '', `userOrder` INTEGER NOT NULL, `enabled` INTEGER NOT NULL, `domains` TEXT NOT NULL, `ip` TEXT NOT NULL, `port` TEXT NOT NULL, `sourcePort` TEXT NOT NULL, `network` TEXT NOT NULL, `source` TEXT NOT NULL, `protocol` TEXT NOT NULL, `outbound` INTEGER NOT NULL, `packages` TEXT NOT NULL)",
270+
"fields": [
271+
{
272+
"fieldPath": "id",
273+
"columnName": "id",
274+
"affinity": "INTEGER",
275+
"notNull": true
276+
},
277+
{
278+
"fieldPath": "name",
279+
"columnName": "name",
280+
"affinity": "TEXT",
281+
"notNull": true
282+
},
283+
{
284+
"fieldPath": "config",
285+
"columnName": "config",
286+
"affinity": "TEXT",
287+
"notNull": true,
288+
"defaultValue": "''"
289+
},
290+
{
291+
"fieldPath": "userOrder",
292+
"columnName": "userOrder",
293+
"affinity": "INTEGER",
294+
"notNull": true
295+
},
296+
{
297+
"fieldPath": "enabled",
298+
"columnName": "enabled",
299+
"affinity": "INTEGER",
300+
"notNull": true
301+
},
302+
{
303+
"fieldPath": "domains",
304+
"columnName": "domains",
305+
"affinity": "TEXT",
306+
"notNull": true
307+
},
308+
{
309+
"fieldPath": "ip",
310+
"columnName": "ip",
311+
"affinity": "TEXT",
312+
"notNull": true
313+
},
314+
{
315+
"fieldPath": "port",
316+
"columnName": "port",
317+
"affinity": "TEXT",
318+
"notNull": true
319+
},
320+
{
321+
"fieldPath": "sourcePort",
322+
"columnName": "sourcePort",
323+
"affinity": "TEXT",
324+
"notNull": true
325+
},
326+
{
327+
"fieldPath": "network",
328+
"columnName": "network",
329+
"affinity": "TEXT",
330+
"notNull": true
331+
},
332+
{
333+
"fieldPath": "source",
334+
"columnName": "source",
335+
"affinity": "TEXT",
336+
"notNull": true
337+
},
338+
{
339+
"fieldPath": "protocol",
340+
"columnName": "protocol",
341+
"affinity": "TEXT",
342+
"notNull": true
343+
},
344+
{
345+
"fieldPath": "outbound",
346+
"columnName": "outbound",
347+
"affinity": "INTEGER",
348+
"notNull": true
349+
},
350+
{
351+
"fieldPath": "packages",
352+
"columnName": "packages",
353+
"affinity": "TEXT",
354+
"notNull": true
355+
}
356+
],
357+
"primaryKey": {
358+
"autoGenerate": true,
359+
"columnNames": [
360+
"id"
361+
]
362+
},
363+
"indices": [],
364+
"foreignKeys": []
365+
}
366+
],
367+
"views": [],
368+
"setupQueries": [
369+
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
370+
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '3d3db9106a89d6f20ef3fde6e81dbaa9')"
371+
]
372+
}
373+
}

app/src/main/java/io/nekohasekai/sagernet/database/RuleEntity.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import kotlinx.parcelize.Parcelize
1212
data class RuleEntity(
1313
@PrimaryKey(autoGenerate = true) var id: Long = 0L,
1414
var name: String = "",
15+
@ColumnInfo(defaultValue = "")
16+
var config: String = "",
1517
var userOrder: Long = 0L,
1618
var enabled: Boolean = false,
1719
var domains: String = "",
@@ -31,11 +33,12 @@ data class RuleEntity(
3133

3234
fun mkSummary(): String {
3335
var summary = ""
36+
if (config.isNotBlank()) summary += "[config]\n"
3437
if (domains.isNotBlank()) summary += "$domains\n"
3538
if (ip.isNotBlank()) summary += "$ip\n"
36-
if (source.isNotBlank()) summary += "source: $source\n"
37-
if (sourcePort.isNotBlank()) summary += "sourcePort: $sourcePort\n"
38-
if (port.isNotBlank()) summary += "port: $port\n"
39+
if (source.isNotBlank()) summary += "src ip: $source\n"
40+
if (sourcePort.isNotBlank()) summary += "src port: $sourcePort\n"
41+
if (port.isNotBlank()) summary += "dst port: $port\n"
3942
if (network.isNotBlank()) summary += "network: $network\n"
4043
if (protocol.isNotBlank()) summary += "protocol: $protocol\n"
4144
if (packages.isNotEmpty()) summary += app.getString(

0 commit comments

Comments
 (0)