Exemplo n.º 1
0
 def get_hostname(self):
     if self.hostname is None:
         resolver = coro.get_resolver()
         try:
             in_addr = to_in_addr_arpa (self.ip)
             self.hostname = resolver.cache.query (in_addr, 'PTR')[0][1]
         except (DNS_Error, IndexError):
             # XXX: Log debug message.
             pass
     return self.hostname
 def get_hostname(self):
     if self.hostname is None:
         resolver = coro.get_resolver()
         try:
             in_addr = to_in_addr_arpa(self.ip)
             self.hostname = resolver.cache.query(in_addr, 'PTR')[0][1]
         except (DNS_Error, IndexError):
             # XXX: Log debug message.
             pass
     return self.hostname
Exemplo n.º 3
0
 def lookup_ptr(self):
     ip = self.other_addr[0]
     if '.' in ip:
         ip = '.'.join(ip.split('.')[::-1]) + '.in-addr.arpa'
     else:
         ip = self.frob_ipv6(ip) + '.ip6.arpa'
     r = coro.get_resolver()
     try:
         answers = r.cache.query(ip, 'PTR')
         self.other_name = answers[0][1]
     except coro.dns.exceptions.DNS_Error:
         pass
Exemplo n.º 4
0
 def lookup_ptr (self):
     ip = self.other_addr[0]
     if '.' in ip:
         ip = '.'.join (ip.split('.')[::-1]) + '.in-addr.arpa'
     else:
         ip = self.frob_ipv6 (ip) + '.ip6.arpa'
     r = coro.get_resolver()
     try:
         answers = r.cache.query (ip, 'PTR')
         self.other_name = answers[0][1]
     except coro.dns.exceptions.DNS_Error:
         pass
Exemplo n.º 5
0
 def seed(self):
     # called only when we don't have a cached peer set.
     G.log('dns', 'seeding...')
     timestamp = coro.tsc_time.now_raw_posix_sec()
     r = coro.get_resolver()
     addrs = set()
     for seed in dns_seeds:
         try:
             for (t, ip) in r.cache.query(seed, 'A'):
                 self.add(timestamp, (1, (ip, 8333)))
             for (t, ip) in r.cache.query(seed, 'AAAA'):
                 self.add(timestamp, (1, (ip, 8333)))
         except coro.dns.exceptions.DNS_Soft_Error:
             pass
Exemplo n.º 6
0
 def seed (self):
     # called only when we don't have a cached peer set.
     G.log ('dns', 'seeding...')
     timestamp = coro.tsc_time.now_raw_posix_sec()
     r = coro.get_resolver()
     addrs = set()
     for seed in dns_seeds:
         try:
             for (t, ip) in r.cache.query (seed, 'A'):
                 self.add (timestamp, (1, (ip, 8333)))
             for (t, ip) in r.cache.query (seed, 'AAAA'):
                 self.add (timestamp, (1, (ip, 8333)))
         except coro.dns.exceptions.DNS_Soft_Error:
             pass
Exemplo n.º 7
0
def doit (ip, port, username):
    if not is_ip (ip):
        ip = coro.get_resolver().resolve_ipv4 (ip)
    debug = coro.ssh.util.debug.Debug()
    debug.level = coro.ssh.util.debug.DEBUG_3
    client = coro.ssh.transport.client.SSH_Client_Transport(debug=debug)
    transport = coro.ssh.l4_transport.coro_socket_transport.coro_socket_transport(ip, port=port)
    client.connect(transport)
    auth_method = coro.ssh.auth.userauth.Userauth(client, username)
    service = coro.ssh.connection.connect.Connection_Service(client)
    client.authenticate(auth_method, service.name)
    channel = coro.ssh.connection.interactive_session.Interactive_Session_Client(service)
    channel.open()
    channel.open_pty()
    channel.open_shell()
    set_stdin_unbuffered()
    coro.spawn(input_thread, channel)
    coro.spawn(transport_thread, channel)
Exemplo n.º 8
0
def doit(ip, port, username):
    if not is_ip(ip):
        ip = coro.get_resolver().resolve_ipv4(ip)
    debug = coro.ssh.util.debug.Debug()
    debug.level = coro.ssh.util.debug.DEBUG_3
    client = coro.ssh.transport.client.SSH_Client_Transport(debug=debug)
    transport = coro.ssh.l4_transport.coro_socket_transport.coro_socket_transport(
        ip, port=port)
    client.connect(transport)
    auth_method = coro.ssh.auth.userauth.Userauth(client, username)
    service = coro.ssh.connection.connect.Connection_Service(client)
    client.authenticate(auth_method, service.name)
    channel = coro.ssh.connection.interactive_session.Interactive_Session_Client(
        service)
    channel.open()
    channel.open_pty()
    channel.open_shell()
    set_stdin_unbuffered()
    coro.spawn(input_thread, channel)
    coro.spawn(transport_thread, channel)