forked from Leev1s/FAK-DNS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
autoupdater.rb
executable file
·52 lines (42 loc) · 1.36 KB
/
autoupdater.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/ruby
require 'concurrent'
require 'filelock'
require 'set'
require_relative 'verify'
$stdout.sync = true
echo_set = Concurrent::Set[]
tested = Concurrent::Set[]
File.readlines("accelerated-domains.china.conf").each do |line|
line.chomp!
if !line.empty? and !line.start_with?("#")
tested << line.split("/")[1]
end
end
v = ChinaListVerify.new
pool = Concurrent::FixedThreadPool.new(ENV.fetch("JOBS", Concurrent.processor_count).to_i)
ARGF.each do |domain|
pool.post do
domain.chomp!.downcase!
next if domain.empty? or domain.end_with?('.arpa', '.cn', '.top')
if !echo_set.include? domain
puts "Trying to detect #{domain}"
echo_set << domain
end
begin
domain = PublicSuffix.domain(domain, ignore_private: true)
rescue PublicSuffix::DomainNotAllowed, PublicSuffix::DomainInvalid
next
end
next if tested.include? domain
tested << domain
if v.check_domain_verbose(domain, enable_cdnlist: false, show_green: true)
Filelock '.git.lock' do
puts `./updater.rb -a #{domain}`
puts `git commit -S -am "accelerated-domains: add #{domain}"` if $?.success?
puts `./update-local` if $?.success?
end
end
end
end
pool.shutdown
pool.wait_for_termination