Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blockchain_name parameter, sub-folder for <blockchain_name>.settings.conf files #4

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

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.

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

- [Features](#features)
Expand Down Expand Up @@ -280,4 +283,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)
Need more help? Read the [DNS Seeder Setup Guide](/SETUP.md)
49 changes: 49 additions & 0 deletions Settings/MARKS.settings.conf
Original file line number Diff line number Diff line change
@@ -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 protected]"
cf_api_key=""
cf_seed_dump="dnsseed.dump"
44 changes: 37 additions & 7 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -39,6 +40,7 @@ int cfg_explorer_requery_seconds;

class CDnsSeedOpts {
public:
// string blockchain_name ??
int nThreads;
int nPort;
int nDnsThreads;
Expand All @@ -62,8 +64,8 @@ class CDnsSeedOpts {
"Usage: %s -h <host> -n <ns> [-m <mbox>] [-t <threads>] [-p <port>]\n"
"\n"
"Options:\n"
"-h <host> Hostname of the DNS seed\n"
"-n <ns> Hostname of the nameserver\n"
"-h <host> Name of the sub-domain to name-serve\n"
"-n <ns> IP address of this nameserver\n"
"-m <mbox> E-Mail address reported in SOA records\n"
"-t <threads> Number of crawlers to run in parallel (default 96)\n"
"-d <threads> Number of DNS server threads (default 4)\n"
Expand Down Expand Up @@ -609,8 +611,9 @@ 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 {
cfg.readFile(sConfigName.c_str());
} catch(const FileIOException &fioex) {
Expand All @@ -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 - " << 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;
cout << "Please set blockchain_name=\"<name>\" parameter in 'settings.conf' file\n";
}

try {
cfg_protocol_version = std::stoi(cfg.lookup("protocol_version").c_str());
} catch(const SettingNotFoundException &nfex) {
Expand Down Expand Up @@ -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);
}

Expand All @@ -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<char*>(cfg.lookup("explorer_requery_seconds").c_str()))) {
cfg_explorer_requery_seconds = std::stoi(cfg.lookup("explorer_requery_seconds").c_str());
Expand Down Expand Up @@ -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();
Expand All @@ -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<uint64_t>::const_iterator it = opts.filter_whitelist.begin(); it != opts.filter_whitelist.end(); it++) {
if (it != opts.filter_whitelist.begin()) {
Expand Down Expand Up @@ -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 << "\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);
void* res;
pthread_join(threadDump, &res);
return 0;
}
}
49 changes: 49 additions & 0 deletions settings.conf
Original file line number Diff line number Diff line change
@@ -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 protected]"
cf_api_key=""
cf_seed_dump="dnsseed.dump"