Skip to content

Commit 627dd92

Browse files
committed
Added ability to listen on all ports + executable
1 parent 5258cc0 commit 627dd92

File tree

12 files changed

+53
-196
lines changed

12 files changed

+53
-196
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ __pycache__/
33
*.py[cod]
44
*$py.class
55

6+
.idea/
7+
68
# C extensions
79
*.so
810

.idea/PySysLogQt.iml

Lines changed: 0 additions & 11 deletions
This file was deleted.

.idea/inspectionProfiles/profiles_settings.xml

Lines changed: 0 additions & 6 deletions
This file was deleted.

.idea/misc.xml

Lines changed: 0 additions & 7 deletions
This file was deleted.

.idea/modules.xml

Lines changed: 0 additions & 8 deletions
This file was deleted.

.idea/workspace.xml

Lines changed: 0 additions & 146 deletions
This file was deleted.

README.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,26 @@
11
# PySysLogQt
22
Simple `syslog` viewer written in `Python 3`.
33

4-
**Note: It is nothing too fancy at this point in time. Currently, there are no intentions of making this too fancy. Features may be requested in the _Issues_ page.**
4+
**Note: It is nothing too fancy at this point in time. Currently, there are
5+
no intentions of making this too fancy. Features may be requested in the
6+
_Issues_ page.**
57

6-
## Run from Source:
8+
## Execution
9+
### Run from Source
710
Make sure you have `Python 3` and `PyQt5` installed.
811
In the root directory, execute
912
```bash
1013
python3 __main__.py
1114
```
15+
16+
### Run from Executable
17+
For Linux-systems, an executable is bundled for simplicity of use. This file
18+
is located in the `dist` folder, or can be downloaded from the latest version.
19+
20+
## Allow all Ports
21+
By default, all ports below 1024 (with the exception of port 0) require root
22+
access. Execute the application as such to be able to capture all those
23+
messages.
24+
25+
Capturing on port 0 is disallowed, since it commonly indicates "_choose any
26+
valid port_".

install.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pyinstaller -n PySysLogQt --onefile --windowed __main__.py

main/MainWindow.py

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,8 @@ def handle(self):
6666
match = re.search(r"^<\d+>", data)
6767
prio = int(match.group(0)[1:-1])
6868

69-
socket = self.request[1]
70-
f = socket.fileno()
71-
level = self.levels[prio ^ (f << 3)]
69+
f = prio // 8
70+
level = self.levels[prio % 8]
7271

7372
global TABLE
7473
row = TABLE.rowCount()
@@ -113,17 +112,32 @@ def searchTable(self, text):
113112
def change(self):
114113
self.end()
115114

116-
dialog = ServerDialog()
117-
dialog.exec_()
118-
self.host.setText(dialog.host.text())
119-
self.port.setValue(dialog.port.value())
115+
def accept():
116+
self.host.setText(dialog.host.text())
117+
self.port.setValue(dialog.port.value())
118+
self.start()
119+
120+
def reject():
121+
self.deleteLater()
120122

121-
self.start()
123+
dialog = ServerDialog(self)
124+
dialog.accepted.connect(accept)
125+
dialog.rejected.connect(reject)
126+
dialog.exec_()
122127

123128
def start(self):
124-
# TODO: catch "address already in use"
125-
self.server = socketserver.UDPServer((self.host.text(), self.port.value()), SyslogUDPHandler)
126-
self.thread.start()
129+
try:
130+
self.server = socketserver.UDPServer((self.host.text(), self.port.value()), SyslogUDPHandler)
131+
self.thread.start()
132+
return
133+
except PermissionError as e:
134+
QtWidgets.QMessageBox.warning(self, str(e), "You don't have permission to listen on this port.\n"
135+
"The ports below 1024 require root access.")
136+
except OSError as e:
137+
QtWidgets.QMessageBox.warning(self, str(e), "The address '%s:%i' is already in use." %
138+
(self.host.text(), self.port.value()))
139+
140+
self.change()
127141

128142
def run(self):
129143
# print("STARTED")

main/MainWindow.ui

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
<bool>false</bool>
114114
</property>
115115
<property name="minimum">
116-
<number>1024</number>
116+
<number>0</number>
117117
</property>
118118
<property name="maximum">
119119
<number>65535</number>

0 commit comments

Comments
 (0)