# Path: txircd/modbase.py
# class Mode(object):
#     def hook(self, base):
#         self.ircd = base
#         return self
#     def checkSet(self, user, target, param):
#         return [True, param]
#     def checkUnset(self, user, target, param):
#         return [True, param]
#     def showParam(self, user, target, param):
#         return param
#     def checkPermission(self, user, cmd, data):
#         return data


from twisted.internet.abstract import isIPv6Address
from txircd.modbase import Mode
from Crypto.Hash import SHA256
            if ip[-1] == ":":
                ip = "{}0000".format(ip)
        pieces = ip.split(":")
        for index, piece in enumerate(pieces):
            pieceLen = len(piece)
            if pieceLen < 4:
                pieces[index] = "{}{}".format("".join(["0" for i in range(4 - pieceLen)]), piece)
        hashedParts = []
        pieces.reverse()
        for i in range(len(pieces)):
            piecesGroup = pieces[i:]
            piecesGroup.reverse()
            wholePiece = "".join(piecesGroup)
            pieceHash = SHA256.new(wholePiece)
            hashedParts.append(pieceHash.hexdigest()[:5])
        return ".".join(hashedParts)
    
    def applyCloak4(self, ip):
        pieces = ip.split(".")
        pieces.reverse()
        hashedParts = []
        for i in range(len(pieces)):
            piecesGroup = pieces[i:]
            piecesGroup.reverse()
            wholePiece = "".join(piecesGroup)
            pieceHash = SHA256.new(wholePiece)
            hashedParts.append(pieceHash.hexdigest()[:8])
        return ".".join(hashedParts)

class Spawner(object):

# Path: txircd/modbase.py
# class Mode(object):
#     def hook(self, base):
#         self.ircd = base
#         return self
#     def checkSet(self, user, target, param):
#         return [True, param]
#     def checkUnset(self, user, target, param):
#         return [True, param]
#     def showParam(self, user, target, param):
#         return param
#     def checkPermission(self, user, cmd, data):
#         return data


# Path: txircd/modules/cloaking.py
from twisted.internet.abstract import isIPv6Address
from txircd.modbase import Mode
from Crypto.Hash import SHA256

            if ip[-1] == ":":
                ip = "{}0000".format(ip)
        pieces = ip.split(":")
        for index, piece in enumerate(pieces):
            pieceLen = len(piece)
            if pieceLen < 4:
                pieces[index] = "{}{}".format("".join(["0" for i in range(4 - pieceLen)]), piece)
        hashedParts = []
        pieces.reverse()
        for i in range(len(pieces)):
            piecesGroup = pieces[i:]
            piecesGroup.reverse()
            wholePiece = "".join(piecesGroup)
            pieceHash = SHA256.new(wholePiece)
            hashedParts.append(pieceHash.hexdigest()[:5])
        return ".".join(hashedParts)
    
    def applyCloak4(self, ip):
        pieces = ip.split(".")
        pieces.reverse()
        hashedParts = []
        for i in range(len(pieces)):
            piecesGroup = pieces[i:]
            piecesGroup.reverse()
            wholePiece = "".join(piecesGroup)
            pieceHash = SHA256.new(wholePiece)
            hashedParts.append(pieceHash.hexdigest()[:8])
        return ".".join(hashedParts)

class Spawner(object):

    def __init__(self, ircd):