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


Python socketserver.BaseServer类代码示例

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


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

示例1: handle_error

  def handle_error( self, request, client_address ):
    # Override default behaviour of error handler in ThreadingMixIn
    # the default handler prints and error message to stdout and stderr.
    # Instead, this re-raises the exception so that it can be caught and 
    # dealt with sensibly!

    print("handle_error!");
    exc_type, exc_value, exc_traceback = sys.exc_info();
    #if exc_type == SSL.Error and exc_value[0][0][2]=='http request':
    print(exc_type);
    print(exc_value);
    print(exc_traceback);
    print("OpenSLL error detected!");

      # We would like to send back a BadRequest to the web-client indicating
      # that they made an http request to this https server (like apache does).
      # But this response message must be sent via http (not https), but this 
      # server's __init__ function sets up an SSL server, so this seems
      # difficult to to.
      # It might be possible to make a mixed server than can serve both types
      # of requests, but this is left for later.

    # Fall back to original error handler.
    # Print: exc_type, exc_value, exc_traceback.
    BaseServer.handle_error( self, request, client_address );
开发者ID:WimbledonLabs,项目名称:sous-vide-cooker,代码行数:25,代码来源:SnakeCharmer.py

示例2: __init__

	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,代码行数:25,代码来源:httpd.py

示例3: __init__

 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,代码行数:7,代码来源:simple_https_server.py

示例4: __init__

 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,代码行数:9,代码来源:server.py

示例5: __init__

 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,代码行数:9,代码来源:eyebrows.py

示例6: __init__

 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,代码行数:10,代码来源:zeroconf_server.py

示例7: __init__

    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,代码行数:10,代码来源:test_https.py

示例8: __init__

    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,代码行数:12,代码来源:httpd.py

示例9: __init__

 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,代码行数:13,代码来源:httpserver.py

示例10: __init__

 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,代码行数:13,代码来源:PoC_SSL.py

示例11: __init__

 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,代码行数:14,代码来源:httpstest.py

示例12: __init__

 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,代码行数:15,代码来源:http_server.py

示例13: __init__

 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,代码行数:15,代码来源:http_server.py

示例14: __init__

 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,代码行数:18,代码来源:harvester.py

示例15: __init__

    	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,代码行数:18,代码来源:uWServer.py


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