# Path: conpot/utils/networking.py
# def sanitize_file_name(name, host, port):
#     """
#     Ensure that file_name is legal. Slug the filename and store it onto the server.
#     This would ensure that there are no duplicates as far as writing a file is concerned. Also client addresses are
#     noted so that one can verify which client uploaded the file.
#     :param name: Name of the file
#     :param host: host/client address
#     :param port port/client port
#     :type name: str
#     """
#     return (
#         "("
#         + host
#         + ", "
#         + str(port)
#         + ")-"
#         + datetime.now().strftime("%Y-%m-%d %H:%M:%S")
#         + "-"
#         + slugify(name)
#     )


import fs
import os
import logging
import tftpy
import time
from gevent import socket
from tftpy import TftpException, TftpErrors
from tftpy.TftpStates import TftpStateExpectACK, TftpStateExpectDAT
from tftpy.TftpPacketTypes import TftpPacketRRQ, TftpPacketWRQ
from conpot.utils.networking import sanitize_file_name
        self.data_fs_fileobj = None
        self.vfs = None
        self.data_fs = None
        self.sock.setblocking(False)

    def start(self, buffer):
        logger.debug(
            "In TFTPContextServer - Starting TFTP context with : {}".format(buffer)
        )
        self.metrics.start_time = time.time()
        self.last_update = time.time()
        pkt = self.factory.parse(buffer)
        self.state = TFTPStateServerStart(self)
        self.state = self.state.handle(pkt, self.host, self.port)

    def end(self):
        logger.debug("In TFTPContextServer.end - closing socket and files.")
        self.sock.close()
        if self.fileobj is not None and not self.fileobj.closed:
            logger.debug("self.fileobj is open - closing")
            self.fileobj.close()
        if not self.state and (not self._already_uploaded):
            if self.file_path:
                # Return None only when transfer is complete!
                logger.info("TFTP : Transfer Complete!")
                _file_path = (
                    self.file_path
                    if isinstance(self.file_path, str)
                    else self.file_path.decode()
                )

# Path: conpot/utils/networking.py
# def sanitize_file_name(name, host, port):
#     """
#     Ensure that file_name is legal. Slug the filename and store it onto the server.
#     This would ensure that there are no duplicates as far as writing a file is concerned. Also client addresses are
#     noted so that one can verify which client uploaded the file.
#     :param name: Name of the file
#     :param host: host/client address
#     :param port port/client port
#     :type name: str
#     """
#     return (
#         "("
#         + host
#         + ", "
#         + str(port)
#         + ")-"
#         + datetime.now().strftime("%Y-%m-%d %H:%M:%S")
#         + "-"
#         + slugify(name)
#     )


# Path: conpot/protocols/tftp/tftp_handler.py
import fs
import os
import logging
import tftpy
import time
from gevent import socket
from tftpy import TftpException, TftpErrors
from tftpy.TftpStates import TftpStateExpectACK, TftpStateExpectDAT
from tftpy.TftpPacketTypes import TftpPacketRRQ, TftpPacketWRQ
from conpot.utils.networking import sanitize_file_name

        self.data_fs_fileobj = None
        self.vfs = None
        self.data_fs = None
        self.sock.setblocking(False)

    def start(self, buffer):
        logger.debug(
            "In TFTPContextServer - Starting TFTP context with : {}".format(buffer)
        )
        self.metrics.start_time = time.time()
        self.last_update = time.time()
        pkt = self.factory.parse(buffer)
        self.state = TFTPStateServerStart(self)
        self.state = self.state.handle(pkt, self.host, self.port)

    def end(self):
        logger.debug("In TFTPContextServer.end - closing socket and files.")
        self.sock.close()
        if self.fileobj is not None and not self.fileobj.closed:
            logger.debug("self.fileobj is open - closing")
            self.fileobj.close()
        if not self.state and (not self._already_uploaded):
            if self.file_path:
                # Return None only when transfer is complete!
                logger.info("TFTP : Transfer Complete!")
                _file_path = (
                    self.file_path
                    if isinstance(self.file_path, str)
                    else self.file_path.decode()
                )

                _data_fs_filename = sanitize_file_name(