示例#1
0
def main():
    global key, update_servers
    server_config, update_servers = get_config('config.json')

    print('[{}] Starting MultiDDNS update server at port: {}.'.format(
        time.asctime(), server_config['port']))

    # Initial IP update.
    update_ips(update_servers, get_ip())

    key = server_config['credentials']

    # Setup server.
    httpd = ThreadingHTTPServer(('', server_config['port']), DDNSHandler)

    # HTTPS
    if USE_TLS:
        context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
        context.load_cert_chain(certfile=server_config['cert'],
                                keyfile=server_config['key'],
                                password=server_config['cert_password'])
        httpd.socket = context.wrap_socket(httpd.socket, server_side=True)

    # Run server.
    httpd.serve_forever()
示例#2
0
    def start(cls):
        """
        This method starts the server.
        """
        config = Config.shared()
        colon_index = config.bind_address.rindex(":")
        port_index = colon_index + 1
        address = config.bind_address[:colon_index]
        port = config.bind_address[port_index:]
        log.info(f"Listening on {address}:{port}")

        if address.startswith("[") and address.endswith("]"):
            server = ThreadingHTTPServerV6((address[1:-1], int(port)), cls)
        else:
            server = ThreadingHTTPServer((address, int(port)), cls)

        if config.enable_tls:
            context = Server.load_ssl_context()
            server.socket = context.wrap_socket(server.socket,
                                                server_side=True)
            observer = Observer()
            event_handler = CertificateEventHandler()
            for path in set([
                    Path(config.certificate_file).parent.as_posix(),
                    Path(config.key_file).parent.as_posix(),
            ]):
                observer.schedule(event_handler, path)
            observer.start()

        server.serve_forever()
示例#3
0
 def run_groupme_listener(self, channel, conf):
     server_address = ('', conf['BOT_PORT'])
     HandlerClass = make_groupme_handler(channel, conf,
                                         self.send_from_groupme)
     httpd = ThreadingHTTPServer(server_address, HandlerClass)
     _LOGGER.debug('listening http for groupme bot: %s', channel)
     httpd.socket = context.wrap_socket(httpd.socket, server_side=True)
     httpd.serve_forever()
示例#4
0
def run():
    logging.info('CLUSTER_LOCATION set to '+CLUSTER_LOCATION)
    httpd = ThreadingHTTPServer(('', 8080), Webhook)
    if os.path.isfile(CERT_PATH) and os.path.isfile(KEY_PATH):
        logging.info('using tls cert at '+CERT_PATH)
        logging.info('using tls key at '+KEY_PATH)
        httpd.socket = ssl.wrap_socket(
            httpd.socket, certfile=CERT_PATH, keyfile=KEY_PATH, server_side=True)
    logging.info('starting on 8080...')
    httpd.serve_forever()
示例#5
0
 def serve_on_thread(address, port, secure):
     httpd = ThreadingHTTPServer((address, port), MyHTTPRequestHandler)
     if secure:
         httpd.socket = ssl.wrap_socket(
             httpd.socket,
             certfile=cert_file,
             keyfile=cert_key_file,
             server_side=True,
         )
     httpd.serve_forever()
示例#6
0
def main() -> int:
    parser = argparse.ArgumentParser()
    parser.add_argument('-k', '--key-file', default='./cert-key.pem')
    parser.add_argument('-c', '--cert-file', default='./cert-crt.pem')
    parser.add_argument('-P', '--port', default=443, type=int)
    parser.add_argument('--ip', default='', metavar='IP')
    args = parser.parse_args()
    httpd = ThreadingHTTPServer((args.ip, args.port), PaddleAPIServerHandler)
    httpd.socket = ssl.wrap_socket(httpd.socket,
                                   keyfile=args.key_file,
                                   certfile=args.cert_file,
                                   server_side=True)
    httpd.serve_forever()
    return 0
    def start(cls):
        """
        This method starts the server.
        """
        config = Config.shared()
        (address, port) = config.bind_address.split(":")
        log.info(f"Listening on {address}:{port}")
        server = ThreadingHTTPServer((address, int(port)), cls)

        if config.enable_tls:
            context = Server.load_ssl_context()
            server.socket = context.wrap_socket(server.socket,
                                                server_side=True)
            observer = Observer()
            event_handler = CertificateEventHandler()
            for path in set([
                    Path(config.certificate_file).parent.as_posix(),
                    Path(config.key_file).parent.as_posix(),
            ]):
                observer.schedule(event_handler, path)
            observer.start()

        server.serve_forever()
示例#8
0
def main():
    server_address = (CONFIG.get('host'), CONFIG.get('port'))
    if sys.version_info >= (3, 7):
        # needs Python 3.7+
        # pylint: disable=no-name-in-module
        from http.server import ThreadingHTTPServer
        httpd = ThreadingHTTPServer(server_address, Server)
        # pylint: enable=no-name-in-module
    else:
        from http.server import HTTPServer
        httpd = HTTPServer(server_address, Server)

    if CONFIG.get('tls') is not None:
        httpd.socket = ssl.wrap_socket(httpd.socket,
                                       keyfile=CONFIG['key'],
                                       certfile=CONFIG['cert'],
                                       server_side=True)
    try:
        print('Server started at %s:%s' % server_address)
        httpd.serve_forever()
    except KeyboardInterrupt:
        print('KeyboardInterrupt, shutting down.')
        httpd.server_close()
