Skip to content

Commit c359be2

Browse files
committed
chore: fix bug
1 parent 21c1423 commit c359be2

File tree

2 files changed

+38
-13
lines changed

2 files changed

+38
-13
lines changed

luci-app-openclash/root/usr/share/openclash/openclash_watchdog.sh

+22
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,28 @@ begin
108108
end;
109109
end;
110110
end;
111+
if not i['path'] and i['type'] == 'inline' and i['payload'] and not i['payload'].empty? then
112+
Value['payload'].each do
113+
|k|
114+
threadsp << Thread.new {
115+
if k['server'] then
116+
if servers.include?(k['server']) then
117+
next;
118+
end;
119+
if k['server'] =~ reg then
120+
servers = servers.push(k['server']).uniq
121+
syscall = '/usr/share/openclash/openclash_debug_dns.lua 2>/dev/null \"' + k['server'] + '\" \"true\"'
122+
result = IO.popen(syscall).read.split(/\n+/)
123+
if result then
124+
ips = ips | result
125+
end;
126+
else
127+
ips = ips.push(k['server']).uniq
128+
end;
129+
end;
130+
};
131+
end;
132+
end;
111133
threadsp.each(&:join);
112134
};
113135
end;

luci-app-openclash/root/usr/share/openclash/yml_rules_change.sh

