Skip to content
Snippets Groups Projects
Select Git revision
  • 043ef8da72ac1fba134f32c3c0154aa56a4ea0f5
  • master default
  • cmake_fixes
  • pulls/1772757862/750
  • copilot/fix-770
  • windows_ci_static
  • c_link
  • cpack
  • windows_ci
  • cert_pk_id
  • proxy_push_result
  • cnode_put_id
  • update-windows-build
  • proxy
  • resubscribe_on_token_change
  • actions
  • client_mode
  • llhttp
  • search_node_add
  • crypto_aes_gcm_argon2
  • ios_notifications
  • v3.4.0
  • v3.3.1
  • v3.3.1rc1
  • v3.3.1rc2
  • v3.3.0
  • v3.2.0
  • v3.1.11
  • v3.1.10
  • v3.1.9
  • v3.1.8.2
  • v3.1.8.1
  • v3.1.8
  • v3.1.7
  • v3.1.6
  • v3.1.5
  • v3.1.4
  • v3.1.3
  • v3.1.2
  • v3.1
  • v3.0.1
41 results

dhtrunner.cpp

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    dhtrunner.cpp 36.55 KiB
    /*
     *  Copyright (C) 2014-2020 Savoir-faire Linux Inc.
     *  Authors: Adrien Béraud <adrien.beraud@savoirfairelinux.com>
     *           Simon Désaulniers <simon.desaulniers@savoirfairelinux.com>
     *           Sébastien Blin <sebastien.blin@savoirfairelinux.com>
     *
     *  This program is free software; you can redistribute it and/or modify
     *  it under the terms of the GNU General Public License as published by
     *  the Free Software Foundation; either version 3 of the License, or
     *  (at your option) any later version.
     *
     *  This program is distributed in the hope that it will be useful,
     *  but WITHOUT ANY WARRANTY; without even the implied warranty of
     *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     *  GNU General Public License for more details.
     *
     *  You should have received a copy of the GNU General Public License
     *  along with this program. If not, see <https://www.gnu.org/licenses/>.
     */
    
    #ifdef HAVE_CONFIG_H
    #include "config.h"
    #endif
    
    #include "dhtrunner.h"
    #include "securedht.h"
    #include "network_utils.h"
    #ifdef OPENDHT_PEER_DISCOVERY
    #include "peer_discovery.h"
    #endif
    #ifdef OPENDHT_PROXY_CLIENT
    #include "dht_proxy_client.h"
    #endif
    
    #include <fstream>
    
    namespace dht {
    
    static const std::string PEER_DISCOVERY_DHT_SERVICE = "dht";
    
    struct DhtRunner::Listener {
        size_t tokenClassicDht {0};
        size_t tokenProxyDht {0};
        ValueCallback gcb;
        InfoHash hash {};
        Value::Filter f;
        Where w;
    };
    
    struct NodeInsertionPack {
        dht::InfoHash nodeId;
        in_port_t port;
        dht::NetId net;
        MSGPACK_DEFINE(nodeId, port, net)
    };
    
    DhtRunner::DhtRunner() : dht_()
    #ifdef OPENDHT_PROXY_CLIENT
    , dht_via_proxy_()
    #endif //OPENDHT_PROXY_CLIENT
    {
    #ifdef _WIN32
        WSADATA wsd;
        if (WSAStartup(MAKEWORD(2,2), &wsd) != 0)
            throw DhtException("Can't initialize Winsock2");
    #endif
    }
    
    DhtRunner::~DhtRunner()
    {