LCOV - code coverage report
Current view: top level - iroha-cli - validators.cpp (source / functions) Hit Total Coverage
Test: cleared_cor.info Lines: 0 33 0.0 %
Date: 2019-03-07 14:46:43 Functions: 0 4 0.0 %

          Line data    Source code
       1             : /**
       2             :  * Copyright Soramitsu Co., Ltd. All Rights Reserved.
       3             :  * SPDX-License-Identifier: Apache-2.0
       4             :  */
       5             : 
       6             : #include <cctype>
       7             : #include <iostream>
       8             : #include <sstream>
       9             : 
      10             : #include "validators.hpp"
      11             : 
      12             : namespace iroha_cli {
      13             : 
      14             :   bool validate_port(const char *, gflags::int32 port) {
      15             :     // TODO 13/10/2017 neewy: Use iroha::network::util::is_port_valid IR-509
      16             :     // #goodfirstissue
      17           0 :     if (port > 0 && port < 65535)
      18           0 :       return 1;
      19             : 
      20           0 :     std::cout << "Port can be only in range (0, 65535)\n";
      21           0 :     return 0;
      22           0 :   }
      23             : 
      24             :   bool validate_peers(const char *, const std::string &s) {
      25           0 :     std::stringstream ss(s);
      26           0 :     std::string tmp;
      27           0 :     while (std::getline(ss, tmp, ';')) {
      28           0 :       if (tmp.size() != 32) {
      29           0 :         printf("\"%s\" doesn't look like pubkey (size != 32)\n", tmp.c_str());
      30           0 :         return 0;
      31             :       }
      32             :     }
      33           0 :     return 1;
      34           0 :   }
      35             : 
      36             :   bool validate_config(const char *, const std::string &file) {
      37           0 :     if (file.empty()) {
      38           0 :       return false;
      39             :     }
      40           0 :     bool valid = true;
      41           0 :     for (const auto &ch : file) {
      42           0 :       valid &= std::isalnum(ch) || ch == '.';
      43             :     }
      44           0 :     if (!valid) {
      45           0 :       std::cout << "ERROR: Specify valid config filename.\n";
      46           0 :     }
      47           0 :     return valid;
      48           0 :   }
      49             : 
      50             :   bool validate_genesis_block(const char *, const std::string &file) {
      51           0 :     if (file.empty()) {
      52           0 :       return false;
      53             :     }
      54           0 :     bool valid = true;
      55           0 :     for (const auto &ch : file) {
      56           0 :       valid &= std::isalnum(ch) || ch == '.';
      57             :     }
      58           0 :     if (!valid) {
      59           0 :       std::cout << "ERROR: Specify valid genesis_block json filename.\n";
      60           0 :     }
      61           0 :     return valid;
      62           0 :   }
      63             : 
      64             : }  // namespace iroha_cli

Generated by: LCOV version 1.13