fix make port and path configurable

This commit is contained in:
chrys 2018-09-07 21:19:21 +02:00
parent 0d0985af9d
commit 6b8c24831c
7 changed files with 38 additions and 14 deletions

View File

@ -188,10 +188,15 @@ cursor=True
highlight=False highlight=False
[remote] [remote]
enabled=True enable=True
# connection type # connection type
# unix = unix sockets # unix = unix sockets
# tcp = tcp (localhost only)
method=unix method=unix
# tcp port
port=22447
# socket filepath
socketpath=/tmp/
# allow settings to overwrite # allow settings to overwrite
enableSettingsRemote=True enableSettingsRemote=True
# permitted settings # permitted settings

View File

@ -201,7 +201,12 @@ highlight=False
enable=True enable=True
# connection type # connection type
# unix = unix sockets # unix = unix sockets
# tcp = tcp (localhost only)
method=unix method=unix
# tcp port
port=22447
# socket filepath
socketpath=/tmp/
# allow settings to overwrite # allow settings to overwrite
enableSettingsRemote=True enableSettingsRemote=True
# permitted settings # permitted settings

View File

@ -199,10 +199,15 @@ cursor=True
highlight=False highlight=False
[remote] [remote]
enabled=True enable=True
# connection type # connection type
# unix = unix sockets # unix = unix sockets
# tcp = tcp (localhost only)
method=unix method=unix
# tcp port
port=22447
# socket filepath
socketpath=/tmp/
# allow settings to overwrite # allow settings to overwrite
enableSettingsRemote=True enableSettingsRemote=True
# permitted settings # permitted settings

View File

@ -144,10 +144,15 @@ cursor=True
highlight=False highlight=False
[remote] [remote]
enabled=True enable=True
# connection type # connection type
# unix = unix sockets # unix = unix sockets
# tcp = tcp (localhost only)
method=unix method=unix
# tcp port
port=22447
# socket filepath
socketpath=/tmp/
# allow settings to overwrite # allow settings to overwrite
enableSettingsRemote=True enableSettingsRemote=True
# permitted settings # permitted settings

View File

@ -198,10 +198,15 @@ cursor=True
highlight=False highlight=False
[remote] [remote]
enabled=True enable=True
# connection type # connection type
# unix = unix sockets # unix = unix sockets
# tcp = tcp (localhost only)
method=unix method=unix
# tcp port
port=22447
# socket filepath
socketpath=/tmp/
# allow settings to overwrite # allow settings to overwrite
enableSettingsRemote=True enableSettingsRemote=True
# permitted settings # permitted settings

View File

@ -57,21 +57,18 @@ class remoteManager():
self.sock.close() self.sock.close()
self.sock = None self.sock = None
def unixSocketWatchDog(self, active, eventQueue): def unixSocketWatchDog(self, active, eventQueue):
# echo "command say this is a test" | socat - UNIX-CLIENT:/tmp/fenrir-deamon.sock # echo "command say this is a test" | socat - UNIX-CLIENT:/tmp/fenrirscreenreader-deamon.sock
# socket daemon
# /run/user/<uid>/fenrirscreenreader/daemon
# socket pty
# /run/user/<uid>/fenrirscreenreader/ptyX
if self.env['runtime']['settingsManager'].getSetting('screen', 'driver') =='vcsaDriver': if self.env['runtime']['settingsManager'].getSetting('screen', 'driver') =='vcsaDriver':
socketpath = '/tmp/fenrirscreenreader-deamon.sock' socketpath = self.env['runtime']['settingsManager'].getSettingAsInt('remote', 'socketpath') + 'fenrirscreenreader-deamon.sock'
else: else:
socketpath = '/tmp/fenrirscreenreader-' + str(os.getpid()) + '.sock' socketpath = self.env['runtime']['settingsManager'].getSettingAsInt('remote', 'socketpath') + 'fenrirscreenreader-' + str(os.getpid()) + '.sock'
if os.path.exists(socketpath): if os.path.exists(socketpath):
os.remove(socketpath) os.remove(socketpath)
self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
self.sock.bind(socketpath) self.sock.bind(socketpath)
self.sock.listen(1) self.sock.listen(1)
if not self.env['runtime']['settingsManager'].getSetting('screen', 'driver') =='vcsaDriver': if self.env['runtime']['settingsManager'].getSetting('screen', 'driver') =='vcsaDriver':
os.chmod(socketpath, 0o222) os.chmod(socketpath, 0o222)
while active.value == 1: while active.value == 1:
client_sock, client_addr = self.sock.accept() client_sock, client_addr = self.sock.accept()
@ -91,7 +88,7 @@ class remoteManager():
except: except:
pass pass
client_sock.close() client_sock.close()
if os.path.exists(socketpath): if os.path.exists(socketpath):
os.remove(socketpath) os.remove(socketpath)
if self.sock: if self.sock:
@ -102,7 +99,7 @@ class remoteManager():
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
self.host = '127.0.0.1' self.host = '127.0.0.1'
self.port = 22447 self.port = self.env['runtime']['settingsManager'].getSettingAsInt('remote', 'port')
self.sock.bind((self.host, self.port)) self.sock.bind((self.host, self.port))
self.sock.listen(1) self.sock.listen(1)
while active.value == 1: while active.value == 1:

View File

@ -84,6 +84,8 @@ settingsData = {
'remote':{ 'remote':{
'enabled': True, 'enabled': True,
'method': 'unix', 'method': 'unix',
'port': 22447,
'socketpath':'/tmp/',
'enableSettingsRemote': True, 'enableSettingsRemote': True,
'allowSettings': 'barrier#enabled', 'allowSettings': 'barrier#enabled',
'enableCommandRemote': True, 'enableCommandRemote': True,