diff options
| author | Namilskyy <alive6863@gmail.com> | 2025-11-29 20:26:35 +0300 |
|---|---|---|
| committer | Namilskyy <alive6863@gmail.com> | 2025-11-29 20:26:35 +0300 |
| commit | d10ac4cc08d679e7971296b79c6eafadcdbc78de (patch) | |
| tree | d12c170704d0632fcdfde809879ec9c477ad8574 | |
| parent | 2536cfdb527cd252ed926e3c05313430858a4ca6 (diff) | |
Big refactors and additions, implemented http package getter and refactored i2p fn
| -rw-r--r-- | Cargo.lock | 1107 | ||||
| -rw-r--r-- | Cargo.toml | 4 | ||||
| -rw-r--r-- | src/i2impl/mi2p.rs | 162 | ||||
| -rw-r--r-- | src/i2impl/mod.rs | 1 | ||||
| -rw-r--r-- | src/main.rs | 37 | ||||
| -rw-r--r-- | src/net/http_packages.rs | 92 | ||||
| -rw-r--r-- | src/net/i2p_package.rs | 120 | ||||
| -rw-r--r-- | src/net/i2p_tools.rs (renamed from src/i2impl/i2tools.rs) | 0 | ||||
| -rw-r--r-- | src/net/mod.rs | 2 | ||||
| -rw-r--r-- | src/pkgtoolkit/pkgtools.rs | 205 |
10 files changed, 1503 insertions, 227 deletions
@@ -86,6 +86,12 @@ dependencies = [ ] [[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + +[[package]] name = "autocfg" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -98,6 +104,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" [[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] name = "base64ct" version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -119,6 +131,12 @@ dependencies = [ ] [[package]] +name = "bumpalo" +version = "3.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43" + +[[package]] name = "byteorder" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -243,6 +261,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" [[package]] +name = "core-foundation" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] name = "cpufeatures" version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -359,6 +393,17 @@ dependencies = [ ] [[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] name = "ecb" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -464,6 +509,15 @@ dependencies = [ ] [[package]] +name = "encoding_rs" +version = "0.8.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3" +dependencies = [ + "cfg-if", +] + +[[package]] name = "equivalent" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -491,6 +545,12 @@ dependencies = [ ] [[package]] +name = "fastrand" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" + +[[package]] name = "ff" version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -544,12 +604,42 @@ dependencies = [ ] [[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] name = "foldhash" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" [[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "form_urlencoded" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" +dependencies = [ + "percent-encoding", +] + +[[package]] name = "futures" version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -661,6 +751,18 @@ dependencies = [ ] [[package]] +name = "getrandom" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" +dependencies = [ + "cfg-if", + "libc", + "r-efi", + "wasip2", +] + +[[package]] name = "group" version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -672,6 +774,25 @@ dependencies = [ ] [[package]] +name = "h2" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3c0b69cfcb4e1b9f1bf2f53f95f766e4661169728ec61cd3fe5a0166f2d1386" +dependencies = [ + "atomic-waker", + "bytes", + "fnv", + "futures-core", + "futures-sink", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] name = "hashbrown" version = "0.15.5" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -710,6 +831,227 @@ dependencies = [ ] [[package]] +name = "http" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3ba2a386d7f85a81f119ad7498ebe444d2e22c2af0b86b069416ace48b3311a" +dependencies = [ + "bytes", + "itoa", +] + +[[package]] +name = "http-body" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" +dependencies = [ + "bytes", + "http", +] + +[[package]] +name = "http-body-util" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b021d93e26becf5dc7e1b75b1bed1fd93124b374ceb73f43d4d4eafec896a64a" +dependencies = [ + "bytes", + "futures-core", + "http", + "http-body", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" + +[[package]] +name = "hyper" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ab2d4f250c3d7b1c9fcdff1cece94ea4e2dfbec68614f7b87cb205f24ca9d11" +dependencies = [ + "atomic-waker", + "bytes", + "futures-channel", + "futures-core", + "h2", + "http", + "http-body", + "httparse", + "itoa", + "pin-project-lite", + "pin-utils", + "smallvec", + "tokio", + "want", +] + +[[package]] +name = "hyper-rustls" +version = "0.27.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3c93eb611681b207e1fe55d5a71ecf91572ec8a6705cdb6857f7d8d5242cf58" +dependencies = [ + "http", + "hyper", + "hyper-util", + "rustls", + "rustls-pki-types", + "tokio", + "tokio-rustls", + "tower-service", +] + +[[package]] +name = "hyper-tls" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" +dependencies = [ + "bytes", + "http-body-util", + "hyper", + "hyper-util", + "native-tls", + "tokio", + "tokio-native-tls", + "tower-service", +] + +[[package]] +name = "hyper-util" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52e9a2a24dc5c6821e71a7030e1e14b7b632acac55c40e9d2e082c621261bb56" +dependencies = [ + "base64", + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "http", + "http-body", + "hyper", + "ipnet", + "libc", + "percent-encoding", + "pin-project-lite", + "socket2", + "system-configuration", + "tokio", + "tower-service", + "tracing", + "windows-registry", +] + +[[package]] +name = "icu_collections" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c6b649701667bbe825c3b7e6388cb521c23d88644678e83c0c4d0a621a34b43" +dependencies = [ + "displaydoc", + "potential_utf", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edba7861004dd3714265b4db54a3c390e880ab658fec5f7db895fae2046b5bb6" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_normalizer" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f6c8828b67bf8908d82127b2054ea1b4427ff0230ee9141c54251934ab1b599" +dependencies = [ + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7aedcccd01fc5fe81e6b489c15b247b8b0690feb23304303a9e560f37efc560a" + +[[package]] +name = "icu_properties" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e93fcd3157766c0c8da2f8cff6ce651a31f0810eaa1c51ec363ef790bbb5fb99" +dependencies = [ + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02845b3647bb045f1100ecd6480ff52f34c35f82d9880e029d329c21d1054899" + +[[package]] +name = "icu_provider" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85962cf0ce02e1e0a629cc34e7ca3e373ce20dda4c4d7294bbd0bf1fdb59e614" +dependencies = [ + "displaydoc", + "icu_locale_core", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] + +[[package]] +name = "idna" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acae9609540aa318d1bc588455225fb2085b9ed0c4f6bd0d9d5bcd86f1a0344" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] name = "indexmap" version = "2.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -729,12 +1071,44 @@ dependencies = [ ] [[package]] +name = "ipnet" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" + +[[package]] +name = "iri-string" +version = "0.7.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f867b9d1d896b67beb18518eda36fdb77a32ea590de864f1325b294a6d14397" +dependencies = [ + "memchr", + "serde", +] + +[[package]] name = "is_terminal_polyfill" version = "1.70.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" [[package]] +name = "itoa" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" + +[[package]] +name = "js-sys" +version = "0.3.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "464a3709c7f55f1f721e5389aa6ea4e3bc6aba669353300af094b29ffbdde1d8" +dependencies = [ + "once_cell", + "wasm-bindgen", +] + +[[package]] name = "lazy_static" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -764,6 +1138,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df1d3c3b53da64cf5760482273a98e575c651a67eec7f77df96b5b642de8f039" [[package]] +name = "litemap" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6373607a59f0be73a39b6fe456b8192fcc3585f602af20751600e974dd455e77" + +[[package]] name = "lock_api" version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -793,15 +1173,23 @@ dependencies = [ "emissary-core", "flate2", "log", + "reqwest", "serde", "sqlite", "tar", "tokio", "toml", + "url", "yosemite", ] [[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] name = "minimal-lexical" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -829,6 +1217,23 @@ dependencies = [ ] [[package]] +name = "native-tls" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87de3442987e9dbec73158d5c715e7ad9072fda936bb03d19d7fa10e00520f0e" +dependencies = [ + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + +[[package]] name = "nom" version = "7.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -885,6 +1290,50 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" [[package]] +name = "openssl" +version = "0.10.75" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08838db121398ad17ab8531ce9de97b244589089e290a384c900cb9ff7434328" +dependencies = [ + "bitflags", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "openssl-probe" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" + +[[package]] +name = "openssl-sys" +version = "0.9.111" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82cab2d520aa75e3c58898289429321eb788c3106963d0dc886ec7a5f4adc321" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] name = "p256" version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -920,6 +1369,12 @@ dependencies = [ ] [[package]] +name = "percent-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + +[[package]] name = "pin-project" version = "1.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -979,6 +1434,15 @@ dependencies = [ ] [[package]] +name = "potential_utf" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b73949432f5e2a09657003c25bca5e19a0e9c84f8058ca374f49e0ebe605af77" +dependencies = [ + "zerovec", +] + +[[package]] name = "ppv-lite86" version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1015,6 +1479,12 @@ dependencies = [ ] [[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + +[[package]] name = "rand" version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1041,7 +1511,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom", + "getrandom 0.2.16", ] [[package]] @@ -1054,6 +1524,46 @@ dependencies = [ ] [[package]] +name = "reqwest" +version = "0.12.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d0946410b9f7b082a427e4ef5c8ff541a88b357bc6c637c40db3a68ac70a36f" +dependencies = [ + "base64", + "bytes", + "encoding_rs", + "futures-core", + "h2", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-rustls", + "hyper-tls", + "hyper-util", + "js-sys", + "log", + "mime", + "native-tls", + "percent-encoding", + "pin-project-lite", + "rustls-pki-types", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper", + "tokio", + "tokio-native-tls", + "tower", + "tower-http", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + +[[package]] name = "rfc6979" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1064,6 +1574,20 @@ dependencies = [ ] [[package]] +name = "ring" +version = "0.17.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" +dependencies = [ + "cc", + "cfg-if", + "getrandom 0.2.16", + "libc", + "untrusted", + "windows-sys 0.52.0", +] + +[[package]] name = "rustc_version" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1086,6 +1610,60 @@ dependencies = [ ] [[package]] +name = "rustls" +version = "0.23.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "533f54bc6a7d4f647e46ad909549eda97bf5afc1585190ef692b4286b198bd8f" +dependencies = [ + "once_cell", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-pki-types" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "708c0f9d5f54ba0272468c1d306a52c495b31fa155e91bc25371e6df7996908c" +dependencies = [ + "zeroize", +] + +[[package]] +name = "rustls-webpki" +version = "0.103.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ffdfa2f5286e2247234e03f680868ac2815974dc39e00ea15adc445d0aafe52" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", +] + +[[package]] +name = "rustversion" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" + +[[package]] +name = "ryu" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" + +[[package]] +name = "schannel" +version = "0.1.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "891d81b926048e76efe18581bf793546b4c0eaf8448d72be8de2bbee5fd166e1" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] name = "scopeguard" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1106,6 +1684,29 @@ dependencies = [ ] [[package]] +name = "security-framework" +version = "2.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc1f0cbffaac4852523ce30d8bd3c5cdc873501d96ff467ca09b6767bb8cd5c0" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] name = "semver" version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1142,6 +1743,19 @@ dependencies = [ ] [[package]] +name = "serde_json" +version = "1.0.145" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "402a6f66d8c709116cf22f558eab210f5a50187f702eb4d7e5ef38d9a7f1c79c" +dependencies = [ + "itoa", + "memchr", + "ryu", + "serde", + "serde_core", +] + +[[package]] name = "serde_spanned" version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1151,6 +1765,18 @@ dependencies = [ ] [[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] name = "sha1" version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1261,6 +1887,12 @@ dependencies = [ ] [[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + +[[package]] name = "static_assertions" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1290,6 +1922,47 @@ dependencies = [ ] [[package]] +name = "sync_wrapper" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" +dependencies = [ + "futures-core", +] + +[[package]] +name = "synstructure" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "system-configuration" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" +dependencies = [ + "bitflags", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] name = "tar" version = "0.4.44" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1301,6 +1974,19 @@ dependencies = [ ] [[package]] +name = "tempfile" +version = "3.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d31c77bdf42a745371d260a26ca7163f1e0924b64afa0b688e61b5a9fa02f16" +dependencies = [ + "fastrand", + "getrandom 0.3.4", + "once_cell", + "rustix", + "windows-sys 0.61.2", +] + +[[package]] name = "thingbuf" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1339,6 +2025,16 @@ dependencies = [ ] [[package]] +name = "tinystr" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42d3e9c45c09de15d06dd8acf5f4e0e399e85927b7f00711024eb7ae10fa4869" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] name = "tokio" version = "1.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1365,6 +2061,39 @@ dependencies = [ ] [[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", +] + +[[package]] +name = "tokio-rustls" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1729aa945f29d91ba541258c8df89027d5792d85a8841fb65e8bf0f4ede4ef61" +dependencies = [ + "rustls", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2efa149fe76073d6e8fd97ef4f4eca7b67f599660115591483572e406e165594" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", +] + +[[package]] name = "toml" version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1404,6 +2133,51 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df8b2b54733674ad286d16267dcfc7a71ed5c776e4ac7aa3c3e2561f7c637bf2" [[package]] +name = "tower" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d039ad9159c98b70ecfd540b2573b97f7f52c3e8d9f8ad57a24b916a536975f9" +dependencies = [ + "futures-core", + "futures-util", + "pin-project-lite", + "sync_wrapper", + "tokio", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-http" +version = "0.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cf146f99d442e8e68e585f5d798ccd3cad9a7835b917e09728880a862706456" +dependencies = [ + "bitflags", + "bytes", + "futures-util", + "http", + "http-body", + "iri-string", + "pin-project-lite", + "tower", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-layer" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" + +[[package]] +name = "tower-service" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" + +[[package]] name = "tracing" version = "0.1.41" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1436,6 +2210,12 @@ dependencies = [ ] [[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + +[[package]] name = "typenum" version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1470,36 +2250,190 @@ dependencies = [ ] [[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "url" +version = "2.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08bc136a29a3d1758e07a9cca267be308aeebf5cfd5a10f3f67ab2097683ef5b" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", + "serde", +] + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + +[[package]] name = "utf8parse" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] name = "version_check" version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + +[[package]] name = "wasi" version = "0.11.1+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" [[package]] +name = "wasip2" +version = "1.0.1+wasi-0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0562428422c63773dad2c345a1882263bbf4d65cf3f42e90921f787ef5ad58e7" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "wasm-bindgen" +version = "0.2.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d759f433fa64a2d763d1340820e46e111a7a5ab75f993d1852d70b03dbb80fd" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "836d9622d604feee9e5de25ac10e3ea5f2d65b41eac0d9ce72eb5deae707ce7c" +dependencies = [ + "cfg-if", + "js-sys", + "once_cell", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48cb0d2638f8baedbc542ed444afc0644a29166f1595371af4fecf8ce1e7eeb3" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cefb59d5cd5f92d9dcf80e4683949f15ca4b511f4ac0a6e14d4e1ac60c6ecd40" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbc538057e648b67f72a982e708d485b2efa771e1ac05fec311f9f63e5800db4" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "web-sys" +version = "0.3.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b32828d774c412041098d182a8b38b16ea816958e07cf40eec2bc080ae137ac" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] name = "windows-link" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" [[package]] +name = "windows-registry" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02752bf7fbdcce7f2a27a742f798510f3e5ad88dbe84871e5168e2120c3d5720" +dependencies = [ + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-result" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] name = "windows-sys" version = "0.60.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" dependencies = [ - "windows-targets", + "windows-targets 0.53.5", ] [[package]] @@ -1513,65 +2447,129 @@ dependencies = [ [[package]] name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm 0.52.6", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", +] + +[[package]] +name = "windows-targets" version = "0.53.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3" dependencies = [ "windows-link", - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.53.1", + "windows_aarch64_msvc 0.53.1", + "windows_i686_gnu 0.53.1", + "windows_i686_gnullvm 0.53.1", + "windows_i686_msvc 0.53.1", + "windows_x86_64_gnu 0.53.1", + "windows_x86_64_gnullvm 0.53.1", + "windows_x86_64_msvc 0.53.1", ] [[package]] name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_gnullvm" version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53" [[package]] name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_aarch64_msvc" version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" [[package]] name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnu" version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3" [[package]] name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_gnullvm" version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c" [[package]] name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_i686_msvc" version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2" [[package]] name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnu" version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499" [[package]] name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_gnullvm" version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" [[package]] name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "windows_x86_64_msvc" version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" @@ -1583,6 +2581,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "21a0236b59786fed61e2a80582dd500fe61f18b5dca67a4a067d0bc9039339cf" [[package]] +name = "wit-bindgen" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59" + +[[package]] +name = "writeable" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9edde0db4769d2dc68579893f2306b26c6ecfbe0ef499b013d731b7b9247e0b9" + +[[package]] name = "x25519-dalek" version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1604,6 +2614,29 @@ dependencies = [ ] [[package]] +name = "yoke" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72d6e5c6afb84d73944e5cedb052c4680d5657337201555f9f2a16b7406d4954" +dependencies = [ + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b659052874eb698efe5b9e8cf382204678a0086ebf46982b79d6ca3182927e5d" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] name = "yosemite" version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1638,6 +2671,27 @@ dependencies = [ ] [[package]] +name = "zerofrom" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] name = "zeroize" version = "1.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1656,3 +2710,36 @@ dependencies = [ "quote", "syn", ] + +[[package]] +name = "zerotrie" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a59c17a5562d507e4b54960e8569ebee33bee890c70aa3fe7b97e85a9fd7851" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + +[[package]] +name = "zerovec" +version = "0.11.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c28719294829477f525be0186d13efa9a3c602f7ec202ca9e353d310fb9a002" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eadce39539ca5cb3985590102671f2567e659fca9666581ad3411d59207951f3" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] @@ -11,7 +11,7 @@ authors = ["namilsk <namilsk@namilsk.tech>", clap = { version = "4.5.53", features = ["derive"] } toml = { version = "0.9.8", features = ["serde"] } serde = { version = "1.0.228", features = ["derive"] } -tokio = { version = "1.48.0", features = ["macros", "rt"] } +tokio = { version = "1.48.0", features = ["fs", "io-util", "macros", "rt"] } flate2 = "1.1.5" log = "0.4.28" sqlite = "0.37.0" @@ -19,4 +19,6 @@ tar = "0.4.44" emissary-core = "0.2.0" yosemite = "0.6.1" cc = "1.2.48" +reqwest = "0.12.24" +url = "2.5.7" diff --git a/src/i2impl/mi2p.rs b/src/i2impl/mi2p.rs deleted file mode 100644 index cf2b8e5..0000000 --- a/src/i2impl/mi2p.rs +++ /dev/null @@ -1,162 +0,0 @@ - -use crate::cfg::config::Config; - -use tokio; -use emissary_core::runtime::{ - AsyncRead, - AsyncWrite, -}; - -use std::{io, - fs::File, - path::Path, - io::Write}; -// use emissary_core::Profile; -// use emissary_core::i2np::Message; -use tokio::io::{AsyncReadExt, AsyncWriteExt}; -use yosemite::SessionOptions; -use yosemite::{Session, style::Stream}; -/* -use i2p_client::ClientType; -use i2p_client::I2PClient; -use i2p_client::SessionStyle::Stream; -use i2p_client::Session; - -struct I2PStatus { - Connected: bool, -} - -impl I2PStatus { - pub fn connect(&self) -> Result<bool, std::io::Error> { - - let config: Config = Config::parse().unwrap(); - let client= I2PClient::new(true, "MeskPKG-manager".to_string(), "2.0", "2.58.0", 10); - // let destination = Session::r#gen(&mut self, SigType::EdDsaSha512Ed25519) - let session = Session::create(config.repo.repo_url, - &config.repo.destination.0, - "MeskPKG-manager", - Stream, - "2.0", - "2.58"); - - Ok(true) - } -} -*/ - -pub struct I2P<Stream> { - session: Option<Session<Stream>>, - connected: bool, - config: Config, - -} - -impl I2P<Stream> { - /// Creates a new I2P object with the given configuration. - /// - /// # Returns - /// - /// A new I2P object with the given configuration. The session is initially set to None and the connected status is set to false. - pub fn new(config: Config) -> Self { - I2P { - session: None, - connected: false, - config: config, - } - } - - /// Fetches the list of packages from the repository specified in the configuration. - /// - /// This function connects to the repository specified in the configuration, sends a GET request for the repository list and returns true if the request is successful, false otherwise. - /// - /// # Errors - /// - /// Returns an error if the repository URL is invalid or if the request fails. - /// - /// # Shortcomings - /// - Currently, &str is used instead of Path. - /// - An incomplete I2P structure, the session is stored in the structure but - /// is recreated when called, perhaps the connection/disconnection methods should be encapsulated, - /// although the function is not used often so it will not carry major changes - pub async fn fetch_index(&mut self) -> Result<bool, std::io::Error> { - let repo_url_str = &self.config.repo.repo_url; - let cache_dir = &self.config.paths.cache_dir; - - let repo_pos = repo_url_str.find("/repo").ok_or_else(|| { - io::Error::new(io::ErrorKind::InvalidData, "URL does not contain '/repo'") - })?; - // BaseURL - let base_url = &repo_url_str[..repo_pos]; - // Url after /repo - let path_suffix = &repo_url_str[repo_pos + "/repo".len()..]; - // HTTP path - let request_path = format!("/repo{}{}", path_suffix, if path_suffix.ends_with(".tar.gz") { "" } else { "/INDEX.tar.gz" }); - - let opts = SessionOptions::default(); - // FIXME: Make sure, opts setted to I2P - // opts.set_host("127.0.0.1"); - // opts.set_port(7656); - let mut session = Session::<Stream>::new(opts).await.map_err(|e| { - io::Error::new(io::ErrorKind::Other, format!("Failed to create session: {}", e)) - })?; - - let mut stream = session.connect(base_url).await.map_err(|e| { - io::Error::new(io::ErrorKind::ConnectionAborted, format!("Failed to connect: {}", e)) - })?; - - let request = format!("GET {} HTTP/1.1\r\nHost: {}\r\n\r\n", request_path, base_url); - stream.write_all(request.as_bytes()).await.map_err(|e| { - io::Error::new(io::ErrorKind::Other, format!("Failed to write request: {}", e)) - })?; - - let mut response_buffer = Vec::new(); - let mut chunk = [0u8; 1024]; - - loop { - // FIXME: Check docs and make suro stream allows to AsyncReadExt - let bytes_read = stream.read(&mut chunk).await.map_err(|e| { - io::Error::new(io::ErrorKind::Other, format!("Failed to read response: {}", e)) - })?; - - if bytes_read == 0 { - break; - } - - response_buffer.extend_from_slice(&chunk[..bytes_read]); - - if let Some(headers_end) = Self::find_double_crlf(&response_buffer) { - let body_start = headers_end + 4; - let headers_str = std::str::from_utf8(&response_buffer[..headers_end]) - .map_err(|_| io::Error::new(io::ErrorKind::InvalidData, "Invalid header encoding"))?; - - if !headers_str.starts_with("HTTP/1.1 200") && !headers_str.starts_with("HTTP/1.0 200") { - return Err(io::Error::new(io::ErrorKind::Other, format!("HTTP Error: {}", headers_str.lines().next().unwrap_or("Unknown")))); - } - - let file_path = Path::new(cache_dir).join("INDEX.tar.gz"); - let mut file = File::create(&file_path)?; - file.write_all(&response_buffer[body_start..])?; - while let Ok(bytes_read) = stream.read(&mut chunk).await { - if bytes_read == 0 { - break; - } - file.write_all(&chunk[..bytes_read])?; - } - - file.flush()?; - break; - } - } - - Ok(true) - } - - fn find_double_crlf(buf: &[u8]) -> Option<usize> { - for i in 0..buf.len().saturating_sub(3) { - if buf[i] == b'\r' && buf[i+1] == b'\n' && buf[i+2] == b'\r' && buf[i+3] == b'\n' { - return Some(i); - } - } - None - } -}
\ No newline at end of file diff --git a/src/i2impl/mod.rs b/src/i2impl/mod.rs deleted file mode 100644 index 4fa58ff..0000000 --- a/src/i2impl/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod mi2p;
\ No newline at end of file diff --git a/src/main.rs b/src/main.rs index c38d265..463bd24 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,14 +1,13 @@ mod cfg; -mod i2impl; +mod net; mod pkgtoolkit; use crate::cfg::config::Config; #[allow(unused_imports)] use crate::pkgtoolkit::pkgtools::Package; -use crate::i2impl::mi2p::I2P; +use crate::net::i2p_package::I2PPackage; use clap::{Args, Command, Parser, Subcommand}; -use yosemite::Stream; use std::io::Write; use std::path::Path; use std::fs::create_dir_all; @@ -41,6 +40,9 @@ enum Commands { Install{ pkgname: String, source: Option<String>, + #[command(flatten)] + args: RemoteInstallArgs + }, #[command(about = "Uninstall package")] Uninstall{ @@ -62,12 +64,13 @@ enum Commands { #[derive(Args, Clone)] #[command(about = "Remote install arguments")] -struct RemoteInstallArgs { - verbose: bool, - debug: bool, +struct RemoteInstallArgs { + #[arg(short = 'b', long = "bin" )] bin: bool, - source: bool, - i2p: bool, + #[arg(short = 'h', long = "http" )] + http: bool, + #[arg(short = 'c', long = "clean" )] + clean: bool } #[tokio::main] @@ -85,7 +88,7 @@ async fn main() -> Result<(), std::io::Error> { println!("Building {}", pkgname); return Ok(()) }, - Commands::Install { pkgname, source} => { + Commands::Install { pkgname, source, args} => { println!("Installing {}", pkgname); return Ok(()) }, @@ -109,9 +112,9 @@ async fn main() -> Result<(), std::io::Error> { log::warn!("Writing the default config to /etc/mesk/mesk.toml"); let path = Path::new("/etc/mesk/mesk.toml"); - create_dir_all(path.parent().unwrap()).unwrap(); - let mut file = File::create(path).unwrap(); - file.write(config.as_bytes()).unwrap(); + create_dir_all(path.parent().unwrap())?; + let mut file = File::create(path)?; + file.write(config.as_bytes())?; println!("Config tool ending work."); } else { @@ -124,9 +127,9 @@ async fn main() -> Result<(), std::io::Error> { log::warn!("Writing the default config to /etc/mesk/mesk.toml"); let path = Path::new("/etc/mesk/mesk.toml"); - create_dir_all(path.parent().unwrap()).unwrap(); - let mut file = File::create(path).unwrap(); - file.write_all(config.as_bytes()).unwrap(); + create_dir_all(path.parent().unwrap())?; + let mut file = File::create(path)?; + file.write_all(config.as_bytes())?; println!("Config tool ending work."); } @@ -135,8 +138,8 @@ async fn main() -> Result<(), std::io::Error> { Commands::Update => { let config = Config::parse().unwrap(); println!("Updating index from {}", config.repo.repo_url); - let mut i2pd = I2P::new(config); - let _index= I2P::fetch_index(&mut i2pd).await?; + let mut i2pd = I2PPackage::new(config); + let _index= I2PPackage::fetch_index(&mut i2pd).await?; println!("Index updated"); return Ok(()) }, diff --git a/src/net/http_packages.rs b/src/net/http_packages.rs new file mode 100644 index 0000000..1e3c6ad --- /dev/null +++ b/src/net/http_packages.rs @@ -0,0 +1,92 @@ +use reqwest; +use std::fs::File; +use std::io::Write; +use std::path::Path; +use crate::cfg::config::Config; + +pub struct HTTPPackage { + config: Config, +} + +impl HTTPPackage { + /// Creates a new Downloader object with the given configuration. + /// + /// # Arguments + /// + /// * `config` - The full mesk + /// + /// # Returns + /// + /// A new Downloader object with the given configuration. + pub fn new(config: Config) -> Self { + Self { config } + } + + /// Parse the mesk configuration file and return the Config object. + /// + /// This function reads the file at `config_path`, parses it and returns the Config object. + /// + /// # Arguments + /// + /// * `config_path` - A string representing the path to the mesk configuration file. + /// + /// # Returns + /// + /// A new Config object with the parsed configuration. If there's an error while reading or parsing the file, returns an Err containing a Box<dyn std::error::Error>. + pub fn parse_config(config_path: &str) -> Result<Config, Box<dyn std::error::Error>> { + let config = Config::parse()?; + Ok(config) + } + + + /// Downloads the INDEX.tar.gz file from the configured repository + /// and stores it in the configured cache directory. + /// + /// # Errors + /// + /// Returns an error if the request fails, if the response status is not successful, or if there's an issue while reading or writing the file. + /// + pub async fn fetch_index_http(&mut self) -> Result<bool, std::io::Error> { + let repo_url_str = &self.config.repo.repo_url; + let cache_dir = &self.config.paths.cache_dir; + + let index_url = if repo_url_str.ends_with(".tar.gz") { + repo_url_str.clone() + } else { + format!("{}/INDEX.tar.gz", repo_url_str.trim_end_matches('/')) + }; + + let client = reqwest::Client::new(); + + let response = client + .get(&index_url) + .send() + .await + .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, format!("Request failed: {}", e)))?; + + if !response.status().is_success() { + return Err(std::io::Error::new( + std::io::ErrorKind::Other, + format!("HTTP Error: {}", response.status()), + )); + } + + let index_data = response + .bytes() + .await + .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, format!("Failed to read response body: {}", e)))? + .to_vec(); + + let file_path = Path::new(cache_dir).join("INDEX.tar.gz"); + + let mut file = File::create(&file_path) + .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, format!("Failed to create file: {}", e)))?; + file.write_all(&index_data) + .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, format!("Failed to write file: {}", e)))?; + file.flush() + .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, format!("Failed to flush file: {}", e)))?; + + Ok(true) + } +} + diff --git a/src/net/i2p_package.rs b/src/net/i2p_package.rs new file mode 100644 index 0000000..2776eea --- /dev/null +++ b/src/net/i2p_package.rs @@ -0,0 +1,120 @@ + +use crate::cfg::config::Config; + +use tokio; +/* +use emissary_core::runtime::{ + AsyncRead, + AsyncWrite, +}; +*/ + +use std::{fs::File, + path::Path, + io::Write}; +// use emissary_core::Profile; +// use emissary_core::i2np::Message; +use tokio::io::{AsyncReadExt, + AsyncWriteExt, + BufReader}; + +use yosemite::SessionOptions; +use yosemite::{Session, style::Stream}; +use url; + +pub struct I2PPackage { + config: Config, + +} + + +impl I2PPackage { + /// Creates a new I2P object with the given configuration. + /// + /// # Returns + /// + /// A new I2P object with the given configuration. The session is initially set to None and the connected status is set to false. + pub fn new(config: Config) -> Self { + I2PPackage{ + + config: config, + } + } + + + /// Downloads the INDEX.tar.gz file from the configured repository + /// and stores it in the configured cache directory. + /// + /// # Errors + /// + /// Returns an error if the request fails, if the response status is not successful, or if there's an issue while reading or writing the file. + pub async fn fetch_index(&mut self) -> Result<bool, std::io::Error> { + let repo_url_str = &self.config.repo.repo_url; + let cache_dir = &self.config.paths.cache_dir; + + let url = url::Url::parse(repo_url_str) + .map_err(|_| std::io::Error::new(std::io::ErrorKind::InvalidInput, "Invalid repo URL"))?; + + let host = url.host_str() + .ok_or_else(|| std::io::Error::new(std::io::ErrorKind::InvalidInput, "No host in URL"))?; + + let request_path = url.path(); + let request_path = if request_path.ends_with(".tar.gz") { + request_path.to_string() + } else { + format!("{}/INDEX.tar.gz", request_path.trim_end_matches('/')) + }; + + let sam_host = "127.0.0.1"; + let sam_port = 7656; + let session_options = SessionOptions::default(); + let mut session = Session::new(session_options).await + .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, format!("Failed to create SAM session: {}", e)))?; + + let mut stream = session.connect(host).await + .map_err(|e| std::io::Error::new(std::io::ErrorKind::ConnectionAborted, format!("Failed to connect: {}", e)))?; + + let request = format!( + "GET {} HTTP/1.1\r\nHost: {}\r\nConnection: close\r\n\r\n", + request_path, host + ); + + + stream.write_all(request.as_bytes()).await + .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, format!("Failed to write request: {}", e)))?; + + let mut reader = BufReader::new(stream); + let mut response_buffer = Vec::new(); + reader.read_to_end(&mut response_buffer).await + .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, format!("Failed to read response: {}", e)))?; + + + let headers_end = response_buffer + .windows(4) + .position(|window| window == b"\r\n\r\n") + .ok_or_else(|| std::io::Error::new(std::io::ErrorKind::InvalidData, "Invalid response: no headers end"))?; + + let headers_str = std::str::from_utf8(&response_buffer[..headers_end]) + .map_err(|_| std::io::Error::new(std::io::ErrorKind::InvalidData, "Invalid header encoding"))?; + + if !headers_str.starts_with("HTTP/1.1 200") && !headers_str.starts_with("HTTP/1.0 200") { + return Err(std::io::Error::new( + std::io::ErrorKind::Other, + format!("HTTP Error: {}", headers_str.lines().next().unwrap_or("Unknown")), + )); + } + + let body_start = headers_end + 4; + let file_path = Path::new(cache_dir).join("INDEX.tar.gz"); + + + let mut file = File::create(&file_path) + .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, format!("Failed to create file: {}", e)))?; + file.write_all(&response_buffer[body_start..]) + .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, format!("Failed to write file: {}", e)))?; + file.flush() + .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, format!("Failed to flush file: {}", e)))?; + + Ok(true) + } +} diff --git a/src/i2impl/i2tools.rs b/src/net/i2p_tools.rs index e69de29..e69de29 100644 --- a/src/i2impl/i2tools.rs +++ b/src/net/i2p_tools.rs diff --git a/src/net/mod.rs b/src/net/mod.rs new file mode 100644 index 0000000..54f5e7f --- /dev/null +++ b/src/net/mod.rs @@ -0,0 +1,2 @@ +pub mod i2p_package; +pub mod http_packages;
\ No newline at end of file diff --git a/src/pkgtoolkit/pkgtools.rs b/src/pkgtoolkit/pkgtools.rs index 5acbd11..cfd3d59 100644 --- a/src/pkgtoolkit/pkgtools.rs +++ b/src/pkgtoolkit/pkgtools.rs @@ -6,8 +6,10 @@ use std::{ io, path::Path, process::Command, - str}; + str, + os::unix::fs::PermissionsExt}; + use emissary_core::i2np::tunnel::build; // use emissary_core::i2np::tunnel::build; use flate2::read::GzDecoder; use serde::{Deserialize, Serialize}; @@ -81,44 +83,74 @@ impl archs { #[allow(dead_code)] impl Package { - fn builder_backend(&mut self) -> Result<bool, std::io::Error> { - let config: Config = Config::parse().unwrap(); - let metadata = Self::loadmeta(self).unwrap(); - let path = Path::new(&config.paths.cache_dir).join(format!("{}-{}/BUILD", metadata.0.package.name, metadata.0.package.version)); - let _ = create_dir_all(&path); - - if metadata.2.is_none() { - Err(std::io::Error::new(std::io::ErrorKind::NotFound, "BUILD file not found"))? - } - - match metadata.2.unwrap().build_system { + /// Execute the build script for the package. + /// + /// This function takes the `Build` meta information as an argument and + /// executes the build script accordingly. It also handles the different + /// build systems supported (Make, CMake, Meson, Cargo). + /// + /// # Errors + /// + /// Returns an error if the build command fails. + fn execute_build(&self, build_meta: &Build) -> Result<(), std::io::Error> { + let config = Config::parse() + .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; + let build_dir = Path::new(&config.paths.cache_dir) + .join(format!("{}-{}", self.name, self.version)); + + let mut cmd = match build_meta.build_system { BuildSystems::Make => { - let _setup = Command::new("make") - .arg("all") - .arg("all") - .output(); + let mut c = Command::new("make"); + c.current_dir(&build_dir); + if build_meta.script.is_some() { + c.arg("-f").arg(build_meta.script.as_ref().unwrap()); + } + c.arg("all"); + c } - BuildSystems::CMake => { - let _setup = Command::new("cmake") - .arg("-S") - .arg(&path) - .arg("-B") - .arg(&path) - .output(); - - let _make = Command::new("make") - .arg("-C") - .arg(&path) - .output(); + let build_dir_build = build_dir.join("build"); + create_dir_all(&build_dir_build)?; + let mut c = Command::new("cmake"); + c.arg("-S").arg(&build_dir) + .arg("-B").arg(&build_dir_build) + .current_dir(&build_dir); + c } - - _ => { - Err(std::io::Error::new(std::io::ErrorKind::NotFound, "BUILD file not found"))? + BuildSystems::Meson => { + let build_dir_build = build_dir.join("build"); + create_dir_all(&build_dir_build)?; + let mut c = Command::new("meson"); + c.arg("setup") + .arg(&build_dir_build) + .current_dir(&build_dir); + c + } + BuildSystems::Cargo => { + let mut c = Command::new("cargo"); + c.arg("build") + .arg("--release") + .current_dir(&build_dir); + c } + }; + + let output = cmd.output().map_err(|e| { + std::io::Error::new( + std::io::ErrorKind::Other, + format!("Build command failed: {}", e), + ) + })?; + + if !output.status.success() { + let stderr = String::from_utf8_lossy(&output.stderr); + return Err(std::io::Error::new( + std::io::ErrorKind::Other, + format!("Build failed:\n{}", stderr), + )); } - Ok(true) + Ok(()) } /// Extracts a .tar.gz archive to the cache directory specified in Config. @@ -366,15 +398,116 @@ impl Package { } Strategies::SOURCE => { log::info!("Strategy: SOURCE; Running default build hook."); - todo!(); + let _ = self.execute_build(&build_meta.unwrap()); } } Ok(true) } - pub fn install() -> Result<bool, std::io::Error> { - todo!(); - } + + + /// Installs the package according to the INSTALL file in the archive. + /// + /// There are two strategies for installing the package. If the BUILD file is empty, the package is assumed to be a binary package and the default install hook is skipped. If the BUILD file is not empty, the package is assumed to be a source package and the default build hook is skipped. + /// + /// If the BUILD file is empty and the INSTALL file contains a custom script, the custom script is run instead of the default install hook. + /// If the BUILD file is not empty and the INSTALL file contains a custom script, the custom script is ignored. + /// + /// # Errors + /// + /// Returns an error if the BUILD file is invalid or if the build or install hook fails. + pub fn install(&mut self) -> Result<bool, std::io::Error> { + let config = Config::parse() + .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; + let (install_meta, _setts_meta, build_meta) = Self::loadmeta(self) + .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; + + + let is_build_present_and_not_empty = build_meta.is_some(); + + if is_build_present_and_not_empty { + log::info!("Found BUILD file, preparing to build and install package: {}", self.name); + let build_meta_ref = build_meta.as_ref().unwrap(); + self.execute_build(build_meta_ref); + + + if matches!(build_meta_ref.build_system, BuildSystems::Make) { + log::info!("Running 'make install' for package: {}", self.name); + let build_dir = Path::new(&config.paths.cache_dir) + .join(format!("{}-{}", self.name, self.version)); + let output = Command::new("make") + .arg("install") + .current_dir(&build_dir) + .output() + .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, format!("'make install' failed: {}", e)))?; + + if !output.status.success() { + let stderr = String::from_utf8_lossy(&output.stderr); + return Err(std::io::Error::new( + std::io::ErrorKind::Other, + format!("'make install' failed:\n{}", stderr), + )); + } + } + } else { + log::info!("No BUILD file or it's empty. Treating as binary package. Installing via INSTALL config or custom script."); + // Установка бинарного пакета + if let Some(ref script) = install_meta.custom_script { + log::info!("Executing custom install script for {}", install_meta.package.name); + let status = if script.starts_with("./") || script.contains('/') { + Command::new("/bin/sh").arg("-c").arg(script).status() + } else { + Command::new(script).status() + } + .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, format!("Failed to run custom script: {}", e)))?; + + if !status.success() { + return Err(std::io::Error::new( + std::io::ErrorKind::Other, + "Custom install script failed", + )); + } + } else { + log::info!("No custom script. Running default install hook for {}", install_meta.package.name); + // --- Дефолтный хук установки --- + // 1. Копируем файл из build_dir (предположим, что бинарный файл лежит в корне распакованного архива) + let source_file_name = &self.name; // Предполагаем имя файла = имя пакета + let build_dir = Path::new(&config.paths.cache_dir) + .join(format!("{}-{}", self.name, self.version)); + let src_path = build_dir.join(source_file_name); + let dest_path = Path::new(&install_meta.path); + + // Убедимся, что целевая директория существует + if let Some(parent) = dest_path.parent() { + create_dir_all(parent) + .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, format!("Failed to create parent dir: {}", e)))?; + } + + fs::copy(&src_path, dest_path) + .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, format!("Failed to copy file: {}", e)))?; + + let mode = u32::from_str_radix(&install_meta.mode, 8) + .map_err(|_| std::io::Error::new(std::io::ErrorKind::InvalidData, "Invalid mode string in INSTALL"))?; + let perms = PermissionsExt::from_mode(mode); + fs::set_permissions(dest_path, perms) + .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, format!("Failed to set permissions: {}", e)))?; + + let output = Command::new("chown") + .arg(&format!("{}:{}", install_meta.user, install_meta.group)) + .arg(dest_path) + .output() + .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, format!("'chown' command failed: {}", e)))?; + + if !output.status.success() { + let stderr = String::from_utf8_lossy(&output.stderr); + log::warn!("Warning: 'chown' command failed (requires root?):\n{}", stderr); + } + } + } + + log::info!("Package {} installed successfully.", self.name); + Ok(true) + } pub fn gen_index() -> Result<bool, std::io::Error> { todo!(); |
