Skip to content

Instantly share code, notes, and snippets.

View bluemonk's full-sized avatar

Marco Ceresa bluemonk

  • Geneva, Switzerland
View GitHub Profile
@bluemonk
bluemonk / howto.md
Last active January 25, 2026 10:26
Looking Glass on NixOS

Synopsis

This howto illustrates how to configure Looking Glass on NixOS.

Prerequisites

  • NixOS 25.11 (unstable should work, but I haven't tested it)
  • Looking Glass B7
  • systemd 258 (because of this)
n = 50_000
ipaddr = IPAddr.new("192.168.10.100/32")
ipaddress = IPAddress::IPv4.new("192.168.10.100/32")
Benchmark.bm do|b|
b.report("ipaddr ") do
n.times { IPAddr.new("192.168.10.0/24").include?(ipaddr) }
end
b.report("ipaddress parse ") do
n = 50_000
Benchmark.bm do|b|
b.report("ipaddr ") do
n.times { IPAddr.new("192.168.10.100").to_s }
end
b.report("ipaddress parse ") do
n.times { IPAddress.parse("192.168.10.100").to_s }
end
IPAddr.new "10.0.0.2955/30"
#=> #<IPAddr: IPv4:10.0.11.136/255.255.255.252>
1) Error:
test_guess_should_recognize_ipv4(ServerTest):
Whois::AllocationUnknown: IP Allocation for `192.168.1.1' unknown. Server definitions might be outdated.
./test/../lib/whois/server.rb:164:in `find_for_ip'
./test/../lib/whois/server.rb:127:in `guess'
./test/whois/server_test.rb:22:in `test_guess_should_recognize_ipv4'
/usr/lib/ruby/gems/1.8/gems/mocha-0.9.8/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb:19:in `__send__'
/usr/lib/ruby/gems/1.8/gems/mocha-0.9.8/lib/mocha/integration/test_unit/ruby_version_186_and_above.rb:19:in `run'
whois$ rake console
(in /home/marco/GitHub/whois)
CodeStatistics (Rails) is not available
irb -rubygems -I lib -r whois.rb
irb(main):001:0> Whois::Server.guess("192.168.1.1")
=> #<Whois::Server::Adapters::Standard:0xb7681b74 @options={}, @host="whois.arin.net", @type=:ipv4, @allocation="192.0.0.0/8">
diff --git a/lib/whois/server.rb b/lib/whois/server.rb
index 787efa8..df6f5ae 100644
--- a/lib/whois/server.rb
+++ b/lib/whois/server.rb
@@ -162,6 +162,7 @@ module Whois
end
def self.find_for_ipv4(qstring)
+ cippirimerlo
ip = IPAddr.new(qstring)