diff --git a/.gitignore b/.gitignore index ea8c4bf..244f4e5 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /target +*.api_key diff --git a/Cargo.lock b/Cargo.lock index d015493..9968daf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,40 +1,59 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi", + "libc", + "winapi 0.3.9", +] + [[package]] name = "autocfg" -version = "1.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "base64" -version = "0.12.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d1ccbaf7d9ec9537465a97bf19edc1a4e158ecb49fc16178202238c569cc42" +checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" [[package]] name = "bitflags" -version = "1.2.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bumpalo" -version = "3.4.0" +version = "3.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e8c087f005730276d1096a652e92a8bacee2e2472bcc9715a74d2bec38b5820" +checksum = "c1ad822118d20d2c234f427000d5acc36eabe1e29a348c89b63dd60b13f28e5d" [[package]] name = "bytes" -version = "0.5.4" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "130aac562c0dd69c56b3b1cc8ffd2e17be31d0b6c25b61c96b76231aa23e39e1" +checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38" + +[[package]] +name = "bytes" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec8a7b6a70fde80372154c65702f00a0f56f3e1c36abbc6c440484be248856db" [[package]] name = "cc" -version = "1.0.54" +version = "1.0.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bbb73db36c1246e9034e307d0fba23f9a2e251faa47ade70c1bd252220c8311" +checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" [[package]] name = "cfg-if" @@ -43,10 +62,53 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] -name = "core-foundation" -version = "0.7.0" +name = "cfg-if" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57d24c7a13c43e870e37c1556b74555437870a04514f7685f5b354e090567171" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "clap" +version = "4.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5840cd9093aabeabf7fd932754c435b7674520fc3ddc935c397837050f0f1e4b" +dependencies = [ + "atty", + "bitflags", + "clap_derive", + "clap_lex", + "once_cell", + "strsim", + "termcolor", +] + +[[package]] +name = "clap_derive" +version = "4.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92289ffc6fb4a85d85c246ddb874c05a87a2e540fb6ad52f7ca07c8c1e1840b1" +dependencies = [ + "heck", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d4198f73e42b4936b35b5bb248d81d2b595ecb170da0bac7655c54eedfa8da8" +dependencies = [ + "os_str_bytes", +] + +[[package]] +name = "core-foundation" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" dependencies = [ "core-foundation-sys", "libc", @@ -54,23 +116,26 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.7.0" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3a71ab494c0b5b860bdc8407ae08978052417070c2ced38573a9157ad75b8ac" - -[[package]] -name = "dtoa" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4358a9e11b9a09cf52383b451b49a169e8d797b68aa02301ff586d70d9661ea3" +checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" [[package]] name = "encoding_rs" -version = "0.8.23" +version = "0.8.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8ac63f94732332f44fe654443c46f6375d1939684c17b0afb6cb56b0456e171" +checksum = "9852635589dc9f9ea1b6fe9f05b50ef208c85c834a562f0c6abb1c475736ec2b" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", +] + +[[package]] +name = "fastrand" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" +dependencies = [ + "instant", ] [[package]] @@ -94,6 +159,15 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" +[[package]] +name = "form_urlencoded" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +dependencies = [ + "percent-encoding", +] + [[package]] name = "fuchsia-zircon" version = "0.3.3" @@ -112,103 +186,102 @@ checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" [[package]] name = "futures-channel" -version = "0.3.5" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f366ad74c28cca6ba456d95e6422883cfb4b252a83bed929c83abfdbbf2967d5" +checksum = "30bdd20c28fadd505d0fd6712cdfcb0d4b5648baf45faef7f852afb2399bb050" dependencies = [ "futures-core", ] [[package]] name = "futures-core" -version = "0.3.5" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59f5fff90fd5d971f936ad674802482ba441b6f09ba5e15fd8b39145582ca399" +checksum = "4e5aa3de05362c3fb88de6531e6296e85cde7739cccad4b9dfeeb7f6ebce56bf" [[package]] name = "futures-io" -version = "0.3.5" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de27142b013a8e869c14957e6d2edeef89e97c289e69d042ee3a49acd8b51789" +checksum = "bbf4d2a7a308fd4578637c0b17c7e1c7ba127b8f6ba00b29f717e9655d85eb68" [[package]] name = "futures-sink" -version = "0.3.5" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f2032893cb734c7a05d85ce0cc8b8c4075278e93b24b66f9de99d6eb0fa8acc" +checksum = "21b20ba5a92e727ba30e72834706623d94ac93a725410b6a6b6fbc1b07f7ba56" [[package]] name = "futures-task" -version = "0.3.5" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdb66b5f09e22019b1ab0830f7785bcea8e7a42148683f99214f73f8ec21a626" -dependencies = [ - "once_cell", -] +checksum = "a6508c467c73851293f390476d4491cf4d227dbabcd4170f3bb6044959b294f1" [[package]] name = "futures-util" -version = "0.3.5" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8764574ff08b701a084482c3c7031349104b07ac897393010494beaa18ce32c6" +checksum = "44fb6cb1be61cc1d2e43b262516aafcf63b241cffdb1d3fa115f91d9c7b09c90" dependencies = [ "futures-core", "futures-io", "futures-task", "memchr", - "pin-project", + "pin-project-lite 0.2.9", "pin-utils", "slab", ] -[[package]] -name = "getrandom" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb" -dependencies = [ - "cfg-if", - "libc", - "wasi", -] - [[package]] name = "h2" -version = "0.2.5" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79b7246d7e4b979c03fa093da39cfb3617a96bbeee6310af63991668d7e843ff" +checksum = "5e4728fd124914ad25e99e3d15a9361a879f6620f63cb56bbb08f95abb97a535" dependencies = [ - "bytes", + "bytes 0.5.6", "fnv", "futures-core", "futures-sink", "futures-util", "http", "indexmap", - "log", "slab", "tokio", "tokio-util", + "tracing", + "tracing-futures", ] [[package]] -name = "hermit-abi" -version = "0.1.13" +name = "hashbrown" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91780f809e750b0a89f5544be56617ff6b1227ee485bcb06ebe10cdf89bd3b71" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[package]] +name = "heck" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" + +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" dependencies = [ "libc", ] [[package]] name = "http" -version = "0.2.1" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d569972648b2c512421b5f2a405ad6ac9666547189d0c5477a3f200f3e02f9" +checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399" dependencies = [ - "bytes", + "bytes 1.2.1", "fnv", - "itoa", + "itoa 1.0.3", ] [[package]] @@ -217,23 +290,29 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13d5ff830006f7646652e057693569bfe0d51760c0085a071769d142a205111b" dependencies = [ - "bytes", + "bytes 0.5.6", "http", ] [[package]] name = "httparse" -version = "1.3.4" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" + +[[package]] +name = "httpdate" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "494b4d60369511e7dea41cf646832512a94e542f68bb9c49e54518e0f468eb47" [[package]] name = "hyper" -version = "0.13.6" +version = "0.13.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6e7655b9594024ad0ee439f3b5a7299369dc2a3f459b47c696f9ff676f9aa1f" +checksum = "8a6f157065790a3ed2f88679250419b5cdd96e714a0d65f7797fd337186e96bb" dependencies = [ - "bytes", + "bytes 0.5.6", "futures-channel", "futures-core", "futures-util", @@ -241,23 +320,23 @@ dependencies = [ "http", "http-body", "httparse", - "itoa", - "log", + "httpdate", + "itoa 0.4.8", "pin-project", "socket2", - "time", "tokio", "tower-service", + "tracing", "want", ] [[package]] name = "hyper-tls" -version = "0.4.1" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3adcd308402b9553630734e9c36b77a7e48b3821251ca2493e8cd596763aafaa" +checksum = "d979acc56dcb5b8dddba3917601745e877576475aa046df3226eabdecef78eed" dependencies = [ - "bytes", + "bytes 0.5.6", "hyper", "native-tls", "tokio", @@ -266,22 +345,31 @@ dependencies = [ [[package]] name = "idna" -version = "0.2.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9" +checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" dependencies = [ - "matches", "unicode-bidi", "unicode-normalization", ] [[package]] name = "indexmap" -version = "1.4.0" +version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c398b2b113b55809ceb9ee3e753fcbac793f1956663f3c36549c1346015c2afe" +checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e" dependencies = [ "autocfg", + "hashbrown", +] + +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if 1.0.0", ] [[package]] @@ -294,16 +382,28 @@ dependencies = [ ] [[package]] -name = "itoa" -version = "0.4.5" +name = "ipnet" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8b7a7c0c47db5545ed3fef7468ee7bb5b74691498139e4b3f6a20685dc6dd8e" +checksum = "879d54834c8c76457ef4293a689b2a8c59b076067ad77b15efafbb05f92a592b" + +[[package]] +name = "itoa" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" + +[[package]] +name = "itoa" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c8af84674fe1f223a982c933a0ee1086ac4d4052aa0fb8060c12c6ad838e754" [[package]] name = "js-sys" -version = "0.3.40" +version = "0.3.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce10c23ad2ea25ceca0093bd3192229da4c5b3c0f2de499c1ecac0d98d452177" +checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47" dependencies = [ "wasm-bindgen", ] @@ -326,30 +426,24 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.71" +version = "0.2.134" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9457b06509d27052635f90d6466700c65095fdf75409b3fbdd903e988b886f49" +checksum = "329c933548736bc49fd575ee68c89e8be4d260064184389a5b77517cddd99ffb" [[package]] name = "log" -version = "0.4.8" +version = "0.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", ] -[[package]] -name = "matches" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" - [[package]] name = "memchr" -version = "2.3.3" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] name = "mime" @@ -359,9 +453,9 @@ checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" [[package]] name = "mime_guess" -version = "2.0.3" +version = "2.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2684d4c2e97d99848d30b324b00c8fcc7e5c897b7cbb5819b09e7c90e8baf212" +checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef" dependencies = [ "mime", "unicase", @@ -369,11 +463,11 @@ dependencies = [ [[package]] name = "mio" -version = "0.6.22" +version = "0.6.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fce347092656428bc8eaf6201042cb551b8d67855af7374542a92a0fbfcac430" +checksum = "4afd66f5b91bf2a3bc13fad0e21caedac168ca4c707504e75585648ae80e4cc4" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", "fuchsia-zircon", "fuchsia-zircon-sys", "iovec", @@ -388,9 +482,9 @@ dependencies = [ [[package]] name = "miow" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" +checksum = "ebd808424166322d4a38da87083bfddd3ac4c131334ed55856112eb06d46944d" dependencies = [ "kernel32-sys", "net2", @@ -398,20 +492,11 @@ dependencies = [ "ws2_32-sys", ] -[[package]] -name = "namesilo_cli" -version = "0.1.0" -dependencies = [ - "reqwest", - "url", - "xml-rs", -] - [[package]] name = "native-tls" -version = "0.2.4" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b0d88c06fe90d5ee94048ba40409ef1d9315d86f6f38c2efdaad4fb50c58b2d" +checksum = "fd7e2f3618557f980e0b17e8856252eee3c97fa12c54dff0ca290fb6266ca4a9" dependencies = [ "lazy_static", "libc", @@ -427,20 +512,30 @@ dependencies = [ [[package]] name = "net2" -version = "0.2.34" +version = "0.2.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ba7c918ac76704fb42afcbbb43891e72731f3dcca3bef2a19786297baf14af7" +checksum = "391630d12b68002ae1e25e8f974306474966550ad82dac6886fb8910c19568ae" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", "libc", - "winapi 0.3.8", + "winapi 0.3.9", +] + +[[package]] +name = "nscli" +version = "0.1.0" +dependencies = [ + "clap", + "reqwest", + "roxmltree", + "url", ] [[package]] name = "num_cpus" -version = "1.13.0" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" +checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" dependencies = [ "hermit-abi", "libc", @@ -448,35 +543,47 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.4.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b631f7e854af39a1739f401cf34a8a013dfe09eac4fa4dba91e9768bd28168d" +checksum = "e82dad04139b71a90c080c8463fe0dc7902db5192d939bd0950f074d014339e1" [[package]] name = "openssl" -version = "0.10.29" +version = "0.10.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cee6d85f4cb4c4f59a6a85d5b68a233d280c82e29e822913b9c8b129fbf20bdd" +checksum = "12fc0523e3bd51a692c8850d075d74dc062ccf251c0110668cbd921917118a13" dependencies = [ "bitflags", - "cfg-if", + "cfg-if 1.0.0", "foreign-types", - "lazy_static", "libc", + "once_cell", + "openssl-macros", "openssl-sys", ] [[package]] -name = "openssl-probe" -version = "0.1.2" +name = "openssl-macros" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" +checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.57" +version = "0.9.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7410fef80af8ac071d4f63755c0ab89ac3df0fd1ea91f1d1f37cf5cec4395990" +checksum = "5230151e44c0f05157effb743e8d517472843121cf9243e8b81393edb5acd9ce" dependencies = [ "autocfg", "cc", @@ -486,25 +593,31 @@ dependencies = [ ] [[package]] -name = "percent-encoding" -version = "2.1.0" +name = "os_str_bytes" +version = "6.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" +checksum = "9ff7415e9ae3fff1225851df9e0d9e4e5479f947619774677a63572e55e80eff" + +[[package]] +name = "percent-encoding" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" [[package]] name = "pin-project" -version = "0.4.17" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edc93aeee735e60ecb40cf740eb319ff23eab1c5748abfdb5c180e4ce49f7791" +checksum = "ad29a609b6bcd67fee905812e544992d216af9d755757c05ed2d0e15a74c6ecc" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "0.4.17" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e58db2081ba5b4c93bd6be09c40fd36cb9193a8336c384f3b40012e531aa7e40" +checksum = "069bdb1e05adc7a8990dce9cc75370895fbe4e3d58b9b73bf1aee56359344a55" dependencies = [ "proc-macro2", "quote", @@ -513,9 +626,15 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.1.6" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9df32da11d84f3a7d70205549562966279adb900e080fad3dccd8e64afccf0ad" +checksum = "257b64915a082f7811703966789728173279bdebb956b143dbcd23f6f970a777" + +[[package]] +name = "pin-project-lite" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" [[package]] name = "pin-utils" @@ -525,98 +644,78 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.17" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677" +checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae" [[package]] -name = "ppv-lite86" -version = "0.2.8" +name = "proc-macro-error" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "237a5ed80e274dbc66f86bd59c1e25edc039660be53194b5fe0a482e0f2612ea" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] [[package]] name = "proc-macro2" -version = "1.0.18" +version = "1.0.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "beae6331a816b1f65d04c45b078fd8e6c93e8071771f41b8163255bbd8d7c8fa" +checksum = "94e2ef8dbfc347b10c094890f778ee2e36ca9bb4262e86dc99cd217e35f3470b" dependencies = [ - "unicode-xid", + "unicode-ident", ] [[package]] name = "quote" -version = "1.0.6" +version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54a21852a652ad6f610c9510194f398ff6f8692e334fd1145fed931f7fbe44ea" +checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" dependencies = [ "proc-macro2", ] -[[package]] -name = "rand" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" -dependencies = [ - "getrandom", - "libc", - "rand_chacha", - "rand_core", - "rand_hc", -] - -[[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", -] - -[[package]] -name = "rand_core" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" -dependencies = [ - "getrandom", -] - -[[package]] -name = "rand_hc" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" -dependencies = [ - "rand_core", -] - [[package]] name = "redox_syscall" -version = "0.1.56" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +dependencies = [ + "bitflags", +] [[package]] name = "remove_dir_all" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e" +checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" dependencies = [ - "winapi 0.3.8", + "winapi 0.3.9", ] [[package]] name = "reqwest" -version = "0.10.6" +version = "0.10.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b82c9238b305f26f53443e3a4bc8528d64b8d0bee408ec949eb7bf5635ec680" +checksum = "0718f81a8e14c4dbb3b34cf23dc6aaf9ab8a0dfec160c534b3dbca1aaa21f47c" dependencies = [ "base64", - "bytes", + "bytes 0.5.6", "encoding_rs", "futures-core", "futures-util", @@ -624,6 +723,7 @@ dependencies = [ "http-body", "hyper", "hyper-tls", + "ipnet", "js-sys", "lazy_static", "log", @@ -631,7 +731,7 @@ dependencies = [ "mime_guess", "native-tls", "percent-encoding", - "pin-project-lite", + "pin-project-lite 0.2.9", "serde", "serde_json", "serde_urlencoded", @@ -645,26 +745,35 @@ dependencies = [ ] [[package]] -name = "ryu" -version = "1.0.5" +name = "roxmltree" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" +checksum = "112908c3ac4711a1554b3948432ecaf5f061a951aa326977b63f7f72a86a4c0e" +dependencies = [ + "xmlparser", +] + +[[package]] +name = "ryu" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" [[package]] name = "schannel" -version = "0.1.19" +version = "0.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75" +checksum = "88d6731146462ea25d9244b2ed5fd1d716d25c52e4d54aa4fb0f3c4e9854dbe2" dependencies = [ "lazy_static", - "winapi 0.3.8", + "windows-sys", ] [[package]] name = "security-framework" -version = "0.4.4" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64808902d7d99f78eaddd2b4e2509713babc3dc3c85ad6f4c447680f3c01e535" +checksum = "2bc1bb97804af6631813c55739f771071e0f2ed33ee20b68c86ec505d906356c" dependencies = [ "bitflags", "core-foundation", @@ -675,9 +784,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "0.4.3" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17bf11d99252f512695eb468de5516e5cf75455521e69dfe343f3b74e4748405" +checksum = "0160a13a177a45bfb43ce71c01580998474f556ad854dcbca936dd2841a5c556" dependencies = [ "core-foundation-sys", "libc", @@ -685,99 +794,115 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.111" +version = "1.0.145" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9124df5b40cbd380080b2cc6ab894c040a3070d995f5c9dc77e18c34a8ae37d" +checksum = "728eb6351430bccb993660dfffc5a72f91ccc1295abaa8ce19b27ebe4f75568b" [[package]] name = "serde_json" -version = "1.0.53" +version = "1.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "993948e75b189211a9b31a7528f950c6adc21f9720b6438ff80a7fa2f864cea2" +checksum = "e55a28e3aaef9d5ce0506d0a14dbba8054ddc7e499ef522dd8b26859ec9d4a44" dependencies = [ - "itoa", + "itoa 1.0.3", "ryu", "serde", ] [[package]] name = "serde_urlencoded" -version = "0.6.1" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ec5d77e2d4c73717816afac02670d5c4f534ea95ed430442cad02e7a6e32c97" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" dependencies = [ - "dtoa", - "itoa", + "form_urlencoded", + "itoa 1.0.3", + "ryu", "serde", - "url", ] [[package]] name = "slab" -version = "0.4.2" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" - -[[package]] -name = "smallvec" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7cb5678e1615754284ec264d9bb5b4c27d2018577fd90ac0ceb578591ed5ee4" - -[[package]] -name = "socket2" -version = "0.3.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03088793f677dce356f3ccc2edb1b314ad191ab702a5de3faf49304f7e104918" +checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "winapi 0.3.8", + "autocfg", ] [[package]] -name = "syn" -version = "1.0.30" +name = "socket2" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93a56fabc59dce20fe48b6c832cc249c713e7ed88fa28b0ee0a3bfcaae5fe4e2" +checksum = "122e570113d28d773067fab24266b66753f6ea915758651696b6e35e49f88d6e" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "winapi 0.3.9", +] + +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + +[[package]] +name = "syn" +version = "1.0.101" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e90cde112c4b9690b8cbe810cba9ddd8bc1d7472e2cae317b69e9438c1cba7d2" dependencies = [ "proc-macro2", "quote", - "unicode-xid", + "unicode-ident", ] [[package]] name = "tempfile" -version = "3.1.0" +version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" +checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", + "fastrand", "libc", - "rand", "redox_syscall", "remove_dir_all", - "winapi 0.3.8", + "winapi 0.3.9", ] [[package]] -name = "time" -version = "0.1.43" +name = "termcolor" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438" +checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" dependencies = [ - "libc", - "winapi 0.3.8", + "winapi-util", ] +[[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.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" + [[package]] name = "tokio" -version = "0.2.21" +version = "0.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d099fa27b9702bed751524694adbe393e18b36b204da91eb1cbbbbb4a5ee2d58" +checksum = "6703a273949a90131b290be1fe7b039d0fc884aa1935860dfcbe056f28cd8092" dependencies = [ - "bytes", + "bytes 0.5.6", "fnv", "futures-core", "iovec", @@ -785,7 +910,7 @@ dependencies = [ "memchr", "mio", "num_cpus", - "pin-project-lite", + "pin-project-lite 0.1.12", "slab", ] @@ -805,25 +930,56 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be8242891f2b6cbef26a2d7e8605133c2c554cd35b3e4948ea892d6d68436499" dependencies = [ - "bytes", + "bytes 0.5.6", "futures-core", "futures-sink", "log", - "pin-project-lite", + "pin-project-lite 0.1.12", "tokio", ] [[package]] name = "tower-service" -version = "0.3.0" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e987b6bf443f4b5b3b6f38704195592cca41c5bb7aedd3c3693c7081f8289860" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" + +[[package]] +name = "tracing" +version = "0.1.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fce9567bd60a67d08a16488756721ba392f24f29006402881e43b19aac64307" +dependencies = [ + "cfg-if 1.0.0", + "log", + "pin-project-lite 0.2.9", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aeea4303076558a00714b823f9ad67d58a3bbda1df83d8827d21193156e22f7" +dependencies = [ + "once_cell", +] + +[[package]] +name = "tracing-futures" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2" +dependencies = [ + "pin-project", + "tracing", +] [[package]] name = "try-lock" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e604eb7b43c06650e854be16a2a03155743d3752dd1c943f6829e26b7a36e382" +checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" [[package]] name = "unicase" @@ -836,50 +992,47 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.4" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" -dependencies = [ - "matches", -] +checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992" + +[[package]] +name = "unicode-ident" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcc811dc4066ac62f84f11307873c4850cb653bfa9b1719cee2bd2204a4bc5dd" [[package]] name = "unicode-normalization" -version = "0.1.12" +version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5479532badd04e128284890390c1e876ef7a993d0570b3597ae43dfa1d59afa4" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" dependencies = [ - "smallvec", + "tinyvec", ] -[[package]] -name = "unicode-xid" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" - [[package]] name = "url" -version = "2.1.1" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "829d4a8476c35c9bf0bbce5a3b23f4106f79728039b726d292bb93bc106787cb" +checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" dependencies = [ + "form_urlencoded", "idna", - "matches", "percent-encoding", ] [[package]] name = "vcpkg" -version = "0.2.9" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55d1e41d56121e07f1e223db0a4def204e45c85425f6a16d462fd07c8d10d74c" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] name = "version_check" -version = "0.9.2" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "want" @@ -891,19 +1044,13 @@ dependencies = [ "try-lock", ] -[[package]] -name = "wasi" -version = "0.9.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" - [[package]] name = "wasm-bindgen" -version = "0.2.63" +version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c2dc4aa152834bc334f506c1a06b866416a8b6697d5c9f75b9a689c8486def0" +checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "serde", "serde_json", "wasm-bindgen-macro", @@ -911,13 +1058,13 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.63" +version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded84f06e0ed21499f6184df0e0cb3494727b0c5da89534e0fcc55c51d812101" +checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142" dependencies = [ "bumpalo", - "lazy_static", "log", + "once_cell", "proc-macro2", "quote", "syn", @@ -926,11 +1073,11 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.13" +version = "0.4.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64487204d863f109eb77e8462189d111f27cb5712cc9fdb3461297a76963a2f6" +checksum = "23639446165ca5a5de86ae1d8896b737ae80319560fbaa4c2887b7da6e7ebd7d" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "js-sys", "wasm-bindgen", "web-sys", @@ -938,9 +1085,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.63" +version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "838e423688dac18d73e31edce74ddfac468e37b1506ad163ffaf0a46f703ffe3" +checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -948,9 +1095,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.63" +version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3156052d8ec77142051a533cdd686cba889537b213f948cd1d20869926e68e92" +checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" dependencies = [ "proc-macro2", "quote", @@ -961,15 +1108,15 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.63" +version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9ba19973a58daf4db6f352eda73dc0e289493cd29fb2632eb172085b6521acd" +checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" [[package]] name = "web-sys" -version = "0.3.40" +version = "0.3.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b72fe77fd39e4bd3eaa4412fd299a0be6b3dfe9d2597e2f1c20beb968f41d17" +checksum = "bcda906d8be16e728fd5adc5b729afad4e444e106ab28cd1c7256e54fa61510f" dependencies = [ "js-sys", "wasm-bindgen", @@ -983,9 +1130,9 @@ checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" [[package]] name = "winapi" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" dependencies = [ "winapi-i686-pc-windows-gnu", "winapi-x86_64-pc-windows-gnu", @@ -1003,19 +1150,71 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi 0.3.9", +] + [[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 = "windows-sys" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" +dependencies = [ + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" + +[[package]] +name = "windows_i686_gnu" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" + +[[package]] +name = "windows_i686_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" + [[package]] name = "winreg" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0120db82e8a1e0b9fb3345a539c478767c0048d842860994d96113d5b667bd69" dependencies = [ - "winapi 0.3.8", + "winapi 0.3.9", ] [[package]] @@ -1029,7 +1228,7 @@ dependencies = [ ] [[package]] -name = "xml-rs" -version = "0.8.3" +name = "xmlparser" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b07db065a5cf61a7e4ba64f29e67db906fb1787316516c4e6e5ff0fea1efcd8a" +checksum = "114ba2b24d2167ef6d67d7d04c8cc86522b87f490025f39f0303b7db5bf5e3d8" diff --git a/Cargo.toml b/Cargo.toml index 7fc16ce..2efa603 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "namesilo_cli" +name = "nscli" version = "0.1.0" authors = ["Pascal"] edition = "2018" @@ -7,6 +7,7 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +clap = { version = "4.0.8", features = ["derive"] } reqwest = { version = "0.10", features = ["blocking", "json"] } # MIT/Apache-2.0 url = { version = "2.1.1" } # MIT/Apache-2.0 -xml-rs = { version = "0.8" } # MIT/Apache-2.0 +roxmltree = { version = "0.15.0" } # MIT/Apache-2.0 diff --git a/README.md b/README.md new file mode 100644 index 0000000..5bc19d2 --- /dev/null +++ b/README.md @@ -0,0 +1,89 @@ +

nscli

+ +

+ A quickly hacked together CLI Client for the NameSilo API. +

+ +Letsencrypt allows for wildcard and certificates for servers that are not accessible on the web, through a DNS Challenge. This tool makes automation possible for domains on the NameSilo registrar. It does not cover the entirety of the NameSilo API. + +

+ + Getting started + • LetsEncrypt + • Roadmap + +

+ +## Getting Started + + +### Build + +``` +# compile +cargo build --package nscli --release +# run +./target/release/nscli --help + +# development +cargo run --package nscli --bin nscli -- help +``` + +### Command Line Interface + +The command line interface of `nscli` is build with [clap](https://docs.rs/clap/latest/clap/): + +``` +Usage: nscli [OPTIONS] + +Commands: + listdomains A list of all active domains within your account + getdomaininfo Get essential information on a domain within your account + dnslistrecords View all DNS records associated with your domain + dnsaddrecord Add a new DNS resource record or update existing + dnsupdaterecord Update an existing DNS resource record + dnsdeleterecord Delete an existing DNS resource record + dnsrecordid [Custom] Get DNS record id if it exists + help Print this message or the help of the given subcommand(s) + +Options: + -a, --api-key [default: .api_key] + -h, --help Print help information + +Process finished with exit code 0 + +``` +> **Note:** As duplicate resource records are out of scope for this tool, the following commands deviate from their NameSilo API counterpart: +> - `dnsaddrecord`: does not create duplicate entries, but instead updates a matching record if it already exists +> - `dnsdeleterecord`: takes a subdomain and record type as parameter and will delete the first matching one +> - `dnsrecordid`: is not part of the NameSilo API + +## LetsEncrypt + +The [pre and post validation hook](https://eff-certbot.readthedocs.io/en/stable/using.html#hooks) of `certbot` can be used to add `nscli` to the certification process. +```bash +certbot certonly --manual --preferred-challenges=dns --manual-auth-hook /path/to/pre.sh --manual-cleanup-hook /path/to/post.sh -d example.com +``` +```bash +#!/bin/bash +# pre hook example +./nscli dnsaddrecord --domain $CERTBOT_DOMAIN \ + --rrtype txt \ + --rrhost _acme-challenge \ + --rrvalue $CERTBOT_VALIDATION +# wait for the change to propagate +sleep 60 +``` +```bash +#!/bin/bash +# post hook example +./nscli dnsdeleterecord --domain $CERTBOT_DOMAIN \ + --rrtype txt \ + --rrhost _acme-challenge + +``` + +## Roadmap +* Add optional `rrid` param to `dnsdeleterecord` +* Properly parse response `xml` and make output available in digestible form on `stdout` +* Add more API calls \ No newline at end of file diff --git a/src/api/constants.rs b/src/api/constants.rs deleted file mode 100644 index 1e8ec3b..0000000 --- a/src/api/constants.rs +++ /dev/null @@ -1,80 +0,0 @@ -use std::collections::HashMap; - -// operation constants -pub(crate) const REGISTERDOMAIN: &str = "registerDomain"; // Register a new domain name -pub(crate) const REGISTERDOMAINDROP: &str = "registerDomainDrop"; // Register a new domain name using drop-catching -pub(crate) const RENEWDOMAIN: &str = "renewDomain"; // Renew a domain name -pub(crate) const TRANSFERDOMAIN: &str = "transferDomain"; // Transfer a domain name into your NameSilo account -pub(crate) const CHECKTRANSFERSTATUS: &str = "checkTransferStatus"; // Check the status of a domain transfer -pub(crate) const TRANSFERUPDATECHANGEEPPCODE: &str = "transferUpdateChangeEPPCode"; // Add/Change the EPP code for a domain transfer -pub(crate) const TRANSFERUPDATERESENDADMINEMAIL: &str = "transferUpdateResendAdminEmail"; // Update a Transfer to Re-Send the Admin Verification Email -pub(crate) const TRANSFERUPDATERESUBMITTOREGISTRY: &str = "transferUpdateResubmitToRegistry"; // Update a Transfer to Re-Submit the transfer to the registry -pub(crate) const CHECKREGISTERAVAILABILITY: &str = "checkRegisterAvailability"; // Determine if up to 200 domains can be registered at this time -pub(crate) const CHECKTRANSFERAVAILABILITY: &str = "checkTransferAvailability"; // Determine if up to 200 domains can be transferred into your account at this time -pub(crate) const LISTDOMAINS: &str = "listDomains"; // A list of all active domains within your account -pub(crate) const GETDOMAININFO: &str = "getDomainInfo"; // Get essential information on a domain within your account -pub(crate) const CONTACTLIST: &str = "contactList"; // View all contact profiles in your account -pub(crate) const CONTACTADD: &str = "contactAdd"; // Add a contact profile to your account -pub(crate) const CONTACTUPDATE: &str = "contactUpdate"; // Update a contact profile in account -pub(crate) const CONTACTDELETE: &str = "contactDelete"; // Delete a contact profile in account -pub(crate) const CONTACTDOMAINASSOCIATE: &str = "contactDomainAssociate"; // Associate contact profiles with a domain -pub(crate) const CHANGENAMESERVERS: &str = "changeNameServers"; // Change the NameServers for up to 200 domains -pub(crate) const DNSLISTRECORDS: &str = "dnsListRecords"; // View all DNS records associated with your domain -pub(crate) const DNSADDRECORD: &str = "dnsAddRecord"; // Add a new DNS resource record -pub(crate) const DNSUPDATERECORD: &str = "dnsUpdateRecord"; // Update an existing DNS resource record -pub(crate) const DNSDELETERECORD: &str = "dnsDeleteRecord"; // Delete an existing DNS resource record -pub(crate) const DNSSECLISTRECORDS: &str = "dnsSecListRecords"; // View all DS (DNSSEC) records associated with your domain -pub(crate) const DNSSECADDRECORD: &str = "dnsSecAddRecord"; // Add a DS record (DNSSEC) to your domain -pub(crate) const DNSSECDELETERECORD: &str = "dnsSecDeleteRecord"; // Delete a DS record (DNSSEC) from your domain -pub(crate) const PORTFOLIOLIST: &str = "portfolioList"; // List the active portfolios within your account -pub(crate) const PORTFOLIOADD: &str = "portfolioAdd"; // Add a portfolio to your account -pub(crate) const PORTFOLIODELETE: &str = "portfolioDelete"; // Delete a portfolio from your account -pub(crate) const PORTFOLIODOMAINASSOCIATE: &str = "portfolioDomainAssociate"; // Add up to 200 domains to a portfolio -pub(crate) const LISTREGISTEREDNAMESERVERS: &str = "listRegisteredNameServers"; // List the Registered NameServers associated with one of your domains -pub(crate) const ADDREGISTEREDNAMESERVER: &str = "addRegisteredNameServer"; // Add a Registered NameServer for one of your domains -pub(crate) const MODIFYREGISTEREDNAMESERVER: &str = "modifyRegisteredNameServer"; // Modify a Registered NameServer -pub(crate) const DELETEREGISTEREDNAMESERVER: &str = "deleteRegisteredNameServer"; // Delete a Registered NameServer -pub(crate) const ADDPRIVACY: &str = "addPrivacy"; // Add WHOIS Privacy to a domain -pub(crate) const REMOVEPRIVACY: &str = "removePrivacy"; // Remove WHOIS Privacy from a domain -pub(crate) const ADDAUTORENEWAL: &str = "addAutoRenewal"; // Set your domain to be auto-renewed -pub(crate) const REMOVEAUTORENEWAL: &str = "removeAutoRenewal"; // Remove the auto-renewal setting from your domain -pub(crate) const RETRIEVEAUTHCODE: &str = "retrieveAuthCode"; // Have the EPP authorization code for the domain emailed to the administrative contact -pub(crate) const DOMAINFORWARD: &str = "domainForward"; // Forward your domain -pub(crate) const DOMAINFORWARDSUBDOMAIN: &str = "domainForwardSubDomain"; // Forward a sub-domain -pub(crate) const DOMAINFORWARDSUBDOMAINDELETE: &str = "domainForwardSubDomainDelete"; // Delete a sub-domain forward -pub(crate) const DOMAINLOCK: &str = "domainLock"; // Lock your domain -pub(crate) const DOMAINUNLOCK: &str = "domainUnlock"; // Unlock your domain -pub(crate) const LISTEMAILFORWARDS: &str = "listEmailForwards"; // List all email forwards for your domain -pub(crate) const CONFIGUREEMAILFORWARD: &str = "configureEmailForward"; // Add or modify an email forward for your domain -pub(crate) const DELETEEMAILFORWARD: &str = "deleteEmailForward"; // Delete an email forward for your domain -pub(crate) const REGISTRANTVERIFICATIONSTATUS: &str = "registrantVerificationStatus"; // See the verification status of any Registrant email addresses -pub(crate) const EMAILVERIFICATION: &str = "emailVerification"; // Verify a Registrant email address -pub(crate) const GETACCOUNTBALANCE: &str = "getAccountBalance"; // View your NameSilo account funds balance -pub(crate) const ADDACCOUNTFUNDS: &str = "addAccountFunds"; // Increase your NameSilo account funds -pub(crate) const MARKETPLACEACTIVESALESOVERVIEW: &str = "marketplaceActiveSalesOverview"; // Returns a list and specifics for all of your active Marketplace sales -pub(crate) const MARKETPLACEADDORMODIFYSALE: &str = "marketplaceAddOrModifySale"; // Allows you to add a new Marketplace sale or modify and existing sale -pub(crate) const MARKETPLACELANDINGPAGEUPDATE: &str = "marketplaceLandingPageUpdate"; // Allows you to update the appearance of your Marketplace Landing Page -pub(crate) const GETPRICES: &str = "getPrices"; // Returns our price list customized optionally based upon your account's specific pricing -pub(crate) const LISTORDERS: &str = "listOrders"; // Returns a list of all orders placed in your account -pub(crate) const ORDERDETAILS: &str = "orderDetails"; // Provides details for the provided order number - -// input constants -pub(crate) const KEY_VALUE_SEP: &str = "="; - -// url constants -const BASE_URL: &'static str = "https://www.namesilo.com/api/"; -const API_VERSION: &'static str = "1"; -const API_TYPE: &'static str = "xml"; -pub(crate) fn api_url(operation: &str, api_key: &str, args: &HashMap) -> String { - let mut params = String::new(); - for (k, v) in args { - params.push_str(&format!("&{}={}", k, v)) - } - format!("{}{}?version={}&type={}&key={}{}", BASE_URL, operation, API_VERSION, API_TYPE, api_key, params ) -} - -// filter constants -pub(crate) type Range = (char, char); -pub(crate) const FILTER_LETTER_NUMBER: &[Range; 2] = &[('a','z'), ('0','9')]; -pub(crate) const FILTER_LETTER: &[Range; 1] = &[('a','z')]; -pub(crate) const WHITELIST_SYMBOLS: &str = "._-"; diff --git a/src/api/functions.rs b/src/api/functions.rs deleted file mode 100644 index d60aef2..0000000 --- a/src/api/functions.rs +++ /dev/null @@ -1,24 +0,0 @@ -use crate::lib::nerror::NError; -use crate::lib::utils::{parse_args, check_args, send_api_request, Response}; -use crate::api::constants::*; -use std::collections::HashMap; - -pub(crate) fn list_domains(api_key: &str, _: &str) -> Result { - - let result: String = send_api_request(LISTDOMAINS, api_key, &HashMap::new())?; - - Ok(Response::with_string(result)) -} - -pub(crate) fn get_domain_info(api_key: &str, args: &str) -> Result { - let args: HashMap = parse_args(args, - (FILTER_LETTER, ""), - (FILTER_LETTER_NUMBER, WHITELIST_SYMBOLS)); - - // check args, return error otherwise - check_args(&args, &["domain"], &[])?; - - let result: String = send_api_request(GETDOMAININFO, api_key, &args)?; - - Ok(Response::with_string(result)) -} \ No newline at end of file diff --git a/src/api/mod.rs b/src/api/mod.rs index 4c65161..6bb553b 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -1,3 +1 @@ -pub mod constants; -pub mod functions; pub mod operations; \ No newline at end of file diff --git a/src/api/operations.rs b/src/api/operations.rs index a77fcbe..2e92ad3 100644 --- a/src/api/operations.rs +++ b/src/api/operations.rs @@ -1,75 +1,446 @@ -use crate::api::functions::*; -use crate::api::constants::*; use std::collections::HashMap; +use clap::{arg, Subcommand}; +use std::fmt; use crate::lib::nerror::NError; -use crate::lib::utils::Response; +use crate::lib::xml::*; +use crate::lib::utils::{send_api_request, check_string, Response}; -pub(crate) type Operation = fn(&str, &str) -> Result; +// url constants +const BASE_URL: &'static str = "https://www.namesilo.com/api/"; +const API_VERSION: &'static str = "1"; +const API_TYPE: &'static str = "xml"; -pub fn get_operation(op_name: &str) -> Result { - let mut operation_mapping: HashMap> = hashmap![type(String, Result) - REGISTERDOMAIN.to_lowercase() => Err(NError::NyiOpError(REGISTERDOMAIN.to_string())), - REGISTERDOMAINDROP.to_lowercase() => Err(NError::NyiOpError(REGISTERDOMAINDROP.to_string())), - RENEWDOMAIN.to_lowercase() => Err(NError::NyiOpError(RENEWDOMAIN.to_string())), - TRANSFERDOMAIN.to_lowercase() => Err(NError::NyiOpError(TRANSFERDOMAIN.to_string())), - CHECKTRANSFERSTATUS.to_lowercase() => Err(NError::NyiOpError(CHECKTRANSFERSTATUS.to_string())), - TRANSFERUPDATECHANGEEPPCODE.to_lowercase() => Err(NError::NyiOpError(TRANSFERUPDATECHANGEEPPCODE.to_string())), - TRANSFERUPDATERESENDADMINEMAIL.to_lowercase() => Err(NError::NyiOpError(TRANSFERUPDATERESENDADMINEMAIL.to_string())), - TRANSFERUPDATERESUBMITTOREGISTRY.to_lowercase() => Err(NError::NyiOpError(TRANSFERUPDATERESUBMITTOREGISTRY.to_string())), - CHECKREGISTERAVAILABILITY.to_lowercase() => Err(NError::NyiOpError(CHECKREGISTERAVAILABILITY.to_string())), - CHECKTRANSFERAVAILABILITY.to_lowercase() => Err(NError::NyiOpError(CHECKTRANSFERAVAILABILITY.to_string())), - LISTDOMAINS.to_lowercase() => Ok(list_domains), - GETDOMAININFO.to_lowercase() => Ok(get_domain_info), - CONTACTLIST.to_lowercase() => Err(NError::NyiOpError(CONTACTLIST.to_string())), - CONTACTADD.to_lowercase() => Err(NError::NyiOpError(CONTACTADD.to_string())), - CONTACTUPDATE.to_lowercase() => Err(NError::NyiOpError(CONTACTUPDATE.to_string())), - CONTACTDELETE.to_lowercase() => Err(NError::NyiOpError(CONTACTDELETE.to_string())), - CONTACTDOMAINASSOCIATE.to_lowercase() => Err(NError::NyiOpError(CONTACTDOMAINASSOCIATE.to_string())), - CHANGENAMESERVERS.to_lowercase() => Err(NError::NyiOpError(CHANGENAMESERVERS.to_string())), - DNSLISTRECORDS.to_lowercase() => Err(NError::NyiOpError(DNSLISTRECORDS.to_string())), - DNSADDRECORD.to_lowercase() => Err(NError::NyiOpError(DNSADDRECORD.to_string())), - DNSUPDATERECORD.to_lowercase() => Err(NError::NyiOpError(DNSUPDATERECORD.to_string())), - DNSDELETERECORD.to_lowercase() => Err(NError::NyiOpError(DNSDELETERECORD.to_string())), - DNSSECLISTRECORDS.to_lowercase() => Err(NError::NyiOpError(DNSSECLISTRECORDS.to_string())), - DNSSECADDRECORD.to_lowercase() => Err(NError::NyiOpError(DNSSECADDRECORD.to_string())), - DNSSECDELETERECORD.to_lowercase() => Err(NError::NyiOpError(DNSSECDELETERECORD.to_string())), - PORTFOLIOLIST.to_lowercase() => Err(NError::NyiOpError(PORTFOLIOLIST.to_string())), - PORTFOLIOADD.to_lowercase() => Err(NError::NyiOpError(PORTFOLIOADD.to_string())), - PORTFOLIODELETE.to_lowercase() => Err(NError::NyiOpError(PORTFOLIODELETE.to_string())), - PORTFOLIODOMAINASSOCIATE.to_lowercase() => Err(NError::NyiOpError(PORTFOLIODOMAINASSOCIATE.to_string())), - LISTREGISTEREDNAMESERVERS.to_lowercase() => Err(NError::NyiOpError(LISTREGISTEREDNAMESERVERS.to_string())), - ADDREGISTEREDNAMESERVER.to_lowercase() => Err(NError::NyiOpError(ADDREGISTEREDNAMESERVER.to_string())), - MODIFYREGISTEREDNAMESERVER.to_lowercase() => Err(NError::NyiOpError(MODIFYREGISTEREDNAMESERVER.to_string())), - DELETEREGISTEREDNAMESERVER.to_lowercase() => Err(NError::NyiOpError(DELETEREGISTEREDNAMESERVER.to_string())), - ADDPRIVACY.to_lowercase() => Err(NError::NyiOpError(ADDPRIVACY.to_string())), - REMOVEPRIVACY.to_lowercase() => Err(NError::NyiOpError(REMOVEPRIVACY.to_string())), - ADDAUTORENEWAL.to_lowercase() => Err(NError::NyiOpError(ADDAUTORENEWAL.to_string())), - REMOVEAUTORENEWAL.to_lowercase() => Err(NError::NyiOpError(REMOVEAUTORENEWAL.to_string())), - RETRIEVEAUTHCODE.to_lowercase() => Err(NError::NyiOpError(RETRIEVEAUTHCODE.to_string())), - DOMAINFORWARD.to_lowercase() => Err(NError::NyiOpError(DOMAINFORWARD.to_string())), - DOMAINFORWARDSUBDOMAIN.to_lowercase() => Err(NError::NyiOpError(DOMAINFORWARDSUBDOMAIN.to_string())), - DOMAINFORWARDSUBDOMAINDELETE.to_lowercase() => Err(NError::NyiOpError(DOMAINFORWARDSUBDOMAINDELETE.to_string())), - DOMAINLOCK.to_lowercase() => Err(NError::NyiOpError(DOMAINLOCK.to_string())), - DOMAINUNLOCK.to_lowercase() => Err(NError::NyiOpError(DOMAINUNLOCK.to_string())), - LISTEMAILFORWARDS.to_lowercase() => Err(NError::NyiOpError(LISTEMAILFORWARDS.to_string())), - CONFIGUREEMAILFORWARD.to_lowercase() => Err(NError::NyiOpError(CONFIGUREEMAILFORWARD.to_string())), - DELETEEMAILFORWARD.to_lowercase() => Err(NError::NyiOpError(DELETEEMAILFORWARD.to_string())), - REGISTRANTVERIFICATIONSTATUS.to_lowercase() => Err(NError::NyiOpError(REGISTRANTVERIFICATIONSTATUS.to_string())), - EMAILVERIFICATION.to_lowercase() => Err(NError::NyiOpError(EMAILVERIFICATION.to_string())), - GETACCOUNTBALANCE.to_lowercase() => Err(NError::NyiOpError(GETACCOUNTBALANCE.to_string())), - ADDACCOUNTFUNDS.to_lowercase() => Err(NError::NyiOpError(ADDACCOUNTFUNDS.to_string())), - MARKETPLACEACTIVESALESOVERVIEW.to_lowercase() => Err(NError::NyiOpError(MARKETPLACEACTIVESALESOVERVIEW.to_string())), - MARKETPLACEADDORMODIFYSALE.to_lowercase() => Err(NError::NyiOpError(MARKETPLACEADDORMODIFYSALE.to_string())), - MARKETPLACELANDINGPAGEUPDATE.to_lowercase() => Err(NError::NyiOpError(MARKETPLACELANDINGPAGEUPDATE.to_string())), - GETPRICES.to_lowercase() => Err(NError::NyiOpError(GETPRICES.to_string())), - LISTORDERS.to_lowercase() => Err(NError::NyiOpError(LISTORDERS.to_string())), - ORDERDETAILS.to_lowercase() => Err(NError::NyiOpError(ORDERDETAILS.to_string())) - ]; +// operation constants +#[derive(Subcommand)] +#[clap(rename_all = "lower")] +pub(crate) enum Operation { + // Register a new domain name + #[command(skip)] + RegisterDomain, + // Register a new domain name using drop-catching + #[command(skip)] + RegisterDomainDrop, + // Renew a domain name + #[command(skip)] + RenewDomain, + // Transfer a domain name into your NameSilo account + #[command(skip)] + TransferDomain, + // Check the status of a domain transfer + #[command(skip)] + CheckTransferStatus, + // Add/Change the EPP code for a domain transfer + #[command(skip)] + TransferUpdateChangeEPPCode, + // Update a Transfer to Re-Send the Admin Verification Email + #[command(skip)] + TransferUpdateResendAdminEmail, + // Update a Transfer to Re-Submit the transfer to the registry + #[command(skip)] + TransferUpdateResubmitToRegistry, + // Determine if up to 200 domains can be registered at this time + #[command(skip)] + CheckRegisterAvailability, + // Determine if up to 200 domains can be transferred into your account at this time + #[command(skip)] + CheckTransferAvailability, + /// A list of all active domains within your account + ListDomains, + /// Get essential information on a domain within your account + GetDomainInfo { + #[arg(short, long)] + /// TLD String [example.com] + domain: String, + }, + // View all contact profiles in your account + #[command(skip)] + ContactList, + // Add a contact profile to your account + #[command(skip)] + ContactAdd, + // Update a contact profile in account + #[command(skip)] + ContactUpdate, + // Delete a contact profile in account + #[command(skip)] + ContactDelete, + // Associate contact profiles with a domain + #[command(skip)] + ContactDomainAssociate, + // Change the NameServers for up to 200 domains + #[command(skip)] + ChangeNameServers, + /// View all DNS records associated with your domain + DnsListRecords { + #[arg(short, long)] + /// TLD String [example.com] + domain: String, + }, + /// Add a new DNS resource record or update existing + DnsAddRecord { + #[arg(short, long)] + /// TLD String [example.com] + domain: String, + #[arg(short = 't', long, value_enum)] + rrtype: ResourceType, + #[arg(short = 'o', long)] + /// Subdomain String [www] (can be empty) + rrhost: String, + #[arg(short = 'v', long)] + /// Value of Record [127.0.0.1] + rrvalue: String, + #[arg(short = 'i', long, default_value_t = 10)] + /// [Optional] distance, only required for mx + rrdistance: u16, + #[arg(short = 'l', long, default_value_t = 3600)] + /// [Optional] time to life + rrttl: u16, + }, + /// Update an existing DNS resource record + DnsUpdateRecord { + #[arg(short, long)] + /// TLD String [example.com] + domain: String, + #[arg(short = 'r', long)] + rrid: String, + #[arg(short = 'o', long)] + /// Subdomain String [www] (can be empty) + rrhost: String, + #[arg(short = 'v', long)] + /// Value of Record [127.0.0.1] + rrvalue: String, + #[arg(short = 'i', long, default_value_t = 10)] + /// [Optional] distance, only required for mx + rrdistance: u16, + #[arg(short = 'l', long, default_value_t = 3600)] + /// [Optional] time to life + rrttl: u16, + }, + /// Delete an existing DNS resource record + DnsDeleteRecord { + #[arg(short, long)] + /// TLD String [example.com] + domain: String, + #[arg(short = 't', long, value_enum)] + rrtype: ResourceType, + #[arg(short = 'o', long)] + /// Subdomain String [www] (can be empty) + rrhost: String, + }, + // View all DS (DNSSEC) records associated with your domain + #[command(skip)] + DnsSecListRecords, + // Add a DS record (DNSSEC) to your domain + #[command(skip)] + DnsSecAddRecord, + // Delete a DS record (DNSSEC) from your domain + #[command(skip)] + DnsSecDeleteRecord, + // List the active portfolios within your account + #[command(skip)] + PortfolioList, + // Add a portfolio to your account + #[command(skip)] + PortfolioAdd, + // Delete a portfolio from your account + #[command(skip)] + PortfolioDelete, + // Add up to 200 domains to a portfolio + #[command(skip)] + PortfolioDomainAssociate, + // List the Registered NameServers associated with one of your domains + #[command(skip)] + ListRegisteredNameServers, + // Add a Registered NameServer for one of your domains + #[command(skip)] + AddRegisteredNameServer, + // Modify a Registered NameServer + #[command(skip)] + ModifyRegisteredNameServer, + // Delete a Registered NameServer + #[command(skip)] + DeleteRegisteredNameServer, + // Add WHOIS Privacy to a domain + #[command(skip)] + AddPrivacy, + // Remove WHOIS Privacy from a domain + #[command(skip)] + RemovePrivacy, + // Set your domain to be auto-renewed + #[command(skip)] + AddAutoRenewal, + // Remove the auto-renewal setting from your domain + #[command(skip)] + RemoveAutoRenewal, + // Have the EPP authorization code for the domain emailed to the administrative contact + #[command(skip)] + RetrieveAuthCode, + // Forward your domain + #[command(skip)] + DomainForward, + // Forward a sub-domain + #[command(skip)] + DomainForwardSubDomain, + // Delete a sub-domain forward + #[command(skip)] + DomainForwardSubDomainDelete, + // Lock your domain + #[command(skip)] + DomainLock, + // Unlock your domain + #[command(skip)] + DomainUnlock, + // List all email forwards for your domain + #[command(skip)] + ListEmailForwards, + // Add or modify an email forward for your domain + #[command(skip)] + ConfigureEmailForward, + // Delete an email forward for your domain + #[command(skip)] + DeleteEmailForward, + // See the verification status of any Registrant email addresses + #[command(skip)] + RegistrantVerificationStatus, + // Verify a Registrant email address + #[command(skip)] + EmailVerification, + // View your NameSilo account funds balance + #[command(skip)] + GetAccountBalance, + // Increase your NameSilo account funds + #[command(skip)] + AddAccountFunds, + // Returns a list and specifics for all of your active Marketplace sales + #[command(skip)] + MarketplaceActiveSalesOverview, + // Allows you to add a new Marketplace sale or modify and existing sale + #[command(skip)] + MarketplaceAddOrModifySale, + // Allows you to update the appearance of your Marketplace Landing Page + #[command(skip)] + MarketplaceLandingPageUpdate, + // Returns our price list customized optionally based upon your account's specific pricing + #[command(skip)] + GetPrices, + // Returns a list of all orders placed in your account + #[command(skip)] + ListOrders, + // Provides details for the provided order number + #[command(skip)] + OrderDetails, + /// [Custom] Get DNS record id if it exists + DnsRecordId { + #[arg(short, long)] + /// TLD String [example.com] + domain: String, + #[arg(short = 't', long, value_enum)] + rrtype: ResourceType, + #[arg(short = 'o', long)] + /// Subdomain String [www] (can be empty) + rrhost: String, + }, +} - let op: Option> = operation_mapping.remove(&op_name.to_lowercase()); - match op { - Some(v) => v, - None => Err(NError::InvalidOpError(op_name.to_string())) +#[derive(clap::ValueEnum, Clone)] +/// Resource Type +pub(crate) enum ResourceType { + /// The IPV4 Address + A, + /// The IPV6 Address + AAAA, + /// The Target Hostname + CNAME, + /// The Target Hostname + MX, + /// The Text + TXT, +} + +impl fmt::Display for ResourceType { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self { + ResourceType::A => write!(f, "A"), + ResourceType::AAAA => write!(f, "AAAA"), + ResourceType::CNAME => write!(f, "CNAME"), + ResourceType::MX => write!(f, "MX"), + ResourceType::TXT => write!(f, "TXT"), + } } +} -} \ No newline at end of file +#[allow(dead_code)] +impl fmt::Display for Operation { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self { + Operation::RegisterDomain => write!(f, "registerDomain"), // Register a new domain name + Operation::RegisterDomainDrop => write!(f, "registerDomainDrop"), // Register a new domain name using drop-catching + Operation::RenewDomain => write!(f, "renewDomain"), // Renew a domain name + Operation::TransferDomain => write!(f, "transferDomain"), // Transfer a domain name into your NameSilo account + Operation::CheckTransferStatus => write!(f, "checkTransferStatus"), // Check the status of a domain transfer + Operation::TransferUpdateChangeEPPCode => write!(f, "transferUpdateChangeEPPCode"), // Add/Change the EPP code for a domain transfer + Operation::TransferUpdateResendAdminEmail => write!(f, "transferUpdateResendAdminEmail"), // Update a Transfer to Re-Send the Admin Verification Email + Operation::TransferUpdateResubmitToRegistry => write!(f, "transferUpdateResubmitToRegistry"), // Update a Transfer to Re-Submit the transfer to the registry + Operation::CheckRegisterAvailability => write!(f, "checkRegisterAvailability"), // Determine if up to 200 domains can be registered at this time + Operation::CheckTransferAvailability => write!(f, "checkTransferAvailability"), // Determine if up to 200 domains can be transferred into your account at this time + Operation::ListDomains => write!(f, "listDomains"), // A list of all active domains within your account + Operation::GetDomainInfo { .. } => write!(f, "getDomainInfo"), // Get essential information on a domain within your account + Operation::ContactList => write!(f, "contactList"), // View all contact profiles in your account + Operation::ContactAdd => write!(f, "contactAdd"), // Add a contact profile to your account + Operation::ContactUpdate => write!(f, "contactUpdate"), // Update a contact profile in account + Operation::ContactDelete => write!(f, "contactDelete"), // Delete a contact profile in account + Operation::ContactDomainAssociate => write!(f, "contactDomainAssociate"), // Associate contact profiles with a domain + Operation::ChangeNameServers => write!(f, "changeNameServers"), // Change the NameServers for up to 200 domains + Operation::DnsListRecords { .. } => write!(f, "dnsListRecords"), // View all DNS records associated with your domain + Operation::DnsAddRecord { .. } => write!(f, "dnsAddRecord"), // Add a new DNS resource record + Operation::DnsUpdateRecord { .. } => write!(f, "dnsUpdateRecord"), // Update an existing DNS resource record + Operation::DnsDeleteRecord { .. } => write!(f, "dnsDeleteRecord"), // Delete an existing DNS resource record + Operation::DnsSecListRecords => write!(f, "dnsSecListRecords"), // View all DS (DNSSEC) records associated with your domain + Operation::DnsSecAddRecord => write!(f, "dnsSecAddRecord"), // Add a DS record (DNSSEC) to your domain + Operation::DnsSecDeleteRecord => write!(f, "dnsSecDeleteRecord"), // Delete a DS record (DNSSEC) from your domain + Operation::PortfolioList => write!(f, "portfolioList"), // List the active portfolios within your account + Operation::PortfolioAdd => write!(f, "portfolioAdd"), // Add a portfolio to your account + Operation::PortfolioDelete => write!(f, "portfolioDelete"), // Delete a portfolio from your account + Operation::PortfolioDomainAssociate => write!(f, "portfolioDomainAssociate"), // Add up to 200 domains to a portfolio + Operation::ListRegisteredNameServers => write!(f, "listRegisteredNameServers"), // List the Registered NameServers associated with one of your domains + Operation::AddRegisteredNameServer => write!(f, "addRegisteredNameServer"), // Add a Registered NameServer for one of your domains + Operation::ModifyRegisteredNameServer => write!(f, "modifyRegisteredNameServer"), // Modify a Registered NameServer + Operation::DeleteRegisteredNameServer => write!(f, "deleteRegisteredNameServer"), // Delete a Registered NameServer + Operation::AddPrivacy => write!(f, "addPrivacy"), // Add WHOIS Privacy to a domain + Operation::RemovePrivacy => write!(f, "removePrivacy"), // Remove WHOIS Privacy from a domain + Operation::AddAutoRenewal => write!(f, "addAutoRenewal"), // Set your domain to be auto-renewed + Operation::RemoveAutoRenewal => write!(f, "removeAutoRenewal"), // Remove the auto-renewal setting from your domain + Operation::RetrieveAuthCode => write!(f, "retrieveAuthCode"), // Have the EPP authorization code for the domain emailed to the administrative contact + Operation::DomainForward => write!(f, "domainForward"), // Forward your domain + Operation::DomainForwardSubDomain => write!(f, "domainForwardSubDomain"), // Forward a sub-domain + Operation::DomainForwardSubDomainDelete => write!(f, "domainForwardSubDomainDelete"), // Delete a sub-domain forward + Operation::DomainLock => write!(f, "domainLock"), // Lock your domain + Operation::DomainUnlock => write!(f, "domainUnlock"), // Unlock your domain + Operation::ListEmailForwards => write!(f, "listEmailForwards"), // List all email forwards for your domain + Operation::ConfigureEmailForward => write!(f, "configureEmailForward"), // Add or modify an email forward for your domain + Operation::DeleteEmailForward => write!(f, "deleteEmailForward"), // Delete an email forward for your domain + Operation::RegistrantVerificationStatus => write!(f, "registrantVerificationStatus"), // See the verification status of any Registrant email addresses + Operation::EmailVerification => write!(f, "emailVerification"), // Verify a Registrant email address + Operation::GetAccountBalance => write!(f, "getAccountBalance"), // View your NameSilo account funds balance + Operation::AddAccountFunds => write!(f, "addAccountFunds"), // Increase your NameSilo account funds + Operation::MarketplaceActiveSalesOverview => write!(f, "marketplaceActiveSalesOverview"), // Returns a list and specifics for all of your active Marketplace sales + Operation::MarketplaceAddOrModifySale => write!(f, "marketplaceAddOrModifySale"), // Allows you to add a new Marketplace sale or modify and existing sale + Operation::MarketplaceLandingPageUpdate => write!(f, "marketplaceLandingPageUpdate"), // Allows you to update the appearance of your Marketplace Landing Page + Operation::GetPrices => write!(f, "getPrices"), // Returns our price list customized optionally based upon your account's specific pricing + Operation::ListOrders => write!(f, "listOrders"), // Returns a list of all orders placed in your account + Operation::OrderDetails => write!(f, "orderDetails"), // Provides details for the provided order number + _ => panic!("unofficial API call") // unofficial api call + } + } +} + +impl Operation { + pub(crate) fn call(&self, api_key: &String) -> Result { + match self { + Operation::ListDomains => send_api_request(&self.url(api_key, &HashMap::new())?), + Operation::GetDomainInfo { domain } => { + send_api_request(&self.url(api_key, + &hashmap![type(&str, (String, Option<(&[Range], &str)>)) + "domain" => (domain.to_string(), Some((FILTER_LETTER_NUMBER, ALLOWLIST_SYMBOLS))) + ])?) + } + Operation::DnsListRecords { domain } => { + send_api_request(&self.url(api_key, + &hashmap![type(&str, (String, Option<(&[Range], &str)>)) + "domain" => (domain.to_string(), Some((FILTER_LETTER_NUMBER, ALLOWLIST_SYMBOLS))) + ])?) + } + Operation::DnsAddRecord { domain, rrtype, rrhost, rrvalue, rrdistance, rrttl, } => { + let id_check = Operation::DnsRecordId { + domain: domain.to_string(), + rrtype: rrtype.clone(), + rrhost: rrhost.to_string() + }.call(api_key); + match id_check { + Ok(id) => Operation::DnsUpdateRecord { + domain: domain.to_string(), + rrid: id.get_string().to_string(), + rrhost: rrhost.to_string(), + rrvalue: rrvalue.to_string(), + rrdistance: *rrdistance, + rrttl: *rrttl, + }.call(api_key), + Err(e) => { + match e { + NError::RecordNotFound(_) => + send_api_request(&self.url(api_key, &hashmap![type(&str, (String, Option<(&[Range], &str)>)) + "domain" => (domain.to_string(), Some((FILTER_LETTER_NUMBER, ALLOWLIST_SYMBOLS))), + "rrtype" => (rrtype.to_string(), None), + "rrhost" => (rrhost.to_string(), Some((FILTER_LETTER_NUMBER, ALLOWLIST_SYMBOLS))), + "rrvalue" => (rrvalue.to_string(), None), + "rrdistance" => (rrdistance.to_string(), None), + "rrttl" => (rrttl.to_string(), None) + ])?), + + e => Err(e) + } + } + } + } + Operation::DnsDeleteRecord { domain, rrtype, rrhost } => { + let id_check = Operation::DnsRecordId { + domain: domain.to_string(), + rrtype: rrtype.clone(), + rrhost: rrhost.to_string() + }.call(api_key); + match id_check { + Ok(id) => + send_api_request(&self.url(api_key, &hashmap![type(&str, (String, Option<(&[Range], &str)>)) + "domain" => (domain.to_string(), Some((FILTER_LETTER_NUMBER, ALLOWLIST_SYMBOLS))), + "rrid" => (id.get_string().to_string(), None) + ])?), + _ => id_check + } + } + Operation::DnsUpdateRecord { domain, rrid, rrhost, rrvalue, rrdistance, rrttl, } => { + send_api_request(&self.url(api_key, + &hashmap![type(&str, (String, Option<(&[Range], &str)>)) + "domain" => (domain.to_string(), Some((FILTER_LETTER_NUMBER, ALLOWLIST_SYMBOLS))), + "rrid" => (rrid.to_string(), Some((FILTER_LETTER_NUMBER, ""))), + "rrhost" => (rrhost.to_string(), Some((FILTER_LETTER_NUMBER, ALLOWLIST_SYMBOLS))), + "rrvalue" => (rrvalue.to_string(), None), + "rrdistance" => (rrdistance.to_string(), None), + "rrttl" => (rrttl.to_string(), None) + ])?) + } + Operation::DnsRecordId { domain, rrtype, rrhost } => { + let record_result: Result = Operation::DnsListRecords { domain: domain.to_string() }.call(api_key); + if record_result.is_err() { return record_result; } + let record: Response = record_result.unwrap(); + let xml: roxmltree::Document = roxmltree::Document::parse(&record.get_string().as_str()).unwrap(); + let domain_str: String = if rrhost.len() > 0 { format!("{}.{}", rrhost, domain.as_str()) } else { domain.to_string() }; + match find_record_id(domain_str.as_str(), rrtype.to_string().as_str(), &xml) { + Some(id) => Ok(Response::with_string(id)), + None => Err(NError::RecordNotFound(format!("{} for {}.{}", rrtype.to_string(), rrhost, domain.as_str()))) + } + } + _ => Err(NError::NyiOpError(self.to_string())), + } + } + fn url(&self, api_key: &str, args: &HashMap<&str, (String, Option<(&[Range], &str)>)>) -> Result { + let mut params: String = String::new(); + for (k, v) in args { + if v.0.len() == 0 || v.1.is_some() && !check_string(&v.0, v.1.unwrap().0, v.1.unwrap().1) { + return Err(NError::InvalidArgError(format!("{} - {}: {}", self.to_string(), k, v.0))); + } + params.push_str(&format!("&{}{}{}", k, KEY_VALUE_SEP, v.0)) + } + Ok(format!("{}{}?version={}&type={}&key={}{}", BASE_URL, self, API_VERSION, API_TYPE, api_key, params)) + } +} + +// input constants +pub(crate) const KEY_VALUE_SEP: &str = "="; + +// filter constants +pub(crate) type Range = (char, char); + +pub(crate) const FILTER_LETTER_NUMBER: &[Range; 2] = &[('a', 'z'), ('0', '9')]; +#[allow(dead_code)] +pub(crate) const FILTER_LETTER: &[Range; 1] = &[('a', 'z')]; +pub(crate) const ALLOWLIST_SYMBOLS: &str = "._-"; diff --git a/src/lib/cli.rs b/src/lib/cli.rs new file mode 100644 index 0000000..a84f062 --- /dev/null +++ b/src/lib/cli.rs @@ -0,0 +1,20 @@ +use clap::Parser; +use crate::api::operations::*; +use crate::lib::nerror::NError; +use crate::lib::utils::{Response, KeyPath}; +use std::path::PathBuf; + +/// A quickly hacked together CLI Client for the NameSilo API +#[derive(Parser)] +struct Args { + #[command(subcommand)] + operation: Operation, + #[arg(short, long, default_value_t = KeyPath::new(PathBuf::from(".api_key")))] + #[clap(value_name="FILE")] + api_key: KeyPath, +} + +pub(crate) fn cli() -> Result { + let args = Args::parse(); + args.operation.call(&args.api_key.get_key()?) +} \ No newline at end of file diff --git a/src/lib/macros.rs b/src/lib/macros.rs index df0ce8e..44a485a 100644 --- a/src/lib/macros.rs +++ b/src/lib/macros.rs @@ -1,4 +1,3 @@ -#[macro_use] macro_rules! hashmap { ($( $key: expr => $val: expr ),*) => {{ let mut map = ::std::collections::HashMap::new(); diff --git a/src/lib/mod.rs b/src/lib/mod.rs index 19265fd..19bed12 100644 --- a/src/lib/mod.rs +++ b/src/lib/mod.rs @@ -1,4 +1,6 @@ #[macro_use] pub mod macros; pub mod nerror; -pub mod utils; \ No newline at end of file +pub mod utils; +pub mod cli; +pub mod xml; \ No newline at end of file diff --git a/src/lib/nerror.rs b/src/lib/nerror.rs index ca5668d..978c90f 100644 --- a/src/lib/nerror.rs +++ b/src/lib/nerror.rs @@ -1,6 +1,7 @@ use std::fmt; use std::error::Error; +#[allow(dead_code)] pub enum NError { ReqwestError(reqwest::Error), ParserError(url::ParseError), @@ -8,7 +9,8 @@ pub enum NError { InvalidArgError(String), MissArgError(String), InvalidOpError(String), - NyiOpError(String) + NyiOpError(String), + RecordNotFound(String) } impl fmt::Display for NError { @@ -17,10 +19,11 @@ impl fmt::Display for NError { NError::ReqwestError(e) => ::fmt(e, f), NError::ParserError(e) => ::fmt(e, f), NError::ResponseError(e) => write!(f, "Server replied with Status Code [{}]", e), - NError::InvalidArgError(arg) => write!(f, "Wrong argument [{}]", arg), + NError::InvalidArgError(arg) => write!(f, "Invalid argument [{}]", arg), NError::MissArgError(arg) => write!(f, "Missing argument [{}]", arg), NError::InvalidOpError(op) => write!(f, "Operation [{}] does not exist", op), - NError::NyiOpError(op) => write!(f, "Operation [{}] is not yet implemented", op) + NError::NyiOpError(op) => write!(f, "Operation [{}] is not yet implemented", op), + NError::RecordNotFound(rec) => write!(f, "Record [{}] does not exist", rec), } } } @@ -31,10 +34,11 @@ impl fmt::Debug for NError { NError::ReqwestError(e) => ::fmt(e, f), NError::ParserError(e) => ::fmt(e, f), NError::ResponseError(e) => write!(f, "Server replied with Status Code [{}]", e), - NError::InvalidArgError(arg) => write!(f, "Wrong argument [{}]", arg), + NError::InvalidArgError(arg) => write!(f, "Invalid argument [{}]", arg), NError::MissArgError(arg) => write!(f, "Missing argument [{}]", arg), NError::InvalidOpError(op) => write!(f, "Operation [{}] does not exist", op), - NError::NyiOpError(op) => write!(f, "Operation [{}] is not yet implemented", op) + NError::NyiOpError(op) => write!(f, "Operation [{}] is not yet implemented", op), + NError::RecordNotFound(rec) => write!(f, "Record [{}] does not exist", rec), } } } diff --git a/src/lib/utils.rs b/src/lib/utils.rs index 763c436..354ff98 100644 --- a/src/lib/utils.rs +++ b/src/lib/utils.rs @@ -1,12 +1,67 @@ use std::collections::HashMap; -use crate::api::constants::*; +use std::{fmt, fs}; +use std::path::PathBuf; +use std::str::FromStr; +use crate::api::operations::*; use crate::lib::nerror::NError; use reqwest::Url; use reqwest::StatusCode; +// PathBuf wrapper to impl Display +pub(crate) struct KeyPath(PathBuf); + +impl KeyPath { + pub(crate) fn new(path: PathBuf) -> KeyPath { + KeyPath(path) + } + pub(crate) fn get_key(&self) -> Result { + match fs::read_to_string(&self.0) { + Ok(key) => Ok(key), + Err(e) => Err(NError::InvalidArgError(format!("api_key: {} ({})", self, e.to_string()))) + } + } +} + +impl fmt::Display for KeyPath { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", self.0.display()) + } +} + +impl core::ops::Deref for KeyPath { + type Target = PathBuf; + fn deref(self: &'_ Self) -> &'_ Self::Target + { + &self.0 + } +} + +impl core::ops::DerefMut for KeyPath { + fn deref_mut(self: &'_ mut Self) -> &'_ mut Self::Target + { + &mut self.0 + } +} + +impl Clone for KeyPath { + fn clone(&self) -> Self { + KeyPath(self.0.clone()) + } +} + +impl FromStr for KeyPath { + type Err = NError; + + fn from_str(s: &str) -> Result { + Ok(KeyPath(std::path::PathBuf::from(s))) + } +} + + +#[allow(dead_code)] pub(crate) fn parse_args(args: &str, key_filter: (&[Range], &str), value_filter: (&[Range], &str)) -> HashMap { let args_vector: Vec<&str> = args.split_ascii_whitespace().collect(); - if args_vector.is_empty() { return HashMap::new() } + if args_vector.is_empty() { return HashMap::new(); } let mut args_map: HashMap = HashMap::new(); for arg in args_vector { let kv: Vec<&str> = arg.split(KEY_VALUE_SEP).collect(); @@ -17,7 +72,13 @@ pub(crate) fn parse_args(args: &str, key_filter: (&[Range], &str), value_filter: args_map } -pub(crate) fn sanitize_string(s: &str, ranges: &[Range], whitelist: &str) -> String { +#[allow(dead_code)] +pub(crate) fn parse_arg(arg: &str, value_filter: (&[Range], &str)) -> String { + sanitize_string(arg, &value_filter.0, &value_filter.1) +} + +#[allow(dead_code)] +pub(crate) fn sanitize_string(s: &str, ranges: &[Range], allowlist: &str) -> String { let s_lower: String = s.to_lowercase(); let mut result: String = String::new(); @@ -30,15 +91,35 @@ pub(crate) fn sanitize_string(s: &str, ranges: &[Range], whitelist: &str) -> Str }; for c in s_lower.chars() { - if whitelist.contains(c) || in_range(c) { + if allowlist.contains(c) || in_range(c) { result.push(c); } } result - } +pub(crate) fn check_string(s: &String, ranges: &[Range], allowlist: &str) -> bool { + let s_lower: String = s.to_lowercase(); + + // helper function to check if c is in any range + let in_range = |c: char| { + for range in ranges { + if c >= range.0 && c <= range.1 { return true; } + } + false + }; + + for c in s_lower.chars() { + if !(allowlist.contains(c) || in_range(c)) { + return false; + } + } + + true +} + +#[allow(dead_code)] pub(crate) fn check_args(args: &HashMap, required: &[&str], optional: &[&str]) -> Result<(), NError> { // check if all required fields are present @@ -68,13 +149,14 @@ pub(crate) fn send_request(url: Url) -> Result { Ok(result) } -pub(crate) fn send_api_request(operation: &str, api_key: &str, args: &HashMap) -> Result { - let url: String = api_url(operation, api_key, &args); - Ok(send_request(reqwest::Url::parse(url.as_str())?)?) +pub(crate) fn send_api_request(url: &String) -> Result { + println!("Request: {}", url); + Ok(Response::with_string(send_request(reqwest::Url::parse(url.as_str())?)?)) } +#[derive(Debug)] pub struct Response { - string: String + string: String, } impl Response { diff --git a/src/lib/xml.rs b/src/lib/xml.rs new file mode 100644 index 0000000..011b707 --- /dev/null +++ b/src/lib/xml.rs @@ -0,0 +1,18 @@ +pub(crate) fn find_node<'a>(node: &'a roxmltree::Node<'a, 'a>, tag_name: &'a str) -> Option> { + node.descendants().find( + |n| n.has_tag_name(tag_name) + ) +} + +pub(crate) fn find_record_id(domain: &str, resource_type: &str, xml: &roxmltree::Document) -> Option { + let root = xml.root(); + let reply_node = find_node(&root, "reply")?; + for node in reply_node.descendants() { + if node.has_tag_name("resource_record") { + if find_node(&node, "type")?.text()? == resource_type && find_node(&node, "host")?.text()? == domain { + return Some(find_node(&node, "record_id")?.text()?.to_string()) + } + } + } + return None +} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 842b830..d3373f8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,22 +1,13 @@ +extern crate core; + #[macro_use] mod lib; mod api; use crate::lib::nerror::NError; -use crate::api::operations::get_operation; +use crate::lib::cli::cli; fn main() -> Result<(), NError> { - - let api_key = ""; - let domain = ""; - - let result = get_operation("listDomains")?(api_key, "")?; - - println!("result: {}", result.get_string()); - - let result = get_operation("getDomainInfo")?(api_key, domain)?; - - println!("result: {}", result.get_string()); - + println!("{:#?}", cli()?); Ok(()) }