+16-13
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ yml_other_set()
367367
);
368368
match_group=Value['rules'].grep(/(MATCH|FINAL)/)[0];
369369
if not match_group.nil? then
370-
common_port_group=match_group.split(',')[2] or common_port_group=match_group.split(',')[1];
370+
common_port_group = (match_group.split(',')[-1] =~ /^no-resolve$|^src$/) ? match_group.split(',')[-2] : match_group.split(',')[-1];
371371
if not common_port_group.nil? then
372372
ruby_add_index = Value['rules'].index(Value['rules'].grep(/(MATCH|FINAL)/).first);
373373
ruby_add_index ||= -1;
@@ -486,7 +486,7 @@ yml_other_set()
486486
Value_1 = YAML.load_file('/tmp/yaml_rule_set_bottom_custom.yaml');
487487
if ruby_add_index != -1 then
488488
Value_1['rules'].uniq.reverse.each{|x|
489-
RULE_GROUP = x.split(',')[2] || RULE_GROUP = x.split(',')[1];
489+
RULE_GROUP = (x.split(',')[-1] =~ /^no-resolve$|^src$/) ? x.split(',')[-2] : x.split(',')[-1];
490490
if CONFIG_GROUP.include?(RULE_GROUP) then
491491
Value['rules'].insert(ruby_add_index,x);
492492
else
@@ -495,7 +495,7 @@ yml_other_set()
495495
};
496496
else
497497
Value_1['rules'].uniq.each{|x|
498-
RULE_GROUP = x.split(',')[2] || RULE_GROUP = x.split(',')[1];
498+
RULE_GROUP = (x.split(',')[-1] =~ /^no-resolve$|^src$/) ? x.split(',')[-2] : x.split(',')[-1];
499499
if CONFIG_GROUP.include?(RULE_GROUP) then
500500
Value['rules'].insert(ruby_add_index,x);
501501
else
@@ -507,7 +507,7 @@ yml_other_set()
507507
if File::exist?('/tmp/yaml_rule_set_top_custom.yaml') then
508508
Value_1 = YAML.load_file('/tmp/yaml_rule_set_top_custom.yaml');
509509
Value_1['rules'].uniq.reverse.each{|x|
510-
RULE_GROUP = x.split(',')[2] || RULE_GROUP = x.split(',')[1];
510+
RULE_GROUP = (x.split(',')[-1] =~ /^no-resolve$|^src$/) ? x.split(',')[-2] : x.split(',')[-1];
511511
if CONFIG_GROUP.include?(RULE_GROUP) then
512512
Value['rules'].insert(0,x);
513513
else
@@ -519,7 +519,7 @@ yml_other_set()
519519
if File::exist?('/tmp/yaml_rule_set_top_custom.yaml') then
520520
Value_1 = YAML.load_file('/tmp/yaml_rule_set_top_custom.yaml')['rules'].uniq;
521521
Value_1.each{|x|
522-
RULE_GROUP = x.split(',')[2] || RULE_GROUP = x.split(',')[1];
522+
RULE_GROUP = (x.split(',')[-1] =~ /^no-resolve$|^src$/) ? x.split(',')[-2] : x.split(',')[-1];
523523
if not CONFIG_GROUP.include?(RULE_GROUP) then
524524
Value_1.delete(x);
525525
YAML.LOG('Warning: Skiped The Custom Rule Because Group & Proxy Not Found:【' + x + '】');
@@ -530,7 +530,7 @@ yml_other_set()
530530
if File::exist?('/tmp/yaml_rule_set_bottom_custom.yaml') then
531531
Value_1 = YAML.load_file('/tmp/yaml_rule_set_bottom_custom.yaml')['rules'].uniq;
532532
Value_1.each{|x|
533-
RULE_GROUP = x.split(',')[2] || RULE_GROUP = x.split(',')[1];
533+
RULE_GROUP = (x.split(',')[-1] =~ /^no-resolve$|^src$/) ? x.split(',')[-2] : x.split(',')[-1];
534534
if not CONFIG_GROUP.include?(RULE_GROUP) then
535535
Value_1.delete(x);
536536
YAML.LOG('Warning: Skiped The Custom Rule Because Group & Proxy Not Found:【' + x + '】');
@@ -564,7 +564,7 @@ yml_other_set()
564564
end;
565565
if defined? Value_2 then
566566
Value_2.each{|x|
567-
RULE_GROUP = x.split(',')[2] || RULE_GROUP = x.split(',')[1];
567+
RULE_GROUP = (x.split(',')[-1] =~ /^no-resolve$|^src$/) ? x.split(',')[-2] : x.split(',')[-1];
568568
if CONFIG_GROUP.include?(RULE_GROUP) then
569569
Value['rules'].insert(0,x);
570570
else
@@ -597,7 +597,7 @@ yml_other_set()
597597
Value_4 = Value_4.reverse!;
598598
end;
599599
Value_4.each{|x|
600-
RULE_GROUP = x.split(',')[2] || RULE_GROUP = x.split(',')[1];
600+
RULE_GROUP = (x.split(',')[-1] =~ /^no-resolve$|^src$/) ? x.split(',')[-2] : x.split(',')[-1];
601601
if CONFIG_GROUP.include?(RULE_GROUP) then
602602
Value['rules'].insert(ruby_add_index,x);
603603
else
@@ -615,7 +615,7 @@ yml_other_set()
615615
if Value_1.class.to_s == 'Hash' then
616616
if not Value_1['rules'].to_a.empty? and Value_1['rules'].class.to_s == 'Array' then
617617
Value_1['rules'].to_a.each{|x|
618-
RULE_GROUP = x.split(',')[2] || RULE_GROUP = x.split(',')[1];
618+
RULE_GROUP = (x.split(',')[-1] =~ /^no-resolve$|^src$/) ? x.split(',')[-2] : x.split(',')[-1];
619619
if not CONFIG_GROUP.include?(RULE_GROUP) then
620620
Value_1['rules'].delete(x);
621621
YAML.LOG('Warning: Skiped The Custom Rule Because Group & Proxy Not Found:【' + x + '】');
@@ -626,7 +626,7 @@ yml_other_set()
626626
end;
627627
elsif Value_1.class.to_s == 'Array' then
628628
Value_1.each{|x|
629-
RULE_GROUP = x.split(',')[2] || RULE_GROUP = x.split(',')[1];
629+
RULE_GROUP = (x.split(',')[-1] =~ /^no-resolve$|^src$/) ? x.split(',')[-2] : x.split(',')[-1];
630630
if not CONFIG_GROUP.include?(RULE_GROUP) then
631631
Value_1.delete(x);
632632
YAML.LOG('Warning: Skiped The Custom Rule Because Group & Proxy Not Found:【' + x + '】');
@@ -644,7 +644,7 @@ yml_other_set()
644644
if Value_2.class.to_s == 'Hash' then
645645
if not Value_2['rules'].to_a.empty? and Value_2['rules'].class.to_s == 'Array' then
646646
Value_2['rules'].to_a.each{|x|
647-
RULE_GROUP = x.split(',')[2] || RULE_GROUP = x.split(',')[1];
647+
RULE_GROUP = (x.split(',')[-1] =~ /^no-resolve$|^src$/) ? x.split(',')[-2] : x.split(',')[-1];
648648
if not CONFIG_GROUP.include?(RULE_GROUP) then
649649
Value_2['rules'].delete(x);
650650
YAML.LOG('Warning: Skiped The Custom Rule Because Group & Proxy Not Found:【' + x + '】');
@@ -655,7 +655,7 @@ yml_other_set()
655655
end;
656656
elsif Value_2.class.to_s == 'Array' then
657657
Value_2.each{|x|
658-
RULE_GROUP = x.split(',')[2] || RULE_GROUP = x.split(',')[1];
658+
RULE_GROUP = (x.split(',')[-1] =~ /^no-resolve$|^src$/) ? x.split(',')[-2] : x.split(',')[-1];
659659
if not CONFIG_GROUP.include?(RULE_GROUP) then
660660
Value_2.delete(x);
661661
YAML.LOG('Warning: Skiped The Custom Rule Because Group & Proxy Not Found:【' + x + '】');
@@ -684,7 +684,7 @@ yml_other_set()
684684
Value_3 = Value_3.reverse!;
685685
end
686686
Value_3.each{|x|
687-
RULE_GROUP = x.split(',')[2] || RULE_GROUP = x.split(',')[1];
687+
RULE_GROUP = (x.split(',')[-1] =~ /^no-resolve$|^src$/) ? x.split(',')[-2] : x.split(',')[-1];
688688
if CONFIG_GROUP.include?(RULE_GROUP) then
689689
Value['rules'].insert(ruby_add_index,x);
690690
else
@@ -780,6 +780,9 @@ yml_other_set()
780780
v=File.basename(x['path']);
781781
x['path']='./'+p+'/'+v;
782782
end;
783+
if not x['path'] and x['type'] == 'http' then
784+
x['path']='./'+p+'/'+x['name'];
785+
end;
783786
#CDN Replace
784787
if '$github_address_mod' != '0' then
785788
if '$github_address_mod' == 'https://cdn.jsdelivr.net/' or '$github_address_mod' == 'https://fastly.jsdelivr.net/' or '$github_address_mod' == 'https://testingcf.jsdelivr.net/'then

0 commit comments

Comments
 (0)