当前位置: 首页>>代码示例>>Python>>正文


Python BaseServer.__init__方法代码示例

本文整理汇总了Python中socketserver.BaseServer.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python BaseServer.__init__方法的具体用法?Python BaseServer.__init__怎么用?Python BaseServer.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在socketserver.BaseServer的用法示例。


在下文中一共展示了BaseServer.__init__方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from socketserver import BaseServer [as 别名]
# 或者: from socketserver.BaseServer import __init__ [as 别名]
	def __init__(self, server_address, RequestHandlerClass, maxthreads=100, pemfile=None, rest_handlers=None, userpass=None):
		try:
			if pemfile: #HTTPS server
				BaseServer.__init__(self, server_address, RequestHandlerClass)
				ctx = SSL.Context(SSL.SSLv23_METHOD)
				ctx.use_privatekey_file(pemfile)
				ctx.use_certificate_file(pemfile)
				self.socket = SSL.Connection(ctx, socket.socket(self.address_family, self.socket_type))
				self.server_bind()
				self.server_activate()
				self.httpstyle = "HTTPS"
			else: #HTTP server
				BaseHTTPServer.__init__(self, server_address, RequestHandlerClass)
				self.httpstyle = "HTTP"
		except socket.error as e:
			if e.errno == 98:
				logging.log(logging.ERROR, "Cannot start HTTP server, address already in use")
				return
			else:
				raise
		self.lock = thread.allocate_lock()
		self.maxthreads = maxthreads
		self.threads = 0
		self.rest_handlers = rest_handlers
		self.userpass = userpass
开发者ID:saggim,项目名称:SleekPubsub,代码行数:27,代码来源:httpd.py

示例2: __init__

# 需要导入模块: from socketserver import BaseServer [as 别名]
# 或者: from socketserver.BaseServer import __init__ [as 别名]
 def __init__(self, server_address, HandlerClass):
     BaseServer.__init__(self, server_address, HandlerClass)
     ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
     ctx.load_cert_chain(certfile=CERT, keyfile=KEY)
     self.socket = ctx.wrap_socket(socket.socket(self.address_family, self.socket_type), server_side=True)
     self.server_bind()
     self.server_activate()
开发者ID:Sud0h4c,项目名称:pentest,代码行数:9,代码来源:simple_https_server.py

示例3: __init__

# 需要导入模块: from socketserver import BaseServer [as 别名]
# 或者: from socketserver.BaseServer import __init__ [as 别名]
 def __init__(self, server_address, RequestHandlerClass, bind_and_activate=True):
     BaseServer.__init__(self, server_address, RequestHandlerClass)
     self.socket = ssl.wrap_socket(socket.socket(self.address_family, self.socket_type),
                                   "./server.key", "./server.crt", True, ssl.CERT_REQUIRED,
                                   ssl.PROTOCOL_TLSv1, "./trusted.crt")
     
     if bind_and_activate:
         self.server_bind()
         self.server_activate()
开发者ID:matematik7,项目名称:CChatServer,代码行数:11,代码来源:server.py

示例4: __init__

# 需要导入模块: from socketserver import BaseServer [as 别名]
# 或者: from socketserver.BaseServer import __init__ [as 别名]
 def __init__(self, server_address, HandlerClass):
     BaseServer.__init__(self, server_address, HandlerClass)
     self.socket = ssl.SSLSocket(
         sock=socket.socket(self.address_family, self.socket_type),
         ssl_version=ssl.PROTOCOL_TLSv1,
         certfile='server.pem',
         server_side=True)
     self.server_bind()
     self.server_activate()
开发者ID:notbryant,项目名称:eyebrows,代码行数:11,代码来源:eyebrows.py

示例5: __init__

# 需要导入模块: from socketserver import BaseServer [as 别名]
# 或者: from socketserver.BaseServer import __init__ [as 别名]
    def __init__(self,address,handler):
        BaseServer.__init__(self,address,handler)

        self.socket = ssl.SSLSocket(
            sock=socket.socket(self.address_family,self.socket_type),
            ssl_version=ssl.PROTOCOL_TLSv1,
            certfile=os.path.join(os.path.dirname(__file__), 'test.pem'),
            server_side=True)
        self.server_bind()
        self.server_activate()
开发者ID:dragon788,项目名称:zorro,代码行数:12,代码来源:test_https.py

示例6: __init__

