summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
b7c1665)
It still returns a raw integer -- for now. But it's a start.
+def parse_address(addrstr):
+ return unpack('>L', S.inet_aton(addrstr))[0]
+
###--------------------------------------------------------------------------
### Parse the configuration file.
###--------------------------------------------------------------------------
### Parse the configuration file.
## and MASK is either a dotted-quad or a single integer N indicating
## a mask with N leading ones followed by trailing zeroes.
slash = net.index('/')
## and MASK is either a dotted-quad or a single integer N indicating
## a mask with N leading ones followed by trailing zeroes.
slash = net.index('/')
- addr, = unpack('>L', S.inet_aton(net[:slash]))
+ addr = parse_address(net[:slash])
if net[slash + 1:].isdigit():
n = int(net[slash + 1:], 10)
mask = (1 << 32) - (1 << 32 - n)
else:
if net[slash + 1:].isdigit():
n = int(net[slash + 1:], 10)
mask = (1 << 32) - (1 << 32 - n)
else:
- mask, = unpack('>L', S.inet_aton(net[slash + 1:]))
+ mask = parse_address(net[slash + 1:])
pats.append((tag, peer, addr & mask, mask))
## Annoyingly, RawConfigParser doesn't preserve the order of options.
pats.append((tag, peer, addr & mask, mask))
## Annoyingly, RawConfigParser doesn't preserve the order of options.
try:
sk.connect((peer, 1))
addr, _ = sk.getsockname()
try:
sk.connect((peer, 1))
addr, _ = sk.getsockname()
- addr, = unpack('>L', S.inet_aton(addr))
+ addr = parse_address(addr)
return addr
except S.error:
return None
return addr
except S.error:
return None