import socket
import threading
from SMB_Cmd_handler import SmbCmd
import time

class TcpServer(threading.Thread):
    def __init__(self,smbdb, qcommand, qtransmit):
        self.db = smbdb
        self.qcmd = qcommand
        self.qxmit = qtransmit
        threading.Thread.__init__(self)

    def run(self):
        host = ''  # Symbolic name meaning all available interfaces
        port = 1024  # Arbitrary non-privileged port
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        s.bind((host, port))
        s.listen(2)
        conn, addr = s.accept()

        while True:
            # See if data recieved via TCP.
            time.sleep(.1)
            data = conn.recv(1024)
            # Convert byte data to string
            strdata = "".join(map(chr, data))

            if data:
                # add recived cmd to the transmit queue to be echoed back

                # if not self.qxmit.full():
                #     output = strdata.rstrip() + '\n'
                #     self.qxmit.put(output.encode('utf-8'))

                self.__enqueue_cmd(strdata)

            # Transmit any data in the transmit queue
            try:
                data = self.qxmit.get(block=True)
                if data:
                    self.qxmit.task_done()
                    conn.sendall(data)
            except ValueError as err:
                print(err)

        conn.close()

    def __enqueue_cmd(self, strdata):
        smb_cmd = SmbCmd(self.db)
        cmd_dict = smb_cmd.parse_smb_cmd(strdata)
        if not self.qcmd.full():
            self.qcmd.put(cmd_dict)

e6c1413eaf259943ee7d8b48ad5b8a9b941750aa
<mask token>


class TcpServer(threading.Thread):
    <mask token>
    <mask token>
    <mask token>

<mask token>


class TcpServer(threading.Thread):

    def __init__(self, smbdb, qcommand, qtransmit):
        self.db = smbdb
        self.qcmd = qcommand
        self.qxmit = qtransmit
        threading.Thread.__init__(self)
    <mask token>

    def __enqueue_cmd(self, strdata):
        smb_cmd = SmbCmd(self.db)
        cmd_dict = smb_cmd.parse_smb_cmd(strdata)
        if not self.qcmd.full():
            self.qcmd.put(cmd_dict)

<mask token>


class TcpServer(threading.Thread):

    def __init__(self, smbdb, qcommand, qtransmit):
        self.db = smbdb
        self.qcmd = qcommand
        self.qxmit = qtransmit
        threading.Thread.__init__(self)

    def run(self):
        host = ''
        port = 1024
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        s.bind((host, port))
        s.listen(2)
        conn, addr = s.accept()
        while True:
            time.sleep(0.1)
            data = conn.recv(1024)
            strdata = ''.join(map(chr, data))
            if data:
                self.__enqueue_cmd(strdata)
            try:
                data = self.qxmit.get(block=True)
                if data:
                    self.qxmit.task_done()
                    conn.sendall(data)
            except ValueError as err:
                print(err)
        conn.close()

    def __enqueue_cmd(self, strdata):
        smb_cmd = SmbCmd(self.db)
        cmd_dict = smb_cmd.parse_smb_cmd(strdata)
        if not self.qcmd.full():
            self.qcmd.put(cmd_dict)

import socket
import threading
from SMB_Cmd_handler import SmbCmd
import time


class TcpServer(threading.Thread):

    def __init__(self, smbdb, qcommand, qtransmit):
        self.db = smbdb
        self.qcmd = qcommand
        self.qxmit = qtransmit
        threading.Thread.__init__(self)

    def run(self):
        host = ''
        port = 1024
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        s.bind((host, port))
        s.listen(2)
        conn, addr = s.accept()
        while True:
            time.sleep(0.1)
            data = conn.recv(1024)
            strdata = ''.join(map(chr, data))
            if data:
                self.__enqueue_cmd(strdata)
            try:
                data = self.qxmit.get(block=True)
                if data:
                    self.qxmit.task_done()
                    conn.sendall(data)
            except ValueError as err:
                print(err)
        conn.close()

    def __enqueue_cmd(self, strdata):
        smb_cmd = SmbCmd(self.db)
        cmd_dict = smb_cmd.parse_smb_cmd(strdata)
        if not self.qcmd.full():
            self.qcmd.put(cmd_dict)

import socket
import threading
from SMB_Cmd_handler import SmbCmd
import time

class TcpServer(threading.Thread):
    def __init__(self,smbdb, qcommand, qtransmit):
        self.db = smbdb
        self.qcmd = qcommand
        self.qxmit = qtransmit
        threading.Thread.__init__(self)

    def run(self):
        host = ''  # Symbolic name meaning all available interfaces
        port = 1024  # Arbitrary non-privileged port
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        s.bind((host, port))
        s.listen(2)
        conn, addr = s.accept()

        while True:
            # See if data recieved via TCP.
            time.sleep(.1)
            data = conn.recv(1024)
            # Convert byte data to string
            strdata = "".join(map(chr, data))

            if data:
                # add recived cmd to the transmit queue to be echoed back

                # if not self.qxmit.full():
                #     output = strdata.rstrip() + '\n'
                #     self.qxmit.put(output.encode('utf-8'))

                self.__enqueue_cmd(strdata)

            # Transmit any data in the transmit queue
            try:
                data = self.qxmit.get(block=True)
                if data:
                    self.qxmit.task_done()
                    conn.sendall(data)
            except ValueError as err:
                print(err)

        conn.close()

    def __enqueue_cmd(self, strdata):
        smb_cmd = SmbCmd(self.db)
        cmd_dict = smb_cmd.parse_smb_cmd(strdata)
        if not self.qcmd.full():
            self.qcmd.put(cmd_dict)
