diff --git a/ngrok-java-native/Cargo.lock b/ngrok-java-native/Cargo.lock index 992b487..4c2e088 100644 --- a/ngrok-java-native/Cargo.lock +++ b/ngrok-java-native/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "aho-corasick" @@ -47,10 +47,47 @@ dependencies = [ ] [[package]] -name = "base64" -version = "0.13.1" +name = "aws-lc-rs" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" +checksum = "048006790404103c488e6c5616b3e7e702a71292aadda08e8f7698a9e0d2eb53" +dependencies = [ + "aws-lc-sys", + "zeroize", +] + +[[package]] +name = "aws-lc-sys" +version = "0.47.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8bfbe32ac36b3c428696ce315464181bc4029d689fd58e3f2a4e58c252242f52" +dependencies = [ + "cc", + "cmake", + "dunce", + "fs_extra", + "pkg-config", +] + +[[package]] +name = "axum-core" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09f2bd6146b97ae3359fa0cc6d6b376d9539582c7b4220f041a33ec24c226199" +dependencies = [ + "async-trait", + "bytes", + "futures-util", + "http", + "http-body", + "http-body-util", + "mime", + "pin-project-lite", + "rustversion", + "sync_wrapper", + "tower-layer", + "tower-service", +] [[package]] name = "base64" @@ -72,9 +109,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.6.0" +version = "2.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" +checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" [[package]] name = "block-buffer" @@ -85,17 +122,11 @@ dependencies = [ "generic-array", ] -[[package]] -name = "bumpalo" -version = "3.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" - [[package]] name = "bytes" -version = "1.4.0" +version = "1.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" +checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04" [[package]] name = "cafebabe" @@ -109,9 +140,15 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.6" +version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aba8f4e9906c7ce3c73463f62a7f0c65183ada1a2d47e397cc8810827f9694f" +checksum = "33ef9e3e8154a45c7a95cff4c1299702106ad94062d7bb85fdc5d3a5afd91d45" +dependencies = [ + "find-msvc-tools", + "jobserver", + "libc", + "shlex", +] [[package]] name = "cesu8" @@ -131,6 +168,26 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chacha20" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65c35e4b699c7e15ccbe7ee35c005e4fc0a278d22238a2857e6ce2dadeda1b06" +dependencies = [ + "cfg-if 1.0.0", + "cpufeatures 0.3.1", + "rand_core 0.10.1", +] + +[[package]] +name = "cmake" +version = "0.1.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0f78a02292a74a88ac736019ab962ece0bc380e3f977bf72e376c5d78ff0678" +dependencies = [ + "cc", +] + [[package]] name = "combine" version = "4.6.6" @@ -151,11 +208,21 @@ dependencies = [ "libc", ] +[[package]] +name = "core-foundation" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "core-foundation-sys" -version = "0.8.4" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "cpufeatures" @@ -167,22 +234,22 @@ dependencies = [ ] [[package]] -name = "crypto-common" -version = "0.1.6" +name = "cpufeatures" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +checksum = "5ca28b0ae3115b884660db4118d803791fd6756b6e88f39c0f3f7859060d7566" dependencies = [ - "generic-array", - "typenum", + "libc", ] [[package]] -name = "ct-logs" -version = "0.8.0" +name = "crypto-common" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1a816186fa68d9e426e3cb4ae4dff1fcd8e4a2c34b781bf7a822574a0d0aac8" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ - "sct", + "generic-array", + "typenum", ] [[package]] @@ -201,6 +268,12 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" +[[package]] +name = "dunce" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" + [[package]] name = "either" version = "1.9.0" @@ -220,10 +293,10 @@ dependencies = [ ] [[package]] -name = "fnv" -version = "1.0.7" +name = "find-msvc-tools" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +checksum = "1c66915cc5391097de7a2b0b972e8505aa33c0df401fd3a6811dbdb32881ba48" [[package]] name = "form_urlencoded" @@ -234,6 +307,12 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "fs_extra" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" + [[package]] name = "futures" version = "0.3.28" @@ -251,9 +330,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.28" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" +checksum = "b1f9e3d69d39e4862ffed03ed071a76f9a13ba1d9109d355b0f0aa6b15e393c4" dependencies = [ "futures-core", "futures-sink", @@ -261,9 +340,9 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.28" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" +checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e" [[package]] name = "futures-executor" @@ -278,49 +357,49 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.28" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" +checksum = "53c0fa8157de1303bfffdaa1cc2a673bfffb60102f76b0ef4441659124373fed" [[package]] name = "futures-macro" -version = "0.3.28" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" +checksum = "9fb9654ba8355388abeb8dcb4fc62f511300867002afc858860463bdd9fe0c44" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 3.0.10", ] [[package]] name = "futures-rustls" -version = "0.25.1" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8d8a2499f0fecc0492eb3e47eab4e92da7875e1028ad2528f214ac3346ca04e" +checksum = "a8f2f12607f92c69b12ed746fabf9ca4f5c482cba46679c1a75b874ed7c26adb" dependencies = [ "futures-io", - "rustls 0.22.4", + "rustls", "rustls-pki-types", ] [[package]] name = "futures-sink" -version = "0.3.28" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" +checksum = "1944426bf7d03f1d14f708785e4b33efd750b36d48a157b836b3efc15ede8e1d" [[package]] name = "futures-task" -version = "0.3.28" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" +checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd" [[package]] name = "futures-util" -version = "0.3.28" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" +checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc" dependencies = [ "futures-channel", "futures-core", @@ -330,7 +409,6 @@ dependencies = [ "futures-task", "memchr", "pin-project-lite", - "pin-utils", "slab", ] @@ -364,14 +442,25 @@ dependencies = [ "wasi", ] +[[package]] +name = "getrandom" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "r-efi", + "rand_core 0.10.1", +] + [[package]] name = "headers" -version = "0.3.8" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3e372db8e5c0d213e0cd0b9be18be2aca3d44cf2fe30a9d46a65581cd454584" +checksum = "fc2700e3fe555c3310aa7286cac6167449f2c87e0eb58769c9208a1c58a1d106" dependencies = [ - "base64 0.13.1", - "bitflags 1.3.2", + "base64 0.22.1", "bytes", "headers-core", "http", @@ -382,9 +471,9 @@ dependencies = [ [[package]] name = "headers-core" -version = "0.2.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7f66481bfee273957b1f20485a4ff3362987f85b2c236580d81b4eb7a326429" +checksum = "54b4a22553d4242c49fddb9ba998a99962b5cc6f22cb5a3482bec22522403ce4" dependencies = [ "http", ] @@ -395,15 +484,6 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" -[[package]] -name = "hermit-abi" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" -dependencies = [ - "libc", -] - [[package]] name = "hostname" version = "0.3.1" @@ -417,31 +497,36 @@ dependencies = [ [[package]] name = "http" -version = "0.2.9" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" +checksum = "918d3568bebf352712bc2ef3d46a8bcf1a75b373be6539de198e9105cbbf9ce0" dependencies = [ "bytes", - "fnv", "itoa", ] [[package]] name = "http-body" -version = "0.4.5" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" +checksum = "ca2a8f2913ee65f60facd6a5905613afaa448497a0230cc41ce022d93290bc2c" dependencies = [ "bytes", "http", - "pin-project-lite", ] [[package]] -name = "httparse" -version = "1.8.0" +name = "http-body-util" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" +checksum = "23169fe34a5fbcdd3f3862e78fb9b6fccd5f02a6dc6f732547005d45631ce71c" +dependencies = [ + "bytes", + "futures-core", + "http", + "http-body", + "pin-project-lite", +] [[package]] name = "httpdate" @@ -451,61 +536,71 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hyper" -version = "0.14.27" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468" +checksum = "fb5aa53871fc917b1a9ed87b683a5d86db645e23acb32c2e0785a353e522fb75" dependencies = [ "bytes", - "futures-channel", - "futures-core", - "futures-util", "http", "http-body", - "httparse", - "httpdate", - "itoa", "pin-project-lite", - "socket2", "tokio", - "tower-service", - "tracing", "want", ] [[package]] -name = "hyper-proxy" -version = "0.9.1" +name = "hyper-http-proxy" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca815a891b24fdfb243fa3239c86154392b0953ee584aa1a2a1f66d20cbe75cc" +checksum = "bd1d471ea2f65ba45eddb1d6ab7d58ac2671d2d4ac14da5c6516ae1d97e1327a" dependencies = [ "bytes", - "futures", + "futures-util", "headers", "http", "hyper", "hyper-rustls", - "rustls-native-certs 0.5.0", + "hyper-util", + "pin-project-lite", "tokio", "tokio-rustls", "tower-service", - "webpki", ] [[package]] name = "hyper-rustls" -version = "0.22.1" +version = "0.27.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f9f7a97316d44c0af9b0301e65010573a853a9fc97046d7331d7f6bc0fd5a64" +checksum = "dfa8e654703247911e29c23fbeaa261834bd9bb74efba2f9acddc37bfb127f53" dependencies = [ - "ct-logs", - "futures-util", + "http", "hyper", - "log", - "rustls 0.19.1", - "rustls-native-certs 0.5.0", + "hyper-util", + "rustls", + "rustls-native-certs 0.8.5", "tokio", "tokio-rustls", - "webpki", + "tower-service", +] + +[[package]] +name = "hyper-util" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca38ef113da30126bbff9cd1705f9273e15d45498615d138b0c20279ac7a76aa" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http", + "http-body", + "hyper", + "pin-project-lite", + "socket2 0.5.10", + "tokio", + "tower", + "tower-service", + "tracing", ] [[package]] @@ -527,7 +622,7 @@ checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" [[package]] name = "jaffi" version = "0.2.0" -source = "git+https://github.com/ngrok-oss/jaffi.git?branch=josh/lower-jni-version#131d4bbff0b4aed69fe5a8fe53920c8974d5d357" +source = "git+https://github.com/ngrok-oss/jaffi.git?branch=josh%2Flower-jni-version#131d4bbff0b4aed69fe5a8fe53920c8974d5d357" dependencies = [ "cafebabe", "enum-as-inner", @@ -535,14 +630,14 @@ dependencies = [ "jaffi_support", "proc-macro2", "quote", - "thiserror", + "thiserror 1.0.40", "typed-builder", ] [[package]] name = "jaffi_support" version = "0.2.0" -source = "git+https://github.com/ngrok-oss/jaffi.git?branch=josh/lower-jni-version#131d4bbff0b4aed69fe5a8fe53920c8974d5d357" +source = "git+https://github.com/ngrok-oss/jaffi.git?branch=josh%2Flower-jni-version#131d4bbff0b4aed69fe5a8fe53920c8974d5d357" dependencies = [ "jni", ] @@ -557,7 +652,7 @@ dependencies = [ "combine", "jni-sys", "log", - "thiserror", + "thiserror 1.0.40", "walkdir", ] @@ -568,12 +663,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" [[package]] -name = "js-sys" -version = "0.3.61" +name = "jobserver" +version = "0.1.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730" +checksum = "1c00acbd29eabad4a2392fa0e921c874934dbbf4194312ad20f04a0ed67a3cb3" dependencies = [ - "wasm-bindgen", + "getrandom 0.4.3", + "libc", ] [[package]] @@ -584,9 +680,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.155" +version = "0.2.191" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a" [[package]] name = "lock_api" @@ -636,21 +732,20 @@ checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "mio" -version = "0.8.6" +version = "1.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9" +checksum = "20521a903f02b0a573cd6840e9d0a5a0cc043d361fe924092cd70f8556cc9c4a" dependencies = [ "libc", - "log", "wasi", - "windows-sys 0.45.0", + "windows-sys 0.61.2", ] [[package]] name = "muxado" -version = "0.4.0" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e92b89ac3127251efde6f5a9586e5aae99468d06fcf9f133b377f58d5ed66446" +checksum = "8ac23a4a060b60ba42de5e988886790ba6aeb86e0ae0c879c637f5bbf0b78299" dependencies = [ "async-trait", "awaitdrop", @@ -658,8 +753,8 @@ dependencies = [ "bytes", "futures", "pin-project", - "rand", - "thiserror", + "rand 0.8.5", + "thiserror 2.0.21", "tokio", "tokio-util", "tracing", @@ -667,24 +762,25 @@ dependencies = [ [[package]] name = "ngrok" -version = "0.14.0-pre.14" +version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83a8b346f2afafd32076a1a63698c185ec18c5ff3a3c58a6eb1283e94eece59e" +checksum = "cc448f204f9e168e07f71ee16b8462591408315dc0d3dc3b6977bdb4a0d12f68" dependencies = [ "arc-swap", "async-trait", "awaitdrop", + "axum-core", "base64 0.21.7", - "bitflags 2.6.0", + "bitflags 2.13.2", "bytes", "futures", "futures-rustls", + "futures-util", "hostname", - "hyper", - "hyper-proxy", + "hyper-http-proxy", + "hyper-util", "muxado", "once_cell", - "parking_lot", "pin-project", "proxy-protocol", "regex", @@ -692,11 +788,12 @@ dependencies = [ "rustls-pemfile", "serde", "serde_json", - "thiserror", + "thiserror 2.0.21", "tokio", "tokio-retry", "tokio-socks", "tokio-util", + "tower-service", "tracing", "url", "windows-sys 0.45.0", @@ -729,16 +826,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "num_cpus" -version = "1.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" -dependencies = [ - "hermit-abi", - "libc", -] - [[package]] name = "once_cell" version = "1.17.1" @@ -751,6 +838,12 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" +[[package]] +name = "openssl-probe" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e036b411754132fd6b74e94b74e9a13c5cf606fa93d1885c35860d3060820b1" + [[package]] name = "overload" version = "0.1.1" @@ -808,15 +901,15 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.9" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" [[package]] -name = "pin-utils" -version = "0.1.0" +name = "pkg-config" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +checksum = "f6b464fbc74e149a392436b17d523f769e057cb6877f6a5c4618bc6f11800548" [[package]] name = "ppv-lite86" @@ -826,9 +919,9 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro2" -version = "1.0.67" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d433d9f1a3e8c1263d9456598b16fec66f4acc9a74dacffd35c7bb09b3a1328" +checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" dependencies = [ "unicode-ident", ] @@ -845,13 +938,19 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.26" +version = "1.0.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" +checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" dependencies = [ "proc-macro2", ] +[[package]] +name = "r-efi" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" + [[package]] name = "rand" version = "0.8.5" @@ -860,7 +959,18 @@ checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", "rand_chacha", - "rand_core", + "rand_core 0.6.4", +] + +[[package]] +name = "rand" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f6fa277c67e6ea590466f04c3fe82cb509f0864fe470643e5570de9514a9b11" +dependencies = [ + "chacha20", + "getrandom 0.4.3", + "rand_core 0.10.1", ] [[package]] @@ -870,7 +980,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core", + "rand_core 0.6.4", ] [[package]] @@ -879,9 +989,15 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom", + "getrandom 0.2.15", ] +[[package]] +name = "rand_core" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69" + [[package]] name = "redox_syscall" version = "0.2.16" @@ -917,21 +1033,6 @@ version = "0.6.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" -[[package]] -name = "ring" -version = "0.16.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" -dependencies = [ - "cc", - "libc", - "once_cell", - "spin 0.5.2", - "untrusted 0.7.1", - "web-sys", - "winapi", -] - [[package]] name = "ring" version = "0.17.8" @@ -940,33 +1041,22 @@ checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" dependencies = [ "cc", "cfg-if 1.0.0", - "getrandom", + "getrandom 0.2.15", "libc", - "spin 0.9.8", - "untrusted 0.9.0", + "spin", + "untrusted", "windows-sys 0.52.0", ] [[package]] name = "rustls" -version = "0.19.1" +version = "0.23.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35edb675feee39aec9c99fa5ff985081995a06d594114ae14cbe797ad7b7a6d7" +checksum = "48e13bd8c0e9365c43cfa5c9e8f9ad49d3c8444926c9aac819e0e4dc503c8fdf" dependencies = [ - "base64 0.13.1", + "aws-lc-rs", "log", - "ring 0.16.20", - "sct", - "webpki", -] - -[[package]] -name = "rustls" -version = "0.22.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf4ef73721ac7bcd79b2b315da7779d8fc09718c6b3d2d1b2d94850eb8c18432" -dependencies = [ - "ring 0.17.8", + "once_cell", "rustls-pki-types", "rustls-webpki", "subtle", @@ -975,27 +1065,27 @@ dependencies = [ [[package]] name = "rustls-native-certs" -version = "0.5.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a07b7c1885bd8ed3831c289b7870b13ef46fe0e856d288c30d9cc17d75a2092" +checksum = "a88d6d420651b496bdd98684116959239430022a115c1240e6c3993be0b15fba" dependencies = [ - "openssl-probe", - "rustls 0.19.1", + "openssl-probe 0.1.5", + "rustls-pemfile", + "rustls-pki-types", "schannel", - "security-framework", + "security-framework 2.9.2", ] [[package]] name = "rustls-native-certs" -version = "0.7.1" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a88d6d420651b496bdd98684116959239430022a115c1240e6c3993be0b15fba" +checksum = "4a073f5dc7469f984c52ad2752b63b0807745133b6de880b7b64c1ac4c48aec4" dependencies = [ - "openssl-probe", - "rustls-pemfile", + "openssl-probe 0.2.2", "rustls-pki-types", "schannel", - "security-framework", + "security-framework 3.7.0", ] [[package]] @@ -1010,21 +1100,31 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.7.0" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d" +checksum = "102f35f7de7b06d8c61f1cff6592f5253e0dea431c74867aad5dfd70f44663fb" +dependencies = [ + "zeroize", +] [[package]] name = "rustls-webpki" -version = "0.102.6" +version = "0.103.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e6b52d4fda176fd835fdc55a835d4a89b8499cad995885a21149d5ad62f852e" +checksum = "e3a0760a887c14823fca5a1c970b01d47c328c696c0c64829d1df50e8f853fd5" dependencies = [ - "ring 0.17.8", + "aws-lc-rs", + "ring", "rustls-pki-types", - "untrusted 0.9.0", + "untrusted", ] +[[package]] +name = "rustversion" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f" + [[package]] name = "ryu" version = "1.0.13" @@ -1056,23 +1156,26 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] -name = "sct" -version = "0.6.1" +name = "security-framework" +version = "2.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b362b83898e0e69f38515b82ee15aa80636befe47c3b6d3d89a911e78fc228ce" +checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de" dependencies = [ - "ring 0.16.20", - "untrusted 0.7.1", + "bitflags 1.3.2", + "core-foundation 0.9.3", + "core-foundation-sys", + "libc", + "security-framework-sys", ] [[package]] name = "security-framework" -version = "2.9.2" +version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de" +checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d" dependencies = [ - "bitflags 1.3.2", - "core-foundation", + "bitflags 2.13.2", + "core-foundation 0.10.1", "core-foundation-sys", "libc", "security-framework-sys", @@ -1080,9 +1183,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.9.1" +version = "2.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a" +checksum = "6ce2691df843ecc5d231c0b14ece2acc3efb62c0a398c7e1d875f3983ce020e3" dependencies = [ "core-foundation-sys", "libc", @@ -1126,7 +1229,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" dependencies = [ "cfg-if 1.0.0", - "cpufeatures", + "cpufeatures 0.2.9", "digest", ] @@ -1139,6 +1242,12 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "shlex" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" + [[package]] name = "signal-hook-registry" version = "1.4.1" @@ -1195,19 +1304,23 @@ dependencies = [ [[package]] name = "socket2" -version = "0.4.9" +version = "0.5.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" +checksum = "e22376abed350d73dd1cd119b57ffccad95b4e585a7cda43e286245ce23c0678" dependencies = [ "libc", - "winapi", + "windows-sys 0.52.0", ] [[package]] -name = "spin" -version = "0.5.2" +name = "socket2" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" +checksum = "c3d1e2c7f27f8d4cb10542a02c49005dbd6e93095799d6f3be745fae9f8fedd4" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] [[package]] name = "spin" @@ -1243,13 +1356,39 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn" +version = "3.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sync_wrapper" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" + [[package]] name = "thiserror" version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" dependencies = [ - "thiserror-impl", + "thiserror-impl 1.0.40", +] + +[[package]] +name = "thiserror" +version = "2.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e" +dependencies = [ + "thiserror-impl 2.0.21", ] [[package]] @@ -1263,6 +1402,17 @@ dependencies = [ "syn 2.0.15", ] +[[package]] +name = "thiserror-impl" +version = "2.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.10", +] + [[package]] name = "thread_local" version = "1.1.7" @@ -1290,54 +1440,51 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.27.0" +version = "1.54.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0de47a4eecbe11f498978a9b29d792f0d2692d1dd003650c24c76510e3bc001" +checksum = "b52fd3255258d26fac7264ab5a76b53c13367136dc011d3d6ad4f8ed070396a3" dependencies = [ - "autocfg", "bytes", "libc", "mio", - "num_cpus", "parking_lot", "pin-project-lite", "signal-hook-registry", - "socket2", + "socket2 0.6.5", "tokio-macros", - "windows-sys 0.45.0", + "windows-sys 0.61.2", ] [[package]] name = "tokio-macros" -version = "2.0.0" +version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61a573bdc87985e9d6ddeed1b3d864e8a302c847e40d647746df2f1de209d1ce" +checksum = "78773a2a397f451582ce068015985c33193cf6dea8b74d2a639fe457b2f07b0e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 3.0.10", ] [[package]] name = "tokio-retry" -version = "0.3.0" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f57eb36ecbe0fc510036adff84824dd3c24bb781e21bfa67b69d556aa85214f" +checksum = "4a129d95275ebf4c493ec53bf0f8cd95f5ac161bc4f381700809a54f595d4470" dependencies = [ - "pin-project", - "rand", + "pin-project-lite", + "rand 0.10.4", "tokio", ] [[package]] name = "tokio-rustls" -version = "0.22.0" +version = "0.26.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc6844de72e57df1980054b38be3a9f4702aba4858be64dd700181a8a6d0e1b6" +checksum = "c9cc2678c2cdd569ef8215e2afd7954ada2ae20b4fdd2c5fe6139a3b02d105db" dependencies = [ - "rustls 0.19.1", + "rustls", "tokio", - "webpki", ] [[package]] @@ -1348,30 +1495,52 @@ checksum = "51165dfa029d2a65969413a6cc96f354b86b464498702f174a4efa13608fd8c0" dependencies = [ "either", "futures-util", - "thiserror", + "thiserror 1.0.40", "tokio", ] [[package]] name = "tokio-util" -version = "0.7.7" +version = "0.7.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5427d89453009325de0d8f342c9490009f76e999cb7672d77e46267448f7e6b2" +checksum = "e464cf451ba96ebfc6f9b6542f17ee8b8956e33f1e40d9690624e59d7a7f8a4b" dependencies = [ "bytes", "futures-core", "futures-io", "futures-sink", + "libc", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tower" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" +dependencies = [ + "futures-core", + "futures-util", + "pin-project", "pin-project-lite", "tokio", + "tower-layer", + "tower-service", "tracing", ] +[[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.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" [[package]] name = "tracing" @@ -1380,6 +1549,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" dependencies = [ "cfg-if 1.0.0", + "log", "pin-project-lite", "tracing-attributes", "tracing-core", @@ -1479,12 +1649,6 @@ dependencies = [ "tinyvec", ] -[[package]] -name = "untrusted" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" - [[package]] name = "untrusted" version = "0.9.0" @@ -1539,80 +1703,6 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" -[[package]] -name = "wasm-bindgen" -version = "0.2.84" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b" -dependencies = [ - "cfg-if 1.0.0", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.84" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9" -dependencies = [ - "bumpalo", - "log", - "once_cell", - "proc-macro2", - "quote", - "syn 1.0.109", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.84" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.84" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.84" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" - -[[package]] -name = "web-sys" -version = "0.3.61" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e33b99f4b23ba3eec1a53ac264e35a755f00e966e0065077d6027c0f575b0b97" -dependencies = [ - "js-sys", - "wasm-bindgen", -] - -[[package]] -name = "webpki" -version = "0.21.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8e38c0608262c46d4a56202ebabdeb094cef7e560ca7a226c6bf055188aa4ea" -dependencies = [ - "ring 0.16.20", - "untrusted 0.7.1", -] - [[package]] name = "winapi" version = "0.3.9" @@ -1644,6 +1734,12 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + [[package]] name = "windows-sys" version = "0.45.0" @@ -1671,6 +1767,15 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + [[package]] name = "windows-targets" version = "0.42.2" diff --git a/ngrok-java-native/Cargo.toml b/ngrok-java-native/Cargo.toml index c5ffb2a..3008fa8 100644 --- a/ngrok-java-native/Cargo.toml +++ b/ngrok-java-native/Cargo.toml @@ -13,7 +13,7 @@ jaffi_support = "0.2.0" once_cell = "1.17.1" futures = "0.3.25" bytes = "1.4.0" -ngrok = "0.14.0-pre.14" +ngrok = "0.19.1" tokio = { version = "1.26.0", features = ["full"] } async-trait = "0.1.59" tracing = "0.1.37" diff --git a/ngrok-java-native/src/lib.rs b/ngrok-java-native/src/lib.rs index 6636bc7..369dd4e 100644 --- a/ngrok-java-native/src/lib.rs +++ b/ngrok-java-native/src/lib.rs @@ -13,7 +13,7 @@ use com_ngrok::{ }; use futures::TryStreamExt; use once_cell::sync::OnceCell; -use std::{collections::HashMap, str::FromStr, sync::MutexGuard, time::Duration}; +use std::{collections::HashMap, num::NonZeroU32, str::FromStr, sync::MutexGuard, time::Duration}; use tokio::{io::AsyncReadExt, io::AsyncWriteExt, runtime::Runtime}; use tracing::{level_filters::LevelFilter, Level}; use tracing_subscriber::{prelude::__tracing_subscriber_SubscriberExt, util::SubscriberInitExt}; @@ -306,6 +306,56 @@ impl<'local> JavaUtilOptional<'local> { } } + /// The java.time.Duration this holds, to the nanosecond. Session.Builder + /// refuses negative durations, so a negative one here is a bug. + fn of_duration(self, env: JNIEnv<'local>) -> Option { + if self.is_present(env) { + let d = self.get(env).expect("cannot get duration"); + let secs = env + .call_method(d, "getSeconds", "()J", &[]) + .and_then(|o| o.j()) + .expect("cannot get duration seconds"); + let nanos = env + .call_method(d, "getNano", "()I", &[]) + .and_then(|o| o.i()) + .expect("cannot get duration nanos"); + Some(Duration::new( + secs.try_into().expect("duration must not be negative"), + nanos + .try_into() + .expect("duration nanos must not be negative"), + )) + } else { + None + } + } + + fn of_bool(self, env: JNIEnv<'local>) -> Option { + if self.is_present(env) { + let b = self + .get(env) + .and_then(|o| env.call_method(o, "booleanValue", "()Z", &[])) + .and_then(|o| o.z()) + .expect("could not get boolean"); + Some(b) + } else { + None + } + } + + fn of_int(self, env: JNIEnv<'local>) -> Option { + if self.is_present(env) { + let i = self + .get(env) + .and_then(|o| env.call_method(o, "intValue", "()I", &[])) + .and_then(|o| o.i()) + .expect("could not get int"); + Some(i) + } else { + None + } + } + fn get( self, env: JNIEnv<'local>, @@ -803,6 +853,30 @@ impl<'local> com_ngrok::NativeSessionRs<'local> for NativeSessionRsImpl<'local> bldr.heartbeat_tolerance(tolerance).map_err(io_exc)?; } + // Session.Builder.reconnectBackoff sets both or neither. + if let (Some(initial), Some(max)) = ( + jsb.get_reconnect_backoff_initial(self.env) + .of_duration(self.env), + jsb.get_reconnect_backoff_max(self.env) + .of_duration(self.env), + ) { + bldr.reconnect_backoff(initial, max) + .map_err(|e| io_exc(format!("reconnectBackoff: {e}")))?; + } + + if let Some(enabled) = jsb.get_reconnect_jitter(self.env).of_bool(self.env) { + bldr.reconnect_jitter(enabled); + } + + if let Some(attempts) = jsb.get_reconnect_max_attempts(self.env).of_int(self.env) { + // Session.Builder.reconnectMaxAttempts refuses anything below 1. + let attempts = u32::try_from(attempts) + .ok() + .and_then(NonZeroU32::new) + .expect("reconnect max attempts must be at least 1"); + bldr.reconnect_max_attempts(attempts); + } + let mut session_metadata = String::from(""); if let Some(metadata) = jsb.get_metadata(self.env).of_string(self.env) { session_metadata = metadata.clone(); diff --git a/ngrok-java-native/src/test/java/com/ngrok/ReconnectTest.java b/ngrok-java-native/src/test/java/com/ngrok/ReconnectTest.java new file mode 100644 index 0000000..ada8bd6 --- /dev/null +++ b/ngrok-java-native/src/test/java/com/ngrok/ReconnectTest.java @@ -0,0 +1,64 @@ +package com.ngrok; + +import org.junit.Test; + +import java.io.IOException; +import java.time.Duration; + +import static org.junit.Assert.*; + +public class ReconnectTest { + // connect() checks the reconnect options before it opens a connection. + // The server address is a local port so that, if that check were lost, + // the test fails on a refused connection rather than reaching ngrok. + private static IOException connectRefusal(Duration initial, Duration max) { + var builder = Session.withAuthtoken("unused") + .serverAddr("127.0.0.1:1") + .reconnectBackoff(initial, max); + return assertThrows(IOException.class, builder::connect); + } + + @Test + public void connectRefusesAStartBelowOneMillisecond() { + var e = connectRefusal(Duration.ZERO, Duration.ofSeconds(1)); + assertEquals("reconnectBackoff: invalid reconnect backoff (start 0ns, cap 1s): " + + "the start must be at least 1 ms", e.getMessage()); + } + + @Test + public void connectRefusesAStartJustBelowOneMillisecond() { + // A nanosecond short of 1 ms: truncating to whole milliseconds would + // turn this into 0 ms, so the start is shown as it was given. + var e = connectRefusal(Duration.ofNanos(999_999), Duration.ofSeconds(1)); + assertEquals("reconnectBackoff: invalid reconnect backoff (start 999.999µs, cap 1s): " + + "the start must be at least 1 ms", e.getMessage()); + } + + @Test + public void connectRefusesAStartAboveTheCap() { + var e = connectRefusal(Duration.ofSeconds(2), Duration.ofSeconds(1)); + assertEquals("reconnectBackoff: invalid reconnect backoff (start 2s, cap 1s): " + + "the start must not be above the cap", e.getMessage()); + } + + @Test + public void connectRefusesACapJustAboveOneDay() { + // One nanosecond over: truncating to whole milliseconds would accept it. + var e = connectRefusal(Duration.ofMillis(1), Duration.ofDays(1).plusNanos(1)); + assertEquals("reconnectBackoff: invalid reconnect backoff (start 1ms, cap 86400.000000001s): " + + "the cap must be at most one day", e.getMessage()); + } + + // Needs NGROK_AUTHTOKEN and the network, as DataTest does. + @Test + public void connectsWithEveryReconnectOptionSet() throws Exception { + try (var session = Session.withAuthtokenFromEnv() + .reconnectBackoff(Duration.ofMillis(100), Duration.ofSeconds(5)) + .reconnectJitter(false) + .reconnectMaxAttempts(5) + .connect(); + var listener = session.httpEndpoint().listen()) { + assertTrue(listener.getUrl(), listener.getUrl().startsWith("https://")); + } + } +} diff --git a/ngrok-java/src/main/java/com/ngrok/Session.java b/ngrok-java/src/main/java/com/ngrok/Session.java index da170de..72009ec 100644 --- a/ngrok-java/src/main/java/com/ngrok/Session.java +++ b/ngrok-java/src/main/java/com/ngrok/Session.java @@ -292,6 +292,12 @@ class Builder { private Optional heartbeatInterval = Optional.empty(); private Optional heartbeatTolerance = Optional.empty(); + // Both set together, by reconnectBackoff. + private Optional reconnectBackoffInitial = Optional.empty(); + private Optional reconnectBackoffMax = Optional.empty(); + private Optional reconnectJitter = Optional.empty(); + private Optional reconnectMaxAttempts = Optional.empty(); + private Optional metadata = Optional.empty(); private Optional serverAddr = Optional.empty(); @@ -331,6 +337,80 @@ public Builder heartbeatTolerance(Duration duration) { return this; } + /** + * Sets how long the session waits between attempts to reconnect after it + * loses its connection to the ngrok service. + *

+ * The first attempt is immediate. After it, the session waits {@code initial}, + * then twice as long before each attempt, up to {@code max}. Each wait is + * scaled by a random factor in [0, 1) unless {@link #reconnectJitter(boolean)} + * turns that off. The defaults are 50 ms and 30 s. For a fixed wait between + * every attempt, pass the same value for both and turn jitter off. + *

+ * These waits never stop the session from reconnecting on their own: + * {@link #reconnectMaxAttempts(int)}, or closing the session, does. + *

+ * The ngrok Rust SDK checks the range when the session connects: an + * {@code initial} below 1 ms or above {@code max}, or a {@code max} above one + * day, makes {@link #connect()} throw an {@link IOException} whose message + * starts with "reconnectBackoff: " and names the rule broken. + * + * @param initial the first wait between reconnect attempts + * @param max the longest wait between reconnect attempts + * @return the builder instance + * @throws NullPointerException if either argument is null + * @throws IllegalArgumentException if either argument is negative; the + * builder is then unchanged + */ + public Builder reconnectBackoff(Duration initial, Duration max) { + Objects.requireNonNull(initial, "initial"); + Objects.requireNonNull(max, "max"); + if (initial.isNegative()) { + throw new IllegalArgumentException("initial must not be negative, got " + initial); + } + if (max.isNegative()) { + throw new IllegalArgumentException("max must not be negative, got " + max); + } + this.reconnectBackoffInitial = Optional.of(initial); + this.reconnectBackoffMax = Optional.of(max); + return this; + } + + /** + * Sets whether each wait between reconnect attempts is scaled by a random + * factor in [0, 1). On by default, so that sessions that lose their + * connections together don't all reconnect at the same moment. + * + * @param enabled whether to scale each wait by a random factor + * @return the builder instance + */ + public Builder reconnectJitter(boolean enabled) { + this.reconnectJitter = Optional.of(enabled); + return this; + } + + /** + * Sets the session to stop reconnecting after {@code attempts} failed attempts + * in one outage, counting the immediate first attempt. Each new outage starts + * the count again. By default the session never stops on its own. + *

+ * When the session stops, every listener and forwarder stops with the last + * attempt's error: {@link Listener#accept()} and {@link Forwarder#join()} + * throw an {@link IOException}. + * + * @param attempts the number of failed attempts after which to stop + * @return the builder instance + * @throws IllegalArgumentException if {@code attempts} is below 1; the builder + * is then unchanged + */ + public Builder reconnectMaxAttempts(int attempts) { + if (attempts < 1) { + throw new IllegalArgumentException("attempts must be at least 1, got " + attempts); + } + this.reconnectMaxAttempts = Optional.of(attempts); + return this; + } + /** * Sets the metadata for this builder * @@ -460,6 +540,44 @@ public Optional getHeartbeatTolerance() { return heartbeatTolerance; } + /** + * Returns the first wait between reconnect attempts set for this builder. + * + * @return the first wait, if {@link #reconnectBackoff(Duration, Duration)} set one + */ + public Optional getReconnectBackoffInitial() { + return reconnectBackoffInitial; + } + + /** + * Returns the longest wait between reconnect attempts set for this builder. + * + * @return the longest wait, if {@link #reconnectBackoff(Duration, Duration)} set one + */ + public Optional getReconnectBackoffMax() { + return reconnectBackoffMax; + } + + /** + * Returns whether reconnect waits are scaled by a random factor, as set for + * this builder. + * + * @return the setting, if {@link #reconnectJitter(boolean)} set one + */ + public Optional getReconnectJitter() { + return reconnectJitter; + } + + /** + * Returns the number of failed reconnect attempts after which the session + * stops, as set for this builder. + * + * @return the number, if {@link #reconnectMaxAttempts(int)} set one + */ + public Optional getReconnectMaxAttempts() { + return reconnectMaxAttempts; + } + /** * Returns the metadata for this builder. * diff --git a/ngrok-java/src/test/java/com/ngrok/SessionBuilderTest.java b/ngrok-java/src/test/java/com/ngrok/SessionBuilderTest.java new file mode 100644 index 0000000..7d345a5 --- /dev/null +++ b/ngrok-java/src/test/java/com/ngrok/SessionBuilderTest.java @@ -0,0 +1,101 @@ +package com.ngrok; + +import org.junit.Test; + +import java.time.Duration; +import java.util.Optional; + +import static org.junit.Assert.*; + +// The range rules (a start of at least 1 ms and at most the cap, a cap of at +// most one day) are the ngrok Rust SDK's, checked when the session connects; +// ngrok-java-native's ReconnectTest covers them. These are the refusals the +// setters make themselves, for what the Rust types cannot hold. +public class SessionBuilderTest { + private static Session.Builder builder() { + return Session.withAuthtoken("unused"); + } + + @Test + public void reconnectOptionsAreUnsetByDefault() { + var builder = builder(); + assertEquals(Optional.empty(), builder.getReconnectBackoffInitial()); + assertEquals(Optional.empty(), builder.getReconnectBackoffMax()); + assertEquals(Optional.empty(), builder.getReconnectJitter()); + assertEquals(Optional.empty(), builder.getReconnectMaxAttempts()); + } + + @Test + public void reconnectBackoffKeepsBothDurationsExactly() { + var initial = Duration.ofNanos(1_500_001); + var max = Duration.ofDays(1); + var builder = builder(); + assertSame(builder, builder.reconnectBackoff(initial, max)); + assertEquals(Optional.of(Duration.ofNanos(1_500_001)), builder.getReconnectBackoffInitial()); + assertEquals(Optional.of(Duration.ofDays(1)), builder.getReconnectBackoffMax()); + } + + @Test + public void reconnectBackoffRefusesANegativeInitial() { + var builder = builder(); + var e = assertThrows(IllegalArgumentException.class, + () -> builder.reconnectBackoff(Duration.ofMillis(-1), Duration.ofSeconds(1))); + assertEquals("initial must not be negative, got PT-0.001S", e.getMessage()); + assertEquals(Optional.empty(), builder.getReconnectBackoffInitial()); + assertEquals(Optional.empty(), builder.getReconnectBackoffMax()); + } + + @Test + public void reconnectBackoffRefusesANegativeMax() { + var builder = builder(); + var e = assertThrows(IllegalArgumentException.class, + () -> builder.reconnectBackoff(Duration.ofMillis(1), Duration.ofSeconds(-1))); + assertEquals("max must not be negative, got PT-1S", e.getMessage()); + assertEquals(Optional.empty(), builder.getReconnectBackoffInitial()); + } + + @Test + public void reconnectBackoffRefusesNull() { + var builder = builder(); + var e = assertThrows(NullPointerException.class, + () -> builder.reconnectBackoff(null, Duration.ofSeconds(1))); + assertEquals("initial", e.getMessage()); + e = assertThrows(NullPointerException.class, + () -> builder.reconnectBackoff(Duration.ofSeconds(1), null)); + assertEquals("max", e.getMessage()); + assertEquals(Optional.empty(), builder.getReconnectBackoffInitial()); + } + + @Test + public void reconnectJitterKeepsTheSetting() { + var builder = builder(); + assertSame(builder, builder.reconnectJitter(false)); + assertEquals(Optional.of(false), builder.getReconnectJitter()); + builder.reconnectJitter(true); + assertEquals(Optional.of(true), builder.getReconnectJitter()); + } + + @Test + public void reconnectMaxAttemptsKeepsOneAndAbove() { + var builder = builder(); + assertSame(builder, builder.reconnectMaxAttempts(1)); + assertEquals(Optional.of(1), builder.getReconnectMaxAttempts()); + builder.reconnectMaxAttempts(Integer.MAX_VALUE); + assertEquals(Optional.of(Integer.MAX_VALUE), builder.getReconnectMaxAttempts()); + } + + @Test + public void reconnectMaxAttemptsRefusesZero() { + var builder = builder(); + var e = assertThrows(IllegalArgumentException.class, () -> builder.reconnectMaxAttempts(0)); + assertEquals("attempts must be at least 1, got 0", e.getMessage()); + assertEquals(Optional.empty(), builder.getReconnectMaxAttempts()); + } + + @Test + public void reconnectMaxAttemptsRefusesANegativeCount() { + var builder = builder(); + var e = assertThrows(IllegalArgumentException.class, () -> builder.reconnectMaxAttempts(-1)); + assertEquals("attempts must be at least 1, got -1", e.getMessage()); + } +}