diff --git a/.idea/modules.xml b/.idea/modules.xml index ed9ea5ac4..c32b128d9 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -4,6 +4,7 @@ + diff --git a/ip_country/Cargo.lock b/ip_country/Cargo.lock new file mode 100644 index 000000000..258b12bbd --- /dev/null +++ b/ip_country/Cargo.lock @@ -0,0 +1,2261 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "actix" +version = "0.7.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c616db5fa4b0c40702fb75201c2af7f8aa8f3a2e2c1dda3b0655772aa949666" +dependencies = [ + "actix_derive", + "bitflags 1.3.2", + "bytes", + "crossbeam-channel 0.3.9", + "failure", + "fnv", + "futures", + "libc", + "log 0.4.21", + "parking_lot 0.7.1", + "smallvec", + "tokio", + "tokio-codec", + "tokio-executor", + "tokio-io", + "tokio-reactor", + "tokio-signal", + "tokio-tcp", + "tokio-timer", + "trust-dns-proto 0.5.0", + "trust-dns-resolver", + "uuid", +] + +[[package]] +name = "actix_derive" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4300e9431455322ae393d43a2ba1ef96b8080573c0fc23b196219efedfb6ba69" +dependencies = [ + "proc-macro2 0.4.30", + "quote 0.6.13", + "syn 0.15.44", +] + +[[package]] +name = "addr2line" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "ansi_term" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +dependencies = [ + "winapi 0.3.9", +] + +[[package]] +name = "arrayref" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" + +[[package]] +name = "arrayvec" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi 0.1.19", + "libc", + "winapi 0.3.9", +] + +[[package]] +name = "autocfg" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dde43e75fd43e8a1bf86103336bc699aa8d17ad1be60c76c0bdfd4828e19b78" +dependencies = [ + "autocfg 1.2.0", +] + +[[package]] +name = "autocfg" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" + +[[package]] +name = "backtrace" +version = "0.3.71" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" +dependencies = [ + "addr2line", + "cc", + "cfg-if 1.0.0", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + +[[package]] +name = "base58" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5024ee8015f02155eee35c711107ddd9a9bf3cb689cf2a9089c97e79b6e1ae83" + +[[package]] +name = "base64" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "489d6c0ed21b11d038c31b6ceccca973e65d73ba3bd8ecb9a2babf5546164643" +dependencies = [ + "byteorder", + "safemem", +] + +[[package]] +name = "base64" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" +dependencies = [ + "byteorder", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" + +[[package]] +name = "bitvec" +version = "0.17.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41262f11d771fd4a61aa3ce019fca363b4b6c282fca9da2a31186d3965a47a5c" +dependencies = [ + "either", + "radium", +] + +[[package]] +name = "block-buffer" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" +dependencies = [ + "block-padding", + "byte-tools", + "byteorder", + "generic-array", +] + +[[package]] +name = "block-padding" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" +dependencies = [ + "byte-tools", +] + +[[package]] +name = "byte-slice-cast" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0a5e3906bcbf133e33c1d4d95afc664ad37fbdb9f6568d8043e7ea8c27d93d3" + +[[package]] +name = "byte-tools" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "bytes" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" +dependencies = [ + "byteorder", + "iovec", +] + +[[package]] +name = "cc" +version = "1.0.90" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" + +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "clap" +version = "2.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" +dependencies = [ + "ansi_term", + "atty", + "bitflags 1.3.2", + "strsim", + "textwrap", + "unicode-width", + "vec_map", +] + +[[package]] +name = "cloudabi" +version = "0.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" +dependencies = [ + "bitflags 1.3.2", +] + +[[package]] +name = "const_format" +version = "0.2.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3a214c7af3d04997541b18d432afaff4c455e79e2029079647e72fc2bd27673" +dependencies = [ + "const_format_proc_macros", +] + +[[package]] +name = "const_format_proc_macros" +version = "0.2.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7f6ff08fd20f4f299298a28e2dfa8a8ba1036e6cd2460ac1de7b425d76f2500" +dependencies = [ + "proc-macro2 1.0.79", + "quote 1.0.35", + "unicode-xid 0.2.4", +] + +[[package]] +name = "crossbeam-channel" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8ec7fcd21571dc78f96cc96243cab8d8f035247c3efd16c687be154c3fa9efa" +dependencies = [ + "crossbeam-utils 0.6.6", +] + +[[package]] +name = "crossbeam-channel" +version = "0.5.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab3db02a9c5b5121e1e42fbdb1aeb65f5e02624cc58c43f2884c6ccac0b82f95" +dependencies = [ + "crossbeam-utils 0.8.19", +] + +[[package]] +name = "crossbeam-deque" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c20ff29ded3204c5106278a81a38f4b482636ed4fa1e6cfbeef193291beb29ed" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils 0.7.2", + "maybe-uninit", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" +dependencies = [ + "autocfg 1.2.0", + "cfg-if 0.1.10", + "crossbeam-utils 0.7.2", + "lazy_static", + "maybe-uninit", + "memoffset 0.5.6", + "scopeguard 1.2.0", +] + +[[package]] +name = "crossbeam-queue" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "774ba60a54c213d409d5353bda12d49cd68d14e45036a285234c8d6f91f92570" +dependencies = [ + "cfg-if 0.1.10", + "crossbeam-utils 0.7.2", + "maybe-uninit", +] + +[[package]] +name = "crossbeam-utils" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04973fa96e96579258a5091af6003abde64af786b860f18622b82e026cca60e6" +dependencies = [ + "cfg-if 0.1.10", + "lazy_static", +] + +[[package]] +name = "crossbeam-utils" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" +dependencies = [ + "autocfg 1.2.0", + "cfg-if 0.1.10", + "lazy_static", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" + +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + +[[package]] +name = "crypto-mac" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4434400df11d95d556bac068ddfedd482915eb18fe8bea89bc80b6e4b1c179e5" +dependencies = [ + "generic-array", + "subtle 1.0.0", +] + +[[package]] +name = "csv" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac574ff4d437a7b5ad237ef331c17ccca63c46479e5b5453eb8e10bb99a759fe" +dependencies = [ + "csv-core", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "csv-core" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5efa2b3d7902f4b634a20cae3c9c4e6209dc4779feb6863329607560143efa70" +dependencies = [ + "memchr", +] + +[[package]] +name = "deranged" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +dependencies = [ + "powerfmt", +] + +[[package]] +name = "digest" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" +dependencies = [ + "generic-array", +] + +[[package]] +name = "dirs" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" +dependencies = [ + "libc", + "redox_users", + "winapi 0.3.9", +] + +[[package]] +name = "either" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" + +[[package]] +name = "error-chain" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6930e04918388a9a2e41d518c25cf679ccafe26733fb4127dbf21993f2575d46" +dependencies = [ + "backtrace", +] + +[[package]] +name = "ethbloom" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71a6567e6fd35589fea0c63b94b4cf2e55573e413901bdbe60ab15cf0e25e5df" +dependencies = [ + "crunchy", + "fixed-hash", + "impl-rlp", + "impl-serde", + "tiny-keccak", +] + +[[package]] +name = "ethereum-types" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "473aecff686bd8e7b9db0165cbbb53562376b39bf35b427f0c60446a9e1634b0" +dependencies = [ + "ethbloom", + "fixed-hash", + "impl-rlp", + "impl-serde", + "primitive-types", + "uint", +] + +[[package]] +name = "failure" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d32e9bd16cc02eae7db7ef620b392808b89f6a5e16bb3497d159c6b92a0f4f86" +dependencies = [ + "backtrace", + "failure_derive", +] + +[[package]] +name = "failure_derive" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4" +dependencies = [ + "proc-macro2 1.0.79", + "quote 1.0.35", + "syn 1.0.109", + "synstructure", +] + +[[package]] +name = "fake-simd" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" + +[[package]] +name = "fixed-hash" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11498d382790b7a8f2fd211780bec78619bba81cdad3a283997c0c41f836759c" +dependencies = [ + "byteorder", + "rand 0.7.3", + "rustc-hex", + "static_assertions", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "fuchsia-cprng" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" + +[[package]] +name = "fuchsia-zircon" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" +dependencies = [ + "bitflags 1.3.2", + "fuchsia-zircon-sys", +] + +[[package]] +name = "fuchsia-zircon-sys" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" + +[[package]] +name = "futures" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a471a38ef8ed83cd6e40aa59c1ffe17db6855c18e3604d9c4ed8c08ebc28678" + +[[package]] +name = "generic-array" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" +dependencies = [ + "typenum", +] + +[[package]] +name = "getrandom" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "wasi 0.9.0+wasi-snapshot-preview1", +] + +[[package]] +name = "getrandom" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "wasi 0.11.0+wasi-snapshot-preview1", +] + +[[package]] +name = "gimli" +version = "0.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" + +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + +[[package]] +name = "hermit-abi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" + +[[package]] +name = "hmac" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dcb5e64cda4c23119ab41ba960d1e170a774c8e4b9d9e6a9bc18aabf5e59695" +dependencies = [ + "crypto-mac", + "digest", +] + +[[package]] +name = "hmac-drbg" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6e570451493f10f6581b48cdd530413b63ea9e780f544bfd3bdcaa0d89d1a7b" +dependencies = [ + "digest", + "generic-array", + "hmac", +] + +[[package]] +name = "hostname" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c731c3e10504cc8ed35cfe2f1db4c9274c3d35fa486e3b31df46f068ef3e867" +dependencies = [ + "libc", + "match_cfg", + "winapi 0.3.9", +] + +[[package]] +name = "httparse" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" + +[[package]] +name = "hyper" +version = "0.10.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a0652d9a2609a968c14be1a9ea00bf4b1d64e2e1f53a1b51b6fff3a6e829273" +dependencies = [ + "base64 0.9.3", + "httparse", + "language-tags", + "log 0.3.9", + "mime", + "num_cpus", + "time 0.1.45", + "traitobject", + "typeable", + "unicase", + "url", +] + +[[package]] +name = "idna" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" +dependencies = [ + "matches", + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "impl-codec" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1be51a921b067b0eaca2fad532d9400041561aa922221cc65f95a85641c6bf53" +dependencies = [ + "parity-scale-codec", +] + +[[package]] +name = "impl-rlp" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f7a72f11830b52333f36e3b09a288333888bf54380fd0ac0790a3c31ab0f3c5" +dependencies = [ + "rlp", +] + +[[package]] +name = "impl-serde" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4551f042f3438e64dbd6226b20527fc84a6e1fe65688b58746a2f53623f25f5c" +dependencies = [ + "serde", +] + +[[package]] +name = "iovec" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" +dependencies = [ + "libc", +] + +[[package]] +name = "ip_country" +version = "0.1.0" +dependencies = [ + "csv", + "lazy_static", + "masq_lib", +] + +[[package]] +name = "ipconfig" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08f7eadeaf4b52700de180d147c4805f199854600b36faa963d91114827b2ffc" +dependencies = [ + "error-chain", + "socket2", + "widestring", + "winapi 0.3.9", + "winreg", +] + +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + +[[package]] +name = "kernel32-sys" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" +dependencies = [ + "winapi 0.2.8", + "winapi-build", +] + +[[package]] +name = "language-tags" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a" + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.153" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" + +[[package]] +name = "libredox" +version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" +dependencies = [ + "bitflags 2.5.0", + "libc", + "redox_syscall 0.4.1", +] + +[[package]] +name = "libsecp256k1" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fc1e2c808481a63dc6da2074752fdd4336a3c8fcc68b83db6f1fd5224ae7962" +dependencies = [ + "arrayref", + "crunchy", + "digest", + "hmac-drbg", + "rand 0.7.3", + "sha2", + "subtle 2.5.0", + "typenum", +] + +[[package]] +name = "linked-hash-map" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" + +[[package]] +name = "lock_api" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c" +dependencies = [ + "owning_ref", + "scopeguard 0.3.3", +] + +[[package]] +name = "lock_api" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4da24a77a3d8a6d4862d95f72e6fdb9c09a643ecdb402d754004a557f2bec75" +dependencies = [ + "scopeguard 1.2.0", +] + +[[package]] +name = "log" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" +dependencies = [ + "log 0.4.21", +] + +[[package]] +name = "log" +version = "0.4.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" + +[[package]] +name = "lru-cache" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31e24f1ad8321ca0e8a1e0ac13f23cb668e6f5466c2c57319f6a5cf1cc8e3b1c" +dependencies = [ + "linked-hash-map", +] + +[[package]] +name = "masq_lib" +version = "0.8.0" +dependencies = [ + "actix", + "clap", + "const_format", + "crossbeam-channel 0.5.12", + "dirs", + "ethereum-types", + "itertools", + "lazy_static", + "log 0.4.21", + "nix", + "regex", + "serde", + "serde_derive", + "serde_json", + "time 0.3.34", + "tiny-hderive", + "toml", + "websocket", +] + +[[package]] +name = "match_cfg" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4" + +[[package]] +name = "matches" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5" + +[[package]] +name = "maybe-uninit" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" + +[[package]] +name = "memchr" +version = "2.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" + +[[package]] +name = "memoffset" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "043175f069eda7b85febe4a74abbaeff828d9f8b448515d3151a14a3542811aa" +dependencies = [ + "autocfg 1.2.0", +] + +[[package]] +name = "memoffset" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +dependencies = [ + "autocfg 1.2.0", +] + +[[package]] +name = "memzero" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93c0d11ac30a033511ae414355d80f70d9f29a44a49140face477117a1ee90db" + +[[package]] +name = "mime" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba626b8a6de5da682e1caa06bdb42a335aee5a84db8e5046a3e8ab17ba0a3ae0" +dependencies = [ + "log 0.3.9", +] + +[[package]] +name = "miniz_oxide" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" +dependencies = [ + "adler", +] + +[[package]] +name = "mio" +version = "0.6.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4afd66f5b91bf2a3bc13fad0e21caedac168ca4c707504e75585648ae80e4cc4" +dependencies = [ + "cfg-if 0.1.10", + "fuchsia-zircon", + "fuchsia-zircon-sys", + "iovec", + "kernel32-sys", + "libc", + "log 0.4.21", + "miow", + "net2", + "slab", + "winapi 0.2.8", +] + +[[package]] +name = "mio-uds" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afcb699eb26d4332647cc848492bbc15eafb26f08d0304550d5aa1f612e066f0" +dependencies = [ + "iovec", + "libc", + "mio", +] + +[[package]] +name = "miow" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebd808424166322d4a38da87083bfddd3ac4c131334ed55856112eb06d46944d" +dependencies = [ + "kernel32-sys", + "net2", + "winapi 0.2.8", + "ws2_32-sys", +] + +[[package]] +name = "net2" +version = "0.2.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b13b648036a2339d06de780866fbdfda0dde886de7b3af2ddeba8b14f4ee34ac" +dependencies = [ + "cfg-if 0.1.10", + "libc", + "winapi 0.3.9", +] + +[[package]] +name = "nix" +version = "0.23.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f3790c00a0150112de0f4cd161e3d7fc4b2d8a5542ffc35f099a2562aecb35c" +dependencies = [ + "bitflags 1.3.2", + "cc", + "cfg-if 1.0.0", + "libc", + "memoffset 0.6.5", +] + +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + +[[package]] +name = "num_cpus" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" +dependencies = [ + "hermit-abi 0.3.9", + "libc", +] + +[[package]] +name = "object" +version = "0.32.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" +dependencies = [ + "memchr", +] + +[[package]] +name = "opaque-debug" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" + +[[package]] +name = "owning_ref" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ff55baddef9e4ad00f88b6c743a2a8062d4c6ade126c2a528644b8e444d52ce" +dependencies = [ + "stable_deref_trait", +] + +[[package]] +name = "parity-scale-codec" +version = "1.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4b26b16c7687c3075982af47719e481815df30bc544f7a6690763a25ca16e9d" +dependencies = [ + "arrayvec", + "bitvec", + "byte-slice-cast", + "serde", +] + +[[package]] +name = "parking_lot" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab41b4aed082705d1056416ae4468b6ea99d52599ecf3169b00088d43113e337" +dependencies = [ + "lock_api 0.1.5", + "parking_lot_core 0.4.0", +] + +[[package]] +name = "parking_lot" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252" +dependencies = [ + "lock_api 0.3.4", + "parking_lot_core 0.6.3", + "rustc_version", +] + +[[package]] +name = "parking_lot_core" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94c8c7923936b28d546dfd14d4472eaf34c99b14e1c973a32b3e6d4eb04298c9" +dependencies = [ + "libc", + "rand 0.6.5", + "rustc_version", + "smallvec", + "winapi 0.3.9", +] + +[[package]] +name = "parking_lot_core" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bda66b810a62be75176a80873726630147a5ca780cd33921e0b5709033e66b0a" +dependencies = [ + "cfg-if 0.1.10", + "cloudabi", + "libc", + "redox_syscall 0.1.57", + "rustc_version", + "smallvec", + "winapi 0.3.9", +] + +[[package]] +name = "percent-encoding" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" + +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "primitive-types" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dd39dcacf71411ba488570da7bbc89b717225e46478b30ba99b92db6b149809" +dependencies = [ + "fixed-hash", + "impl-codec", + "impl-rlp", + "impl-serde", + "uint", +] + +[[package]] +name = "proc-macro2" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +dependencies = [ + "unicode-xid 0.1.0", +] + +[[package]] +name = "proc-macro2" +version = "1.0.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quick-error" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" + +[[package]] +name = "quote" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" +dependencies = [ + "proc-macro2 0.4.30", +] + +[[package]] +name = "quote" +version = "1.0.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +dependencies = [ + "proc-macro2 1.0.79", +] + +[[package]] +name = "radium" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "def50a86306165861203e7f84ecffbbdfdea79f0e51039b33de1e952358c47ac" + +[[package]] +name = "rand" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c618c47cd3ebd209790115ab837de41425723956ad3ce2e6a7f09890947cacb9" +dependencies = [ + "cloudabi", + "fuchsia-cprng", + "libc", + "rand_core 0.3.1", + "winapi 0.3.9", +] + +[[package]] +name = "rand" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" +dependencies = [ + "autocfg 0.1.8", + "libc", + "rand_chacha 0.1.1", + "rand_core 0.4.2", + "rand_hc 0.1.0", + "rand_isaac", + "rand_jitter", + "rand_os", + "rand_pcg", + "rand_xorshift", + "winapi 0.3.9", +] + +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom 0.1.16", + "libc", + "rand_chacha 0.2.2", + "rand_core 0.5.1", + "rand_hc 0.2.0", +] + +[[package]] +name = "rand_chacha" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" +dependencies = [ + "autocfg 0.1.8", + "rand_core 0.3.1", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core 0.5.1", +] + +[[package]] +name = "rand_core" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" +dependencies = [ + "rand_core 0.4.2", +] + +[[package]] +name = "rand_core" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom 0.1.16", +] + +[[package]] +name = "rand_hc" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" +dependencies = [ + "rand_core 0.3.1", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core 0.5.1", +] + +[[package]] +name = "rand_isaac" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" +dependencies = [ + "rand_core 0.3.1", +] + +[[package]] +name = "rand_jitter" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" +dependencies = [ + "libc", + "rand_core 0.4.2", + "winapi 0.3.9", +] + +[[package]] +name = "rand_os" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" +dependencies = [ + "cloudabi", + "fuchsia-cprng", + "libc", + "rand_core 0.4.2", + "rdrand", + "winapi 0.3.9", +] + +[[package]] +name = "rand_pcg" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" +dependencies = [ + "autocfg 0.1.8", + "rand_core 0.4.2", +] + +[[package]] +name = "rand_xorshift" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" +dependencies = [ + "rand_core 0.3.1", +] + +[[package]] +name = "rdrand" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" +dependencies = [ + "rand_core 0.3.1", +] + +[[package]] +name = "redox_syscall" +version = "0.1.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" + +[[package]] +name = "redox_syscall" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +dependencies = [ + "bitflags 1.3.2", +] + +[[package]] +name = "redox_users" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4" +dependencies = [ + "getrandom 0.2.12", + "libredox", + "thiserror", +] + +[[package]] +name = "regex" +version = "1.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" + +[[package]] +name = "resolv-conf" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11834e137f3b14e309437a8276714eed3a80d1ef894869e510f2c0c0b98b9f4a" +dependencies = [ + "hostname", + "quick-error", +] + +[[package]] +name = "rlp" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1190dcc8c3a512f1eef5d09bb8c84c7f39e1054e174d1795482e18f5272f2e73" +dependencies = [ + "rustc-hex", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" + +[[package]] +name = "rustc-hex" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" + +[[package]] +name = "rustc_version" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +dependencies = [ + "semver", +] + +[[package]] +name = "ryu" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" + +[[package]] +name = "safemem" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072" + +[[package]] +name = "scopeguard" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "semver" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +dependencies = [ + "semver-parser", +] + +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" + +[[package]] +name = "serde" +version = "1.0.197" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.197" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" +dependencies = [ + "proc-macro2 1.0.79", + "quote 1.0.35", + "syn 2.0.55", +] + +[[package]] +name = "serde_json" +version = "1.0.115" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12dc5c46daa8e9fdf4f5e71b6cf9a53f2487da0e86e55808e2d35539666497dd" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha-1" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df" +dependencies = [ + "block-buffer", + "digest", + "fake-simd", + "opaque-debug", +] + +[[package]] +name = "sha2" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a256f46ea78a0c0d9ff00077504903ac881a1dafdc20da66545699e7776b3e69" +dependencies = [ + "block-buffer", + "digest", + "fake-simd", + "opaque-debug", +] + +[[package]] +name = "signal-hook-registry" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" +dependencies = [ + "libc", +] + +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg 1.2.0", +] + +[[package]] +name = "smallvec" +version = "0.6.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b97fcaeba89edba30f044a10c6a3cc39df9c3f17d7cd829dd1446cab35f890e0" +dependencies = [ + "maybe-uninit", +] + +[[package]] +name = "socket2" +version = "0.3.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "122e570113d28d773067fab24266b66753f6ea915758651696b6e35e49f88d6e" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "winapi 0.3.9", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "strsim" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" + +[[package]] +name = "subtle" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" + +[[package]] +name = "subtle" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" + +[[package]] +name = "syn" +version = "0.15.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" +dependencies = [ + "proc-macro2 0.4.30", + "quote 0.6.13", + "unicode-xid 0.1.0", +] + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2 1.0.79", + "quote 1.0.35", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "002a1b3dbf967edfafc32655d0f377ab0bb7b994aa1d32c8cc7e9b8bf3ebb8f0" +dependencies = [ + "proc-macro2 1.0.79", + "quote 1.0.35", + "unicode-ident", +] + +[[package]] +name = "synstructure" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" +dependencies = [ + "proc-macro2 1.0.79", + "quote 1.0.35", + "syn 1.0.109", + "unicode-xid 0.2.4", +] + +[[package]] +name = "textwrap" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" +dependencies = [ + "unicode-width", +] + +[[package]] +name = "thiserror" +version = "1.0.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" +dependencies = [ + "proc-macro2 1.0.79", + "quote 1.0.35", + "syn 2.0.55", +] + +[[package]] +name = "time" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" +dependencies = [ + "libc", + "wasi 0.10.0+wasi-snapshot-preview1", + "winapi 0.3.9", +] + +[[package]] +name = "time" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8248b6521bb14bc45b4067159b9b6ad792e2d6d754d6c41fb50e29fefe38749" +dependencies = [ + "deranged", + "itoa", + "num-conv", + "powerfmt", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" + +[[package]] +name = "time-macros" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ba3a3ef41e6672a2f0f001392bb5dcd3ff0a9992d618ca761a11c3121547774" +dependencies = [ + "num-conv", + "time-core", +] + +[[package]] +name = "tiny-hderive" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01b874a4992538d4b2f4fbbac11b9419d685f4b39bdc3fed95b04e07bfd76040" +dependencies = [ + "base58", + "hmac", + "libsecp256k1", + "memzero", + "sha2", +] + +[[package]] +name = "tiny-keccak" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" +dependencies = [ + "crunchy", +] + +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "tokio" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a09c0b5bb588872ab2f09afa13ee6e9dac11e10a0ec9e8e3ba39a5a5d530af6" +dependencies = [ + "bytes", + "futures", + "mio", + "num_cpus", + "tokio-codec", + "tokio-current-thread", + "tokio-executor", + "tokio-fs", + "tokio-io", + "tokio-reactor", + "tokio-sync", + "tokio-tcp", + "tokio-threadpool", + "tokio-timer", + "tokio-udp", + "tokio-uds", +] + +[[package]] +name = "tokio-codec" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25b2998660ba0e70d18684de5d06b70b70a3a747469af9dea7618cc59e75976b" +dependencies = [ + "bytes", + "futures", + "tokio-io", +] + +[[package]] +name = "tokio-current-thread" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1de0e32a83f131e002238d7ccde18211c0a5397f60cbfffcb112868c2e0e20e" +dependencies = [ + "futures", + "tokio-executor", +] + +[[package]] +name = "tokio-executor" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb2d1b8f4548dbf5e1f7818512e9c406860678f29c300cdf0ebac72d1a3a1671" +dependencies = [ + "crossbeam-utils 0.7.2", + "futures", +] + +[[package]] +name = "tokio-fs" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "297a1206e0ca6302a0eed35b700d292b275256f596e2f3fea7729d5e629b6ff4" +dependencies = [ + "futures", + "tokio-io", + "tokio-threadpool", +] + +[[package]] +name = "tokio-io" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57fc868aae093479e3131e3d165c93b1c7474109d13c90ec0dda2a1bbfff0674" +dependencies = [ + "bytes", + "futures", + "log 0.4.21", +] + +[[package]] +name = "tokio-reactor" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09bc590ec4ba8ba87652da2068d150dcada2cfa2e07faae270a5e0409aa51351" +dependencies = [ + "crossbeam-utils 0.7.2", + "futures", + "lazy_static", + "log 0.4.21", + "mio", + "num_cpus", + "parking_lot 0.9.0", + "slab", + "tokio-executor", + "tokio-io", + "tokio-sync", +] + +[[package]] +name = "tokio-signal" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0c34c6e548f101053321cba3da7cbb87a610b85555884c41b07da2eb91aff12" +dependencies = [ + "futures", + "libc", + "mio", + "mio-uds", + "signal-hook-registry", + "tokio-executor", + "tokio-io", + "tokio-reactor", + "winapi 0.3.9", +] + +[[package]] +name = "tokio-sync" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edfe50152bc8164fcc456dab7891fa9bf8beaf01c5ee7e1dd43a397c3cf87dee" +dependencies = [ + "fnv", + "futures", +] + +[[package]] +name = "tokio-tcp" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98df18ed66e3b72e742f185882a9e201892407957e45fbff8da17ae7a7c51f72" +dependencies = [ + "bytes", + "futures", + "iovec", + "mio", + "tokio-io", + "tokio-reactor", +] + +[[package]] +name = "tokio-threadpool" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df720b6581784c118f0eb4310796b12b1d242a7eb95f716a8367855325c25f89" +dependencies = [ + "crossbeam-deque", + "crossbeam-queue", + "crossbeam-utils 0.7.2", + "futures", + "lazy_static", + "log 0.4.21", + "num_cpus", + "slab", + "tokio-executor", +] + +[[package]] +name = "tokio-timer" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93044f2d313c95ff1cb7809ce9a7a05735b012288a888b62d4434fd58c94f296" +dependencies = [ + "crossbeam-utils 0.7.2", + "futures", + "slab", + "tokio-executor", +] + +[[package]] +name = "tokio-udp" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2a0b10e610b39c38b031a2fcab08e4b82f16ece36504988dcbd81dbba650d82" +dependencies = [ + "bytes", + "futures", + "log 0.4.21", + "mio", + "tokio-codec", + "tokio-io", + "tokio-reactor", +] + +[[package]] +name = "tokio-uds" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab57a4ac4111c8c9dbcf70779f6fc8bc35ae4b2454809febac840ad19bd7e4e0" +dependencies = [ + "bytes", + "futures", + "iovec", + "libc", + "log 0.4.21", + "mio", + "mio-uds", + "tokio-codec", + "tokio-io", + "tokio-reactor", +] + +[[package]] +name = "toml" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" +dependencies = [ + "serde", +] + +[[package]] +name = "traitobject" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "efd1f82c56340fdf16f2a953d7bda4f8fdffba13d93b00844c25572110b26079" + +[[package]] +name = "trust-dns-proto" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0838272e89f1c693b4df38dc353412e389cf548ceed6f9fd1af5a8d6e0e7cf74" +dependencies = [ + "byteorder", + "failure", + "futures", + "idna", + "lazy_static", + "log 0.4.21", + "rand 0.5.6", + "smallvec", + "socket2", + "tokio-executor", + "tokio-io", + "tokio-reactor", + "tokio-tcp", + "tokio-timer", + "tokio-udp", + "url", +] + +[[package]] +name = "trust-dns-proto" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09144f0992b0870fa8d2972cc069cbf1e3c0fda64d1f3d45c4d68d0e0b52ad4e" +dependencies = [ + "byteorder", + "failure", + "futures", + "idna", + "lazy_static", + "log 0.4.21", + "rand 0.5.6", + "smallvec", + "socket2", + "tokio-executor", + "tokio-io", + "tokio-reactor", + "tokio-tcp", + "tokio-timer", + "tokio-udp", + "url", +] + +[[package]] +name = "trust-dns-resolver" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9f877f7a1ad821ab350505e1f1b146a4960402991787191d6d8cab2ce2de2c" +dependencies = [ + "cfg-if 0.1.10", + "failure", + "futures", + "ipconfig", + "lazy_static", + "log 0.4.21", + "lru-cache", + "resolv-conf", + "smallvec", + "tokio", + "trust-dns-proto 0.6.3", +] + +[[package]] +name = "typeable" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1410f6f91f21d1612654e7cc69193b0334f909dcf2c790c4826254fbb86f8887" + +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] +name = "uint" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9db035e67dfaf7edd9aebfe8676afcd63eed53c8a4044fed514c8cccf1835177" +dependencies = [ + "byteorder", + "crunchy", + "rustc-hex", + "static_assertions", +] + +[[package]] +name = "unicase" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f4765f83163b74f957c797ad9253caf97f103fb064d3999aea9568d09fc8a33" +dependencies = [ + "version_check", +] + +[[package]] +name = "unicode-bidi" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "unicode-normalization" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-width" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" + +[[package]] +name = "unicode-xid" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" + +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + +[[package]] +name = "url" +version = "1.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a" +dependencies = [ + "idna", + "matches", + "percent-encoding", +] + +[[package]] +name = "uuid" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90dbc611eb48397705a6b0f6e917da23ae517e4d127123d2cf7674206627d32a" +dependencies = [ + "rand 0.6.5", +] + +[[package]] +name = "vec_map" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" + +[[package]] +name = "version_check" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" + +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + +[[package]] +name = "wasi" +version = "0.10.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "websocket" +version = "0.26.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92aacab060eea423e4036820ddd28f3f9003b2c4d8048cbda985e5a14e18038d" +dependencies = [ + "hyper", + "rand 0.6.5", + "unicase", + "url", + "websocket-base", +] + +[[package]] +name = "websocket-base" +version = "0.26.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49aec794b07318993d1db16156d5a9c750120597a5ee40c6b928d416186cb138" +dependencies = [ + "base64 0.10.1", + "bitflags 1.3.2", + "byteorder", + "rand 0.6.5", + "sha-1", +] + +[[package]] +name = "widestring" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7157704c2e12e3d2189c507b7482c52820a16dfa4465ba91add92f266667cadb" + +[[package]] +name = "winapi" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-build" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "winreg" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a27a759395c1195c4cc5cda607ef6f8f6498f64e78f7900f5de0a127a424704a" +dependencies = [ + "winapi 0.3.9", +] + +[[package]] +name = "ws2_32-sys" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" +dependencies = [ + "winapi 0.2.8", + "winapi-build", +] diff --git a/ip_country/Cargo.toml b/ip_country/Cargo.toml new file mode 100644 index 000000000..873af2758 --- /dev/null +++ b/ip_country/Cargo.toml @@ -0,0 +1,23 @@ +[package] +name = "ip_country" +version = "0.1.0" +edition = "2021" +license = "GPL-3.0-only" +authors = ["Dan Wiebe ", "MASQ"] +description = "Handle embedding IP-address-to-country data in MASQ Node" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +csv = "1.3.0" +lazy_static = "1.4.0" +masq_lib = { path = "../masq_lib" } + + +[[bin]] +name = "ip_country" +path = "src/main.rs" + +[lib] +name = "ip_country_lib" +path = "src/lib.rs" diff --git a/ip_country/src/bit_queue.rs b/ip_country/src/bit_queue.rs new file mode 100644 index 000000000..8523277d3 --- /dev/null +++ b/ip_country/src/bit_queue.rs @@ -0,0 +1,227 @@ +use std::cmp::min; +use std::collections::VecDeque; + +#[derive(Default)] +struct EndBuffer { + buffer: u8, + bit_count: usize +} + +impl EndBuffer { + fn bits_available(&self) -> usize { + 8 - self.bit_count + } + + fn set(&mut self, buffer: u8, bit_count: usize) { + self.buffer = buffer; + self.bit_count = bit_count; + } + + fn clear(&mut self) { + self.buffer = 0; + self.bit_count = 0; + } +} + +pub struct BitQueue { + back_buffer: EndBuffer, + byte_queue: VecDeque, + front_buffer: EndBuffer, +} + +impl BitQueue { + + pub fn new () -> Self { + Self { + back_buffer: EndBuffer::default(), + byte_queue: VecDeque::new(), + front_buffer: EndBuffer::default(), + } + } + + pub fn len(&self) -> usize { + self.back_buffer.bit_count + (self.byte_queue.len() * 8) + self.front_buffer.bit_count + } + + pub fn add_bits(&mut self, bits: u64, count: usize) { + if (count > 64) { + panic! ("You can only add bits up to 64 at a time, not {}", count) + } + let mut cur_bits = bits; + let mut cur_count = count; + loop { + let available_bits_in_back_buffer = self.back_buffer.bits_available(); + if cur_count < available_bits_in_back_buffer { + break; + } + let transfer_chunk_mask = !(u64::MAX << available_bits_in_back_buffer); + let transfer_chunk = bits & transfer_chunk_mask; + let positioned_transfer_chunk = (transfer_chunk << self.back_buffer.bit_count) as u8; + let new_byte = self.back_buffer.buffer | positioned_transfer_chunk; + self.byte_queue.push_back(new_byte); + self.back_buffer.clear(); + cur_bits >>= available_bits_in_back_buffer; + cur_count -= available_bits_in_back_buffer; + } + let available_bits_in_back_buffer = self.back_buffer.bits_available(); + let transfer_chunk_mask = !(u64::MAX << available_bits_in_back_buffer); + let transfer_chunk = bits & transfer_chunk_mask; + let positioned_transfer_chunk = (transfer_chunk << self.back_buffer.bit_count) as u8; + let new_buffer = self.back_buffer.buffer | positioned_transfer_chunk; + self.back_buffer.set(new_buffer, self.back_buffer.bit_count + cur_count); + } + + pub fn take_bits(&mut self, count: usize) -> Option { + if count > 64 { + panic!("You can only take bits up to 64 at a time, not {}", count) + } + let self_len = self.len(); + if count > self_len { + return None + } + let mut cur_bits = 0u64; + let mut cur_count = 0usize; + // Satisfy request from front_buffer if possible + let bits_needed_from_front_buffer = count.min(self.front_buffer.bit_count); + cur_bits = (self.front_buffer.buffer as u64) & !(u64::MAX << bits_needed_from_front_buffer); + cur_count = bits_needed_from_front_buffer; + self.front_buffer.buffer >>= bits_needed_from_front_buffer; + self.front_buffer.bit_count -= bits_needed_from_front_buffer; + if cur_count == count { + return Some(cur_bits) + } + // If not, use byte_queue + self.front_buffer.clear(); + while (count - cur_count) >= 8 { + let next_byte = self.byte_queue.pop_front().expect("You said there were enough!"); + cur_bits = (cur_bits << 8) | (next_byte as u64); + cur_count += 8; + } + if self.byte_queue.is_empty() { + // get remaining bits from back_buffer + let bits_needed_from_back_buffer = (count - cur_count).min(self.back_buffer.bit_count); + cur_bits = (self.back_buffer.buffer as u64) & !(u64::MAX << bits_needed_from_back_buffer); + cur_count += bits_needed_from_back_buffer; + self.back_buffer.buffer >>= bits_needed_from_back_buffer; + self.back_buffer.bit_count -= bits_needed_from_back_buffer; + return Some(cur_bits) + } + else { + // repopulate front_buffer and get remaining bits from it + self.front_buffer.buffer = self.byte_queue.pop_front().expect("You said there were enough!"); + self.front_buffer.bit_count = 8; + let bits_still_needed = count - cur_count; + let bits = self.front_buffer.buffer & !(u8::MAX << bits_still_needed); + cur_bits = (cur_bits << bits_still_needed) | (bits as u64); + self.front_buffer.buffer >>= bits_still_needed; + self.front_buffer.bit_count -= bits_still_needed; + Some (cur_bits) + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn reading_without_writing_produces_none() { + let mut subject = BitQueue::new(); + + let result = subject.take_bits(1); + + assert_eq! (result, None); + } + + #[test] + #[should_panic(expected = "You can only add bits up to 64 at a time, not 65")] + fn adding_more_than_64_bits_causes_panic() { + let mut subject = BitQueue::new(); + + subject.add_bits(0, 65); + } + + #[test] + #[should_panic(expected = "You can only take bits up to 64 at a time, not 65")] + fn taking_more_than_64_bits_causes_panic() { + let mut subject = BitQueue::new(); + + let _ = subject.take_bits(65); + } + + #[test] + fn queues_and_unqueues_one_bit() { + let mut subject = BitQueue::new(); + + subject.add_bits(1, 1); + let one_bit = subject.take_bits(1); + subject.add_bits(0, 1); + let zero_bit = subject.take_bits(1); + + assert_eq!(one_bit, Some(1)); + assert_eq!(zero_bit, Some(0)); + } + + #[test] + fn queues_and_unqueues_32_bits() { + let mut subject = BitQueue::new(); + + subject.add_bits(0xB77BEFDF, 32); + let result = subject.take_bits(32); + + assert_eq!(result, Some(0xB77BEFDF)); + } + + #[test] + fn can_queue_bits_properly() { + let mut subject = BitQueue::new(); + + subject.add_bits(0b11011, 5); + subject.add_bits(0b00111001110011100, 17); + subject.add_bits(0b1, 1); + + let first_chunk = subject.take_bits(10).unwrap(); + let second_chunk = subject.take_bits(5).unwrap(); + let third_chunk = subject.take_bits(5).unwrap(); + let fourth_chunk = subject.take_bits(3).unwrap(); + let should_be_none = subject.take_bits(1); + + assert_eq!(first_chunk, 0b1101100111); + assert_eq!(second_chunk, 0b00111); + assert_eq!(third_chunk, 0b00111); + assert_eq!(fourth_chunk, 0b001); + assert_eq!(should_be_none, None); + } +} + +/* + let mut cur_bits = 0u64; + let mut cur_count = count; + if self.front_buffer.bit_count >= cur_count { + let mask = !(u64::MAX << cur_count); + cur_bits = self.front_buffer.buffer as u64; + cur_bits &= mask; + self.front_buffer.buffer = self.front_buffer.buffer >> cur_bits; + self.front_buffer.bit_count -= cur_bits; + return Some(cur_bits) + } + // May have bits in the front_buffer still, but not enough to satisfy the request + cur_bits = self.front_buffer.buffer as u64; + cur_count -= self.front_buffer.bit_count; + self.front_buffer.clear(); + while cur_count >= 8 { + if self.byte_queue.is_empty() { + return None + } + let next_byte = self.byte_queue.pop_front().expect("You said it wasn't empty!"); + cur_bits <<= 8; + cur_bits &= next_byte as u64; + cur_count -= 8; + } + + + // Get bits from front_buffer + // If that's enough, return them + // If not, pull bytes from queue until there are enough + // Leave extra bits in front_buffer + */ \ No newline at end of file diff --git a/ip_country/src/countries.rs b/ip_country/src/countries.rs new file mode 100644 index 000000000..e473be18e --- /dev/null +++ b/ip_country/src/countries.rs @@ -0,0 +1,361 @@ +use std::collections::HashMap; +use lazy_static::lazy_static; +use crate::country_block_stream::Country; + +lazy_static! { + pub static ref COUNTRIES: Vec = vec![ + Country::new(0, "ZZ", "Sentinel"), + Country::new(1, "AF", "Afghanistan"), + Country::new(2, "AX", "Aland Islands"), + Country::new(3, "AL", "Albania"), + Country::new(4, "DZ", "Algeria"), + Country::new(5, "AS", "American Samoa"), + Country::new(6, "AD", "Andorra"), + Country::new(7, "AO", "Angola"), + Country::new(8, "AI", "Anguilla"), + Country::new(9, "AQ", "Antarctica"), + Country::new(10, "AG", "Antigua and Barbuda"), + Country::new(11, "AR", "Argentina"), + Country::new(12, "AM", "Armenia"), + Country::new(13, "AW", "Aruba"), + Country::new(14, "AU", "Australia"), + Country::new(15, "AT", "Austria"), + Country::new(16, "AZ", "Azerbaijan"), + Country::new(17, "BS", "Bahamas"), + Country::new(18, "BH", "Bahrain"), + Country::new(19, "BD", "Bangladesh"), + Country::new(20, "BB", "Barbados"), + Country::new(21, "BY", "Belarus"), + Country::new(22, "BE", "Belgium"), + Country::new(23, "BZ", "Belize"), + Country::new(24, "BJ", "Benin"), + Country::new(25, "BM", "Bermuda"), + Country::new(26, "BT", "Bhutan"), + Country::new(27, "BO", "Bolivia"), + Country::new(28, "BQ", "Bonaire, Sint Eustatius, Saba"), + Country::new(29, "BA", "Bosnia, Herzegovina"), + Country::new(30, "BW", "Botswana"), + Country::new(31, "BV", "Bouvet Island"), + Country::new(32, "BR", "Brazil"), + Country::new(33, "IO", "British Indian Ocean Territory"), + Country::new(34, "BN", "Brunei Darussalam"), + Country::new(35, "BG", "Bulgaria"), + Country::new(36, "BF", "Burkina Faso"), + Country::new(37, "BI", "Burundi"), + Country::new(38, "CV", "Cabo Verde"), + Country::new(39, "KH", "Cambodia"), + Country::new(40, "CM", "Cameroon"), + Country::new(41, "CA", "Canada"), + Country::new(42, "KY", "Cayman Islands"), + Country::new(43, "CF", "Central African Republic"), + Country::new(44, "TD", "Chad"), + Country::new(45, "CL", "Chile"), + Country::new(46, "CN", "China"), + Country::new(47, "CX", "Christmas Island"), + Country::new(48, "CC", "Cocos Islands"), + Country::new(49, "CO", "Colombia"), + Country::new(50, "KM", "Comoros"), + Country::new(51, "CD", "Democratic Republic of Congo"), + Country::new(52, "CG", "Congo"), + Country::new(53, "CK", "Cook Islands"), + Country::new(54, "CR", "Costa Rica"), + Country::new(55, "CI", "Ivory Coast"), + Country::new(56, "HR", "Croatia"), + Country::new(57, "CU", "Cuba"), + Country::new(58, "CW", "Curacao"), + Country::new(59, "CY", "Cyprus"), + Country::new(60, "CZ", "Czechia"), + Country::new(61, "DK", "Denmark"), + Country::new(62, "DJ", "Djibouti"), + Country::new(63, "DM", "Dominica"), + Country::new(64, "DO", "Dominican Republic"), + Country::new(65, "EC", "Ecuador"), + Country::new(66, "EG", "Egypt"), + Country::new(67, "SV", "El Salvador"), + Country::new(68, "GQ", "Equatorial Guinea"), + Country::new(69, "ER", "Eritrea"), + Country::new(70, "EE", "Estonia"), + Country::new(71, "SZ", "Eswatini"), + Country::new(72, "ET", "Ethiopia"), + Country::new(73, "FK", "Falkland Islands"), + Country::new(74, "FO", "Faroe Islands"), + Country::new(75, "FJ", "Fiji"), + Country::new(76, "FI", "Finland"), + Country::new(77, "FR", "France"), + Country::new(78, "GF", "French Guiana"), + Country::new(79, "PF", "French Polynesia"), + Country::new(80, "TF", "French Southern Territories"), + Country::new(81, "GA", "Gabon"), + Country::new(82, "GM", "Gambia"), + Country::new(83, "GE", "Georgia"), + Country::new(84, "DE", "Germany"), + Country::new(85, "GH", "Ghana"), + Country::new(86, "GI", "Gibraltar"), + Country::new(87, "GR", "Greece"), + Country::new(88, "GL", "Greenland"), + Country::new(89, "GD", "Grenada"), + Country::new(90, "GP", "Guadeloupe"), + Country::new(91, "GU", "Guam"), + Country::new(92, "GT", "Guatemala"), + Country::new(93, "GG", "Guernsey"), + Country::new(94, "GN", "Guinea"), + Country::new(95, "GW", "Guinea-Bissau"), + Country::new(96, "GY", "Guyana"), + Country::new(97, "HT", "Haiti"), + Country::new(98, "HM", "Heard Island and McDonald Islands"), + Country::new(99, "VA", "Holy See"), + Country::new(100, "HN", "Honduras"), + Country::new(101, "HK", "Hong Kong"), + Country::new(102, "HU", "Hungary"), + Country::new(103, "IS", "Iceland"), + Country::new(104, "IN", "India"), + Country::new(105, "ID", "Indonesia"), + Country::new(106, "IR", "Iran"), + Country::new(107, "IQ", "Iraq"), + Country::new(108, "IE", "Ireland"), + Country::new(109, "IM", "Isle of Man"), + Country::new(110, "IL", "Israel"), + Country::new(111, "IT", "Italy"), + Country::new(112, "JM", "Jamaica"), + Country::new(113, "JP", "Japan"), + Country::new(114, "JE", "Jersey"), + Country::new(115, "JO", "Jordan"), + Country::new(116, "KZ", "Kazakhstan"), + Country::new(117, "KE", "Kenya"), + Country::new(118, "KI", "Kiribati"), + Country::new(119, "KP", "North Korea"), + Country::new(120, "KR", "South Korea"), + Country::new(121, "KW", "Kuwait"), + Country::new(122, "KG", "Kyrgyzstan"), + Country::new(123, "LA", "Lao People's Democratic Republic"), + Country::new(124, "LV", "Latvia"), + Country::new(125, "LB", "Lebanon"), + Country::new(126, "LS", "Lesotho"), + Country::new(127, "LR", "Liberia"), + Country::new(128, "LY", "Libya"), + Country::new(129, "LI", "Liechtenstein"), + Country::new(130, "LT", "Lithuania"), + Country::new(131, "LU", "Luxembourg"), + Country::new(132, "MO", "Macao"), + Country::new(133, "MG", "Madagascar"), + Country::new(134, "MW", "Malawi"), + Country::new(135, "MY", "Malaysia"), + Country::new(136, "MV", "Maldives"), + Country::new(137, "ML", "Mali"), + Country::new(138, "MT", "Malta"), + Country::new(139, "MH", "Harshall Islands"), + Country::new(140, "MQ", "Martinique"), + Country::new(141, "MR", "Mauritania"), + Country::new(142, "MU", "Mauritius"), + Country::new(143, "YT", "Mayotte"), + Country::new(144, "MX", "Mexico"), + Country::new(145, "FM", "Micronesia"), + Country::new(146, "MD", "Moldova"), + Country::new(147, "MC", "Monaco"), + Country::new(148, "MN", "Mongolia"), + Country::new(149, "ME", "Montenegro"), + Country::new(150, "MS", "Montserrat"), + Country::new(151, "MA", "Morocco"), + Country::new(152, "MZ", "Mozambique"), + Country::new(153, "MM", "Myanmar"), + Country::new(154, "NA", "Namibia"), + Country::new(155, "NR", "Nauru"), + Country::new(156, "NP", "Nepal"), + Country::new(157, "NL", "Netherlands"), + Country::new(158, "NC", "New Caledonia"), + Country::new(159, "NZ", "New Zealand"), + Country::new(160, "NI", "Nicaragua"), + Country::new(161, "NE", "Niger"), + Country::new(162, "NG", "Nigeria"), + Country::new(163, "NU", "Niue"), + Country::new(164, "NF", "Norfolk Island"), + Country::new(165, "MK", "North Macedonia"), + Country::new(166, "MP", "Morthern Mariana Islands"), + Country::new(167, "NO", "Norway"), + Country::new(168, "OM", "Oman"), + Country::new(169, "PK", "Pakistan"), + Country::new(170, "PW", "Palau"), + Country::new(171, "PS", "Palestine"), + Country::new(172, "PA", "Panama"), + Country::new(173, "PG", "Papua New Guinea"), + Country::new(174, "PY", "Paraguay"), + Country::new(175, "PE", "Peru"), + Country::new(176, "PH", "Phillipines"), + Country::new(177, "PN", "Pitcairn"), + Country::new(178, "PL", "Poland"), + Country::new(179, "PT", "Portugal"), + Country::new(180, "PR", "Puerto Rico"), + Country::new(181, "QA", "Qatar"), + Country::new(182, "RE", "Reunion"), + Country::new(183, "RO", "Romanian"), + Country::new(184, "RU", "Russian Federation"), + Country::new(185, "RW", "Rwanda"), + Country::new(186, "BL", "Saint Barthelemy"), + Country::new(187, "SH", "Saint Helena, Ascension Island, Tristan da Cunha"), + Country::new(188, "KN", "Saint Kitts and Nevis"), + Country::new(189, "LC", "Saint Lucia"), + Country::new(190, "MF", "Saint Martin"), + Country::new(191, "PM", "Saint Pierre and Miquelon"), + Country::new(192, "VC", "Saint Vincent and the Grenadines"), + Country::new(193, "WS", "Samoa"), + Country::new(194, "SM", "San Marino"), + Country::new(195, "ST", "Sao Tome and Principe"), + Country::new(196, "SA", "Saudi Arabia"), + Country::new(197, "SN", "Senegal"), + Country::new(198, "RS", "Serbia"), + Country::new(199, "SC", "Seychelles"), + Country::new(200, "SL", "Sierra Leone"), + Country::new(201, "SG", "Singapore"), + Country::new(202, "SX", "Sint Maarten"), + Country::new(203, "SK", "Slovakia"), + Country::new(204, "SI", "Slovenia"), + Country::new(205, "SB", "Solomon Islands"), + Country::new(206, "SO", "Somalia"), + Country::new(207, "ZA", "South Africa"), + Country::new(208, "GS", "South Georgia and the South Sandwich Islands"), + Country::new(209, "SS", "South Sudan"), + Country::new(210, "ES", "Spain"), + Country::new(211, "LK", "Sri Lanka"), + Country::new(212, "SD", "Sudan"), + Country::new(213, "SR", "Suriname"), + Country::new(214, "SJ", "Svalbard and Jan Mayen"), + Country::new(215, "SE", "Sweden"), + Country::new(216, "CH", "Switzerland"), + Country::new(217, "SY", "Syrian Arab Republic"), + Country::new(218, "TW", "Taiwan"), + Country::new(219, "TJ", "Tajikistan"), + Country::new(220, "TZ", "Tanzania"), + Country::new(221, "TH", "Thailand"), + Country::new(222, "TL", "Timor-Leste"), + Country::new(223, "TG", "Togo"), + Country::new(224, "TK", "Tokelau"), + Country::new(225, "TO", "Tonga"), + Country::new(226, "TT", "Trinidad and Tobago"), + Country::new(227, "TN", "Tunisia"), + Country::new(228, "TR", "Turkiye"), + Country::new(229, "TM", "Turkmenistan"), + Country::new(230, "TC", "Turks and Caicos Islands"), + Country::new(231, "TV", "Tuvalu"), + Country::new(232, "UG", "Uganda"), + Country::new(233, "UA", "Ukraine"), + Country::new(234, "AE", "United Arab Emirates"), + Country::new(235, "GB", "United Kingdom"), + Country::new(236, "UM", "United States Minor Outlying Islands"), + Country::new(237, "US", "United States"), + Country::new(238, "UY", "Uruguay"), + Country::new(239, "UZ", "Uzbekistan"), + Country::new(240, "VU", "Vanuatu"), + Country::new(241, "VE", "Venezuela"), + Country::new(242, "VN", "Vietnam"), + Country::new(243, "VG", "British Virgin Islands"), + Country::new(244, "VI", "US Virgin Islands"), + Country::new(245, "WF", "Wallis and Futuna"), + Country::new(246, "EH", "Western Sahara"), + Country::new(247, "YE", "Yemen"), + Country::new(248, "ZM", "Zambia"), + Country::new(249, "ZW", "Zimbabwe"), + ]; + + pub static ref INDEX_BY_ISO3166: HashMap = COUNTRIES + .iter() + .map(|country| (country.iso3166.clone(), country.index)) + .collect::>(); +} + +impl TryFrom<&str> for Country { + type Error = String; + + fn try_from(iso3166: &str) -> Result { + let index = match INDEX_BY_ISO3166.get(&iso3166.to_ascii_uppercase()) { + None => return Err(format!("'{}' is not a valid ISO3166 country code", iso3166)), + Some(index) => *index, + }; + Ok(Country::try_from(index).expect(&format!("Data error: ISO3166 {} maps to index {}, but there is no such Country", iso3166, index))) + } +} + +impl TryFrom for Country { + type Error = String; + + fn try_from(index: usize) -> Result { + match COUNTRIES.get(index) { + None => Err(format!("There are only {} Countries; no Country is at index {}", COUNTRIES.len(), index)), + Some(country) => Ok(country.clone()), + } + } +} + +#[cfg(test)] +mod tests { + use crate::countries::COUNTRIES; + use crate::country_block_stream::Country; + + #[test] + fn countries_are_properly_ordered() { + COUNTRIES.iter() + .enumerate() + .for_each(|(index, country)| + assert_eq!( + country.index, + index, + "Index for {} should have been {} but was {}", + country.name, + index, + country.index + ) + ); + } + + #[test] + fn string_length_check() { + COUNTRIES.iter() + .for_each(|country| { + assert_eq!(country.iso3166.len(), 2); + assert_eq!( + country.name.len() > 0, true, + "Blank country name for {} at index {}", + country.iso3166, country.index + ); + }) + } + + #[test] + fn try_from_str_happy_path() { + + let result = Country::try_from("IL"); + + assert_eq!(result, Ok(COUNTRIES.get(110).unwrap().clone())); + } + + #[test] + fn try_from_str_wrong_case() { + + let result = Country::try_from("il"); + + assert_eq!(result, Ok(COUNTRIES.get(110).unwrap().clone())); + } + + #[test] + fn try_from_str_bad_iso3166() { + + let result = Country::try_from("Booga"); + + assert_eq!(result, Err("'Booga' is not a valid ISO3166 country code".to_string())); + } + + #[test] + fn try_from_index_happy_path() { + + let result = Country::try_from(110); + + assert_eq!(result, Ok(COUNTRIES.get(110).unwrap().clone())); + } + + #[test] + fn try_from_index_bad_index() { + + let result = Country::try_from(4096); + + assert_eq!(result, Err(format!("There are only {} Countries; no Country is at index 4096", COUNTRIES.len()))); + } +} \ No newline at end of file diff --git a/ip_country/src/country_block_stream.rs b/ip_country/src/country_block_stream.rs new file mode 100644 index 000000000..be10e97f6 --- /dev/null +++ b/ip_country/src/country_block_stream.rs @@ -0,0 +1,153 @@ + +use std::net::IpAddr; +use std::str::FromStr; +use csv::{StringRecord, StringRecordIter}; +use crate::bit_queue::BitQueue; + +#[derive(Clone, PartialEq, Debug)] +pub struct Country { + pub index: usize, + pub iso3166: String, + pub name: String, +} + +impl Country { + pub fn new(index: usize, iso3166: &str, name: &str) -> Self { + Self { + index, + iso3166: iso3166.to_string(), + name: name.to_string(), + } + } +} + +#[derive(Clone, PartialEq, Debug)] +pub struct CountryBlock { + start_ip: IpAddr, + end_ip: IpAddr, + country: Country, +} + +impl TryFrom for CountryBlock { + type Error = String; + + fn try_from(string_record: StringRecord) -> Result { + let mut iter = string_record.iter(); + let start_ip = Self::ip_addr_from_iter(&mut iter)?; + let end_ip = Self::ip_addr_from_iter(&mut iter)?; + let iso3166 = match iter.next() { + None => return Err("CSV line contains no ISO 3166 country code".to_string()), + Some(s) => s, + }; + if iter.next().is_some() { + return Err(format!("CSV line should contain 3 elements, but contains {}", string_record.len())) + }; + let country = Country::try_from(iso3166)?; + Ok(CountryBlock { + start_ip, + end_ip, + country + }) + } +} + +impl CountryBlock { + pub fn serialize_to(&self, bit_queue: &mut BitQueue) { + todo!() + } + + fn ip_addr_from_iter(iter: &mut StringRecordIter) -> Result { + let ip_string = match iter.next() { + None => return Err("Missing IP address in CSV record".to_string()), + Some (s) => s, + }; + let ip_addr = match IpAddr::from_str(ip_string) { + Err(e) => return Err(format!("Invalid IP address in CSV record: '{}'", ip_string)), + Ok(ip) => ip, + }; + Ok(ip_addr) + } +} + +#[cfg(test)] +mod tests { + use std::str::FromStr; + use crate::countries::{COUNTRIES, INDEX_BY_ISO3166}; + use super::*; + + #[test] + fn try_from_works_for_ipv4() { + let string_record = StringRecord::from(vec!["1.2.3.4", "5.6.7.8", "AS"]); + + let result = CountryBlock::try_from(string_record); + + assert_eq! (result, Ok(CountryBlock { + start_ip: IpAddr::from_str("1.2.3.4").unwrap(), + end_ip: IpAddr::from_str("5.6.7.8").unwrap(), + country: Country::try_from("AS").unwrap().clone(), + })); + } + + #[test] + fn try_from_works_for_ipv6() { + let string_record = StringRecord::from(vec![ + "1234:2345:3456:4567:5678:6789:789A:89AB", + "4321:5432:6543:7654:8765:9876:A987:BA98", + "VN" + ]); + + let result = CountryBlock::try_from(string_record); + + assert_eq! (result, Ok(CountryBlock { + start_ip: IpAddr::from_str("1234:2345:3456:4567:5678:6789:789A:89AB").unwrap(), + end_ip: IpAddr::from_str("4321:5432:6543:7654:8765:9876:A987:BA98").unwrap(), + country: Country::try_from("VN").unwrap().clone(), + })); + } + + #[test] + fn try_from_fails_for_bad_ip_syntax() { + let string_record = StringRecord::from(vec!["Ooga", "Booga", "AS"]); + + let result = CountryBlock::try_from(string_record); + + assert_eq!(result, Err("Invalid IP address in CSV record: 'Ooga'".to_string())); + } + + #[test] + fn try_from_fails_for_missing_start_ip() { + let strings: Vec<&str> = vec![]; + let string_record = StringRecord::from(strings); + + let result = CountryBlock::try_from(string_record); + + assert_eq!(result, Err("Missing IP address in CSV record".to_string())); + } + + #[test] + fn try_from_fails_for_missing_end_ip() { + let string_record = StringRecord::from(vec!["1.2.3.4"]); + + let result = CountryBlock::try_from(string_record); + + assert_eq!(result, Err("Missing IP address in CSV record".to_string())); + } + + #[test] + fn try_from_fails_for_missing_iso3166() { + let string_record = StringRecord::from(vec!["1.2.3.4", "5.6.7.8"]); + + let result = CountryBlock::try_from(string_record); + + assert_eq!(result, Err("CSV line contains no ISO 3166 country code".to_string())); + } + + #[test] + fn try_from_fails_for_too_many_elements() { + let string_record = StringRecord::from(vec!["1.2.3.4", "5.6.7.8", "US", "extra"]); + + let result = CountryBlock::try_from(string_record); + + assert_eq!(result, Err("CSV line should contain 3 elements, but contains 4".to_string())); + } +} \ No newline at end of file diff --git a/ip_country/src/ip_country.rs b/ip_country/src/ip_country.rs new file mode 100644 index 000000000..16f3078d8 --- /dev/null +++ b/ip_country/src/ip_country.rs @@ -0,0 +1,129 @@ +use std::io; +use masq_lib::test_utils::fake_stream_holder::ByteArrayWriter; +use crate::bit_queue::BitQueue; +use crate::country_block_stream::CountryBlock; + +pub fn ip_country( + args: Vec, + stdin: &mut dyn io::Read, + stdout: &mut dyn io::Write, + stderr: &mut dyn io::Write +) -> i32 { + let mut bit_queue = BitQueue::new(); + let mut line_number = 0usize; + let mut csvRdr = csv::Reader::from_reader(stdin); + let errors = csvRdr.records() + .map(|string_record_result| { + match string_record_result { + Ok(string_record) => CountryBlock::try_from(string_record), + Err(e) => Err(format!("{:?}", e)) + } + }) + .flat_map(|country_block_result| { + line_number += 1; + match country_block_result { + Ok(country_block) => { + country_block.serialize_to(&mut bit_queue); + None + }, + Err(e) => Some(format!("Line {}: {}", line_number, e)), // TODO no test for this line yet + } + }) + .collect::>(); + generate_rust_code (bit_queue, stdout); + if (errors.is_empty()) { + return 0 + } + else { + todo!("Write errors to stderr and return error code"); + } +} + +fn generate_rust_code(mut bit_queue: BitQueue, output: &mut dyn io::Write) { + todo!() +} + +#[cfg(test)] +mod tests { + use masq_lib::test_utils::fake_stream_holder::{ByteArrayReader, ByteArrayWriter}; + use super::*; + + static TEST_DATA: &str = +"0.0.0.0,0.255.255.255,ZZ +1.0.0.0,1.0.0.255,AU +1.0.1.0,1.0.3.255,CN +1.0.4.0,1.0.7.255,AU +1.0.8.0,1.0.15.255,CN +1.0.16.0,1.0.31.255,JP +1.0.32.0,1.0.63.255,CN +1.0.64.0,1.0.127.255,JP +1.0.128.0,1.0.255.255,TH +1.1.0.0,1.1.0.255,CN +"; + + /* +IPv4 +For each block: + Two bits: number of elements since the last block that have changed, minus one + For each changed element: + Two bits giving the index of the changed element + Eight bits giving the value of the changed element + Nine bits giving the index of the country code in crate::countries::COUNTRIES + +000.000.000.000, 000.255.255.255, ZZ +001.000.000.000, 001.000.000.255, AU +001.000.001.000, 001.000.003.255, CN +001.000.004.000, 001.000.007.255, AU +001.000.008.000, 001.000.015.255, CN +001.000.016.000, 001.000.031.255, JP +001.000.032.000, 001.000.063.255, CN +001.000.064.000, 001.000.127.255, JP +001.000.128.000, 001.000.255.255, TH +001.001.000.000, 001.001.000.255, CN +001.001.001.000, ? , ZZ + +11 00 00000000 01 00000000 10 00000000 11 00000000 000000000 +00 00 00000001 000001110 +00 10 00000001 000101110 +00 10 00000100 000001110 +00 10 00001000 000101110 +00 10 00010000 001110001 +00 10 00100000 000101110 +00 10 01000000 001110001 +00 10 10000000 011011101 +01 01 00000001 10 00000000 0000011|10 +00 10 00000001 000000000 +------------------------------------------------------------------------------------- +C0040200C00000020E201171020388205C42071220171201C4A01BA8030003880400 + + */ + + #[test] + fn high_level_test() { + let mut stdin = ByteArrayReader::new(TEST_DATA.as_bytes()); + let mut stdout = ByteArrayWriter::new(); + let mut stderr = ByteArrayWriter::new(); + + let result = ip_country(vec![], &mut stdin, &mut stdout, &mut stderr); + + assert_eq!(result, 0); + let stdout_string = String::from_utf8(stdout.get_bytes()).unwrap(); + let stderr_string = String::from_utf8(stderr.get_bytes()).unwrap(); + assert_eq!(stdout_string, +" +// GENERATED CODE: DO NOT MODIFY! +use lazy_static::lazy_static; + +lazy_static! { + static ref IP_COUNTRY_DATA: Vec = vec![ + 0xC0, 0x04, 0x02, 0x00, 0xC0, 0x00, 0x00, 0x02, 0x0E, 0x20, + 0x11, 0x71, 0x02, 0x03, 0x88, 0x20, 0x5C, 0x42, 0x07, 0x12, + 0x20, 0x17, 0x12, 0x01, 0xC4, 0xA0, 0x1B, 0xA8, 0x03, 0x00, + 0x03, 0x88, 0x04, 0x00, + ]; +} +".to_string() + ); + assert_eq!(stderr_string, "".to_string()); + } +} diff --git a/ip_country/src/lib.rs b/ip_country/src/lib.rs new file mode 100644 index 000000000..b19e3fa1e --- /dev/null +++ b/ip_country/src/lib.rs @@ -0,0 +1,5 @@ +pub mod countries; +pub mod country_block_stream; +pub mod ip_country; +pub mod bit_queue; + diff --git a/ip_country/src/main.rs b/ip_country/src/main.rs new file mode 100644 index 000000000..978a24536 --- /dev/null +++ b/ip_country/src/main.rs @@ -0,0 +1,8 @@ +use std::io; +use std::env; +use std::process; +use ip_country_lib::ip_country::ip_country; + +pub fn main() { + process::exit(ip_country(env::args().collect(), &mut io::stdin(), &mut io::stdout(), &mut io::stderr())) +}