# 需要导入模块: from socketserver import BaseServer [as 别名]
# 或者: from socketserver.BaseServer import __init__ [as 别名]
 def __init__(self, server_address, multicast_group, RequestHandlerClass, bind_and_activate=True, multicast_ttl = 1):
     BaseServer.__init__(self, server_address, RequestHandlerClass)
     self.socket = socket.socket(self.address_family,
                                 self.socket_type,
                                 self.protocol_type)
     self.multicast_group = multicast_group
     self.multicast_ttl = multicast_ttl
     if bind_and_activate:
         self.server_bind()
         self.server_activate()
开发者ID:rasp-home,项目名称:rasp-home-backend,代码行数:12,代码来源:zeroconf_server.py

示例7: __init__

# 需要导入模块: from socketserver import BaseServer [as 别名]
# 或者: from socketserver.BaseServer import __init__ [as 别名]
    def __init__(self, server_address, HandlerClass):
        BaseServer.__init__(self, server_address, HandlerClass)
        ctx = SSL.Context(SSL.SSLv23_METHOD)

        fpem = MongoServer.pem
        ctx.use_privatekey_file(fpem)
        ctx.use_certificate_file(fpem)
        
        self.socket = SSL.Connection(ctx, socket.socket(self.address_family,
                                                        self.socket_type))
        self.server_bind()
        self.server_activate()
开发者ID:edosoft,项目名称:sleepy.mongoose,代码行数:14,代码来源:httpd.py

示例8: __init__

# 需要导入模块: from socketserver import BaseServer [as 别名]
# 或者: from socketserver.BaseServer import __init__ [as 别名]
 def __init__(self, address, handler):
     """
     Initialise the secure handlers for the SSL server if required.s
     """
     BaseServer.__init__(self, address, handler)
     local_data = AppLocation.get_directory(AppLocation.DataDir)
     self.socket = ssl.SSLSocket(
         sock=socket.socket(self.address_family, self.socket_type),
         certfile=os.path.join(local_data, 'remotes', 'openlp.crt'),
         keyfile=os.path.join(local_data, 'remotes', 'openlp.key'),
         server_side=True)
     self.server_bind()
     self.server_activate()
开发者ID:imkernel,项目名称:openlp,代码行数:15,代码来源:httpserver.py

示例9: __init__

# 需要导入模块: from socketserver import BaseServer [as 别名]
# 或者: from socketserver.BaseServer import __init__ [as 别名]
 def __init__(self, server_address, HandlerClass):
     BaseServer.__init__(self, server_address, HandlerClass)
     ctx = SSL.Context(SSL.SSLv23_METHOD)
     # server.pem's location (containing the server private key and
     # the server certificate).
     fpem_priv = 'newreq.pem'  # server
     fpem_cli = 'newcert.pem'  # cli
     ctx.use_privatekey_file(fpem_priv)
     ctx.use_certificate_file(fpem_cli)
     self.socket = SSL.Connection(ctx, socket.socket(self.address_family,
                                                     self.socket_type))
     self.server_bind()
     self.server_activate()
开发者ID:1872892142,项目名称:social-engineer-toolkit,代码行数:15,代码来源:PoC_SSL.py

示例10: __init__

# 需要导入模块: from socketserver import BaseServer [as 别名]
# 或者: from socketserver.BaseServer import __init__ [as 别名]
 def __init__(self, server_address, HandlerClass):
     BaseServer.__init__(self, server_address, HandlerClass)
     
     ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
     
     fpem = '../cacert.crt'
     ctx.load_verify_locations(fpem)
     ctx.verify_mode = ssl.CERT_NONE
     
     self.socket = ssl.SSLSocket(ctx, socket.socket(self.address_family,
                                                    self.socket_type),
                                 certfile = fpem)
     self.server_bind()
     self.server_activate()
开发者ID:ejamesc,项目名称:openbox,代码行数:16,代码来源:httpstest.py

示例11: __init__

# 需要导入模块: from socketserver import BaseServer [as 别名]
# 或者: from socketserver.BaseServer import __init__ [as 别名]
 def __init__ (self, address, handler):
     import ssl
     BaseServer.__init__ (self, address, handler)
     # step one up because test suite change directory away from $srcdir (don't do that !!!)
     CERTFILE = os.path.abspath(os.path.join('..', os.getenv('srcdir', '.'), 'certs', 'wget-cert.pem'))
     fop = open (CERTFILE)
     print (fop.readline())
     self.socket = ssl.wrap_socket (
         sock = socket.socket (self.address_family, self.socket_type),
         ssl_version = ssl.PROTOCOL_TLSv1,
         certfile = CERTFILE,
         server_side = True
     )
     self.server_bind()
     self.server_activate()
