-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
38 lines (29 loc) · 1.04 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python3
# Run with twistd -ny app.py
import os
from twisted.internet import reactor, endpoints
from twisted.application import service, strports
from twisted.application.internet import ClientService
from twisted.web import server
# Load config
from isaliveme import Config, ManholeNamespace
# Setup application
from isaliveme import IsAliveMeTokenResource
application = service.Application("IsAlive.me")
serv_collection = service.IServiceCollection(application)
# TokenResource
resource = IsAliveMeTokenResource(tokens=Config.isaliveme.tokens)
site = server.Site(resource)
i = strports.service(Config.isaliveme.endpoint, site)
i.setServiceParent(serv_collection)
# Set up SSH config service
from isaliveme import conch_helper, IsAliveMeSSHProtocol
IsAliveMeSSHProtocol.update_state = resource.processToken
i = conch_helper(
Config.manhole.endpoint,
namespace=ManholeNamespace,
proto=IsAliveMeSSHProtocol,
keyDir=os.getenv("ISALIVEME_KEY_DIR", "ssh/"),
keySize=Config.manhole.keySize,
)
i.setServiceParent(serv_collection)