mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
Remove SSL support from API
This commit is contained in:
parent
66d02d40ce
commit
e465c7567b
1 changed files with 6 additions and 11 deletions
17
yunohost.tac
17
yunohost.tac
|
@ -11,7 +11,7 @@ sys.path.append('/usr/share/pyshared')
|
||||||
from twisted.python.log import ILogObserver, FileLogObserver, startLogging, msg
|
from twisted.python.log import ILogObserver, FileLogObserver, startLogging, msg
|
||||||
from twisted.python.logfile import DailyLogFile
|
from twisted.python.logfile import DailyLogFile
|
||||||
from twisted.web.server import Site, http
|
from twisted.web.server import Site, http
|
||||||
from twisted.internet import reactor, ssl
|
from twisted.internet import reactor
|
||||||
from twisted.application import internet,service
|
from twisted.application import internet,service
|
||||||
from txrestapi.resource import APIResource
|
from txrestapi.resource import APIResource
|
||||||
from yunohost import YunoHostError, YunoHostLDAP, str_to_func, colorize, pretty_print_dict, display_error, validate, win, parse_dict
|
from yunohost import YunoHostError, YunoHostLDAP, str_to_func, colorize, pretty_print_dict, display_error, validate, win, parse_dict
|
||||||
|
@ -24,8 +24,6 @@ gettext.install('YunoHost')
|
||||||
|
|
||||||
dev = False
|
dev = False
|
||||||
installed = True
|
installed = True
|
||||||
ssl_key = '/etc/ssl/private/yunohost_key.pem'
|
|
||||||
ssl_crt = '/etc/ssl/certs/yunohost_crt.pem'
|
|
||||||
action_dict = {}
|
action_dict = {}
|
||||||
api = APIResource()
|
api = APIResource()
|
||||||
|
|
||||||
|
@ -173,16 +171,16 @@ def api_doc(request):
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
if request.path == '/api':
|
if request.path == '/api':
|
||||||
with open('doc/resources.json') as f:
|
with open('doc/resources.json') as f:
|
||||||
return f.read()
|
return f.read()
|
||||||
|
|
||||||
category = request.path.split('/')[2]
|
category = request.path.split('/')[2]
|
||||||
try:
|
try:
|
||||||
with open('doc/'+ category +'.json') as f:
|
with open('doc/'+ category +'.json') as f:
|
||||||
return f.read()
|
return f.read()
|
||||||
except IOError:
|
except IOError:
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
def favicon(request):
|
def favicon(request):
|
||||||
request.setHeader('Access-Control-Allow-Origin', '*') # Allow cross-domain requests
|
request.setHeader('Access-Control-Allow-Origin', '*') # Allow cross-domain requests
|
||||||
request.setResponseCode(404, 'Not Found')
|
request.setResponseCode(404, 'Not Found')
|
||||||
|
@ -256,14 +254,11 @@ if __name__ == '__main__':
|
||||||
else:
|
else:
|
||||||
startLogging(open('/var/log/yunohost.log', 'a+')) # Log actions to file
|
startLogging(open('/var/log/yunohost.log', 'a+')) # Log actions to file
|
||||||
main()
|
main()
|
||||||
if '--dev' in sys.argv:
|
reactor.listenTCP(6787, Site(api, timeout=None))
|
||||||
reactor.listenTCP(6767, Site(api, timeout=None))
|
|
||||||
else:
|
|
||||||
reactor.listenSSL(6767, Site(api, timeout=None), ssl.DefaultOpenSSLContextFactory(ssl_key, ssl_crt))
|
|
||||||
reactor.run()
|
reactor.run()
|
||||||
else:
|
else:
|
||||||
application = service.Application("YunoHost API")
|
application = service.Application("YunoHost API")
|
||||||
logfile = DailyLogFile("yunohost.log", "/var/log")
|
logfile = DailyLogFile("yunohost.log", "/var/log")
|
||||||
application.setComponent(ILogObserver, FileLogObserver(logfile).emit)
|
application.setComponent(ILogObserver, FileLogObserver(logfile).emit)
|
||||||
main()
|
main()
|
||||||
internet.SSLServer(6767, Site(api, timeout=None), ssl.DefaultOpenSSLContextFactory(ssl_key, ssl_crt)).setServiceParent(application)
|
internet.TCPServer(6787, Site(api, timeout=None)).setServiceParent(application)
|
||||||
|
|
Loading…
Add table
Reference in a new issue