开发者ID:andrewhead,项目名称:StackSkim,代码行数:17,代码来源:http_server.py

示例12: __init__

# 需要导入模块: from socketserver import BaseServer [as 别名]
# 或者: from socketserver.BaseServer import __init__ [as 别名]
 def __init__ (self, address, handler):
       BaseServer.__init__ (self, address, handler)
       print (os.getcwd())
       CERTFILE = os.path.abspath (os.path.join ('..', 'certs', 'wget-cert.pem'))
       print (CERTFILE)
       fop = open (CERTFILE)
       print (fop.readline())
       self.socket = ssl.wrap_socket (
             sock = socket.socket (self.address_family, self.socket_type),
             ssl_version = ssl.PROTOCOL_TLSv1,
             certfile = CERTFILE,
             server_side = True
             )
       self.server_bind ()
       self.server_activate ()
开发者ID:Devil399,项目名称:wget,代码行数:17,代码来源:http_server.py

示例13: __init__

# 需要导入模块: from socketserver import BaseServer [as 别名]
# 或者: from socketserver.BaseServer import __init__ [as 别名]
 def __init__(self, server_address, HandlerClass):
     BaseServer.__init__(self, server_address, HandlerClass)
     # SSLv2 and SSLv3 supported
     ctx = SSL.Context(SSL.SSLv23_METHOD)
     # pem files defined before
     fpem_priv = 'newreq.pem'
     fpem_cli = 'newcert.pem'
     # establish private key
     ctx.use_privatekey_file(fpem_priv)
     # establish public/client certificate
     ctx.use_certificate_file(fpem_cli)
     # setup the ssl socket
     self.socket = SSL.Connection(ctx, socket.socket(
         self.address_family, self.socket_type))
     # bind to interface
     self.server_bind()
     # activate the interface
     self.server_activate()
开发者ID:onlydole,项目名称:social-engineer-toolkit,代码行数:20,代码来源:harvester.py

示例14: __init__

# 需要导入模块: from socketserver import BaseServer [as 别名]
# 或者: from socketserver.BaseServer import __init__ [as 别名]
    	def __init__(self, server_address, HandlerClass, options):
            BaseServer.__init__(self, server_address, HandlerClass)
            pwd = os.path.dirname(os.path.realpath(__file__))
            keys = os.path.join(pwd,options.key)
            certs = os.path.join(pwd,options.cert)
            self.options = options

            self.daemon_threads = True
            self.protocol_version = 'HTTP/1.1'
            if options.clientverify:
            	self.socket = ssl.wrap_socket(socket.socket(self.address_family, self.socket_type),
                    keyfile=keys, certfile=certs, server_side=True, cert_reqs=ssl.CERT_REQUIRED, ca_certs='/etc/ssl/certs/ca-certificates.crt')
            else:
                self.socket = ssl.wrap_socket(socket.socket(self.address_family, self.socket_type),
                    keyfile=keys, certfile=certs, server_side=True)

            self.server_bind()
            self.server_activate()
开发者ID:chenglongwei,项目名称:trafficserver,代码行数:20,代码来源:uWServer.py

示例15: __init__

# 需要导入模块: from socketserver import BaseServer [as 别名]
# 或者: from socketserver.BaseServer import __init__ [as 别名]
    def __init__(self, address, handler):
        global logger
        try:
            BaseServer.__init__(self, address, handler)
            self.socket = ssl.SSLSocket(
                sock=socket.socket(self.address_family, self.socket_type),
                ssl_version=ssl.PROTOCOL_TLSv1,
                certfile=settings.ServerParams["Certificate"],
                server_side=True)
            self.server_bind()
            self.server_activate()
            #   create http logger
            logger = logging.getLogger('HTTP')
            logger.setLevel(settings.SystemParams["LogLevel"])
            logger.addHandler(log.ch)

            logger.info('HTTPS server started. Press ^C to stop')
        except Exception as err:
            Logger.error('Error during HTTPS server starting')
开发者ID:appdevel,项目名称:webserver,代码行数:21,代码来源:httpserver.py


注:本文中的socketserver.BaseServer.__init__方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。