hyperlocal-0.9.1/.cargo_vcs_info.json0000644000000001360000000000100132050ustar { "git": { "sha1": "720d1c9a6f6acb311919dfa0e3ed92101b66c1ba" }, "path_in_vcs": "" }hyperlocal-0.9.1/.github/workflows/main.yml000064400000000000000000000057421046102023000170510ustar 00000000000000name: Main on: workflow_dispatch: push: paths-ignore: - '*.md' branches: - main tags: - '**' pull_request: paths-ignore: - '*.md' branches: - main env: CARGO_TERM_COLOR: always jobs: codestyle: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - uses: actions/cache@v2 with: path: | ~/.cargo/registry ~/.cargo/git target key: ${{ runner.os }}-nightly-cargo-${{ hashFiles('Cargo.lock') }} - name: Set up Rust uses: hecrj/setup-rust-action@v1 with: components: rustfmt rust-version: nightly - run: cargo fmt --all -- --check lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - uses: actions/cache@v2 with: path: | ~/.cargo/registry ~/.cargo/git target key: ${{ runner.os }}-stable-cargo-${{ hashFiles('Cargo.lock') }} - name: Set up Rust uses: hecrj/setup-rust-action@v1 with: components: clippy - run: cargo clippy --all-targets --all-features -- -D clippy::all compile: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - uses: actions/cache@v2 with: path: | ~/.cargo/registry ~/.cargo/git target key: ${{ runner.os }}-stable-cargo-${{ hashFiles('Cargo.lock') }} - name: Set up Rust uses: hecrj/setup-rust-action@v1 - run: cargo check --all test: needs: [codestyle, lint, compile] strategy: matrix: os: [ubuntu-latest, macOS-latest] rust: [stable] runs-on: ${{ matrix.os }} steps: - name: Checkout uses: actions/checkout@v2 - name: Setup Rust uses: hecrj/setup-rust-action@v1 with: rust-version: ${{ matrix.rust }} - name: Test run: cargo test --all-features publish-docs: if: github.ref == 'refs/heads/main' runs-on: ubuntu-latest needs: [test] steps: - name: Set up Rust uses: hecrj/setup-rust-action@v1 - uses: actions/checkout@v2 - name: Generate Docs run: | cargo doc --no-deps --all-features echo "" > target/doc/index.html - name: Publish uses: peaceiris/actions-gh-pages@v3 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ./target/doc publish-crate: if: startsWith(github.ref, 'refs/tags/') needs: [test] runs-on: ubuntu-latest steps: - name: Set up Rust uses: hecrj/setup-rust-action@v1 - uses: actions/checkout@v1 - name: Publish if: env.CRATES_TOKEN shell: bash run: cargo publish --token ${{ env.CRATES_TOKEN }} env: CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }} hyperlocal-0.9.1/.gitignore000064400000000000000000000000221046102023000137570ustar 00000000000000target Cargo.lock hyperlocal-0.9.1/CHANGELOG.md000064400000000000000000000051331046102023000136100ustar 00000000000000# 0.9.1 - Export UnixStream for clients [#60](https://github.com/softprops/hyperlocal/pull/60) via [@onalante-msft](https://github.com/onalante-msft) - Adding support for UnixStream to take advantage of vectored writes [#63](https://github.com/softprops/hyperlocal/pull/63) via [@craftytrickster](https://github.com/craftytrickster) # 0.9.0 - upgrade to hyper 1.1 [#65](https://github.com/softprops/hyperlocal/pull/65) via [iamjpotts](https://github.com/iamjpotts) # 0.8.0 - upgrade to tokio 1.0 and hyper 0.14 [#44](https://github.com/softprops/hyperlocal/pull/44) - port ci from Travis CI to GitHub Actions - `main` is the new default GitHub branch # 0.7.0 - reimplement server for `std::future` (`async`/`await`) - upgrade to tokio 0.2 - add `SocketIncoming` interface # 0.6.0 - upgrade to hyper 0.13 - upgrade hex to 0.3 [#15](https://github.com/softprops/hyperlocal/pull/15) - move from tokio-core to tokio 0.1 [#16](https://github.com/softprops/hyperlocal/pull/16) - don't explicitly block on unix socket connection [#18](https://github.com/softprops/hyperlocal/pull/18) - provide a more flexible set of Server interfaces and to align more closely with those of hyper's default server bindings [#19](https://github.com/softprops/hyperlocal/pull/19) You'll want to use `hyperlocal::server::Server` where you would have used `hyperlocal::server::Http` in the past and use `hyperlocal::server::Http` for a lower level interfaces that give you more control over "driving" your server. # 0.5.0 - upgrade to hyper 0.12 [#11](https://github.com/softprops/hyperlocal/pull/11) - expose the [SocketAddr](https://doc.rust-lang.org/std/os/unix/net/struct.SocketAddr.html) servers listen on with `Server#local_addr` # 0.4.1 - implement Clone for `UnixConnector` [@letmutx](https://github.com/softprops/hyperlocal/pull/7) # 0.4.0 - refactor for async hyper - `hyperlocal::DomainUrl` is now `hyperlocal::Uri` the semantics are the same but the name now matches hyper's new name can can be lifted into hypers type ```rust let uri: hyper:Uri = hyperlocal::Uri( "path/to/server.sock", "/foo/bar?baz=boom" ).into(); ``` - `hyperlocal::UnitSocketConnector` is now just `hyperlocal::UnixConnector` to be more inline with the naming conventions behind`hyper::HttpConnector` and `hyper_tls::HttpsConnector` - `hyperlocal::UnixSocketServer` is now `hyperlocal::server::Http` to be more inline with hyper naming conventions # 0.3.0 - enable using unix_socket from stdlib. [#4](https://github.com/softprops/hyperlocal/pull/4) - upgrade to hyper 0.10 # 0.2.0 - upgraded to hyper 0.9 and transitively url 1.0 # 0.1.0 Initial release hyperlocal-0.9.1/Cargo.lock0000644000000403020000000000100111570ustar # This file is automatically @generated by Cargo. # It is not intended for manual editing. version = 3 [[package]] name = "addr2line" version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" dependencies = [ "gimli", ] [[package]] name = "adler" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "backtrace" version = "0.3.73" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" dependencies = [ "addr2line", "cc", "cfg-if", "libc", "miniz_oxide", "object", "rustc-demangle", ] [[package]] name = "bytes" version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a12916984aab3fa6e39d655a33e09c0071eb36d6ab3aea5c2d78551f1df6d952" [[package]] name = "cc" version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2aba8f4e9906c7ce3c73463f62a7f0c65183ada1a2d47e397cc8810827f9694f" [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "fnv" version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "futures-channel" version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" dependencies = [ "futures-core", ] [[package]] name = "futures-core" version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" [[package]] name = "futures-task" version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" [[package]] name = "futures-util" version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" dependencies = [ "futures-core", "futures-task", "pin-project-lite", "pin-utils", ] [[package]] name = "gimli" version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" [[package]] name = "hermit-abi" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" [[package]] name = "hex" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "http" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" dependencies = [ "bytes", "fnv", "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.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" dependencies = [ "bytes", "futures-util", "http", "http-body", "pin-project-lite", ] [[package]] name = "httparse" version = "1.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" [[package]] name = "httpdate" version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hyper" version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "50dfd22e0e76d0f662d429a5f80fcaf3855009297eab6a0a9f8543834744ba05" dependencies = [ "bytes", "futures-channel", "futures-util", "http", "http-body", "httparse", "httpdate", "itoa", "pin-project-lite", "smallvec", "tokio", "want", ] [[package]] name = "hyper-util" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ab92f4f49ee4fb4f997c784b7a2e0fa70050211e0b6a287f898c3c9785ca956" dependencies = [ "bytes", "futures-channel", "futures-util", "http", "http-body", "hyper", "pin-project-lite", "socket2", "tokio", "tower", "tower-service", "tracing", ] [[package]] name = "hyperlocal" version = "0.9.1" dependencies = [ "hex", "http-body-util", "hyper", "hyper-util", "pin-project-lite", "thiserror", "tokio", "tower-service", ] [[package]] name = "itoa" version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "libc" version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "memchr" version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "miniz_oxide" version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" dependencies = [ "adler", ] [[package]] name = "mio" version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" dependencies = [ "libc", "wasi", "windows-sys 0.48.0", ] [[package]] name = "num_cpus" version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ "hermit-abi", "libc", ] [[package]] name = "object" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "081b846d1d56ddfc18fdf1a922e4f6e07a11768ea1b92dec44e42b72712ccfce" dependencies = [ "memchr", ] [[package]] name = "once_cell" version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "pin-project" version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "pin-project-lite" version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" [[package]] name = "pin-utils" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "proc-macro2" version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] [[package]] name = "quote" version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] [[package]] name = "rustc-demangle" version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "smallvec" version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "socket2" version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" dependencies = [ "libc", "windows-sys 0.52.0", ] [[package]] name = "syn" version = "2.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] [[package]] name = "thiserror" version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", "syn", ] [[package]] name = "tokio" version = "1.38.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb2caba9f80616f438e09748d5acda951967e1ea58508ef53d9c6402485a46df" dependencies = [ "backtrace", "bytes", "libc", "mio", "num_cpus", "pin-project-lite", "socket2", "tokio-macros", "windows-sys 0.48.0", ] [[package]] name = "tokio-macros" version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" dependencies = [ "proc-macro2", "quote", "syn", ] [[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", ] [[package]] name = "tower-layer" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" [[package]] name = "tower-service" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" [[package]] name = "tracing" version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ "pin-project-lite", "tracing-core", ] [[package]] name = "tracing-core" version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", ] [[package]] name = "try-lock" version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "unicode-ident" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[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.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "windows-sys" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ "windows-targets 0.48.5", ] [[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-targets" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ "windows_aarch64_gnullvm 0.48.5", "windows_aarch64_msvc 0.48.5", "windows_i686_gnu 0.48.5", "windows_i686_msvc 0.48.5", "windows_x86_64_gnu 0.48.5", "windows_x86_64_gnullvm 0.48.5", "windows_x86_64_msvc 0.48.5", ] [[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", "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_aarch64_gnullvm" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[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_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[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_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[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_gnullvm" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[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_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" hyperlocal-0.9.1/Cargo.toml0000644000000035750000000000100112150ustar # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g., crates.io) dependencies. # # If you are reading this file be aware that the original Cargo.toml # will likely look very different (and much more reasonable). # See Cargo.toml.orig for the original contents. [package] edition = "2021" name = "hyperlocal" version = "0.9.1" authors = ["softprops "] description = "Hyper bindings for Unix domain sockets" homepage = "https://github.com/softprops/hyperlocal" readme = "README.md" keywords = [ "hyper", "unix", "sockets", "http", ] license = "MIT" repository = "https://github.com/softprops/hyperlocal" [[example]] name = "client" required-features = ["client"] [[example]] name = "server" required-features = ["server"] [[test]] name = "server_client" required-features = [ "client", "server", ] [dependencies.hex] version = "0.4" [dependencies.http-body-util] version = "0.1" optional = true [dependencies.hyper] version = "1.3" [dependencies.hyper-util] version = "0.1.2" optional = true [dependencies.pin-project-lite] version = "0.2" [dependencies.tokio] version = "1.35" features = ["net"] default-features = false [dependencies.tower-service] version = "0.3" optional = true [dev-dependencies.thiserror] version = "1.0" [dev-dependencies.tokio] version = "1.35" features = [ "io-std", "io-util", "macros", "rt-multi-thread", ] [features] client = [ "http-body-util", "hyper/client", "hyper/http1", "hyper-util/client-legacy", "hyper-util/http1", "hyper-util/tokio", "tower-service", ] default = [ "client", "server", ] server = [ "hyper/http1", "hyper/server", "hyper-util/tokio", ] hyperlocal-0.9.1/Cargo.toml.orig000064400000000000000000000024021046102023000146620ustar 00000000000000[package] name = "hyperlocal" version = "0.9.1" authors = ["softprops "] description = "Hyper bindings for Unix domain sockets" homepage = "https://github.com/softprops/hyperlocal" repository = "https://github.com/softprops/hyperlocal" keywords = ["hyper", "unix", "sockets", "http"] license = "MIT" readme = "README.md" edition = "2021" [dependencies] hex = "0.4" http-body-util = { version = "0.1", optional = true } hyper = "1.3" hyper-util = { version = "0.1.2", optional = true } tokio = { version = "1.35", default-features = false, features = ["net"] } tower-service = { version = "0.3", optional = true } pin-project-lite = "0.2" [dev-dependencies] thiserror = "1.0" tokio = { version = "1.35", features = [ "io-std", "io-util", "macros", "rt-multi-thread", ] } [features] default = ["client", "server"] client = [ "http-body-util", "hyper/client", "hyper/http1", "hyper-util/client-legacy", "hyper-util/http1", "hyper-util/tokio", "tower-service", ] server = ["hyper/http1", "hyper/server", "hyper-util/tokio"] [[example]] name = "client" required-features = ["client"] [[example]] name = "server" required-features = ["server"] [[test]] name = "server_client" required-features = ["client", "server"] hyperlocal-0.9.1/LICENSE000064400000000000000000000020441046102023000130020ustar 00000000000000Copyright (c) 2015-2020 Doug Tangren Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.hyperlocal-0.9.1/README.md000064400000000000000000000064201046102023000132560ustar 00000000000000u
🔌 ✨

