Ejemplo n.º 1
0
        def connection_done(ok):
            self.ssids.set_click(True)
            self.scan_btn.set_click(True)

            if ok:
                self.screen.set_status("wifi", True)

                self.write_key(ssid, password)

                self.ssids.set_show_selected(True)

                # find ssid in network list and select it
                for i in range(len(self.networks)):
                    if self.networks[i]["ssid"] == ssid:
                        self.ssids.set_selected(i)

                self.label.set_text("Connected\n\nSSID: " + ssid + "\nIP: " +
                                    self.wlan.ifconfig()[0] + "\n" +
                                    self.config["name"] + ".local")

                try:
                    self.server = http_server()
                    self.server.register_input_callback()
                except Exception as e:
                    print("Webserver error:", e)

                import espidf
                if espidf.mdns_init() == 0:
                    espidf.mdns_hostname_set(self.config["name"])
            else:
                self.label.set_text("Connection failed")

            self.task.set_repeat_count(0)
Ejemplo n.º 2
0
    def __init__(self, input_q, output_q, endpoint, **kwds):
        from http_server import http_server

        threading.Thread.__init__(self, **kwds)
        self.setDaemon(1)
        self.input_q = input_q
        self.output_q = output_q
        self.endpoint = endpoint
        self.keep_running = True
        self.server = http_server(self.input_q, self.output_q, self.endpoint)

        self.start()
Ejemplo n.º 3
0
import filesys
import ftp_server
import http_server
import status_handler

# M2Crypto
import https_server
import poison_handler
import ftps_server
from M2Crypto import Rand, SSL, threading

HTTP_PORT = 39080
HTTPS_PORT = 39443
FTP_PORT = 39021

hs = http_server.http_server('', HTTP_PORT)

Rand.load_file('../randpool.dat', -1)
ssl_ctx = SSL.Context('sslv23')
ssl_ctx.load_cert('server.pem')
ssl_ctx.load_verify_locations('ca.pem', '')
ssl_ctx.load_client_CA('ca.pem')
#ssl_ctx.set_verify(SSL.verify_peer, 10)
#ssl_ctx.set_verify(SSL.verify_peer|SSL.verify_fail_if_no_peer_cert, 10)
#ssl_ctx.set_verify(SSL.verify_peer|SSL.verify_client_once, 10)
ssl_ctx.set_verify(SSL.verify_none, 10)
ssl_ctx.set_session_id_ctx('127.0.0.1:39443')
ssl_ctx.set_tmp_dh('dh1024.pem')
ssl_ctx.set_info_callback()

hss = https_server.https_server('', HTTPS_PORT, ssl_ctx)
Ejemplo n.º 4
0
import http_server
import status_handler

# M2Crypto
import https_server
import poison_handler
from M2Crypto import Rand, SSL

# XMLrpc
import xmlrpc_handler


HTTP_PORT=39080
HTTPS_PORT=39443

hs=http_server.http_server('', HTTP_PORT)

Rand.load_file('../randpool.dat', -1) 
ssl_ctx=SSL.Context('sslv23')
ssl_ctx.load_cert('server.pem')
#ssl_ctx.load_verify_location('ca.pem')
#ssl_ctx.load_client_CA('ca.pem')
#ssl_ctx.set_verify(SSL.verify_peer, 10)
#ssl_ctx.set_verify(SSL.verify_peer|SSL.verify_fail_if_no_peer_cert, 10)
#ssl_ctx.set_verify(SSL.verify_peer|SSL.verify_client_once, 10)
ssl_ctx.set_verify(SSL.verify_none, 10)
ssl_ctx.set_session_id_ctx('127.0.0.1:9443')
ssl_ctx.set_tmp_dh('dh1024.pem')
#ssl_ctx.set_info_callback()

hss=https_server.https_server('', HTTPS_PORT, ssl_ctx)
Ejemplo n.º 5
0
#
# XML-RPC SERVER
# $Id: xmlrpc_handler.py,v 1.1 2001/07/11 17:42:21 effbot Exp $
#
# an asynchronous XML-RPC server for Medusa
#
# written by Sam Rushing
#
# Based on "xmlrpcserver.py" by Fredrik Lundh ([email protected])
#
import http_server
import xmlrpclib
import regex
import string
import sys

