From b2c7044a488856ca3d053b1fe2967f9a5b41606d Mon Sep 17 00:00:00 2001 From: dbkeys Date: Tue, 16 Feb 2021 00:03:30 +0000 Subject: [PATCH 1/4] For use as a Bitmark (MARKS) (BTM) Node Tracker / DNS Seeder, use configuration file "setttings.conf", a copy of "MARKS.settings.conf". --- MARKS.settings.conf | 49 +++++++++++++++++++++++++++++++++++++++++++++ settings.conf | 49 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 MARKS.settings.conf create mode 100644 settings.conf diff --git a/MARKS.settings.conf b/MARKS.settings.conf new file mode 100644 index 0000000..538ac32 --- /dev/null +++ b/MARKS.settings.conf @@ -0,0 +1,49 @@ +// BlockChain parameters and Protocol version numbers +//---------------------------------------------------------------------------------------------------------------------------------------------/ +blockchain_name="Bitmark" // +protocol_version="70003" // --- Typically, these are found ( protocol version,init_proto_version, etc) in the coin's version.h file +init_proto_version="209" // +min_peer_proto_version="209" // Leave blank or set to the same value as protocol_version if not applicable in your blockchain +caddr_time_version="31402" // +pchMessageStart_0 = "0xf9" // --- Typically you can find the 4 pchMessageStart values in your coin's main.cpp or chainparams.cpp file +pchMessageStart_1 = "0xbe" // +pchMessageStart_2 = "0xb4" // +pchMessageStart_3 = "0xd9" // +wallet_port="9265" // P2P port: The coin servers's main port + +// BlockHeight - Get up-to-date value or default to predetermined height. +//---------------------------------------------------------------------------------------------------------------------------------------------/ + // Set to a block explorer url that returns the current block height. + // Leave blank to default to the block_count value below +explorer_url="https://chainz.cryptoid.info/marks/api.dws?q=getblockcount" // + // A 2nd block explorer url to be used as backup in case that the 1st block explorer is unreachable +second_explorer_url="" // example: "http://blockexplorer.deutsche-emark.org/api/getblockcount" +explorer_requery_seconds="120" // Used in conjunction with the explorer_url and second_explorer_url parameters. + // Interval in seconds for querying the current block height value from block explorer api url(s). + // Typically recommended set to the block interval target time. +block_count="1118363" // A node cannot be considered "good" unless it has a block height greater or equal to this value. + // http://compoasso.free.fr/primelistweb/page/prime/liste_online_en.php 5 × 17 × 13159 + // This value is only used if both explorer_url and second_explorer_url are left blank + // or when the explorer(s) cannot be contacted + +// Static Node - hosts committed to continually run node +//----------------------------------------------------------------------------------------------------------------------------------------------/ +// At least one valid seed ip address is required to begin crawling the network +seed_1="139.162.128.92" // Frank - Frankfurt, - Germany +seed_2="94.137.177.227" // Anton - Tbilisi, - Georgia +seed_3="139.162.122.138" // Akio - Tokyo, - Japan +seed_4="173.255.252.140" // Sam - Fremont, CA - USA +seed_5="206.72.198.107" // Vinny - Seacaucus, NJ - USA +seed_6="45.56.75.20" // Speedy - Dallas, TX - USA +seed_7="139.162.35.170" // Ben - Singapore - Singapore +seed_8="139.162.155.117" // Baum - Frankfurt - Germany +seed_9="" +seed_10="" + +// CloudFlare +//---------------------------------------------------------------------------------------------------------------------------------------------/ +cf_domain="" +cf_domain_prefix="" +cf_username="email@domain.com" +cf_api_key="" +cf_seed_dump="dnsseed.dump" diff --git a/settings.conf b/settings.conf new file mode 100644 index 0000000..538ac32 --- /dev/null +++ b/settings.conf @@ -0,0 +1,49 @@ +// BlockChain parameters and Protocol version numbers +//---------------------------------------------------------------------------------------------------------------------------------------------/ +blockchain_name="Bitmark" // +protocol_version="70003" // --- Typically, these are found ( protocol version,init_proto_version, etc) in the coin's version.h file +init_proto_version="209" // +min_peer_proto_version="209" // Leave blank or set to the same value as protocol_version if not applicable in your blockchain +caddr_time_version="31402" // +pchMessageStart_0 = "0xf9" // --- Typically you can find the 4 pchMessageStart values in your coin's main.cpp or chainparams.cpp file +pchMessageStart_1 = "0xbe" // +pchMessageStart_2 = "0xb4" // +pchMessageStart_3 = "0xd9" // +wallet_port="9265" // P2P port: The coin servers's main port + +// BlockHeight - Get up-to-date value or default to predetermined height. +//---------------------------------------------------------------------------------------------------------------------------------------------/ + // Set to a block explorer url that returns the current block height. + // Leave blank to default to the block_count value below +explorer_url="https://chainz.cryptoid.info/marks/api.dws?q=getblockcount" // + // A 2nd block explorer url to be used as backup in case that the 1st block explorer is unreachable +second_explorer_url="" // example: "http://blockexplorer.deutsche-emark.org/api/getblockcount" +explorer_requery_seconds="120" // Used in conjunction with the explorer_url and second_explorer_url parameters. + // Interval in seconds for querying the current block height value from block explorer api url(s). + // Typically recommended set to the block interval target time. +block_count="1118363" // A node cannot be considered "good" unless it has a block height greater or equal to this value. + // http://compoasso.free.fr/primelistweb/page/prime/liste_online_en.php 5 × 17 × 13159 + // This value is only used if both explorer_url and second_explorer_url are left blank + // or when the explorer(s) cannot be contacted + +// Static Node - hosts committed to continually run node +//----------------------------------------------------------------------------------------------------------------------------------------------/ +// At least one valid seed ip address is required to begin crawling the network +seed_1="139.162.128.92" // Frank - Frankfurt, - Germany +seed_2="94.137.177.227" // Anton - Tbilisi, - Georgia +seed_3="139.162.122.138" // Akio - Tokyo, - Japan +seed_4="173.255.252.140" // Sam - Fremont, CA - USA +seed_5="206.72.198.107" // Vinny - Seacaucus, NJ - USA +seed_6="45.56.75.20" // Speedy - Dallas, TX - USA +seed_7="139.162.35.170" // Ben - Singapore - Singapore +seed_8="139.162.155.117" // Baum - Frankfurt - Germany +seed_9="" +seed_10="" + +// CloudFlare +//---------------------------------------------------------------------------------------------------------------------------------------------/ +cf_domain="" +cf_domain_prefix="" +cf_username="email@domain.com" +cf_api_key="" +cf_seed_dump="dnsseed.dump" From cb8d4dc42a0026b1d45932692409e59d547ac472 Mon Sep 17 00:00:00 2001 From: dbkeys Date: Mon, 15 Feb 2021 16:34:33 -0800 Subject: [PATCH 2/4] Include pre-configured instance of settings.conf file for Bitmark Introduce "blockchain_name" parameter to the settings.conf file --- README.md | 4 +++- main.cpp | 42 ++++++++++++++++++++++++++++++++++++------ 2 files changed, 39 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 1966db9..7353c0c 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@ The generic-seeder is a blockchain network crawler that maintains a list of IP addresses of the most reliable nodes on the network and shares those node IPs via DNS request to anyone requiring an entry point into the decentralized network. Choose between two main usage modes which consist of locally running a lightweight DNS server or feeding the data into a [Cloudflare](https://www.cloudflare.com/) account in order to respond to DNS seed requests. If you just want to crawl a network to get a list of the connectable nodes, without worrying about the DNS setup, you can do that too. The seeder app is compatible with almost any bitcoin-based blockchain network and can be configured in a short amount of time by filling out a small handful of parameters in the configuration file with the data from your coin's network. Tested to work with Ubuntu 18.04+ and Debian 8.x+ but it should work fine on any Linux installation, although package names and install steps may differ. +For use as a Bitmark Node Tracker / DNS Seeder, the configuration file settings.conf is provided, as well as a backup copy MARKS.settings.conf + ## Table of Contents - [Features](#features) @@ -280,4 +282,4 @@ Once configured correctly, it is recommended to set up a cron job that will auto Usage Example: `./dnsseed -?` --- -Need more help? Read the [DNS Seeder Setup Guide](/SETUP.md) \ No newline at end of file +Need more help? Read the [DNS Seeder Setup Guide](/SETUP.md) diff --git a/main.cpp b/main.cpp index f86066d..2b9e4bc 100644 --- a/main.cpp +++ b/main.cpp @@ -27,6 +27,7 @@ string sCurrentBlock; int nCurrentBlock = -1; int nDefaultBlockHeight = -1; +string cfg_blockchain_name; int cfg_protocol_version; int cfg_init_proto_version; int cfg_min_peer_proto_version; @@ -39,6 +40,7 @@ int cfg_explorer_requery_seconds; class CDnsSeedOpts { public: +// string blockchain_name ?? int nThreads; int nPort; int nDnsThreads; @@ -62,8 +64,8 @@ class CDnsSeedOpts { "Usage: %s -h -n [-m ] [-t ] [-p ]\n" "\n" "Options:\n" - "-h Hostname of the DNS seed\n" - "-n Hostname of the nameserver\n" + "-h Name of the sub-domain to name-serve\n" + "-n IP address of this nameserver\n" "-m E-Mail address reported in SOA records\n" "-t Number of crawlers to run in parallel (default 96)\n" "-d Number of DNS server threads (default 4)\n" @@ -611,6 +613,7 @@ int main(int argc, char **argv) { string sConfigName = "settings.conf"; printf("%s\n", (sAppName + " v" + sAppVersion).c_str()); + // Read "settings.conf" file for configuration parameters. try { cfg.readFile(sConfigName.c_str()); } catch(const FileIOException &fioex) { @@ -621,7 +624,17 @@ int main(int argc, char **argv) { << " - " << pex.getError() << std::endl; return(EXIT_FAILURE); } - + + // This version introduces "BlockChain Name" parameter + try { + cfg_blockchain_name = cfg.lookup("blockchain_name").c_str(); + cout << cfg_blockchain_name << " - DNS Seed Server\n"; + } catch(const SettingNotFoundException &nfex) { + // return(EXIT_FAILURE); // Too drastic: can ignore this failure + cout << "Missing 'blockchain_name' setting in configuration file." << endl; + cout << "Please set blockchain_name=\"\" parameter in 'settings.conf' file\n"; + } + try { cfg_protocol_version = std::stoi(cfg.lookup("protocol_version").c_str()); } catch(const SettingNotFoundException &nfex) { @@ -662,7 +675,7 @@ int main(int argc, char **argv) { try { cfg_wallet_port = std::stoi(cfg.lookup("wallet_port").c_str()); } catch(const SettingNotFoundException &nfex) { - cerr << "Error: Missing 'wallet_port' setting in configuration file." << endl; + cerr << "Error: Missing 'wallet_port' setting in configuration file. (ie., this blockchain's standard P2P port)" << endl; return(EXIT_FAILURE); } @@ -682,6 +695,12 @@ int main(int argc, char **argv) { cfg_explorer_url2 = ""; } + if (!cfg_explorer_url.empty()) { + cout << "Explorer: " << cfg_explorer_url << "\n"; + } else { + cout << "Explorer URL not set.\n"; + } + try { if (is_numeric(const_cast(cfg.lookup("explorer_requery_seconds").c_str()))) { cfg_explorer_requery_seconds = std::stoi(cfg.lookup("explorer_requery_seconds").c_str()); @@ -710,6 +729,11 @@ int main(int argc, char **argv) { return(EXIT_FAILURE); } + if (cfg_explorer_url.empty()) { + cout << "Will accept nodes reporting blockheight at or above: " << nDefaultBlockHeight << endl; + } else { + cout << "Will seek current blockheight info from: " << cfg_explorer_url << endl; + } for (int i=1; i<=10; i++) { try { sSeeds[i-1] = cfg.lookup("seed_" + std::to_string(i)).c_str(); @@ -722,7 +746,8 @@ int main(int argc, char **argv) { signal(SIGPIPE, SIG_IGN); setbuf(stdout, NULL); CDnsSeedOpts opts; - opts.ParseCommandLine(argc, argv); + opts.ParseCommandLine(argc, argv); // Check for command line arguments + printf("Supporting whitelisted filters: "); for (std::set::const_iterator it = opts.filter_whitelist.begin(); it != opts.filter_whitelist.end(); it++) { if (it != opts.filter_whitelist.begin()) { @@ -813,9 +838,14 @@ int main(int argc, char **argv) { } pthread_attr_destroy(&attr_crawler); printf("done\n"); + + cout << "\n" << cfg_blockchain_name << " - DNS Seed Server\n"; + cout << "\t for sub-domain: " << opts.host << endl; + cout << "dig -p " << opts.nPort << " @" << opts.ns << "\n" << endl; + pthread_create(&threadStats, NULL, ThreadStats, NULL); pthread_create(&threadDump, NULL, ThreadDumper, NULL); void* res; pthread_join(threadDump, &res); return 0; -} \ No newline at end of file +} From 94fc3bb2c4a46864e9b8974138176bf251126175 Mon Sep 17 00:00:00 2001 From: dbkeys Date: Mon, 15 Feb 2021 16:50:44 -0800 Subject: [PATCH 3/4] Create 'Settings/" folder for pre-configured .settings.conf files --- README.md | 3 ++- MARKS.settings.conf => Settings/MARKS.settings.conf | 0 2 files changed, 2 insertions(+), 1 deletion(-) rename MARKS.settings.conf => Settings/MARKS.settings.conf (100%) diff --git a/README.md b/README.md index 7353c0c..b1ba19a 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,8 @@ The generic-seeder is a blockchain network crawler that maintains a list of IP addresses of the most reliable nodes on the network and shares those node IPs via DNS request to anyone requiring an entry point into the decentralized network. Choose between two main usage modes which consist of locally running a lightweight DNS server or feeding the data into a [Cloudflare](https://www.cloudflare.com/) account in order to respond to DNS seed requests. If you just want to crawl a network to get a list of the connectable nodes, without worrying about the DNS setup, you can do that too. The seeder app is compatible with almost any bitcoin-based blockchain network and can be configured in a short amount of time by filling out a small handful of parameters in the configuration file with the data from your coin's network. Tested to work with Ubuntu 18.04+ and Debian 8.x+ but it should work fine on any Linux installation, although package names and install steps may differ. -For use as a Bitmark Node Tracker / DNS Seeder, the configuration file settings.conf is provided, as well as a backup copy MARKS.settings.conf +This version introduces the Settings/ folder to collect pre-configured settings.conf files for different blockchains. +For use as a Bitmark Node Tracker / DNS Seeder, the configuration file settings.conf is provided, as well as a backup copy Settings/MARKS.settings.conf ## Table of Contents diff --git a/MARKS.settings.conf b/Settings/MARKS.settings.conf similarity index 100% rename from MARKS.settings.conf rename to Settings/MARKS.settings.conf From 39a81582903614db348db87afb17c1008f38c9b1 Mon Sep 17 00:00:00 2001 From: dbkeys Date: Tue, 16 Feb 2021 01:28:25 +0000 Subject: [PATCH 4/4] Display formatting --- main.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main.cpp b/main.cpp index 2b9e4bc..c3ce6c4 100644 --- a/main.cpp +++ b/main.cpp @@ -611,7 +611,7 @@ extern "C" void* ThreadSeeder(void*) { int main(int argc, char **argv) { Config cfg; string sConfigName = "settings.conf"; - printf("%s\n", (sAppName + " v" + sAppVersion).c_str()); + //printf("%s\n", (sAppName + " v" + sAppVersion).c_str()); // Read "settings.conf" file for configuration parameters. try { @@ -628,7 +628,7 @@ int main(int argc, char **argv) { // This version introduces "BlockChain Name" parameter try { cfg_blockchain_name = cfg.lookup("blockchain_name").c_str(); - cout << cfg_blockchain_name << " - DNS Seed Server\n"; + cout << cfg_blockchain_name << " - DNS Seed Server - " << sAppName << " v" << sAppVersion << "\n"; } catch(const SettingNotFoundException &nfex) { // return(EXIT_FAILURE); // Too drastic: can ignore this failure cout << "Missing 'blockchain_name' setting in configuration file." << endl; @@ -839,9 +839,9 @@ int main(int argc, char **argv) { pthread_attr_destroy(&attr_crawler); printf("done\n"); - cout << "\n" << cfg_blockchain_name << " - DNS Seed Server\n"; + cout << "\n " << cfg_blockchain_name << " - DNS Seed Server\n"; cout << "\t for sub-domain: " << opts.host << endl; - cout << "dig -p " << opts.nPort << " @" << opts.ns << "\n" << endl; + cout << "\t ( Query with: \'dig -p " << opts.nPort << " @" << opts.ns << " " << opts.host <<"\' )\n" << endl; pthread_create(&threadStats, NULL, ThreadStats, NULL); pthread_create(&threadDump, NULL, ThreadDumper, NULL);