commit 29f8b6692e8ced140a9e1fbf1e93e9d91c996039 Author: Pascal Date: Sat Aug 15 10:31:05 2020 -0500 [add] initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..d015493 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,1035 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "autocfg" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" + +[[package]] +name = "base64" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d1ccbaf7d9ec9537465a97bf19edc1a4e158ecb49fc16178202238c569cc42" + +[[package]] +name = "bitflags" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" + +[[package]] +name = "bumpalo" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e8c087f005730276d1096a652e92a8bacee2e2472bcc9715a74d2bec38b5820" + +[[package]] +name = "bytes" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "130aac562c0dd69c56b3b1cc8ffd2e17be31d0b6c25b61c96b76231aa23e39e1" + +[[package]] +name = "cc" +version = "1.0.54" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7bbb73db36c1246e9034e307d0fba23f9a2e251faa47ade70c1bd252220c8311" + +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + +[[package]] +name = "core-foundation" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57d24c7a13c43e870e37c1556b74555437870a04514f7685f5b354e090567171" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.7.0" +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" + +[[package]] +name = "encoding_rs" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8ac63f94732332f44fe654443c46f6375d1939684c17b0afb6cb56b0456e171" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "fuchsia-zircon" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" +dependencies = [ + "bitflags", + "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-channel" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f366ad74c28cca6ba456d95e6422883cfb4b252a83bed929c83abfdbbf2967d5" +dependencies = [ + "futures-core", +] + +[[package]] +name = "futures-core" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59f5fff90fd5d971f936ad674802482ba441b6f09ba5e15fd8b39145582ca399" + +[[package]] +name = "futures-io" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de27142b013a8e869c14957e6d2edeef89e97c289e69d042ee3a49acd8b51789" + +[[package]] +name = "futures-sink" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f2032893cb734c7a05d85ce0cc8b8c4075278e93b24b66f9de99d6eb0fa8acc" + +[[package]] +name = "futures-task" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdb66b5f09e22019b1ab0830f7785bcea8e7a42148683f99214f73f8ec21a626" +dependencies = [ + "once_cell", +] + +[[package]] +name = "futures-util" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8764574ff08b701a084482c3c7031349104b07ac897393010494beaa18ce32c6" +dependencies = [ + "futures-core", + "futures-io", + "futures-task", + "memchr", + "pin-project", + "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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79b7246d7e4b979c03fa093da39cfb3617a96bbeee6310af63991668d7e843ff" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap", + "log", + "slab", + "tokio", + "tokio-util", +] + +[[package]] +name = "hermit-abi" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91780f809e750b0a89f5544be56617ff6b1227ee485bcb06ebe10cdf89bd3b71" +dependencies = [ + "libc", +] + +[[package]] +name = "http" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d569972648b2c512421b5f2a405ad6ac9666547189d0c5477a3f200f3e02f9" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13d5ff830006f7646652e057693569bfe0d51760c0085a071769d142a205111b" +dependencies = [ + "bytes", + "http", +] + +[[package]] +name = "httparse" +version = "1.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9" + +[[package]] +name = "hyper" +version = "0.13.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6e7655b9594024ad0ee439f3b5a7299369dc2a3f459b47c696f9ff676f9aa1f" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "itoa", + "log", + "pin-project", + "socket2", + "time", + "tokio", + "tower-service", + "want", +] + +[[package]] +name = "hyper-tls" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3adcd308402b9553630734e9c36b77a7e48b3821251ca2493e8cd596763aafaa" +dependencies = [ + "bytes", + "hyper", + "native-tls", + "tokio", + "tokio-tls", +] + +[[package]] +name = "idna" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9" +dependencies = [ + "matches", + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "indexmap" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c398b2b113b55809ceb9ee3e753fcbac793f1956663f3c36549c1346015c2afe" +dependencies = [ + "autocfg", +] + +[[package]] +name = "iovec" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" +dependencies = [ + "libc", +] + +[[package]] +name = "itoa" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8b7a7c0c47db5545ed3fef7468ee7bb5b74691498139e4b3f6a20685dc6dd8e" + +[[package]] +name = "js-sys" +version = "0.3.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce10c23ad2ea25ceca0093bd3192229da4c5b3c0f2de499c1ecac0d98d452177" +dependencies = [ + "wasm-bindgen", +] + +[[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 = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.71" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9457b06509d27052635f90d6466700c65095fdf75409b3fbdd903e988b886f49" + +[[package]] +name = "log" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" +dependencies = [ + "cfg-if", +] + +[[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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" + +[[package]] +name = "mime" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" + +[[package]] +name = "mime_guess" +version = "2.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2684d4c2e97d99848d30b324b00c8fcc7e5c897b7cbb5819b09e7c90e8baf212" +dependencies = [ + "mime", + "unicase", +] + +[[package]] +name = "mio" +version = "0.6.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fce347092656428bc8eaf6201042cb551b8d67855af7374542a92a0fbfcac430" +dependencies = [ + "cfg-if", + "fuchsia-zircon", + "fuchsia-zircon-sys", + "iovec", + "kernel32-sys", + "libc", + "log", + "miow", + "net2", + "slab", + "winapi 0.2.8", +] + +[[package]] +name = "miow" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" +dependencies = [ + "kernel32-sys", + "net2", + "winapi 0.2.8", + "ws2_32-sys", +] + +[[package]] +name = "namesilo_cli" +version = "0.1.0" +dependencies = [ + "reqwest", + "url", + "xml-rs", +] + +[[package]] +name = "native-tls" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b0d88c06fe90d5ee94048ba40409ef1d9315d86f6f38c2efdaad4fb50c58b2d" +dependencies = [ + "lazy_static", + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + +[[package]] +name = "net2" +version = "0.2.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ba7c918ac76704fb42afcbbb43891e72731f3dcca3bef2a19786297baf14af7" +dependencies = [ + "cfg-if", + "libc", + "winapi 0.3.8", +] + +[[package]] +name = "num_cpus" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "once_cell" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b631f7e854af39a1739f401cf34a8a013dfe09eac4fa4dba91e9768bd28168d" + +[[package]] +name = "openssl" +version = "0.10.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cee6d85f4cb4c4f59a6a85d5b68a233d280c82e29e822913b9c8b129fbf20bdd" +dependencies = [ + "bitflags", + "cfg-if", + "foreign-types", + "lazy_static", + "libc", + "openssl-sys", +] + +[[package]] +name = "openssl-probe" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" + +[[package]] +name = "openssl-sys" +version = "0.9.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7410fef80af8ac071d4f63755c0ab89ac3df0fd1ea91f1d1f37cf5cec4395990" +dependencies = [ + "autocfg", + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "percent-encoding" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" + +[[package]] +name = "pin-project" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edc93aeee735e60ecb40cf740eb319ff23eab1c5748abfdb5c180e4ce49f7791" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e58db2081ba5b4c93bd6be09c40fd36cb9193a8336c384f3b40012e531aa7e40" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "pin-project-lite" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9df32da11d84f3a7d70205549562966279adb900e080fad3dccd8e64afccf0ad" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkg-config" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677" + +[[package]] +name = "ppv-lite86" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "237a5ed80e274dbc66f86bd59c1e25edc039660be53194b5fe0a482e0f2612ea" + +[[package]] +name = "proc-macro2" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "beae6331a816b1f65d04c45b078fd8e6c93e8071771f41b8163255bbd8d7c8fa" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "quote" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54a21852a652ad6f610c9510194f398ff6f8692e334fd1145fed931f7fbe44ea" +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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" + +[[package]] +name = "remove_dir_all" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e" +dependencies = [ + "winapi 0.3.8", +] + +[[package]] +name = "reqwest" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b82c9238b305f26f53443e3a4bc8528d64b8d0bee408ec949eb7bf5635ec680" +dependencies = [ + "base64", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "http", + "http-body", + "hyper", + "hyper-tls", + "js-sys", + "lazy_static", + "log", + "mime", + "mime_guess", + "native-tls", + "percent-encoding", + "pin-project-lite", + "serde", + "serde_json", + "serde_urlencoded", + "tokio", + "tokio-tls", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "winreg", +] + +[[package]] +name = "ryu" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" + +[[package]] +name = "schannel" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75" +dependencies = [ + "lazy_static", + "winapi 0.3.8", +] + +[[package]] +name = "security-framework" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64808902d7d99f78eaddd2b4e2509713babc3dc3c85ad6f4c447680f3c01e535" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17bf11d99252f512695eb468de5516e5cf75455521e69dfe343f3b74e4748405" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "serde" +version = "1.0.111" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9124df5b40cbd380080b2cc6ab894c040a3070d995f5c9dc77e18c34a8ae37d" + +[[package]] +name = "serde_json" +version = "1.0.53" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "993948e75b189211a9b31a7528f950c6adc21f9720b6438ff80a7fa2f864cea2" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_urlencoded" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ec5d77e2d4c73717816afac02670d5c4f534ea95ed430442cad02e7a6e32c97" +dependencies = [ + "dtoa", + "itoa", + "serde", + "url", +] + +[[package]] +name = "slab" +version = "0.4.2" +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" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "winapi 0.3.8", +] + +[[package]] +name = "syn" +version = "1.0.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93a56fabc59dce20fe48b6c832cc249c713e7ed88fa28b0ee0a3bfcaae5fe4e2" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "tempfile" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" +dependencies = [ + "cfg-if", + "libc", + "rand", + "redox_syscall", + "remove_dir_all", + "winapi 0.3.8", +] + +[[package]] +name = "time" +version = "0.1.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438" +dependencies = [ + "libc", + "winapi 0.3.8", +] + +[[package]] +name = "tokio" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d099fa27b9702bed751524694adbe393e18b36b204da91eb1cbbbbb4a5ee2d58" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "iovec", + "lazy_static", + "memchr", + "mio", + "num_cpus", + "pin-project-lite", + "slab", +] + +[[package]] +name = "tokio-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a70f4fcd7b3b24fb194f837560168208f669ca8cb70d0c4b862944452396343" +dependencies = [ + "native-tls", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be8242891f2b6cbef26a2d7e8605133c2c554cd35b3e4948ea892d6d68436499" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "log", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tower-service" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e987b6bf443f4b5b3b6f38704195592cca41c5bb7aedd3c3693c7081f8289860" + +[[package]] +name = "try-lock" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e604eb7b43c06650e854be16a2a03155743d3752dd1c943f6829e26b7a36e382" + +[[package]] +name = "unicase" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" +dependencies = [ + "version_check", +] + +[[package]] +name = "unicode-bidi" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" +dependencies = [ + "matches", +] + +[[package]] +name = "unicode-normalization" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5479532badd04e128284890390c1e876ef7a993d0570b3597ae43dfa1d59afa4" +dependencies = [ + "smallvec", +] + +[[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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "829d4a8476c35c9bf0bbce5a3b23f4106f79728039b726d292bb93bc106787cb" +dependencies = [ + "idna", + "matches", + "percent-encoding", +] + +[[package]] +name = "vcpkg" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55d1e41d56121e07f1e223db0a4def204e45c85425f6a16d462fd07c8d10d74c" + +[[package]] +name = "version_check" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" + +[[package]] +name = "want" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" +dependencies = [ + "log", + "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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c2dc4aa152834bc334f506c1a06b866416a8b6697d5c9f75b9a689c8486def0" +dependencies = [ + "cfg-if", + "serde", + "serde_json", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ded84f06e0ed21499f6184df0e0cb3494727b0c5da89534e0fcc55c51d812101" +dependencies = [ + "bumpalo", + "lazy_static", + "log", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64487204d863f109eb77e8462189d111f27cb5712cc9fdb3461297a76963a2f6" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "838e423688dac18d73e31edce74ddfac468e37b1506ad163ffaf0a46f703ffe3" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3156052d8ec77142051a533cdd686cba889537b213f948cd1d20869926e68e92" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9ba19973a58daf4db6f352eda73dc0e289493cd29fb2632eb172085b6521acd" + +[[package]] +name = "web-sys" +version = "0.3.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b72fe77fd39e4bd3eaa4412fd299a0be6b3dfe9d2597e2f1c20beb968f41d17" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[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.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" +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.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0120db82e8a1e0b9fb3345a539c478767c0048d842860994d96113d5b667bd69" +dependencies = [ + "winapi 0.3.8", +] + +[[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", +] + +[[package]] +name = "xml-rs" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b07db065a5cf61a7e4ba64f29e67db906fb1787316516c4e6e5ff0fea1efcd8a" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..7fc16ce --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "namesilo_cli" +version = "0.1.0" +authors = ["Pascal"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +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 diff --git a/src/api/constants.rs b/src/api/constants.rs new file mode 100644 index 0000000..1e8ec3b --- /dev/null +++ b/src/api/constants.rs @@ -0,0 +1,80 @@ +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 new file mode 100644 index 0000000..d60aef2 --- /dev/null +++ b/src/api/functions.rs @@ -0,0 +1,24 @@ +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 new file mode 100644 index 0000000..4c65161 --- /dev/null +++ b/src/api/mod.rs @@ -0,0 +1,3 @@ +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 new file mode 100644 index 0000000..a77fcbe --- /dev/null +++ b/src/api/operations.rs @@ -0,0 +1,75 @@ +use crate::api::functions::*; +use crate::api::constants::*; +use std::collections::HashMap; +use crate::lib::nerror::NError; +use crate::lib::utils::Response; + +pub(crate) type Operation = fn(&str, &str) -> Result; + +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())) + ]; + + let op: Option> = operation_mapping.remove(&op_name.to_lowercase()); + match op { + Some(v) => v, + None => Err(NError::InvalidOpError(op_name.to_string())) + } + +} \ No newline at end of file diff --git a/src/lib/macros.rs b/src/lib/macros.rs new file mode 100644 index 0000000..df0ce8e --- /dev/null +++ b/src/lib/macros.rs @@ -0,0 +1,13 @@ +#[macro_use] +macro_rules! hashmap { + ($( $key: expr => $val: expr ),*) => {{ + let mut map = ::std::collections::HashMap::new(); + $( map.insert($key, $val); )* + map + }}; + ( type($key_type: ty, $value_type: ty) $( $key: expr => $val: expr ),* ) => {{ + let mut map: HashMap<$key_type, $value_type> = ::std::collections::HashMap::new(); + $( map.insert($key, $val); )* + map + }} +} \ No newline at end of file diff --git a/src/lib/mod.rs b/src/lib/mod.rs new file mode 100644 index 0000000..19265fd --- /dev/null +++ b/src/lib/mod.rs @@ -0,0 +1,4 @@ +#[macro_use] +pub mod macros; +pub mod nerror; +pub mod utils; \ No newline at end of file diff --git a/src/lib/nerror.rs b/src/lib/nerror.rs new file mode 100644 index 0000000..ca5668d --- /dev/null +++ b/src/lib/nerror.rs @@ -0,0 +1,54 @@ +use std::fmt; +use std::error::Error; + +pub enum NError { + ReqwestError(reqwest::Error), + ParserError(url::ParseError), + ResponseError(u16), + InvalidArgError(String), + MissArgError(String), + InvalidOpError(String), + NyiOpError(String) +} + +impl fmt::Display for NError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self { + 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::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) + } + } +} + +impl fmt::Debug for NError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self { + 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::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) + } + } +} + +impl From for NError { + fn from(e: reqwest::Error) -> NError { + NError::ReqwestError(e) + } +} + +impl From for NError { + fn from(e: url::ParseError) -> NError { + NError::ParserError(e) + } +} + +impl Error for NError {} \ No newline at end of file diff --git a/src/lib/utils.rs b/src/lib/utils.rs new file mode 100644 index 0000000..763c436 --- /dev/null +++ b/src/lib/utils.rs @@ -0,0 +1,92 @@ +use std::collections::HashMap; +use crate::api::constants::*; +use crate::lib::nerror::NError; +use reqwest::Url; +use reqwest::StatusCode; + +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() } + let mut args_map: HashMap = HashMap::new(); + for arg in args_vector { + let kv: Vec<&str> = arg.split(KEY_VALUE_SEP).collect(); + if kv.len() < 2 { continue; } + args_map.insert(sanitize_string(kv[0], &key_filter.0, &key_filter.1), + sanitize_string(kv[1], &value_filter.0, &value_filter.1)); + } + args_map +} + +pub(crate) fn sanitize_string(s: &str, ranges: &[Range], whitelist: &str) -> String { + let s_lower: String = s.to_lowercase(); + let mut result: String = String::new(); + + // 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 whitelist.contains(c) || in_range(c) { + result.push(c); + } + } + + result + +} + +pub(crate) fn check_args(args: &HashMap, required: &[&str], optional: &[&str]) -> Result<(), NError> { + + // check if all required fields are present + for required_param in required { + if !args.contains_key(&required_param.to_string()) { + return Err(NError::MissArgError(required_param.to_string())); + } + } + + // check if all fields are valid + for (k, _) in args { + if !(required.contains(&k.as_str()) || optional.contains(&k.as_str())) { + return Err(NError::InvalidArgError(k.to_string())); + } + } + + Ok(()) +} + +pub(crate) fn send_request(url: Url) -> Result { + let resp: reqwest::blocking::Response = reqwest::blocking::get(url)?; + if resp.status() != StatusCode::OK { + return Err(NError::ResponseError(resp.status().as_u16())); + } + let result: String = resp.text()?; + + 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 struct Response { + string: String +} + +impl Response { + #[allow(dead_code)] + pub(crate) fn new() -> Response { + Response { string: String::new() } + } + pub(crate) fn with_string(string: String) -> Response { + Response { string } + } + + pub fn get_string(&self) -> &String { + &self.string + } +} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..842b830 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,22 @@ +#[macro_use] +mod lib; +mod api; + +use crate::lib::nerror::NError; +use crate::api::operations::get_operation; + +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()); + + Ok(()) +}