class xmlrpc_handler:
    def match(self, request):
        # Note: /RPC2 is not required by the spec, so you may override this method.
        if request.uri[:5] == '/RPC2':
            return 1
        else:
            return 0
    def handle_request(self, request):
        [path, params, query, fragment] = request.split_uri()
        if request.command in ('post', 'put'):
            request.collector = collector(self, request)
        else:
            request.error(400)
    def continue_request(self, data, request):
Ejemplo n.º 6
0

if __name__ == "__main__":

    import sys

    if len(sys.argv) < 2:
        print "Usage: %s <worker_threads>" % sys.argv[0]
    else:
        nthreads = string.atoi(sys.argv[1])

        import asyncore
        import http_server

        # create a generic web server
        hs = http_server.http_server("", 7080)

        # create a request queue
        q = request_queue()

        # create a script handler
        sh = script_handler(q)

        # install the script handler on the web server
        hs.install_handler(sh)

        # get a couple of CGI modules
        import test_module
        import pi_module

        # install the module on the script handler
Ejemplo n.º 7
0
Archivo: pycs.py Proyecto: myelin/pycs
	# Make handler for /system
	mod_h = pycs_module_handler.pycs_module_handler( set )
	if os.path.isfile( os.path.join( pycs_paths.CONFDIR, 'users.conf' ) ):
		# Add auth wrapper
		mod_h = pycs_auth_handler.pycs_auth_handler( set, mod_h, set.authorizer )
	
	# add the webauth wrapper (handles accessRestriction restrictions)
	default_h = pycs_webauth_handler.pycs_webauth_handler( set, default_h, rpc_ar_h )

	# Make logger
	accessLog = logger.rotating_file_logger( pycs_paths.ACCESSLOG, None, 1024*1024 )
	print "logging to",pycs_paths.ACCESSLOG
	logger = status_handler.logger_for_status( accessLog )

	# Make web server
	hs = http_server.http_server( '', set.ServerPort(), None, logger )
	hs.server_name = set.conf['serverhostname']

	ms = None
	if set.conf.has_key( 'monitorport' ):
		port = int( set.conf['monitorport'] )
		if set.conf.has_key( 'monitorpassword' ):
			pwd = set.conf['monitorpassword']
			ms = monitor.secure_monitor_server( pwd, '', port )
		else:
			ms = monitor.monitor_server( '', port )

	# become the PyCS user
	if os.name == 'posix':
		try:
			# look in ~medusa/patches for {set,get}euid.
Ejemplo n.º 8
0
        if not cl:
            request.error(411)
        else:
            cl = string.atoi(cl)
            # using a 'numeric' terminator
            self.request.channel.set_terminator(cl)

    def collect_incoming_data(self, data):
        self.data.append(data)

    def found_terminator(self):
        # set the terminator back to the default
        self.request.channel.set_terminator('\r\n\r\n')
        self.handler.continue_request("".join(self.data), self.request)


if __name__ == '__main__':

    class rpc_demo(xmlrpc_handler):
        def call(self, method, params):
            print 'method="%s" params=%s' % (method, params)
            return "Sure, that works"

    import asyncore_25 as asyncore

    hs = http_server.http_server('', 8000)
    rpc = rpc_demo()
    hs.install_handler(rpc)

    asyncore.loop()
Ejemplo n.º 9
0
# deliver files!

# This default handler uses the filesystem object we just constructed.

dh = default_handler.default_handler (dfs)
cdh = cdms_handler.cdms_handler(fs)

# Wrap an authentication handler around the default file handler

ah = auth_handler.auth_handler(dh,'access')
acdh = auth_handler.auth_handler(cdh,'access')

# ===========================================================================
# HTTP Server
# ===========================================================================
hs = http_server.http_server (IP_ADDRESS, HTTP_PORT, rs, lg)

# Here we install the authentication handler created above.
hs.install_handler (ah)
hs.install_handler(acdh)

# ===========================================================================
# Unix user `public_html' directory support
# ===========================================================================
if os.name == 'posix':
	import unix_user_handler
	uh = unix_user_handler.unix_user_handler ('public_html')
	hs.install_handler (uh)

