예제 #1
0
def Maint_check(context, data):
    """

    :type context: ShipProxy.ShipProxy
    """
    global maintmode
    if not maintmode:
        return data
    context.send_crypto_packet(
        SystemMessagePacket(
            "The PSO2 or PSO2Proxy server is currently undergoing maintenance. Please try again later.",
            0x1).build())
    context.transport.loseConnection()
    return data
예제 #2
0
def whitelist_check(context, data):
    """

    :type context: ShipProxy.ShipProxy
    """
    global whitelist
    start = len(data) - 132  # Skip password
    username = data[start:start + 0x40].decode('utf-8')
    username = username.rstrip('\0')
    if username not in whitelist:
        print("[Whitelist] %s is not in the whitelist, disconnecting client." %
              username)
        context.send_crypto_packet(
            SystemMessagePacket(
                "You are not on the whitelist for this proxy, please contact the owner of this proxy.",
                0x1).build())
        context.transport.loseConnection()
    return data
예제 #3
0
def whitelist_check(context, data):
    """

    :type context: ShipProxy.ShipProxy
    """
    global whitelist
    global whitelistmode
    if not whitelistmode:
        return data
    start = len(data) - 132  # Skip password
    username = data[start:start + 0x40].decode('utf-8')
    username = username.rstrip('\0')
    if username not in whitelist:
        print("[Whitelist] %s is not in the whitelist, disconnecting client." %
              username)
        context.send_crypto_packet(
            SystemMessagePacket(
                "Oops sorry, you are not registered in the whitelist, doom might have missed your name from the last edit. Please contact doom or kasumi",
                0x1).build())
        context.transport.loseConnection()
    return data
예제 #4
0
 def call_from_client(self, client):
     client.send_crypto_packet(SystemMessagePacket("You are currently connected to %s, on the IP address %s." % (connector_conf['server_name'], config.myIpAddress), 0x3).build())
예제 #5
0
    def call_from_console(self):
        global maintmode
        maintmode = not maintmode
        if maintmode:
            return "[PCP Bot] Maintenance mode: ON."
        else:
            return "[PCP Bot] Maintenance mode: OFF."


@plugins.PacketHook(0x11, 0x0)
def Maint_check(context, data):
    """

    :type context: ShipProxy.ShipProxy
    """
    global maintmode
    if not maintmode:
        return data
<<<<<<< HEAD
    context.send_crypto_packet(SystemMessagePacket("Proxy Lagi Maintenance. Silahkan coba beberapa saat lagi.", 0x1).build())
=======
    context.send_crypto_packet(
        SystemMessagePacket(
            "The PSO2 or PSO2Proxy server is currently undergoing maintenance. Please try again later.", 0x1
        ).build()
    )
>>>>>>> d4a7bf2cacdd48a2cfb02935e664e0f093252d00
    context.transport.loseConnection()
    return data
예제 #6
0
def geoip_check(context, data):
    """

    :type context: ShipProxy.ShipProxy
    """
    global geoip2c, geoip1c
    global geoiplist
    global geoipenabled
    place = "NONE"
    ip = context.transport.getPeer().host
    badip = True

    if geoip2c:
        try:
            respone = geoip2c.country(ip)
            place = respone.country.iso_code
            if place in geoiplist:
                badip = False
        except geoip2.AddressNotFoundError:
            print("[GeoIP] Could not find {} in GeoIP database)".format(ip))
            place = "NULL"
        except Exception as e:
            print("[GeoIP] Error: {}".format(e))
            place = "ERROR"
    elif geoip1c:
        try:
            place = geoip1c.country_code_by_addr(ip)
            if place is None:
                place = "NULL"
            elif place in geoiplist:
                badip = False
        except Exception as e:
            print("[GeoIP] Error: {}".format(e))
            place = "ERROR"

    loc = place
    if ip in geoiplist:
        badip = False
        place = "IPV4"
    if cidr:
        ipa = IPAddress(ip)
        for x in cidrlist:
            if ipa == x:
                badip = False
                place = "CIDR"

    if place == "NONE" or place == "NULL" or place == "ERROR":
        print("Please check your GeoIP settings, IPv4 address {} return as {}".
              format(ip, place))
    else:
        print("[GeoIP] Connection from {}|{}".format(loc, ip))
        if badip and geoipenabled:
            print(
                "[GeoIP] {} (IP: {}) is not in the GeoIP whitelist, disconnecting client."
                .format(loc, ip))
            context.send_crypto_packet(
                SystemMessagePacket(notallowed.format(loc, ip), 0x1).build())
            context.transport.loseConnection()
        elif badip:
            print("[GeoIP] Not rejecting bad connection")
        elif not geoipenabled:
            print("[GeoIP] Allowing good connection")

    return data