All Samples(508) | Call(451) | Derive(0) | Import(57)
inet_aton(string) -> packed 32-bit IP representation Convert an IP address in string format (123.45.67.89) to the 32-bit packed binary format used in low-level network functions.
src/p/y/PyTide-HEAD/NetworkTools/DNS/Lib.py PyTide(Download)
from struct import pack as struct_pack
from struct import unpack as struct_unpack
from socket import inet_ntoa, inet_aton
def pack16bit(n):
return struct_pack('!H', n)
def addr2bin(addr):
return struct_unpack('!l', inet_aton(addr))[0]
def bin2addr(n):
return inet_ntoa(struct_pack('!L', n))
# Packing class
src/t/o/torrentcast-HEAD/BTL/IPTools.py torrentcast(Download)
# License.
from struct import pack, unpack
from socket import inet_aton, inet_ntoa
def compact(ip, port):
return pack("!4sH", inet_aton(ip), port) # ! == "network order"
src/w/o/wolpertinger-HEAD/scripts/wolper-mcp.py wolpertinger(Download)
import warnings from datetime import datetime from socket import gethostbyname, htonl, ntohl, inet_aton, inet_ntoa from struct import pack, unpack # disable warnings
def get_host_results(self, scan_id, ip):
"""Get portscan results of specified host"""
results = [] # result list
# convert IP address
ip = unpack("I", inet_aton(ip))[0]
src/p/y/pyautomation-HEAD/DNS/Lib.py pyautomation(Download)
from struct import pack as struct_pack
from struct import unpack as struct_unpack
from socket import inet_ntoa, inet_aton
def pack16bit(n):
return struct_pack('!H', n)
def addr2bin(addr):
return struct_unpack('!l', inet_aton(addr))[0]
def bin2addr(n):
return inet_ntoa(struct_pack('!L', n))
# Packing class
src/p/y/pydns-2.3.4/DNS/Lib.py pydns(Download)
from struct import pack as struct_pack
from struct import unpack as struct_unpack
from socket import inet_ntoa, inet_aton
def pack16bit(n):
return struct_pack('!H', n)
def addr2bin(addr):
return struct_unpack('!l', inet_aton(addr))[0]
def bin2addr(n):
return inet_ntoa(struct_pack('!L', n))
# Packing class
src/w/c/wc3helper-HEAD/trunk/libs/ip2cc/update.py wc3helper(Download)
#!/usr/bin/env python # $Id: update.py,v 1.4 2005/03/23 15:18:41 ods Exp $ from urllib2 import urlopen from socket import inet_aton, inet_ntoa import struct, sys, os from ip2cc import cc2name
parts[6] in ('allocated', 'assigned') and \
name==parts[0]:
first = parts[3]
first_int = struct.unpack('!I', inet_aton(first))[0]
last_int = first_int+int(parts[4])-1
last = inet_ntoa(struct.pack('!I', last_int))
try:
src/w/c/wc3helper-HEAD/libs/ip2cc/update.py wc3helper(Download)
#!/usr/bin/env python # $Id: update.py,v 1.4 2005/03/23 15:18:41 ods Exp $ from urllib2 import urlopen from socket import inet_aton, inet_ntoa import struct, sys, os from ip2cc import cc2name
parts[6] in ('allocated', 'assigned') and \
name==parts[0]:
first = parts[3]
first_int = struct.unpack('!I', inet_aton(first))[0]
last_int = first_int+int(parts[4])-1
last = inet_ntoa(struct.pack('!I', last_int))
try:
src/f/l/flamboyantsshd-0.1r1/flamboyantsshd/handlers.py flamboyantsshd(Download)
"Failure handlers"
from socket import inet_aton as ip2long
import subprocess
class Handler(object):
def __init__(self, penalties, tolerance):
def ban(self, who):
long_addr = ip2long(who)
if long_addr not in self.banned:
self._ipt("-I", self.chain_name, "-s", who, "-j", self.abuse_target)
self.banned.append(ip2long(who))
def abused(self, source, penalty=1):
penalties = self.abusers[source] = self.abusers.get(source, self.tolerance.base_penalty) + penalty
return penalties
def invalid_user(self, user=None, source=None):
if self.abused(ip2long(source), self.penalties.invalid_user) > self.tolerance.invalid_user:
def password_failure(self, user=None, source=None):
if self.abused(ip2long(source), self.penalties.password_failure) > self.tolerance.password_failure:
self.ban(source)
class DebugHandler(Handler):
def __getattr__(self, attr):
def f(*a, **kw):
src/p/e/pendrell-0.3.3/lib/protocols.py pendrell(Download)
from struct import calcsize, pack, unpack, error as UnpackError
from socket import inet_aton, inet_ntoa
from urlparse import urlunsplit
from twisted.internet import (error as netErr,
interfaces as netInterfaces, protocol, reactor)
def openConnection(self, host, port, user=""):
log.debug("%r: Opening a SOCKSv4 connection to %s%s:%d" %
(self, "%s@" % user if user else "", host, port))
hostIP = yield reactor.resolve(host)
server = inet_aton(hostIP)
log.debug("user: %r" % user)
packed = pack("!BBH", self._VERSION_CODE, self._CONNECT_CODE, port)
packed += inet_aton(hostIP)
packed += user + "\000"
self.transport.write(packed)
version = self._VERSION_CODE
command = self._CONNECT_CODE
server = inet_aton(self._INVALID_SERVER)
domain = host
log.debug("version: %r" % version)
src/w/h/whitetrash-HEAD/trunk/django_site/whitetrash/whitelist/templatetags/whitetrash_filters.py whitetrash(Download)
#!/usr/bin/env python from django import template from django.template.defaultfilters import stringfilter from whitetrash.whitelist.models import Whitelist from socket import inet_aton import re
def ip(value):
try:
inet_aton(value)
return value
except:
return ""
1 | 2 | 3 | 4 | 5 | 6 Next