LCOV - code coverage report
Current view: top level - src - netbase.h (source / functions) Hit Total Coverage
Test: total_coverage.info Lines: 4 4 100.0 %
Date: 2020-09-26 01:30:44 Functions: 8 8 100.0 %

          Line data    Source code
       1             : // Copyright (c) 2009-2019 The Bitcoin Core developers
       2             : // Distributed under the MIT software license, see the accompanying
       3             : // file COPYING or http://www.opensource.org/licenses/mit-license.php.
       4             : 
       5             : #ifndef BITCOIN_NETBASE_H
       6             : #define BITCOIN_NETBASE_H
       7             : 
       8             : #if defined(HAVE_CONFIG_H)
       9             : #include <config/bitcoin-config.h>
      10             : #endif
      11             : 
      12             : #include <compat.h>
      13             : #include <netaddress.h>
      14             : #include <serialize.h>
      15             : 
      16             : #include <stdint.h>
      17             : #include <string>
      18             : #include <vector>
      19             : 
      20             : extern int nConnectTimeout;
      21             : extern bool fNameLookup;
      22             : 
      23             : //! -timeout default
      24             : static const int DEFAULT_CONNECT_TIMEOUT = 5000;
      25             : //! -dns default
      26             : static const int DEFAULT_NAME_LOOKUP = true;
      27             : 
      28        8495 : class proxyType
      29             : {
      30             : public:
      31        8456 :     proxyType(): randomize_credentials(false) {}
      32           8 :     explicit proxyType(const CService &_proxy, bool _randomize_credentials=false): proxy(_proxy), randomize_credentials(_randomize_credentials) {}
      33             : 
      34         787 :     bool IsValid() const { return proxy.IsValid(); }
      35             : 
      36             :     CService proxy;
      37             :     bool randomize_credentials;
      38             : };
      39             : 
      40             : enum Network ParseNetwork(const std::string& net);
      41             : std::string GetNetworkName(enum Network net);
      42             : bool SetProxy(enum Network net, const proxyType &addrProxy);
      43             : bool GetProxy(enum Network net, proxyType &proxyInfoOut);
      44             : bool IsProxy(const CNetAddr &addr);
      45             : bool SetNameProxy(const proxyType &addrProxy);
      46             : bool HaveNameProxy();
      47             : bool GetNameProxy(proxyType &nameProxyOut);
      48             : bool LookupHost(const std::string& name, std::vector<CNetAddr>& vIP, unsigned int nMaxSolutions, bool fAllowLookup);
      49             : bool LookupHost(const std::string& name, CNetAddr& addr, bool fAllowLookup);
      50             : bool Lookup(const std::string& name, CService& addr, int portDefault, bool fAllowLookup);
      51             : bool Lookup(const std::string& name, std::vector<CService>& vAddr, int portDefault, bool fAllowLookup, unsigned int nMaxSolutions);
      52             : CService LookupNumeric(const std::string& name, int portDefault = 0);
      53             : bool LookupSubNet(const std::string& strSubnet, CSubNet& subnet);
      54             : SOCKET CreateSocket(const CService &addrConnect);
      55             : bool ConnectSocketDirectly(const CService &addrConnect, const SOCKET& hSocketRet, int nTimeout, bool manual_connection);
      56             : bool ConnectThroughProxy(const proxyType &proxy, const std::string& strDest, int port, const SOCKET& hSocketRet, int nTimeout, bool& outProxyConnectionFailed);
      57             : /** Return readable error string for a network error code */
      58             : std::string NetworkErrorString(int err);
      59             : /** Close socket and set hSocket to INVALID_SOCKET */
      60             : bool CloseSocket(SOCKET& hSocket);
      61             : /** Disable or enable blocking-mode for a socket */
      62             : bool SetSocketNonBlocking(const SOCKET& hSocket, bool fNonBlocking);
      63             : /** Set the TCP_NODELAY flag on a socket */
      64             : bool SetSocketNoDelay(const SOCKET& hSocket);
      65             : /**
      66             :  * Convert milliseconds to a struct timeval for e.g. select.
      67             :  */
      68             : struct timeval MillisToTimeval(int64_t nTimeout);
      69             : void InterruptSocks5(bool interrupt);
      70             : 
      71             : #endif // BITCOIN_NETBASE_H

Generated by: LCOV version 1.15