rubyのIPAddrクラスを使います。
require "ipaddr"
def ip_in_range?(low,high,addr)
(IPAddr.new(low).to_i..IPAddr.new(high).to_i).cover?(IPAddr.new(addr).to_i)
end
Go to list of users who liked
Share on X(Twitter)
Share on Facebook
More than 5 years have passed since last update.
rubyのIPAddrクラスを使います。
require "ipaddr"
def ip_in_range?(low,high,addr)
(IPAddr.new(low).to_i..IPAddr.new(high).to_i).cover?(IPAddr.new(addr).to_i)
end
Register as a new user and use Qiita more conveniently
Go to list of users who liked