From 6b8c24831c29f7511a8972b24c2329fbbec4135c Mon Sep 17 00:00:00 2001 From: chrys Date: Fri, 7 Sep 2018 21:19:21 +0200 Subject: [PATCH] fix make port and path configurable --- config/settings/espeak.settings.conf | 7 ++++++- config/settings/settings.conf | 5 +++++ config/settings/settings.conf.example | 7 ++++++- config/settings/settings.conf.storm | 7 ++++++- config/settings/speech-dispatcher.settings.conf | 7 ++++++- src/fenrirscreenreader/core/remoteManager.py | 17 +++++++---------- src/fenrirscreenreader/core/settingsData.py | 2 ++ 7 files changed, 38 insertions(+), 14 deletions(-) diff --git a/config/settings/espeak.settings.conf b/config/settings/espeak.settings.conf index 5b2b5250..3137a660 100644 --- a/config/settings/espeak.settings.conf +++ b/config/settings/espeak.settings.conf @@ -188,10 +188,15 @@ cursor=True highlight=False [remote] -enabled=True +enable=True # connection type # unix = unix sockets +# tcp = tcp (localhost only) method=unix +# tcp port +port=22447 +# socket filepath +socketpath=/tmp/ # allow settings to overwrite enableSettingsRemote=True # permitted settings diff --git a/config/settings/settings.conf b/config/settings/settings.conf index a3afbdb4..ab2d8f90 100644 --- a/config/settings/settings.conf +++ b/config/settings/settings.conf @@ -201,7 +201,12 @@ highlight=False enable=True # connection type # unix = unix sockets +# tcp = tcp (localhost only) method=unix +# tcp port +port=22447 +# socket filepath +socketpath=/tmp/ # allow settings to overwrite enableSettingsRemote=True # permitted settings diff --git a/config/settings/settings.conf.example b/config/settings/settings.conf.example index 8754aa14..a9e893e8 100644 --- a/config/settings/settings.conf.example +++ b/config/settings/settings.conf.example @@ -199,10 +199,15 @@ cursor=True highlight=False [remote] -enabled=True +enable=True # connection type # unix = unix sockets +# tcp = tcp (localhost only) method=unix +# tcp port +port=22447 +# socket filepath +socketpath=/tmp/ # allow settings to overwrite enableSettingsRemote=True # permitted settings diff --git a/config/settings/settings.conf.storm b/config/settings/settings.conf.storm index e9bc09be..2969e76a 100644 --- a/config/settings/settings.conf.storm +++ b/config/settings/settings.conf.storm @@ -144,10 +144,15 @@ cursor=True highlight=False [remote] -enabled=True +enable=True # connection type # unix = unix sockets +# tcp = tcp (localhost only) method=unix +# tcp port +port=22447 +# socket filepath +socketpath=/tmp/ # allow settings to overwrite enableSettingsRemote=True # permitted settings diff --git a/config/settings/speech-dispatcher.settings.conf b/config/settings/speech-dispatcher.settings.conf index b4fb40af..4bfe3c0c 100644 --- a/config/settings/speech-dispatcher.settings.conf +++ b/config/settings/speech-dispatcher.settings.conf @@ -198,10 +198,15 @@ cursor=True highlight=False [remote] -enabled=True +enable=True # connection type # unix = unix sockets +# tcp = tcp (localhost only) method=unix +# tcp port +port=22447 +# socket filepath +socketpath=/tmp/ # allow settings to overwrite enableSettingsRemote=True # permitted settings diff --git a/src/fenrirscreenreader/core/remoteManager.py b/src/fenrirscreenreader/core/remoteManager.py index 72b71763..89a7b77f 100644 --- a/src/fenrirscreenreader/core/remoteManager.py +++ b/src/fenrirscreenreader/core/remoteManager.py @@ -57,21 +57,18 @@ class remoteManager(): self.sock.close() self.sock = None def unixSocketWatchDog(self, active, eventQueue): - # echo "command say this is a test" | socat - UNIX-CLIENT:/tmp/fenrir-deamon.sock - # socket daemon - # /run/user//fenrirscreenreader/daemon - # socket pty - # /run/user//fenrirscreenreader/ptyX + # echo "command say this is a test" | socat - UNIX-CLIENT:/tmp/fenrirscreenreader-deamon.sock + 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: - 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): os.remove(socketpath) self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) self.sock.bind(socketpath) 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) while active.value == 1: client_sock, client_addr = self.sock.accept() @@ -91,7 +88,7 @@ class remoteManager(): except: pass client_sock.close() - + if os.path.exists(socketpath): os.remove(socketpath) if self.sock: @@ -102,7 +99,7 @@ class remoteManager(): self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 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.listen(1) while active.value == 1: diff --git a/src/fenrirscreenreader/core/settingsData.py b/src/fenrirscreenreader/core/settingsData.py index 12e206f0..b0cb535f 100644 --- a/src/fenrirscreenreader/core/settingsData.py +++ b/src/fenrirscreenreader/core/settingsData.py @@ -84,6 +84,8 @@ settingsData = { 'remote':{ 'enabled': True, 'method': 'unix', + 'port': 22447, + 'socketpath':'/tmp/', 'enableSettingsRemote': True, 'allowSettings': 'barrier#enabled', 'enableCommandRemote': True,