Parameter interaction based on rules
| 746 | |
| 747 | // Parameter interaction based on rules |
| 748 | void InitParameterInteraction() |
| 749 | { |
| 750 | // when specifying an explicit binding address, you want to listen on it |
| 751 | // even when -connect or -proxy is specified |
| 752 | if (gArgs.IsArgSet("-bind")) { |
| 753 | if (gArgs.SoftSetBoolArg("-listen", true)) |
| 754 | LogPrintf("%s: parameter interaction: -bind set -> setting -listen=1\n", __func__); |
| 755 | } |
| 756 | if (gArgs.IsArgSet("-whitebind")) { |
| 757 | if (gArgs.SoftSetBoolArg("-listen", true)) |
| 758 | LogPrintf("%s: parameter interaction: -whitebind set -> setting -listen=1\n", __func__); |
| 759 | } |
| 760 | |
| 761 | if (gArgs.IsArgSet("-connect")) { |
| 762 | // when only connecting to trusted nodes, do not seed via DNS, or listen by default |
| 763 | if (gArgs.SoftSetBoolArg("-dnsseed", false)) |
| 764 | LogPrintf("%s: parameter interaction: -connect set -> setting -dnsseed=0\n", __func__); |
| 765 | if (gArgs.SoftSetBoolArg("-listen", false)) |
| 766 | LogPrintf("%s: parameter interaction: -connect set -> setting -listen=0\n", __func__); |
| 767 | } |
| 768 | |
| 769 | if (gArgs.IsArgSet("-proxy")) { |
| 770 | // to protect privacy, do not listen by default if a default proxy server is specified |
| 771 | if (gArgs.SoftSetBoolArg("-listen", false)) |
| 772 | LogPrintf("%s: parameter interaction: -proxy set -> setting -listen=0\n", __func__); |
| 773 | // to protect privacy, do not use UPNP when a proxy is set. The user may still specify -listen=1 |
| 774 | // to listen locally, so don't rely on this happening through -listen below. |
| 775 | if (gArgs.SoftSetBoolArg("-upnp", false)) |
| 776 | LogPrintf("%s: parameter interaction: -proxy set -> setting -upnp=0\n", __func__); |
| 777 | // to protect privacy, do not discover addresses by default |
| 778 | if (gArgs.SoftSetBoolArg("-discover", false)) |
| 779 | LogPrintf("%s: parameter interaction: -proxy set -> setting -discover=0\n", __func__); |
| 780 | } |
| 781 | |
| 782 | if (!gArgs.GetBoolArg("-listen", DEFAULT_LISTEN)) { |
| 783 | // do not map ports or try to retrieve public IP when not listening (pointless) |
| 784 | if (gArgs.SoftSetBoolArg("-upnp", false)) |
| 785 | LogPrintf("%s: parameter interaction: -listen=0 -> setting -upnp=0\n", __func__); |
| 786 | if (gArgs.SoftSetBoolArg("-discover", false)) |
| 787 | LogPrintf("%s: parameter interaction: -listen=0 -> setting -discover=0\n", __func__); |
| 788 | if (gArgs.SoftSetBoolArg("-listenonion", false)) |
| 789 | LogPrintf("%s: parameter interaction: -listen=0 -> setting -listenonion=0\n", __func__); |
| 790 | } |
| 791 | |
| 792 | if (gArgs.IsArgSet("-externalip")) { |
| 793 | // if an explicit public IP is specified, do not try to find others |
| 794 | if (gArgs.SoftSetBoolArg("-discover", false)) |
| 795 | LogPrintf("%s: parameter interaction: -externalip set -> setting -discover=0\n", __func__); |
| 796 | } |
| 797 | |
| 798 | // disable whitelistrelay in blocksonly mode |
| 799 | if (gArgs.GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY)) { |
| 800 | if (gArgs.SoftSetBoolArg("-whitelistrelay", false)) |
| 801 | LogPrintf("%s: parameter interaction: -blocksonly=1 -> setting -whitelistrelay=0\n", __func__); |
| 802 | } |
| 803 | |
| 804 | // Forcing relay from whitelisted hosts implies we will accept relays from them in the first place. |
| 805 | if (gArgs.GetBoolArg("-whitelistforcerelay", DEFAULT_WHITELISTFORCERELAY)) { |
no test coverage detected