def parse_addr(addr_str):
    """parse an IPv4 address, e.g. "1.2.3.4:567",
       return tuple of IP and port, e.g. ("1.2.3.4", 567), None on error"""
    fields = addr_str.split(':')
    if len(fields) > 2:
        return None
    ip = fields[0]
    port = fields[1]
    if len(ip.split('.')) != 4:
        return None
    try:
        port = int(port)
    except:
        return None
    if port < 0 or port > 65535:
        return None
    return ip, port
