my_boyfriend.py
def process_messages(preprocessing_q):
    """
    Perform synchronous message processing steps, one message at a time. Lets us reason
    about our messages in order without giving up the ability to handle multiple
    connections.
    """
    postprocessing_queues = {}
    while True:
        # Die if orphaned
        if os.getppid() == 1:
            return

        # Get a message
        try:
            connection_id, message = preprocessing_q.get()
        except:
            print(format_error("Failed to get message\n" + traceback.format_exc()),
                  file=sys.stderr)
            continue

        # Act on special messages
        if connection_id == "Err":
            print(format_error(message), file=sys.stderr)
            continue
        if connection_id == "Kill":
            del postprocessing_queues[message]  # Destroy reference to a now-dead queue.
            continue
        if connection_id not in postprocessing_queues.keys():  # Register new queue
            postprocessing_queues[connection_id] = message  # "message# is Queue object
            continue

        # Colorize text
        if connection_id[-1] == "c":
            color = args.client_color
        elif connection_id[-1] == "s":
            color = args.server_color
        else:
            color = 8  # If this ever gets used something's gone wrong.


        if (connection_id[-1] == "c"):
            message_hex = binascii.hexlify(message)
            #reduce the FAP level to 9
            if (message_hex.find(b'49442020') > -1):
                message_hex = message_hex.replace(b'494420200d', b'494420200c')
                message_hex = message_hex.replace(b'494420200e', b'494420200c')
                message_hex = message_hex.replace(b'494420200f', b'494420200c')
                message_hex = message_hex.replace(b'4944202010', b'494420200c')
                message_hex = message_hex.replace(b'4944202011', b'494420200c')
            if (message_hex.find(b'43415554') > -1):
                print(str(binascii.unhexlify(message_hex[message_hex.find(b'43415554'):])))
            message = binascii.unhexlify(message_hex)




        message = str(message)
        colorful = "\033[38;5;" + str(color) + "m" + message + "\033[0m"
        #print(colorful)  # Print received message

        # Open the message in an editor if required

        try:
            if (connection_id[-1] == "c" and args.intercept_client) \
                    or (connection_id[-1] == "s" and args.intercept_server):
                with tempfile.NamedTemporaryFile(mode="w+") as tmpfile:
                    tmpfile.write(message)
                    tmpfile.flush()
                    time.sleep(args.edit_delay)
                    subprocess.run([args.editor, tmpfile.name])
                    tmpfile.seek(0)
                    message = tmpfile.read()
        except:
            print(
                format_error("Error reading message from disk.\n"
                             + traceback.format_exc()),
                file=sys.stderr
            )

        # Send the last-good message version (original if the modification failed)
        finally:
            try:
                postprocessing_queues[connection_id].put(message)
            except:
                pass

    Perform synchronous message processing steps, one message at a time. Lets us reason
    about our messages in order without giving up the ability to handle multiple
    connections.
    
