<s> """<STR_LIT>""" <EOL> import socket <EOL> import idiokit <EOL> import urlparse <EOL> from abusehelper . core import utils , bot , events <EOL> FEED_URL = "<STR_LIT>" <EOL> def i_am_a_name ( string ) : <EOL> for addr_type in ( socket . AF_INET , socket . AF_INET6 ) : <EOL> try : <EOL> socket . inet_ntop ( addr_type , socket . inet_pton ( addr_type , string ) ) <EOL> except ( ValueError , socket . error ) : <EOL> pass <EOL> else : <EOL> return False <EOL> return True <EOL> def parseURL ( line ) : <EOL> parsed = urlparse . urlparse ( line ) <EOL> if parsed . scheme and parsed . netloc : <EOL> return line . strip ( ) , parsed . netloc <EOL> else : <EOL> return None , None <EOL> class VxVaultBot ( bot . PollingBot ) : <EOL> feed_url = bot . Param ( default = FEED_URL ) <EOL> @ idiokit . stream <EOL> def poll ( self ) : <EOL> self . log . info ( "<STR_LIT>" . format ( self . feed_url ) ) <EOL> try : <EOL> info , fileobj = yield utils . fetch_url ( self . feed_url ) <EOL> except utils . FetchUrlFailed as fuf : <EOL> raise bot . PollSkipped ( "<STR_LIT>" . format ( self . feed_url , fuf ) ) <EOL> self . log . info ( "<STR_LIT>" ) <EOL> for line in fileobj : <EOL> url , netloc = parseURL ( line ) <EOL> if url is None : <EOL> continue <EOL> event = events . Event ( ) <EOL> event . add ( "<STR_LIT:url>" , url ) <EOL> if i_am_a_name ( netloc ) : <EOL> event . add ( "<STR_LIT>" , netloc ) <EOL> else : <EOL> event . add ( "<STR_LIT>" , netloc ) <EOL> event . add ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> event . add ( "<STR_LIT>" , self . feed_url ) <EOL> event . add ( "<STR_LIT:type>" , "<STR_LIT>" ) <EOL> event . add ( "<STR_LIT:description>" , "<STR_LIT>" ) <EOL> yield idiokit . send ( event ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> VxVaultBot . from_command_line ( ) . execute ( ) </s>