# ===========================================================================
# FTP Server
Ejemplo n.º 10
0
            request.error(411)
        else:
            cl = string.atoi(cl)
            # using a 'numeric' terminator
            self.request.channel.set_terminator(cl)

    def collect_incoming_data(self, data):
        self.data = self.data + data

    def found_terminator(self):
        # set the terminator back to the default
        self.request.channel.set_terminator("\r\n\r\n")
        self.handler.continue_request(self.data, self.request)


if __name__ == "__main__":

    class rpc_demo(xmlrpc_handler):
        def call(self, method, params):
            print 'method="%s" params=%s' % (method, params)
            return "Sure, that works"

    import asyncore
    import http_server

    hs = http_server.http_server("", 8000)
    rpc = rpc_demo()
    hs.install_handler(rpc)

    asyncore.loop()
Ejemplo n.º 11
0
import http_server, script_handler
import basecfg

#--------------------------------------

path = basecfg.basepath+'/browser/http'
#path = '/home/rand/apr/browser/http'

os.chdir(path)
fs = filesys.os_filesystem(path)

dh = default_handler.default_handler(fs)
sh = script_handler.script_handler(fs)

if os.uname()[0] == 'AIX' or len(sys.argv) > 1:
  h = http_server.http_server('', 8080)
else:
  h = http_server.http_server('', 8180)

h.install_handler (dh)
h.install_handler (sh)

authorizer = ftp_server.anon_authorizer (basecfg.baselog)
if os.uname()[0] == 'AIX' or len(sys.argv) > 1:
  fs = ftp_server.ftp_server (authorizer, port=8021)
else:
  fs = ftp_server.ftp_server (authorizer, port=8121)

asyncore.loop()

Ejemplo n.º 12
0
        # set the terminator back to the default
        self.request.channel.set_terminator ('\r\n\r\n')
        self.handler.continue_request (self.data, self.request)


if __name__ == '__main__':

    import asyncore
    import http_server

    class Thing:
    
        def badparam(self, param):
            if param == 'good param':
                return 1
            else:
                return Fault(faultstring='bad param')
    
        def dt(self, aDateTime):
            return aDateTime

    thing = Thing()
    soaph = soap_handler()
    soaph.registerObject(thing)
    
    hs = http_server.http_server('', 10080)
    hs.install_handler(soaph)
    
    asyncore.loop()

def init_server(request):
    """
    Launch the http server, but don't start blocking until
    the testing session is over!
    """
    request.addfinalizer(http_server().join)
Ejemplo n.º 14
0
#
# XML-RPC SERVER
# $Id: xmlrpc_handler.py,v 1.1 2001/07/11 17:42:21 effbot Exp $
#
# an asynchronous XML-RPC server for Medusa
#
# written by Sam Rushing
#
# Based on "xmlrpcserver.py" by Fredrik Lundh ([email protected])
#
import http_server
import xmlrpclib
import regex
import string
import sys
class xmlrpc_handler:
    def match (self, request):
        # Note: /RPC2 is not required by the spec, so you may override this method.
        if request.uri[:5] == '/RPC2':
            return 1
        else:
            return 0
    def handle_request (self, request):
        [path, params, query, fragment] = request.split_uri()
        if request.command in ('post', 'put'):
            request.collector = collector (self, request)
        else:
            request.error (400)
    def continue_request (self, data, request):
        params, method = xmlrpclib.loads (data)
Ejemplo n.º 15
0
    for opt,arg in optlist:
        if opt =="-h":
            print("usage python server.py [-p port_num] [-f num_forks] [-t num_threads_per_fork]")
            sys.exit(0)
        elif opt =="p":
            server_settings.port=arg
        elif opt =="-f":
            server_settings.num_forks=arg
        elif opt == "-t":
            server_settings.num_threads_per_fork=arg
        elif opt == "-d":
            server_settings.service_dir=arg

    
    server=http_server()
    
    print("Starting server "+str(time.asctime()))
    print("Port "+str(server_settings.port))
    print("Num forks "+str(server_settings.num_forks))
    print("Num threads per fork "+str(server_settings.num_threads_per_fork))

    
    try:
        server.serve_forever()
    except KeyboardInterrupt:
        pass

    print("Closing server "+str(time.asctime()))
    try:
        server.shutdown()
Ejemplo n.º 16
0
    def found_terminator(self):
        # set the terminator back to the default
        self.request.channel.set_terminator('\r\n\r\n')
        self.handler.continue_request(self.data, self.request)