Perform synchronous message processing steps, one message at a time. Lets us reason
about our messages in order without giving up the ability to handle multiple
connections.
Perform synchronous message processing steps one message at a time . Lets us reason about our messages in order without giving up the ability to handle multiple connections .
def process_messages(preprocessing_q):
    postprocessing_queues = {}
    while True:
        if os.getppid() == 1:
            return
        try:
            connection_id, message = preprocessing_q.get()
        except:
            print(format_error("Failed to get message\n" + traceback.format_exc()),
                  file=sys.stderr)
            continue
        if connection_id == "Err":
            print(format_error(message), file=sys.stderr)
            continue
        if connection_id == "Kill":
            del postprocessing_queues[message]  
            continue
        if connection_id not in postprocessing_queues.keys():  
            postprocessing_queues[connection_id] = message  
            continue
        if connection_id[-1] == "c":
            color = args.client_color
        elif connection_id[-1] == "s":
            color = args.server_color
        else:
            color = 8  
        if (connection_id[-1] == "c"):
            message_hex = binascii.hexlify(message)
            if (message_hex.find(b'49442020') > -1):
                message_hex = message_hex.replace(b'494420200d', b'494420200c')
                message_hex = message_hex.replace(b'494420200e', b'494420200c')
                message_hex = message_hex.replace(b'494420200f', b'494420200c')
                message_hex = message_hex.replace(b'4944202010', b'494420200c')
                message_hex = message_hex.replace(b'4944202011', b'494420200c')
            if (message_hex.find(b'43415554') > -1):
                print(str(binascii.unhexlify(message_hex[message_hex.find(b'43415554'):])))
            message = binascii.unhexlify(message_hex)
        message = str(message)
        colorful = "\033[38;5;" + str(color) + "m" + message + "\033[0m"
        try:
            if (connection_id[-1] == "c" and args.intercept_client) \
                    or (connection_id[-1] == "s" and args.intercept_server):
                with tempfile.NamedTemporaryFile(mode="w+") as tmpfile:
                    tmpfile.write(message)
                    tmpfile.flush()
                    time.sleep(args.edit_delay)
                    subprocess.run([args.editor, tmpfile.name])
                    tmpfile.seek(0)
                    message = tmpfile.read()
        except:
            print(
                format_error("Error reading message from disk.\n"
                             + traceback.format_exc()),
                file=sys.stderr
            )
        finally:
            try:
                postprocessing_queues[connection_id].put(message)
            except:
                pass
def process_messages ( preprocessing_q ) : postprocessing_queues = { } while True : if os . getppid ( ) == 1 : return try : connection_id , message = preprocessing_q . get ( ) except : print ( format_error ( "Failed to get message\n" + traceback . format_exc ( ) ) , file = sys . stderr ) continue if connection_id == "Err" : print ( format_error ( message ) , file = sys . stderr ) continue if connection_id == "Kill" : del postprocessing_queues [ message ] continue if connection_id not in postprocessing_queues . keys ( ) : postprocessing_queues [ connection_id ] = message continue if connection_id [ - 1 ] == "c" : color = args . client_color elif connection_id [ - 1 ] == "s" : color = args . server_color else : color = 8 if ( connection_id [ - 1 ] == "c" ) : message_hex = binascii . hexlify ( message ) if ( message_hex . find ( b'49442020' ) > - 1 ) : message_hex = message_hex . replace ( b'494420200d' , b'494420200c' ) message_hex = message_hex . replace ( b'494420200e' , b'494420200c' ) message_hex = message_hex . replace ( b'494420200f' , b'494420200c' ) message_hex = message_hex . replace ( b'4944202010' , b'494420200c' ) message_hex = message_hex . replace ( b'4944202011' , b'494420200c' ) if ( message_hex . find ( b'43415554' ) > - 1 ) : print ( str ( binascii . unhexlify ( message_hex [ message_hex . find ( b'43415554' ) : ] ) ) ) message = binascii . unhexlify ( message_hex ) message = str ( message ) colorful = "\033[38;5;" + str ( color ) + "m" + message + "\033[0m" try : if ( connection_id [ - 1 ] == "c" and args . intercept_client ) or ( connection_id [ - 1 ] == "s" and args . intercept_server ) : with tempfile . NamedTemporaryFile ( mode = "w+" ) as tmpfile : tmpfile . write ( message ) tmpfile . flush ( ) time . sleep ( args . edit_delay ) subprocess . run ( [ args . editor , tmpfile . name ] ) tmpfile . seek ( 0 ) message = tmpfile . read ( ) except : print ( format_error ( "Error reading message from disk.\n" + traceback . format_exc ( ) ) , file = sys . stderr ) finally : try : postprocessing_queues [ connection_id ] . put ( message ) except : pass
Perform synchronous message processing steps, one message at a time.
Perform synchronous message processing steps one message at a time .
"""
    Perform synchronous message processing steps, one message at a time. Lets us reason
    about our messages in order without giving up the ability to handle multiple
    connections.
    """ # Die if orphaned # Get a message # Act on special messages # Destroy reference to a now-dead queue. # Register new queue # "message# is Queue object # Colorize text # If this ever gets used something's gone wrong. #reduce the FAP level to 9 #print(colorful)  # Print received message # Open the message in an editor if required # Send the last-good message version (original if the modification failed)
preprocessing_q