merge branche "@"
This commit is contained in:
commit
fe502fc0fc
2 changed files with 48 additions and 62 deletions
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
|
||||
import dataclasses
|
||||
from functools import partial
|
||||
from pathlib import Path
|
||||
from twisted.spread import jelly, pb
|
||||
from twisted.internet import reactor
|
||||
|
|
@ -106,12 +107,8 @@ class Bridge(object):
|
|||
log.info("Init Perspective Broker...")
|
||||
self.root = PBRoot()
|
||||
conf = config.parseMainConf()
|
||||
conn_type = config.getConfig(
|
||||
conf,
|
||||
"",
|
||||
"bridge_pb_connection_type",
|
||||
"unix_socket"
|
||||
)
|
||||
getConf = partial(config.getConf, conf, "bridge_pb", "")
|
||||
conn_type = getConf("connection_type", "unix_socket")
|
||||
if conn_type == "unix_socket":
|
||||
local_dir = Path(config.getConfig(conf, "", "local_dir")).resolve()
|
||||
socket_path = local_dir / "bridge_pb"
|
||||
|
|
@ -120,12 +117,7 @@ class Bridge(object):
|
|||
str(socket_path), pb.PBServerFactory(self.root), mode=0o600
|
||||
)
|
||||
elif conn_type == "socket":
|
||||
port = int(config.getConfig(
|
||||
conf,
|
||||
"",
|
||||
"bridge_pb_port",
|
||||
8789
|
||||
))
|
||||
port = int(getConf("port", 8789))
|
||||
log.info(f"using TCP Socket at port {port}")
|
||||
reactor.listenTCP(port, pb.PBServerFactory(self.root))
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -140,29 +140,15 @@ class Bridge(object):
|
|||
def bridgeConnect(self, callback, errback):
|
||||
factory = pb.PBClientFactory()
|
||||
conf = config.parseMainConf()
|
||||
conn_type = config.getConfig(
|
||||
conf,
|
||||
"",
|
||||
"bridge_pb_connection_type",
|
||||
"unix_socket"
|
||||
)
|
||||
getConf = partial(config.getConf, conf, "bridge_pb", "")
|
||||
conn_type = getConf("connection_type", "unix_socket")
|
||||
if conn_type == "unix_socket":
|
||||
local_dir = Path(config.getConfig(conf, "", "local_dir")).resolve()
|
||||
socket_path = local_dir / "bridge_pb"
|
||||
reactor.connectUNIX(str(socket_path), factory)
|
||||
elif conn_type == "socket":
|
||||
host = int(config.getConfig(
|
||||
conf,
|
||||
"",
|
||||
"bridge_pb_host",
|
||||
"localhost"
|
||||
))
|
||||
port = int(config.getConfig(
|
||||
conf,
|
||||
"",
|
||||
"bridge_pb_port",
|
||||
8789
|
||||
))
|
||||
host = getConf("host", "localhost")
|
||||
port = int(getConf("port", 8789))
|
||||
reactor.connectTCP(host, port, factory)
|
||||
else:
|
||||
raise ValueError(f"Unknown pb connection type: {conn_type!r}")
|
||||
|
|
|
|||
Loading…
Reference in a new issue