Esempio n. 1
0
def get_api_factory():
    settings = dict(cookie_secret=randbits(128), debug=GLSettings.log_requests_responses, gzip=True)

    GLAPIFactory = web.Application(spec, **settings)
    GLAPIFactory.protocol = base.GLHTTPConnection

    return GLAPIFactory
Esempio n. 2
0
def get_api_factory():
    settings = dict(cookie_secret=randbits(128),
                    debug=GLSettings.log_requests_responses,
                    gzip=True)

    GLAPIFactory = Antani(spec, **settings)
    GLAPIFactory.protocol = base.GLHTTPConnection

    return GLAPIFactory
Esempio n. 3
0
 def test_randbits(self):
     self.assertEqual(len(utility.randbits(4)), 0)
     self.assertEqual(len(utility.randbits(8)), 1)
     self.assertEqual(len(utility.randbits(9)), 1)
     self.assertEqual(len(utility.randbits(16)), 2)
Esempio n. 4
0
 def test_randbits(self):
     self.assertEqual(len(utility.randbits(4)), 0)
     self.assertEqual(len(utility.randbits(8)), 1)
     self.assertEqual(len(utility.randbits(9)), 1)
     self.assertEqual(len(utility.randbits(16)), 2)
Esempio n. 5
0
# do all the necessary high level wiring to make everything work together.
# Specifically we create the cyclone web.Application from the API specification,
# we create a TCPServer for it and setup logging.
# We also set to kill the threadpool (the one used by Storm) when the
# application shuts down.

from twisted.application.service import Application
from twisted.application import internet
from cyclone import web

from globaleaks.utils.utility import randbits
from globaleaks.settings import GLSetting
from globaleaks.rest import api
from globaleaks.handlers.base import GLHTTPServer

application = Application('GLBackend')

settings = dict(cookie_secret=randbits(128),
                xsrf_cookies=True,
                debug=GLSetting.http_log)

# Initialize the web API event listener, handling all the synchronous operations
GLBackendAPIFactory = web.Application(api.spec, **settings)
GLBackendAPIFactory.protocol = GLHTTPServer

for ip in GLSetting.bind_addresses:
    GLBackendAPI = internet.TCPServer(GLSetting.bind_port, GLBackendAPIFactory, interface=ip)
    GLBackendAPI.setServiceParent(application)

# define exit behaviour
Esempio n. 6
0
#   *******
# Here is the logic for creating a twisted service. In this part of the code we
# do all the necessary high level wiring to make everything work together.
# Specifically we create the cyclone web.Application from the API specification,
# we create a TCPServer for it and setup logging.
# We also set to kill the threadpool (the one used by Storm) when the
# application shuts down.

from twisted.application.service import Application
from twisted.application import internet
from cyclone import web

from globaleaks.utils.utility import randbits
from globaleaks.settings import GLSettings
from globaleaks.rest import api
from globaleaks.handlers.base import GLHTTPConnection

application = Application("GLBackend")

settings = dict(cookie_secret=randbits(128), debug=GLSettings.http_log, gzip=True)

# Initialize the web API event listener, handling all the synchronous operations
GLBackendAPIFactory = web.Application(api.spec, **settings)
GLBackendAPIFactory.protocol = GLHTTPConnection

for ip in GLSettings.bind_addresses:
    GLBackendAPI = internet.TCPServer(GLSettings.bind_port, GLBackendAPIFactory, interface=ip)
    GLBackendAPI.setServiceParent(application)

# define exit behaviour