class Object
Public Instance Methods
get_hostname(rule)
click to toggle source
# File bin/gfwlist2ipset, line 64 def get_hostname(rule) host = URI.parse(rule).host if PublicSuffix.valid?(host) return PublicSuffix.parse(host).domain elsif PublicSuffix.valid?('.' + host) tld = PublicSuffix.parse('.' + host).tld return tld if tld.include?('.') && tld == host else puts 'Hostname not valid: ' + host end return nil rescue puts 'can not parse rule as url: ' + rule return nil end