Skip to content

Commit

Permalink
fix: ip or site rules is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
7Sageer committed Aug 25, 2024
1 parent 0ebe3c4 commit 54911e6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/ClashConfigBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ export class ClashConfigBuilder extends BaseConfigBuilder {
const rules = generateRules(this.selectedRules, this.customRules);

this.config.rules = rules.flatMap(rule => {
const siteRules = rule.site_rules ? rule.site_rules.map(site => `GEOSITE,${site},${rule.outbound}`) : [];
const ipRules = rule.ip_rules ? rule.ip_rules.map(ip => `GEOIP,${ip},${rule.outbound}`) : [];
const siteRules = rule.site_rules[0] !== '' ? rule.site_rules.map(site => `GEOSITE,${site},${rule.outbound}`) : [];
const ipRules = rule.ip_rules[0] !== '' ? rule.ip_rules.map(ip => `GEOIP,${ip},${rule.outbound}`) : [];
return [...siteRules, ...ipRules];
});

Expand Down
3 changes: 2 additions & 1 deletion src/SingboxConfigBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ export class ConfigBuilder extends BaseConfigBuilder {
this.config.route.rule_set = [...site_rule_sets, ...ip_rule_sets];

this.config.route.rules = rules.map(rule => ({
rule_set: [...rule.site_rules, ...rule.ip_rules.map(ip => `${ip}-ip`)],
rule_set: rule.site_rules[0] !== '' ? [...rule.site_rules, ...rule.ip_rules.map(ip => `${ip}-ip`)] :
rule.ip_rules[0] !== '' ? rule.ip_rules.map(ip => `${ip}-ip`) : [],
outbound: rule.outbound
}));

Expand Down

0 comments on commit 54911e6

Please sign in to comment.