本文整理汇总了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, HandlerClass, cmd=None, env_term=None, ssl_enabled=True, ssl_cert=None, www_dir='www'):
BaseServer.__init__(self, server_address, HandlerClass)
# Setup SSL
if ssl_enabled:
try:
ctx = SSL.Context(SSL.SSLv23_METHOD)
# ctx.set_options(SSL.OP_NO_SSLv2)
ctx.use_privatekey_file(ssl_cert)
ctx.use_certificate_chain_file(ssl_cert)
# Demand a certificate
# ctx.set_verify(SSL.VERIFY_PEER|SSL.VERIFY_FAIL_IF_NO_PEER_CERT,
# verify_cb)
# ctx.load_verify_locations(os.path.join(dir, 'CA.cert'))
except SSL.Error:
self.socket = None
return
# Setup webshell multiplex
self.webshell_files = {}
for i in ['css', 'html', 'js', 'gif', 'jpg', 'png']:
for j in glob.glob(www_dir + '/*.%s' % i):
self.webshell_files[os.path.basename(j)] = file(j).read()
self.webshell_mime = mimetypes.types_map.copy()
self.webshell_multiplex = Multiplex(cmd, env_term)
# Open socket
self.socket = socket.socket(self.address_family, self.socket_type)
if ssl_enabled:
self.socket = SSL.Connection(ctx, self.socket)
self.server_bind()
self.server_activate()
示例2: __init__
# 需要导入模块: from SocketServer import BaseServer [as 别名]
# 或者: from SocketServer.BaseServer import __init__ [as 别名]
def __init__(self, server_address, HandlerClass, config):
BaseServer.__init__(self, server_address, HandlerClass)
ctx = makeSSLContext(config.verifypeer, config.cacert, config.localcert, self.sslReject)
self.socket = SSL.Connection(ctx, socket.socket(self.address_family,
self.socket_type))
self.server_bind()
self.server_activate()
示例3: __init__
# 需要导入模块: from SocketServer import BaseServer [as 别名]
# 或者: from SocketServer.BaseServer import __init__ [as 别名]
def __init__(self, server_address, handler_class, config,
bind_and_activate=True):
# pylint: disable=super-init-not-called, non-parent-init-called
# Init just BaseServer, TCPServer creates a socket.
BaseServer.__init__(self, server_address, handler_class)
if isinstance(server_address, socket.socket):
# It's a bound and activates socket from systemd.
self.socket = server_address
bind_and_activate = False
else:
self.socket = socket.socket(self.address_family,
self.socket_type)
# copied from TCPServer
if bind_and_activate:
try:
self.server_bind()
self.server_activate()
except:
self.server_close()
raise
if self.socket.family == socket.AF_UNIX:
self.socket_file = self.socket.getsockname()
if 'consumers' not in config:
raise ValueError('Configuration does not provide any consumer')
self.config = config
if 'server_string' in self.config:
self.server_string = self.config['server_string']
self.auditlog = log.auditlog
示例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)
ctx = SSL.Context(SSL.SSLv23_METHOD) #定义一个ssl连接,ssl所采用的版本
ctx.use_privatekey(privatekey)
ctx.use_certificate(certificate)
self.socket = SSL.Connection(ctx, socket.socket(self.address_family, self.socket_type)) #使用给定的OpenSSL.SSL.Content和Socket创建连接对象
self.server_bind()
self.server_activate()
示例5: __init__
# 需要导入模块: from SocketServer import BaseServer [as 别名]
# 或者: from SocketServer.BaseServer import __init__ [as 别名]
def __init__( self, addr, htdocs ):
BaseServer.__init__( self, addr, WebserverHandler )
self.socket = socket.socket( self.address_family, self.socket_type )
self.socket.setblocking( 0 )
self.server_bind()
self.server_activate()
self.htdocs = htdocs
示例6: __init__
# 需要导入模块: from SocketServer import BaseServer [as 别名]
# 或者: from SocketServer.BaseServer import __init__ [as 别名]
def __init__(self, server_address, RequestHandlerClass, bind_and_activate=True):
# Initialize
BaseServer.__init__(self, server_address, RequestHandlerClass)
self.socket = socket.socket(self.address_family,
self.socket_type)
if bind_and_activate:
self.server_bind()
self.server_activate()
示例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)
ctx.use_privatekey_file(privatekey)
ctx.use_certificate_file(certificate)
self.socket = SSL.Connection(ctx, socket.socket(self.address_family, self.socket_type))
self.server_bind()
self.server_activate()
示例8: __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 = 'server.pem' # location of the server private key and the server certificate
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:jerry-0824,项目名称:011_python_network_programming_cookbook_demo,代码行数:11,代码来源:04_10_https_server.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)
self.socket = ssl.SSLSocket(socket.socket(self.address_family, self.socket_type),
keyfile="test-key.pem",
certfile="test-cert.pem")
self.server_bind()
self.server_activate()
示例10: __init__
# 需要导入模块: from SocketServer import BaseServer [as 别名]
# 或者: from SocketServer.BaseServer import __init__ [as 别名]
def __init__(self, server_address, RequestHandlerClass, certfile, bind_and_activate=True):
# See SocketServer.TCPServer.__init__
# (added ssl-support):
BaseServer.__init__(self, server_address,RequestHandlerClass)
self.socket = ssl.wrap_socket(socket.socket(self.address_family,self.socket_type),server_side=True,certfile=certfile)
if bind_and_activate:
self.server_bind()
self.server_activate()
示例11: __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.wrap_socket(
socket.socket(self.address_family, self.socket_type),
keyfile = "data/serverkey.pem",
certfile = "data/serverkey.pem"
)
self.server_bind()
self.server_activate()
示例12: __init__
# 需要导入模块: from SocketServer import BaseServer [as 别名]
# 或者: from SocketServer.BaseServer import __init__ [as 别名]
def __init__(self, HandlerClass):
self.cfg, self.profiles = config.get_config()
BaseServer.__init__(self, (self.cfg['address'], int(self.cfg['port'])), HandlerClass)
ctx = SSL.Context(SSL.SSLv23_METHOD)
ctx.use_privatekey_file (self.cfg['keyfile'])
ctx.use_certificate_file(self.cfg['certfile'])
self.socket = SSL.Connection(ctx, socket.socket(self.address_family, self.socket_type))
self.server_bind()
self.server_activate()
示例13: __init__
# 需要导入模块: from SocketServer import BaseServer [as 别名]
# 或者: from SocketServer.BaseServer import __init__ [as 别名]
def __init__(self, server_address, HandlerClass, keyfile = 'hessian/test/server.pem'):
BaseServer.__init__(self, server_address, HandlerClass)
ctx = SSL.Context(SSL.SSLv23_METHOD) #@UndefinedVariable
ctx.use_privatekey_file (keyfile)
ctx.use_certificate_file(keyfile)
self.socket = SSL.Connection( #@UndefinedVariable
ctx,
socket.socket(self.address_family, self.socket_type))
self.server_bind()
self.server_activate()
示例14: __init__
# 需要导入模块: from SocketServer import BaseServer [as 别名]
# 或者: from SocketServer.BaseServer import __init__ [as 别名]
def __init__(self, server_address, HandlerClass):
BaseServer.__init__(self, server_address, HandlerClass)
fpem = 'server.pem'
self.socket = ssl.SSLSocket(
socket.socket(self.address_family,self.socket_type),
keyfile = fpem,
certfile = fpem
)
self.server_bind()
self.server_activate()
示例15: __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.wrap_socket(
socket.socket(self.address_family, self.socket_type),
certfile=SSLKeyfile, keyfile=SSLKeyfile, ssl_version=ssl.PROTOCOL_SSLv23,
server_side=True, suppress_ragged_eofs=False
)
self.server_bind()
self.server_activate()