if __name__ == '__main__':

    import asyncore
    import http_server

    class Thing:
        def badparam(self, param):
            if param == 'good param':
                return 1
            else:
                return Fault(faultstring='bad param')

        def dt(self, aDateTime):
            return aDateTime

    thing = Thing()
    soaph = soap_handler()
    soaph.registerObject(thing)

    hs = http_server.http_server('', 10080)
    hs.install_handler(soaph)

    asyncore.loop()
Ejemplo n.º 17
0
# -*- Mode: Python; tab-width: 4 -*-

import asyncore
import http_server
import script_handler
import filesys

h = http_server.http_server ('', 8081)
fs = filesys.os_filesystem ('.')
sh = script_handler.script_handler (fs)

import persistent
ph = script_handler.persistent_script_handler()
ph.add_module ('per', persistent)

# install the two handlers
# Hit me as: http://www.your_server.com:8081/per
h.install_handler (ph)
# Hit me as: http://www.your_server.com:8081/form.mpy
h.install_handler (sh)

asyncore.loop()
Ejemplo n.º 18
0
import filesys

# For this demo, we'll just use a dictionary of usernames/passwords.
# You can of course use anything that supports the mapping interface,
# and it would be pretty easy to set this up to use the crypt module
# on unix.

users = { 'mozart' : 'jupiter', 'beethoven' : 'pastoral' }

# The filesystem we will be giving access to
fs = filesys.os_filesystem ('/home/medusa')

# The 'default' handler - delivers files for the HTTP GET method.
dh = default_handler.default_handler (fs)

# Supports the HTTP PUT method...
ph = put_handler.put_handler (fs, '/.*')

# ... but be sure to wrap it with an auth handler:
ah = auth_handler.auth_handler (users, ph)

# Create a Web Server
hs = http_server.http_server (ip='', port=8080)

# install the handlers we created:

hs.install_handler (dh) # for GET
hs.install_handler (ah) # for PUT

asyncore.loop()
Ejemplo n.º 19
0
        while 1:
            function, (env, stdin, stdout) = self.queue.get()
            function(env, stdin, stdout)
            stdout.close()


if __name__ == '__main__':
    if len(sys.argv) < 2:
        print('Usage: %s <worker_threads>' % sys.argv[0])
    else:
        nthreads = string.atoi(sys.argv[1])

        import asyncore
        import http_server
        # create a generic web server
        hs = http_server.http_server('', 7080)

        # create a request queue
        q = request_queue()

        # create a script handler
        sh = script_handler(q)

        # install the script handler on the web server
        hs.install_handler(sh)

        # get a couple of CGI modules
        import test_module
        import pi_module

        # install the module on the script handler
            request.error (411)
        else:
            cl = int (cl)
            # using a 'numeric' terminator
            self.request.channel.set_terminator (cl)

    def collect_incoming_data (self, data):
        self.data = self.data + data

    def found_terminator (self):
        # set the terminator back to the default
        self.request.channel.set_terminator ('\r\n\r\n')
        self.handler.continue_request (self.data, self.request)

if __name__ == '__main__':

    class rpc_demo (xmlrpc_handler):

        def call (self, method, params):
            print 'method="%s" params=%s' % (method, params)
            return "Sure, that works"

    import asyncore
    import http_server

    hs = http_server.http_server ('', 8000)
    rpc = rpc_demo()
    hs.install_handler (rpc)

    asyncore.loop()
Ejemplo n.º 21
0
# deliver files!

# This default handler uses the filesystem object we just constructed.

dh = default_handler.default_handler(dfs)
cdh = cdms_handler.cdms_handler(fs)

# Wrap an authentication handler around the default file handler

ah = auth_handler.auth_handler(dh, 'access')
acdh = auth_handler.auth_handler(cdh, 'access')

# ===========================================================================
# HTTP Server
# ===========================================================================
hs = http_server.http_server(IP_ADDRESS, HTTP_PORT, rs, lg)

# Here we install the authentication handler created above.
hs.install_handler(ah)
hs.install_handler(acdh)

# ===========================================================================
# Unix user `public_html' directory support
# ===========================================================================
if os.name == 'posix':
    import unix_user_handler
    uh = unix_user_handler.unix_user_handler('public_html')
    hs.install_handler(uh)

# ===========================================================================
# FTP Server