# Path: conpot/protocols/http/command_responder.py
# class CommandResponder(object):
#     def __init__(self, host, port, template, docpath):
# 
#         # Create HTTP server class
#         self.httpd = SubHTTPServer((host, port), HTTPServer, template, docpath)
#         self.server_port = self.httpd.server_port
# 
#     def serve_forever(self):
#         self.httpd.serve_forever()
# 
#     def stop(self):
#         logging.info(
#             "HTTP server will shut down gracefully as soon as all connections are closed."
#         )
#         self.httpd.shutdown()
# 
# Path: conpot/core/protocol_wrapper.py
# def conpot_protocol(cls):
#     class Wrapper(object):
#         def __init__(self, *args, **kwargs):
#             self.wrapped = cls(*args, **kwargs)
#             self.cls = cls
#             if self.cls.__name__ not in "Proxy":
#                 if self.cls not in core_interface.protocols:
#                     core_interface.protocols[self.cls] = []
# 
#                 core_interface.protocols[self.cls].append(self.wrapped)
# 
#             self.__class__.__name__ = self.cls.__name__
# 
#         def __getattr__(self, name):
#             if name == "handle":
#                 # assuming that handle function from a class is only called when a client tries to connect with an
#                 # enabled protocol, update the last_active (last_attacked attribute)
#                 # FIXME: No handle function in HTTPServer
#                 core_interface.last_active = datetime.now().strftime(
#                     "%b %d %Y - %H:%M:%S"
#                 )
#             return self.wrapped.__getattribute__(name)
# 
#         def __repr__(self):
#             return self.wrapped.__repr__()
# 
#         __doc__ = cls.__doc__
#         __module__ = cls.__module__
# 
#     return Wrapper


import os
import logging
from conpot.protocols.http.command_responder import CommandResponder
from conpot.core.protocol_wrapper import conpot_protocol
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.



logger = logging.getLogger(__name__)


@conpot_protocol
class HTTPServer(object):
    def __init__(self, template, template_directory, args):
        self.template = template
        self.template_directory = template_directory
        self.server_port = None
        self.cmd_responder = None

    def start(self, host, port):
        logger.info("HTTP server started on: %s", (host, port))

# Path: conpot/protocols/http/command_responder.py
# class CommandResponder(object):
#     def __init__(self, host, port, template, docpath):
# 
#         # Create HTTP server class
#         self.httpd = SubHTTPServer((host, port), HTTPServer, template, docpath)
#         self.server_port = self.httpd.server_port
# 
#     def serve_forever(self):
#         self.httpd.serve_forever()
# 
#     def stop(self):
#         logging.info(
#             "HTTP server will shut down gracefully as soon as all connections are closed."
#         )
#         self.httpd.shutdown()
# 
# Path: conpot/core/protocol_wrapper.py
# def conpot_protocol(cls):
#     class Wrapper(object):
#         def __init__(self, *args, **kwargs):
#             self.wrapped = cls(*args, **kwargs)
#             self.cls = cls
#             if self.cls.__name__ not in "Proxy":
#                 if self.cls not in core_interface.protocols:
#                     core_interface.protocols[self.cls] = []
# 
#                 core_interface.protocols[self.cls].append(self.wrapped)
# 
#             self.__class__.__name__ = self.cls.__name__
# 
#         def __getattr__(self, name):
#             if name == "handle":
#                 # assuming that handle function from a class is only called when a client tries to connect with an
#                 # enabled protocol, update the last_active (last_attacked attribute)
#                 # FIXME: No handle function in HTTPServer
#                 core_interface.last_active = datetime.now().strftime(
#                     "%b %d %Y - %H:%M:%S"
#                 )
#             return self.wrapped.__getattribute__(name)
# 
#         def __repr__(self):
#             return self.wrapped.__repr__()
# 
#         __doc__ = cls.__doc__
#         __module__ = cls.__module__
# 
#     return Wrapper


# Path: conpot/protocols/http/web_server.py
import os
import logging
from conpot.protocols.http.command_responder import CommandResponder
from conpot.core.protocol_wrapper import conpot_protocol

# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.



logger = logging.getLogger(__name__)


@conpot_protocol
class HTTPServer(object):
    def __init__(self, template, template_directory, args):
        self.template = template
        self.template_directory = template_directory
        self.server_port = None
        self.cmd_responder = None

    def start(self, host, port):
        logger.info("HTTP server started on: %s", (host, port))

        self.cmd_responder = CommandResponder(