import ipaddress


def rule(event):
    if all(
        [
            event.deep_get("EventID", default="") in [30803, 30804, 30806],
            not any(
                [
                    any(
                        [
                            ipaddress.ip_address(event.deep_get("ServerAddress", default=""))
                            in ipaddress.ip_network("10.0.0.0/8"),
                            ipaddress.ip_address(event.deep_get("ServerAddress", default=""))
                            in ipaddress.ip_network("127.0.0.0/8"),
                            ipaddress.ip_address(event.deep_get("ServerAddress", default=""))
                            in ipaddress.ip_network("169.254.0.0/16"),
                            ipaddress.ip_address(event.deep_get("ServerAddress", default=""))
                            in ipaddress.ip_network("172.16.0.0/12"),
                            ipaddress.ip_address(event.deep_get("ServerAddress", default=""))
                            in ipaddress.ip_network("192.168.0.0/16"),
                            ipaddress.ip_address(event.deep_get("ServerAddress", default=""))
                            in ipaddress.ip_network("::1/128"),
                            ipaddress.ip_address(event.deep_get("ServerAddress", default=""))
                            in ipaddress.ip_network("fe80::/10"),
                            ipaddress.ip_address(event.deep_get("ServerAddress", default=""))
                            in ipaddress.ip_network("fc00::/7"),
                        ]
                    ),
                    any(
                        [
                            event.deep_get("Address", default="").startswith("10."),
                            event.deep_get("Address", default="").startswith("127."),
                            event.deep_get("Address", default="").startswith("169.254."),
                            event.deep_get("Address", default="").startswith("172."),
                            event.deep_get("Address", default="").startswith("192.168."),
                            event.deep_get("Address", default="").startswith("::1"),
                            event.deep_get("Address", default="").startswith("fe80::"),
                            event.deep_get("Address", default="").startswith("fc00::"),
                        ]
                    ),
                    any(
                        [
                            "00000000000000000000000000000001"
                            in event.deep_get("Address", default=""),
                            "FE80000000000000" in event.deep_get("Address", default=""),
                            "FC00000000000000" in event.deep_get("Address", default=""),
                            "0200????C0A8" in event.deep_get("Address", default=""),
                            "0200????AC" in event.deep_get("Address", default=""),
                            "0200????0A" in event.deep_get("Address", default=""),
                            "0200????7F" in event.deep_get("Address", default=""),
                            "0200????A9FE" in event.deep_get("Address", default=""),
                        ]
                    ),
                    any(
                        [
                            "00000000000000000000000000000001"
                            in event.deep_get("ServerAddress", default=""),
                            "FE80000000000000" in event.deep_get("ServerAddress", default=""),
                            "FC00000000000000" in event.deep_get("ServerAddress", default=""),
                            "0200????C0A8" in event.deep_get("ServerAddress", default=""),
                            "0200????AC" in event.deep_get("ServerAddress", default=""),
                            "0200????0A" in event.deep_get("ServerAddress", default=""),
                            "0200????7F" in event.deep_get("ServerAddress", default=""),
                            "0200????A9FE" in event.deep_get("ServerAddress", default=""),
                        ]
                    ),
                    any(
                        [
                            "00000000000000000000000000000001"
                            in event.deep_get("RemoteAddress", default=""),
                            "FE80000000000000" in event.deep_get("RemoteAddress", default=""),
                            "FC00000000000000" in event.deep_get("RemoteAddress", default=""),
                            "0200????C0A8" in event.deep_get("RemoteAddress", default=""),
                            "0200????AC" in event.deep_get("RemoteAddress", default=""),
                            "0200????0A" in event.deep_get("RemoteAddress", default=""),
                            "0200????7F" in event.deep_get("RemoteAddress", default=""),
                            "0200????A9FE" in event.deep_get("RemoteAddress", default=""),
                        ]
                    ),
                ]
            ),
        ]
    ):
        return True
    return False
