Skip to content

Commit 05051e3

Browse files
authored
Merge pull request #38 from StashNetworks/main
feat: 支持 Stash 逻辑规则 & JQ
2 parents 349f38b + 6959dff commit 05051e3

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

Rewrite-Parser.beta.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ if (binaryInfo != null && binaryInfo.length > 0) {
559559

560560
if (/\s((request|response)-body-json-jq)\s/.test(_x)) {
561561
let [_, regex, type, value] = _x.match(/^(.*?)\s+?(?:(request|response)-body-json-jq)\s+?(.*?)\s*$/)
562-
if (jqEnabled && isSurgeiOS) {
562+
if (jqEnabled && (isSurgeiOS || isStashiOS)) {
563563
const jqPath = value.match(/jq-path="(.+?)"/)?.[1]
564564
if (jqPath) {
565565
if (/^https?:\/\//.test(jqPath)) {
@@ -610,7 +610,7 @@ if (binaryInfo != null && binaryInfo.length > 0) {
610610
const jsptn = regex
611611
let args = [[action, newSuffixArray]]
612612

613-
if (jqEnabled && isSurgeiOS) {
613+
if (jqEnabled && (isSurgeiOS || isStashiOS)) {
614614
if (action === 'json-add') {
615615
newSuffixArray.forEach(item => {
616616
const paths = parseJsonPath(item[0])
@@ -1199,6 +1199,8 @@ if (binaryInfo != null && binaryInfo.length > 0) {
11991199
rules.push(mark + noteK + ruletype + ',' + rulevalue + ',' + rulepolicy + rulenore + rulesni + rulepm)
12001200
} else if (/^(?:and|or|not)$/i.test(ruletype) && !isStashiOS) {
12011201
rules.push(ori)
1202+
} else if (/^(?:and|or|not)$/i.test(ruletype) && isStashiOS) {
1203+
rules.push(mark + noteK2 + '- ' + ori)
12021204
} else if (/(?:^domain$|domain-suffix|domain-keyword|ip-|de?st-port)/i.test(ruletype) && isStashiOS) {
12031205
rules.push(mark + noteK2 + '- ' + ruletype + ',' + rulevalue + ',' + rulepolicy + rulenore)
12041206
} else if (/src-port/i.test(ruletype) && (isSurgeiOS || isLooniOS)) {

Rewrite-Parser.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ if (binaryInfo != null && binaryInfo.length > 0) {
559559

560560
if (/\s((request|response)-body-json-jq)\s/.test(_x)) {
561561
let [_, regex, type, value] = _x.match(/^(.*?)\s+?(?:(request|response)-body-json-jq)\s+?(.*?)\s*$/)
562-
if (jqEnabled && isSurgeiOS) {
562+
if (jqEnabled && (isSurgeiOS || isStashiOS)) {
563563
const jqPath = value.match(/jq-path="(.+?)"/)?.[1]
564564
if (jqPath) {
565565
if (/^https?:\/\//.test(jqPath)) {
@@ -610,7 +610,7 @@ if (binaryInfo != null && binaryInfo.length > 0) {
610610
const jsptn = regex
611611
let args = [[action, newSuffixArray]]
612612

613-
if (jqEnabled && isSurgeiOS) {
613+
if (jqEnabled && (isSurgeiOS || isStashiOS)) {
614614
if (action === 'json-add') {
615615
newSuffixArray.forEach(item => {
616616
const paths = parseJsonPath(item[0])
@@ -1199,6 +1199,8 @@ if (binaryInfo != null && binaryInfo.length > 0) {
11991199
rules.push(mark + noteK + ruletype + ',' + rulevalue + ',' + rulepolicy + rulenore + rulesni + rulepm)
12001200
} else if (/^(?:and|or|not)$/i.test(ruletype) && !isStashiOS) {
12011201
rules.push(ori)
1202+
} else if (/^(?:and|or|not)$/i.test(ruletype) && isStashiOS) {
1203+
rules.push(mark + noteK2 + '- ' + ori)
12021204
} else if (/(?:^domain$|domain-suffix|domain-keyword|ip-|de?st-port)/i.test(ruletype) && isStashiOS) {
12031205
rules.push(mark + noteK2 + '- ' + ruletype + ',' + rulevalue + ',' + rulepolicy + rulenore)
12041206
} else if (/src-port/i.test(ruletype) && (isSurgeiOS || isLooniOS)) {

0 commit comments

Comments
 (0)