mirror of
https://github.com/discourse/discourse.git
synced 2024-11-28 00:33:37 +08:00
0398ab7514
first FEATURE: allow admins to search users using IP ranges
17 lines
204 B
Ruby
17 lines
204 B
Ruby
class IPAddr
|
|
|
|
def to_cidr_s
|
|
if @addr
|
|
mask = @mask_addr.to_s(2).count('1')
|
|
if mask == 32
|
|
to_s
|
|
else
|
|
"#{to_s}/#{mask}"
|
|
end
|
|
else
|
|
nil
|
|
end
|
|
end
|
|
|
|
end
|