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

Make P2P and Tor configurations oneliners #1945

Merged
merged 40 commits into from Jul 22, 2019
Merged
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
52659cb
Create new config params
nopara73 Jul 18, 2019
b4271cf
Read obsolate config values and set new ones according,
molnard Jul 18, 2019
cf61a13
Starting to remove host, port config entries and use the new EndPoints
molnard Jul 18, 2019
1fda515
Overwrite old config with the new one
molnard Jul 18, 2019
646a071
Read obsolete config values and set new ones according (#21)
nopara73 Jul 18, 2019
5440fb3
Revert "Read obsolete config values and set new ones according"
nopara73 Jul 18, 2019
dad774f
Revert "Read obsolete config values and set new ones according" (#22)
nopara73 Jul 18, 2019
c6147a5
Implement backwards compatibility on config files.
nopara73 Jul 18, 2019
b7c5afc
Introduce EndPointParser
nopara73 Jul 18, 2019
3898d84
Implement corresponding settings
nopara73 Jul 18, 2019
d3b2f3e
Rename _bitcoinCoreEndPoint to _bitcoinP2pEndPoint
nopara73 Jul 18, 2019
90a80f4
fix typo
nopara73 Jul 18, 2019
9558f1c
Remove unnecessary backing field.
nopara73 Jul 19, 2019
52e0022
Simplify backwardscomp check
nopara73 Jul 19, 2019
4fae835
save progress
nopara73 Jul 19, 2019
f5b48dc
Add unit tests for parser
nopara73 Jul 19, 2019
83a1295
Add ParserTests to CI.
nopara73 Jul 19, 2019
a14b689
Add more unit tests
nopara73 Jul 19, 2019
b5b4c2b
Assert default port constants so NBitcoin updates don't surprise us.
nopara73 Jul 19, 2019
e43d21f
Assert min and maxrange of port
nopara73 Jul 19, 2019
c39b827
fix var name
nopara73 Jul 21, 2019
3235adc
Test with real ports instead of 0.
nopara73 Jul 21, 2019
c443cc0
Bring network nullcheck up.
nopara73 Jul 21, 2019
714efc0
Add more tests
nopara73 Jul 21, 2019
bd6012b
Improve port parsing
nopara73 Jul 21, 2019
2afa2ee
Make Tor lib work with EndPoints instead of IPEndPoints
nopara73 Jul 21, 2019
07deed4
Merge branch 'master' into config
nopara73 Jul 21, 2019
000a514
Fix codemaid brainfuck
nopara73 Jul 21, 2019
af81cd9
fix regtests
nopara73 Jul 21, 2019
811ab4d
Add RPC params to the config file.
nopara73 Jul 21, 2019
13f5416
Cleanup ports from CoreNode
nopara73 Jul 21, 2019
fbede18
Make Network a Network, not a string.
nopara73 Jul 21, 2019
c7e9726
Use Network types in the selection array, too.
nopara73 Jul 21, 2019
3beeef5
Merge branch 'master' into config
nopara73 Jul 22, 2019
334f745
Save on lost textbox focus instead on character change.
nopara73 Jul 22, 2019
ac9d9d9
Warning message always visible at SettingsTab
molnard Jul 22, 2019
80bca4b
Enable `bitcoin-p2p` and `tcp`
nopara73 Jul 22, 2019
d68bb91
Warning message always visible at SettingsTab (#23)
nopara73 Jul 22, 2019
bd51135
add wait on error let UI run
molnard Jul 22, 2019
54a991d
Add wait on update error and let UI run (#24)
nopara73 Jul 22, 2019
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Simplify backwardscomp check

  • Loading branch information...
nopara73 committed Jul 19, 2019
commit 52e0022d486dc578ebfa060113145ebd9f7e5243
@@ -163,55 +163,59 @@ public void AssertFilePathSet()

private bool TryEnsureBackwardsCompatibility(string jsonString)
{
var jsObject = JsonConvert.DeserializeObject<JObject>(jsonString);
bool saveIt = false;

if (jsObject.TryGetValue("MainNetBitcoinCoreHost", out JToken jMainNetBitcoinCoreHost))
try
{
int port = Constants.DefaultMainNetBitcoinP2pPort;
if (jsObject.TryGetValue("MainNetBitcoinCorePort", out JToken jMainNetBitcoinCorePort) && int.TryParse(jMainNetBitcoinCorePort.ToString(), out int p))
{
port = p;
}
var jsObject = JsonConvert.DeserializeObject<JObject>(jsonString);
bool saveIt = false;

if (EndPointParser.TryParse(jMainNetBitcoinCoreHost.ToString(), port, out EndPoint ep))
{
MainNetBitcoinP2pEndPoint = ep;
saveIt = true;
}
}
var mainNetBitcoinCoreHost = jsObject.Value<string>("MainNetBitcoinCoreHost");
var mainNetBitcoinCorePort = jsObject.Value<int?>("MainNetBitcoinCorePort");
var testNetBitcoinCoreHost = jsObject.Value<string>("TestNetBitcoinCoreHost");
var testNetBitcoinCorePort = jsObject.Value<int?>("TestNetBitcoinCorePort");
var regTestBitcoinCoreHost = jsObject.Value<string>("RegTestBitcoinCoreHost");
var regTestBitcoinCorePort = jsObject.Value<int?>("RegTestBitcoinCorePort");

if (jsObject.TryGetValue("TestNetBitcoinCoreHost", out JToken jTestNetBitcoinCoreHost))
{
int port = Constants.DefaultTestNetBitcoinP2pPort;
if (jsObject.TryGetValue("TestNetBitcoinCorePort", out JToken jTestNetBitcoinCorePort) && int.TryParse(jTestNetBitcoinCorePort.ToString(), out int p))
if (mainNetBitcoinCoreHost != null)
{
port = p;
}
int port = mainNetBitcoinCorePort ?? Constants.DefaultMainNetBitcoinP2pPort;

if (EndPointParser.TryParse(jTestNetBitcoinCoreHost.ToString(), port, out EndPoint ep))
{
TestNetBitcoinP2pEndPoint = ep;
saveIt = true;
if (EndPointParser.TryParse(mainNetBitcoinCoreHost, port, out EndPoint ep))
{
MainNetBitcoinP2pEndPoint = ep;
saveIt = true;
}
}
}

if (jsObject.TryGetValue("RegTestBitcoinCoreHost", out JToken jRegTestBitcoinCoreHost))
{
int port = Constants.DefaultRegTestBitcoinP2pPort;
if (jsObject.TryGetValue("RegTestBitcoinCorePort", out JToken jRegTestBitcoinCorePort) && int.TryParse(jRegTestBitcoinCorePort.ToString(), out int p))
if (testNetBitcoinCoreHost != null)
{
port = p;
int port = testNetBitcoinCorePort ?? Constants.DefaultTestNetBitcoinP2pPort;

if (EndPointParser.TryParse(testNetBitcoinCoreHost, port, out EndPoint ep))
{
TestNetBitcoinP2pEndPoint = ep;
saveIt = true;
}
}

if (EndPointParser.TryParse(jRegTestBitcoinCoreHost.ToString(), port, out EndPoint ep))
if (regTestBitcoinCoreHost != null)
{
RegTestBitcoinP2pEndPoint = ep;
saveIt = true;
int port = regTestBitcoinCorePort ?? Constants.DefaultRegTestBitcoinP2pPort;

if (EndPointParser.TryParse(regTestBitcoinCoreHost, port, out EndPoint ep))
{
RegTestBitcoinP2pEndPoint = ep;
saveIt = true;
}
}
}

return saveIt;
return saveIt;
}
catch (Exception ex)
{
Logger.LogWarning<Config>("Backwards compatibility couldn't be ensured.");
Logger.LogInfo<Config>(ex);
return false;
}
}
}
}
@@ -421,70 +421,72 @@ public int GetTargetLevel(TargetPrivacy target)

private bool TryEnsureBackwardsCompatibility(string jsonString)
{
var jsObject = JsonConvert.DeserializeObject<JObject>(jsonString);
bool saveIt = false;

if (jsObject.TryGetValue("TorHost", out JToken jTorHost))
try
{
int port = Constants.DefaultTorSocksPort;
if (jsObject.TryGetValue("TorSocks5Port", out JToken jTorSocks5Port) && int.TryParse(jTorSocks5Port.ToString(), out int p))
{
port = p;
}
var jsObject = JsonConvert.DeserializeObject<JObject>(jsonString);
bool saveIt = false;

if (EndPointParser.TryParse(jTorHost.ToString(), port, out EndPoint ep))
{
TorSocks5EndPoint = ep;
saveIt = true;
}
}
var torHost = jsObject.Value<string>("TorHost");
var torSocks5Port = jsObject.Value<int?>("TorSocks5Port");
var mainNetBitcoinCoreHost = jsObject.Value<string>("MainNetBitcoinCoreHost");
var mainNetBitcoinCorePort = jsObject.Value<int?>("MainNetBitcoinCorePort");
var testNetBitcoinCoreHost = jsObject.Value<string>("TestNetBitcoinCoreHost");
var testNetBitcoinCorePort = jsObject.Value<int?>("TestNetBitcoinCorePort");
var regTestBitcoinCoreHost = jsObject.Value<string>("RegTestBitcoinCoreHost");
var regTestBitcoinCorePort = jsObject.Value<int?>("RegTestBitcoinCorePort");

if (jsObject.TryGetValue("MainNetBitcoinCoreHost", out JToken jMainNetBitcoinCoreHost))
{
int port = Constants.DefaultMainNetBitcoinP2pPort;
if (jsObject.TryGetValue("MainNetBitcoinCorePort", out JToken jMainNetBitcoinCorePort) && int.TryParse(jMainNetBitcoinCorePort.ToString(), out int p))
if (torHost != null)
{
port = p;
}
int port = torSocks5Port ?? Constants.DefaultTorSocksPort;

if (EndPointParser.TryParse(jMainNetBitcoinCoreHost.ToString(), port, out EndPoint ep))
{
MainNetBitcoinP2pEndPoint = ep;
saveIt = true;
if (EndPointParser.TryParse(torHost, port, out EndPoint ep))
{
TorSocks5EndPoint = ep;
saveIt = true;
}
}
}

if (jsObject.TryGetValue("TestNetBitcoinCoreHost", out JToken jTestNetBitcoinCoreHost))
{
int port = Constants.DefaultTestNetBitcoinP2pPort;
if (jsObject.TryGetValue("TestNetBitcoinCorePort", out JToken jTestNetBitcoinCorePort) && int.TryParse(jTestNetBitcoinCorePort.ToString(), out int p))
if (mainNetBitcoinCoreHost != null)
{
port = p;
}
int port = mainNetBitcoinCorePort ?? Constants.DefaultMainNetBitcoinP2pPort;

if (EndPointParser.TryParse(jTestNetBitcoinCoreHost.ToString(), port, out EndPoint ep))
{
TestNetBitcoinP2pEndPoint = ep;
saveIt = true;
if (EndPointParser.TryParse(mainNetBitcoinCoreHost, port, out EndPoint ep))
{
MainNetBitcoinP2pEndPoint = ep;
saveIt = true;
}
}
}

if (jsObject.TryGetValue("RegTestBitcoinCoreHost", out JToken jRegTestBitcoinCoreHost))
{
int port = Constants.DefaultRegTestBitcoinP2pPort;
if (jsObject.TryGetValue("RegTestBitcoinCorePort", out JToken jRegTestBitcoinCorePort) && int.TryParse(jRegTestBitcoinCorePort.ToString(), out int p))
if (testNetBitcoinCoreHost != null)
{
port = p;
int port = testNetBitcoinCorePort ?? Constants.DefaultTestNetBitcoinP2pPort;

if (EndPointParser.TryParse(testNetBitcoinCoreHost, port, out EndPoint ep))
{
TestNetBitcoinP2pEndPoint = ep;
saveIt = true;
}
}

if (EndPointParser.TryParse(jRegTestBitcoinCoreHost.ToString(), port, out EndPoint ep))
if (regTestBitcoinCoreHost != null)
{
RegTestBitcoinP2pEndPoint = ep;
saveIt = true;
int port = regTestBitcoinCorePort ?? Constants.DefaultRegTestBitcoinP2pPort;

if (EndPointParser.TryParse(regTestBitcoinCoreHost, port, out EndPoint ep))
{
RegTestBitcoinP2pEndPoint = ep;
saveIt = true;
}
}
}

return saveIt;
return saveIt;
}
catch (Exception ex)
{
Logger.LogWarning<Config>("Backwards compatibility couldn't be ensured.");
Logger.LogInfo<Config>(ex);
return false;
}
}
}
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.