示例#9
0

try:

    httpd = ThreadingHTTPServer((LHOST, LPORT), handler)

except OSError:

    logger.log('La dirección proporcionada ya está en uso!', WAR)

else:

    try:

        httpd.socket = ssl.wrap_socket(httpd.socket,
                                       certfile=global_conf.ssl['cert'],
                                       keyfile=global_conf.ssl['key'],
                                       server_side=True)

    except ssl.SSLError as Except:

        logger.log(
            'Ocurrió una Excepción con el certificado/clave. Excepción: "{}"'.
            format(Except), debug.COM)

        reset_term.reset(1)

    except OSError:

        logger.log(
            'Error ingresando la frase de contraseña del certificado/clave.',
            debug.COM)
示例#10
0
        elif self.path == "/seesat":
            email_information = json_body["message"]["data"]
            email_history = urlsafe_b64decode(email_information).decode(
                'utf-8')
            email_history = json.loads(email_history)
            print(email_history)
            print(google_email.get_email_history(email_history['historyId']))
            self.send_204()

        else:
            self.send_response(404)
            self.end_headers()
            self.wfile.write(b'')
            return

        self.db.clean()


httpd = ThreadingHTTPServer(('', PORT_NUMBER), SimpleHTTPRequestHandler)

if os.getenv('TRUSAT_DISABLE_HTTPS', False):
    print('HTTPS disabled!')
else:
    httpd.socket = ssl.wrap_socket(httpd.socket,
                                   keyfile='./privkey.pem',
                                   certfile='./fullchain.pem',
                                   server_side=True)

httpd.serve_forever()
示例#11
0
#!/usr/bin/env python

from http.server import ThreadingHTTPServer, SimpleHTTPRequestHandler
import ssl
from argparse import ArgumentParser
from argparse import ArgumentDefaultsHelpFormatter

ap = ArgumentParser(
        description="Simple HTTPS server.",
        formatter_class=ArgumentDefaultsHelpFormatter)
ap.add_argument("certfile", help="specify a file name containing "
                "both server cert and private key.")
ap.add_argument("-p", action="store", dest="port", type=int, default=8443,
                help="specify the port number to be listened.")
opt = ap.parse_args()

httpd = ThreadingHTTPServer(("", opt.port), SimpleHTTPRequestHandler)
httpd.socket = ssl.wrap_socket(httpd.socket,
                               certfile=opt.certfile,
                               server_side=True)
print(f"HTTPS server has started on port# {opt.port}.")
httpd.serve_forever()
        for i in range(2000):
            a = i + 3.0 * 12.0 - random()
            b = random()
            c = float(a) * b
            self._nothing(a, b, c)
            elem = c
        phrase = 'Hello world! This is our web page!!! {}'.format(elem)
        self.send_response(200)
        self.end_headers()
        self.wfile.write(str.encode(phrase))


WEBSITE_PORT = os.environ[
    "WEBSITE_PORT"] if "WEBSITE_PORT" in os.environ else 4443
WEBSITE_HOST = os.environ[
    "WEBSITE_HOST"] if "WEBSITE_HOST" in os.environ else ''

redpath = os.path.realpath('..')

print("HTTPS client will listen on server {} and tcp port {}".format(
    WEBSITE_HOST, WEBSITE_PORT))

httpd = ThreadingHTTPServer((WEBSITE_HOST, int(WEBSITE_PORT)),
                            SimpleHTTPRequestHandler)
httpd.socket = ssl.wrap_socket(httpd.socket,
                               certfile=os.path.join(
                                   redpath, "certificates/localhost.pem"),
                               server_side=True)
#"C:\Program Files\OpenSSL-Win64\bin\openssl.exe" req -new -x509 -keyout localhost.pem -out localhost.pem -days 365 -nodes
httpd.serve_forever()
示例#13
0
        return

    def log_message(self, *args):
        args = args[1:]

        method = args[0]
        status_code = args[1]

        log_system.stdout("{}: {}".format(method, status_code))


httpd = ThreadingHTTPServer((host_config.LHOST, host_config.LPORT), Handler)
try:
    httpd.socket = ssl.wrap_socket(httpd.socket,
                                   keyfile=sec_config.key,
                                   certfile=sec_config.cert,
                                   server_side=True)

except Exception as Except:
    log_system.stderr(
        'NO se usará la clave o el certificado debido a un posible error: {}'.
        format(Except))

    proto = 'http'  # Indicamos al usuario que ya no se usará https

try:
    log_system.stdout('Escuchando en %s://%s:%d' %
                      (proto, host_config.LHOST, host_config.LPORT))

    httpd.serve_forever()