1
0
Эх сурвалжийг харах

feat: Support publish to pypi

zu1k 2 жил өмнө
parent
commit
04714ed480

+ 109 - 0
.github/workflows/maturin.yml

@@ -0,0 +1,109 @@
+# This file is autogenerated by maturin v0.15.2
+# To update, run
+#
+#    maturin generate-ci github
+#
+name: CI
+
+on:
+  push:
+    branches:
+      - master
+    tags:
+      - '*'
+  pull_request:
+  workflow_dispatch:
+
+permissions:
+  contents: read
+
+jobs:
+  linux:
+    runs-on: ubuntu-latest
+    strategy:
+      matrix:
+        target: [x86_64, x86, aarch64, armv7, s390x, ppc64le]
+    steps:
+      - uses: actions/checkout@v3
+      - name: Build wheels
+        uses: PyO3/maturin-action@v1
+        with:
+          target: ${{ matrix.target }}
+          args: --release --out dist
+          sccache: 'true'
+          manylinux: auto
+      - name: Upload wheels
+        uses: actions/upload-artifact@v3
+        with:
+          name: wheels
+          path: dist
+
+  windows:
+    runs-on: windows-latest
+    strategy:
+      matrix:
+        target: [x64, x86]
+    steps:
+      - uses: actions/checkout@v3
+      - name: Build wheels
+        uses: PyO3/maturin-action@v1
+        with:
+          target: ${{ matrix.target }}
+          args: --release --out dist
+          sccache: 'true'
+      - name: Upload wheels
+        uses: actions/upload-artifact@v3
+        with:
+          name: wheels
+          path: dist
+
+  macos:
+    runs-on: macos-latest
+    strategy:
+      matrix:
+        target: [x86_64, aarch64]
+    steps:
+      - uses: actions/checkout@v3
+      - name: Build wheels
+        uses: PyO3/maturin-action@v1
+        with:
+          target: ${{ matrix.target }}
+          args: --release --out dist
+          sccache: 'true'
+      - name: Upload wheels
+        uses: actions/upload-artifact@v3
+        with:
+          name: wheels
+          path: dist
+
+  sdist:
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v3
+      - name: Build sdist
+        uses: PyO3/maturin-action@v1
+        with:
+          command: sdist
+          args: --out dist
+      - name: Upload sdist
+        uses: actions/upload-artifact@v3
+        with:
+          name: wheels
+          path: dist
+
+  release:
+    name: Release
+    runs-on: ubuntu-latest
+    if: "startsWith(github.ref, 'refs/tags/')"
+    needs: [linux, windows, macos, sdist]
+    steps:
+      - uses: actions/download-artifact@v3
+        with:
+          name: wheels
+      - name: Publish to PyPI
+        uses: PyO3/maturin-action@v1
+        env:
+          MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
+        with:
+          command: upload
+          args: --skip-existing *

+ 75 - 1
.gitignore

@@ -4,4 +4,78 @@
 .vscode
 .idea
 
-/crates/adblocker
+/crates/adblocker
+
+
+/target
+
+# Byte-compiled / optimized / DLL files
+__pycache__/
+.pytest_cache/
+*.py[cod]
+
+# C extensions
+*.so
+
+# Distribution / packaging
+.Python
+.venv/
+env/
+bin/
+build/
+develop-eggs/
+dist/
+eggs/
+lib/
+lib64/
+parts/
+sdist/
+var/
+include/
+man/
+venv/
+*.egg-info/
+.installed.cfg
+*.egg
+
+# Installer logs
+pip-log.txt
+pip-delete-this-directory.txt
+pip-selfcheck.json
+
+# Unit test / coverage reports
+htmlcov/
+.tox/
+.coverage
+.cache
+nosetests.xml
+coverage.xml
+
+# Translations
+*.mo
+
+# Mr Developer
+.mr.developer.cfg
+.project
+.pydevproject
+
+# Rope
+.ropeproject
+
+# Django stuff:
+*.log
+*.pot
+
+.DS_Store
+
+# Sphinx documentation
+docs/_build/
+
+# PyCharm
+.idea/
+
+# VSCode
+.vscode/
+
+# Pyenv
+.python-version

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 235 - 197
Cargo.lock


+ 3 - 3
Cargo.toml

@@ -1,9 +1,9 @@
 [package]
 name = "good-mitm"
-version = "0.4.0"
+version = "0.4.1"
 authors = ["zu1k <[email protected]>"]
 edition = "2021"
-description = "Use MITM technology to provide features like rewrite, redirect."
+description = "Good Man in the Middle: Use MITM technology to provide features like rewrite, redirect."
 readme = "README.md"
 homepage = "https://github.com/zu1k/good-mitm"
 repository = "https://github.com/zu1k/good-mitm"
