From e5afd54ce072574da5052a329f0a9761c7ba6ad7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Stuczy=C5=84ski?= Date: Mon, 19 Jul 2021 14:02:47 +0100 Subject: [PATCH] Feature/node status api (#680) * Basic storage stub * New models for new node status api * Route handling * Mounting new routes * Missing selective commit * Moved network monitor related files to separate package * Starting to see some sqlx action * Schema updates * Log statement upon finished migration * Removed old diesel related imports * Converted mixnode cache initialisation into a fairing * Moved cache related functionalities to separate package Also defined staging there * Created run method for validator cache + removed unwrap * Removed old node-status-api types and left bunch of todo placeholders in their place * Fixed managing validatorcache * Status reports are starting to get constructed * Submitting some dummy results to the database * Removing duplicate code for generating reports * Removed statuses older than 48h * Initial attempt at trying to obtain reports for all active nodes * Removed duplicates from the full report * Grabbing uptime history * Updating historical uptimes of active nodes * Updated sqlx-data.json * Removed all placeholder foomp owner values * Changed Layer serde behaviour for easier usage * Extended validator api config * Initial (seems working !) integration with network monitor * Added database path configuration to config * Using ValidatorCache in NetworkMonitor * Flag indicating whether validator cache has been initialised * Introduced a locla-only route for reward script to perform daily chores * Flag to save config to a file * Moved spawning of receiving future to run method rather than new * Removed arguments that dont make sense to be configured via CLI * Removed dead code from config file * More dead code removal * Added validator API to CI * Corrected manifest-path arguments * Constructing network monitor by passing config * Combined validator API CI with the main CI file * Using query_as for NodeStatus * Checking if historical uptimes were already calculated on particular day * Making id field NOT NULL * More query_as! action * Updated sqlx-data.json * Removed unused chrono feature * Renamed the migration file * Changed default validator endpoint to point to local validator * Removing unnecessary clone * More appropriate naming * Removed dead code * Lock file updates * Updated network monitor address in contract code * Don't stage node status api if network monitor is disabled * cargo fmt * Updated all license notices to SPDX --- .github/workflows/build.yml | 31 +- Cargo.lock | 71 - Cargo.toml | 6 +- .../src/client/cover_traffic_stream.rs | 15 +- clients/client-core/src/client/key_manager.rs | 15 +- clients/client-core/src/client/mix_traffic.rs | 15 +- .../acknowledgement_listener.rs | 15 +- .../action_controller.rs | 15 +- .../input_message_listener.rs | 15 +- .../acknowledgement_control/mod.rs | 15 +- .../retransmission_request_listener.rs | 15 +- .../sent_notification_listener.rs | 15 +- .../src/client/real_messages_control/mod.rs | 15 +- .../real_traffic_stream.rs | 15 +- .../client-core/src/client/received_buffer.rs | 15 +- .../src/client/reply_key_storage.rs | 15 +- .../src/client/topology_control.rs | 15 +- clients/client-core/src/config/mod.rs | 15 +- .../src/config/persistence/key_pathfinder.rs | 15 +- .../client-core/src/config/persistence/mod.rs | 15 +- clients/native/src/client/config/mod.rs | 15 +- clients/native/src/client/config/template.rs | 15 +- clients/native/src/client/mod.rs | 15 +- clients/native/src/commands/init.rs | 15 +- clients/native/src/commands/mod.rs | 15 +- clients/native/src/commands/run.rs | 15 +- clients/native/src/commands/upgrade.rs | 15 +- clients/native/src/lib.rs | 15 +- clients/native/src/main.rs | 15 +- clients/native/src/websocket/handler.rs | 15 +- clients/native/src/websocket/listener.rs | 15 +- clients/native/src/websocket/mod.rs | 15 +- .../native/websocket-requests/src/error.rs | 15 +- clients/native/websocket-requests/src/lib.rs | 15 +- .../native/websocket-requests/src/requests.rs | 15 +- .../websocket-requests/src/responses.rs | 15 +- clients/native/websocket-requests/src/text.rs | 15 +- clients/socks5/src/client/config/mod.rs | 15 +- clients/socks5/src/client/config/template.rs | 15 +- clients/socks5/src/client/mod.rs | 15 +- clients/socks5/src/commands/init.rs | 15 +- clients/socks5/src/commands/mod.rs | 15 +- clients/socks5/src/commands/run.rs | 15 +- clients/socks5/src/commands/upgrade.rs | 15 +- clients/socks5/src/lib.rs | 16 +- clients/socks5/src/main.rs | 15 +- clients/webassembly/Cargo.toml | 4 +- clients/webassembly/src/client/mod.rs | 15 +- .../src/client/received_processor.rs | 15 +- clients/webassembly/src/lib.rs | 15 +- common/client-libs/gateway-client/Cargo.toml | 11 +- .../client-libs/gateway-client/src/client.rs | 15 +- .../client-libs/gateway-client/src/error.rs | 15 +- common/client-libs/gateway-client/src/lib.rs | 15 +- .../gateway-client/src/packet_router.rs | 15 +- .../gateway-client/src/socket_state.rs | 15 +- .../client-libs/mixnet-client/src/client.rs | 15 +- .../mixnet-client/src/forwarder.rs | 15 +- common/client-libs/mixnet-client/src/lib.rs | 15 +- .../client-libs/validator-client/Cargo.toml | 10 +- .../client-libs/validator-client/src/lib.rs | 1 + .../validator-client/src/models.rs | 4 +- .../validator-client/src/serde_helpers.rs | 2 +- .../crypto/src/asymmetric/encryption/mod.rs | 15 +- common/crypto/src/asymmetric/identity/mod.rs | 15 +- common/crypto/src/asymmetric/mod.rs | 15 +- common/crypto/src/crypto_hash.rs | 15 +- common/crypto/src/hkdf.rs | 15 +- common/crypto/src/hmac.rs | 15 +- common/crypto/src/lib.rs | 15 +- common/crypto/src/shared_key.rs | 15 +- common/crypto/src/symmetric/mod.rs | 15 +- .../src/cached_packet_processor/cache.rs | 15 +- .../src/cached_packet_processor/error.rs | 15 +- .../src/cached_packet_processor/mod.rs | 15 +- .../src/cached_packet_processor/processor.rs | 15 +- common/mixnode-common/src/lib.rs | 15 +- common/mixnode-common/src/verloc/error.rs | 15 +- common/mixnode-common/src/verloc/listener.rs | 15 +- .../mixnode-common/src/verloc/measurement.rs | 15 +- common/mixnode-common/src/verloc/mod.rs | 15 +- common/mixnode-common/src/verloc/packet.rs | 15 +- common/mixnode-common/src/verloc/sender.rs | 15 +- common/nonexhaustive-delayqueue/src/lib.rs | 15 +- .../acknowledgements/src/identifier.rs | 15 +- common/nymsphinx/acknowledgements/src/key.rs | 15 +- common/nymsphinx/acknowledgements/src/lib.rs | 15 +- .../acknowledgements/src/surb_ack.rs | 15 +- common/nymsphinx/addressing/src/lib.rs | 15 +- common/nymsphinx/addressing/src/nodes.rs | 15 +- .../anonymous-replies/src/encryption_key.rs | 15 +- common/nymsphinx/anonymous-replies/src/lib.rs | 16 +- .../anonymous-replies/src/reply_surb.rs | 15 +- common/nymsphinx/chunking/src/fragment.rs | 15 +- common/nymsphinx/chunking/src/lib.rs | 15 +- .../nymsphinx/chunking/src/reconstruction.rs | 16 +- common/nymsphinx/chunking/src/set.rs | 15 +- common/nymsphinx/cover/src/lib.rs | 15 +- common/nymsphinx/forwarding/src/lib.rs | 15 +- common/nymsphinx/forwarding/src/packet.rs | 15 +- common/nymsphinx/framing/src/codec.rs | 15 +- common/nymsphinx/framing/src/lib.rs | 15 +- common/nymsphinx/framing/src/packet.rs | 15 +- common/nymsphinx/params/src/lib.rs | 16 +- common/nymsphinx/params/src/packet_modes.rs | 15 +- common/nymsphinx/params/src/packet_sizes.rs | 15 +- common/nymsphinx/src/lib.rs | 15 +- common/nymsphinx/src/preparer/mod.rs | 15 +- common/nymsphinx/src/preparer/vpn_manager.rs | 15 +- common/nymsphinx/src/receiver.rs | 15 +- common/nymsphinx/src/utils/mod.rs | 15 +- common/nymsphinx/types/src/lib.rs | 15 +- common/pemstore/src/lib.rs | 16 +- common/pemstore/src/traits.rs | 15 +- .../proxy-helpers/src/available_reader.rs | 15 +- .../src/connection_controller.rs | 15 +- common/socks5/proxy-helpers/src/lib.rs | 15 +- .../proxy-helpers/src/proxy_runner/inbound.rs | 15 +- .../proxy-helpers/src/proxy_runner/mod.rs | 15 +- .../src/proxy_runner/outbound.rs | 15 +- common/topology/src/filter.rs | 15 +- common/topology/src/gateway.rs | 15 +- common/topology/src/lib.rs | 15 +- common/topology/src/mix.rs | 15 +- common/version-checker/src/lib.rs | 15 +- common/wasm-utils/src/lib.rs | 15 +- common/wasm-utils/src/websocket/mod.rs | 15 +- common/wasm-utils/src/websocket/state.rs | 15 +- contracts/mixnet/src/contract.rs | 2 +- contracts/mixnet/src/helpers.rs | 15 +- validator-api/Cargo.lock | 3710 +++++++++++++++++ validator-api/Cargo.toml | 6 + .../20210714120000_create_initial_tables.sql | 91 + validator-api/sqlx-data.json | 505 +++ validator-api/src/cache.rs | 65 - validator-api/src/cache/mod.rs | 146 + validator-api/src/cache/routes.rs | 17 + validator-api/src/config/mod.rs | 74 +- validator-api/src/config/template.rs | 16 +- validator-api/src/main.rs | 439 +- .../src/{ => network_monitor}/chunker.rs | 2 +- .../{ => network_monitor}/gateways_reader.rs | 0 validator-api/src/network_monitor/mod.rs | 220 + .../src/{ => network_monitor}/monitor/mod.rs | 99 +- .../{ => network_monitor}/monitor/preparer.rs | 72 +- .../monitor/processor.rs | 44 +- .../{ => network_monitor}/monitor/receiver.rs | 4 +- .../{ => network_monitor}/monitor/sender.rs | 2 +- .../monitor/summary_producer.rs | 105 +- .../src/{ => network_monitor}/test_packet.rs | 4 +- .../tested_network/good_topology.rs | 2 +- .../tested_network/mod.rs | 4 +- validator-api/src/node_status_api/client.rs | 110 - .../src/node_status_api/local_guard.rs | 42 + validator-api/src/node_status_api/mod.rs | 92 +- validator-api/src/node_status_api/models.rs | 284 +- validator-api/src/node_status_api/routes.rs | 98 + validator-api/src/node_status_api/storage.rs | 1045 +++++ validator-api/src/node_status_api/utils.rs | 99 + 159 files changed, 6857 insertions(+), 2487 deletions(-) create mode 100644 validator-api/Cargo.lock create mode 100644 validator-api/migrations/20210714120000_create_initial_tables.sql create mode 100644 validator-api/sqlx-data.json delete mode 100644 validator-api/src/cache.rs create mode 100644 validator-api/src/cache/mod.rs create mode 100644 validator-api/src/cache/routes.rs rename validator-api/src/{ => network_monitor}/chunker.rs (97%) rename validator-api/src/{ => network_monitor}/gateways_reader.rs (100%) create mode 100644 validator-api/src/network_monitor/mod.rs rename validator-api/src/{ => network_monitor}/monitor/mod.rs (70%) rename validator-api/src/{ => network_monitor}/monitor/preparer.rs (90%) rename validator-api/src/{ => network_monitor}/monitor/processor.rs (85%) rename validator-api/src/{ => network_monitor}/monitor/receiver.rs (93%) rename validator-api/src/{ => network_monitor}/monitor/sender.rs (99%) rename validator-api/src/{ => network_monitor}/monitor/summary_producer.rs (73%) rename validator-api/src/{ => network_monitor}/test_packet.rs (97%) rename validator-api/src/{ => network_monitor}/tested_network/good_topology.rs (94%) rename validator-api/src/{ => network_monitor}/tested_network/mod.rs (94%) delete mode 100644 validator-api/src/node_status_api/client.rs create mode 100644 validator-api/src/node_status_api/local_guard.rs create mode 100644 validator-api/src/node_status_api/routes.rs create mode 100644 validator-api/src/node_status_api/storage.rs create mode 100644 validator-api/src/node_status_api/utils.rs diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 28d8d1bfc8..c872b3f90e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,23 +21,52 @@ jobs: override: true components: rustfmt, clippy + # main repo - uses: actions-rs/cargo@v1 with: command: build args: --all + # validator API + - uses: actions-rs/cargo@v1 + with: + command: build + args: --manifest-path validator-api/Cargo.toml + + # main repo - uses: actions-rs/cargo@v1 with: command: test args: --all + # validator API + - uses: actions-rs/cargo@v1 + with: + command: test + args: --manifest-path validator-api/Cargo.toml + + # main repo - uses: actions-rs/cargo@v1 with: command: fmt args: --all -- --check + # validator API + - uses: actions-rs/cargo@v1 + with: + command: fmt + args: --manifest-path validator-api/Cargo.toml -- --check + + # main repo - uses: actions-rs/cargo@v1 if: ${{ matrix.rust != 'nightly' }} with: command: clippy - args: -- -D warnings \ No newline at end of file + args: -- -D warnings + + # validator API + - uses: actions-rs/cargo@v1 + if: ${{ matrix.rust != 'nightly' }} + with: + command: clippy + args: --manifest-path validator-api/Cargo.toml -- -D warnings \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index b72b887f29..eeabe0bca6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -88,12 +88,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "anyhow" -version = "1.0.41" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15af2628f6890fe2609a3b91bef4c83450512802e59489f9c1cb1fa5df064a61" - [[package]] name = "arrayref" version = "0.3.6" @@ -1841,37 +1835,6 @@ dependencies = [ "version-checker", ] -[[package]] -name = "nym-validator-api" -version = "0.11.0-rc1" -dependencies = [ - "anyhow", - "clap", - "config", - "crypto", - "dirs", - "dotenv", - "futures", - "gateway-client", - "gateway-requests", - "humantime-serde", - "log", - "mixnet-contract", - "nymsphinx", - "pin-project", - "pretty_env_logger", - "rand 0.7.3", - "reqwest", - "rocket", - "rocket_cors", - "serde", - "serde_json", - "tokio", - "topology", - "validator-client", - "version-checker", -] - [[package]] name = "nymsphinx" version = "0.1.0" @@ -2567,21 +2530,6 @@ dependencies = [ "unicode-xid", ] -[[package]] -name = "rocket_cors" -version = "0.5.2" -source = "git+https://github.com/lawliet89/rocket_cors?rev=dfd3662c49e2f6fc37df35091cb94d82f7fb5915#dfd3662c49e2f6fc37df35091cb94d82f7fb5915" -dependencies = [ - "log", - "regex", - "rocket", - "serde", - "serde_derive", - "unicase", - "unicase_serde", - "url", -] - [[package]] name = "rocket_http" version = "0.5.0-rc.1" @@ -3461,25 +3409,6 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eeba86d422ce181a719445e51872fa30f1f7413b62becb52e95ec91aa262d85c" -[[package]] -name = "unicase" -version = "2.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" -dependencies = [ - "version_check", -] - -[[package]] -name = "unicase_serde" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ef53697679d874d69f3160af80bc28de12730a985d57bdf2b47456ccb8b11f1" -dependencies = [ - "serde", - "unicase", -] - [[package]] name = "unicode-bidi" version = "0.3.5" diff --git a/Cargo.toml b/Cargo.toml index 1f8a0a5e77..e6868937ca 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,7 +42,7 @@ members = [ "gateway", "gateway/gateway-requests", "mixnode", - "validator-api", +# "validator-api", "service-providers/network-requester", ] @@ -53,7 +53,7 @@ default-members = [ "gateway", "service-providers/network-requester", "mixnode", - "validator-api", +# "validator-api", ] -exclude = ["explorer", "contracts"] +exclude = ["explorer", "contracts", "validator-api"] diff --git a/clients/client-core/src/client/cover_traffic_stream.rs b/clients/client-core/src/client/cover_traffic_stream.rs index f2c3ad9d70..1b22b689e9 100644 --- a/clients/client-core/src/client/cover_traffic_stream.rs +++ b/clients/client-core/src/client/cover_traffic_stream.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use crate::client::mix_traffic::BatchMixMessageSender; use crate::client::topology_control::TopologyAccessor; diff --git a/clients/client-core/src/client/key_manager.rs b/clients/client-core/src/client/key_manager.rs index 73c522b15f..cad8f726d4 100644 --- a/clients/client-core/src/client/key_manager.rs +++ b/clients/client-core/src/client/key_manager.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use crate::config::persistence::key_pathfinder::ClientKeyPathfinder; use crypto::asymmetric::{encryption, identity}; diff --git a/clients/client-core/src/client/mix_traffic.rs b/clients/client-core/src/client/mix_traffic.rs index 1b092f95b6..a8851c5db4 100644 --- a/clients/client-core/src/client/mix_traffic.rs +++ b/clients/client-core/src/client/mix_traffic.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use futures::channel::mpsc; use futures::StreamExt; diff --git a/clients/client-core/src/client/real_messages_control/acknowledgement_control/acknowledgement_listener.rs b/clients/client-core/src/client/real_messages_control/acknowledgement_control/acknowledgement_listener.rs index 5fd4f8f423..77294b8cd6 100644 --- a/clients/client-core/src/client/real_messages_control/acknowledgement_control/acknowledgement_listener.rs +++ b/clients/client-core/src/client/real_messages_control/acknowledgement_control/acknowledgement_listener.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use super::action_controller::{Action, ActionSender}; use futures::StreamExt; diff --git a/clients/client-core/src/client/real_messages_control/acknowledgement_control/action_controller.rs b/clients/client-core/src/client/real_messages_control/acknowledgement_control/action_controller.rs index 393e740552..d619cf3f35 100644 --- a/clients/client-core/src/client/real_messages_control/acknowledgement_control/action_controller.rs +++ b/clients/client-core/src/client/real_messages_control/acknowledgement_control/action_controller.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use super::PendingAcknowledgement; use crate::client::real_messages_control::acknowledgement_control::RetransmissionRequestSender; diff --git a/clients/client-core/src/client/real_messages_control/acknowledgement_control/input_message_listener.rs b/clients/client-core/src/client/real_messages_control/acknowledgement_control/input_message_listener.rs index 388219cadc..2e34451de3 100644 --- a/clients/client-core/src/client/real_messages_control/acknowledgement_control/input_message_listener.rs +++ b/clients/client-core/src/client/real_messages_control/acknowledgement_control/input_message_listener.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use super::action_controller::{Action, ActionSender}; use super::PendingAcknowledgement; diff --git a/clients/client-core/src/client/real_messages_control/acknowledgement_control/mod.rs b/clients/client-core/src/client/real_messages_control/acknowledgement_control/mod.rs index 3e3c4bbee2..5156a34115 100644 --- a/clients/client-core/src/client/real_messages_control/acknowledgement_control/mod.rs +++ b/clients/client-core/src/client/real_messages_control/acknowledgement_control/mod.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use self::{ acknowledgement_listener::AcknowledgementListener, action_controller::ActionController, diff --git a/clients/client-core/src/client/real_messages_control/acknowledgement_control/retransmission_request_listener.rs b/clients/client-core/src/client/real_messages_control/acknowledgement_control/retransmission_request_listener.rs index 1e4c01dbc1..d0081f4d04 100644 --- a/clients/client-core/src/client/real_messages_control/acknowledgement_control/retransmission_request_listener.rs +++ b/clients/client-core/src/client/real_messages_control/acknowledgement_control/retransmission_request_listener.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use super::action_controller::{Action, ActionSender}; use super::PendingAcknowledgement; diff --git a/clients/client-core/src/client/real_messages_control/acknowledgement_control/sent_notification_listener.rs b/clients/client-core/src/client/real_messages_control/acknowledgement_control/sent_notification_listener.rs index cede5a38fb..2bd2eac933 100644 --- a/clients/client-core/src/client/real_messages_control/acknowledgement_control/sent_notification_listener.rs +++ b/clients/client-core/src/client/real_messages_control/acknowledgement_control/sent_notification_listener.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use super::action_controller::{Action, ActionSender}; use super::SentPacketNotificationReceiver; diff --git a/clients/client-core/src/client/real_messages_control/mod.rs b/clients/client-core/src/client/real_messages_control/mod.rs index 3020a6835d..78681a6101 100644 --- a/clients/client-core/src/client/real_messages_control/mod.rs +++ b/clients/client-core/src/client/real_messages_control/mod.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 // INPUT: InputMessage from user // INPUT2: Acks from mix diff --git a/clients/client-core/src/client/real_messages_control/real_traffic_stream.rs b/clients/client-core/src/client/real_messages_control/real_traffic_stream.rs index b088f91630..34f8b5c9e9 100644 --- a/clients/client-core/src/client/real_messages_control/real_traffic_stream.rs +++ b/clients/client-core/src/client/real_messages_control/real_traffic_stream.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use crate::client::mix_traffic::BatchMixMessageSender; use crate::client::real_messages_control::acknowledgement_control::SentPacketNotificationSender; diff --git a/clients/client-core/src/client/received_buffer.rs b/clients/client-core/src/client/received_buffer.rs index f4c1836c27..fae6320ab5 100644 --- a/clients/client-core/src/client/received_buffer.rs +++ b/clients/client-core/src/client/received_buffer.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use crate::client::reply_key_storage::ReplyKeyStorage; use crypto::asymmetric::encryption; diff --git a/clients/client-core/src/client/reply_key_storage.rs b/clients/client-core/src/client/reply_key_storage.rs index 06911faed1..e8c01e9526 100644 --- a/clients/client-core/src/client/reply_key_storage.rs +++ b/clients/client-core/src/client/reply_key_storage.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use log::*; use nymsphinx::anonymous_replies::{ diff --git a/clients/client-core/src/client/topology_control.rs b/clients/client-core/src/client/topology_control.rs index 89cdbc9a7e..d325d4cca7 100644 --- a/clients/client-core/src/client/topology_control.rs +++ b/clients/client-core/src/client/topology_control.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use log::*; use nymsphinx::addressing::clients::Recipient; diff --git a/clients/client-core/src/config/mod.rs b/clients/client-core/src/config/mod.rs index e73eafe081..7d8b43efdd 100644 --- a/clients/client-core/src/config/mod.rs +++ b/clients/client-core/src/config/mod.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use config::{deserialize_duration, deserialize_validators, NymConfig}; use serde::{Deserialize, Serialize}; diff --git a/clients/client-core/src/config/persistence/key_pathfinder.rs b/clients/client-core/src/config/persistence/key_pathfinder.rs index c23c30e205..d5dda75a27 100644 --- a/clients/client-core/src/config/persistence/key_pathfinder.rs +++ b/clients/client-core/src/config/persistence/key_pathfinder.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use crate::config::Config; use config::NymConfig; diff --git a/clients/client-core/src/config/persistence/mod.rs b/clients/client-core/src/config/persistence/mod.rs index b87c0be15d..f0080c1f99 100644 --- a/clients/client-core/src/config/persistence/mod.rs +++ b/clients/client-core/src/config/persistence/mod.rs @@ -1,15 +1,4 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 pub mod key_pathfinder; diff --git a/clients/native/src/client/config/mod.rs b/clients/native/src/client/config/mod.rs index e86f4aa212..a0368460db 100644 --- a/clients/native/src/client/config/mod.rs +++ b/clients/native/src/client/config/mod.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use crate::client::config::template::config_template; use client_core::config::Config as BaseConfig; diff --git a/clients/native/src/client/config/template.rs b/clients/native/src/client/config/template.rs index 99e1b867c8..2a5ed41040 100644 --- a/clients/native/src/client/config/template.rs +++ b/clients/native/src/client/config/template.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 pub(crate) fn config_template() -> &'static str { // While using normal toml marshalling would have been way simpler with less overhead, diff --git a/clients/native/src/client/mod.rs b/clients/native/src/client/mod.rs index db692e4b47..ab544acb59 100644 --- a/clients/native/src/client/mod.rs +++ b/clients/native/src/client/mod.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use crate::client::config::{Config, SocketType}; use crate::websocket; diff --git a/clients/native/src/commands/init.rs b/clients/native/src/commands/init.rs index e5d0b15f84..1f68add2d3 100644 --- a/clients/native/src/commands/init.rs +++ b/clients/native/src/commands/init.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use crate::client::config::Config; use crate::commands::override_config; diff --git a/clients/native/src/commands/mod.rs b/clients/native/src/commands/mod.rs index 22b8afb5df..7edab6ee2d 100644 --- a/clients/native/src/commands/mod.rs +++ b/clients/native/src/commands/mod.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use crate::client::config::{Config, SocketType}; use clap::ArgMatches; diff --git a/clients/native/src/commands/run.rs b/clients/native/src/commands/run.rs index 6a2c2c7574..0b315a714a 100644 --- a/clients/native/src/commands/run.rs +++ b/clients/native/src/commands/run.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use crate::client::config::Config; use crate::client::NymClient; diff --git a/clients/native/src/commands/upgrade.rs b/clients/native/src/commands/upgrade.rs index 111731cd7c..4cbcf46a7e 100644 --- a/clients/native/src/commands/upgrade.rs +++ b/clients/native/src/commands/upgrade.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use crate::client::config::{Config, MISSING_VALUE}; use clap::{App, Arg, ArgMatches}; diff --git a/clients/native/src/lib.rs b/clients/native/src/lib.rs index c38ba57566..2adec5a73d 100644 --- a/clients/native/src/lib.rs +++ b/clients/native/src/lib.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 pub mod client; pub mod websocket; diff --git a/clients/native/src/main.rs b/clients/native/src/main.rs index a59fd48239..8527347c6e 100644 --- a/clients/native/src/main.rs +++ b/clients/native/src/main.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use clap::{App, ArgMatches}; diff --git a/clients/native/src/websocket/handler.rs b/clients/native/src/websocket/handler.rs index 95dd4ee2c9..fe23a518ab 100644 --- a/clients/native/src/websocket/handler.rs +++ b/clients/native/src/websocket/handler.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use client_core::client::{ inbound_messages::{InputMessage, InputMessageSender}, diff --git a/clients/native/src/websocket/listener.rs b/clients/native/src/websocket/listener.rs index c8d2230d78..d53da380a4 100644 --- a/clients/native/src/websocket/listener.rs +++ b/clients/native/src/websocket/listener.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use super::handler::Handler; use log::*; diff --git a/clients/native/src/websocket/mod.rs b/clients/native/src/websocket/mod.rs index bff0aa245b..5469112f19 100644 --- a/clients/native/src/websocket/mod.rs +++ b/clients/native/src/websocket/mod.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 pub(crate) mod handler; pub(crate) mod listener; diff --git a/clients/native/websocket-requests/src/error.rs b/clients/native/websocket-requests/src/error.rs index 33dd2852a8..522a592da3 100644 --- a/clients/native/websocket-requests/src/error.rs +++ b/clients/native/websocket-requests/src/error.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use serde::{Deserialize, Serialize}; use std::fmt; diff --git a/clients/native/websocket-requests/src/lib.rs b/clients/native/websocket-requests/src/lib.rs index c3c719dda2..ec8228b506 100644 --- a/clients/native/websocket-requests/src/lib.rs +++ b/clients/native/websocket-requests/src/lib.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 pub mod error; pub mod requests; diff --git a/clients/native/websocket-requests/src/requests.rs b/clients/native/websocket-requests/src/requests.rs index 9a3446d63f..d84349bc68 100644 --- a/clients/native/websocket-requests/src/requests.rs +++ b/clients/native/websocket-requests/src/requests.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 // all variable size data is always prefixed with u64 length // tags are u8 diff --git a/clients/native/websocket-requests/src/responses.rs b/clients/native/websocket-requests/src/responses.rs index 473449a65f..603650f0b8 100644 --- a/clients/native/websocket-requests/src/responses.rs +++ b/clients/native/websocket-requests/src/responses.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 // all variable size data is always prefixed with u64 length // tags are u8 diff --git a/clients/native/websocket-requests/src/text.rs b/clients/native/websocket-requests/src/text.rs index d6039b5cc0..812774bd32 100644 --- a/clients/native/websocket-requests/src/text.rs +++ b/clients/native/websocket-requests/src/text.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use crate::error::ErrorKind; use crate::requests::ClientRequest; diff --git a/clients/socks5/src/client/config/mod.rs b/clients/socks5/src/client/config/mod.rs index 705c7615f8..d32a2a8b24 100644 --- a/clients/socks5/src/client/config/mod.rs +++ b/clients/socks5/src/client/config/mod.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use crate::client::config::template::config_template; use client_core::config::Config as BaseConfig; diff --git a/clients/socks5/src/client/config/template.rs b/clients/socks5/src/client/config/template.rs index 791580718a..57e2f2ae15 100644 --- a/clients/socks5/src/client/config/template.rs +++ b/clients/socks5/src/client/config/template.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 pub(crate) fn config_template() -> &'static str { // While using normal toml marshalling would have been way simpler with less overhead, diff --git a/clients/socks5/src/client/mod.rs b/clients/socks5/src/client/mod.rs index c4c83102bc..aedd6eb265 100644 --- a/clients/socks5/src/client/mod.rs +++ b/clients/socks5/src/client/mod.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use crate::client::config::Config; use crate::socks::{ diff --git a/clients/socks5/src/commands/init.rs b/clients/socks5/src/commands/init.rs index 09e446f1dc..7889dbcbf5 100644 --- a/clients/socks5/src/commands/init.rs +++ b/clients/socks5/src/commands/init.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use crate::client::config::Config; use crate::commands::override_config; diff --git a/clients/socks5/src/commands/mod.rs b/clients/socks5/src/commands/mod.rs index 683dcafe5c..88dbd40ed3 100644 --- a/clients/socks5/src/commands/mod.rs +++ b/clients/socks5/src/commands/mod.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use crate::client::config::Config; use clap::ArgMatches; diff --git a/clients/socks5/src/commands/run.rs b/clients/socks5/src/commands/run.rs index f68cff66a8..fe606a1380 100644 --- a/clients/socks5/src/commands/run.rs +++ b/clients/socks5/src/commands/run.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use crate::client::config::Config; use crate::client::NymClient; diff --git a/clients/socks5/src/commands/upgrade.rs b/clients/socks5/src/commands/upgrade.rs index 15b7c2d70c..c5924953ce 100644 --- a/clients/socks5/src/commands/upgrade.rs +++ b/clients/socks5/src/commands/upgrade.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use crate::client::config::{Config, MISSING_VALUE}; use clap::{App, Arg, ArgMatches}; diff --git a/clients/socks5/src/lib.rs b/clients/socks5/src/lib.rs index c200a3501e..2faec9d4e8 100644 --- a/clients/socks5/src/lib.rs +++ b/clients/socks5/src/lib.rs @@ -1,15 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 + pub mod client; pub mod socks; diff --git a/clients/socks5/src/main.rs b/clients/socks5/src/main.rs index a04f8ec90d..44b23b85a0 100644 --- a/clients/socks5/src/main.rs +++ b/clients/socks5/src/main.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use clap::{App, ArgMatches}; diff --git a/clients/webassembly/Cargo.toml b/clients/webassembly/Cargo.toml index 298f9176bc..3b91d195d7 100644 --- a/clients/webassembly/Cargo.toml +++ b/clients/webassembly/Cargo.toml @@ -27,8 +27,8 @@ rand = { version = "0.7.3", features = ["wasm-bindgen"] } crypto = { path = "../../common/crypto" } nymsphinx = { path = "../../common/nymsphinx" } topology = { path = "../../common/topology" } -gateway-client = { path = "../../common/client-libs/gateway-client" } -validator-client = { path = "../../common/client-libs/validator-client" } +gateway-client = { path = "../../common/client-libs/gateway-client", features = ["wasm"] } +validator-client = { path = "../../common/client-libs/validator-client", features = ["wasm"] } wasm-utils = { path = "../../common/wasm-utils" } # The `console_error_panic_hook` crate provides better debugging of panics by diff --git a/clients/webassembly/src/client/mod.rs b/clients/webassembly/src/client/mod.rs index e47943a24c..1c0f7ab0b1 100644 --- a/clients/webassembly/src/client/mod.rs +++ b/clients/webassembly/src/client/mod.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use crypto::asymmetric::{encryption, identity}; use futures::channel::mpsc; diff --git a/clients/webassembly/src/client/received_processor.rs b/clients/webassembly/src/client/received_processor.rs index 01c9b377df..a59a0dfa59 100644 --- a/clients/webassembly/src/client/received_processor.rs +++ b/clients/webassembly/src/client/received_processor.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use crypto::asymmetric::encryption; use futures::StreamExt; diff --git a/clients/webassembly/src/lib.rs b/clients/webassembly/src/lib.rs index 3c9a70fcd9..bedff27424 100644 --- a/clients/webassembly/src/lib.rs +++ b/clients/webassembly/src/lib.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use wasm_bindgen::prelude::*; diff --git a/common/client-libs/gateway-client/Cargo.toml b/common/client-libs/gateway-client/Cargo.toml index c357a9d3dc..ab30379515 100644 --- a/common/client-libs/gateway-client/Cargo.toml +++ b/common/client-libs/gateway-client/Cargo.toml @@ -32,16 +32,20 @@ version = "0.14" # wasm-only dependencies [target."cfg(target_arch = \"wasm32\")".dependencies.wasm-bindgen] +optional = true version = "0.2" [target."cfg(target_arch = \"wasm32\")".dependencies.wasm-bindgen-futures] +optional = true version = "0.4" [target."cfg(target_arch = \"wasm32\")".dependencies.wasm-utils] +optional = true path = "../../wasm-utils" # only import it in wasm. Prefer proper tokio timer in non-wasm [target."cfg(target_arch = \"wasm32\")".dependencies.wasm-timer] +optional = true version = "0.2" # this is due to tungstenite using `rand` 0.8 and associated changes in `getrandom` crate @@ -50,9 +54,14 @@ version = "0.2" # containing javascript (such as a web browser or node.js). # refer to https://docs.rs/getrandom/0.2.2/getrandom/#webassembly-support for more information [target."cfg(target_arch = \"wasm32\")".dependencies.getrandom] +optional = true version = "0.2" -features = ["js"] [dev-dependencies] # for tests #url = "2.1" + +[features] +# the reason for introducing additional features is to let cargo know we don't want anything to do with "getrandom/js" +# by default as it messes up with cyclic dependencies for ahash that's indirectly used by sqlx in validator-api +wasm = ["getrandom/js", "wasm-timer", "wasm-utils", "wasm-bindgen-futures", "wasm-bindgen"] diff --git a/common/client-libs/gateway-client/src/client.rs b/common/client-libs/gateway-client/src/client.rs index 77d7a24e34..a507db08d1 100644 --- a/common/client-libs/gateway-client/src/client.rs +++ b/common/client-libs/gateway-client/src/client.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use crate::cleanup_socket_message; use crate::error::GatewayClientError; diff --git a/common/client-libs/gateway-client/src/error.rs b/common/client-libs/gateway-client/src/error.rs index 985074228a..2f9938b57a 100644 --- a/common/client-libs/gateway-client/src/error.rs +++ b/common/client-libs/gateway-client/src/error.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use gateway_requests::registration::handshake::error::HandshakeError; use std::fmt::{self, Error, Formatter}; diff --git a/common/client-libs/gateway-client/src/lib.rs b/common/client-libs/gateway-client/src/lib.rs index 2565e964d8..f1f0987392 100644 --- a/common/client-libs/gateway-client/src/lib.rs +++ b/common/client-libs/gateway-client/src/lib.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use crate::error::GatewayClientError; pub use client::GatewayClient; diff --git a/common/client-libs/gateway-client/src/packet_router.rs b/common/client-libs/gateway-client/src/packet_router.rs index d296ff103a..8fb35aed5f 100644 --- a/common/client-libs/gateway-client/src/packet_router.rs +++ b/common/client-libs/gateway-client/src/packet_router.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 // JS: I personally don't like this name very much, but could not think of anything better. // I will gladly take any suggestions on how to rename this. diff --git a/common/client-libs/gateway-client/src/socket_state.rs b/common/client-libs/gateway-client/src/socket_state.rs index 6329f600f8..7a7a01834b 100644 --- a/common/client-libs/gateway-client/src/socket_state.rs +++ b/common/client-libs/gateway-client/src/socket_state.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use crate::cleanup_socket_message; use crate::error::GatewayClientError; diff --git a/common/client-libs/mixnet-client/src/client.rs b/common/client-libs/mixnet-client/src/client.rs index 6d82977a26..8d3d66820c 100644 --- a/common/client-libs/mixnet-client/src/client.rs +++ b/common/client-libs/mixnet-client/src/client.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use futures::channel::mpsc; use futures::StreamExt; diff --git a/common/client-libs/mixnet-client/src/forwarder.rs b/common/client-libs/mixnet-client/src/forwarder.rs index 3787f2d573..350af150b5 100644 --- a/common/client-libs/mixnet-client/src/forwarder.rs +++ b/common/client-libs/mixnet-client/src/forwarder.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use crate::client::{Client, Config}; use futures::channel::mpsc; diff --git a/common/client-libs/mixnet-client/src/lib.rs b/common/client-libs/mixnet-client/src/lib.rs index 053750615e..6836a46f12 100644 --- a/common/client-libs/mixnet-client/src/lib.rs +++ b/common/client-libs/mixnet-client/src/lib.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 pub mod client; pub mod forwarder; diff --git a/common/client-libs/validator-client/Cargo.toml b/common/client-libs/validator-client/Cargo.toml index 47b7ff7029..be7143dd6a 100644 --- a/common/client-libs/validator-client/Cargo.toml +++ b/common/client-libs/validator-client/Cargo.toml @@ -18,5 +18,11 @@ log = "0.4" url = "2" wasm-timer = "0.2" -[target.'cfg(target_env = "wasm32-unknown-unknown")'.dependencies] -getrandom = { version="0.2", features=["js"] } +[target."cfg(target_arch = \"wasm32\")".dependencies.getrandom] +version = "0.2" +optional = true + +[features] +# the reason for introducing additional features is to let cargo know we don't want anything to do with "getrandom/js" +# by default as it messes up with cyclic dependencies for ahash that's indirectly used by sqlx in validator-api +wasm = ["getrandom/js"] diff --git a/common/client-libs/validator-client/src/lib.rs b/common/client-libs/validator-client/src/lib.rs index a43324bc2b..51d32e4010 100644 --- a/common/client-libs/validator-client/src/lib.rs +++ b/common/client-libs/validator-client/src/lib.rs @@ -110,6 +110,7 @@ impl Client { let mut validator_urls = self.available_validators_rest_urls().clone(); // This will never exit + // JS: Shouldn't it have some sort of maximum attempts counter to return an error at some point? loop { validator_urls.as_mut_slice().shuffle(&mut thread_rng()); for url in validator_urls.iter() { diff --git a/common/client-libs/validator-client/src/models.rs b/common/client-libs/validator-client/src/models.rs index 9a73050a64..93b4fbacd6 100644 --- a/common/client-libs/validator-client/src/models.rs +++ b/common/client-libs/validator-client/src/models.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 use crate::error::{CodedError, SmartQueryError}; -use crate::serde_helpers::{de_i64_from_str, de_paged_query_response_from_str}; +use crate::serde_helpers::{de_i64_from_str, de_smart_query_response_from_str}; use mixnet_contract::IdentityKey; use serde::{Deserialize, Serialize}; @@ -29,7 +29,7 @@ pub(super) struct SmartQueryResult where for<'a> T: Deserialize<'a>, { - #[serde(deserialize_with = "de_paged_query_response_from_str")] + #[serde(deserialize_with = "de_smart_query_response_from_str")] pub(super) smart: T, } diff --git a/common/client-libs/validator-client/src/serde_helpers.rs b/common/client-libs/validator-client/src/serde_helpers.rs index eeda0c68c7..87c1326fb0 100644 --- a/common/client-libs/validator-client/src/serde_helpers.rs +++ b/common/client-libs/validator-client/src/serde_helpers.rs @@ -5,7 +5,7 @@ use core::str::FromStr; use serde::de::DeserializeOwned; use serde::{Deserialize, Deserializer}; -pub(super) fn de_paged_query_response_from_str<'de, D, T>(deserializer: D) -> Result +pub(super) fn de_smart_query_response_from_str<'de, D, T>(deserializer: D) -> Result where D: Deserializer<'de>, T: DeserializeOwned, diff --git a/common/crypto/src/asymmetric/encryption/mod.rs b/common/crypto/src/asymmetric/encryption/mod.rs index ba3e8d89ef..a577425888 100644 --- a/common/crypto/src/asymmetric/encryption/mod.rs +++ b/common/crypto/src/asymmetric/encryption/mod.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use pemstore::traits::{PemStorableKey, PemStorableKeyPair}; use rand::{CryptoRng, RngCore}; diff --git a/common/crypto/src/asymmetric/identity/mod.rs b/common/crypto/src/asymmetric/identity/mod.rs index ca748612d3..2a97494bb5 100644 --- a/common/crypto/src/asymmetric/identity/mod.rs +++ b/common/crypto/src/asymmetric/identity/mod.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use ed25519_dalek::ed25519::signature::Signature as SignatureTrait; pub use ed25519_dalek::SignatureError; diff --git a/common/crypto/src/asymmetric/mod.rs b/common/crypto/src/asymmetric/mod.rs index 1623a8212b..6e8836809c 100644 --- a/common/crypto/src/asymmetric/mod.rs +++ b/common/crypto/src/asymmetric/mod.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 pub mod encryption; pub mod identity; diff --git a/common/crypto/src/crypto_hash.rs b/common/crypto/src/crypto_hash.rs index 93be9906ef..4585789715 100644 --- a/common/crypto/src/crypto_hash.rs +++ b/common/crypto/src/crypto_hash.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use digest::{BlockInput, Digest, FixedOutput, Reset, Update}; use generic_array::{ArrayLength, GenericArray}; diff --git a/common/crypto/src/hkdf.rs b/common/crypto/src/hkdf.rs index 7efe8eb8c0..8791ea1bbf 100644 --- a/common/crypto/src/hkdf.rs +++ b/common/crypto/src/hkdf.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use digest::{BlockInput, FixedOutput, Reset, Update}; use generic_array::ArrayLength; diff --git a/common/crypto/src/hmac.rs b/common/crypto/src/hmac.rs index 1586a737e6..10de75d027 100644 --- a/common/crypto/src/hmac.rs +++ b/common/crypto/src/hmac.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use digest::{BlockInput, FixedOutput, Reset, Update}; use generic_array::{typenum::Unsigned, ArrayLength, GenericArray}; diff --git a/common/crypto/src/lib.rs b/common/crypto/src/lib.rs index d71db2b98f..97f90b3694 100644 --- a/common/crypto/src/lib.rs +++ b/common/crypto/src/lib.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 pub mod asymmetric; pub mod crypto_hash; diff --git a/common/crypto/src/shared_key.rs b/common/crypto/src/shared_key.rs index fa24bbf0e7..f4334e652d 100644 --- a/common/crypto/src/shared_key.rs +++ b/common/crypto/src/shared_key.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use crate::asymmetric::encryption; use crate::hkdf; diff --git a/common/crypto/src/symmetric/mod.rs b/common/crypto/src/symmetric/mod.rs index 6f1c2e086b..f61a2e5eb2 100644 --- a/common/crypto/src/symmetric/mod.rs +++ b/common/crypto/src/symmetric/mod.rs @@ -1,15 +1,4 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 pub mod stream_cipher; diff --git a/common/mixnode-common/src/cached_packet_processor/cache.rs b/common/mixnode-common/src/cached_packet_processor/cache.rs index a5feaf1be7..c55ce834af 100644 --- a/common/mixnode-common/src/cached_packet_processor/cache.rs +++ b/common/mixnode-common/src/cached_packet_processor/cache.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use dashmap::mapref::one::Ref; use dashmap::DashMap; diff --git a/common/mixnode-common/src/cached_packet_processor/error.rs b/common/mixnode-common/src/cached_packet_processor/error.rs index 9e97b7493d..4078f8a2ae 100644 --- a/common/mixnode-common/src/cached_packet_processor/error.rs +++ b/common/mixnode-common/src/cached_packet_processor/error.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use nymsphinx_acknowledgements::surb_ack::SurbAckRecoveryError; use nymsphinx_addressing::nodes::NymNodeRoutingAddressError; diff --git a/common/mixnode-common/src/cached_packet_processor/mod.rs b/common/mixnode-common/src/cached_packet_processor/mod.rs index 3bca3d7611..0d85c0954e 100644 --- a/common/mixnode-common/src/cached_packet_processor/mod.rs +++ b/common/mixnode-common/src/cached_packet_processor/mod.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 mod cache; pub mod error; diff --git a/common/mixnode-common/src/cached_packet_processor/processor.rs b/common/mixnode-common/src/cached_packet_processor/processor.rs index 068c23e7f7..d8eca98e65 100644 --- a/common/mixnode-common/src/cached_packet_processor/processor.rs +++ b/common/mixnode-common/src/cached_packet_processor/processor.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use crate::cached_packet_processor::cache::KeyCache; use crate::cached_packet_processor::error::MixProcessingError; diff --git a/common/mixnode-common/src/lib.rs b/common/mixnode-common/src/lib.rs index a7e8a54485..7aa13cc7e6 100644 --- a/common/mixnode-common/src/lib.rs +++ b/common/mixnode-common/src/lib.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 pub mod cached_packet_processor; pub mod verloc; diff --git a/common/mixnode-common/src/verloc/error.rs b/common/mixnode-common/src/verloc/error.rs index 851957a912..5e1cb460da 100644 --- a/common/mixnode-common/src/verloc/error.rs +++ b/common/mixnode-common/src/verloc/error.rs @@ -1,16 +1,5 @@ -// Copyright 2021 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use std::fmt::{self, Display, Formatter}; use std::io; diff --git a/common/mixnode-common/src/verloc/listener.rs b/common/mixnode-common/src/verloc/listener.rs index 0b8025dde7..c2522ac223 100644 --- a/common/mixnode-common/src/verloc/listener.rs +++ b/common/mixnode-common/src/verloc/listener.rs @@ -1,16 +1,5 @@ -// Copyright 2021 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use crate::verloc::error::RttError; use crate::verloc::packet::{EchoPacket, ReplyPacket}; diff --git a/common/mixnode-common/src/verloc/measurement.rs b/common/mixnode-common/src/verloc/measurement.rs index f5d2f86e55..5c23d523a5 100644 --- a/common/mixnode-common/src/verloc/measurement.rs +++ b/common/mixnode-common/src/verloc/measurement.rs @@ -1,16 +1,5 @@ -// Copyright 2021 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use crypto::asymmetric::identity; use serde::{Serialize, Serializer}; diff --git a/common/mixnode-common/src/verloc/mod.rs b/common/mixnode-common/src/verloc/mod.rs index 26c79df3b4..7daa497b25 100644 --- a/common/mixnode-common/src/verloc/mod.rs +++ b/common/mixnode-common/src/verloc/mod.rs @@ -1,16 +1,5 @@ -// Copyright 2021 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use crate::verloc::listener::PacketListener; pub use crate::verloc::measurement::{AtomicVerlocResult, Verloc, VerlocResult}; diff --git a/common/mixnode-common/src/verloc/packet.rs b/common/mixnode-common/src/verloc/packet.rs index d899273694..ad91aa7fda 100644 --- a/common/mixnode-common/src/verloc/packet.rs +++ b/common/mixnode-common/src/verloc/packet.rs @@ -1,16 +1,5 @@ -// Copyright 2021 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use crate::verloc::error::RttError; use crypto::asymmetric::identity::{self, PUBLIC_KEY_LENGTH, SIGNATURE_LENGTH}; diff --git a/common/mixnode-common/src/verloc/sender.rs b/common/mixnode-common/src/verloc/sender.rs index 2f45d99854..81fd5667d2 100644 --- a/common/mixnode-common/src/verloc/sender.rs +++ b/common/mixnode-common/src/verloc/sender.rs @@ -1,16 +1,5 @@ -// Copyright 2021 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use crate::verloc::error::RttError; use crate::verloc::measurement::Measurement; diff --git a/common/nonexhaustive-delayqueue/src/lib.rs b/common/nonexhaustive-delayqueue/src/lib.rs index 9762693120..11c1d608c3 100644 --- a/common/nonexhaustive-delayqueue/src/lib.rs +++ b/common/nonexhaustive-delayqueue/src/lib.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use std::pin::Pin; use std::task::{Context, Poll, Waker}; diff --git a/common/nymsphinx/acknowledgements/src/identifier.rs b/common/nymsphinx/acknowledgements/src/identifier.rs index dd79aa2291..54bb30d475 100644 --- a/common/nymsphinx/acknowledgements/src/identifier.rs +++ b/common/nymsphinx/acknowledgements/src/identifier.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use crate::AckKey; use crypto::generic_array::typenum::Unsigned; diff --git a/common/nymsphinx/acknowledgements/src/key.rs b/common/nymsphinx/acknowledgements/src/key.rs index bff9a3f991..9f27427137 100644 --- a/common/nymsphinx/acknowledgements/src/key.rs +++ b/common/nymsphinx/acknowledgements/src/key.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use crypto::generic_array::{typenum::Unsigned, GenericArray}; use crypto::symmetric::stream_cipher::{generate_key, Key, NewStreamCipher}; diff --git a/common/nymsphinx/acknowledgements/src/lib.rs b/common/nymsphinx/acknowledgements/src/lib.rs index 8c954c7916..490e94eaea 100644 --- a/common/nymsphinx/acknowledgements/src/lib.rs +++ b/common/nymsphinx/acknowledgements/src/lib.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 pub mod identifier; pub mod key; diff --git a/common/nymsphinx/acknowledgements/src/surb_ack.rs b/common/nymsphinx/acknowledgements/src/surb_ack.rs index d16ab1e763..4bac6cbd05 100644 --- a/common/nymsphinx/acknowledgements/src/surb_ack.rs +++ b/common/nymsphinx/acknowledgements/src/surb_ack.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use crate::identifier::prepare_identifier; use crate::AckKey; diff --git a/common/nymsphinx/addressing/src/lib.rs b/common/nymsphinx/addressing/src/lib.rs index dd2c47e8c0..d30f0bde57 100644 --- a/common/nymsphinx/addressing/src/lib.rs +++ b/common/nymsphinx/addressing/src/lib.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 pub mod clients; pub mod nodes; diff --git a/common/nymsphinx/addressing/src/nodes.rs b/common/nymsphinx/addressing/src/nodes.rs index c947b1e515..be2cf95c68 100644 --- a/common/nymsphinx/addressing/src/nodes.rs +++ b/common/nymsphinx/addressing/src/nodes.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use crypto::asymmetric::identity; use nymsphinx_types::{NodeAddressBytes, NODE_ADDRESS_LENGTH}; diff --git a/common/nymsphinx/anonymous-replies/src/encryption_key.rs b/common/nymsphinx/anonymous-replies/src/encryption_key.rs index 2d6a776bae..85520bf6c8 100644 --- a/common/nymsphinx/anonymous-replies/src/encryption_key.rs +++ b/common/nymsphinx/anonymous-replies/src/encryption_key.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 pub use crypto::generic_array::typenum::Unsigned; use crypto::{ diff --git a/common/nymsphinx/anonymous-replies/src/lib.rs b/common/nymsphinx/anonymous-replies/src/lib.rs index 5884e84136..f405c8043f 100644 --- a/common/nymsphinx/anonymous-replies/src/lib.rs +++ b/common/nymsphinx/anonymous-replies/src/lib.rs @@ -1,17 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 pub mod encryption_key; pub mod reply_surb; diff --git a/common/nymsphinx/anonymous-replies/src/reply_surb.rs b/common/nymsphinx/anonymous-replies/src/reply_surb.rs index 3f2a581105..32cb6cb84e 100644 --- a/common/nymsphinx/anonymous-replies/src/reply_surb.rs +++ b/common/nymsphinx/anonymous-replies/src/reply_surb.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use crate::encryption_key::{ SurbEncryptionKey, SurbEncryptionKeyError, SurbEncryptionKeySize, Unsigned, diff --git a/common/nymsphinx/chunking/src/fragment.rs b/common/nymsphinx/chunking/src/fragment.rs index d0f2a5d1e0..69a5042af6 100644 --- a/common/nymsphinx/chunking/src/fragment.rs +++ b/common/nymsphinx/chunking/src/fragment.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use crate::set::generate_set_id; use crate::ChunkingError; diff --git a/common/nymsphinx/chunking/src/lib.rs b/common/nymsphinx/chunking/src/lib.rs index 02a452ba55..1edad6fd0f 100644 --- a/common/nymsphinx/chunking/src/lib.rs +++ b/common/nymsphinx/chunking/src/lib.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use crate::fragment::{linked_fragment_payload_max_len, unlinked_fragment_payload_max_len}; pub use set::split_into_sets; diff --git a/common/nymsphinx/chunking/src/reconstruction.rs b/common/nymsphinx/chunking/src/reconstruction.rs index a98b49ed01..9901cfa055 100644 --- a/common/nymsphinx/chunking/src/reconstruction.rs +++ b/common/nymsphinx/chunking/src/reconstruction.rs @@ -1,17 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use crate::fragment::Fragment; use crate::ChunkingError; use log::*; diff --git a/common/nymsphinx/chunking/src/set.rs b/common/nymsphinx/chunking/src/set.rs index 2bdedb51a0..c8710a63b8 100644 --- a/common/nymsphinx/chunking/src/set.rs +++ b/common/nymsphinx/chunking/src/set.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use crate::fragment::{ linked_fragment_payload_max_len, unlinked_fragment_payload_max_len, Fragment, diff --git a/common/nymsphinx/cover/src/lib.rs b/common/nymsphinx/cover/src/lib.rs index 5da4e3ec19..5a6cce9212 100644 --- a/common/nymsphinx/cover/src/lib.rs +++ b/common/nymsphinx/cover/src/lib.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use crypto::shared_key::new_ephemeral_shared_key; use crypto::symmetric::stream_cipher; diff --git a/common/nymsphinx/forwarding/src/lib.rs b/common/nymsphinx/forwarding/src/lib.rs index f85c8e9362..9c22601490 100644 --- a/common/nymsphinx/forwarding/src/lib.rs +++ b/common/nymsphinx/forwarding/src/lib.rs @@ -1,15 +1,4 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 pub mod packet; diff --git a/common/nymsphinx/forwarding/src/packet.rs b/common/nymsphinx/forwarding/src/packet.rs index e1defeff94..86cb7871fe 100644 --- a/common/nymsphinx/forwarding/src/packet.rs +++ b/common/nymsphinx/forwarding/src/packet.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use nymsphinx_addressing::nodes::{NymNodeRoutingAddress, NymNodeRoutingAddressError}; use nymsphinx_params::{PacketMode, PacketSize}; diff --git a/common/nymsphinx/framing/src/codec.rs b/common/nymsphinx/framing/src/codec.rs index 58e351ba0a..f03280091d 100644 --- a/common/nymsphinx/framing/src/codec.rs +++ b/common/nymsphinx/framing/src/codec.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use crate::packet::{FramedSphinxPacket, Header}; use bytes::{Buf, BufMut, BytesMut}; diff --git a/common/nymsphinx/framing/src/lib.rs b/common/nymsphinx/framing/src/lib.rs index 4215f88801..6c3fe39018 100644 --- a/common/nymsphinx/framing/src/lib.rs +++ b/common/nymsphinx/framing/src/lib.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 pub mod codec; pub mod packet; diff --git a/common/nymsphinx/framing/src/packet.rs b/common/nymsphinx/framing/src/packet.rs index 9467f81b8a..f1db17b91c 100644 --- a/common/nymsphinx/framing/src/packet.rs +++ b/common/nymsphinx/framing/src/packet.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use crate::codec::SphinxCodecError; use bytes::{BufMut, BytesMut}; diff --git a/common/nymsphinx/params/src/lib.rs b/common/nymsphinx/params/src/lib.rs index 0b3f325114..ba230827c0 100644 --- a/common/nymsphinx/params/src/lib.rs +++ b/common/nymsphinx/params/src/lib.rs @@ -1,16 +1,6 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 + use crypto::aes_ctr::Aes128Ctr; use crypto::blake3; diff --git a/common/nymsphinx/params/src/packet_modes.rs b/common/nymsphinx/params/src/packet_modes.rs index b401173600..bc634647ed 100644 --- a/common/nymsphinx/params/src/packet_modes.rs +++ b/common/nymsphinx/params/src/packet_modes.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use std::convert::TryFrom; diff --git a/common/nymsphinx/params/src/packet_sizes.rs b/common/nymsphinx/params/src/packet_sizes.rs index e00a54bb2b..2d28014409 100644 --- a/common/nymsphinx/params/src/packet_sizes.rs +++ b/common/nymsphinx/params/src/packet_sizes.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use crate::FRAG_ID_LEN; use nymsphinx_types::header::HEADER_SIZE; diff --git a/common/nymsphinx/src/lib.rs b/common/nymsphinx/src/lib.rs index 89300a7ca1..e3e7c51fac 100644 --- a/common/nymsphinx/src/lib.rs +++ b/common/nymsphinx/src/lib.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 pub mod preparer; pub mod receiver; diff --git a/common/nymsphinx/src/preparer/mod.rs b/common/nymsphinx/src/preparer/mod.rs index ab2bcfbebe..250f109dc2 100644 --- a/common/nymsphinx/src/preparer/mod.rs +++ b/common/nymsphinx/src/preparer/mod.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use self::vpn_manager::VpnManager; use crate::chunking; diff --git a/common/nymsphinx/src/preparer/vpn_manager.rs b/common/nymsphinx/src/preparer/vpn_manager.rs index e349891d00..06a6e11c28 100644 --- a/common/nymsphinx/src/preparer/vpn_manager.rs +++ b/common/nymsphinx/src/preparer/vpn_manager.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use nymsphinx_types::EphemeralSecret; use rand::{CryptoRng, Rng}; diff --git a/common/nymsphinx/src/receiver.rs b/common/nymsphinx/src/receiver.rs index d5be0e704d..01f308ac75 100644 --- a/common/nymsphinx/src/receiver.rs +++ b/common/nymsphinx/src/receiver.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use crypto::asymmetric::encryption; use crypto::shared_key::recompute_shared_key; diff --git a/common/nymsphinx/src/utils/mod.rs b/common/nymsphinx/src/utils/mod.rs index b3baf8710b..aa5d71f9b0 100644 --- a/common/nymsphinx/src/utils/mod.rs +++ b/common/nymsphinx/src/utils/mod.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use rand::Rng; use rand_distr::{Distribution, Exp}; diff --git a/common/nymsphinx/types/src/lib.rs b/common/nymsphinx/types/src/lib.rs index 06a52d38c4..d3f8d629e4 100644 --- a/common/nymsphinx/types/src/lib.rs +++ b/common/nymsphinx/types/src/lib.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 // re-exporting types and constants available in sphinx pub use sphinx::{ diff --git a/common/pemstore/src/lib.rs b/common/pemstore/src/lib.rs index 5f74af58ad..25e45d33f7 100644 --- a/common/pemstore/src/lib.rs +++ b/common/pemstore/src/lib.rs @@ -1,16 +1,6 @@ -// Copyright 2021 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 + use crate::traits::{PemStorableKey, PemStorableKeyPair}; use pem::{self, Pem}; use std::fs::File; diff --git a/common/pemstore/src/traits.rs b/common/pemstore/src/traits.rs index c796c6151d..436289b1e4 100644 --- a/common/pemstore/src/traits.rs +++ b/common/pemstore/src/traits.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 pub trait PemStorableKey: Sized { type Error: std::error::Error; diff --git a/common/socks5/proxy-helpers/src/available_reader.rs b/common/socks5/proxy-helpers/src/available_reader.rs index c4f6b6eac3..a897360ebe 100644 --- a/common/socks5/proxy-helpers/src/available_reader.rs +++ b/common/socks5/proxy-helpers/src/available_reader.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use bytes::{BufMut, Bytes, BytesMut}; use futures::Stream; diff --git a/common/socks5/proxy-helpers/src/connection_controller.rs b/common/socks5/proxy-helpers/src/connection_controller.rs index bcff242a84..03f3d4b5cc 100644 --- a/common/socks5/proxy-helpers/src/connection_controller.rs +++ b/common/socks5/proxy-helpers/src/connection_controller.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use futures::channel::mpsc; use futures::StreamExt; diff --git a/common/socks5/proxy-helpers/src/lib.rs b/common/socks5/proxy-helpers/src/lib.rs index 0141322047..cce784c4da 100644 --- a/common/socks5/proxy-helpers/src/lib.rs +++ b/common/socks5/proxy-helpers/src/lib.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 pub mod available_reader; pub mod connection_controller; diff --git a/common/socks5/proxy-helpers/src/proxy_runner/inbound.rs b/common/socks5/proxy-helpers/src/proxy_runner/inbound.rs index 59c5a52468..979ae918c4 100644 --- a/common/socks5/proxy-helpers/src/proxy_runner/inbound.rs +++ b/common/socks5/proxy-helpers/src/proxy_runner/inbound.rs @@ -1,16 +1,5 @@ -// Copyright 2021 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use super::MixProxySender; use super::SHUTDOWN_TIMEOUT; diff --git a/common/socks5/proxy-helpers/src/proxy_runner/mod.rs b/common/socks5/proxy-helpers/src/proxy_runner/mod.rs index d47d3a0e53..d31ef8ced7 100644 --- a/common/socks5/proxy-helpers/src/proxy_runner/mod.rs +++ b/common/socks5/proxy-helpers/src/proxy_runner/mod.rs @@ -1,16 +1,5 @@ -// Copyright 2021 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use crate::connection_controller::ConnectionReceiver; use futures::channel::mpsc; diff --git a/common/socks5/proxy-helpers/src/proxy_runner/outbound.rs b/common/socks5/proxy-helpers/src/proxy_runner/outbound.rs index c196d82b9a..111bc6bf9e 100644 --- a/common/socks5/proxy-helpers/src/proxy_runner/outbound.rs +++ b/common/socks5/proxy-helpers/src/proxy_runner/outbound.rs @@ -1,16 +1,5 @@ -// Copyright 2021 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use super::SHUTDOWN_TIMEOUT; use crate::connection_controller::{ConnectionMessage, ConnectionReceiver}; diff --git a/common/topology/src/filter.rs b/common/topology/src/filter.rs index d54b80e99f..652b5f92e9 100644 --- a/common/topology/src/filter.rs +++ b/common/topology/src/filter.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use std::collections::HashMap; use std::hash::Hash; diff --git a/common/topology/src/gateway.rs b/common/topology/src/gateway.rs index 388b77195d..45fb7b0dfd 100644 --- a/common/topology/src/gateway.rs +++ b/common/topology/src/gateway.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use crate::{filter, NetworkAddress}; use crypto::asymmetric::{encryption, identity}; diff --git a/common/topology/src/lib.rs b/common/topology/src/lib.rs index 4827c597b6..eb32901f18 100644 --- a/common/topology/src/lib.rs +++ b/common/topology/src/lib.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use crate::filter::VersionFilterable; use log::warn; diff --git a/common/topology/src/mix.rs b/common/topology/src/mix.rs index 7f78e0bc73..cced6c3d70 100644 --- a/common/topology/src/mix.rs +++ b/common/topology/src/mix.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use crate::{filter, NetworkAddress}; use crypto::asymmetric::{encryption, identity}; diff --git a/common/version-checker/src/lib.rs b/common/version-checker/src/lib.rs index 46aafc2c80..a3968d610c 100644 --- a/common/version-checker/src/lib.rs +++ b/common/version-checker/src/lib.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use semver::SemVerError; pub use semver::Version; diff --git a/common/wasm-utils/src/lib.rs b/common/wasm-utils/src/lib.rs index 6ba4241b23..94b8faae05 100644 --- a/common/wasm-utils/src/lib.rs +++ b/common/wasm-utils/src/lib.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use js_sys::Promise; use wasm_bindgen::prelude::*; diff --git a/common/wasm-utils/src/websocket/mod.rs b/common/wasm-utils/src/websocket/mod.rs index 7d4117c92c..08e16217f5 100644 --- a/common/wasm-utils/src/websocket/mod.rs +++ b/common/wasm-utils/src/websocket/mod.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use crate::websocket::state::State; use crate::{console_error, console_log}; diff --git a/common/wasm-utils/src/websocket/state.rs b/common/wasm-utils/src/websocket/state.rs index 60072040a4..d9f0f15f76 100644 --- a/common/wasm-utils/src/websocket/state.rs +++ b/common/wasm-utils/src/websocket/state.rs @@ -1,16 +1,5 @@ -// Copyright 2020 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use web_sys::WebSocket; diff --git a/contracts/mixnet/src/contract.rs b/contracts/mixnet/src/contract.rs index 5a4c8655e8..58ce4ff41a 100644 --- a/contracts/mixnet/src/contract.rs +++ b/contracts/mixnet/src/contract.rs @@ -22,7 +22,7 @@ pub const INITIAL_GATEWAY_BOND_REWARD_RATE: u64 = 110; pub const INITIAL_MIXNODE_ACTIVE_SET_SIZE: u32 = 100; -const NETWORK_MONITOR_ADDRESS: &str = "hal1v9qauwdq5terag6uvfsdytcs2d0sdmfdq6e83g"; +const NETWORK_MONITOR_ADDRESS: &str = "punk1v9qauwdq5terag6uvfsdytcs2d0sdmfdy7hgk3"; /// Constant specifying denomination of the coin used for bonding pub const DENOM: &str = "upunk"; diff --git a/contracts/mixnet/src/helpers.rs b/contracts/mixnet/src/helpers.rs index cfac69dacb..25c5896f80 100644 --- a/contracts/mixnet/src/helpers.rs +++ b/contracts/mixnet/src/helpers.rs @@ -1,16 +1,5 @@ -// Copyright 2021 Nym Technologies SA -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 use crate::error::ContractError; use cosmwasm_std::{Decimal, Uint128}; diff --git a/validator-api/Cargo.lock b/validator-api/Cargo.lock new file mode 100644 index 0000000000..ccf826a987 --- /dev/null +++ b/validator-api/Cargo.lock @@ -0,0 +1,3710 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "aes-ctr" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2e5b0458ea3beae0d1d8c0f3946564f8e10f90646cf78c06b4351052058d1ee" +dependencies = [ + "aes-soft 0.3.3", + "aesni 0.6.0", + "ctr 0.3.2", + "stream-cipher", +] + +[[package]] +name = "aes-ctr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7729c3cde54d67063be556aeac75a81330d802f0259500ca40cb52967f975763" +dependencies = [ + "aes-soft 0.6.4", + "aesni 0.10.0", + "cipher", + "ctr 0.6.0", +] + +[[package]] +name = "aes-soft" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfd7e7ae3f9a1fb5c03b389fc6bb9a51400d0c13053f0dca698c832bfd893a0d" +dependencies = [ + "block-cipher-trait", + "byteorder", + "opaque-debug 0.2.3", +] + +[[package]] +name = "aes-soft" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be14c7498ea50828a38d0e24a765ed2effe92a705885b57d029cd67d45744072" +dependencies = [ + "cipher", + "opaque-debug 0.3.0", +] + +[[package]] +name = "aesni" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f70a6b5f971e473091ab7cfb5ffac6cde81666c4556751d8d5620ead8abf100" +dependencies = [ + "block-cipher-trait", + "opaque-debug 0.2.3", + "stream-cipher", +] + +[[package]] +name = "aesni" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea2e11f5e94c2f7d386164cc2aa1f97823fed6f259e486940a71c174dd01b0ce" +dependencies = [ + "cipher", + "opaque-debug 0.3.0", +] + +[[package]] +name = "ahash" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43bb833f0bf979d8475d38fbf09ed3b8a55e1885fe93ad3f93239fc6a4f17b98" +dependencies = [ + "getrandom 0.2.3", + "once_cell", + "version_check", +] + +[[package]] +name = "aho-corasick" +version = "0.7.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" +dependencies = [ + "memchr", +] + +[[package]] +name = "ansi_term" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" +dependencies = [ + "winapi", +] + +[[package]] +name = "anyhow" +version = "1.0.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15af2628f6890fe2609a3b91bef4c83450512802e59489f9c1cb1fa5df064a61" + +[[package]] +name = "arrayref" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" + +[[package]] +name = "arrayvec" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" + +[[package]] +name = "async-stream" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "171374e7e3b2504e0e5236e3b59260560f9fe94bfe9ac39ba5e4e929c5590625" +dependencies = [ + "async-stream-impl", + "futures-core", +] + +[[package]] +name = "async-stream-impl" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "648ed8c8d2ce5409ccd57453d9d1b214b342a0d69376a6feda1fd6cae3299308" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "async-trait" +version = "0.1.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b98e84bbb4cbcdd97da190ba0c58a1bb0de2c1fdf67d159e192ed766aeca722" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "atoi" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "616896e05fc0e2649463a93a15183c6a16bf03413a7af88ef1285ddedfa9cda5" +dependencies = [ + "num-traits", +] + +[[package]] +name = "atomic" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3410529e8288c463bedb5930f82833bc0c90e5d2fe639a56582a4d09220b281" +dependencies = [ + "autocfg", +] + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi", + "libc", + "winapi", +] + +[[package]] +name = "autocfg" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" + +[[package]] +name = "base-x" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4521f3e3d031370679b3b140beb36dfe4801b09ac77e30c61941f97df3ef28b" + +[[package]] +name = "base64" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" + +[[package]] +name = "binascii" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "383d29d513d8764dcdc42ea295d979eb99c3c9f00607b3692cf68a431f7dca72" + +[[package]] +name = "bitflags" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" + +[[package]] +name = "bitvec" +version = "0.18.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98fcd36dda4e17b7d7abc64cb549bf0201f4ab71e00700c798ca7e62ed3761fa" +dependencies = [ + "funty", + "radium 0.3.0", + "wyz", +] + +[[package]] +name = "bitvec" +version = "0.19.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8942c8d352ae1838c9dda0b0ca2ab657696ef2232a20147cf1b30ae1a9cb4321" +dependencies = [ + "funty", + "radium 0.5.3", + "tap", + "wyz", +] + +[[package]] +name = "blake2" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94cb07b0da6a73955f8fb85d24c466778e70cda767a568229b104f0264089330" +dependencies = [ + "byte-tools", + "crypto-mac 0.7.0", + "digest 0.8.1", + "opaque-debug 0.2.3", +] + +[[package]] +name = "blake3" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b64485778c4f16a6a5a9d335e80d449ac6c70cdd6a06d2af18a6f6f775a125b3" +dependencies = [ + "arrayref", + "arrayvec", + "cc", + "cfg-if 0.1.10", + "constant_time_eq", + "crypto-mac 0.8.0", + "digest 0.9.0", +] + +[[package]] +name = "block-buffer" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" +dependencies = [ + "block-padding", + "byte-tools", + "byteorder", + "generic-array 0.12.4", +] + +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array 0.14.4", +] + +[[package]] +name = "block-cipher-trait" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c924d49bd09e7c06003acda26cd9742e796e34282ec6c1189404dee0c1f4774" +dependencies = [ + "generic-array 0.12.4", +] + +[[package]] +name = "block-padding" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" +dependencies = [ + "byte-tools", +] + +[[package]] +name = "bs58" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "476e9cd489f9e121e02ffa6014a8ef220ecb15c05ed23fc34cca13925dc283fb" + +[[package]] +name = "bs58" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" + +[[package]] +name = "build_const" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4ae4235e6dac0694637c763029ecea1a2ec9e4e06ec2729bd21ba4d9c863eb7" + +[[package]] +name = "bumpalo" +version = "3.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c59e7af012c713f529e7a3ee57ce9b31ddd858d4b512923602f74608b009631" + +[[package]] +name = "byte-tools" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" + +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + +[[package]] +name = "bytes" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b700ce4376041dcd0a327fd0097c41095743c4c8af8887265942faf1100bd040" + +[[package]] +name = "cc" +version = "1.0.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a72c244c1ff497a746a7e1fb3d14bd08420ecda70c8f25c7112f2781652d787" + +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "chacha" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddf3c081b5fba1e5615640aae998e0fbd10c24cbd897ee39ed754a77601a4862" +dependencies = [ + "byteorder", + "keystream", +] + +[[package]] +name = "cipher" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12f8e7987cbd042a63249497f41aed09f8e65add917ea6566effbc56578d6801" +dependencies = [ + "generic-array 0.14.4", +] + +[[package]] +name = "clap" +version = "2.33.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" +dependencies = [ + "ansi_term", + "atty", + "bitflags", + "strsim", + "textwrap", + "unicode-width", + "vec_map", +] + +[[package]] +name = "config" +version = "0.1.0" +dependencies = [ + "handlebars", + "humantime-serde", + "serde", + "toml", +] + +[[package]] +name = "const-oid" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f6b64db6932c7e49332728e3a6bd82c6b7e16016607d20923b537c3bc4c0d5f" + +[[package]] +name = "const_fn" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f92cfa0fd5690b3cf8c1ef2cabbd9b7ef22fa53cf5e1f92b05103f6d5d1cf6e7" + +[[package]] +name = "constant_time_eq" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" + +[[package]] +name = "convert_case" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" + +[[package]] +name = "cookie" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffdf8865bac3d9a3bde5bde9088ca431b11f5d37c7a578b8086af77248b76627" +dependencies = [ + "percent-encoding", + "time", + "version_check", +] + +[[package]] +name = "core-foundation" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a89e2ae426ea83155dccf10c0fa6b1463ef6d5fcb44cee0b224a408fa640a62" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea221b5284a47e40033bf9b66f35f984ec0ea2931eb03505246cd27a963f981b" + +[[package]] +name = "cosmwasm-crypto" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "038089cdadfe61e4e85617d91cecec2c49f828db8e5986bb85e29d0b29c59b77" +dependencies = [ + "digest 0.9.0", + "ed25519-zebra", + "k256", + "rand_core 0.5.1", + "thiserror", +] + +[[package]] +name = "cosmwasm-derive" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "628bf3da935843795a7f52678262ef06398878b0cf4c89b69612d8525ea27b84" +dependencies = [ + "syn", +] + +[[package]] +name = "cosmwasm-std" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22de097cf4f7e7f575f51a22de7260932756ccfe499e005f98244a3043470e48" +dependencies = [ + "base64", + "cosmwasm-crypto", + "cosmwasm-derive", + "schemars", + "serde", + "serde-json-wasm", + "thiserror", + "uint", +] + +[[package]] +name = "cpufeatures" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66c99696f6c9dd7f35d486b9d04d7e6e202aa3e8c40d553f2fdf5e7e0c6a71ef" +dependencies = [ + "libc", +] + +[[package]] +name = "crc" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d663548de7f5cca343f1e0a48d14dcfb0e9eb4e079ec58883b7251539fa10aeb" +dependencies = [ + "build_const", +] + +[[package]] +name = "crossbeam-channel" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4" +dependencies = [ + "cfg-if 1.0.0", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-queue" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b10ddc024425c88c2ad148c1b0fd53f4c6d38db9697c9f1588381212fa657c9" +dependencies = [ + "cfg-if 1.0.0", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d82cfc11ce7f2c3faef78d8a684447b40d503d9681acebed6cb728d45940c4db" +dependencies = [ + "cfg-if 1.0.0", + "lazy_static", +] + +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + +[[package]] +name = "crypto" +version = "0.1.0" +dependencies = [ + "aes-ctr 0.6.0", + "blake3", + "bs58 0.4.0", + "cipher", + "digest 0.9.0", + "ed25519-dalek", + "generic-array 0.14.4", + "hkdf 0.10.0", + "hmac 0.8.1", + "log", + "nymsphinx-types", + "pemstore", + "rand 0.7.3", + "x25519-dalek", +] + +[[package]] +name = "crypto-mac" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4434400df11d95d556bac068ddfedd482915eb18fe8bea89bc80b6e4b1c179e5" +dependencies = [ + "generic-array 0.12.4", + "subtle 1.0.0", +] + +[[package]] +name = "crypto-mac" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" +dependencies = [ + "generic-array 0.14.4", + "subtle 2.4.0", +] + +[[package]] +name = "crypto-mac" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4857fd85a0c34b3c3297875b747c1e02e06b6a0ea32dd892d8192b9ce0813ea6" +dependencies = [ + "generic-array 0.14.4", + "subtle 2.4.0", +] + +[[package]] +name = "ctr" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "022cd691704491df67d25d006fe8eca083098253c4d43516c2206479c58c6736" +dependencies = [ + "block-cipher-trait", + "stream-cipher", +] + +[[package]] +name = "ctr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb4a30d54f7443bf3d6191dcd486aca19e67cb3c49fa7a06a319966346707e7f" +dependencies = [ + "cipher", +] + +[[package]] +name = "curve25519-dalek" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "639891fde0dbea823fc3d798a0fdf9d2f9440a42d64a78ab3488b0ca025117b3" +dependencies = [ + "byteorder", + "digest 0.9.0", + "rand_core 0.5.1", + "subtle 2.4.0", + "zeroize", +] + +[[package]] +name = "der" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51f59c66c30bb7445c8320a5f9233e437e3572368099f25532a59054328899b4" +dependencies = [ + "const-oid", +] + +[[package]] +name = "derive_more" +version = "0.99.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cc7b9cef1e351660e5443924e4f43ab25fbbed3e9a5f052df3677deb4d6b320" +dependencies = [ + "convert_case", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "devise" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "411cf45ac38f00df3679689616649dc12607b846db171780bb790b514a042832" +dependencies = [ + "devise_codegen", + "devise_core", +] + +[[package]] +name = "devise_codegen" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2cf7081f06822f1787e29359354426132cf832cc977d7a8ff747848631462ad1" +dependencies = [ + "devise_core", + "quote", +] + +[[package]] +name = "devise_core" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80c23631758736875d7ce08f847f296b4001b72cf90878e85b47df7ac5442147" +dependencies = [ + "bitflags", + "proc-macro2", + "proc-macro2-diagnostics", + "quote", + "syn", +] + +[[package]] +name = "digest" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" +dependencies = [ + "generic-array 0.12.4", +] + +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array 0.14.4", +] + +[[package]] +name = "dirs" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30baa043103c9d0c2a57cf537cc2f35623889dc0d405e6c3cccfadbc81c71309" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03d86534ed367a67548dc68113a0f5db55432fdfbb6e6f9d77704397d95d5780" +dependencies = [ + "libc", + "redox_users", + "winapi", +] + +[[package]] +name = "discard" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0" + +[[package]] +name = "dotenv" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f" + +[[package]] +name = "dyn-clone" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee2626afccd7561a06cf1367e2950c4718ea04565e20fb5029b6c7d8ad09abcf" + +[[package]] +name = "ecdsa" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41fbdb4ff710acb4db8ca29f93b897529ea6d6a45626d5183b47e012aa6ae7e4" +dependencies = [ + "elliptic-curve", + "hmac 0.10.1", + "signature", +] + +[[package]] +name = "ed25519" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d0860415b12243916284c67a9be413e044ee6668247b99ba26d94b2bc06c8f6" +dependencies = [ + "signature", +] + +[[package]] +name = "ed25519-dalek" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" +dependencies = [ + "curve25519-dalek", + "ed25519", + "rand 0.7.3", + "serde", + "sha2 0.9.5", + "zeroize", +] + +[[package]] +name = "ed25519-zebra" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a128b76af6dd4b427e34a6fd43dc78dbfe73672ec41ff615a2414c1a0ad0409" +dependencies = [ + "curve25519-dalek", + "hex", + "rand_core 0.5.1", + "serde", + "sha2 0.9.5", + "thiserror", +] + +[[package]] +name = "either" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" +dependencies = [ + "serde", +] + +[[package]] +name = "elliptic-curve" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2db227e61a43a34915680bdda462ec0e212095518020a88a1f91acd16092c39" +dependencies = [ + "bitvec 0.18.5", + "digest 0.9.0", + "ff", + "funty", + "generic-array 0.14.4", + "group", + "pkcs8", + "rand_core 0.5.1", + "subtle 2.4.0", + "zeroize", +] + +[[package]] +name = "encoding_rs" +version = "0.8.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80df024fbc5ac80f87dfef0d9f5209a252f2a497f7f42944cff24d8253cac065" +dependencies = [ + "cfg-if 1.0.0", +] + +[[package]] +name = "env_logger" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" +dependencies = [ + "atty", + "humantime 1.3.0", + "log", + "regex", + "termcolor", +] + +[[package]] +name = "fake-simd" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" + +[[package]] +name = "ff" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01646e077d4ebda82b73f1bca002ea1e91561a77df2431a9e79729bcc31950ef" +dependencies = [ + "bitvec 0.18.5", + "rand_core 0.5.1", + "subtle 2.4.0", +] + +[[package]] +name = "figment" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "790b4292c72618abbab50f787a477014fe15634f96291de45672ce46afe122df" +dependencies = [ + "atomic", + "pear", + "serde", + "toml", + "uncased", + "version_check", +] + +[[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 = "form_urlencoded" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" +dependencies = [ + "matches", + "percent-encoding", +] + +[[package]] +name = "funty" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7" + +[[package]] +name = "futures" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e7e43a803dae2fa37c1f6a8fe121e1f7bf9548b4dfc0522a42f34145dadfc27" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e682a68b29a882df0545c143dc3646daefe80ba479bcdede94d5a703de2871e2" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0402f765d8a89a26043b889b26ce3c4679d268fa6bb22cd7c6aad98340e179d1" + +[[package]] +name = "futures-executor" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "badaa6a909fac9e7236d0620a2f57f7664640c56575b71a7552fbd68deafab79" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acc499defb3b348f8d8f3f66415835a9131856ff7714bf10dadfc4ec4bdb29a1" + +[[package]] +name = "futures-macro" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4c40298486cdf52cc00cd6d6987892ba502c7656a16a4192a9992b1ccedd121" +dependencies = [ + "autocfg", + "proc-macro-hack", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "futures-sink" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a57bead0ceff0d6dde8f465ecd96c9338121bb7717d3e7b108059531870c4282" + +[[package]] +name = "futures-task" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a16bef9fc1a4dddb5bee51c989e3fbba26569cbb0e31f5b303c184e3dd33dae" + +[[package]] +name = "futures-util" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "feb5c238d27e2bf94ffdfd27b2c29e3df4a68c4193bb6427384259e2bf191967" +dependencies = [ + "autocfg", + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "proc-macro-hack", + "proc-macro-nested", + "slab", +] + +[[package]] +name = "gateway-client" +version = "0.1.0" +dependencies = [ + "crypto", + "futures", + "gateway-requests", + "log", + "nymsphinx", + "rand 0.7.3", + "tokio", + "tokio-tungstenite", + "tungstenite", +] + +[[package]] +name = "gateway-requests" +version = "0.1.0" +dependencies = [ + "bs58 0.3.1", + "crypto", + "futures", + "log", + "nymsphinx", + "pemstore", + "rand 0.7.3", + "serde", + "serde_json", + "tungstenite", +] + +[[package]] +name = "generator" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1d9279ca822891c1a4dae06d185612cf8fc6acfe5dff37781b41297811b12ee" +dependencies = [ + "cc", + "libc", + "log", + "rustversion", + "winapi", +] + +[[package]] +name = "generic-array" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" +dependencies = [ + "typenum", +] + +[[package]] +name = "generic-array" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +dependencies = [ + "cfg-if 1.0.0", + "js-sys", + "libc", + "wasi 0.9.0+wasi-snapshot-preview1", + "wasm-bindgen", +] + +[[package]] +name = "getrandom" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "wasi 0.10.2+wasi-snapshot-preview1", +] + +[[package]] +name = "glob" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" + +[[package]] +name = "group" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc11f9f5fbf1943b48ae7c2bf6846e7d827a512d1be4f23af708f5ca5d01dde1" +dependencies = [ + "ff", + "rand_core 0.5.1", + "subtle 2.4.0", +] + +[[package]] +name = "h2" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "825343c4eef0b63f541f8903f395dc5beb362a979b5799a84062527ef1e37726" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "handlebars" +version = "3.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4498fc115fa7d34de968184e473529abb40eeb6be8bc5f7faba3d08c316cb3e3" +dependencies = [ + "log", + "pest", + "pest_derive", + "quick-error 2.0.1", + "serde", + "serde_json", +] + +[[package]] +name = "hashbrown" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" +dependencies = [ + "ahash", +] + +[[package]] +name = "hashlink" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7249a3129cbc1ffccd74857f81464a323a152173cdb134e0fd81bc803b29facf" +dependencies = [ + "hashbrown", +] + +[[package]] +name = "heck" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hkdf" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fa08a006102488bd9cd5b8013aabe84955cf5ae22e304c2caf655b633aefae3" +dependencies = [ + "digest 0.8.1", + "hmac 0.7.1", +] + +[[package]] +name = "hkdf" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51ab2f639c231793c5f6114bdb9bbe50a7dbbfcd7c7c6bd8475dec2d991e964f" +dependencies = [ + "digest 0.9.0", + "hmac 0.10.1", +] + +[[package]] +name = "hmac" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dcb5e64cda4c23119ab41ba960d1e170a774c8e4b9d9e6a9bc18aabf5e59695" +dependencies = [ + "crypto-mac 0.7.0", + "digest 0.8.1", +] + +[[package]] +name = "hmac" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "126888268dcc288495a26bf004b38c5fdbb31682f992c84ceb046a1f0fe38840" +dependencies = [ + "crypto-mac 0.8.0", + "digest 0.9.0", +] + +[[package]] +name = "hmac" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1441c6b1e930e2817404b5046f1f989899143a12bf92de603b69f4e0aee1e15" +dependencies = [ + "crypto-mac 0.10.0", + "digest 0.9.0", +] + +[[package]] +name = "http" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "527e8c9ac747e28542699a951517aa9a6945af506cd1f2e1b53a576c17b6cc11" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60daa14be0e0786db0f03a9e57cb404c9d756eed2b6c62b9ea98ec5743ec75a9" +dependencies = [ + "bytes", + "http", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3a87b616e37e93c22fb19bcd386f02f3af5ea98a25670ad0fce773de23c5e68" + +[[package]] +name = "httpdate" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6456b8a6c8f33fee7d958fcd1b60d55b11940a79e63ae87013e6d22e26034440" + +[[package]] +name = "humantime" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" +dependencies = [ + "quick-error 1.2.3", +] + +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + +[[package]] +name = "humantime-serde" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac34a56cfd4acddb469cc7fff187ed5ac36f498ba085caf8bbc725e3ff474058" +dependencies = [ + "humantime 2.1.0", + "serde", +] + +[[package]] +name = "hyper" +version = "0.14.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07d6baa1b441335f3ce5098ac421fb6547c46dda735ca1bc6d0153c838f9dd83" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "hyper-tls" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +dependencies = [ + "bytes", + "hyper", + "native-tls", + "tokio", + "tokio-native-tls", +] + +[[package]] +name = "idna" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" +dependencies = [ + "matches", + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "indexmap" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5" +dependencies = [ + "autocfg", + "hashbrown", + "serde", +] + +[[package]] +name = "inlinable_string" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3094308123a0e9fd59659ce45e22de9f53fc1d2ac6e1feb9fef988e4f76cad77" + +[[package]] +name = "input_buffer" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f97967975f448f1a7ddb12b0bc41069d09ed6a1c161a92687e057325db35d413" +dependencies = [ + "bytes", +] + +[[package]] +name = "instant" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61124eeebbd69b8190558df225adf7e4caafce0d743919e5d6b19652314ec5ec" +dependencies = [ + "cfg-if 1.0.0", +] + +[[package]] +name = "ipnet" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68f2d64f2edebec4ce84ad108148e67e1064789bee435edc5b60ad398714a3a9" + +[[package]] +name = "itoa" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" + +[[package]] +name = "js-sys" +version = "0.3.51" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83bdfbace3a0e81a4253f73b49e960b053e396a11012cbd49b9b74d6a2b67062" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "k256" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4476a0808212a9e81ce802eb1a0cfc60e73aea296553bacc0fac7e1268bc572a" +dependencies = [ + "cfg-if 1.0.0", + "ecdsa", + "elliptic-curve", + "sha2 0.9.5", +] + +[[package]] +name = "keystream" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c33070833c9ee02266356de0c43f723152bd38bd96ddf52c82b3af10c9138b28" + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "lexical-core" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6607c62aa161d23d17a9072cc5da0be67cdfc89d3afb1e8d9c842bebc2525ffe" +dependencies = [ + "arrayvec", + "bitflags", + "cfg-if 1.0.0", + "ryu", + "static_assertions", +] + +[[package]] +name = "libc" +version = "0.2.97" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12b8adadd720df158f4d70dfe7ccc6adb0472d7c55ca83445f6a5ab3e36f8fb6" + +[[package]] +name = "libm" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7d73b3f436185384286bd8098d17ec07c9a7d2388a6599f824d8502b529702a" + +[[package]] +name = "libsqlite3-sys" +version = "0.22.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290b64917f8b0cb885d9de0f9959fe1f775d7fa12f1da2db9001c1c8ab60f89d" +dependencies = [ + "cc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "lioness" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ae926706ba42c425c9457121178330d75e273df2e82e28b758faf3de3a9acb9" +dependencies = [ + "arrayref", + "blake2", + "chacha", + "keystream", +] + +[[package]] +name = "lock_api" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0382880606dff6d15c9476c416d18690b72742aa7b605bb6dd6ec9030fbf07eb" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" +dependencies = [ + "cfg-if 1.0.0", +] + +[[package]] +name = "loom" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2111607c723d7857e0d8299d5ce7a0bf4b844d3e44f8de136b13da513eaf8fc4" +dependencies = [ + "cfg-if 1.0.0", + "generator", + "scoped-tls", + "serde", + "serde_json", +] + +[[package]] +name = "maplit" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" + +[[package]] +name = "matches" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" + +[[package]] +name = "memchr" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b16bd47d9e329435e309c58469fe0791c2d0d1ba96ec0954152a5ae2b04387dc" + +[[package]] +name = "mime" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" + +[[package]] +name = "mio" +version = "0.7.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c2bdb6314ec10835cd3293dd268473a835c02b7b352e788be788b3c6ca6bb16" +dependencies = [ + "libc", + "log", + "miow", + "ntapi", + "winapi", +] + +[[package]] +name = "miow" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21" +dependencies = [ + "winapi", +] + +[[package]] +name = "mixnet-contract" +version = "0.1.0" +dependencies = [ + "cosmwasm-std", + "schemars", + "serde", + "serde_repr", +] + +[[package]] +name = "multer" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fdd568fea4758b30d6423f013f7171e193c34aa97828d1bd9f924fb3af30a8c" +dependencies = [ + "bytes", + "derive_more", + "encoding_rs", + "futures-util", + "http", + "httparse", + "log", + "mime", + "spin 0.9.1", + "tokio", + "tokio-util", + "twoway", + "version_check", +] + +[[package]] +name = "native-tls" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8d96b2e1c8da3957d58100b09f102c6d9cfdfced01b7ec5a8974044bb09dbd4" +dependencies = [ + "lazy_static", + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + +[[package]] +name = "nom" +version = "6.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7413f999671bd4745a7b624bd370a569fb6bc574b23c83a3c5ed2e453f3d5e2" +dependencies = [ + "bitvec 0.19.5", + "funty", + "lexical-core", + "memchr", + "version_check", +] + +[[package]] +name = "ntapi" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44" +dependencies = [ + "winapi", +] + +[[package]] +name = "num-traits" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +dependencies = [ + "autocfg", + "libm", +] + +[[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 = "nym-validator-api" +version = "0.11.0-rc1" +dependencies = [ + "anyhow", + "clap", + "config", + "crypto", + "dirs", + "dotenv", + "futures", + "gateway-client", + "gateway-requests", + "humantime-serde", + "log", + "mixnet-contract", + "nymsphinx", + "pin-project", + "pretty_env_logger", + "rand 0.7.3", + "reqwest", + "rocket", + "rocket_cors", + "rocket_sync_db_pools", + "serde", + "serde_json", + "sqlx", + "tokio", + "topology", + "validator-client", + "version-checker", +] + +[[package]] +name = "nymsphinx" +version = "0.1.0" +dependencies = [ + "crypto", + "nymsphinx-acknowledgements", + "nymsphinx-addressing", + "nymsphinx-anonymous-replies", + "nymsphinx-chunking", + "nymsphinx-cover", + "nymsphinx-forwarding", + "nymsphinx-framing", + "nymsphinx-params", + "nymsphinx-types", + "rand 0.7.3", + "rand_distr 0.3.0", + "tokio", + "topology", +] + +[[package]] +name = "nymsphinx-acknowledgements" +version = "0.1.0" +dependencies = [ + "crypto", + "nymsphinx-addressing", + "nymsphinx-params", + "nymsphinx-types", + "pemstore", + "rand 0.7.3", + "topology", +] + +[[package]] +name = "nymsphinx-addressing" +version = "0.1.0" +dependencies = [ + "crypto", + "nymsphinx-types", + "serde", +] + +[[package]] +name = "nymsphinx-anonymous-replies" +version = "0.1.0" +dependencies = [ + "bs58 0.4.0", + "crypto", + "nymsphinx-addressing", + "nymsphinx-params", + "nymsphinx-types", + "rand 0.7.3", + "serde", + "topology", +] + +[[package]] +name = "nymsphinx-chunking" +version = "0.1.0" +dependencies = [ + "log", + "nymsphinx-addressing", + "nymsphinx-params", + "nymsphinx-types", + "rand 0.7.3", +] + +[[package]] +name = "nymsphinx-cover" +version = "0.1.0" +dependencies = [ + "crypto", + "nymsphinx-acknowledgements", + "nymsphinx-addressing", + "nymsphinx-chunking", + "nymsphinx-forwarding", + "nymsphinx-params", + "nymsphinx-types", + "rand 0.7.3", + "topology", +] + +[[package]] +name = "nymsphinx-forwarding" +version = "0.1.0" +dependencies = [ + "nymsphinx-addressing", + "nymsphinx-params", + "nymsphinx-types", +] + +[[package]] +name = "nymsphinx-framing" +version = "0.1.0" +dependencies = [ + "bytes", + "nymsphinx-params", + "nymsphinx-types", + "tokio-util", +] + +[[package]] +name = "nymsphinx-params" +version = "0.1.0" +dependencies = [ + "crypto", + "nymsphinx-types", +] + +[[package]] +name = "nymsphinx-types" +version = "0.1.0" +dependencies = [ + "sphinx", +] + +[[package]] +name = "once_cell" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56" + +[[package]] +name = "opaque-debug" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" + +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + +[[package]] +name = "openssl" +version = "0.10.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "549430950c79ae24e6d02e0b7404534ecf311d94cc9f861e9e4020187d13d885" +dependencies = [ + "bitflags", + "cfg-if 1.0.0", + "foreign-types", + "libc", + "once_cell", + "openssl-sys", +] + +[[package]] +name = "openssl-probe" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28988d872ab76095a6e6ac88d99b54fd267702734fd7ffe610ca27f533ddb95a" + +[[package]] +name = "openssl-sys" +version = "0.9.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a7907e3bfa08bb85105209cdfcb6c63d109f8f6c1ed6ca318fff5c1853fbc1d" +dependencies = [ + "autocfg", + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "parking_lot" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb" +dependencies = [ + "instant", + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa7a782938e745763fe6907fc6ba86946d72f49fe7e21de074e08128a99fb018" +dependencies = [ + "cfg-if 1.0.0", + "instant", + "libc", + "redox_syscall", + "smallvec", + "winapi", +] + +[[package]] +name = "pear" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15e44241c5e4c868e3eaa78b7c1848cadd6344ed4f54d029832d32b415a58702" +dependencies = [ + "inlinable_string", + "pear_codegen", + "yansi", +] + +[[package]] +name = "pear_codegen" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82a5ca643c2303ecb740d506539deba189e16f2754040a42901cd8105d0282d0" +dependencies = [ + "proc-macro2", + "proc-macro2-diagnostics", + "quote", + "syn", +] + +[[package]] +name = "pem" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd56cbd21fea48d0c440b41cd69c589faacade08c992d9a54e471b79d0fd13eb" +dependencies = [ + "base64", + "once_cell", + "regex", +] + +[[package]] +name = "pemstore" +version = "0.1.0" +dependencies = [ + "pem", +] + +[[package]] +name = "percent-encoding" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" + +[[package]] +name = "pest" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53" +dependencies = [ + "ucd-trie", +] + +[[package]] +name = "pest_derive" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "833d1ae558dc601e9a60366421196a8d94bc0ac980476d0b67e1d0988d72b2d0" +dependencies = [ + "pest", + "pest_generator", +] + +[[package]] +name = "pest_generator" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99b8db626e31e5b81787b9783425769681b347011cc59471e33ea46d2ea0cf55" +dependencies = [ + "pest", + "pest_meta", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "pest_meta" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54be6e404f5317079812fc8f9f5279de376d8856929e21c184ecf6bbd692a11d" +dependencies = [ + "maplit", + "pest", + "sha-1 0.8.2", +] + +[[package]] +name = "pin-project" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7509cc106041c40a4518d2af7a61530e1eed0e6285296a3d8c5472806ccc4a4" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48c950132583b500556b1efd71d45b319029f2b71518d979fcc208e16b42426f" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkcs8" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4839a901843f3942576e65857f0ebf2e190ef7024d3c62a94099ba3f819ad1d" +dependencies = [ + "der", +] + +[[package]] +name = "pkg-config" +version = "0.3.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c" + +[[package]] +name = "ppv-lite86" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" + +[[package]] +name = "pretty_env_logger" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "926d36b9553851b8b0005f1275891b392ee4d2d833852c417ed025477350fb9d" +dependencies = [ + "env_logger", + "log", +] + +[[package]] +name = "proc-macro-hack" +version = "0.5.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" + +[[package]] +name = "proc-macro-nested" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086" + +[[package]] +name = "proc-macro2" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0d8caf72986c1a598726adc988bb5984792ef84f5ee5aa50209145ee8077038" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "proc-macro2-diagnostics" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bf29726d67464d49fa6224a1d07936a8c08bb3fba727c7493f6cf1616fdaada" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "version_check", + "yansi", +] + +[[package]] +name = "quick-error" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" + +[[package]] +name = "quick-error" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3" + +[[package]] +name = "quote" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r2d2" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "545c5bc2b880973c9c10e4067418407a0ccaa3091781d1671d46eb35107cb26f" +dependencies = [ + "log", + "parking_lot", + "scheduled-thread-pool", +] + +[[package]] +name = "radium" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "def50a86306165861203e7f84ecffbbdfdea79f0e51039b33de1e952358c47ac" + +[[package]] +name = "radium" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "941ba9d78d8e2f7ce474c015eea4d9c6d25b6a3327f9832ee29a4de27f91bbb8" + +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom 0.1.16", + "libc", + "rand_chacha 0.2.2", + "rand_core 0.5.1", + "rand_hc 0.2.0", +] + +[[package]] +name = "rand" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8" +dependencies = [ + "libc", + "rand_chacha 0.3.1", + "rand_core 0.6.3", + "rand_hc 0.3.1", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core 0.5.1", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.3", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom 0.1.16", +] + +[[package]] +name = "rand_core" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" +dependencies = [ + "getrandom 0.2.3", +] + +[[package]] +name = "rand_distr" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96977acbdd3a6576fb1d27391900035bf3863d4a16422973a409b488cf29ffb2" +dependencies = [ + "rand 0.7.3", +] + +[[package]] +name = "rand_distr" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9e9532ada3929fb8b2e9dbe28d1e06c9b2cc65813f074fcb6bd5fbefeff9d56" +dependencies = [ + "num-traits", + "rand 0.7.3", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core 0.5.1", +] + +[[package]] +name = "rand_hc" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d51e9f596de227fda2ea6c84607f5558e196eeaf43c986b724ba4fb8fdf497e7" +dependencies = [ + "rand_core 0.6.3", +] + +[[package]] +name = "redox_syscall" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ab49abadf3f9e1c4bc499e8845e152ad87d2ad2d30371841171169e9d75feee" +dependencies = [ + "bitflags", +] + +[[package]] +name = "redox_users" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64" +dependencies = [ + "getrandom 0.2.3", + "redox_syscall", +] + +[[package]] +name = "ref-cast" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "300f2a835d808734ee295d45007adacb9ebb29dd3ae2424acfa17930cae541da" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c38e3aecd2b21cb3959637b883bb3714bc7e43f0268b9a29d3743ee3e55cdd2" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "regex" +version = "1.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.6.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" + +[[package]] +name = "remove_dir_all" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" +dependencies = [ + "winapi", +] + +[[package]] +name = "reqwest" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "246e9f61b9bb77df069a947682be06e31ac43ea37862e244a69f177694ea6d22" +dependencies = [ + "base64", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "http", + "http-body", + "hyper", + "hyper-tls", + "ipnet", + "js-sys", + "lazy_static", + "log", + "mime", + "native-tls", + "percent-encoding", + "pin-project-lite", + "serde", + "serde_json", + "serde_urlencoded", + "tokio", + "tokio-native-tls", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "winreg", +] + +[[package]] +name = "ring" +version = "0.16.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" +dependencies = [ + "cc", + "libc", + "once_cell", + "spin 0.5.2", + "untrusted", + "web-sys", + "winapi", +] + +[[package]] +name = "rocket" +version = "0.5.0-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a71c18c42a0eb15bf3816831caf0dad11e7966f2a41aaf486a701979c4dd1f2" +dependencies = [ + "async-stream", + "async-trait", + "atomic", + "atty", + "binascii", + "bytes", + "either", + "figment", + "futures", + "indexmap", + "log", + "memchr", + "multer", + "num_cpus", + "parking_lot", + "pin-project-lite", + "rand 0.8.4", + "ref-cast", + "rocket_codegen", + "rocket_http", + "serde", + "serde_json", + "state", + "tempfile", + "time", + "tokio", + "tokio-stream", + "tokio-util", + "ubyte", + "version_check", + "yansi", +] + +[[package]] +name = "rocket_codegen" +version = "0.5.0-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66f5fa462f7eb958bba8710c17c5d774bbbd59809fa76fb1957af7e545aea8bb" +dependencies = [ + "devise", + "glob", + "indexmap", + "proc-macro2", + "quote", + "rocket_http", + "syn", + "unicode-xid", +] + +[[package]] +name = "rocket_cors" +version = "0.5.2" +source = "git+https://github.com/lawliet89/rocket_cors?rev=dfd3662c49e2f6fc37df35091cb94d82f7fb5915#dfd3662c49e2f6fc37df35091cb94d82f7fb5915" +dependencies = [ + "log", + "regex", + "rocket", + "serde", + "serde_derive", + "unicase", + "unicase_serde", + "url", +] + +[[package]] +name = "rocket_http" +version = "0.5.0-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23c8b7d512d2fcac2316ebe590cde67573844b99e6cc9ee0f53375fa16e25ebd" +dependencies = [ + "cookie", + "either", + "http", + "hyper", + "indexmap", + "log", + "memchr", + "mime", + "parking_lot", + "pear", + "percent-encoding", + "pin-project-lite", + "ref-cast", + "serde", + "smallvec", + "stable-pattern", + "state", + "time", + "tokio", + "uncased", +] + +[[package]] +name = "rocket_sync_db_pools" +version = "0.1.0-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38cfdfebd552d075c368e641c88a5cd6ce1c58c5c710548aeb777abb48830f4b" +dependencies = [ + "r2d2", + "rocket", + "rocket_sync_db_pools_codegen", + "serde", + "tokio", +] + +[[package]] +name = "rocket_sync_db_pools_codegen" +version = "0.1.0-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5267808c094db5366e1d8925aaf9f2ce05ff9b3bd92cb18c7040a1fe219c2e25" +dependencies = [ + "devise", + "quote", +] + +[[package]] +name = "rustc_version" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +dependencies = [ + "semver 0.9.0", +] + +[[package]] +name = "rustls" +version = "0.19.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35edb675feee39aec9c99fa5ff985081995a06d594114ae14cbe797ad7b7a6d7" +dependencies = [ + "base64", + "log", + "ring", + "sct", + "webpki", +] + +[[package]] +name = "rustversion" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61b3909d758bb75c79f23d4736fac9433868679d3ad2ea7a61e3c25cfda9a088" + +[[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", +] + +[[package]] +name = "scheduled-thread-pool" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc6f74fd1204073fa02d5d5d68bec8021be4c38690b61264b2fdb48083d0e7d7" +dependencies = [ + "parking_lot", +] + +[[package]] +name = "schemars" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc6ab463ae35acccb5cba66c0084c985257b797d288b6050cc2f6ac1b266cb78" +dependencies = [ + "dyn-clone", + "schemars_derive", + "serde", + "serde_json", +] + +[[package]] +name = "schemars_derive" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "902fdfbcf871ae8f653bddf4b2c05905ddaabc08f69d32a915787e3be0d31356" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn", +] + +[[package]] +name = "scoped-tls" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2" + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "sct" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b362b83898e0e69f38515b82ee15aa80636befe47c3b6d3d89a911e78fc228ce" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "security-framework" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23a2ac85147a3a11d77ecf1bc7166ec0b92febfa4461c37944e180f319ece467" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e4effb91b4b8b6fb7732e670b6cee160278ff8e6bf485c7805d9e319d76e284" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "semver" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +dependencies = [ + "semver-parser 0.7.0", +] + +[[package]] +name = "semver" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" +dependencies = [ + "semver-parser 0.10.2", +] + +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" + +[[package]] +name = "semver-parser" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" +dependencies = [ + "pest", +] + +[[package]] +name = "serde" +version = "1.0.126" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec7505abeacaec74ae4778d9d9328fe5a5d04253220a85c4ee022239fc996d03" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde-json-wasm" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50eef3672ec8fa45f3457fd423ba131117786784a895548021976117c1ded449" +dependencies = [ + "serde", +] + +[[package]] +name = "serde_derive" +version = "1.0.126" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "963a7dbc9895aeac7ac90e74f34a5d5261828f79df35cbed41e10189d3804d43" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_derive_internals" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dbab34ca63057a1f15280bdf3c39f2b1eb1b54c17e98360e511637aef7418c6" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79" +dependencies = [ + "indexmap", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_repr" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98d0516900518c29efa217c298fa1f4e6c6ffc85ae29fd7f4ee48f176e1a9ed5" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edfa57a7f8d9c1d260a549e7224100f6c43d43f9103e06dd8b4095a9b2b43ce9" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha-1" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df" +dependencies = [ + "block-buffer 0.7.3", + "digest 0.8.1", + "fake-simd", + "opaque-debug 0.2.3", +] + +[[package]] +name = "sha-1" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c4cfa741c5832d0ef7fab46cabed29c2aae926db0b11bb2069edd8db5e64e16" +dependencies = [ + "block-buffer 0.9.0", + "cfg-if 1.0.0", + "cpufeatures", + "digest 0.9.0", + "opaque-debug 0.3.0", +] + +[[package]] +name = "sha1" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" + +[[package]] +name = "sha2" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a256f46ea78a0c0d9ff00077504903ac881a1dafdc20da66545699e7776b3e69" +dependencies = [ + "block-buffer 0.7.3", + "digest 0.8.1", + "fake-simd", + "opaque-debug 0.2.3", +] + +[[package]] +name = "sha2" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b362ae5752fd2137731f9fa25fd4d9058af34666ca1966fb969119cc35719f12" +dependencies = [ + "block-buffer 0.9.0", + "cfg-if 1.0.0", + "cpufeatures", + "digest 0.9.0", + "opaque-debug 0.3.0", +] + +[[package]] +name = "signal-hook-registry" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" +dependencies = [ + "libc", +] + +[[package]] +name = "signature" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29f060a7d147e33490ec10da418795238fd7545bba241504d6b31a409f2e6210" +dependencies = [ + "digest 0.9.0", + "rand_core 0.5.1", +] + +[[package]] +name = "slab" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f173ac3d1a7e3b28003f40de0b5ce7fe2710f9b9dc3fc38664cebee46b3b6527" + +[[package]] +name = "smallvec" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" + +[[package]] +name = "socket2" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e3dfc207c526015c632472a77be09cf1b6e46866581aecae5cc38fb4235dea2" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "sphinx" +version = "0.1.0" +source = "git+https://github.com/nymtech/sphinx?rev=283dcc77dec8ee9ed3bed58c2b878e9c18320723#283dcc77dec8ee9ed3bed58c2b878e9c18320723" +dependencies = [ + "aes-ctr 0.3.0", + "arrayref", + "blake2", + "bs58 0.3.1", + "byteorder", + "chacha", + "curve25519-dalek", + "hkdf 0.8.0", + "hmac 0.7.1", + "lioness", + "log", + "rand 0.7.3", + "rand_distr 0.2.2", + "sha2 0.8.2", +] + +[[package]] +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + +[[package]] +name = "spin" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5fdd7196b4ae35a111c6dc97f9cc152ca3ea8ad744f7cb46a9f27b3ef8f2f54" + +[[package]] +name = "sqlformat" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d86e3c77ff882a828346ba401a7ef4b8e440df804491c6064fe8295765de71c" +dependencies = [ + "lazy_static", + "maplit", + "nom", + "regex", + "unicode_categories", +] + +[[package]] +name = "sqlx" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba82f79b31f30acebf19905bcd8b978f46891b9d0723f578447361a8910b6584" +dependencies = [ + "sqlx-core", + "sqlx-macros", +] + +[[package]] +name = "sqlx-core" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f23af36748ec8ea8d49ef8499839907be41b0b1178a4e82b8cb45d29f531dc9" +dependencies = [ + "ahash", + "atoi", + "bitflags", + "byteorder", + "bytes", + "crc", + "crossbeam-channel", + "crossbeam-queue", + "crossbeam-utils", + "either", + "futures-channel", + "futures-core", + "futures-util", + "hashlink", + "hex", + "itoa", + "libc", + "libsqlite3-sys", + "log", + "memchr", + "once_cell", + "parking_lot", + "percent-encoding", + "rustls", + "serde", + "sha2 0.9.5", + "smallvec", + "sqlformat", + "sqlx-rt", + "stringprep", + "thiserror", + "time", + "tokio-stream", + "url", + "webpki", + "webpki-roots", + "whoami", +] + +[[package]] +name = "sqlx-macros" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47e4a2349d1ffd60a03ca0de3f116ba55d7f406e55a0d84c64a5590866d94c06" +dependencies = [ + "dotenv", + "either", + "futures", + "heck", + "hex", + "once_cell", + "proc-macro2", + "quote", + "serde", + "serde_json", + "sha2 0.9.5", + "sqlx-core", + "sqlx-rt", + "syn", + "url", +] + +[[package]] +name = "sqlx-rt" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8199b421ecf3493ee9ef3e7bc90c904844cfb2ea7ea2f57347a93f52bfd3e057" +dependencies = [ + "once_cell", + "tokio", + "tokio-rustls", +] + +[[package]] +name = "stable-pattern" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4564168c00635f88eaed410d5efa8131afa8d8699a612c80c455a0ba05c21045" +dependencies = [ + "memchr", +] + +[[package]] +name = "standback" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e113fb6f3de07a243d434a56ec6f186dfd51cb08448239fe7bcae73f87ff28ff" +dependencies = [ + "version_check", +] + +[[package]] +name = "state" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cf4f5369e6d3044b5e365c9690f451516ac8f0954084622b49ea3fde2f6de5" +dependencies = [ + "loom", +] + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "stdweb" +version = "0.4.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d022496b16281348b52d0e30ae99e01a73d737b2f45d38fed4edf79f9325a1d5" +dependencies = [ + "discard", + "rustc_version", + "stdweb-derive", + "stdweb-internal-macros", + "stdweb-internal-runtime", + "wasm-bindgen", +] + +[[package]] +name = "stdweb-derive" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c87a60a40fccc84bef0652345bbbbbe20a605bf5d0ce81719fc476f5c03b50ef" +dependencies = [ + "proc-macro2", + "quote", + "serde", + "serde_derive", + "syn", +] + +[[package]] +name = "stdweb-internal-macros" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58fa5ff6ad0d98d1ffa8cb115892b6e69d67799f6763e162a1c9db421dc22e11" +dependencies = [ + "base-x", + "proc-macro2", + "quote", + "serde", + "serde_derive", + "serde_json", + "sha1", + "syn", +] + +[[package]] +name = "stdweb-internal-runtime" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "213701ba3370744dcd1a12960caa4843b3d68b4d1c0a5d575e0d65b2ee9d16c0" + +[[package]] +name = "stream-cipher" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8131256a5896cabcf5eb04f4d6dacbe1aefda854b0d9896e09cb58829ec5638c" +dependencies = [ + "generic-array 0.12.4", +] + +[[package]] +name = "stringprep" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ee348cb74b87454fff4b551cbf727025810a004f88aeacae7f85b87f4e9a1c1" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "strsim" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" + +[[package]] +name = "subtle" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" + +[[package]] +name = "subtle" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e81da0851ada1f3e9d4312c704aa4f8806f0f9d69faaf8df2f3464b4a9437c2" + +[[package]] +name = "syn" +version = "1.0.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f71489ff30030d2ae598524f61326b902466f72a0fb1a8564c001cc63425bcc7" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "synstructure" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b834f2d66f734cb897113e34aaff2f1ab4719ca946f9a7358dba8f8064148701" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "unicode-xid", +] + +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + +[[package]] +name = "tempfile" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "rand 0.8.4", + "redox_syscall", + "remove_dir_all", + "winapi", +] + +[[package]] +name = "termcolor" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "textwrap" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" +dependencies = [ + "unicode-width", +] + +[[package]] +name = "thiserror" +version = "1.0.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93119e4feac1cbe6c798c34d3a53ea0026b0b1de6a120deef895137c0529bfe2" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "060d69a0afe7796bf42e9e2ff91f5ee691fb15c53d38b4b62a9a53eb23164745" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "time" +version = "0.2.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4752a97f8eebd6854ff91f1c1824cd6160626ac4bd44287f7f4ea2035a02a242" +dependencies = [ + "const_fn", + "libc", + "standback", + "stdweb", + "time-macros", + "version_check", + "winapi", +] + +[[package]] +name = "time-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "957e9c6e26f12cb6d0dd7fc776bb67a706312e7299aed74c8dd5b17ebb27e2f1" +dependencies = [ + "proc-macro-hack", + "time-macros-impl", +] + +[[package]] +name = "time-macros-impl" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd3c141a1b43194f3f56a1411225df8646c55781d5f26db825b3d98507eb482f" +dependencies = [ + "proc-macro-hack", + "proc-macro2", + "quote", + "standback", + "syn", +] + +[[package]] +name = "tinyvec" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b5220f05bb7de7f3f53c7c065e1199b3172696fe2db9f9c4d8ad9b4ee74c342" +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 = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "570c2eb13b3ab38208130eccd41be92520388791207fde783bda7c1e8ace28d4" +dependencies = [ + "autocfg", + "bytes", + "libc", + "memchr", + "mio", + "num_cpus", + "once_cell", + "pin-project-lite", + "signal-hook-registry", + "tokio-macros", + "winapi", +] + +[[package]] +name = "tokio-macros" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c49e3df43841dafb86046472506755d8501c5615673955f6aa17181125d13c37" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tokio-native-tls" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7d995660bd2b7f8c1568414c1126076c13fbb725c40112dc0120b78eb9b717b" +dependencies = [ + "native-tls", + "tokio", +] + +[[package]] +name = "tokio-rustls" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc6844de72e57df1980054b38be3a9f4702aba4858be64dd700181a8a6d0e1b6" +dependencies = [ + "rustls", + "tokio", + "webpki", +] + +[[package]] +name = "tokio-stream" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8864d706fdb3cc0843a49647ac892720dac98a6eeb818b77190592cf4994066" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-tungstenite" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e96bb520beab540ab664bd5a9cfeaa1fcd846fa68c830b42e2c8963071251d2" +dependencies = [ + "futures-util", + "log", + "pin-project", + "tokio", + "tungstenite", +] + +[[package]] +name = "tokio-util" +version = "0.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1caa0b0c8d94a049db56b5acf8cba99dc0623aab1b26d5b5f5e2d945846b3592" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "log", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "toml" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa" +dependencies = [ + "serde", +] + +[[package]] +name = "topology" +version = "0.1.0" +dependencies = [ + "bs58 0.4.0", + "crypto", + "log", + "mixnet-contract", + "nymsphinx-addressing", + "nymsphinx-types", + "rand 0.7.3", + "version-checker", +] + +[[package]] +name = "tower-service" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" + +[[package]] +name = "tracing" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09adeb8c97449311ccd28a427f96fb563e7fd31aabf994189879d9da2394b89d" +dependencies = [ + "cfg-if 1.0.0", + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9ff14f98b1a4b289c6248a023c1c2fa1491062964e9fed67ab29c4e4da4a052" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "try-lock" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" + +[[package]] +name = "tungstenite" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fe8dada8c1a3aeca77d6b51a4f1314e0f4b8e438b7b1b71e3ddaca8080e4093" +dependencies = [ + "base64", + "byteorder", + "bytes", + "http", + "httparse", + "input_buffer", + "log", + "rand 0.8.4", + "sha-1 0.9.6", + "thiserror", + "url", + "utf-8", +] + +[[package]] +name = "twoway" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c57ffb460d7c24cd6eda43694110189030a3d1dfe418416d9468fd1c1d290b47" +dependencies = [ + "memchr", + "unchecked-index", +] + +[[package]] +name = "typenum" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06" + +[[package]] +name = "ubyte" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42756bb9e708855de2f8a98195643dff31a97f0485d90d8467b39dc24be9e8fe" +dependencies = [ + "serde", +] + +[[package]] +name = "ucd-trie" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" + +[[package]] +name = "uint" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6470ab50f482bde894a037a57064480a246dbfdd5960bd65a44824693f08da5f" +dependencies = [ + "byteorder", + "crunchy", + "hex", + "static_assertions", +] + +[[package]] +name = "uncased" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5baeed7327e25054889b9bd4f975f32e5f4c5d434042d59ab6cd4142c0a76ed0" +dependencies = [ + "serde", + "version_check", +] + +[[package]] +name = "unchecked-index" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eeba86d422ce181a719445e51872fa30f1f7413b62becb52e95ec91aa262d85c" + +[[package]] +name = "unicase" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" +dependencies = [ + "version_check", +] + +[[package]] +name = "unicase_serde" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ef53697679d874d69f3160af80bc28de12730a985d57bdf2b47456ccb8b11f1" +dependencies = [ + "serde", + "unicase", +] + +[[package]] +name = "unicode-bidi" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eeb8be209bb1c96b7c177c7420d26e04eccacb0eeae6b980e35fcb74678107e0" +dependencies = [ + "matches", +] + +[[package]] +name = "unicode-normalization" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d54590932941a9e9266f0832deed84ebe1bf2e4c9e4a3554d393d18f5e854bf9" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-segmentation" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8895849a949e7845e06bd6dc1aa51731a103c42707010a5b591c0038fb73385b" + +[[package]] +name = "unicode-width" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" + +[[package]] +name = "unicode-xid" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" + +[[package]] +name = "unicode_categories" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e" + +[[package]] +name = "untrusted" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" + +[[package]] +name = "url" +version = "2.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a507c383b2d33b5fc35d1861e77e6b383d158b2da5e14fe51b83dfedf6fd578c" +dependencies = [ + "form_urlencoded", + "idna", + "matches", + "percent-encoding", +] + +[[package]] +name = "utf-8" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" + +[[package]] +name = "validator-client" +version = "0.1.0" +dependencies = [ + "base64", + "log", + "mixnet-contract", + "rand 0.8.4", + "reqwest", + "serde", + "serde_json", + "thiserror", + "url", + "wasm-timer", +] + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "vec_map" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" + +[[package]] +name = "version-checker" +version = "0.1.0" +dependencies = [ + "semver 0.11.0", +] + +[[package]] +name = "version_check" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" + +[[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 = "wasi" +version = "0.10.2+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" + +[[package]] +name = "wasm-bindgen" +version = "0.2.74" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d54ee1d4ed486f78874278e63e4069fc1ab9f6a18ca492076ffb90c5eb2997fd" +dependencies = [ + "cfg-if 1.0.0", + "serde", + "serde_json", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.74" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b33f6a0694ccfea53d94db8b2ed1c3a8a4c86dd936b13b9f0a15ec4a451b900" +dependencies = [ + "bumpalo", + "lazy_static", + "log", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fba7978c679d53ce2d0ac80c8c175840feb849a161664365d1287b41f2e67f1" +dependencies = [ + "cfg-if 1.0.0", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.74" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "088169ca61430fe1e58b8096c24975251700e7b1f6fd91cc9d59b04fb9b18bd4" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.74" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be2241542ff3d9f241f5e2cb6dd09b37efe786df8851c54957683a49f0987a97" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.74" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7cff876b8f18eed75a66cf49b65e7f967cb354a7aa16003fb55dbfd25b44b4f" + +[[package]] +name = "wasm-timer" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be0ecb0db480561e9a7642b5d3e4187c128914e58aa84330b9493e3eb68c5e7f" +dependencies = [ + "futures", + "js-sys", + "parking_lot", + "pin-utils", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + +[[package]] +name = "web-sys" +version = "0.3.51" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e828417b379f3df7111d3a2a9e5753706cae29c41f7c4029ee9fd77f3e09e582" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "webpki" +version = "0.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8e38c0608262c46d4a56202ebabdeb094cef7e560ca7a226c6bf055188aa4ea" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "webpki-roots" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aabe153544e473b775453675851ecc86863d2a81d786d741f6b76778f2a48940" +dependencies = [ + "webpki", +] + +[[package]] +name = "whoami" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4abacf325c958dfeaf1046931d37f2a901b6dfe0968ee965a29e94c6766b2af6" +dependencies = [ + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +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", +] + +[[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", +] + +[[package]] +name = "wyz" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214" + +[[package]] +name = "x25519-dalek" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a0c105152107e3b96f6a00a65e86ce82d9b125230e1c4302940eca58ff71f4f" +dependencies = [ + "curve25519-dalek", + "rand_core 0.5.1", + "zeroize", +] + +[[package]] +name = "yansi" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fc79f4a1e39857fc00c3f662cbf2651c771f00e9c15fe2abc341806bd46bd71" + +[[package]] +name = "zeroize" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4756f7db3f7b5574938c3eb1c117038b8e07f95ee6718c0efad4ac21508f1efd" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2c1e130bebaeab2f23886bf9acbaca14b092408c452543c857f66399cd6dab1" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] diff --git a/validator-api/Cargo.toml b/validator-api/Cargo.toml index 93b235f6ba..235e8d3ae1 100644 --- a/validator-api/Cargo.toml +++ b/validator-api/Cargo.toml @@ -11,6 +11,10 @@ authors = [ ] edition = "2018" +# if there's ANY panic in ANY thread, abort the whole thing +[profile.release] +panic = "abort" + # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] @@ -31,6 +35,8 @@ tokio = { version="1.4", features=["rt-multi-thread", "macros", "signal", "time" rocket_cors = { git="https://github.com/lawliet89/rocket_cors", rev="dfd3662c49e2f6fc37df35091cb94d82f7fb5915" } anyhow = "1" +rocket_sync_db_pools = {version = "0.1.0-rc.1", default-features = false} +sqlx = { version = "0.5", features = ["runtime-tokio-rustls", "sqlite", "macros", "offline", "migrate", "time"]} ## internal config = { path = "../common/config" } diff --git a/validator-api/migrations/20210714120000_create_initial_tables.sql b/validator-api/migrations/20210714120000_create_initial_tables.sql new file mode 100644 index 0000000000..26e88d07e5 --- /dev/null +++ b/validator-api/migrations/20210714120000_create_initial_tables.sql @@ -0,0 +1,91 @@ +CREATE TABLE mixnode_details +( + id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + owner VARCHAR NOT NULL UNIQUE, + pub_key VARCHAR NOT NULL UNIQUE +); + +CREATE TABLE gateway_details +( + id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + owner VARCHAR NOT NULL UNIQUE, + pub_key VARCHAR NOT NULL UNIQUE +); + +create TABLE mixnode_historical_uptime +( + mixnode_details_id INTEGER NOT NULL, + + -- 'YYYY-MM-DD' + date VARCHAR NOT NULL, + + -- 24h uptimes for that day + ipv4_uptime INTEGER NOT NULL, + ipv6_uptime INTEGER NOT NULL, + + FOREIGN KEY (mixnode_details_id) REFERENCES mixnode_details (id) +); + +create table mixnode_ipv4_status +( + mixnode_details_id INTEGER NOT NULL, + up BOOLEAN NOT NULL, + timestamp INTEGER NOT NULL, + + FOREIGN KEY (mixnode_details_id) REFERENCES mixnode_details (id) +); + +create table mixnode_ipv6_status +( + mixnode_details_id INTEGER NOT NULL, + up BOOLEAN NOT NULL, + timestamp INTEGER NOT NULL, + + FOREIGN KEY (mixnode_details_id) REFERENCES mixnode_details (id) +); + +create TABLE gateway_historical_uptime +( + gateway_details_id INTEGER NOT NULL, + + -- 'YYYY-MM-DD' + date VARCHAR NOT NULL, + + -- 24h uptimes for that day + ipv4_uptime INTEGER NOT NULL, + ipv6_uptime INTEGER NOT NULL, + + FOREIGN KEY (gateway_details_id) REFERENCES gateway_details (id) +); + +create table gateway_ipv4_status +( + gateway_details_id INTEGER NOT NULL, + up BOOLEAN NOT NULL, + timestamp INTEGER NOT NULL, + + FOREIGN KEY (gateway_details_id) REFERENCES gateway_details (id) +); + +create table gateway_ipv6_status +( + gateway_details_id INTEGER NOT NULL, + up BOOLEAN NOT NULL, + timestamp INTEGER NOT NULL, + + FOREIGN KEY (gateway_details_id) REFERENCES gateway_details (id) +); + +-- indices for faster lookups +CREATE +INDEX `mixnode_ipv4_status_index` ON `mixnode_ipv4_status` (`mixnode_details_id`, `timestamp` desc); +CREATE +INDEX `mixnode_ipv6_status_index` ON `mixnode_ipv6_status` (`mixnode_details_id`, `timestamp` desc); + +CREATE +INDEX `gateway_ipv4_status_index` ON `gateway_ipv4_status` (`gateway_details_id`, `timestamp` desc); +CREATE +INDEX `gateway_ipv6_status_index` ON `gateway_ipv6_status` (`gateway_details_id`, `timestamp` desc); + +CREATE INDEX `mixnode_identity_index` ON `mixnode_details` (`id`, `pub_key`); +CREATE INDEX `gateway_identity_index` ON `gateway_details` (`id`, `pub_key`); \ No newline at end of file diff --git a/validator-api/sqlx-data.json b/validator-api/sqlx-data.json new file mode 100644 index 0000000000..124fef609f --- /dev/null +++ b/validator-api/sqlx-data.json @@ -0,0 +1,505 @@ +{ + "db": "SQLite", + "01de0a1f0b7c432dfdcad2cc2dedd2c1fa2c9618a0166207a1920e3b25d2b7e7": { + "query": "DELETE FROM mixnode_ipv4_status WHERE timestamp < ?", + "describe": { + "columns": [], + "parameters": { + "Right": 1 + }, + "nullable": [] + } + }, + "1915fb818696abb354f1bc7915399be69fb7b97204f7fb81baba4f4be1777fce": { + "query": "\n SELECT date, ipv4_uptime, ipv6_uptime\n FROM gateway_historical_uptime\n JOIN gateway_details\n ON gateway_historical_uptime.gateway_details_id = gateway_details.id\n WHERE gateway_details.pub_key = ?\n ORDER BY date ASC\n ", + "describe": { + "columns": [ + { + "name": "date", + "ordinal": 0, + "type_info": "Text" + }, + { + "name": "ipv4_uptime", + "ordinal": 1, + "type_info": "Int64" + }, + { + "name": "ipv6_uptime", + "ordinal": 2, + "type_info": "Int64" + } + ], + "parameters": { + "Right": 1 + }, + "nullable": [ + false, + false, + false + ] + } + }, + "20b7eee88b4bfb196d0dbbbef19d789d9ffd0790349b7ae6bea6b536123be3b3": { + "query": "INSERT INTO mixnode_historical_uptime(mixnode_details_id, date, ipv4_uptime, ipv6_uptime) VALUES (?, ?, ?, ?)", + "describe": { + "columns": [], + "parameters": { + "Right": 4 + }, + "nullable": [] + } + }, + "26a6cec333e3187d1bee9a583529b4126cb12d711771c5276e9598ccaa0a144d": { + "query": "\n INSERT INTO mixnode_ipv4_status (mixnode_details_id, up, timestamp) VALUES (?, ?, ?);\n ", + "describe": { + "columns": [], + "parameters": { + "Right": 3 + }, + "nullable": [] + } + }, + "2a29b2ccfab79d5e3646591dbd7800e26c222f1a5c1fc600dcd13ad67e133e68": { + "query": "DELETE FROM mixnode_ipv6_status WHERE timestamp < ?", + "describe": { + "columns": [], + "parameters": { + "Right": 1 + }, + "nullable": [] + } + }, + "2d87cc44c28330492c7cf90589e5d8113ccff07d6f67c485226bbe59246db522": { + "query": "\n INSERT OR IGNORE INTO gateway_details(pub_key, owner) VALUES (?, ?);\n SELECT id FROM gateway_details WHERE pub_key = ?;\n ", + "describe": { + "columns": [ + { + "name": "id", + "ordinal": 0, + "type_info": "Int64" + } + ], + "parameters": { + "Right": 3 + }, + "nullable": [ + false + ] + } + }, + "3ee79b29c8df08c3e40fcafb26d82d7dbb13a093df4134be05dac6d96442be75": { + "query": "\n SELECT timestamp, up\n FROM mixnode_ipv6_status\n WHERE mixnode_details_id=? AND timestamp > ?;\n ", + "describe": { + "columns": [ + { + "name": "timestamp", + "ordinal": 0, + "type_info": "Int64" + }, + { + "name": "up", + "ordinal": 1, + "type_info": "Bool" + } + ], + "parameters": { + "Right": 2 + }, + "nullable": [ + false, + false + ] + } + }, + "452451398ef5ae0cc43a7d6bcfdffefbd2b1b67cd429f0a649c365c20ea65ad0": { + "query": "\n SELECT timestamp, up\n FROM gateway_ipv4_status\n WHERE gateway_details_id=? AND timestamp > ?;\n ", + "describe": { + "columns": [ + { + "name": "timestamp", + "ordinal": 0, + "type_info": "Int64" + }, + { + "name": "up", + "ordinal": 1, + "type_info": "Bool" + } + ], + "parameters": { + "Right": 2 + }, + "nullable": [ + false, + false + ] + } + }, + "4c32c31247672549621c5b817625228f1a777919ae711d0d29a192494183e9d3": { + "query": "DELETE FROM gateway_ipv6_status WHERE timestamp < ?", + "describe": { + "columns": [], + "parameters": { + "Right": 1 + }, + "nullable": [] + } + }, + "573944d1f6d79d139da359e6499e1cad07f1d9017f00cfa03d9918b8c5955fb2": { + "query": "\n INSERT INTO gateway_ipv6_status (gateway_details_id, up, timestamp) VALUES (?, ?, ?);\n ", + "describe": { + "columns": [], + "parameters": { + "Right": 3 + }, + "nullable": [] + } + }, + "6b421289099f59d2f61287e87152621039d47b311dd2474887dcc91c0ca7db7e": { + "query": "\n SELECT timestamp, up\n FROM mixnode_ipv4_status\n JOIN mixnode_details\n ON mixnode_ipv4_status.mixnode_details_id = mixnode_details.id\n WHERE mixnode_details.pub_key=? AND mixnode_ipv4_status.timestamp > ?;\n ", + "describe": { + "columns": [ + { + "name": "timestamp", + "ordinal": 0, + "type_info": "Int64" + }, + { + "name": "up", + "ordinal": 1, + "type_info": "Bool" + } + ], + "parameters": { + "Right": 2 + }, + "nullable": [ + false, + false + ] + } + }, + "76c9645a1d79ce4294bff73e0fb60d211490bd810687f8e7d9963d05e7970cee": { + "query": "DELETE FROM gateway_ipv4_status WHERE timestamp < ?", + "describe": { + "columns": [], + "parameters": { + "Right": 1 + }, + "nullable": [] + } + }, + "9212a4484ce59c30e9ef7d9e6796eb837e00e618db6f21b711cbf17661011054": { + "query": "\n SELECT timestamp, up\n FROM mixnode_ipv6_status\n JOIN mixnode_details\n ON mixnode_ipv6_status.mixnode_details_id = mixnode_details.id\n WHERE mixnode_details.pub_key=? AND mixnode_ipv6_status.timestamp > ?;\n ", + "describe": { + "columns": [ + { + "name": "timestamp", + "ordinal": 0, + "type_info": "Int64" + }, + { + "name": "up", + "ordinal": 1, + "type_info": "Bool" + } + ], + "parameters": { + "Right": 2 + }, + "nullable": [ + false, + false + ] + } + }, + "9214cdd2b78eae6fce99f25dd65dde6bee2a55792763e63ca49f1e9498c5eb81": { + "query": "\n SELECT timestamp, up\n FROM mixnode_ipv4_status\n WHERE mixnode_details_id=? AND timestamp > ?;\n ", + "describe": { + "columns": [ + { + "name": "timestamp", + "ordinal": 0, + "type_info": "Int64" + }, + { + "name": "up", + "ordinal": 1, + "type_info": "Bool" + } + ], + "parameters": { + "Right": 2 + }, + "nullable": [ + false, + false + ] + } + }, + "95ba8a44df5f91da83655a994e56c7ff79d7c2e4f5c01e0402c2f868e7cb54cd": { + "query": "\n INSERT INTO gateway_ipv4_status (gateway_details_id, up, timestamp) VALUES (?, ?, ?);\n ", + "describe": { + "columns": [], + "parameters": { + "Right": 3 + }, + "nullable": [] + } + }, + "97e108e08c4a8aa2c0e2a32f93ae7c65193a26be2d06f8f97ab8fdc0f7004fa4": { + "query": "SELECT owner FROM gateway_details WHERE pub_key = ?", + "describe": { + "columns": [ + { + "name": "owner", + "ordinal": 0, + "type_info": "Text" + } + ], + "parameters": { + "Right": 1 + }, + "nullable": [ + false + ] + } + }, + "9cd914e2f1e8058c6935a50f2a02c0e04c4ee5a1c4a400f08d9d0eb47f5665d8": { + "query": "SELECT owner FROM mixnode_details WHERE pub_key = ?", + "describe": { + "columns": [ + { + "name": "owner", + "ordinal": 0, + "type_info": "Text" + } + ], + "parameters": { + "Right": 1 + }, + "nullable": [ + false + ] + } + }, + "aa9708202a664aa8b85e8881deb9f0137efd91f88eba18a7fa05ee1ad7e8e621": { + "query": "\n SELECT date, ipv4_uptime, ipv6_uptime\n FROM mixnode_historical_uptime\n JOIN mixnode_details\n ON mixnode_historical_uptime.mixnode_details_id = mixnode_details.id\n WHERE mixnode_details.pub_key = ?\n ORDER BY date ASC\n ", + "describe": { + "columns": [ + { + "name": "date", + "ordinal": 0, + "type_info": "Text" + }, + { + "name": "ipv4_uptime", + "ordinal": 1, + "type_info": "Int64" + }, + { + "name": "ipv6_uptime", + "ordinal": 2, + "type_info": "Int64" + } + ], + "parameters": { + "Right": 1 + }, + "nullable": [ + false, + false, + false + ] + } + }, + "b34e1f8595764d2706e80b317c7aed9ee9a11b23028aa44ff56ce840349e0ff9": { + "query": "\n SELECT DISTINCT pub_key, owner, id\n FROM gateway_details\n JOIN gateway_ipv4_status\n ON gateway_details.id = gateway_ipv4_status.gateway_details_id\n WHERE EXISTS (\n SELECT 1 FROM gateway_ipv4_status WHERE timestamp > ?\n )\n ", + "describe": { + "columns": [ + { + "name": "pub_key", + "ordinal": 0, + "type_info": "Text" + }, + { + "name": "owner", + "ordinal": 1, + "type_info": "Text" + }, + { + "name": "id", + "ordinal": 2, + "type_info": "Int64" + } + ], + "parameters": { + "Right": 1 + }, + "nullable": [ + false, + false, + false + ] + } + }, + "b8e05a65bf3a6f0d4173e0c27cb5491e4f5d1615407c9b46651fcc2dd5970feb": { + "query": "\n SELECT timestamp, up\n FROM gateway_ipv4_status\n JOIN gateway_details\n ON gateway_ipv4_status.gateway_details_id = gateway_details.id\n WHERE gateway_details.pub_key=? AND gateway_ipv4_status.timestamp > ?;\n ", + "describe": { + "columns": [ + { + "name": "timestamp", + "ordinal": 0, + "type_info": "Int64" + }, + { + "name": "up", + "ordinal": 1, + "type_info": "Bool" + } + ], + "parameters": { + "Right": 2 + }, + "nullable": [ + false, + false + ] + } + }, + "bed01502a7770069c0ad5f6bc13cab7f08ea219d71f4ab3e594cde5809e6f4be": { + "query": "\n INSERT INTO mixnode_ipv6_status (mixnode_details_id, up, timestamp) VALUES (?, ?, ?);\n ", + "describe": { + "columns": [], + "parameters": { + "Right": 3 + }, + "nullable": [] + } + }, + "d378bade0e786e3efdda4a02a5f403da9a23c20f4eecb86fceb18930cf2cceec": { + "query": "\n SELECT DISTINCT pub_key, owner, id\n FROM mixnode_details\n JOIN mixnode_ipv4_status\n ON mixnode_details.id = mixnode_ipv4_status.mixnode_details_id\n WHERE EXISTS (\n SELECT 1 FROM mixnode_ipv4_status WHERE timestamp > ?\n )\n ", + "describe": { + "columns": [ + { + "name": "pub_key", + "ordinal": 0, + "type_info": "Text" + }, + { + "name": "owner", + "ordinal": 1, + "type_info": "Text" + }, + { + "name": "id", + "ordinal": 2, + "type_info": "Int64" + } + ], + "parameters": { + "Right": 1 + }, + "nullable": [ + false, + false, + false + ] + } + }, + "d4b9a3e22a1230635523aec12a0b5a980e99949232369ebd748c70fed3f4532e": { + "query": "\n INSERT OR IGNORE INTO mixnode_details(pub_key, owner) VALUES (?, ?);\n SELECT id FROM mixnode_details WHERE pub_key = ?;\n ", + "describe": { + "columns": [ + { + "name": "id", + "ordinal": 0, + "type_info": "Int64" + } + ], + "parameters": { + "Right": 3 + }, + "nullable": [ + false + ] + } + }, + "d85a0985f6e0d818217f6733a1df0c9b83821ecf0e824b0a606c3723ad87362a": { + "query": "\n SELECT timestamp, up\n FROM gateway_ipv6_status\n JOIN gateway_details\n ON gateway_ipv6_status.gateway_details_id = gateway_details.id\n WHERE gateway_details.pub_key=? AND gateway_ipv6_status.timestamp > ?;\n ", + "describe": { + "columns": [ + { + "name": "timestamp", + "ordinal": 0, + "type_info": "Int64" + }, + { + "name": "up", + "ordinal": 1, + "type_info": "Bool" + } + ], + "parameters": { + "Right": 2 + }, + "nullable": [ + false, + false + ] + } + }, + "e55db4def70689c061d0e07115a21068431575afd2be8afafce1a7fb13507e7e": { + "query": "SELECT EXISTS (SELECT 1 FROM mixnode_historical_uptime WHERE date = ?) AS 'exists'", + "describe": { + "columns": [ + { + "name": "exists", + "ordinal": 0, + "type_info": "Int" + } + ], + "parameters": { + "Right": 1 + }, + "nullable": [ + false + ] + } + }, + "e72d78b175ee7265caad12555d6c72dbf036a842b8136d94373c78905d19b111": { + "query": "INSERT INTO gateway_historical_uptime(gateway_details_id, date, ipv4_uptime, ipv6_uptime) VALUES (?, ?, ?, ?)", + "describe": { + "columns": [], + "parameters": { + "Right": 4 + }, + "nullable": [] + } + }, + "f384fdebb41a03b626b39de62a8fe53ebba0c02500a91442af168394910c40db": { + "query": "\n SELECT timestamp, up\n FROM gateway_ipv6_status\n WHERE gateway_details_id=? AND timestamp > ?;\n ", + "describe": { + "columns": [ + { + "name": "timestamp", + "ordinal": 0, + "type_info": "Int64" + }, + { + "name": "up", + "ordinal": 1, + "type_info": "Bool" + } + ], + "parameters": { + "Right": 2 + }, + "nullable": [ + false, + false + ] + } + } +} \ No newline at end of file diff --git a/validator-api/src/cache.rs b/validator-api/src/cache.rs deleted file mode 100644 index b317af99bf..0000000000 --- a/validator-api/src/cache.rs +++ /dev/null @@ -1,65 +0,0 @@ -use anyhow::Result; -use mixnet_contract::{GatewayBond, MixNodeBond}; -use serde::Serialize; -use std::time::{SystemTime, UNIX_EPOCH}; -use tokio::sync::RwLock; -use validator_client::Client; - -pub struct ValidatorCache { - mixnodes: RwLock>>, - gateways: RwLock>>, - validator_client: Client, -} - -#[derive(Default, Serialize, Clone)] -pub struct Cache { - value: T, - #[allow(dead_code)] - as_at: u64, -} - -impl Cache { - fn set(&mut self, value: T) { - self.value = value; - self.as_at = SystemTime::now() - .duration_since(UNIX_EPOCH) - .unwrap() - .as_secs() - } - - #[allow(dead_code)] - pub fn get(&self) -> T { - self.value.clone() - } -} - -impl ValidatorCache { - pub fn init(validators_rest_uris: Vec, mixnet_contract: String) -> Self { - let config = validator_client::Config::new(validators_rest_uris, mixnet_contract); - let validator_client = validator_client::Client::new(config); - ValidatorCache { - mixnodes: RwLock::new(Cache::default()), - gateways: RwLock::new(Cache::default()), - validator_client, - } - } - - pub async fn refresh_cache(&self) -> Result<()> { - let (mixnodes, gateways) = tokio::join!( - self.validator_client.get_mix_nodes(), - self.validator_client.get_gateways() - ); - self.mixnodes.write().await.set(mixnodes?); - self.gateways.write().await.set(gateways?); - - Ok(()) - } - - pub async fn mixnodes(&self) -> Cache> { - self.mixnodes.read().await.clone() - } - - pub async fn gateways(&self) -> Cache> { - self.gateways.read().await.clone() - } -} diff --git a/validator-api/src/cache/mod.rs b/validator-api/src/cache/mod.rs new file mode 100644 index 0000000000..0f121f7120 --- /dev/null +++ b/validator-api/src/cache/mod.rs @@ -0,0 +1,146 @@ +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 + +use anyhow::Result; +use mixnet_contract::{GatewayBond, MixNodeBond}; +use rocket::fairing::AdHoc; +use serde::Serialize; +use std::sync::atomic::{AtomicBool, Ordering}; +use std::sync::Arc; +use std::time::{Duration, SystemTime, UNIX_EPOCH}; +use tokio::sync::RwLock; +use tokio::time; +use validator_client::Client; + +pub(crate) mod routes; + +pub struct ValidatorCacheRefresher { + validator_client: Client, + cache: ValidatorCache, + caching_interval: Duration, +} + +#[derive(Clone)] +pub struct ValidatorCache { + inner: Arc, +} + +struct ValidatorCacheInner { + initialised: AtomicBool, + mixnodes: RwLock>>, + gateways: RwLock>>, +} + +#[derive(Default, Serialize, Clone)] +pub struct Cache { + value: T, + #[allow(dead_code)] + as_at: u64, +} + +impl Cache { + fn set(&mut self, value: T) { + self.value = value; + self.as_at = SystemTime::now() + .duration_since(UNIX_EPOCH) + .unwrap() + .as_secs() + } + + pub fn into_inner(self) -> T { + self.value + } +} + +impl ValidatorCacheRefresher { + pub(crate) fn new( + validators_rest_uris: Vec, + mixnet_contract: String, + caching_interval: Duration, + cache: ValidatorCache, + ) -> Self { + let config = validator_client::Config::new(validators_rest_uris, mixnet_contract); + let validator_client = validator_client::Client::new(config); + + ValidatorCacheRefresher { + validator_client, + cache, + caching_interval, + } + } + + async fn refresh_cache(&self) -> Result<()> { + let (mixnodes, gateways) = tokio::try_join!( + self.validator_client.get_mix_nodes(), + self.validator_client.get_gateways() + )?; + + info!( + "Updating validator cache. There are {} mixnodes and {} gateways", + mixnodes.len(), + gateways.len() + ); + + self.cache.update_cache(mixnodes, gateways).await; + + Ok(()) + } + + pub(crate) async fn run(&self) { + let mut interval = time::interval(self.caching_interval); + loop { + interval.tick().await; + if let Err(err) = self.refresh_cache().await { + error!("Failed to refresh validator cache - {}", err); + } else { + // relaxed memory ordering is fine here. worst case scenario network monitor + // will just have to wait for an additional backoff to see the change. + // And so this will not really incur any performance penalties by setting it every loop iteration + self.cache.inner.initialised.store(true, Ordering::Relaxed) + } + } + } +} + +impl ValidatorCache { + fn new() -> Self { + ValidatorCache { + inner: Arc::new(ValidatorCacheInner::new()), + } + } + + pub fn stage() -> AdHoc { + AdHoc::on_ignite("Validator Cache Stage", |rocket| async { + rocket + .manage(Self::new()) + .mount("/v1", routes![routes::get_mixnodes, routes::get_gateways]) + }) + } + + async fn update_cache(&self, mixnodes: Vec, gateways: Vec) { + self.inner.mixnodes.write().await.set(mixnodes); + self.inner.gateways.write().await.set(gateways); + } + + pub async fn mixnodes(&self) -> Cache> { + self.inner.mixnodes.read().await.clone() + } + + pub async fn gateways(&self) -> Cache> { + self.inner.gateways.read().await.clone() + } + + pub fn initialised(&self) -> bool { + self.inner.initialised.load(Ordering::Relaxed) + } +} + +impl ValidatorCacheInner { + fn new() -> Self { + ValidatorCacheInner { + initialised: AtomicBool::new(false), + mixnodes: RwLock::new(Cache::default()), + gateways: RwLock::new(Cache::default()), + } + } +} diff --git a/validator-api/src/cache/routes.rs b/validator-api/src/cache/routes.rs new file mode 100644 index 0000000000..62864d84af --- /dev/null +++ b/validator-api/src/cache/routes.rs @@ -0,0 +1,17 @@ +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 + +use crate::cache::{Cache, ValidatorCache}; +use mixnet_contract::{GatewayBond, MixNodeBond}; +use rocket::serde::json::Json; +use rocket::State; + +#[get("/mixnodes")] +pub(crate) async fn get_mixnodes(cache: &State) -> Json>> { + Json(cache.mixnodes().await) +} + +#[get("/gateways")] +pub(crate) async fn get_gateways(cache: &State) -> Json>> { + Json(cache.gateways().await) +} diff --git a/validator-api/src/config/mod.rs b/validator-api/src/config/mod.rs index e07448f259..4793d72d5f 100644 --- a/validator-api/src/config/mod.rs +++ b/validator-api/src/config/mod.rs @@ -9,15 +9,14 @@ use std::time::Duration; mod template; -const DEFAULT_VALIDATOR_REST_ENDPOINTS: &[&str] = &[ - "http://testnet-milhon-validator1.nymtech.net:1317", - "http://testnet-milhon-validator2.nymtech.net:1317", -]; +const DEFAULT_VALIDATOR_REST_ENDPOINTS: &[&str] = &["http://localhost:1317"]; const DEFAULT_MIXNET_CONTRACT: &str = "punk10pyejy66429refv3g35g2t7am0was7yalwrzen"; -const DEFAULT_NODE_STATUS_API: &str = "http://localhost:8081"; const DEFAULT_GATEWAY_SENDING_RATE: usize = 500; const DEFAULT_MAX_CONCURRENT_GATEWAY_CLIENTS: usize = 50; +const DEFAULT_PACKET_DELIVERY_TIMEOUT: Duration = Duration::from_secs(20); +const DEFAULT_MONITOR_RUN_INTERVAL: Duration = Duration::from_secs(15 * 60); +const DEFAULT_GATEWAY_PING_INTERVAL: Duration = Duration::from_secs(60); const DEFAULT_GATEWAY_RESPONSE_TIMEOUT: Duration = Duration::from_millis(1_500); const DEFAULT_GATEWAY_CONNECTION_TIMEOUT: Duration = Duration::from_millis(2_500); @@ -104,10 +103,14 @@ pub struct NetworkMonitor { /// Location of .json file containing IPv6 'good' network topology good_v6_topology_file: PathBuf, - // TODO: another field that will be replaced very soon when node status api is moved - // to this process - /// Address of the node status api to submit results to. Most likely it's a local address - node_status_api_url: String, + /// Specifies the interval at which the network monitor sends the test packets. + #[serde(with = "humantime_serde")] + run_interval: Duration, + + /// Specifies interval at which we should be sending ping packets to all active gateways + /// in order to keep the websocket connections alive. + #[serde(with = "humantime_serde")] + gateway_ping_interval: Duration, /// Specifies maximum rate (in packets per second) of test packets being sent to gateway gateway_sending_rate: usize, @@ -123,6 +126,11 @@ pub struct NetworkMonitor { /// Maximum allowed time for the gateway connection to get established. #[serde(with = "humantime_serde")] gateway_connection_timeout: Duration, + + /// Specifies the duration the monitor is going to wait after sending all measurement + /// packets before declaring nodes unreachable. + #[serde(with = "humantime_serde")] + packet_delivery_timeout: Duration, } impl NetworkMonitor { @@ -142,11 +150,13 @@ impl Default for NetworkMonitor { print_detailed_report: false, good_v4_topology_file: Self::default_good_v4_topology_file(), good_v6_topology_file: Self::default_good_v6_topology_file(), - node_status_api_url: DEFAULT_NODE_STATUS_API.to_string(), + run_interval: DEFAULT_MONITOR_RUN_INTERVAL, + gateway_ping_interval: DEFAULT_GATEWAY_PING_INTERVAL, gateway_sending_rate: DEFAULT_GATEWAY_SENDING_RATE, max_concurrent_gateway_clients: DEFAULT_MAX_CONCURRENT_GATEWAY_CLIENTS, gateway_response_timeout: DEFAULT_GATEWAY_RESPONSE_TIMEOUT, gateway_connection_timeout: DEFAULT_GATEWAY_CONNECTION_TIMEOUT, + packet_delivery_timeout: DEFAULT_PACKET_DELIVERY_TIMEOUT, } } } @@ -154,12 +164,21 @@ impl Default for NetworkMonitor { #[derive(Debug, Deserialize, PartialEq, Serialize)] #[serde(deny_unknown_fields)] pub struct NodeStatusAPI { - // does not yet exist + /// Path to the database file containing uptime statuses for all mixnodes and gateways. + database_path: PathBuf, +} + +impl NodeStatusAPI { + fn default_database_path() -> PathBuf { + Config::default_data_directory(None).join("db.sqlite") + } } impl Default for NodeStatusAPI { fn default() -> Self { - NodeStatusAPI {} + NodeStatusAPI { + database_path: Self::default_database_path(), + } } } @@ -213,21 +232,6 @@ impl Config { self } - pub fn with_custom_node_status_api>(mut self, node_status_api: S) -> Self { - self.network_monitor.node_status_api_url = node_status_api.into(); - self - } - - pub fn with_gateway_sending_rate(mut self, rate: usize) -> Self { - self.network_monitor.gateway_sending_rate = rate; - self - } - - pub fn with_caching_interval(mut self, interval: Duration) -> Self { - self.topology_cacher.caching_interval = interval; - self - } - pub fn get_network_monitor_enabled(&self) -> bool { self.network_monitor.enabled } @@ -252,8 +256,16 @@ impl Config { self.base.mixnet_contract_address.clone() } - pub fn get_node_status_api_url(&self) -> String { - self.network_monitor.node_status_api_url.clone() + pub fn get_network_monitor_run_interval(&self) -> Duration { + self.network_monitor.run_interval + } + + pub fn get_gateway_ping_interval(&self) -> Duration { + self.network_monitor.gateway_ping_interval + } + + pub fn get_packet_delivery_timeout(&self) -> Duration { + self.network_monitor.packet_delivery_timeout } pub fn get_gateway_sending_rate(&self) -> usize { @@ -275,4 +287,8 @@ impl Config { pub fn get_caching_interval(&self) -> Duration { self.topology_cacher.caching_interval } + + pub fn get_node_status_api_database_path(&self) -> PathBuf { + self.node_status_api.database_path.clone() + } } diff --git a/validator-api/src/config/template.rs b/validator-api/src/config/template.rs index ad87218980..201f6625ba 100644 --- a/validator-api/src/config/template.rs +++ b/validator-api/src/config/template.rs @@ -36,8 +36,12 @@ good_v4_topology_file = '{{ network_monitor.good_v4_topology_file }}' # Location of .json file containing IPv6 'good' network topology good_v6_topology_file = '{{ network_monitor.good_v6_topology_file }}' -# Address of the node status api to submit results to. Most likely it's a local address -node_status_api_url = '{{ network_monitor.node_status_api_url }}' +# Specifies the interval at which the network monitor sends the test packets. +run_interval = '{{ network_monitor.run_interval }}' + +# Specifies interval at which we should be sending ping packets to all active gateways +# in order to keep the websocket connections alive. +gateway_ping_interval = '{{ network_monitor.gateway_ping_interval }}' # Specifies maximum rate (in packets per second) of test packets being sent to gateway gateway_sending_rate = {{ network_monitor.gateway_sending_rate }} @@ -51,6 +55,14 @@ gateway_response_timeout = '{{ network_monitor.gateway_response_timeout }}' # Maximum allowed time for the gateway connection to get established. gateway_connection_timeout = '{{ network_monitor.gateway_connection_timeout }}' +# Specifies the duration the monitor is going to wait after sending all measurement +# packets before declaring nodes unreachable. +packet_delivery_timeout = '{{ network_monitor.packet_delivery_timeout }}' + +[node_status_api] + +# Path to the database file containing uptime statuses for all mixnodes and gateways. +database_path = '{{ node_status_api.database_path }}' "# } diff --git a/validator-api/src/main.rs b/validator-api/src/main.rs index f3bb05b41b..bda832366b 100644 --- a/validator-api/src/main.rs +++ b/validator-api/src/main.rs @@ -4,55 +4,32 @@ #[macro_use] extern crate rocket; -use rocket::http::Method; -use rocket::serde::json::Json; -use rocket::State; -use rocket_cors::{AllowedHeaders, AllowedOrigins}; - +use crate::cache::ValidatorCacheRefresher; use crate::config::Config; -use crate::monitor::preparer::PacketPreparer; -use crate::monitor::processor::{ - ReceivedProcessor, ReceivedProcessorReceiver, ReceivedProcessorSender, -}; -use crate::monitor::receiver::{ - GatewayClientUpdateReceiver, GatewayClientUpdateSender, PacketReceiver, -}; -use crate::monitor::sender::PacketSender; -use crate::monitor::summary_producer::SummaryProducer; -use crate::tested_network::good_topology::parse_topology_file; -use crate::tested_network::TestedNetwork; +use crate::network_monitor::new_monitor_runnables; +use crate::network_monitor::tested_network::good_topology::parse_topology_file; +use crate::node_status_api::storage::NodeStatusStorage; use ::config::NymConfig; use anyhow::Result; -use cache::{Cache, ValidatorCache}; +use cache::ValidatorCache; use clap::{App, Arg, ArgMatches}; -use crypto::asymmetric::{encryption, identity}; -use futures::channel::mpsc; use log::info; -use mixnet_contract::{GatewayBond, MixNodeBond}; -use nymsphinx::addressing::clients::Recipient; -use std::sync::Arc; -use std::time::Duration; -use tokio::time; -use topology::NymTopology; +use rocket::http::Method; +use rocket_cors::{AllowedHeaders, AllowedOrigins, Cors}; +use std::process; -mod cache; -mod chunker; -mod config; -pub(crate) mod gateways_reader; -mod monitor; +pub(crate) mod cache; +pub(crate) mod config; +mod network_monitor; mod node_status_api; -mod test_packet; -mod tested_network; const MONITORING_ENABLED: &str = "enable-monitor"; const V4_TOPOLOGY_ARG: &str = "v4-topology-filepath"; const V6_TOPOLOGY_ARG: &str = "v6-topology-filepath"; const VALIDATORS_ARG: &str = "validators"; -const NODE_STATUS_API_ARG: &str = "node-status-api"; const DETAILED_REPORT_ARG: &str = "detailed-report"; -const GATEWAY_SENDING_RATE_ARG: &str = "gateway-rate"; const MIXNET_CONTRACT_ARG: &str = "mixnet-contract"; -const CACHE_INTERVAL_ARG: &str = "cache-interval"; +const WRITE_CONFIG_ARG: &str = "save-config"; pub(crate) const PENALISE_OUTDATED: bool = false; @@ -69,14 +46,12 @@ fn parse_args<'a>() -> ArgMatches<'a> { .help("location of .json file containing IPv4 'good' network topology") .long(V4_TOPOLOGY_ARG) .takes_value(true) - .required(true), ) .arg( Arg::with_name(V6_TOPOLOGY_ARG) .help("location of .json file containing IPv6 'good' network topology") .long(V6_TOPOLOGY_ARG) .takes_value(true) - .required(true), ) .arg( Arg::with_name(VALIDATORS_ARG) @@ -89,27 +64,16 @@ fn parse_args<'a>() -> ArgMatches<'a> { .help("Address of the validator contract managing the network") .takes_value(true), ) - .arg( - Arg::with_name(NODE_STATUS_API_ARG) - .help("Address of the node status api to submit results to. Most likely it's a local address") - .long(NODE_STATUS_API_ARG) - .takes_value(true) - ) .arg( Arg::with_name(DETAILED_REPORT_ARG) .help("specifies whether a detailed report should be printed after each run") .long(DETAILED_REPORT_ARG) ) - .arg(Arg::with_name(GATEWAY_SENDING_RATE_ARG) - .help("specifies maximum rate (in packets per second) of test packets being sent to gateway") - .takes_value(true) - .long(GATEWAY_SENDING_RATE_ARG) - .short("r") + .arg( + Arg::with_name(WRITE_CONFIG_ARG) + .help("specifies whether a config file based on provided arguments should be saved to a file") + .long(WRITE_CONFIG_ARG) ) - .arg(Arg::with_name(CACHE_INTERVAL_ARG) - .help("Specified rate, in seconds, at which cache will be refreshed, global for all cache") - .takes_value(true) - .long(CACHE_INTERVAL_ARG)) .get_matches() } @@ -123,76 +87,6 @@ async fn wait_for_interrupt() { println!("Received SIGINT - the network monitor will terminate now"); } -fn new_packet_preparer( - validator_client: validator_client::Client, - tested_network: TestedNetwork, - test_mixnode_sender: Recipient, - self_public_identity: identity::PublicKey, - self_public_encryption: encryption::PublicKey, -) -> PacketPreparer { - PacketPreparer::new( - validator_client, - tested_network, - test_mixnode_sender, - self_public_identity, - self_public_encryption, - ) -} - -fn new_packet_sender( - config: &Config, - gateways_status_updater: GatewayClientUpdateSender, - local_identity: Arc, - max_sending_rate: usize, -) -> PacketSender { - PacketSender::new( - gateways_status_updater, - local_identity, - config.get_gateway_response_timeout(), - config.get_gateway_connection_timeout(), - config.get_max_concurrent_gateway_clients(), - max_sending_rate, - ) -} - -fn new_received_processor( - packets_receiver: ReceivedProcessorReceiver, - client_encryption_keypair: Arc, -) -> ReceivedProcessor { - ReceivedProcessor::new(packets_receiver, client_encryption_keypair) -} - -fn new_summary_producer(detailed_report: bool) -> SummaryProducer { - // right now always print the basic report. If we feel like we need to change it, it can - // be easily adjusted by adding some flag or something - let summary_producer = SummaryProducer::default().with_report(); - if detailed_report { - summary_producer.with_detailed_report() - } else { - summary_producer - } -} - -fn new_packet_receiver( - gateways_status_updater: GatewayClientUpdateReceiver, - processor_packets_sender: ReceivedProcessorSender, -) -> PacketReceiver { - PacketReceiver::new(gateways_status_updater, processor_packets_sender) -} - -fn new_validator_client( - validator_rest_uris: Vec, - mixnet_contract: &str, -) -> validator_client::Client { - let config = validator_client::Config::new(validator_rest_uris, mixnet_contract); - validator_client::Client::new(config) -} - -fn new_node_status_api_client>(base_url: S) -> node_status_api::Client { - let config = node_status_api::Config::new(base_url); - node_status_api::Client::new(config) -} - fn setup_logging() { let mut log_builder = pretty_env_logger::formatted_timed_builder(); if let Ok(s) = ::std::env::var("RUST_LOG") { @@ -214,59 +108,6 @@ fn setup_logging() { .init(); } -fn check_if_up_to_date(v4_topology: &NymTopology, v6_topology: &NymTopology) { - let monitor_version = env!("CARGO_PKG_VERSION"); - for (_, layer_mixes) in v4_topology.mixes().iter() { - for mix in layer_mixes.iter() { - if !version_checker::is_minor_version_compatible(monitor_version, &*mix.version) { - panic!( - "Our good topology is not compatible with monitor! Mix runs {}, we have {}", - mix.version, monitor_version - ) - } - } - } - - for gateway in v4_topology.gateways().iter() { - if !version_checker::is_minor_version_compatible(monitor_version, &*gateway.version) { - panic!( - "Our good topology is not compatible with monitor! Gateway runs {}, we have {}", - gateway.version, monitor_version - ) - } - } - - for (_, layer_mixes) in v6_topology.mixes().iter() { - for mix in layer_mixes.iter() { - if !version_checker::is_minor_version_compatible(monitor_version, &*mix.version) { - panic!( - "Our good topology is not compatible with monitor! Mix runs {}, we have {}", - mix.version, monitor_version - ) - } - } - } - - for gateway in v6_topology.gateways().iter() { - if !version_checker::is_minor_version_compatible(monitor_version, &*gateway.version) { - panic!( - "Our good topology is not compatible with monitor! Gateway runs {}, we have {}", - gateway.version, monitor_version - ) - } - } -} - -#[get("/mixnodes")] -async fn get_mixnodes(cache: &State>) -> Json>> { - Json(cache.mixnodes().await) -} - -#[get("/gateways")] -async fn get_gateways(cache: &State>) -> Json>> { - Json(cache.gateways().await) -} - fn override_config(mut config: Config, matches: &ArgMatches) -> Config { fn parse_validators(raw: &str) -> Vec { raw.split(',') @@ -290,10 +131,6 @@ fn override_config(mut config: Config, matches: &ArgMatches) -> Config { config = config.with_custom_validators(parse_validators(raw_validators)); } - if let Some(node_status_api_uri) = matches.value_of(NODE_STATUS_API_ARG) { - config = config.with_custom_node_status_api(node_status_api_uri) - } - if let Some(mixnet_contract) = matches.value_of(MIXNET_CONTRACT_ARG) { config = config.with_custom_mixnet_contract(mixnet_contract) } @@ -302,158 +139,18 @@ fn override_config(mut config: Config, matches: &ArgMatches) -> Config { config = config.detailed_network_monitor_report(true) } - if let Some(sending_rate) = matches - .value_of(GATEWAY_SENDING_RATE_ARG) - .map(|v| v.parse().unwrap()) - { - config = config.with_gateway_sending_rate(sending_rate) - } - - if let Some(caching_interval_secs) = matches - .value_of(CACHE_INTERVAL_ARG) - .map(|v| v.parse().unwrap()) - { - config = config.with_caching_interval(Duration::from_secs(caching_interval_secs)) + if matches.is_present(WRITE_CONFIG_ARG) { + info!("Saving the configuration to a file"); + if let Err(err) = config.save_to_file(None) { + error!("Failed to write config to a file - {}", err); + process::exit(1) + } } config } -#[tokio::main] -async fn main() -> Result<()> { - setup_logging(); - - println!("Starting validator api..."); - - let config = match Config::load_from_file(None) { - Ok(cfg) => cfg, - Err(_) => { - warn!( - "Configuration file could not be found in {}. Using the default values.", - Config::default_config_file_path(None) - .into_os_string() - .into_string() - .unwrap() - ); - Config::new() - } - }; - - let matches = parse_args(); - let config = override_config(config, &matches); - - if config.get_network_monitor_enabled() { - info!("Network monitor starting..."); - - let v4_topology = parse_topology_file(config.get_v4_good_topology_file()); - let v6_topology = parse_topology_file(config.get_v6_good_topology_file()); - check_if_up_to_date(&v4_topology, &v6_topology); - - info!("* validator servers: {:?}", config.get_validators_urls()); - info!( - "* node status api server: {}", - config.get_node_status_api_url() - ); - info!( - "* mixnet contract: {}", - config.get_mixnet_contract_address() - ); - info!( - "* detailed report printing: {}", - config.get_detailed_report() - ); - info!( - "* gateway sending rate: {} packets/s", - config.get_gateway_sending_rate() - ); - - // TODO: in the future I guess this should somehow change to distribute the load - let tested_mix_gateway = v4_topology.gateways()[0].clone(); - info!( - "* gateway for testing mixnodes: {}", - tested_mix_gateway.identity_key.to_base58_string() - ); - - // TODO: those keys change constant throughout the whole execution of the monitor. - // and on top of that, they are used with ALL the gateways -> presumably this should change - // in the future - let mut rng = rand::rngs::OsRng; - - let identity_keypair = Arc::new(identity::KeyPair::new(&mut rng)); - let encryption_keypair = Arc::new(encryption::KeyPair::new(&mut rng)); - - let test_mixnode_sender = Recipient::new( - *identity_keypair.public_key(), - *encryption_keypair.public_key(), - tested_mix_gateway.identity_key, - ); - - let tested_network = TestedNetwork::new_good(v4_topology, v6_topology); - let validator_client = new_validator_client( - config.get_validators_urls(), - &config.get_mixnet_contract_address(), - ); - let node_status_api_client = new_node_status_api_client(config.get_node_status_api_url()); - - let (gateway_status_update_sender, gateway_status_update_receiver) = mpsc::unbounded(); - let (received_processor_sender_channel, received_processor_receiver_channel) = - mpsc::unbounded(); - - let packet_preparer = new_packet_preparer( - validator_client, - tested_network.clone(), - test_mixnode_sender, - *identity_keypair.public_key(), - *encryption_keypair.public_key(), - ); - - let packet_sender = new_packet_sender( - &config, - gateway_status_update_sender, - Arc::clone(&identity_keypair), - config.get_gateway_sending_rate(), - ); - let received_processor = new_received_processor( - received_processor_receiver_channel, - Arc::clone(&encryption_keypair), - ); - let summary_producer = new_summary_producer(config.get_detailed_report()); - let mut packet_receiver = new_packet_receiver( - gateway_status_update_receiver, - received_processor_sender_channel, - ); - - let mut monitor = monitor::Monitor::new( - packet_preparer, - packet_sender, - received_processor, - summary_producer, - node_status_api_client, - tested_network, - ); - - tokio::spawn(async move { packet_receiver.run().await }); - - tokio::spawn(async move { monitor.run().await }); - } else { - info!("Network monitoring is disabled.") - } - - let validator_cache = Arc::new(ValidatorCache::init( - config.get_validators_urls(), - config.get_mixnet_contract_address(), - )); - - let write_validator_cache = Arc::clone(&validator_cache); - - tokio::spawn(async move { - let mut interval = time::interval(config.get_caching_interval()); - loop { - interval.tick().await; - write_validator_cache.refresh_cache().await.unwrap() - } - }); - +fn setup_cors() -> Result { let allowed_origins = AllowedOrigins::all(); // You can also deserialize this @@ -469,14 +166,88 @@ async fn main() -> Result<()> { } .to_cors()?; - rocket::build() - .attach(cors) - .mount("/v1", routes![get_mixnodes, get_gateways]) - .manage(validator_cache) - .ignite() - .await? - .launch() - .await?; + Ok(cors) +} + +#[tokio::main] +async fn main() -> Result<()> { + setup_logging(); + + println!("Starting validator api..."); + + // try to load config from the file, if it doesn't exist, use default values + let config = match Config::load_from_file(None) { + Ok(cfg) => cfg, + Err(_) => { + warn!( + "Configuration file could not be found at {}. Using the default values.", + Config::default_config_file_path(None) + .into_os_string() + .into_string() + .unwrap() + ); + Config::new() + } + }; + + let matches = parse_args(); + let config = override_config(config, &matches); + + // let's build our rocket! + let rocket = rocket::build() + .attach(setup_cors()?) + .attach(ValidatorCache::stage()); + + // see if we should start up network monitor and ignite our rocket + let rocket = if config.get_network_monitor_enabled() { + // don't start our node-status api if we're not running the monitor - we can't get + // report data otherwise + let rocket = rocket + .attach(node_status_api::stage( + config.get_node_status_api_database_path(), + )) + .ignite() + .await?; + + info!("Network monitor starting..."); + + // get instances of managed states + let node_status_storage = rocket.state::().unwrap().clone(); + let validator_cache = rocket.state::().unwrap().clone(); + + let v4_topology = parse_topology_file(config.get_v4_good_topology_file()); + let v6_topology = parse_topology_file(config.get_v6_good_topology_file()); + network_monitor::check_if_up_to_date(&v4_topology, &v6_topology); + + let network_monitor_runnables = new_monitor_runnables( + &config, + v4_topology, + v6_topology, + node_status_storage, + validator_cache, + ); + network_monitor_runnables.spawn_tasks(); + + rocket + } else { + info!("Network monitoring is disabled."); + rocket.ignite().await? + }; + + let validator_cache = rocket.state::().unwrap().clone(); + + let validator_cache_refresher = ValidatorCacheRefresher::new( + config.get_validators_urls(), + config.get_mixnet_contract_address(), + config.get_caching_interval(), + validator_cache, + ); + + // spawn our cacher + tokio::spawn(async move { validator_cache_refresher.run().await }); + + // and launch the rocket + tokio::spawn(rocket.launch()); wait_for_interrupt().await; diff --git a/validator-api/src/chunker.rs b/validator-api/src/network_monitor/chunker.rs similarity index 97% rename from validator-api/src/chunker.rs rename to validator-api/src/network_monitor/chunker.rs index b2bc7c1736..0b7472bd69 100644 --- a/validator-api/src/chunker.rs +++ b/validator-api/src/network_monitor/chunker.rs @@ -1,4 +1,4 @@ -// Copyright 2020 - Nym Technologies SA +// Copyright 2021 - Nym Technologies SA // SPDX-License-Identifier: Apache-2.0 use nymsphinx::forwarding::packet::MixPacket; diff --git a/validator-api/src/gateways_reader.rs b/validator-api/src/network_monitor/gateways_reader.rs similarity index 100% rename from validator-api/src/gateways_reader.rs rename to validator-api/src/network_monitor/gateways_reader.rs diff --git a/validator-api/src/network_monitor/mod.rs b/validator-api/src/network_monitor/mod.rs new file mode 100644 index 0000000000..62ff5f43bf --- /dev/null +++ b/validator-api/src/network_monitor/mod.rs @@ -0,0 +1,220 @@ +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 + +use crate::cache::ValidatorCache; +use crate::config::Config; +use crate::network_monitor::monitor::preparer::PacketPreparer; +use crate::network_monitor::monitor::processor::{ + ReceivedProcessor, ReceivedProcessorReceiver, ReceivedProcessorSender, +}; +use crate::network_monitor::monitor::receiver::{ + GatewayClientUpdateReceiver, GatewayClientUpdateSender, PacketReceiver, +}; +use crate::network_monitor::monitor::sender::PacketSender; +use crate::network_monitor::monitor::summary_producer::SummaryProducer; +use crate::network_monitor::monitor::Monitor; +use crate::network_monitor::tested_network::TestedNetwork; +use crate::node_status_api::storage::NodeStatusStorage; +use crypto::asymmetric::{encryption, identity}; +use futures::channel::mpsc; +use nymsphinx::addressing::clients::Recipient; +use std::sync::Arc; +use topology::NymTopology; + +pub(crate) mod chunker; +pub(crate) mod gateways_reader; +pub(crate) mod monitor; +pub(crate) mod test_packet; +pub(crate) mod tested_network; + +pub(crate) struct NetworkMonitorRunnables { + monitor: Monitor, + packet_receiver: PacketReceiver, +} + +impl NetworkMonitorRunnables { + // TODO: note, that is not exactly doing what we want, because when + // `ReceivedProcessor` is constructed, it already spawns a future + // this needs to be refactored! + pub(crate) fn spawn_tasks(self) { + let mut packet_receiver = self.packet_receiver; + let mut monitor = self.monitor; + tokio::spawn(async move { packet_receiver.run().await }); + tokio::spawn(async move { monitor.run().await }); + } +} + +pub(crate) fn new_monitor_runnables( + config: &Config, + v4_topology: NymTopology, + v6_topology: NymTopology, + node_status_storage: NodeStatusStorage, + validator_cache: ValidatorCache, +) -> NetworkMonitorRunnables { + // TODO: in the future I guess this should somehow change to distribute the load + let tested_mix_gateway = v4_topology.gateways()[0].clone(); + info!( + "* gateway for testing mixnodes: {}", + tested_mix_gateway.identity_key.to_base58_string() + ); + + let tested_network = TestedNetwork::new_good(v4_topology, v6_topology); + + // TODO: those keys change constant throughout the whole execution of the monitor. + // and on top of that, they are used with ALL the gateways -> presumably this should change + // in the future + let mut rng = rand::rngs::OsRng; + + let identity_keypair = Arc::new(identity::KeyPair::new(&mut rng)); + let encryption_keypair = Arc::new(encryption::KeyPair::new(&mut rng)); + + let test_mixnode_sender = Recipient::new( + *identity_keypair.public_key(), + *encryption_keypair.public_key(), + tested_mix_gateway.identity_key, + ); + + let (gateway_status_update_sender, gateway_status_update_receiver) = mpsc::unbounded(); + let (received_processor_sender_channel, received_processor_receiver_channel) = + mpsc::unbounded(); + + let packet_preparer = new_packet_preparer( + validator_cache, + tested_network.clone(), + test_mixnode_sender, + *identity_keypair.public_key(), + *encryption_keypair.public_key(), + ); + + let packet_sender = new_packet_sender( + config, + gateway_status_update_sender, + Arc::clone(&identity_keypair), + config.get_gateway_sending_rate(), + ); + + let received_processor = new_received_processor( + received_processor_receiver_channel, + Arc::clone(&encryption_keypair), + ); + let summary_producer = new_summary_producer(config.get_detailed_report()); + let packet_receiver = new_packet_receiver( + gateway_status_update_receiver, + received_processor_sender_channel, + ); + + let monitor = monitor::Monitor::new( + config, + packet_preparer, + packet_sender, + received_processor, + summary_producer, + node_status_storage, + tested_network, + ); + + NetworkMonitorRunnables { + monitor, + packet_receiver, + } +} + +fn new_packet_preparer( + validator_cache: ValidatorCache, + tested_network: TestedNetwork, + test_mixnode_sender: Recipient, + self_public_identity: identity::PublicKey, + self_public_encryption: encryption::PublicKey, +) -> PacketPreparer { + PacketPreparer::new( + validator_cache, + tested_network, + test_mixnode_sender, + self_public_identity, + self_public_encryption, + ) +} + +fn new_packet_sender( + config: &Config, + gateways_status_updater: GatewayClientUpdateSender, + local_identity: Arc, + max_sending_rate: usize, +) -> PacketSender { + PacketSender::new( + gateways_status_updater, + local_identity, + config.get_gateway_response_timeout(), + config.get_gateway_connection_timeout(), + config.get_max_concurrent_gateway_clients(), + max_sending_rate, + ) +} + +fn new_received_processor( + packets_receiver: ReceivedProcessorReceiver, + client_encryption_keypair: Arc, +) -> ReceivedProcessor { + ReceivedProcessor::new(packets_receiver, client_encryption_keypair) +} + +fn new_summary_producer(detailed_report: bool) -> SummaryProducer { + // right now always print the basic report. If we feel like we need to change it, it can + // be easily adjusted by adding some flag or something + let summary_producer = SummaryProducer::default().with_report(); + if detailed_report { + summary_producer.with_detailed_report() + } else { + summary_producer + } +} + +fn new_packet_receiver( + gateways_status_updater: GatewayClientUpdateReceiver, + processor_packets_sender: ReceivedProcessorSender, +) -> PacketReceiver { + PacketReceiver::new(gateways_status_updater, processor_packets_sender) +} + +pub(crate) fn check_if_up_to_date(v4_topology: &NymTopology, v6_topology: &NymTopology) { + let monitor_version = env!("CARGO_PKG_VERSION"); + for (_, layer_mixes) in v4_topology.mixes().iter() { + for mix in layer_mixes.iter() { + if !version_checker::is_minor_version_compatible(monitor_version, &*mix.version) { + panic!( + "Our good topology is not compatible with monitor! Mix runs {}, we have {}", + mix.version, monitor_version + ) + } + } + } + + for gateway in v4_topology.gateways().iter() { + if !version_checker::is_minor_version_compatible(monitor_version, &*gateway.version) { + panic!( + "Our good topology is not compatible with monitor! Gateway runs {}, we have {}", + gateway.version, monitor_version + ) + } + } + + for (_, layer_mixes) in v6_topology.mixes().iter() { + for mix in layer_mixes.iter() { + if !version_checker::is_minor_version_compatible(monitor_version, &*mix.version) { + panic!( + "Our good topology is not compatible with monitor! Mix runs {}, we have {}", + mix.version, monitor_version + ) + } + } + } + + for gateway in v6_topology.gateways().iter() { + if !version_checker::is_minor_version_compatible(monitor_version, &*gateway.version) { + panic!( + "Our good topology is not compatible with monitor! Gateway runs {}, we have {}", + gateway.version, monitor_version + ) + } + } +} diff --git a/validator-api/src/monitor/mod.rs b/validator-api/src/network_monitor/monitor/mod.rs similarity index 70% rename from validator-api/src/monitor/mod.rs rename to validator-api/src/network_monitor/monitor/mod.rs index 1e7030f84e..6cdff95610 100644 --- a/validator-api/src/monitor/mod.rs +++ b/validator-api/src/network_monitor/monitor/mod.rs @@ -1,15 +1,16 @@ // Copyright 2021 - Nym Technologies SA // SPDX-License-Identifier: Apache-2.0 -use crate::monitor::preparer::{PacketPreparer, TestedNode}; -use crate::monitor::processor::ReceivedProcessor; -use crate::monitor::sender::PacketSender; -use crate::monitor::summary_producer::{SummaryProducer, TestReport}; -use crate::node_status_api; -use crate::node_status_api::models::{BatchGatewayStatus, BatchMixStatus}; -use crate::test_packet::NodeType; -use crate::tested_network::TestedNetwork; +use crate::config::Config; +use crate::network_monitor::monitor::preparer::{PacketPreparer, TestedNode}; +use crate::network_monitor::monitor::processor::ReceivedProcessor; +use crate::network_monitor::monitor::sender::PacketSender; +use crate::network_monitor::monitor::summary_producer::{NodeResult, SummaryProducer, TestReport}; +use crate::network_monitor::test_packet::NodeType; +use crate::network_monitor::tested_network::TestedNetwork; +use crate::node_status_api::storage::NodeStatusStorage; use log::{debug, info}; +use std::process; use tokio::time::{sleep, Duration, Instant}; pub(crate) mod preparer; @@ -18,27 +19,27 @@ pub(crate) mod receiver; pub(crate) mod sender; pub(crate) mod summary_producer; -const PACKET_DELIVERY_TIMEOUT: Duration = Duration::from_secs(20); -const MONITOR_RUN_INTERVAL: Duration = Duration::from_secs(15 * 60); -const GATEWAY_PING_INTERVAL: Duration = Duration::from_secs(60); - pub(super) struct Monitor { nonce: u64, packet_preparer: PacketPreparer, packet_sender: PacketSender, received_processor: ReceivedProcessor, summary_producer: SummaryProducer, - node_status_api_client: node_status_api::Client, + node_status_storage: NodeStatusStorage, tested_network: TestedNetwork, + run_interval: Duration, + gateway_ping_interval: Duration, + packet_delivery_timeout: Duration, } impl Monitor { pub(super) fn new( + config: &Config, packet_preparer: PacketPreparer, packet_sender: PacketSender, received_processor: ReceivedProcessor, summary_producer: SummaryProducer, - node_status_api_client: node_status_api::Client, + node_status_storage: NodeStatusStorage, tested_network: TestedNetwork, ) -> Self { Monitor { @@ -47,38 +48,34 @@ impl Monitor { packet_sender, received_processor, summary_producer, - node_status_api_client, + node_status_storage, tested_network, + run_interval: config.get_network_monitor_run_interval(), + gateway_ping_interval: config.get_gateway_ping_interval(), + packet_delivery_timeout: config.get_packet_delivery_timeout(), } } // while it might have been cleaner to put this into a separate `Notifier` structure, // I don't see much point considering it's only a single, small, method - async fn notify_node_status_api( + async fn submit_new_node_statuses( &self, - mix_status: BatchMixStatus, - gateway_status: BatchGatewayStatus, + mixnode_results: Vec, + gateway_results: Vec, ) { if let Err(err) = self - .node_status_api_client - .post_batch_mix_status(mix_status) + .node_status_storage + .submit_new_statuses(mixnode_results, gateway_results) .await { - warn!( - "Failed to send batch mix status to node status api - {:?}", + // this can only fail if there's an issue with the database - we can't really recover + error!( + "Failed to submit new monitoring results to the database - {}", err - ) - } + ); - if let Err(err) = self - .node_status_api_client - .post_batch_gateway_status(gateway_status) - .await - { - warn!( - "Failed to send batch mix status to node status api - {:?}", - err - ) + // TODO: slightly more graceful shutdown here + process::exit(1); } } @@ -140,14 +137,7 @@ impl Monitor { info!(target: "Monitor", "Starting test run no. {}", self.nonce); debug!(target: "Monitor", "Preparing mix packets to all nodes..."); - let prepared_packets = match self.packet_preparer.prepare_test_packets(self.nonce).await { - Ok(packets) => packets, - Err(err) => { - error!("failed to create packets for the test run - {:?}", err); - // TODO: return error? - return; - } - }; + let prepared_packets = self.packet_preparer.prepare_test_packets(self.nonce).await; self.received_processor.set_new_expected(self.nonce).await; @@ -159,11 +149,11 @@ impl Monitor { info!( target: "Monitor", "Sending is over, waiting for {:?} before checking what we received", - PACKET_DELIVERY_TIMEOUT + self.packet_delivery_timeout ); // give the packets some time to traverse the network - sleep(PACKET_DELIVERY_TIMEOUT).await; + sleep(self.packet_delivery_timeout).await; let received = self.received_processor.return_received().await; @@ -175,9 +165,9 @@ impl Monitor { // our "good" nodes MUST be working correctly otherwise we cannot trust the results if self.check_good_nodes_status(&test_summary.test_report) { - self.notify_node_status_api( - test_summary.batch_mix_status, - test_summary.batch_gateway_status, + self.submit_new_node_statuses( + test_summary.mixnode_results, + test_summary.gateway_results, ) .await; } else { @@ -192,23 +182,30 @@ impl Monitor { } pub(crate) async fn run(&mut self) { + self.received_processor.start_receiving(); + + // wait for validator cache to be ready + self.packet_preparer + .wait_for_validator_cache_initial_values() + .await; + // start from 0 to run test immediately on startup let test_delay = sleep(Duration::from_secs(0)); tokio::pin!(test_delay); - let ping_delay = sleep(GATEWAY_PING_INTERVAL); + let ping_delay = sleep(self.gateway_ping_interval); tokio::pin!(ping_delay); loop { tokio::select! { _ = &mut test_delay => { self.test_run().await; - info!(target: "Monitor", "Next test run will happen in {:?}", MONITOR_RUN_INTERVAL); + info!(target: "Monitor", "Next test run will happen in {:?}", self.run_interval); let now = Instant::now(); - test_delay.as_mut().reset(now + MONITOR_RUN_INTERVAL); + test_delay.as_mut().reset(now + self.run_interval); // since we just sent packets through gateways, there's no need to ping them - ping_delay.as_mut().reset(now + GATEWAY_PING_INTERVAL); + ping_delay.as_mut().reset(now + self.gateway_ping_interval); } _ = &mut ping_delay => { @@ -216,7 +213,7 @@ impl Monitor { self.ping_all_gateways().await; let now = Instant::now(); - ping_delay.as_mut().reset(now + GATEWAY_PING_INTERVAL); + ping_delay.as_mut().reset(now + self.gateway_ping_interval); } } } diff --git a/validator-api/src/monitor/preparer.rs b/validator-api/src/network_monitor/monitor/preparer.rs similarity index 90% rename from validator-api/src/monitor/preparer.rs rename to validator-api/src/network_monitor/monitor/preparer.rs index e8525abb68..96b434b532 100644 --- a/validator-api/src/monitor/preparer.rs +++ b/validator-api/src/network_monitor/monitor/preparer.rs @@ -1,10 +1,11 @@ // Copyright 2021 - Nym Technologies SA // SPDX-License-Identifier: Apache-2.0 -use crate::chunker::Chunker; -use crate::monitor::sender::GatewayPackets; -use crate::test_packet::{NodeType, TestPacket}; -use crate::tested_network::TestedNetwork; +use crate::cache::ValidatorCache; +use crate::network_monitor::chunker::Chunker; +use crate::network_monitor::monitor::sender::GatewayPackets; +use crate::network_monitor::test_packet::{NodeType, TestPacket}; +use crate::network_monitor::tested_network::TestedNetwork; use crypto::asymmetric::{encryption, identity}; use log::{info, warn}; use mixnet_contract::{GatewayBond, MixNodeBond}; @@ -12,13 +13,8 @@ use nymsphinx::addressing::clients::Recipient; use nymsphinx::forwarding::packet::MixPacket; use std::convert::TryInto; use std::fmt::{self, Display, Formatter}; +use std::time::Duration; use topology::{gateway, mix}; -use validator_client::ValidatorClientError; - -#[derive(Debug)] -pub(super) enum PacketPreparerError { - ValidatorClientError(ValidatorClientError), -} // declared type aliases for easier code reasoning type Version = String; @@ -142,7 +138,7 @@ pub(crate) struct PreparedPackets { pub(crate) struct PacketPreparer { chunker: Chunker, - validator_client: validator_client::Client, + validator_cache: ValidatorCache, tested_network: TestedNetwork, // currently all test MIXNODE packets are sent via the same gateway @@ -155,7 +151,7 @@ pub(crate) struct PacketPreparer { impl PacketPreparer { pub(crate) fn new( - validator_client: validator_client::Client, + validator_cache: ValidatorCache, tested_network: TestedNetwork, test_mixnode_sender: Recipient, self_public_identity: identity::PublicKey, @@ -163,7 +159,7 @@ impl PacketPreparer { ) -> Self { PacketPreparer { chunker: Chunker::new(test_mixnode_sender), - validator_client, + validator_cache, tested_network, test_mixnode_sender, self_public_identity, @@ -171,34 +167,27 @@ impl PacketPreparer { } } - async fn get_network_nodes( - &mut self, - ) -> Result<(Vec, Vec), PacketPreparerError> { + pub(crate) async fn wait_for_validator_cache_initial_values(&self) { + let initialisation_backoff = Duration::from_secs(10); + loop { + if self.validator_cache.initialised() { + break; + } else { + debug!("Validator cache hasn't been initialised yet - waiting for {:?} before trying again", initialisation_backoff); + tokio::time::sleep(initialisation_backoff).await; + } + } + } + + async fn get_network_nodes(&mut self) -> (Vec, Vec) { info!(target: "Monitor", "Obtaining network topology..."); - // TODO: This should probably be using the cached data directly, without going through - // the API - let mixnodes = match self.validator_client.get_cached_mix_nodes().await { - Err(err) => { - error!("failed to get network mixnodes - {}", err); - return Err(PacketPreparerError::ValidatorClientError(err)); - } - Ok(mixes) => mixes, - }; - - // TODO: This should probably be using the cached data directly, without going through - // the API - let gateways = match self.validator_client.get_cached_gateways().await { - Err(err) => { - error!("failed to get network gateways - {}", err); - return Err(PacketPreparerError::ValidatorClientError(err)); - } - Ok(gateways) => gateways, - }; + let mixnodes = self.validator_cache.mixnodes().await.into_inner(); + let gateways = self.validator_cache.gateways().await.into_inner(); info!(target: "Monitor", "Obtained network topology"); - Ok((mixnodes, gateways)) + (mixnodes, gateways) } fn check_version_compatibility(&self, mix_version: &str) -> bool { @@ -428,11 +417,8 @@ impl PacketPreparer { packets } - pub(super) async fn prepare_test_packets( - &mut self, - nonce: u64, - ) -> Result { - let (mixnode_bonds, gateway_bonds) = self.get_network_nodes().await?; + pub(super) async fn prepare_test_packets(&mut self, nonce: u64) -> PreparedPackets { + let (mixnode_bonds, gateway_bonds) = self.get_network_nodes().await; let mut invalid_nodes = Vec::new(); let mixes = self.prepare_mixnodes(nonce, &mixnode_bonds); @@ -474,10 +460,10 @@ impl PacketPreparer { gateway_packets.push(main_gateway_packets); } - Ok(PreparedPackets { + PreparedPackets { packets: gateway_packets, tested_nodes, invalid_nodes, - }) + } } } diff --git a/validator-api/src/monitor/processor.rs b/validator-api/src/network_monitor/monitor/processor.rs similarity index 85% rename from validator-api/src/monitor/processor.rs rename to validator-api/src/network_monitor/monitor/processor.rs index fda77b1149..7ac13febf2 100644 --- a/validator-api/src/monitor/processor.rs +++ b/validator-api/src/network_monitor/monitor/processor.rs @@ -1,8 +1,8 @@ // Copyright 2021 - Nym Technologies SA // SPDX-License-Identifier: Apache-2.0 -use crate::gateways_reader::GatewayMessages; -use crate::test_packet::TestPacket; +use crate::network_monitor::gateways_reader::GatewayMessages; +use crate::network_monitor::test_packet::TestPacket; use crypto::asymmetric::encryption; use futures::channel::mpsc; use futures::lock::{Mutex, MutexGuard}; @@ -107,7 +107,7 @@ impl ReceivedProcessorInner { } pub(crate) struct ReceivedProcessor { - permit_changer: mpsc::Sender, + permit_changer: Option>, inner: Arc>, } @@ -125,34 +125,32 @@ impl ReceivedProcessor { received_packets: Vec::new(), })); - // TODO: perhaps it should be using 0 size instead? - let (permit_sender, permit_receiver) = mpsc::channel(1); - - Self::start_receiving(Arc::clone(&inner), permit_receiver); - ReceivedProcessor { - permit_changer: permit_sender, + permit_changer: None, inner, } } - fn start_receiving( - inner: Arc>, - mut permit_change: mpsc::Receiver, - ) { + pub(crate) fn start_receiving(&mut self) { + let inner = Arc::clone(&self.inner); + + // TODO: perhaps it should be using 0 size instead? + let (permit_sender, mut permit_receiver) = mpsc::channel(1); + self.permit_changer = Some(permit_sender); + tokio::spawn(async move { loop { - let permit = wait_for_permit(&mut permit_change, &*inner).await; - receive_or_release_permit(&mut permit_change, permit).await; + let permit = wait_for_permit(&mut permit_receiver, &*inner).await; + receive_or_release_permit(&mut permit_receiver, permit).await; } async fn receive_or_release_permit( - permit_change: &mut mpsc::Receiver, + permit_receiver: &mut mpsc::Receiver, mut inner: MutexGuard<'_, ReceivedProcessorInner>, ) { loop { tokio::select! { - permit_change = permit_change.next() => match permit_change.unwrap() { + permit_receiver = permit_receiver.next() => match permit_receiver.unwrap() { LockPermit::Release => return, LockPermit::Free => error!("somehow we got notification that the lock is free to take while we already hold it!"), }, @@ -171,11 +169,11 @@ impl ReceivedProcessor { // the compiler can't figure out appropriate lifetime bounds #[allow(clippy::needless_lifetimes)] async fn wait_for_permit<'a>( - permit_change: &mut mpsc::Receiver, + permit_receiver: &mut mpsc::Receiver, inner: &'a Mutex, ) -> MutexGuard<'a, ReceivedProcessorInner> { loop { - match permit_change.next().await.unwrap() { + match permit_receiver.next().await.unwrap() { // we should only ever get this on the very first run LockPermit::Release => debug!( "somehow got request to drop our lock permit while we do not hold it!" @@ -190,6 +188,8 @@ impl ReceivedProcessor { pub(super) async fn set_new_expected(&mut self, nonce: u64) { // ask for the lock back self.permit_changer + .as_mut() + .expect("ReceivedProcessor hasn't started receiving!") .send(LockPermit::Release) .await .expect("processing task has died!"); @@ -200,6 +200,8 @@ impl ReceivedProcessor { // give the permit back drop(inner); self.permit_changer + .as_mut() + .expect("ReceivedProcessor hasn't started receiving!") .send(LockPermit::Free) .await .expect("processing task has died!"); @@ -208,6 +210,8 @@ impl ReceivedProcessor { pub(super) async fn return_received(&mut self) -> Vec { // ask for the lock back self.permit_changer + .as_mut() + .expect("ReceivedProcessor hasn't started receiving!") .send(LockPermit::Release) .await .expect("processing task has died!"); @@ -218,6 +222,8 @@ impl ReceivedProcessor { // give the permit back drop(inner); self.permit_changer + .as_mut() + .expect("ReceivedProcessor hasn't started receiving!") .send(LockPermit::Free) .await .expect("processing task has died!"); diff --git a/validator-api/src/monitor/receiver.rs b/validator-api/src/network_monitor/monitor/receiver.rs similarity index 93% rename from validator-api/src/monitor/receiver.rs rename to validator-api/src/network_monitor/monitor/receiver.rs index 230f4e7989..5cefb3894d 100644 --- a/validator-api/src/monitor/receiver.rs +++ b/validator-api/src/network_monitor/monitor/receiver.rs @@ -1,8 +1,8 @@ // Copyright 2021 - Nym Technologies SA // SPDX-License-Identifier: Apache-2.0 -use crate::gateways_reader::{GatewayChannel, GatewayMessages, GatewaysReader}; -use crate::monitor::processor::ReceivedProcessorSender; +use crate::network_monitor::gateways_reader::{GatewayChannel, GatewayMessages, GatewaysReader}; +use crate::network_monitor::monitor::processor::ReceivedProcessorSender; use crypto::asymmetric::identity; use futures::channel::mpsc; use futures::StreamExt; diff --git a/validator-api/src/monitor/sender.rs b/validator-api/src/network_monitor/monitor/sender.rs similarity index 99% rename from validator-api/src/monitor/sender.rs rename to validator-api/src/network_monitor/monitor/sender.rs index a0fe4d6aac..2aa4a0b3fe 100644 --- a/validator-api/src/monitor/sender.rs +++ b/validator-api/src/network_monitor/monitor/sender.rs @@ -1,7 +1,7 @@ // Copyright 2021 - Nym Technologies SA // SPDX-License-Identifier: Apache-2.0 -use crate::monitor::receiver::{GatewayClientUpdate, GatewayClientUpdateSender}; +use crate::network_monitor::monitor::receiver::{GatewayClientUpdate, GatewayClientUpdateSender}; use crypto::asymmetric::identity::{self, PUBLIC_KEY_LENGTH}; use futures::channel::mpsc; use futures::stream::{self, FuturesUnordered, StreamExt}; diff --git a/validator-api/src/monitor/summary_producer.rs b/validator-api/src/network_monitor/monitor/summary_producer.rs similarity index 73% rename from validator-api/src/monitor/summary_producer.rs rename to validator-api/src/network_monitor/monitor/summary_producer.rs index e22b70d75d..1d72510161 100644 --- a/validator-api/src/monitor/summary_producer.rs +++ b/validator-api/src/network_monitor/monitor/summary_producer.rs @@ -1,55 +1,32 @@ // Copyright 2021 - Nym Technologies SA // SPDX-License-Identifier: Apache-2.0 -use crate::monitor::preparer::{InvalidNode, TestedNode}; -use crate::node_status_api::models::{ - BatchGatewayStatus, BatchMixStatus, GatewayStatus, MixStatus, -}; -use crate::test_packet::{NodeType, TestPacket}; +use crate::network_monitor::monitor::preparer::{InvalidNode, TestedNode}; +use crate::network_monitor::test_packet::{NodeType, TestPacket}; use crate::PENALISE_OUTDATED; use std::collections::HashMap; +pub(crate) struct NodeResult { + pub(crate) pub_key: String, + pub(crate) owner: String, + pub(crate) working_ipv4: bool, + pub(crate) working_ipv6: bool, +} + #[derive(Default)] -struct NodeResult { +struct NodeStatus { ip_v4_compatible: bool, ip_v6_compatible: bool, } -impl NodeResult { - fn into_mix_status(self, pub_key: String, owner: String) -> Vec { - let v4_status = MixStatus { - owner: owner.clone(), - pub_key: pub_key.clone(), - ip_version: "4".to_string(), - up: self.ip_v4_compatible, - }; - - let v6_status = MixStatus { - owner, +impl NodeStatus { + fn into_node_status(self, pub_key: String, owner: String) -> NodeResult { + NodeResult { pub_key, - ip_version: "6".to_string(), - up: self.ip_v6_compatible, - }; - - vec![v4_status, v6_status] - } - - fn into_gateway_status(self, pub_key: String, owner: String) -> Vec { - let v4_status = GatewayStatus { - owner: owner.clone(), - pub_key: pub_key.clone(), - ip_version: "4".to_string(), - up: self.ip_v4_compatible, - }; - - let v6_status = GatewayStatus { owner, - pub_key, - ip_version: "6".to_string(), - up: self.ip_v6_compatible, - }; - - vec![v4_status, v6_status] + working_ipv4: self.ip_v4_compatible, + working_ipv6: self.ip_v6_compatible, + } } } @@ -60,14 +37,20 @@ pub(crate) struct TestReport { pub(crate) malformed: Vec, // below are only populated if we're going to be printing the report - pub(crate) only_ipv4_compatible_mixes: Vec, // can't speak v6, but can speak v4 - pub(crate) only_ipv6_compatible_mixes: Vec, // can't speak v4, but can speak v6 - pub(crate) completely_unroutable_mixes: Vec, // can't speak either v4 or v6 + pub(crate) only_ipv4_compatible_mixes: Vec, + // can't speak v6, but can speak v4 + pub(crate) only_ipv6_compatible_mixes: Vec, + // can't speak v4, but can speak v6 + pub(crate) completely_unroutable_mixes: Vec, + // can't speak either v4 or v6 pub(crate) fully_working_mixes: Vec, - pub(crate) only_ipv4_compatible_gateways: Vec, // can't speak v6, but can speak v4 - pub(crate) only_ipv6_compatible_gateways: Vec, // can't speak v4, but can speak v6 - pub(crate) completely_unroutable_gateways: Vec, // can't speak either v4 or v6 + pub(crate) only_ipv4_compatible_gateways: Vec, + // can't speak v6, but can speak v4 + pub(crate) only_ipv6_compatible_gateways: Vec, + // can't speak v4, but can speak v6 + pub(crate) completely_unroutable_gateways: Vec, + // can't speak either v4 or v6 pub(crate) fully_working_gateways: Vec, } @@ -145,7 +128,7 @@ impl TestReport { } } - fn parse_summary(&mut self, summary: &HashMap) { + fn parse_summary(&mut self, summary: &HashMap) { for (node, result) in summary.iter() { let owned_node = node.clone(); if node.is_gateway() { @@ -172,8 +155,8 @@ impl TestReport { } pub(crate) struct TestSummary { - pub(crate) batch_mix_status: BatchMixStatus, - pub(crate) batch_gateway_status: BatchGatewayStatus, + pub(crate) mixnode_results: Vec, + pub(crate) gateway_results: Vec, pub(crate) test_report: TestReport, } @@ -205,7 +188,7 @@ impl SummaryProducer { let received_packets_count = received_packets.len(); // contains map of all (seemingly valid) nodes and whether they speak ipv4/ipv6 - let mut summary: HashMap = HashMap::new(); + let mut summary: HashMap = HashMap::new(); // update based on data we actually got for received_status in received_packets.into_iter() { @@ -256,31 +239,19 @@ impl SummaryProducer { .into_iter() .partition(|(node, _)| node.node_type == NodeType::Mixnode); - let mix_statuses = mixes + let mixnode_results = mixes .into_iter() - .flat_map(|(node, result)| { - result - .into_mix_status(node.identity, node.owner) - .into_iter() - }) + .map(|(node, result)| result.into_node_status(node.identity, node.owner)) .collect(); - let gateway_statuses = gateways + let gateway_results = gateways .into_iter() - .flat_map(|(node, result)| { - result - .into_gateway_status(node.identity, node.owner) - .into_iter() - }) + .map(|(node, result)| result.into_node_status(node.identity, node.owner)) .collect(); TestSummary { - batch_mix_status: BatchMixStatus { - status: mix_statuses, - }, - batch_gateway_status: BatchGatewayStatus { - status: gateway_statuses, - }, + mixnode_results, + gateway_results, test_report: report, } } diff --git a/validator-api/src/test_packet.rs b/validator-api/src/network_monitor/test_packet.rs similarity index 97% rename from validator-api/src/test_packet.rs rename to validator-api/src/network_monitor/test_packet.rs index 08ef1bcad7..33dd4f3f3f 100644 --- a/validator-api/src/test_packet.rs +++ b/validator-api/src/network_monitor/test_packet.rs @@ -1,7 +1,7 @@ -// Copyright 2020 - Nym Technologies SA +// Copyright 2021 - Nym Technologies SA // SPDX-License-Identifier: Apache-2.0 -use crate::monitor::preparer::TestedNode; +use crate::network_monitor::monitor::preparer::TestedNode; use crypto::asymmetric::identity; use std::convert::{TryFrom, TryInto}; use std::fmt::{self, Display, Formatter}; diff --git a/validator-api/src/tested_network/good_topology.rs b/validator-api/src/network_monitor/tested_network/good_topology.rs similarity index 94% rename from validator-api/src/tested_network/good_topology.rs rename to validator-api/src/network_monitor/tested_network/good_topology.rs index a2c2b4ccf0..9f26ab7c41 100644 --- a/validator-api/src/tested_network/good_topology.rs +++ b/validator-api/src/network_monitor/tested_network/good_topology.rs @@ -1,4 +1,4 @@ -// Copyright 2020 - Nym Technologies SA +// Copyright 2021 - Nym Technologies SA // SPDX-License-Identifier: Apache-2.0 use mixnet_contract::{GatewayBond, MixNodeBond}; diff --git a/validator-api/src/tested_network/mod.rs b/validator-api/src/network_monitor/tested_network/mod.rs similarity index 94% rename from validator-api/src/tested_network/mod.rs rename to validator-api/src/network_monitor/tested_network/mod.rs index f3f41c056d..9a8d0abf4e 100644 --- a/validator-api/src/tested_network/mod.rs +++ b/validator-api/src/network_monitor/tested_network/mod.rs @@ -1,7 +1,7 @@ -// Copyright 2020 - Nym Technologies SA +// Copyright 2021 - Nym Technologies SA // SPDX-License-Identifier: Apache-2.0 -use crate::test_packet::IpVersion; +use crate::network_monitor::test_packet::IpVersion; use topology::{gateway, mix, NymTopology}; pub(crate) mod good_topology; diff --git a/validator-api/src/node_status_api/client.rs b/validator-api/src/node_status_api/client.rs deleted file mode 100644 index b7698f6c07..0000000000 --- a/validator-api/src/node_status_api/client.rs +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright 2021 - Nym Technologies SA -// SPDX-License-Identifier: Apache-2.0 - -use crate::node_status_api::models::{BatchGatewayStatus, BatchMixStatus, DefaultRestResponse}; -use crate::node_status_api::NodeStatusApiClientError; - -pub(crate) struct Config { - base_url: String, -} - -impl Config { - pub(crate) fn new>(base_url: S) -> Self { - Config { - base_url: base_url.into(), - } - } -} - -pub(crate) struct Client { - config: Config, - reqwest_client: reqwest::Client, -} - -impl Client { - pub(crate) fn new(config: Config) -> Self { - let reqwest_client = reqwest::Client::new(); - Client { - config, - reqwest_client, - } - } - - // Potentially, down the line, this could be moved to /common/client-libs - // and additional methods could be added like GET for report data, but currently - // we have absolutely no use for that in Rust. - - pub(crate) async fn post_batch_mix_status( - &self, - batch_status: BatchMixStatus, - ) -> Result<(), NodeStatusApiClientError> { - const RELATIVE_PATH: &str = "api/status/mixnode/batch"; - - let url = format!("{}/{}", self.config.base_url, RELATIVE_PATH); - - let response = self - .reqwest_client - .post(url) - .json(&batch_status) - .send() - .await?; - - if response.status().is_success() { - let response_content: DefaultRestResponse = response.json().await?; - match response_content { - DefaultRestResponse::Ok(ok_response) => { - if ok_response.ok { - Ok(()) - } else { - Err(NodeStatusApiClientError::NodeStatusApiError( - "received an ok response with false status".into(), - )) - } - } - DefaultRestResponse::Error(err_response) => Err(err_response.into()), - } - } else { - Err(NodeStatusApiClientError::NodeStatusApiError(format!( - "received response with status {}", - response.status() - ))) - } - } - - pub(crate) async fn post_batch_gateway_status( - &self, - batch_status: BatchGatewayStatus, - ) -> Result<(), NodeStatusApiClientError> { - const RELATIVE_PATH: &str = "api/status/gateway/batch"; - - let url = format!("{}/{}", self.config.base_url, RELATIVE_PATH); - - let response = self - .reqwest_client - .post(url) - .json(&batch_status) - .send() - .await?; - - if response.status().is_success() { - let response_content: DefaultRestResponse = response.json().await?; - match response_content { - DefaultRestResponse::Ok(ok_response) => { - if ok_response.ok { - Ok(()) - } else { - Err(NodeStatusApiClientError::NodeStatusApiError( - "received an ok response with false status".into(), - )) - } - } - DefaultRestResponse::Error(err_response) => Err(err_response.into()), - } - } else { - Err(NodeStatusApiClientError::NodeStatusApiError(format!( - "received response with status {}", - response.status() - ))) - } - } -} diff --git a/validator-api/src/node_status_api/local_guard.rs b/validator-api/src/node_status_api/local_guard.rs new file mode 100644 index 0000000000..e9256a5d9c --- /dev/null +++ b/validator-api/src/node_status_api/local_guard.rs @@ -0,0 +1,42 @@ +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 + +use rocket::http::Status; +use rocket::request::{FromRequest, Outcome}; +use rocket::Request; +use std::fmt::Debug; +use std::net::{IpAddr, Ipv4Addr, Ipv6Addr}; + +#[derive(Debug)] +pub struct NonLocalRequestError; + +/// Request guard that only allows requests coming from a local address +pub(crate) struct LocalRequest; + +fn is_local_address(ip: Option) -> bool { + if let Some(address) = ip { + match address { + IpAddr::V4(ip) => ip == Ipv4Addr::LOCALHOST, + IpAddr::V6(ip) => ip == Ipv6Addr::LOCALHOST, + } + } else { + false + } +} + +#[rocket::async_trait] +impl<'r> FromRequest<'r> for LocalRequest { + type Error = NonLocalRequestError; + + async fn from_request(request: &'r Request<'_>) -> Outcome { + if is_local_address(request.client_ip()) { + Outcome::Success(LocalRequest) + } else { + warn!( + "Received a request from {:?} for a local-only route", + request.client_ip() + ); + Outcome::Failure((Status::Unauthorized, NonLocalRequestError)) + } + } +} diff --git a/validator-api/src/node_status_api/mod.rs b/validator-api/src/node_status_api/mod.rs index 6570a3ebc1..aae4e45f6f 100644 --- a/validator-api/src/node_status_api/mod.rs +++ b/validator-api/src/node_status_api/mod.rs @@ -1,73 +1,35 @@ // Copyright 2021 - Nym Technologies SA // SPDX-License-Identifier: Apache-2.0 -use crate::node_status_api::models::ErrorResponses; -use std::fmt::{self, Display, Formatter}; +use rocket::fairing::AdHoc; +use std::path::PathBuf; +use std::time::Duration; -mod client; +pub(crate) mod local_guard; pub(crate) mod models; +pub(crate) mod routes; +pub(crate) mod storage; +pub(crate) mod utils; -pub(crate) use client::{Client, Config}; +pub(crate) const FIFTEEN_MINUTES: Duration = Duration::from_secs(900); +pub(crate) const ONE_HOUR: Duration = Duration::from_secs(3600); +pub(crate) const ONE_DAY: Duration = Duration::from_secs(86400); -const MAX_SANE_UNEXPECTED_PRINT: usize = 100; - -#[derive(Debug)] -pub enum NodeStatusApiClientError { - ReqwestClientError(reqwest::Error), - NodeStatusApiError(String), - UnexpectedResponse(String), -} - -impl From for NodeStatusApiClientError { - fn from(err: reqwest::Error) -> Self { - NodeStatusApiClientError::ReqwestClientError(err) - } -} - -impl From for NodeStatusApiClientError { - fn from(err: ErrorResponses) -> Self { - match err { - ErrorResponses::Error(err_message) => { - NodeStatusApiClientError::NodeStatusApiError(err_message.error) - } - ErrorResponses::Unexpected(received) => { - NodeStatusApiClientError::UnexpectedResponse(received.to_string()) - } - } - } -} - -impl Display for NodeStatusApiClientError { - fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { - match self { - NodeStatusApiClientError::ReqwestClientError(err) => { - write!(f, "there was an issue with the REST request - {}", err) - } - NodeStatusApiClientError::NodeStatusApiError(err) => { - write!( - f, - "there was an issue with the node status api client - {}", - err - ) - } - NodeStatusApiClientError::UnexpectedResponse(received) => { - if received.len() < MAX_SANE_UNEXPECTED_PRINT { - write!( - f, - "received data was completely unexpected. got: {}", - received - ) - } else { - write!( - f, - "received data was completely unexpected. got: {}...", - received - .chars() - .take(MAX_SANE_UNEXPECTED_PRINT) - .collect::() - ) - } - } - } - } +pub(crate) fn stage(database_path: PathBuf) -> AdHoc { + AdHoc::on_ignite("SQLx Stage", |rocket| async { + rocket + .attach(storage::NodeStatusStorage::stage(database_path)) + .mount( + "/v1/status", + routes![ + routes::mixnode_report, + routes::gateway_report, + routes::mixnode_uptime_history, + routes::gateway_uptime_history, + routes::mixnodes_full_report, + routes::gateways_full_report, + routes::rewarding_chores, + ], + ) + }) } diff --git a/validator-api/src/node_status_api/models.rs b/validator-api/src/node_status_api/models.rs index 93e39ec470..32bc58cb77 100644 --- a/validator-api/src/node_status_api/models.rs +++ b/validator-api/src/node_status_api/models.rs @@ -1,68 +1,258 @@ // Copyright 2021 - Nym Technologies SA // SPDX-License-Identifier: Apache-2.0 +use crate::node_status_api::utils::{NodeStatus, NodeUptimes}; +use rocket::http::{ContentType, Status}; +use rocket::response::{self, Responder, Response}; +use rocket::Request; use serde::{Deserialize, Serialize}; +use std::convert::TryFrom; +use std::fmt::{self, Display, Formatter}; +use std::io::Cursor; -#[derive(Debug, Deserialize, Serialize)] -#[serde(rename_all = "camelCase")] -/// A notification sent to the validators to let them know whether a given mix is -/// currently up or down (based on whether it's mixing packets) -pub struct MixStatus { - pub pub_key: String, - pub owner: String, - pub ip_version: String, - pub up: bool, +// todo: put into some error enum +#[derive(Debug)] +pub struct InvalidUptime; + +// value in range 0-100 +#[derive(Clone, Serialize, Deserialize, Debug)] +pub struct Uptime(u8); + +impl Uptime { + pub const fn zero() -> Self { + Uptime(0) + } + + pub fn from_ratio(numerator: usize, denominator: usize) -> Result { + if denominator == 0 { + return Ok(Self::zero()); + } + + let uptime = ((numerator as f32 / denominator as f32) * 100.0) as u8; + + if uptime > 100 { + Err(InvalidUptime) + } else { + Ok(Uptime(uptime)) + } + } + + pub fn u8(&self) -> u8 { + self.0 + } } -#[derive(Debug, Deserialize, Serialize)] -#[serde(rename_all = "camelCase")] -/// A notification sent to the validators to let them know whether a given set of mixes is -/// currently up or down (based on whether it's mixing packets) -pub struct BatchMixStatus { - pub status: Vec, +impl From for u8 { + fn from(uptime: Uptime) -> Self { + uptime.0 + } } -#[derive(Debug, Deserialize, Serialize)] -#[serde(rename_all = "camelCase")] -/// A notification sent to the validators to let them know whether a given gateway is -/// currently up or down (based on whether it's mixing packets) -pub struct GatewayStatus { - pub pub_key: String, - pub owner: String, - pub ip_version: String, - pub up: bool, +impl TryFrom for Uptime { + type Error = InvalidUptime; + + fn try_from(value: u8) -> Result { + if value > 100 { + Err(InvalidUptime) + } else { + Ok(Uptime(value)) + } + } } -#[derive(Debug, Deserialize, Serialize)] -#[serde(rename_all = "camelCase")] -/// A notification sent to the validators to let them know whether a given set of gateways is -/// currently up or down (based on whether it's mixing packets) -pub struct BatchGatewayStatus { - pub status: Vec, +impl TryFrom for Uptime { + type Error = InvalidUptime; + + fn try_from(value: i64) -> Result { + if !(0..=100).contains(&value) { + Err(InvalidUptime) + } else { + Ok(Uptime(value as u8)) + } + } } -#[derive(Deserialize, Debug)] -#[serde(rename_all = "camelCase", untagged)] -pub(crate) enum ErrorResponses { - Error(ErrorResponse), - Unexpected(serde_json::Value), +#[derive(Clone, Serialize, Deserialize, Debug)] +pub struct MixnodeStatusReport { + identity: String, + owner: String, + + most_recent_ipv4: bool, + most_recent_ipv6: bool, + + last_hour_ipv4: Uptime, + last_hour_ipv6: Uptime, + + last_day_ipv4: Uptime, + last_day_ipv6: Uptime, +} + +impl MixnodeStatusReport { + pub(crate) fn construct_from_last_day_reports( + identity: String, + owner: String, + last_day_ipv4: Vec, + last_day_ipv6: Vec, + ) -> Self { + let node_uptimes = + NodeUptimes::calculate_from_last_day_reports(last_day_ipv4, last_day_ipv6); + + MixnodeStatusReport { + identity, + owner, + most_recent_ipv4: node_uptimes.most_recent_ipv4, + most_recent_ipv6: node_uptimes.most_recent_ipv6, + last_hour_ipv4: node_uptimes.last_hour_ipv4, + last_hour_ipv6: node_uptimes.last_hour_ipv6, + last_day_ipv4: node_uptimes.last_day_ipv4, + last_day_ipv6: node_uptimes.last_day_ipv6, + } + } +} + +#[derive(Clone, Serialize, Deserialize, Debug)] +pub struct GatewayStatusReport { + identity: String, + owner: String, + + most_recent_ipv4: bool, + most_recent_ipv6: bool, + + last_hour_ipv4: Uptime, + last_hour_ipv6: Uptime, + + last_day_ipv4: Uptime, + last_day_ipv6: Uptime, +} + +impl GatewayStatusReport { + pub(crate) fn construct_from_last_day_reports( + identity: String, + owner: String, + last_day_ipv4: Vec, + last_day_ipv6: Vec, + ) -> Self { + let node_uptimes = + NodeUptimes::calculate_from_last_day_reports(last_day_ipv4, last_day_ipv6); + + GatewayStatusReport { + identity, + owner, + most_recent_ipv4: node_uptimes.most_recent_ipv4, + most_recent_ipv6: node_uptimes.most_recent_ipv6, + last_hour_ipv4: node_uptimes.last_hour_ipv4, + last_hour_ipv6: node_uptimes.last_hour_ipv6, + last_day_ipv4: node_uptimes.last_day_ipv4, + last_day_ipv6: node_uptimes.last_day_ipv6, + } + } +} + +#[derive(Clone, Serialize, Deserialize, Debug)] +pub struct MixnodeUptimeHistory { + pub(crate) identity: String, + pub(crate) owner: String, + + pub(crate) history: Vec, +} + +impl MixnodeUptimeHistory { + pub(crate) fn new(identity: String, owner: String, history: Vec) -> Self { + MixnodeUptimeHistory { + identity, + owner, + history, + } + } +} + +#[derive(Clone, Serialize, Deserialize, Debug)] +pub struct GatewayUptimeHistory { + pub(crate) identity: String, + pub(crate) owner: String, + + pub(crate) history: Vec, +} + +impl GatewayUptimeHistory { + pub(crate) fn new(identity: String, owner: String, history: Vec) -> Self { + GatewayUptimeHistory { + identity, + owner, + history, + } + } +} + +#[derive(Clone, Serialize, Deserialize, Debug)] +pub struct HistoricalUptime { + // ISO 8601 date string + // I think this is more than enough, we don't need the uber precision of timezone offsets, etc + pub(crate) date: String, + + pub(crate) ipv4_uptime: Uptime, + pub(crate) ipv6_uptime: Uptime, } -#[derive(Deserialize, Debug)] -#[serde(rename_all = "camelCase")] pub(crate) struct ErrorResponse { - pub(crate) error: String, + error: NodeStatusApiError, + status: Status, } -#[derive(Deserialize, Debug)] -#[serde(rename_all = "camelCase")] -pub(crate) struct OkResponse { - pub(crate) ok: bool, +impl ErrorResponse { + pub(crate) fn new(error: NodeStatusApiError, status: Status) -> Self { + ErrorResponse { error, status } + } } -#[derive(Deserialize, Debug)] -#[serde(rename_all = "camelCase", untagged)] -pub(crate) enum DefaultRestResponse { - Ok(OkResponse), - Error(ErrorResponses), +impl<'r, 'o: 'r> Responder<'r, 'o> for ErrorResponse { + fn respond_to(self, _: &'r Request<'_>) -> response::Result<'o> { + let message = format!("{}", self.error); + Response::build() + .header(ContentType::Plain) + .sized_body(message.len(), Cursor::new(message)) + .status(self.status) + .ok() + } +} + +#[derive(Debug)] +pub enum NodeStatusApiError { + MixnodeReportNotFound(String), + GatewayReportNotFound(String), + MixnodeUptimeHistoryNotFound(String), + GatewayUptimeHistoryNotFound(String), + + // I don't think we want to expose errors to the user about what really happened + InternalDatabaseError, +} + +impl Display for NodeStatusApiError { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + match self { + NodeStatusApiError::MixnodeReportNotFound(identity) => write!( + f, + "Could not find status report associated with mixnode {}", + identity + ), + NodeStatusApiError::GatewayReportNotFound(identity) => write!( + f, + "Could not find status report associated with gateway {}", + identity + ), + NodeStatusApiError::MixnodeUptimeHistoryNotFound(identity) => write!( + f, + "Could not find uptime history associated with mixnode {}", + identity + ), + NodeStatusApiError::GatewayUptimeHistoryNotFound(identity) => write!( + f, + "Could not find uptime history associated with gateway {}", + identity + ), + NodeStatusApiError::InternalDatabaseError => { + write!(f, "The internal database has experienced an issue") + } + } + } } diff --git a/validator-api/src/node_status_api/routes.rs b/validator-api/src/node_status_api/routes.rs new file mode 100644 index 0000000000..dedfac1d6c --- /dev/null +++ b/validator-api/src/node_status_api/routes.rs @@ -0,0 +1,98 @@ +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 + +use crate::node_status_api::local_guard::LocalRequest; +use crate::node_status_api::models::{ + ErrorResponse, GatewayStatusReport, GatewayUptimeHistory, MixnodeStatusReport, + MixnodeUptimeHistory, +}; +use crate::node_status_api::storage::NodeStatusStorage; +use rocket::http::Status; +use rocket::serde::json::Json; +use rocket::State; + +#[get("/daily-chores")] +pub(crate) async fn rewarding_chores( + _local_request: LocalRequest, + storage: &State, +) -> Result<&'static str, ErrorResponse> { + if storage + .daily_chores() + .await + .map_err(|err| ErrorResponse::new(err, Status::InternalServerError))? + { + Ok("Updated historical uptimes and purged old reports.") + } else { + Ok("The historical uptimes were already updated at some point today - nothing was done now.") + } +} + +#[get("/mixnode//report")] +pub(crate) async fn mixnode_report( + storage: &State, + pubkey: &str, +) -> Result, ErrorResponse> { + storage + .construct_mixnode_report(pubkey) + .await + .map(Json) + .map_err(|err| ErrorResponse::new(err, Status::NotFound)) +} + +#[get("/gateway//report")] +pub(crate) async fn gateway_report( + storage: &State, + pubkey: &str, +) -> Result, ErrorResponse> { + storage + .construct_gateway_report(pubkey) + .await + .map(Json) + .map_err(|err| ErrorResponse::new(err, Status::NotFound)) +} + +#[get("/mixnode//history")] +pub(crate) async fn mixnode_uptime_history( + storage: &State, + pubkey: &str, +) -> Result, ErrorResponse> { + storage + .get_mixnode_uptime_history(pubkey) + .await + .map(Json) + .map_err(|err| ErrorResponse::new(err, Status::NotFound)) +} + +#[get("/gateway//history")] +pub(crate) async fn gateway_uptime_history( + storage: &State, + pubkey: &str, +) -> Result, ErrorResponse> { + storage + .get_gateway_uptime_history(pubkey) + .await + .map(Json) + .map_err(|err| ErrorResponse::new(err, Status::NotFound)) +} + +#[get("/mixnodes/all/report")] +pub(crate) async fn mixnodes_full_report( + storage: &State, +) -> Result>, ErrorResponse> { + storage + .get_all_mixnode_reports() + .await + .map(Json) + .map_err(|err| ErrorResponse::new(err, Status::InternalServerError)) +} + +#[get("/gateways/all/report")] +pub(crate) async fn gateways_full_report( + storage: &State, +) -> Result>, ErrorResponse> { + storage + .get_all_gateway_reports() + .await + .map(Json) + .map_err(|err| ErrorResponse::new(err, Status::InternalServerError)) +} diff --git a/validator-api/src/node_status_api/storage.rs b/validator-api/src/node_status_api/storage.rs new file mode 100644 index 0000000000..7e9761c133 --- /dev/null +++ b/validator-api/src/node_status_api/storage.rs @@ -0,0 +1,1045 @@ +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 + +use crate::network_monitor::monitor::summary_producer::NodeResult; +use crate::node_status_api::models::{ + GatewayStatusReport, GatewayUptimeHistory, HistoricalUptime, MixnodeStatusReport, + MixnodeUptimeHistory, NodeStatusApiError, Uptime, +}; +use crate::node_status_api::utils::{ActiveNode, ActiveNodeDayStatuses, NodeStatus}; +use crate::node_status_api::ONE_DAY; +use rocket::fairing::{self, AdHoc}; +use rocket::{Build, Rocket}; +use sqlx::types::time::OffsetDateTime; +use sqlx::ConnectOptions; +use std::convert::TryFrom; +use std::path::PathBuf; + +// A type alias to be more explicit about type of timestamp used. +type UnixTimestamp = i64; + +// note that clone here is fine as upon cloning the same underlying pool will be used +// +// note2: the reason 'inner' was introduced was so that there would be an explicit split to +// where pure SQL is used (i.e. `Inner` should be the only place containing any sort +// of SQL while `NodeStatusStorage` should provide a slightly higher level API) +#[derive(Clone)] +pub(crate) struct NodeStatusStorage { + inner: NodeStatusStorageInner, +} + +#[derive(Clone)] +struct NodeStatusStorageInner { + connection_pool: sqlx::SqlitePool, +} + +impl NodeStatusStorage { + async fn init(rocket: Rocket, database_path: PathBuf) -> fairing::Result { + // TODO: we can inject here more stuff based on our validator-api global config + // struct. Maybe different pool size or timeout intervals? + let mut opts = sqlx::sqlite::SqliteConnectOptions::new() + .filename(&database_path) + .create_if_missing(true); + + // TODO: do we want auto_vacuum ? + + opts.disable_statement_logging(); + + let connection_pool = match sqlx::SqlitePool::connect_with(opts).await { + Ok(db) => db, + Err(e) => { + error!("Failed to connect to SQLx database: {}", e); + return Err(rocket); + } + }; + + if let Err(e) = sqlx::migrate!("./migrations").run(&connection_pool).await { + error!("Failed to initialize SQLx database: {}", e); + return Err(rocket); + } + + info!("Database migration finished!"); + + let storage = NodeStatusStorage { + inner: NodeStatusStorageInner { connection_pool }, + }; + + Ok(rocket.manage(storage)) + } + + pub(crate) fn stage(database_path: PathBuf) -> AdHoc { + AdHoc::try_on_ignite("SQLx Database", |rocket| { + NodeStatusStorage::init(rocket, database_path) + }) + } + + /// Gets all statuses for particular mixnode (ipv4 and ipv6) that were inserted in last 24h. + async fn get_mixnode_daily_statuses( + &self, + identity: &str, + ) -> Result<(Vec, Vec), NodeStatusApiError> { + let now = OffsetDateTime::now_utc(); + let day_ago = now - ONE_DAY; + + let ipv4_statuses = self + .inner + .get_mixnode_ipv4_statuses_since(identity, day_ago.unix_timestamp()) + .await + .map_err(|_| NodeStatusApiError::InternalDatabaseError)?; + + let ipv6_statuses = self + .inner + .get_mixnode_ipv6_statuses_since(identity, day_ago.unix_timestamp()) + .await + .map_err(|_| NodeStatusApiError::InternalDatabaseError)?; + + Ok((ipv4_statuses, ipv6_statuses)) + } + + /// Gets all statuses for particular gateway (ipv4 and ipv6) that were inserted in last 24h. + async fn get_gateway_daily_statuses( + &self, + identity: &str, + ) -> Result<(Vec, Vec), NodeStatusApiError> { + let now = OffsetDateTime::now_utc(); + let day_ago = now - ONE_DAY; + + let ipv4_statuses = self + .inner + .get_gateway_ipv4_statuses_since(identity, day_ago.unix_timestamp()) + .await + .map_err(|_| NodeStatusApiError::InternalDatabaseError)?; + + let ipv6_statuses = self + .inner + .get_gateway_ipv6_statuses_since(identity, day_ago.unix_timestamp()) + .await + .map_err(|_| NodeStatusApiError::InternalDatabaseError)?; + + Ok((ipv4_statuses, ipv6_statuses)) + } + + /// Tries to construct a status report for mixnode with the specified identity. + pub(crate) async fn construct_mixnode_report( + &self, + identity: &str, + ) -> Result { + let (ipv4_statuses, ipv6_statuses) = self.get_mixnode_daily_statuses(identity).await?; + + // if we have no statuses, the node doesn't exist (or monitor is down), but either way, we can't make a report + if ipv4_statuses.is_empty() { + return Err(NodeStatusApiError::MixnodeReportNotFound( + identity.to_owned(), + )); + } + + // now, technically this is not a critical error, but this should have NEVER happened in the first place + // so something super weird is going on + if ipv4_statuses.len() != ipv6_statuses.len() { + error!("Somehow we have different number of ipv4 and ipv6 statuses for mixnode {}! (ipv4: {}, ipv6: {})", + identity, + ipv4_statuses.len(), + ipv6_statuses.len(), + ) + } + + let mixnode_owner = self + .inner + .get_mixnode_owner(identity) + .await + .map_err(|_| NodeStatusApiError::InternalDatabaseError)? + .expect("The node doesn't have an owner even though we have status information on it!"); + + Ok(MixnodeStatusReport::construct_from_last_day_reports( + identity.to_owned(), + mixnode_owner, + ipv4_statuses, + ipv6_statuses, + )) + } + + pub(crate) async fn construct_gateway_report( + &self, + identity: &str, + ) -> Result { + let (ipv4_statuses, ipv6_statuses) = self.get_gateway_daily_statuses(identity).await?; + + // if we have no statuses, the node doesn't exist (or monitor is down), but either way, we can't make a report + if ipv4_statuses.is_empty() { + return Err(NodeStatusApiError::GatewayReportNotFound( + identity.to_owned(), + )); + } + + // now, technically this is not a critical error, but this should have NEVER happened in the first place + // so something super weird is going on + if ipv4_statuses.len() != ipv6_statuses.len() { + error!("Somehow we have different number of ipv4 and ipv6 statuses for gateway {}! (ipv4: {}, ipv6: {})", + identity, + ipv4_statuses.len(), + ipv6_statuses.len(), + ) + } + + let gateway_owner = self + .inner + .get_gateway_owner(identity) + .await + .map_err(|_| NodeStatusApiError::InternalDatabaseError)? + .expect( + "The gateway doesn't have an owner even though we have status information on it!", + ); + + Ok(GatewayStatusReport::construct_from_last_day_reports( + identity.to_owned(), + gateway_owner, + ipv4_statuses, + ipv6_statuses, + )) + } + + pub(crate) async fn get_mixnode_uptime_history( + &self, + identity: &str, + ) -> Result { + let history = self + .inner + .get_mixnode_historical_uptimes(identity) + .await + .map_err(|_| NodeStatusApiError::InternalDatabaseError)?; + + if history.is_empty() { + return Err(NodeStatusApiError::MixnodeUptimeHistoryNotFound( + identity.to_owned(), + )); + } + + let mixnode_owner = self + .inner + .get_mixnode_owner(identity) + .await + .map_err(|_| NodeStatusApiError::InternalDatabaseError)? + .expect("The node doesn't have an owner even though we have uptime history for it!"); + + Ok(MixnodeUptimeHistory::new( + identity.to_owned(), + mixnode_owner, + history, + )) + } + + pub(crate) async fn get_gateway_uptime_history( + &self, + identity: &str, + ) -> Result { + let history = self + .inner + .get_gateway_historical_uptimes(identity) + .await + .map_err(|_| NodeStatusApiError::InternalDatabaseError)?; + + if history.is_empty() { + return Err(NodeStatusApiError::GatewayUptimeHistoryNotFound( + identity.to_owned(), + )); + } + + let gateway_owner = self + .inner + .get_gateway_owner(identity) + .await + .map_err(|_| NodeStatusApiError::InternalDatabaseError)? + .expect("The gateway doesn't have an owner even though we have uptime history for it!"); + + Ok(GatewayUptimeHistory::new( + identity.to_owned(), + gateway_owner, + history, + )) + } + + // NOTE: this method will go away once we move payments into the validator-api + // it just helps us to get rid of having to query for reports of each node individually + pub(crate) async fn get_all_mixnode_reports( + &self, + ) -> Result, NodeStatusApiError> { + let reports = self + .inner + .get_all_active_mixnodes_statuses() + .await + .map_err(|_| NodeStatusApiError::InternalDatabaseError)? + .into_iter() + .map(|statuses| { + MixnodeStatusReport::construct_from_last_day_reports( + statuses.pub_key, + statuses.owner, + statuses.ipv4_statuses, + statuses.ipv6_statuses, + ) + }) + .collect(); + + Ok(reports) + } + + // NOTE: this method will go away once we move payments into the validator-api + // it just helps us to get rid of having to query for reports of each node individually + pub(crate) async fn get_all_gateway_reports( + &self, + ) -> Result, NodeStatusApiError> { + let reports = self + .inner + .get_all_active_gateways_statuses() + .await + .map_err(|_| NodeStatusApiError::InternalDatabaseError)? + .into_iter() + .map(|statuses| { + GatewayStatusReport::construct_from_last_day_reports( + statuses.pub_key, + statuses.owner, + statuses.ipv4_statuses, + statuses.ipv6_statuses, + ) + }) + .collect(); + + Ok(reports) + } + + // Used by network monitor + pub(crate) async fn submit_new_statuses( + &self, + mixnode_results: Vec, + gateway_results: Vec, + ) -> Result<(), NodeStatusApiError> { + self.inner + .submit_new_statuses(mixnode_results, gateway_results) + .await + .map_err(|_| NodeStatusApiError::InternalDatabaseError) + } + + // Called on timer/reward script + async fn update_historical_uptimes( + &self, + today_iso_8601: &str, + ) -> Result<(), NodeStatusApiError> { + // get statuses for all active mixnodes... + let active_mixnodes_statuses = self + .inner + .get_all_active_mixnodes_statuses() + .await + .map_err(|_| NodeStatusApiError::InternalDatabaseError)?; + + for statuses in active_mixnodes_statuses.into_iter() { + let ipv4_day_up = statuses + .ipv4_statuses + .iter() + .filter(|status| status.up) + .count(); + let ipv6_day_up = statuses + .ipv6_statuses + .iter() + .filter(|status| status.up) + .count(); + + // calculate their uptimes for the last 24h + let ipv4_uptime = Uptime::from_ratio(ipv4_day_up, statuses.ipv4_statuses.len()) + .unwrap() + .u8(); + let ipv6_uptime = Uptime::from_ratio(ipv6_day_up, statuses.ipv6_statuses.len()) + .unwrap() + .u8(); + + // and insert into the database + self.inner + .insert_mixnode_historical_uptime( + statuses.node_id, + today_iso_8601, + ipv4_uptime, + ipv6_uptime, + ) + .await + .map_err(|_| NodeStatusApiError::InternalDatabaseError)?; + } + + // get statuses for all active gateways... + let active_gateways_statuses = self + .inner + .get_all_active_gateways_statuses() + .await + .map_err(|_| NodeStatusApiError::InternalDatabaseError)?; + + for statuses in active_gateways_statuses.into_iter() { + let ipv4_day_up = statuses + .ipv4_statuses + .iter() + .filter(|status| status.up) + .count(); + let ipv6_day_up = statuses + .ipv6_statuses + .iter() + .filter(|status| status.up) + .count(); + + // calculate their uptimes for the last 24h + let ipv4_uptime = Uptime::from_ratio(ipv4_day_up, statuses.ipv4_statuses.len()) + .unwrap() + .u8(); + let ipv6_uptime = Uptime::from_ratio(ipv6_day_up, statuses.ipv6_statuses.len()) + .unwrap() + .u8(); + + // and insert into the database + self.inner + .insert_gateway_historical_uptime( + statuses.node_id, + today_iso_8601, + ipv4_uptime, + ipv6_uptime, + ) + .await + .map_err(|_| NodeStatusApiError::InternalDatabaseError)?; + } + + Ok(()) + } + + async fn check_if_historical_uptimes_exist_for_date( + &self, + date_iso_8601: &str, + ) -> Result { + self.inner + .check_for_historical_uptime_existence(date_iso_8601) + .await + .map_err(|_| NodeStatusApiError::InternalDatabaseError) + } + + // Called on timer/reward script + async fn purge_old_statuses(&self) -> Result<(), NodeStatusApiError> { + self.inner + .purge_old_statuses() + .await + .map_err(|_| NodeStatusApiError::InternalDatabaseError) + } + + pub(crate) async fn daily_chores(&self) -> Result { + let today_iso_8601 = OffsetDateTime::now_utc().date().to_string(); + + // if we have already performed the update for today's date, don't do anything + if self + .check_if_historical_uptimes_exist_for_date(&today_iso_8601) + .await? + { + Ok(false) + } else { + info!( + "Updating historical daily uptimes of all nodes and purging old status reports..." + ); + self.update_historical_uptimes(&today_iso_8601).await?; + self.purge_old_statuses().await?; + Ok(true) + } + } +} + +// all SQL goes here +impl NodeStatusStorageInner { + /// Tries to obtain owner value of given mixnode given its identity + async fn get_mixnode_owner(&self, identity: &str) -> Result, sqlx::Error> { + let owner = sqlx::query!( + "SELECT owner FROM mixnode_details WHERE pub_key = ?", + identity + ) + .fetch_optional(&self.connection_pool) + .await? + .map(|row| row.owner); + + Ok(owner) + } + + /// Tries to obtain owner value of given gateway given its identity + async fn get_gateway_owner(&self, identity: &str) -> Result, sqlx::Error> { + let owner = sqlx::query!( + "SELECT owner FROM gateway_details WHERE pub_key = ?", + identity + ) + .fetch_optional(&self.connection_pool) + .await? + .map(|row| row.owner); + + Ok(owner) + } + + /// Gets all ipv4 statuses for mixnode with particular identity that were inserted + /// into the database after the specified unix timestamp. + async fn get_mixnode_ipv4_statuses_since( + &self, + identity: &str, + timestamp: UnixTimestamp, + ) -> Result, sqlx::Error> { + sqlx::query_as!( + NodeStatus, + r#" + SELECT timestamp, up + FROM mixnode_ipv4_status + JOIN mixnode_details + ON mixnode_ipv4_status.mixnode_details_id = mixnode_details.id + WHERE mixnode_details.pub_key=? AND mixnode_ipv4_status.timestamp > ?; + "#, + identity, + timestamp, + ) + .fetch_all(&self.connection_pool) + .await + } + + /// Gets all ipv6 statuses for mixnode with particular identity that were inserted + /// into the database after the specified unix timestamp. + async fn get_mixnode_ipv6_statuses_since( + &self, + identity: &str, + timestamp: UnixTimestamp, + ) -> Result, sqlx::Error> { + sqlx::query_as!( + NodeStatus, + r#" + SELECT timestamp, up + FROM mixnode_ipv6_status + JOIN mixnode_details + ON mixnode_ipv6_status.mixnode_details_id = mixnode_details.id + WHERE mixnode_details.pub_key=? AND mixnode_ipv6_status.timestamp > ?; + "#, + identity, + timestamp + ) + .fetch_all(&self.connection_pool) + .await + } + + /// Gets all ipv4 statuses for gateway with particular identity that were inserted + /// into the database after the specified unix timestamp. + async fn get_gateway_ipv4_statuses_since( + &self, + identity: &str, + timestamp: UnixTimestamp, + ) -> Result, sqlx::Error> { + sqlx::query_as!( + NodeStatus, + r#" + SELECT timestamp, up + FROM gateway_ipv4_status + JOIN gateway_details + ON gateway_ipv4_status.gateway_details_id = gateway_details.id + WHERE gateway_details.pub_key=? AND gateway_ipv4_status.timestamp > ?; + "#, + identity, + timestamp, + ) + .fetch_all(&self.connection_pool) + .await + } + + /// Gets all ipv6 statuses for gateway with particular identity that were inserted + /// into the database after the specified unix timestamp. + async fn get_gateway_ipv6_statuses_since( + &self, + identity: &str, + timestamp: UnixTimestamp, + ) -> Result, sqlx::Error> { + sqlx::query_as!( + NodeStatus, + r#" + SELECT timestamp, up + FROM gateway_ipv6_status + JOIN gateway_details + ON gateway_ipv6_status.gateway_details_id = gateway_details.id + WHERE gateway_details.pub_key=? AND gateway_ipv6_status.timestamp > ?; + "#, + identity, + timestamp + ) + .fetch_all(&self.connection_pool) + .await + } + + /// Gets the historical daily uptime associated with the particular mixnode + async fn get_mixnode_historical_uptimes( + &self, + identity: &str, + ) -> Result, sqlx::Error> { + let uptimes = sqlx::query!( + r#" + SELECT date, ipv4_uptime, ipv6_uptime + FROM mixnode_historical_uptime + JOIN mixnode_details + ON mixnode_historical_uptime.mixnode_details_id = mixnode_details.id + WHERE mixnode_details.pub_key = ? + ORDER BY date ASC + "#, + identity + ) + .fetch_all(&self.connection_pool) + .await? + .into_iter() + // filter out nodes with valid uptime (in theory all should be 100% valid since we insert them ourselves, but + // better safe than sorry and not use an unwrap) + .filter_map(|row| { + Uptime::try_from(row.ipv4_uptime) + .ok() + .map(|ipv4_uptime| { + Uptime::try_from(row.ipv6_uptime) + .ok() + .map(|ipv6_uptime| HistoricalUptime { + date: row.date, + ipv4_uptime, + ipv6_uptime, + }) + }) + .flatten() + }) + .collect(); + + Ok(uptimes) + } + + /// Gets the historical daily uptime associated with the particular gateway + async fn get_gateway_historical_uptimes( + &self, + identity: &str, + ) -> Result, sqlx::Error> { + let uptimes = sqlx::query!( + r#" + SELECT date, ipv4_uptime, ipv6_uptime + FROM gateway_historical_uptime + JOIN gateway_details + ON gateway_historical_uptime.gateway_details_id = gateway_details.id + WHERE gateway_details.pub_key = ? + ORDER BY date ASC + "#, + identity + ) + .fetch_all(&self.connection_pool) + .await? + .into_iter() + // filter out nodes with valid uptime (in theory all should be 100% valid since we insert them ourselves, but + // better safe than sorry and not use an unwrap) + .filter_map(|row| { + Uptime::try_from(row.ipv4_uptime) + .ok() + .map(|ipv4_uptime| { + Uptime::try_from(row.ipv6_uptime) + .ok() + .map(|ipv6_uptime| HistoricalUptime { + date: row.date, + ipv4_uptime, + ipv6_uptime, + }) + }) + .flatten() + }) + .collect(); + + Ok(uptimes) + } + + // NOTE: this method will go away once we move payments into the validator-api + // it just helps us to get rid of having to query for reports of each node individually + /// Returns public key, owner and id of all mixnodes that have had any ipv4 statuses submitted + /// since provided timestamp. + async fn get_all_active_mixnodes( + &self, + timestamp: UnixTimestamp, + ) -> Result, sqlx::Error> { + // find mixnode details of all nodes that have had at least 1 ipv4 status since the provided + // timestamp + // TODO: I dont know if theres a potential issue of if we have a lot of inactive nodes that + // haven't mixed in ages, they might increase the query times? + sqlx::query_as!( + ActiveNode, + r#" + SELECT DISTINCT pub_key, owner, id + FROM mixnode_details + JOIN mixnode_ipv4_status + ON mixnode_details.id = mixnode_ipv4_status.mixnode_details_id + WHERE EXISTS ( + SELECT 1 FROM mixnode_ipv4_status WHERE timestamp > ? + ) + "#, + timestamp + ) + .fetch_all(&self.connection_pool) + .await + } + + // NOTE: this method will go away once we move payments into the validator-api + // it just helps us to get rid of having to query for reports of each node individually + /// Returns public key, owner and id of all gateways that have had any ipv4 statuses submitted + /// since provided timestamp. + async fn get_all_active_gateways( + &self, + timestamp: UnixTimestamp, + ) -> Result, sqlx::Error> { + sqlx::query_as!( + ActiveNode, + r#" + SELECT DISTINCT pub_key, owner, id + FROM gateway_details + JOIN gateway_ipv4_status + ON gateway_details.id = gateway_ipv4_status.gateway_details_id + WHERE EXISTS ( + SELECT 1 FROM gateway_ipv4_status WHERE timestamp > ? + ) + "#, + timestamp + ) + .fetch_all(&self.connection_pool) + .await + } + + /// Gets all ipv4 statuses for mixnode with particular id that were inserted + /// into the database after the specified unix timestamp. + async fn get_mixnode_ipv4_statuses_since_by_id( + &self, + id: i64, + timestamp: UnixTimestamp, + ) -> Result, sqlx::Error> { + sqlx::query_as!( + NodeStatus, + r#" + SELECT timestamp, up + FROM mixnode_ipv4_status + WHERE mixnode_details_id=? AND timestamp > ?; + "#, + id, + timestamp + ) + .fetch_all(&self.connection_pool) + .await + } + + /// Gets all ipv6 statuses for mixnode with particular id that were inserted + /// into the database after the specified unix timestamp. + async fn get_mixnode_ipv6_statuses_since_by_id( + &self, + id: i64, + timestamp: UnixTimestamp, + ) -> Result, sqlx::Error> { + sqlx::query_as!( + NodeStatus, + r#" + SELECT timestamp, up + FROM mixnode_ipv6_status + WHERE mixnode_details_id=? AND timestamp > ?; + "#, + id, + timestamp + ) + .fetch_all(&self.connection_pool) + .await + } + + /// Gets all ipv4 statuses for gateway with particular id that were inserted + /// into the database after the specified unix timestamp. + async fn get_gateway_ipv4_statuses_since_by_id( + &self, + id: i64, + timestamp: UnixTimestamp, + ) -> Result, sqlx::Error> { + sqlx::query_as!( + NodeStatus, + r#" + SELECT timestamp, up + FROM gateway_ipv4_status + WHERE gateway_details_id=? AND timestamp > ?; + "#, + id, + timestamp + ) + .fetch_all(&self.connection_pool) + .await + } + + /// Gets all ipv6 statuses for gateway with particular id that were inserted + /// into the database after the specified unix timestamp. + async fn get_gateway_ipv6_statuses_since_by_id( + &self, + id: i64, + timestamp: UnixTimestamp, + ) -> Result, sqlx::Error> { + sqlx::query_as!( + NodeStatus, + r#" + SELECT timestamp, up + FROM gateway_ipv6_status + WHERE gateway_details_id=? AND timestamp > ?; + "#, + id, + timestamp + ) + .fetch_all(&self.connection_pool) + .await + } + + // NOTE: this method will go away once we move payments into the validator-api + // it just helps us to get rid of having to query for reports of each node individually + // TODO: should that live on the 'Inner' struct or should it rather exist on the actual storage struct + // since technically it doesn't touch any SQL directly + async fn get_all_active_mixnodes_statuses( + &self, + ) -> Result, sqlx::Error> { + let now = OffsetDateTime::now_utc(); + let day_ago = (now - ONE_DAY).unix_timestamp(); + + let active_nodes = self.get_all_active_mixnodes(day_ago).await?; + + let mut active_day_statuses = Vec::with_capacity(active_nodes.len()); + for active_node in active_nodes.into_iter() { + let ipv4_statuses = self + .get_mixnode_ipv4_statuses_since_by_id(active_node.id, day_ago) + .await?; + let ipv6_statuses = self + .get_mixnode_ipv6_statuses_since_by_id(active_node.id, day_ago) + .await?; + + let statuses = ActiveNodeDayStatuses { + pub_key: active_node.pub_key, + owner: active_node.owner, + node_id: active_node.id, + ipv4_statuses, + ipv6_statuses, + }; + + active_day_statuses.push(statuses); + } + + Ok(active_day_statuses) + } + + // NOTE: this method will go away once we move payments into the validator-api + // it just helps us to get rid of having to query for reports of each node individually + // TODO: should that live on the 'Inner' struct or should it rather exist on the actual storage struct + // since technically it doesn't touch any SQL directly + async fn get_all_active_gateways_statuses( + &self, + ) -> Result, sqlx::Error> { + let now = OffsetDateTime::now_utc(); + let day_ago = (now - ONE_DAY).unix_timestamp(); + + let active_nodes = self.get_all_active_gateways(day_ago).await?; + + let mut active_day_statuses = Vec::with_capacity(active_nodes.len()); + for active_node in active_nodes.into_iter() { + let ipv4_statuses = self + .get_gateway_ipv4_statuses_since_by_id(active_node.id, day_ago) + .await?; + let ipv6_statuses = self + .get_gateway_ipv6_statuses_since_by_id(active_node.id, day_ago) + .await?; + + let statuses = ActiveNodeDayStatuses { + pub_key: active_node.pub_key, + owner: active_node.owner, + node_id: active_node.id, + ipv4_statuses, + ipv6_statuses, + }; + + active_day_statuses.push(statuses); + } + + Ok(active_day_statuses) + } + + /// Tries to submit [`NodeResult`] from the network monitor to the database. + async fn submit_new_statuses( + &self, + mixnode_results: Vec, + gateway_results: Vec, + ) -> Result<(), sqlx::Error> { + // TODO: lower that to debug before creating PR + info!("Submitting new node results to the database. There are {} mixnode results and {} gateway results", mixnode_results.len(), gateway_results.len()); + + let now = OffsetDateTime::now_utc().unix_timestamp(); + + // insert it all in a transaction to make sure all nodes are updated at the same time + // (plus it's a nice guard against new nodes) + let mut tx = self.connection_pool.begin().await?; + for mixnode_result in mixnode_results { + // if mixnode info doesn't exist, insert it and get its id + + // TODO: the potential "problem" (if you can call it that way) is that if entry DID exist + // then the id field will be incremented for the next node we create thus we will + // have gaps in our ids. ask @DH if that's fine (I don't see why not because nodes + // are still correctly ordered and you can get their total number with a simple query + // and we'd have to run the system until the heat death of the universe to run out of id numbers) + let mixnode_id = sqlx::query!( + r#" + INSERT OR IGNORE INTO mixnode_details(pub_key, owner) VALUES (?, ?); + SELECT id FROM mixnode_details WHERE pub_key = ?; + "#, + mixnode_result.pub_key, + mixnode_result.owner, + mixnode_result.pub_key, + ) + .fetch_one(&mut tx) + .await? + .id; + + // insert ipv4 status + sqlx::query!( + r#" + INSERT INTO mixnode_ipv4_status (mixnode_details_id, up, timestamp) VALUES (?, ?, ?); + "#, + mixnode_id, + mixnode_result.working_ipv4, + now + ) + .execute(&mut tx) + .await?; + + // insert ipv6 status + sqlx::query!( + r#" + INSERT INTO mixnode_ipv6_status (mixnode_details_id, up, timestamp) VALUES (?, ?, ?); + "#, + mixnode_id, + mixnode_result.working_ipv6, + now + ) + .execute(&mut tx) + .await?; + } + + // repeat the procedure for gateways + for gateway_result in gateway_results { + // if gateway info doesn't exist, insert it and get its id + + // same ID "problem" as described for mixnode insertion + let gateway_id = sqlx::query!( + r#" + INSERT OR IGNORE INTO gateway_details(pub_key, owner) VALUES (?, ?); + SELECT id FROM gateway_details WHERE pub_key = ?; + "#, + gateway_result.pub_key, + gateway_result.owner, + gateway_result.pub_key, + ) + .fetch_one(&mut tx) + .await? + .id; + + // insert ipv4 status + sqlx::query!( + r#" + INSERT INTO gateway_ipv4_status (gateway_details_id, up, timestamp) VALUES (?, ?, ?); + "#, + gateway_id, + gateway_result.working_ipv4, + now + ) + .execute(&mut tx) + .await?; + + // insert ipv6 status + sqlx::query!( + r#" + INSERT INTO gateway_ipv6_status (gateway_details_id, up, timestamp) VALUES (?, ?, ?); + "#, + gateway_id, + gateway_result.working_ipv6, + now + ) + .execute(&mut tx) + .await?; + } + + // finally commit the transaction + tx.commit().await + } + + /// Checks whether there are already any historical uptimes with this particular date. + async fn check_for_historical_uptime_existence( + &self, + today_iso_8601: &str, + ) -> Result { + sqlx::query!( + "SELECT EXISTS (SELECT 1 FROM mixnode_historical_uptime WHERE date = ?) AS 'exists'", + today_iso_8601 + ) + .fetch_one(&self.connection_pool) + .await + .map(|result| result.exists == 1) + } + + /// Creates new entry for mixnode historical uptime + async fn insert_mixnode_historical_uptime( + &self, + node_id: i64, + date: &str, + ipv4_uptime: u8, + ipv6_uptime: u8, + ) -> Result<(), sqlx::Error> { + sqlx::query!( + "INSERT INTO mixnode_historical_uptime(mixnode_details_id, date, ipv4_uptime, ipv6_uptime) VALUES (?, ?, ?, ?)", + node_id, + date, + ipv4_uptime, + ipv6_uptime, + ).execute(&self.connection_pool).await?; + Ok(()) + } + + /// Creates new entry for gatewy historical uptime + async fn insert_gateway_historical_uptime( + &self, + node_id: i64, + date: &str, + ipv4_uptime: u8, + ipv6_uptime: u8, + ) -> Result<(), sqlx::Error> { + sqlx::query!( + "INSERT INTO gateway_historical_uptime(gateway_details_id, date, ipv4_uptime, ipv6_uptime) VALUES (?, ?, ?, ?)", + node_id, + date, + ipv4_uptime, + ipv6_uptime, + ).execute(&self.connection_pool).await?; + Ok(()) + } + + /// Removes all statuses from the database that are older than 48h. + async fn purge_old_statuses(&self) -> Result<(), sqlx::Error> { + let now = OffsetDateTime::now_utc(); + let two_days_ago = (now - 2 * ONE_DAY).unix_timestamp(); + + sqlx::query!( + "DELETE FROM mixnode_ipv4_status WHERE timestamp < ?", + two_days_ago + ) + .execute(&self.connection_pool) + .await?; + + sqlx::query!( + "DELETE FROM mixnode_ipv6_status WHERE timestamp < ?", + two_days_ago + ) + .execute(&self.connection_pool) + .await?; + + sqlx::query!( + "DELETE FROM gateway_ipv4_status WHERE timestamp < ?", + two_days_ago + ) + .execute(&self.connection_pool) + .await?; + + sqlx::query!( + "DELETE FROM gateway_ipv6_status WHERE timestamp < ?", + two_days_ago + ) + .execute(&self.connection_pool) + .await?; + + Ok(()) + } +} diff --git a/validator-api/src/node_status_api/utils.rs b/validator-api/src/node_status_api/utils.rs new file mode 100644 index 0000000000..a173089451 --- /dev/null +++ b/validator-api/src/node_status_api/utils.rs @@ -0,0 +1,99 @@ +// Copyright 2021 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 + +use crate::node_status_api::models::Uptime; +use crate::node_status_api::{FIFTEEN_MINUTES, ONE_HOUR}; +use sqlx::types::time::OffsetDateTime; + +// Internally used struct to catch results from the database to calculate uptimes for given mixnode/gateway +pub(crate) struct NodeStatus { + pub(crate) timestamp: i64, + pub(crate) up: bool, +} + +// Internally used struct to catch results from the database to find active mixnodes/gateways +pub(crate) struct ActiveNode { + pub(crate) id: i64, + pub(crate) pub_key: String, + pub(crate) owner: String, +} + +// A temporary helper struct used to produce reports for active nodes. +pub(crate) struct ActiveNodeDayStatuses { + pub(crate) pub_key: String, + pub(crate) owner: String, + pub(crate) node_id: i64, + + pub(crate) ipv4_statuses: Vec, + pub(crate) ipv6_statuses: Vec, +} + +// A helper intermediate struct to remove duplicate code for construction of mixnode and gateway reports +pub(crate) struct NodeUptimes { + pub(crate) most_recent_ipv4: bool, + pub(crate) most_recent_ipv6: bool, + + pub(crate) last_hour_ipv4: Uptime, + pub(crate) last_hour_ipv6: Uptime, + + pub(crate) last_day_ipv4: Uptime, + pub(crate) last_day_ipv6: Uptime, +} + +impl NodeUptimes { + pub(crate) fn calculate_from_last_day_reports( + last_day_ipv4: Vec, + last_day_ipv6: Vec, + ) -> Self { + let now = OffsetDateTime::now_utc(); + let hour_ago = (now - ONE_HOUR).unix_timestamp(); + let fifteen_minutes_ago = (now - FIFTEEN_MINUTES).unix_timestamp(); + + let ipv4_day_total = last_day_ipv4.len(); + let ipv6_day_total = last_day_ipv6.len(); + + let ipv4_day_up = last_day_ipv4.iter().filter(|report| report.up).count(); + let ipv6_day_up = last_day_ipv6.iter().filter(|report| report.up).count(); + + let ipv4_hour_total = last_day_ipv4 + .iter() + .filter(|report| report.timestamp >= hour_ago) + .count(); + let ipv6_hour_total = last_day_ipv6 + .iter() + .filter(|report| report.timestamp >= hour_ago) + .count(); + + let ipv4_hour_up = last_day_ipv4 + .iter() + .filter(|report| report.up && report.timestamp >= hour_ago) + .count(); + let ipv6_hour_up = last_day_ipv6 + .iter() + .filter(|report| report.up && report.timestamp >= hour_ago) + .count(); + + // most recent status MUST BE within last 15min + let most_recent_ipv4 = last_day_ipv4 + .iter() + .max_by_key(|report| report.timestamp) // find the most recent + .map(|status| status.timestamp >= fifteen_minutes_ago && status.up) // make sure its within last 15min + .unwrap_or_default(); + let most_recent_ipv6 = last_day_ipv6 + .iter() + .max_by_key(|report| report.timestamp) // find the most recent + .map(|status| status.timestamp >= fifteen_minutes_ago && status.up) // make sure its within last 15min + .unwrap_or_default(); + + // the unwraps in Uptime::from_ratio are fine because it's impossible for us to have more "up" results than all results in total + // because both of those values originate from the same vector + NodeUptimes { + most_recent_ipv4, + most_recent_ipv6, + last_hour_ipv4: Uptime::from_ratio(ipv4_hour_up, ipv4_hour_total).unwrap(), + last_hour_ipv6: Uptime::from_ratio(ipv6_hour_up, ipv6_hour_total).unwrap(), + last_day_ipv4: Uptime::from_ratio(ipv4_day_up, ipv4_day_total).unwrap(), + last_day_ipv6: Uptime::from_ratio(ipv6_day_up, ipv6_day_total).unwrap(), + } + } +}