From c9d06c3fb2bef87d862a47c98d997653b9468118 Mon Sep 17 00:00:00 2001 From: Arthur Britto Date: Tue, 19 Jun 2012 12:45:01 -0700 Subject: [PATCH] Config support for [ips]. --- newcoin.txt | 12 ++++++++---- newcoind.cfg | 25 ++++++++++++++++++++----- src/Config.cpp | 11 ++++++++++- src/Config.h | 1 + 4 files changed, 39 insertions(+), 10 deletions(-) diff --git a/newcoin.txt b/newcoin.txt index e4cd6e2c1..420d930a5 100644 --- a/newcoin.txt +++ b/newcoin.txt @@ -31,7 +31,7 @@ # Example: google.com # # [ips]: -# Only valid in "newcoin.txt" and the referered [ips_url]. +# Only valid in "newcoind.cfg", "newcoin.txt", and the referered [ips_url]. # List of ips where the Newcoin protocol is avialable. # One ipv4 or ipv6 address per line. # A port may optionally be specified after adding a space to the address. @@ -43,12 +43,16 @@ # 2001:0db8:0100:f101:0210:a4ff:fee3:9566 # # [validators]: -# Only valid in "newcoin.txt" and the referered [validators_url]. +# Only valid in "newcoind.cfg", "newcoin.txt", and the referered [validators_url]. # List of Newcoin validators this node recommends. # +# For domains, newcoind will probe for https web servers at the specied +# domain in the following order: newcoin.DOMAIN, www.DOMAIN, DOMAIN +# # Examples: -# amazon.com -# newegg.com +# redstem.com +# n9KorY8QtTdRx7TVDpwnG9NvyxsDwHUKUEeDLY3AkiGncVaSXZi5 +# n9MqiExBcoG19UXwoLjBJnhsxEhAZMuWwJDRdkyDz1EkEkwzQTNt John Doe # # [ips_url]: # Only valid in "newcoin.txt". diff --git a/newcoind.cfg b/newcoind.cfg index bc846fa14..a7a6b42f6 100644 --- a/newcoind.cfg +++ b/newcoind.cfg @@ -57,18 +57,33 @@ # # Specify the file by specifying its full path. # -# Examples: C:/home/johndoe/newcoin/validators.txt -# /home/johndoe/newcoin/validators.txt +# Examples: +# C:/home/johndoe/newcoin/validators.txt +# /home/johndoe/newcoin/validators.txt # # [validators]: +# Only valid in "newcoind.cfg", "newcoin.txt", and the referered [validators_url]. # List of nodes to accept as validators speficied by public key or domain. # # For domains, newcoind will probe for https web servers at the specied # domain in the following order: newcoin.DOMAIN, www.DOMAIN, DOMAIN # -# Examples: redstem.com -# n9KorY8QtTdRx7TVDpwnG9NvyxsDwHUKUEeDLY3AkiGncVaSXZi5 -# n9MqiExBcoG19UXwoLjBJnhsxEhAZMuWwJDRdkyDz1EkEkwzQTNt John Doe +# Examples: +# redstem.com +# n9KorY8QtTdRx7TVDpwnG9NvyxsDwHUKUEeDLY3AkiGncVaSXZi5 +# n9MqiExBcoG19UXwoLjBJnhsxEhAZMuWwJDRdkyDz1EkEkwzQTNt John Doe +# +# [ips]: +# Only valid in "newcoind.cfg", "newcoin.txt", and the referered [ips_url]. +# List of ips where the Newcoin protocol is avialable. +# One ipv4 or ipv6 address per line. +# A port may optionally be specified after adding a space to the address. +# By convention, if known, IPs are listed in from most to least trusted. +# +# Examples: +# 192.168.0.1 +# 192.168.0.1 3939 +# 2001:0db8:0100:f101:0210:a4ff:fee3:9566 # # [peer_ip]: # IP address or domain to bind to allow external connections from peers. diff --git a/src/Config.cpp b/src/Config.cpp index e61552053..c49b5a13d 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -11,6 +11,7 @@ #define SECTION_FEE_ACCOUNT_CREATE "fee_account_create" #define SECTION_FEE_DEFAULT "fee_default" #define SECTION_FEE_NICKNAME_CREATE "fee_nickname_create" +#define SECTION_IPS "ips" #define SECTION_NETWORK_QUORUM "network_quorum" #define SECTION_PEER_CONNECT_LOW_WATER "peer_connect_low_water" #define SECTION_PEER_IP "peer_ip" @@ -172,13 +173,21 @@ void Config::load() section secConfig = ParseSection(strConfigFile, true); std::string strTemp; + // XXX Leak section::mapped_type* smtTmp; smtTmp = sectionEntries(secConfig, SECTION_VALIDATORS); if (smtTmp) { VALIDATORS = *smtTmp; - sectionEntriesPrint(&VALIDATORS, SECTION_VALIDATORS); + // sectionEntriesPrint(&VALIDATORS, SECTION_VALIDATORS); + } + + smtTmp = sectionEntries(secConfig, SECTION_IPS); + if (smtTmp) + { + IPS = *smtTmp; + sectionEntriesPrint(&IPS, SECTION_IPS); } (void) sectionSingleB(secConfig, SECTION_VALIDATORS_SITE, VALIDATORS_SITE); diff --git a/src/Config.h b/src/Config.h index 4e433d0c6..3a0948ddf 100644 --- a/src/Config.h +++ b/src/Config.h @@ -54,6 +54,7 @@ public: std::string VALIDATORS_SITE; // Where to find validators.txt on the Internet. std::vector VALIDATORS; // Validators from newcoind.cfg. + std::vector IPS; // Peer IPs from newcoind.cfg. // Network parameters int NETWORK_START_TIME; // The Unix time we start ledger 0.