From 765125d29e03fc4e10b322933b33117c1e88711c Mon Sep 17 00:00:00 2001 From: TheMythologist Date: Sun, 29 Jan 2023 13:18:22 +0800 Subject: [PATCH 1/5] refactor: move debug_logger into DebugSession --- src/network/sessions.py | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/network/sessions.py b/src/network/sessions.py index 737ec7c..ad7295c 100644 --- a/src/network/sessions.py +++ b/src/network/sessions.py @@ -13,18 +13,6 @@ logger = logging.getLogger("guardian") -debug_logger = logging.getLogger("debugger") -debug_logger.setLevel(logging.DEBUG) -if not debug_logger.handlers: - fh = logging.FileHandler("debugger.log") - fh.setLevel(logging.DEBUG) - fh.setFormatter( - logging.Formatter( - "[%(asctime)s][%(levelname)s] %(message)s", datefmt="%Y-%m-%d %H:%M:%S" - ) - ) - debug_logger.addHandler(fh) - # It appears that there is *ONE* more problem we may need to take care of which was missed during testing of the prototype. # Apparently, it's not only R* tunnels, but also client tunnels! If the circumstances are right, then it turns out that # people in your session can also tunnel players if they could not connect to you directly. Such is the joy of P2P @@ -275,6 +263,22 @@ def __init__(self, ips: set[str], priority: int): self.priority = priority self.process = multiprocessing.Process(target=self.run) self.process.daemon = True + self.init_debugging_log() + + def init_debugging_log(self) -> None: + debug_logger = logging.getLogger("debugger") + debug_logger.setLevel(logging.DEBUG) + if not debug_logger.handlers: + fh = logging.FileHandler("debugger.log") + fh.setLevel(logging.DEBUG) + fh.setFormatter( + logging.Formatter( + "[%(asctime)s][%(levelname)s] %(message)s", + datefmt="%Y-%m-%d %H:%M:%S", + ) + ) + debug_logger.addHandler(fh) + self.logger = debug_logger def start(self) -> None: self.process.start() @@ -283,7 +287,7 @@ def stop(self) -> None: self.process.terminate() def run(self) -> None: - debug_logger.debug("Started debugging") + self.logger.debug("Started debugging") with pydivert.WinDivert( PACKET_FILTER, priority=self.priority, flags=pydivert.Flag.SNIFF ) as w: @@ -320,7 +324,7 @@ def run(self) -> None: log = f"[{filler}] {src}:{packet.src_port} --> {dst}:{packet.dst_port}" else: log = f"[{filler}] {src}:{packet.src_port} <-- {dst}:{packet.dst_port}" - debug_logger.debug(log) + self.logger.debug(log) # Okay, so there's a couple of changes that need to be done to fix auto-whitelisting. From 5a4ad4f42d51379256aff2664fb8e4b4cc24ec44 Mon Sep 17 00:00:00 2001 From: TheMythologist Date: Sun, 29 Jan 2023 18:28:11 +0800 Subject: [PATCH 2/5] deps: remove cx-freeze and add pyinstaller --- poetry.lock | 265 ++++++++++++++++++++----------------------------- pyproject.toml | 4 +- 2 files changed, 111 insertions(+), 158 deletions(-) diff --git a/poetry.lock b/poetry.lock index c2802b2..f236990 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,5 +1,17 @@ # This file is automatically @generated by Poetry and should not be changed by hand. +[[package]] +name = "altgraph" +version = "0.17.3" +description = "Python graph (network) package" +category = "main" +optional = false +python-versions = "*" +files = [ + {file = "altgraph-0.17.3-py2.py3-none-any.whl", hash = "sha256:c8ac1ca6772207179ed8003ce7687757c04b0b71536f81e2ac5755c6226458fe"}, + {file = "altgraph-0.17.3.tar.gz", hash = "sha256:ad33358114df7c9416cdb8fa1eaa5852166c505118717021c6a8c7c7abbd03dd"}, +] + [[package]] name = "attrs" version = "22.2.0" @@ -203,100 +215,6 @@ files = [ {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, ] -[[package]] -name = "cx-freeze" -version = "6.14.1" -description = "Create standalone executables from Python scripts" -category = "main" -optional = false -python-versions = ">=3.7.4" -files = [ - {file = "cx_Freeze-6.14.1-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:043556edd8a0a68832237c99bb1ee18058eef59df5e66d9e88de802ef64b79d1"}, - {file = "cx_Freeze-6.14.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:d50a18704d8962fd131c09c8dd254b6e9b67ce9995810e2dd76f08a08a662716"}, - {file = "cx_Freeze-6.14.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:686e99bd75a70ecacff9e24491d5c8ba3f1b3973268dbda61528e9b0e2a4877c"}, - {file = "cx_Freeze-6.14.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:bb92977b9917f35bf85ee0c7c7bd96b7f66d08b18b6f024a4de41ee0699876e2"}, - {file = "cx_Freeze-6.14.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:aa4debdc1c8d387b7a2ea53c68a71239282e44a6ff4290e68b00e7e4bbd8afbb"}, - {file = "cx_Freeze-6.14.1-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:c272e71d1321f3a4a65b6bb3233778d23b41a9f0a2f74ab96f1ebc189c9ed986"}, - {file = "cx_Freeze-6.14.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:87c917cccc81bd7a5f3c8aac13db30c9358cc068f974f5461500dfb2fa565ed4"}, - {file = "cx_Freeze-6.14.1-cp310-cp310-win32.whl", hash = "sha256:e2eb830371ae8bb6bc2a199e1a674ad44e79771aecdacd00d038e4d5bea57951"}, - {file = "cx_Freeze-6.14.1-cp310-cp310-win_amd64.whl", hash = "sha256:893fdddb551cf0684861286f8755c4dc7eaaf3e5c8f3487a090903d8ff138100"}, - {file = "cx_Freeze-6.14.1-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:ab5e194b455a686d1ea456740e049462aed2bbb674cfd93cebd56e1a1f9a2a4c"}, - {file = "cx_Freeze-6.14.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:7e16a7e3e6937d7cc8600c980c5fb97ef3c6fface102d0e3b024686393e07c38"}, - {file = "cx_Freeze-6.14.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:6c930d511f3f0ad1ed19bc2ea1d9447d5808c301e0fb6a3fc6cdc886cc6f890c"}, - {file = "cx_Freeze-6.14.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d6821ee5f1120d2056d9cb16e211517ba1539b5ed62bb431f01ef1315a394771"}, - {file = "cx_Freeze-6.14.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e706341d9ff41313c7b99b01c9f5e51ec3721072f3d5b71bdf676a29b451f50b"}, - {file = "cx_Freeze-6.14.1-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:f32ce5973f997541439a8de3cb36a40d0648b125938a45f7dcf78ebbd3966bef"}, - {file = "cx_Freeze-6.14.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:340d26b04f63ffcf8567e38eea76bf273d07b2e4ae12d05837c28703cb29c9d4"}, - {file = "cx_Freeze-6.14.1-cp311-cp311-win32.whl", hash = "sha256:4b8f24294999d87a008c6f06535d1bd80c868c8a53b68787c3f12a1e41c4fa74"}, - {file = "cx_Freeze-6.14.1-cp311-cp311-win_amd64.whl", hash = "sha256:8effee1d0b67e00ad2943dd2fe2878d88d2da4817e41bcf08d16bf0d6810bb06"}, - {file = "cx_Freeze-6.14.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:239b5e74524a1726f3dc8b52a41b959ab2bec972ddefac518cc327699e341d1e"}, - {file = "cx_Freeze-6.14.1-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:454f0f896534f6c5d4c9412f167b457b2734929aa0c7f428e9b624049b089507"}, - {file = "cx_Freeze-6.14.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b535f5f30c5d08a9a29ec882305c444f1aff394cf69ad0283b9c5630e30d7f85"}, - {file = "cx_Freeze-6.14.1-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:87cc2ac7d8c879f1fa29ecc38b0d1ffab0a663ee844e02229666e7cba53adc68"}, - {file = "cx_Freeze-6.14.1-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:fa1f2e91176cbd8597b0912b5394c8a29c0183cb188dc6c6b79984e7a5f249f7"}, - {file = "cx_Freeze-6.14.1-cp37-cp37m-win32.whl", hash = "sha256:55dff247bd0d6175f47deb35727bc44e63683c1dd531ec82910ba7c95dc1324f"}, - {file = "cx_Freeze-6.14.1-cp37-cp37m-win_amd64.whl", hash = "sha256:215b40db234dd07dfabe800dd5361ec0e89e8103de5e8110683b836508a292c8"}, - {file = "cx_Freeze-6.14.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:2d3d24bbb99e45ebe7410e23eec2f46c92bce5bee02fccd98b8096e17d1d07b3"}, - {file = "cx_Freeze-6.14.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4e5e85c3e6b5c4dd2c3ffcf588c5cf8cf3da6ded07f221c94f207062dc2cdb6f"}, - {file = "cx_Freeze-6.14.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6f499cff29b8b65acf54aea4b6040b0adae99e7a68dc4af7c3cccbb4342b6937"}, - {file = "cx_Freeze-6.14.1-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:41f5a9d0554b97b545ae8efaa1010ad099b5b35ba1e5b3625a49b594c48d916a"}, - {file = "cx_Freeze-6.14.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:a947223198a7abdfff28a830b65269f52265290146657f21fd5d60dbe2f0622b"}, - {file = "cx_Freeze-6.14.1-cp38-cp38-win32.whl", hash = "sha256:ef87d2bf4e1fe299e35110a1c437943f640cd0970c4a087ece2b8b2ae9505848"}, - {file = "cx_Freeze-6.14.1-cp38-cp38-win_amd64.whl", hash = "sha256:be3e49beed269a861b14091e08ce8e96c88a6d08b91c7ae8cdae0034d83b82e3"}, - {file = "cx_Freeze-6.14.1-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:b9d313f290ae44e86567c09a31f533ef4d99e32f37b510037b05b37585cadf5e"}, - {file = "cx_Freeze-6.14.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:e4e5f11f6747d59d76a437fed1c5437b16abba3a3ebff503e04368306af30ed8"}, - {file = "cx_Freeze-6.14.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:b7bce6d10f57bc6fd78738659b8b5d6eea44d30d5c7457ae152a06b905b28ae8"}, - {file = "cx_Freeze-6.14.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:56e459bc0307bba7ee136299315cf4deb67e3be984dab0419f5d2b9b558b16d7"}, - {file = "cx_Freeze-6.14.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c4459d348f8474e65dc34de7aefda2400e5c66b2a16d22cc78ab83e2aefd01c5"}, - {file = "cx_Freeze-6.14.1-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:53543d5c59511fb91603ddb1a70f3167ac5132cec630c879bf4808b30c26da75"}, - {file = "cx_Freeze-6.14.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:3b49891a06d02d11361932e844e07fea2e8373a3b8c33b58b851e440a57d6bb7"}, - {file = "cx_Freeze-6.14.1-cp39-cp39-win32.whl", hash = "sha256:7f4ad9b76e1c351740d17d51f89706ff829f0f1b0f440ad4e17d0d6704a1e9a1"}, - {file = "cx_Freeze-6.14.1-cp39-cp39-win_amd64.whl", hash = "sha256:027b69a3d7871e2797f0782cd4a2abb6c2b370d326f696902d5ccd55d3c93455"}, - {file = "cx_Freeze-6.14.1.tar.gz", hash = "sha256:e620c61a57518d35033a85696501e0e24920401e2564923bcf034dc3b9c259ca"}, -] - -[package.dependencies] -cx-Logging = {version = ">=3.1", markers = "sys_platform == \"win32\""} -lief = {version = ">=0.12.0", markers = "sys_platform == \"win32\""} -patchelf = {version = ">=0.14", markers = "sys_platform == \"linux\" and platform_machine == \"aarch64\" or sys_platform == \"linux\" and platform_machine == \"i686\" or sys_platform == \"linux\" and platform_machine == \"ppc64le\" or sys_platform == \"linux\" and platform_machine == \"s390x\" or sys_platform == \"linux\" and platform_machine == \"x86_64\""} -setuptools = ">=61.2,<67" - -[package.extras] -dev = ["bump2version (>=1.0.1)", "cibuildwheel (>=2.11.2)", "pre-commit (>=2.20.0)", "pylint (>=2.15.4)", "wheel (>=0.37.1)"] -doc = ["furo", "sphinx (==5.3.0)", "sphinx-tabs"] -test = ["nose (==1.3.7)", "pygments (>=2.13.0)", "pytest (>=7.1.3)", "pytest-cov (>=4.0.0)", "pytest-mock (>=3.10.0)", "pytest-timeout (>=2.1.0)"] - -[[package]] -name = "cx-logging" -version = "3.1.0" -description = "Python and C interfaces for logging" -category = "main" -optional = false -python-versions = ">=3.7" -files = [ - {file = "cx_Logging-3.1.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9d6aee2d91d4abeafa8ae1a5cacdcc363031ab6e69a3c5b221b294f5b94b0830"}, - {file = "cx_Logging-3.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f7f2d686ca7347e14d248e4f57279b9340b305f86888806313111ab7964835f4"}, - {file = "cx_Logging-3.1.0-cp310-cp310-win32.whl", hash = "sha256:93ee6c9109d129f63344aa9da10dfc6c0d2ac3b2656599a4f884bf482c1fd2f6"}, - {file = "cx_Logging-3.1.0-cp310-cp310-win_amd64.whl", hash = "sha256:7d69b2986e53f8f14d6fcd1614472f378edf63eea6c71c04d42cb215f7012717"}, - {file = "cx_Logging-3.1.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4e16a66e8ce16b28a79c9dcf9bda2f36297bd552ec7d9a80cc70e19970d49460"}, - {file = "cx_Logging-3.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:564bea49c30342478ff2301c39a61c47c926e01146052b2a505ac11896ef51d2"}, - {file = "cx_Logging-3.1.0-cp311-cp311-win32.whl", hash = "sha256:cfd260cd431f2087cac2a9bfb738c2e428eb30e2b85ba0e0bce8dde2cb4843eb"}, - {file = "cx_Logging-3.1.0-cp311-cp311-win_amd64.whl", hash = "sha256:c61388bd9410817839187dab602f47d307f3f58df2dd11fb698cd321b8b48985"}, - {file = "cx_Logging-3.1.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1937991c2daab59ced3bf8f52b1052b0157c0c30f229aa87bd384ab18dc8d1f3"}, - {file = "cx_Logging-3.1.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8129e2d6bbff03fa7b09e9b587a5aed178fa16032508bae0f4db7e933fb43d08"}, - {file = "cx_Logging-3.1.0-cp37-cp37m-win32.whl", hash = "sha256:80aac0557464995780769535edf8057bab79a54cb4126363a7134b4ae38d25a3"}, - {file = "cx_Logging-3.1.0-cp37-cp37m-win_amd64.whl", hash = "sha256:ce9a37ab15890a87d144a7206c30d16192b67e63e8e52f02c579daa72a10767e"}, - {file = "cx_Logging-3.1.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8040a77b922eacd342d2dc0804a06425d772cf9cde61dd4c01e61aaaf9189f9f"}, - {file = "cx_Logging-3.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3accfa4ae945c3f65d7fc830058272e263b27e09672539d8dc2ed190a07be99e"}, - {file = "cx_Logging-3.1.0-cp38-cp38-win32.whl", hash = "sha256:ae6d01072625de14584e79af4aade249b3b7080e90a3df6b47ada72b0ecd8b79"}, - {file = "cx_Logging-3.1.0-cp38-cp38-win_amd64.whl", hash = "sha256:10fca1790e3467548472987e1a39379a96b93da09bdc1b64b3075605d473aaf6"}, - {file = "cx_Logging-3.1.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:78b82737e589d5805b044a64afa8d2782a388a42898af084c6ab76153bc531fb"}, - {file = "cx_Logging-3.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:82fc9cd57a4c151856759d76b9e44700913de60d6b97d661000577dad89f383b"}, - {file = "cx_Logging-3.1.0-cp39-cp39-win32.whl", hash = "sha256:a98781f59652c58b0648a835b5f5a9cfcdc90957283818d1babf98aed3a5e28f"}, - {file = "cx_Logging-3.1.0-cp39-cp39-win_amd64.whl", hash = "sha256:8a1548d8339baf54c7f1f372e68d381be7ce3e9506f2aa0987e88670a446a773"}, - {file = "cx_Logging-3.1.0.tar.gz", hash = "sha256:8a06834d8527aa904a68b25c9c1a5fa09f0dfdc94dbd9f86b81cd8d2f7a0e487"}, -] - [[package]] name = "distlib" version = "0.3.6" @@ -357,6 +275,17 @@ mccabe = ">=0.7.0,<0.8.0" pycodestyle = ">=2.10.0,<2.11.0" pyflakes = ">=3.0.0,<3.1.0" +[[package]] +name = "future" +version = "0.18.3" +description = "Clean single-source support for Python 3 and 2" +category = "main" +optional = false +python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" +files = [ + {file = "future-0.18.3.tar.gz", hash = "sha256:34a17436ed1e96697a86f9de3d15a3b0be01d8bc8de9c1dffd59fb8234ed5307"}, +] + [[package]] name = "identify" version = "2.5.16" @@ -415,49 +344,20 @@ plugins = ["setuptools"] requirements-deprecated-finder = ["pip-api", "pipreqs"] [[package]] -name = "lief" -version = "0.12.3" -description = "Library to instrument executable formats" +name = "macholib" +version = "1.16.2" +description = "Mach-O header analysis and editing" category = "main" optional = false -python-versions = ">=3.6" +python-versions = "*" files = [ - {file = "lief-0.12.3-cp310-cp310-macosx_10_14_arm64.whl", hash = "sha256:66724f337e6a36cea1a9380f13b59923f276c49ca837becae2e7be93a2e245d9"}, - {file = "lief-0.12.3-cp310-cp310-macosx_10_14_x86_64.whl", hash = "sha256:6d18aafa2028587c98f6d4387bec94346e92f2b5a8a5002f70b1cf35b1c045cc"}, - {file = "lief-0.12.3-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:d4f69d125caaa8d5ddb574f29cc83101e165ebea1a9f18ad042eb3544081a797"}, - {file = "lief-0.12.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c078d6230279ffd3bca717c79664fb8368666f610b577deb24b374607936e9c1"}, - {file = "lief-0.12.3-cp310-cp310-win32.whl", hash = "sha256:e3a6af926532d0aac9e7501946134513d63217bacba666e6f7f5a0b7e15ba236"}, - {file = "lief-0.12.3-cp310-cp310-win_amd64.whl", hash = "sha256:0750b72e3aa161e1fb0e2e7f571121ae05d2428aafd742ff05a7656ad2288447"}, - {file = "lief-0.12.3-cp311-cp311-macosx_10_14_arm64.whl", hash = "sha256:b5c123cb99a7879d754c059e299198b34e7e30e3b64cf22e8962013db0099f47"}, - {file = "lief-0.12.3-cp311-cp311-macosx_10_14_x86_64.whl", hash = "sha256:8bc58fa26a830df6178e36f112cb2bbdd65deff593f066d2d51434ff78386ba5"}, - {file = "lief-0.12.3-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:74ac6143ac6ccd813c9b068d9c5f1f9d55c8813c8b407387eb57de01c3db2d74"}, - {file = "lief-0.12.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:04eb6b70d646fb5bd6183575928ee23715550f161f2832cbcd8c6ff2071fb408"}, - {file = "lief-0.12.3-cp311-cp311-win32.whl", hash = "sha256:7e2d0a53c403769b04adcf8df92e83c5e25f9103a052aa7f17b0a9cf057735fb"}, - {file = "lief-0.12.3-cp311-cp311-win_amd64.whl", hash = "sha256:7f6395c12ee1bc4a5162f567cba96d0c72dfb660e7902e84d4f3029daf14fe33"}, - {file = "lief-0.12.3-cp36-cp36m-macosx_10_14_x86_64.whl", hash = "sha256:71327fdc764fd2b1f3cd371d8ac5e0b801bde32b71cfcf7dccee506d46768539"}, - {file = "lief-0.12.3-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d320fb80ed5b42b354b8e4f251ab05a51929c162c57c377b5e95ad4b1c1b415d"}, - {file = "lief-0.12.3-cp36-cp36m-win32.whl", hash = "sha256:176fa6c342dd480195cda34a20f62ac76dfae103b22ca7583b762e0b434ee1f3"}, - {file = "lief-0.12.3-cp36-cp36m-win_amd64.whl", hash = "sha256:3a18fe108fb82a2640864deef933731afe77413b1226551796ef2c373a1b3a2a"}, - {file = "lief-0.12.3-cp37-cp37m-macosx_10_14_x86_64.whl", hash = "sha256:c73e990cd2737d1060b8c1e8edcc128832806995b69d1d6bf191409e2cea7bde"}, - {file = "lief-0.12.3-cp37-cp37m-manylinux2014_aarch64.whl", hash = "sha256:5fa2b1c8ffe47ee66b2507c2bb4e3fd628965532b7888c0627d10e690b5ef20c"}, - {file = "lief-0.12.3-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5f224e9a261e88099f86160f121d088d30894c2946e3e551cf11c678daadcf2b"}, - {file = "lief-0.12.3-cp37-cp37m-win32.whl", hash = "sha256:3481d7c9fb3d3a1acff53851f40efd1a5a05d354312d367294bc2e310b736826"}, - {file = "lief-0.12.3-cp37-cp37m-win_amd64.whl", hash = "sha256:4e5173e1be5ebf43594f4eb187cbcb04758761942bc0a1e685ea1cb9047dc0d9"}, - {file = "lief-0.12.3-cp38-cp38-macosx_10_14_x86_64.whl", hash = "sha256:54d6a45e01260b9c8bf1c99f58257cff5338aee5c02eacfeee789f9d15cf38c6"}, - {file = "lief-0.12.3-cp38-cp38-manylinux2014_aarch64.whl", hash = "sha256:4501dc399fb15dc7a3c8df4a76264a86be6d581d99098dafc3a67626149d8ff1"}, - {file = "lief-0.12.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c848aadac0816268aeb9dde7cefdb54bf24f78e664a19e97e74c92d3be1bb147"}, - {file = "lief-0.12.3-cp38-cp38-win32.whl", hash = "sha256:d7e35f9ee9dd6e79add3b343f83659b71c05189e5cb224e02a1902ddc7654e96"}, - {file = "lief-0.12.3-cp38-cp38-win_amd64.whl", hash = "sha256:b00667257b43e93d94166c959055b6147d46d302598f3ee55c194b40414c89cc"}, - {file = "lief-0.12.3-cp39-cp39-macosx_10_14_arm64.whl", hash = "sha256:e6a1b5b389090d524621c2455795e1262f62dc9381bedd96f0cd72b878c4066d"}, - {file = "lief-0.12.3-cp39-cp39-macosx_10_14_x86_64.whl", hash = "sha256:ae773196df814202c0c51056163a1478941b299512b09660a3c37be3c7fac81e"}, - {file = "lief-0.12.3-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:66ddf88917ec7b00752687c476bb2771dc8ec19bd7e4c0dcff1f8ef774cad4e9"}, - {file = "lief-0.12.3-cp39-cp39-manylinux2014_aarch64.whl", hash = "sha256:4a47f410032c63ac3be051d963d0337d6b47f0e94bfe8e946ab4b6c428f4d0f8"}, - {file = "lief-0.12.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:dbd11367c2259bd1131a6c8755dcde33314324de5ea029227bfbc7d3755871e6"}, - {file = "lief-0.12.3-cp39-cp39-win32.whl", hash = "sha256:2ce53e311918c3e5b54c815ef420a747208d2a88200c41cd476f3dd1eb876bcf"}, - {file = "lief-0.12.3-cp39-cp39-win_amd64.whl", hash = "sha256:446e53ccf0ebd1616c5d573470662ff71ca6df3cd62ec1764e303764f3f03cca"}, - {file = "lief-0.12.3.zip", hash = "sha256:62e81d2f1a827d43152aed12446a604627e8833493a51dca027026eed0ce7128"}, + {file = "macholib-1.16.2-py2.py3-none-any.whl", hash = "sha256:44c40f2cd7d6726af8fa6fe22549178d3a4dfecc35a9cd15ea916d9c83a688e0"}, + {file = "macholib-1.16.2.tar.gz", hash = "sha256:557bbfa1bb255c20e9abafe7ed6cd8046b48d9525db2f9b77d3122a63a2a8bf8"}, ] +[package.dependencies] +altgraph = ">=0.17" + [[package]] name = "mccabe" version = "0.7.0" @@ -560,25 +460,6 @@ files = [ {file = "packaging-23.0.tar.gz", hash = "sha256:b6ad297f8907de0fa2fe1ccbd26fdaf387f5f47c7275fedf8cce89f99446cf97"}, ] -[[package]] -name = "patchelf" -version = "0.17.2.0" -description = "A small utility to modify the dynamic linker and RPATH of ELF executables." -category = "main" -optional = false -python-versions = "*" -files = [ - {file = "patchelf-0.17.2.0-py2.py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.musllinux_1_1_aarch64.whl", hash = "sha256:b8d86f32e1414d6964d5d166ddd2cf829d156fba0d28d32a3bd0192f987f4529"}, - {file = "patchelf-0.17.2.0-py2.py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.musllinux_1_1_ppc64le.whl", hash = "sha256:9233a0f2fc73820c5bd468f27507bdf0c9ac543f07c7f9888bb7cf910b1be22f"}, - {file = "patchelf-0.17.2.0-py2.py3-none-manylinux_2_17_s390x.manylinux2014_s390x.musllinux_1_1_s390x.whl", hash = "sha256:6601d7d831508bcdd3d8ebfa6435c2379bf11e41af2409ae7b88de572926841c"}, - {file = "patchelf-0.17.2.0-py2.py3-none-manylinux_2_5_i686.manylinux1_i686.musllinux_1_1_i686.whl", hash = "sha256:c62a34f0c25e6c2d6ae44389f819a00ccdf3f292ad1b814fbe1cc23cb27023ce"}, - {file = "patchelf-0.17.2.0-py2.py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.musllinux_1_1_x86_64.whl", hash = "sha256:1b9fd14f300341dc020ae05c49274dd1fa6727eabb4e61dd7fb6fb3600acd26e"}, - {file = "patchelf-0.17.2.0.tar.gz", hash = "sha256:dedf987a83d7f6d6f5512269e57f5feeec36719bd59567173b6d9beabe019efe"}, -] - -[package.extras] -test = ["importlib-metadata", "pytest"] - [[package]] name = "pathspec" version = "0.11.0" @@ -591,6 +472,20 @@ files = [ {file = "pathspec-0.11.0.tar.gz", hash = "sha256:64d338d4e0914e91c1792321e6907b5a593f1ab1851de7fc269557a21b30ebbc"}, ] +[[package]] +name = "pefile" +version = "2022.5.30" +description = "Python PE parsing module" +category = "main" +optional = false +python-versions = ">=3.6.0" +files = [ + {file = "pefile-2022.5.30.tar.gz", hash = "sha256:a5488a3dd1fd021ce33f969780b88fe0f7eebb76eb20996d7318f307612a045b"}, +] + +[package.dependencies] +future = "*" + [[package]] name = "platformdirs" version = "2.6.2" @@ -718,6 +613,52 @@ files = [ {file = "pyflakes-3.0.1.tar.gz", hash = "sha256:ec8b276a6b60bd80defed25add7e439881c19e64850afd9b346283d4165fd0fd"}, ] +[[package]] +name = "pyinstaller" +version = "5.7.0" +description = "PyInstaller bundles a Python application and all its dependencies into a single package." +category = "main" +optional = false +python-versions = "<3.12,>=3.7" +files = [ + {file = "pyinstaller-5.7.0-py3-none-macosx_10_13_universal2.whl", hash = "sha256:b967ae71ab7b05e18608dbb4518da5afa54f0835927cb7a5ce52ab8fffed03b6"}, + {file = "pyinstaller-5.7.0-py3-none-manylinux2014_aarch64.whl", hash = "sha256:3180b9bf22263380adc5e2ee051b7c21463292877215bbe70c9155dc76f4b966"}, + {file = "pyinstaller-5.7.0-py3-none-manylinux2014_i686.whl", hash = "sha256:0f80e2403e76630ad3392c71f09c1a4284e8d8a8a99fb55ff3a0aba0e06300ed"}, + {file = "pyinstaller-5.7.0-py3-none-manylinux2014_ppc64le.whl", hash = "sha256:2c1dd9d11cfc48bab61eeb06de69a3d1ad742bbb2ef14716965ca0333dd43a5b"}, + {file = "pyinstaller-5.7.0-py3-none-manylinux2014_s390x.whl", hash = "sha256:dfc12e92fe10ae645dd0dd1fcfa4cd7677b2e96119e3cd4980d742e09bb78925"}, + {file = "pyinstaller-5.7.0-py3-none-manylinux2014_x86_64.whl", hash = "sha256:f35f06d48faea0ad738429c009941059beebaa306e9d9ead95f1df4b441de2aa"}, + {file = "pyinstaller-5.7.0-py3-none-musllinux_1_1_aarch64.whl", hash = "sha256:28a8a0da656493aa32d9665e2f6f84775da0f23174859ed8facaa4226fe77a17"}, + {file = "pyinstaller-5.7.0-py3-none-musllinux_1_1_x86_64.whl", hash = "sha256:1ac3f09b838710c43e34b0a7ad003bd168a754b0b786c561b47baf1af9104354"}, + {file = "pyinstaller-5.7.0-py3-none-win32.whl", hash = "sha256:9cdb8ee8622ee8d2c6cd67f001b610019d4371a8bf3f7850562640ce786894d7"}, + {file = "pyinstaller-5.7.0-py3-none-win_amd64.whl", hash = "sha256:9b47c10fbefac6f6493266f8b1689109b2b14efa9142dbd2cd7549226a4568b7"}, + {file = "pyinstaller-5.7.0-py3-none-win_arm64.whl", hash = "sha256:3e51e18a16dec0414079762843cf892a5d70749ad56ca7b3c7b5f8367dc50b1e"}, + {file = "pyinstaller-5.7.0.tar.gz", hash = "sha256:0e5953937d35f0b37543cc6915dacaf3239bcbdf3fd3ecbb7866645468a16775"}, +] + +[package.dependencies] +altgraph = "*" +macholib = {version = ">=1.8", markers = "sys_platform == \"darwin\""} +pefile = {version = ">=2022.5.30", markers = "sys_platform == \"win32\""} +pyinstaller-hooks-contrib = ">=2021.4" +pywin32-ctypes = {version = ">=0.2.0", markers = "sys_platform == \"win32\""} +setuptools = ">=42.0.0" + +[package.extras] +encryption = ["tinyaes (>=1.0.0)"] +hook-testing = ["execnet (>=1.5.0)", "psutil", "pytest (>=2.7.3)"] + +[[package]] +name = "pyinstaller-hooks-contrib" +version = "2022.15" +description = "Community maintained hooks for PyInstaller" +category = "main" +optional = false +python-versions = ">=3.7" +files = [ + {file = "pyinstaller-hooks-contrib-2022.15.tar.gz", hash = "sha256:73fd4051dc1620f3ae9643291cd9e2f47bfed582ade2eb05e3247ecab4a4f5f3"}, + {file = "pyinstaller_hooks_contrib-2022.15-py2.py3-none-any.whl", hash = "sha256:55c1def8066d0279d06cd67eea30c12ffcdb961a5edeeaf361adac0164baef30"}, +] + [[package]] name = "pyproject-flake8" version = "6.0.0.post1" @@ -758,6 +699,18 @@ tomli = {version = ">=1.0.0", markers = "python_version < \"3.11\""} [package.extras] testing = ["argcomplete", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "xmlschema"] +[[package]] +name = "pywin32-ctypes" +version = "0.2.0" +description = "" +category = "main" +optional = false +python-versions = "*" +files = [ + {file = "pywin32-ctypes-0.2.0.tar.gz", hash = "sha256:24ffc3b341d457d48e8922352130cf2644024a4ff09762a2261fd34c36ee5942"}, + {file = "pywin32_ctypes-0.2.0-py2.py3-none-any.whl", hash = "sha256:9dc2d991b3479cc2df15930958b674a48a227d5361d413827a4cfd0b5876fc98"}, +] + [[package]] name = "pyyaml" version = "6.0" @@ -850,14 +803,14 @@ use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"] [[package]] name = "setuptools" -version = "66.1.1" +version = "67.0.0" description = "Easily download, build, install, upgrade, and uninstall Python packages" category = "main" optional = false python-versions = ">=3.7" files = [ - {file = "setuptools-66.1.1-py3-none-any.whl", hash = "sha256:6f590d76b713d5de4e49fe4fbca24474469f53c83632d5d0fd056f7ff7e8112b"}, - {file = "setuptools-66.1.1.tar.gz", hash = "sha256:ac4008d396bc9cd983ea483cb7139c0240a07bbc74ffb6232fceffedc6cf03a8"}, + {file = "setuptools-67.0.0-py3-none-any.whl", hash = "sha256:9d790961ba6219e9ff7d9557622d2fe136816a264dd01d5997cfc057d804853d"}, + {file = "setuptools-67.0.0.tar.gz", hash = "sha256:883131c5b6efa70b9101c7ef30b2b7b780a4283d5fc1616383cdf22c83cbefe6"}, ] [package.extras] @@ -1013,5 +966,5 @@ files = [ [metadata] lock-version = "2.0" -python-versions = "^3.10" -content-hash = "805b668da35227293618187f234f4b39784631bc6c4aa754e1cef9c92353de42" +python-versions = "3.10" +content-hash = "d0c7ca731ec89510358a3a881a50fde163b24f3043071be1403536a22e0864a3" diff --git a/pyproject.toml b/pyproject.toml index 0b967c7..113ee68 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,9 +7,9 @@ license = "LGPL-3.0" readme = "README.md" [tool.poetry.dependencies] -python = "^3.10" +python = "3.10" colorama = "^0.4.6" -cx-freeze = "^6.14.1" +pyinstaller = "^5.7.0" pydivert = "2.1.0" questionary = "^1.10.0" tqdm = "^4.64.1" From 8aa0d8c61ec642470df1a85e95c955c14fbf8b9f Mon Sep 17 00:00:00 2001 From: TheMythologist Date: Sun, 29 Jan 2023 18:29:15 +0800 Subject: [PATCH 3/5] build: use pyinstaller for building of executable --- build.py | 16 ++++++++++++ setup.py | 75 ----------------------------------------------------- version.txt | 41 +++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 75 deletions(-) create mode 100644 build.py delete mode 100644 setup.py create mode 100644 version.txt diff --git a/build.py b/build.py new file mode 100644 index 0000000..8196921 --- /dev/null +++ b/build.py @@ -0,0 +1,16 @@ +import PyInstaller.__main__ + +if __name__ == "__main__": + PyInstaller.__main__.run( + ( + "src\\app.py", + "--onefile", + "--icon", + "logo.ico", + "--uac-admin", + "--name", + "Guardian", + "--version-file", + "version.txt", + ) + ) diff --git a/setup.py b/setup.py deleted file mode 100644 index 9d680d2..0000000 --- a/setup.py +++ /dev/null @@ -1,75 +0,0 @@ -import os -import shutil -import sys -import zipfile - -from cx_Freeze import Executable, setup - -version = "3.3.1" - -build_path = f"build/exe.win-amd64-{sys.version_info.major}.{sys.version_info.minor}" - -zip_exclude_packages = [ - "certifi", - "pydivert", -] -include_files = ["SOURCE", "LICENSE"] -if os.path.isfile("db.json"): - include_files.append("db.json") -buildOptions = dict( - packages=[], - replace_paths=[("*", "")], - optimize=2, - include_files=include_files, - zip_include_packages="*", - zip_exclude_packages=zip_exclude_packages, - silent=True, - path=sys.path + [f"{sys.path[0]}/src"], -) -executables = [ - Executable( - "src/app.py", target_name="Guardian.exe", icon="logo.ico", uac_admin=True - ) -] - - -def zip_folder(folder_path: str, output_path: str) -> None: - """ - Zip the contents of an entire folder (with that folder included - in the archive). Empty subfolders will be included in the archive - as well. - """ - parent_folder = os.path.dirname(folder_path) - # Retrieve the paths of the folder contents. - contents = os.walk(folder_path) - with zipfile.ZipFile(output_path, "w", zipfile.ZIP_DEFLATED) as zip_file: - for root, folders, files in contents: - # Include all subfolders, including empty ones. - for folder_name in folders: - absolute_path = os.path.join(root, folder_name) - relative_path = absolute_path.replace(f"{parent_folder}\\", "") - zip_file.write(absolute_path, relative_path.replace(build_path, "")) - for file in files: - absolute_path = os.path.join(root, file) - relative_path = absolute_path.replace(f"{parent_folder}\\", "") - zip_file.write(absolute_path, relative_path.replace(build_path, "")) - - -if os.path.exists(build_path): - shutil.rmtree(build_path) - -if not os.path.exists("build/exe"): - os.makedirs("build/exe") - -if os.path.isfile(f"build/exe/guardian-{version}.zip"): - os.remove(f"build/exe/guardian-{version}.zip") - -setup( - name="Guardian", - version=version, - description="Firewall", - options=dict(build_exe=buildOptions), - executables=executables, -) - -zip_folder(build_path, rf"build\exe\guardian-{version}.zip") diff --git a/version.txt b/version.txt new file mode 100644 index 0000000..a29bc60 --- /dev/null +++ b/version.txt @@ -0,0 +1,41 @@ +VSVersionInfo( + ffi=FixedFileInfo( + # filevers and prodvers should be always a tuple with four items: (1, 2, 3, 4) + # Set not needed items to zero 0. + filevers=(3, 3, 1, 0), + prodvers=(3, 3, 1, 0), + # Contains a bitmask that specifies the valid bits 'flags'r + mask=0x3f, + # Contains a bitmask that specifies the Boolean attributes of the file. + flags=0x1, + # The operating system for which this file was designed. + # 0x4 - NT and there is no need to change it. + OS=0x40004, + # The general type of file. + # 0x1 - the file is an application. + fileType=0x1, + # The function of the file. + # 0x0 - the function is not defined for this fileType + subtype=0x0, + # Creation date and time stamp. + date=(0, 0) + ), + kids=[ + StringFileInfo( + [ + StringTable( + '040904E4', + [StringStruct('Comments', ''), + StringStruct('CompanyName', ''), + StringStruct('FileDescription', 'Firewall'), + StringStruct('FileVersion', '3.3.1'), + StringStruct('InternalName', 'Guardian.exe'), + StringStruct('LegalCopyright', ''), + StringStruct('LegalTrademarks', ''), + StringStruct('OriginalFilename', 'Guardian.exe'), + StringStruct('ProductName', 'Guardian'), + StringStruct('ProductVersion', '3.3.1')]) + ]), + VarFileInfo([VarStruct('Translation', [1033, 1252])]) + ] +) From 6c3caff09b334a4066cbbbbfc95ce0ece60a51f8 Mon Sep 17 00:00:00 2001 From: TheMythologist Date: Sun, 29 Jan 2023 18:35:59 +0800 Subject: [PATCH 4/5] deps: loosen python version dependency --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 113ee68..51eba54 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ license = "LGPL-3.0" readme = "README.md" [tool.poetry.dependencies] -python = "3.10" +python = "^3.10.0" colorama = "^0.4.6" pyinstaller = "^5.7.0" pydivert = "2.1.0" From 6142f451b2ddad0538a5460ff65f84e666ca497f Mon Sep 17 00:00:00 2001 From: TheMythologist Date: Sun, 29 Jan 2023 18:39:40 +0800 Subject: [PATCH 5/5] ci: do not typecheck build.py for mypy --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 51eba54..08e44a6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,7 +37,7 @@ profile = "black" [tool.mypy] platform = "win32" -exclude = ["build/", "speed_tests/", "tests"] +exclude = ["build/", "dist/", "speed_tests/", "tests", "build.py"] [[tool.mypy.overrides]] module = ["cx_Freeze", "pydivert", "prsw"]