forked from ClitherProject/Slither.io-Protocol
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver-list.rb
executable file
·38 lines (30 loc) · 950 Bytes
/
server-list.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
#!/usr/bin/env ruby
require 'open-uri'
contents = open('http://slither.io/i33628.txt') {|f| f.read}
def to24bit(val1, val2, val3)
return (val1 * (256^2)) + (val2 * 256) + val3
end
# Step 1
dropped = contents.split('').drop(1)
# Step 2
converted = dropped.map {|n| n.ord - 97}
# Step 3
subtracted = converted.each_with_index.map {|n, i| n - (7 * i)}
# Step 4
moduloed = subtracted.map {|n| (n % 26 + 26) % 26}
# Step 5
evens = moduloed.values_at(* moduloed.each_index.select {|i| i.even?})
evens = evens.map {|n| n * 16}
odds = moduloed.values_at(* moduloed.each_index.select {|i| i.odd?})
merged = [evens, odds].transpose.map {|x| x.reduce(:+)}
i = 0
while i < merged.size do
puts "ip: #{merged[i]}.#{merged[i+1]}.#{merged[i+2]}.#{merged[i+3]}"
i += 4
puts "port: #{to24bit(merged[i], merged[i+1], merged[i+2])}"
i += 3
puts "ac: #{to24bit(merged[i], merged[i+1], merged[i+2])}"
i += 3
puts "clu: #{merged[i]}\n\n"
i += 1
end