mirror of
https://github.com/evilsocket/opensnitch.git
synced 2025-03-03 16:14:40 +01:00
ui: allow to use multiple protobuffer versions
Protobuffers compiled with protobuf < 3.20.0 are incompatible with protobuf >= 4.0.0: https://github.com/evilsocket/opensnitch/wiki/GUI-known-problems#gui-does-not-show-up This has been a source of problems for some users (#1214, #647), and in some distributions, previous protobuffer does no longer work due to incompatibility with the protobuf package version installed (OpenSuse Tumbleweed). So in order to solve this issue, we provide several protobuffers, for old and new protobuf versions: proto/ui_pb2* for protobuf >= 4.0.0 proto/pre3200/ui_pb2* for protobuf >= 3.6.0 and < 3.20.0 To avoid import errors, each protobuffer must be placed in its own directory, and the name of the protobuffer files must be named with the syntax <prefix>_pb2.py/<prefix>_pb2_grpc.py: ui_pb2.py and ui_pb2_grpc.py The default compiled protobuffer will be opensnitch/proto/ui_*.py instead of opensnitch/ui_*.py
This commit is contained in:
parent
24a5105d77
commit
5dd4ef06bb
20 changed files with 50 additions and 34 deletions
|
@ -4,9 +4,9 @@ all: ../daemon/ui/protocol/ui.pb.go ../ui/opensnitch/ui_pb2.py
|
|||
protoc -I. ui.proto --go_out=../daemon/ui/protocol/ --go-grpc_out=../daemon/ui/protocol/ --go_opt=paths=source_relative --go-grpc_opt=paths=source_relative
|
||||
|
||||
../ui/opensnitch/ui_pb2.py: ui.proto
|
||||
python3 -m grpc_tools.protoc -I. --python_out=../ui/opensnitch/ --grpc_python_out=../ui/opensnitch/ ui.proto
|
||||
python3 -m grpc_tools.protoc -I. --python_out=../ui/opensnitch/proto/ --grpc_python_out=../ui/opensnitch/proto/ ui.proto
|
||||
|
||||
clean:
|
||||
@rm -rf ../daemon/ui/protocol/ui.pb.go
|
||||
@rm -rf ../ui/opensnitch/ui_pb2.py
|
||||
@rm -rf ../ui/opensnitch/ui_pb2_grpc.py
|
||||
@rm -rf ../ui/opensnitch/proto/ui_pb2.py
|
||||
@rm -rf ../ui/opensnitch/proto/ui_pb2_grpc.py
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
recursive-include opensnitch/proto *
|
||||
recursive-include opensnitch/res *
|
||||
recursive-include opensnitch/i18n *.qm
|
||||
recursive-include opensnitch/database/migrations *.sql
|
||||
|
|
|
@ -5,7 +5,7 @@ install:
|
|||
|
||||
opensnitch/resources_rc.py: translations deps
|
||||
@pyrcc5 -o opensnitch/resources_rc.py opensnitch/res/resources.qrc
|
||||
sed -i 's/^import ui_pb2/from . import ui_pb2/' opensnitch/ui_pb2*
|
||||
@find opensnitch/proto/ -name 'ui_pb2_grpc.py' -exec sed -i 's/^import ui_pb2/from . import ui_pb2/' {} \;
|
||||
|
||||
translations:
|
||||
@cd i18n ; make
|
||||
|
|
|
@ -42,9 +42,11 @@ from opensnitch.service import UIService
|
|||
from opensnitch.config import Config
|
||||
from opensnitch.utils import Themes, Utils, Versions, Message
|
||||
from opensnitch.utils.xdg import xdg_opensnitch_dir, xdg_current_session
|
||||
from opensnitch.ui_pb2_grpc import add_UIServicer_to_server
|
||||
from opensnitch import auth
|
||||
|
||||
import opensnitch.proto as proto
|
||||
ui_pb2, ui_pb2_grpc = proto.import_()
|
||||
|
||||
app_id = os.path.join(xdg_opensnitch_dir, "io.github.evilsocket.opensnitch")
|
||||
|
||||
def on_exit():
|
||||
|
@ -202,7 +204,7 @@ Examples:
|
|||
('grpc.max_receive_message_length', maxmsglen),
|
||||
))
|
||||
|
||||
add_UIServicer_to_server(service, server)
|
||||
ui_pb2_grpc.add_UIServicer_to_server(service, server)
|
||||
|
||||
auth_type = auth.Simple
|
||||
if args.socket_auth != None:
|
||||
|
|
|
@ -11,10 +11,11 @@ from opensnitch.utils import Icons, Message
|
|||
from opensnitch.config import Config
|
||||
from opensnitch.nodes import Nodes
|
||||
from opensnitch.dialogs.firewall_rule import FwRuleDialog
|
||||
from opensnitch import ui_pb2
|
||||
import opensnitch.firewall as Fw
|
||||
import opensnitch.firewall.profiles as FwProfiles
|
||||
|
||||
import opensnitch.proto as proto
|
||||
ui_pb2, ui_pb2_grpc = proto.import_()
|
||||
|
||||
DIALOG_UI_PATH = "%s/../res/firewall.ui" % os.path.dirname(sys.modules[__name__].__file__)
|
||||
class FirewallDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]):
|
||||
|
|
|
@ -9,10 +9,11 @@ from PyQt5.QtCore import QCoreApplication as QC
|
|||
from opensnitch.config import Config
|
||||
from opensnitch.nodes import Nodes
|
||||
from opensnitch.utils import NetworkServices, NetworkInterfaces, QuickHelp, Icons, Utils
|
||||
from opensnitch import ui_pb2
|
||||
import opensnitch.firewall as Fw
|
||||
from opensnitch.firewall.utils import Utils as FwUtils
|
||||
|
||||
import opensnitch.proto as proto
|
||||
ui_pb2, ui_pb2_grpc = proto.import_()
|
||||
|
||||
DIALOG_UI_PATH = "%s/../res/firewall_rule.ui" % os.path.dirname(sys.modules[__name__].__file__)
|
||||
class FwRuleDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]):
|
||||
|
|
|
@ -15,7 +15,9 @@ from opensnitch.utils.xdg import Autostart
|
|||
from opensnitch.notifications import DesktopNotifications
|
||||
from opensnitch.rules import DefaultRulesPath
|
||||
|
||||
from opensnitch import ui_pb2, auth
|
||||
from opensnitch import auth
|
||||
import opensnitch.proto as proto
|
||||
ui_pb2, ui_pb2_grpc = proto.import_()
|
||||
|
||||
DIALOG_UI_PATH = "%s/../res/preferences.ui" % os.path.dirname(sys.modules[__name__].__file__)
|
||||
class PreferencesDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]):
|
||||
|
|
|
@ -5,7 +5,9 @@ import re
|
|||
|
||||
from PyQt5 import QtCore, QtGui, uic, QtWidgets
|
||||
|
||||
from opensnitch import ui_pb2
|
||||
import opensnitch.proto as proto
|
||||
ui_pb2, ui_pb2_grpc = proto.import_()
|
||||
|
||||
from opensnitch.nodes import Nodes
|
||||
from opensnitch.desktop_parser import LinuxDesktopParser
|
||||
from opensnitch.utils import Message, Icons
|
||||
|
|
|
@ -22,8 +22,9 @@ from opensnitch.plugins import PluginBase
|
|||
from opensnitch.rules import Rules, Rule
|
||||
from opensnitch.nodes import Nodes
|
||||
|
||||
from opensnitch import ui_pb2
|
||||
from opensnitch.dialogs.prompt import _utils, _constants, _checksums, _details
|
||||
import opensnitch.proto as proto
|
||||
ui_pb2, ui_pb2_grpc = proto.import_()
|
||||
|
||||
from network_aliases import NetworkAliases
|
||||
|
||||
|
@ -589,7 +590,7 @@ class PromptDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]):
|
|||
self._rule.operator.type, self._rule.operator.operand, self._rule.operator.data = _utils.get_combo_operator(
|
||||
self.whatCombo.itemData(what_idx),
|
||||
self.whatCombo.currentText(),
|
||||
self._con)
|
||||
self._con)
|
||||
if self._rule.operator.data == "":
|
||||
print("popups: Invalid rule, discarding: ", self._rule)
|
||||
self._rule = None
|
||||
|
|
|
@ -7,10 +7,12 @@ import re
|
|||
import sys
|
||||
import os
|
||||
import pwd
|
||||
from opensnitch import ui_pb2
|
||||
import time
|
||||
import ipaddress
|
||||
|
||||
import opensnitch.proto as proto
|
||||
ui_pb2, ui_pb2_grpc = proto.import_()
|
||||
|
||||
from opensnitch.config import Config
|
||||
from opensnitch.nodes import Nodes
|
||||
from opensnitch.database import Database
|
||||
|
|
|
@ -9,7 +9,6 @@ import json
|
|||
from PyQt5 import QtCore, QtGui, uic, QtWidgets
|
||||
from PyQt5.QtCore import QCoreApplication as QC
|
||||
|
||||
from opensnitch import ui_pb2
|
||||
from opensnitch.config import Config
|
||||
from opensnitch.version import version
|
||||
from opensnitch.nodes import Nodes
|
||||
|
@ -32,6 +31,9 @@ from opensnitch.actions import Actions
|
|||
from opensnitch.plugins import PluginBase
|
||||
from opensnitch.rules import Rule, Rules
|
||||
|
||||
import opensnitch.proto as proto
|
||||
ui_pb2, ui_pb2_grpc = proto.import_()
|
||||
|
||||
DIALOG_UI_PATH = "%s/../res/stats.ui" % os.path.dirname(sys.modules[__name__].__file__)
|
||||
class StatsDialog(QtWidgets.QDialog, uic.loadUiType(DIALOG_UI_PATH)[0]):
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
from PyQt5.QtCore import QObject, QCoreApplication as QC
|
||||
from google.protobuf import json_format
|
||||
from opensnitch import ui_pb2
|
||||
|
||||
import opensnitch.proto as proto
|
||||
ui_pb2, ui_pb2_grpc = proto.import_()
|
||||
|
||||
from opensnitch.nodes import Nodes
|
||||
from .enums import *
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
from opensnitch import ui_pb2
|
||||
from .enums import *
|
||||
|
||||
import opensnitch.proto as proto
|
||||
ui_pb2, ui_pb2_grpc = proto.import_()
|
||||
|
||||
class Chains():
|
||||
|
||||
def __init__(self, nodes):
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
|
||||
from opensnitch import ui_pb2
|
||||
from .enums import *
|
||||
|
||||
import opensnitch.proto as proto
|
||||
ui_pb2, ui_pb2_grpc = proto.import_()
|
||||
|
||||
class Expr():
|
||||
"""
|
||||
Expr returns a new nftables expression that defines a match or an action:
|
||||
|
|
|
@ -3,10 +3,12 @@ from PyQt5.QtCore import QCoreApplication as QC
|
|||
from google.protobuf.json_format import MessageToJson
|
||||
import uuid
|
||||
|
||||
from opensnitch import ui_pb2
|
||||
from .enums import Operator
|
||||
from .exprs import ExprLog
|
||||
|
||||
import opensnitch.proto as proto
|
||||
ui_pb2, ui_pb2_grpc = proto.import_()
|
||||
|
||||
class Rules(QObject):
|
||||
rulesUpdated = pyqtSignal()
|
||||
|
||||
|
|
|
@ -4,12 +4,14 @@ from datetime import datetime
|
|||
import time
|
||||
import json
|
||||
|
||||
from opensnitch import ui_pb2
|
||||
from opensnitch.database import Database
|
||||
from opensnitch.config import Config
|
||||
from opensnitch.utils import NetworkInterfaces
|
||||
from opensnitch.rules import Rules
|
||||
|
||||
import opensnitch.proto as proto
|
||||
ui_pb2, ui_pb2_grpc = proto.import_()
|
||||
|
||||
class Nodes(QObject):
|
||||
__instance = None
|
||||
nodesUpdated = pyqtSignal(int) # total
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
from PyQt5.QtCore import QObject, pyqtSignal
|
||||
|
||||
from opensnitch import ui_pb2
|
||||
from opensnitch.database import Database
|
||||
from opensnitch.database.enums import RuleFields
|
||||
from opensnitch.config import Config
|
||||
|
||||
import opensnitch.proto as proto
|
||||
ui_pb2, ui_pb2_grpc = proto.import_()
|
||||
|
||||
import os
|
||||
import json
|
||||
from slugify import slugify
|
||||
|
|
|
@ -12,8 +12,8 @@ import copy
|
|||
path = os.path.abspath(os.path.dirname(__file__))
|
||||
sys.path.append(path)
|
||||
|
||||
from opensnitch import ui_pb2
|
||||
from opensnitch import ui_pb2_grpc
|
||||
import opensnitch.proto as proto
|
||||
ui_pb2, ui_pb2_grpc = proto.import_()
|
||||
|
||||
from opensnitch.dialogs.prompt import PromptDialog
|
||||
from opensnitch.dialogs.stats import StatsDialog
|
||||
|
|
|
@ -13,25 +13,15 @@ override_dh_auto_clean:
|
|||
python3 setup.py clean -a
|
||||
find . -name \*.pyc -exec rm {} \;
|
||||
|
||||
|
||||
|
||||
override_dh_auto_build:
|
||||
python3 setup.py build --force
|
||||
|
||||
|
||||
|
||||
override_dh_auto_install:
|
||||
cd i18n; make
|
||||
cp -r i18n/locales/ opensnitch/i18n/
|
||||
pyrcc5 -o opensnitch/resources_rc.py opensnitch/res/resources.qrc
|
||||
sed -i 's/^import ui_pb2/from . import ui_pb2/' opensnitch/ui_pb2*
|
||||
find opensnitch/proto/ -name 'ui_pb2_grpc.py' -exec sed -i 's/^import ui_pb2/from . import ui_pb2/' {} \;
|
||||
python3 setup.py install --force --root=debian/python3-opensnitch-ui --no-compile -O0 --install-layout=deb
|
||||
|
||||
|
||||
|
||||
override_dh_python2:
|
||||
dh_python2 --no-guessing-versions
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ fi
|
|||
cd i18n; make; cd ..
|
||||
cp -r i18n/locales/ opensnitch/i18n
|
||||
pyrcc5 -o opensnitch/resources_rc.py opensnitch/res/resources.qrc
|
||||
sed -i 's/^import ui_pb2/from . import ui_pb2/' opensnitch/ui_pb2*
|
||||
find opensnitch/proto/ -name 'ui_pb2_grpc.py' -exec sed -i 's/^import ui_pb2/from . import ui_pb2/' {} \;
|
||||
python3 setup.py build
|
||||
|
||||
%install
|
||||
|
|
Loading…
Add table
Reference in a new issue