hyperlocal

Hyper client and server bindings for Unix domain sockets


Hyper is a rock solid [Rust](https://www.rust-lang.org/) HTTP client and server toolkit. [Unix domain sockets](https://en.wikipedia.org/wiki/Unix_domain_socket) provide a mechanism for host-local interprocess communication. `hyperlocal` builds on and complements Hyper's interfaces for building Unix domain socket HTTP clients and servers. This is useful for exposing simple HTTP interfaces for your Unix daemons in cases where you want to limit access to the current host, in which case, opening and exposing tcp ports is not needed. Examples of Unix daemons that provide this kind of host local interface include [Docker](https://docs.docker.com/engine/misc/), a process container manager. ## Installation Add the following to your `Cargo.toml` file ```toml [dependencies] hyperlocal = "0.9" ``` ## Usage ### Servers A typical server can be built by creating a `tokio::net::UnixListener` and accepting connections in a loop using `hyper::service::service_fn` to create a request/response processing function, and connecting the `UnixStream` to it using `hyper::server::conn::http1::Builder::new().serve_connection()`. `hyperlocal` provides an extension trait `UnixListenerExt` with an implementation of this. An example is at [examples/server.rs](./examples/server.rs), runnable via `cargo run --example server` To test that your server is working you can use an out-of-the-box tool like `curl` ```sh $ curl --unix-socket /tmp/hyperlocal.sock localhost It's a Unix system. I know this. ``` ### Clients `hyperlocal` also provides bindings for writing unix domain socket based HTTP clients the `Client` interface from the `hyper-utils` crate. An example is at [examples/client.rs](./examples/client.rs), runnable via `cargo run --example client` Hyper's client interface makes it easy to send typical HTTP methods like `GET`, `POST`, `DELETE` with factory methods, `get`, `post`, `delete`, etc. These require an argument that can be transformed into a `hyper::Uri`. Since Unix domain sockets aren't represented with hostnames that resolve to ip addresses coupled with network ports, your standard over the counter URL string won't do. Instead, use a `hyperlocal::Uri`, which represents both file path to the domain socket and the resource URI path and query string. --- Doug Tangren (softprops) 2015-2020 hyperlocal-0.9.1/examples/client.rs000064400000000000000000000013231046102023000154360ustar 00000000000000use http_body_util::{BodyExt, Full}; use hyper::body::Bytes; use hyper_util::client::legacy::Client; use hyperlocal::{UnixClientExt, UnixConnector, Uri}; use std::error::Error; use tokio::io::{self, AsyncWriteExt as _}; #[tokio::main] async fn main() -> Result<(), Box> { let url = Uri::new("/tmp/hyperlocal.sock", "/").into(); let client: Client> = Client::unix(); let mut response = client.get(url).await?; while let Some(frame_result) = response.frame().await { let frame = frame_result?; if let Some(segment) = frame.data_ref() { io::stdout().write_all(segment.iter().as_slice()).await?; } } Ok(()) } hyperlocal-0.9.1/examples/server.rs000064400000000000000000000014731046102023000154740ustar 00000000000000use std::{error::Error, fs, path::Path}; use hyper::Response; use tokio::net::UnixListener; use hyperlocal::UnixListenerExt; const PHRASE: &str = "It's a Unix system. I know this.\n"; // Adapted from https://hyper.rs/guides/1/server/hello-world/ #[tokio::main] async fn main() -> Result<(), Box> { let path = Path::new("/tmp/hyperlocal.sock"); if path.exists() { fs::remove_file(path)?; } let listener = UnixListener::bind(path)?; println!("Listening for connections at {}.", path.display()); listener .serve(|| { println!("Accepted connection."); |_request| async { let body = PHRASE.to_string(); Ok::<_, hyper::Error>(Response::new(body)) } }) .await?; Ok(()) } hyperlocal-0.9.1/rustfmt.toml000064400000000000000000000005561046102023000144040ustar 00000000000000# https://github.com/rust-lang/rustfmt/blob/master/Configurations.md#fn_params_layout fn_params_layout = "Vertical" # https://github.com/rust-lang/rustfmt/blob/master/Configurations.md#imports_granularity imports_granularity = "Crate" # https://github.com/rust-lang/rustfmt/blob/master/Configurations.md#format_code_in_doc_comments format_code_in_doc_comments = truehyperlocal-0.9.1/src/client.rs000064400000000000000000000132521046102023000144130ustar 00000000000000use hex::FromHex; use hyper::{body::Body, rt::ReadBufCursor, Uri}; use hyper_util::{ client::legacy::{ connect::{Connected, Connection}, Client, }, rt::{TokioExecutor, TokioIo}, }; use pin_project_lite::pin_project; use std::{ future::Future, io, io::Error, path::{Path, PathBuf}, pin::Pin, task::{Context, Poll}, }; use tokio::io::{AsyncRead, AsyncWrite, ReadBuf}; use tower_service::Service; pin_project! { /// Wrapper around [`tokio::net::UnixStream`]. #[derive(Debug)] pub struct UnixStream { #[pin] unix_stream: tokio::net::UnixStream, } } impl UnixStream { async fn connect(path: impl AsRef) -> io::Result { let unix_stream = tokio::net::UnixStream::connect(path).await?; Ok(Self { unix_stream }) } } impl AsyncWrite for UnixStream { fn poll_write( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8], ) -> Poll> { self.project().unix_stream.poll_write(cx, buf) } fn poll_flush( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll> { self.project().unix_stream.poll_flush(cx) } fn poll_shutdown( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll> { self.project().unix_stream.poll_shutdown(cx) } fn poll_write_vectored( self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &[io::IoSlice<'_>], ) -> Poll> { self.project().unix_stream.poll_write_vectored(cx, bufs) } fn is_write_vectored(&self) -> bool { self.unix_stream.is_write_vectored() } } impl hyper::rt::Write for UnixStream { fn poll_write( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8], ) -> Poll> { self.project().unix_stream.poll_write(cx, buf) } fn poll_flush( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll> { self.project().unix_stream.poll_flush(cx) } fn poll_shutdown( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll> { self.project().unix_stream.poll_shutdown(cx) } } impl AsyncRead for UnixStream { fn poll_read( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &mut ReadBuf<'_>, ) -> Poll> { self.project().unix_stream.poll_read(cx, buf) } } impl hyper::rt::Read for UnixStream { fn poll_read( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: ReadBufCursor<'_>, ) -> Poll> { let mut t = TokioIo::new(self.project().unix_stream); Pin::new(&mut t).poll_read(cx, buf) } } /// the `[UnixConnector]` can be used to construct a `[hyper::Client]` which can /// speak to a unix domain socket. /// /// # Example /// ``` /// use http_body_util::Full; /// use hyper::body::Bytes; /// use hyper_util::{client::legacy::Client, rt::TokioExecutor}; /// use hyperlocal::UnixConnector; /// /// let connector = UnixConnector; /// let client: Client> = /// Client::builder(TokioExecutor::new()).build(connector); /// ``` /// /// # Note /// If you don't need access to the low-level `[hyper::Client]` builder /// interface, consider using the `[UnixClientExt]` trait instead. #[derive(Clone, Copy, Debug, Default)] pub struct UnixConnector; impl Unpin for UnixConnector {} impl Service for UnixConnector { type Response = UnixStream; type Error = io::Error; #[allow(clippy::type_complexity)] type Future = Pin> + Send + 'static>>; fn call( &mut self, req: Uri, ) -> Self::Future { let fut = async move { let path = parse_socket_path(&req)?; UnixStream::connect(path).await }; Box::pin(fut) } fn poll_ready( &mut self, _cx: &mut Context<'_>, ) -> Poll> { Poll::Ready(Ok(())) } } impl Connection for UnixStream { fn connected(&self) -> Connected { Connected::new() } } fn parse_socket_path(uri: &Uri) -> Result { if uri.scheme_str() != Some("unix") { return Err(io::Error::new( io::ErrorKind::InvalidInput, "invalid URL, scheme must be unix", )); } if let Some(host) = uri.host() { let bytes = Vec::from_hex(host).map_err(|_| { io::Error::new( io::ErrorKind::InvalidInput, "invalid URL, host must be a hex-encoded path", ) })?; Ok(PathBuf::from(String::from_utf8_lossy(&bytes).into_owned())) } else { Err(io::Error::new( io::ErrorKind::InvalidInput, "invalid URL, host must be present", )) } } /// Extension trait for constructing a hyper HTTP client over a Unix domain /// socket. pub trait UnixClientExt { /// Construct a client which speaks HTTP over a Unix domain socket /// /// # Example /// ``` /// use http_body_util::Full; /// use hyper::body::Bytes; /// use hyper_util::client::legacy::Client; /// use hyperlocal::{UnixClientExt, UnixConnector}; /// /// let client: Client> = Client::unix(); /// ``` #[must_use] fn unix() -> Client where B::Data: Send, { Client::builder(TokioExecutor::new()).build(UnixConnector) } } impl UnixClientExt for Client {} hyperlocal-0.9.1/src/lib.rs000064400000000000000000000015051046102023000137010ustar 00000000000000#![deny( missing_debug_implementations, unreachable_pub, rust_2018_idioms, missing_docs )] #![warn(clippy::all, clippy::pedantic)] //! `hyperlocal` provides [Hyper](http://github.com/hyperium/hyper) bindings //! for [Unix domain sockets](https://github.com/tokio-rs/tokio/tree/master/tokio-net/src/uds/). //! //! See the examples for how to configure a client or a server. //! //! # Features //! //! - Client- enables the client extension trait and connector. *Enabled by //! default*. //! //! - Server- enables the server extension trait. *Enabled by default*. #[cfg(feature = "client")] mod client; #[cfg(feature = "client")] pub use client::{UnixClientExt, UnixConnector, UnixStream}; #[cfg(feature = "server")] mod server; #[cfg(feature = "server")] pub use server::UnixListenerExt; mod uri; pub use uri::Uri; hyperlocal-0.9.1/src/server.rs000064400000000000000000000051441046102023000144440ustar 00000000000000use hyper::{ body::{Body, Incoming}, service::service_fn, Request, Response, }; use hyper_util::rt::TokioIo; use std::future::Future; use tokio::net::UnixListener; /// Extension trait for provisioning a hyper HTTP server over a Unix domain /// socket. /// /// # Example /// /// ```rust /// use hyper::Response; /// use hyperlocal::UnixListenerExt; /// use tokio::net::UnixListener; /// /// let future = async move { /// let listener = UnixListener::bind("/tmp/hyperlocal.sock").expect("parsed unix path"); /// /// listener /// .serve(|| { /// |_request| async { /// Ok::<_, hyper::Error>(Response::new("Hello, world.".to_string())) /// } /// }) /// .await /// .expect("failed to serve a connection") /// }; /// ``` pub trait UnixListenerExt { /// Indefinitely accept and respond to connections. /// /// Pass a function which will generate the function which responds to /// all requests for an individual connection. fn serve( self, f: MakeResponseFn, ) -> impl Future>> where MakeResponseFn: Fn() -> ResponseFn, ResponseFn: Fn(Request) -> ResponseFuture, ResponseFuture: Future, E>>, B: Body + 'static, ::Error: std::error::Error + Send + Sync, E: std::error::Error + Send + Sync + 'static; } impl UnixListenerExt for UnixListener { fn serve( self, f: MakeServiceFn, ) -> impl Future>> where MakeServiceFn: Fn() -> ResponseFn, ResponseFn: Fn(Request) -> ResponseFuture, ResponseFuture: Future, E>>, B: Body + 'static, ::Error: std::error::Error + Send + Sync, E: std::error::Error + Send + Sync + 'static, { async move { loop { let (stream, _) = self.accept().await?; let io = TokioIo::new(stream); let svc_fn = service_fn(f()); hyper::server::conn::http1::Builder::new() // On OSX, disabling keep alive prevents serve_connection from // blocking and later returning an Err derived from E_NOTCONN. .keep_alive(false) .serve_connection(io, svc_fn) .await?; } } } } hyperlocal-0.9.1/src/uri.rs000064400000000000000000000024401046102023000137310ustar 00000000000000use hyper::Uri as HyperUri; use std::path::Path; /// A convenience type that can be used to construct Unix Domain Socket URIs /// /// This type implements `Into`. /// /// # Example /// ``` /// use hyper::Uri as HyperUri; /// use hyperlocal::Uri; /// /// let uri: HyperUri = Uri::new("/tmp/hyperlocal.sock", "/").into(); /// ``` #[derive(Debug, Clone)] pub struct Uri { hyper_uri: HyperUri, } impl Uri { /// Create a new `[Uri]` from a socket address and a path /// /// # Panics /// Will panic if path is not absolute and/or a malformed path string. pub fn new( socket: impl AsRef, path: &str, ) -> Self { let host = hex::encode(socket.as_ref().to_string_lossy().as_bytes()); let host_str = format!("unix://{host}:0{path}"); let hyper_uri: HyperUri = host_str.parse().unwrap(); Self { hyper_uri } } } impl From for HyperUri { fn from(uri: Uri) -> Self { uri.hyper_uri } } #[cfg(test)] mod tests { use super::Uri; use hyper::Uri as HyperUri; #[test] fn test_unix_uri_into_hyper_uri() { let unix: HyperUri = Uri::new("foo.sock", "/").into(); let expected: HyperUri = "unix://666f6f2e736f636b:0/".parse().unwrap(); assert_eq!(unix, expected); } } hyperlocal-0.9.1/tests/server_client.rs000064400000000000000000000033071046102023000163540ustar 00000000000000use http_body_util::{BodyExt, Full}; use std::{error::Error, fs, path::Path}; use hyper::{body::Bytes, service::service_fn, Response}; use hyper_util::{client::legacy::Client, rt::TokioIo}; use hyperlocal::{UnixClientExt, UnixConnector, Uri}; use tokio::net::UnixListener; const PHRASE: &str = "It works!"; #[derive(Debug, thiserror::Error)] enum ListenerError { #[error("Failed to accept connection: {0}")] Accepting(std::io::Error), #[error("Failed to serve connection: {0}")] Serving(hyper::Error), } #[tokio::test] async fn test_server_client() -> Result<(), Box> { let path = Path::new("/tmp/hyperlocal.sock"); if path.exists() { fs::remove_file(path)?; } let svc_fn = service_fn(|_req| async { Ok::<_, hyper::Error>(Response::new(PHRASE.to_string())) }); let listener = UnixListener::bind(path)?; let _server_task = tokio::spawn(async move { let (stream, _) = listener.accept().await.map_err(ListenerError::Accepting)?; let io = TokioIo::new(stream); hyper::server::conn::http1::Builder::new() .serve_connection(io, svc_fn) .await .map_err(ListenerError::Serving) }); let client: Client> = Client::unix(); let url = Uri::new(path, "/").into(); let mut response = client.get(url).await?; let mut bytes = Vec::default(); while let Some(frame_result) = response.frame().await { let frame = frame_result?; if let Some(segment) = frame.data_ref() { bytes.extend(segment.iter().as_slice()); } } let string = String::from_utf8(bytes)?; assert_eq!(PHRASE, string); Ok(()) }