@@ -31,7 +31,7 @@ serde_yaml = "0.9"
 hyper-proxy = { version = "0.9", default-features = false }
 rustls-pemfile = "1.0"
 tokio = { version = "1", features = ["rt-multi-thread", "signal"] }
-rustls = "0.20"
+rustls = "0.21"
 trust_cert = { path = "crates/trust_cert", optional = true }
 
 [features]

+ 1 - 1
LICENSE

@@ -1,6 +1,6 @@
 MIT License
 
-Copyright (c) 2021 zu1k
+Copyright (c) 2021-2023 zu1k [email protected]
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal

+ 5 - 5
crates/core/Cargo.toml

@@ -14,21 +14,21 @@ cfg-if = "1"
 http = "0.2"
 hyper = { version = "0.14", features = ["http1", "http2", "server", "stream", "tcp", "runtime"]  }
 hyper-proxy = { version = "0.9" }
-hyper-rustls = { version = "0.23" }
+hyper-rustls = { version = "0.24" }
 hyper-tls = { version = "0.5", optional = true }
 log = "0.4"
-moka = { version = "0.9", features = ["future"] }
+moka = { version = "0.11", features = ["future"] }
 openssl = { version = "0.10", features = ["vendored"], optional = true }
 rcgen = { version = "0.10", features = ["x509-parser"] }
 serde = { version = "1.0", features = ["derive"] }
 thiserror = "1"
 time = "0.3"
-typed-builder = "0.10"
+typed-builder = "0.14"
 tokio = { version = "1", features = ["rt"] }
-tokio-rustls = { version = "0.23", default-features = false, features = ["tls12"] }
+tokio-rustls = { version = "0.24", default-features = false, features = ["tls12"] }
 tokio-util = { version = "0.7", features = ["io"] }
 wildmatch = "2.1"
-rustls = { version = "0.20", features = ["dangerous_configuration"] }
+rustls = { version = "0.21", features = ["dangerous_configuration"] }
 rand = "0.8"
 
 [features]

+ 4 - 4
crates/core/src/ca.rs

@@ -5,13 +5,13 @@ use rcgen::{
     BasicConstraints, Certificate, CertificateParams, DistinguishedName, DnType,
     ExtendedKeyUsagePurpose, IsCa, KeyPair, KeyUsagePurpose, RcgenError, SanType,
 };
-use rustls::{
+use std::sync::Arc;
+use time::{ext::NumericalDuration, OffsetDateTime};
+use tokio_rustls::rustls::{
     server::{ClientHello, ResolvesServerCert},
     sign::CertifiedKey,
+    ServerConfig,
 };
-use std::sync::Arc;
-use time::{ext::NumericalDuration, OffsetDateTime};
-use tokio_rustls::rustls::{self, ServerConfig};
 
 const CERT_TTL_DAYS: u64 = 365;
 const CERT_CACHE_TTL_SECONDS: u64 = CERT_TTL_DAYS * 24 * 60 * 60 / 2;

+ 3 - 3
crates/rule/Cargo.toml

@@ -13,9 +13,9 @@ mitm-core = { path = "../core", package = "good-mitm-core" }
 
 anyhow = "1.0"
 async-trait = "0.1"
-cached = "0.40"
-cookie = "0.16"
-fancy-regex = "0.10"
+cached = "0.43"
+cookie = "0.17"
+fancy-regex = "0.11"
 http = "0.2"
 hyper = { version = "0.14", features = ["client", "http1", "server", "stream", "tcp"]  }
 log = "0.4"

+ 2 - 2
crates/trust_cert/Cargo.toml

@@ -11,7 +11,7 @@ license = "MIT"
 rcgen = { version = "0.10", features = ["x509-parser"] }
 
 [target.'cfg(unix)'.dependencies]
-nix = { version = "0.25", default-features = false, features = ["user"] }
+nix = { version = "0.26", default-features = false, features = ["user"] }
 
 [target.'cfg(windows)'.dependencies]
-windows = { version = "0.43", features = ["Win32_Security_Cryptography", "Win32_Foundation"] }
+windows = { version = "0.48", features = ["Win32_Security_Cryptography", "Win32_Foundation"] }

+ 16 - 0
pyproject.toml

@@ -0,0 +1,16 @@
+[build-system]
+requires = ["maturin>=0.15,<0.16"]
+build-backend = "maturin"
+
+[project]
+name = "good-mitm"
+requires-python = ">=3.7"
+classifiers = [
+    "Programming Language :: Rust",
+    "Programming Language :: Python :: Implementation :: CPython",
+    "Programming Language :: Python :: Implementation :: PyPy",
+]
+
+
+[tool.maturin]
+bindings = "bin"

+ 1 - 1
rust-toolchain

@@ -1,3 +1,3 @@
 [toolchain]
-channel = "nightly"
+channel = "1.69"
 components = ["rustfmt", "clippy"]

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно