Parameter interaction based on rules
| 788 | |
| 789 | // Parameter interaction based on rules |
| 790 | void InitParameterInteraction(ArgsManager& args) |
| 791 | { |
| 792 | // when specifying an explicit binding address, you want to listen on it |
| 793 | // even when -connect or -proxy is specified |
| 794 | if (!args.GetArgs("-bind").empty()) { |
| 795 | if (args.SoftSetBoolArg("-listen", true)) |
| 796 | LogInfo("parameter interaction: -bind set -> setting -listen=1\n"); |
| 797 | } |
| 798 | if (!args.GetArgs("-whitebind").empty()) { |
| 799 | if (args.SoftSetBoolArg("-listen", true)) |
| 800 | LogInfo("parameter interaction: -whitebind set -> setting -listen=1\n"); |
| 801 | } |
| 802 | |
| 803 | if (!args.GetArgs("-connect").empty() || args.IsArgNegated("-connect") || args.GetIntArg("-maxconnections", DEFAULT_MAX_PEER_CONNECTIONS) <= 0) { |
| 804 | // when only connecting to trusted nodes, do not seed via DNS, or listen by default |
| 805 | // do the same when connections are disabled |
| 806 | if (args.SoftSetBoolArg("-dnsseed", false)) |
| 807 | LogInfo("parameter interaction: -connect or -maxconnections=0 set -> setting -dnsseed=0\n"); |
| 808 | if (args.SoftSetBoolArg("-listen", false)) |
| 809 | LogInfo("parameter interaction: -connect or -maxconnections=0 set -> setting -listen=0\n"); |
| 810 | } |
| 811 | |
| 812 | std::string proxy_arg = args.GetArg("-proxy", ""); |
| 813 | if (proxy_arg != "" && proxy_arg != "0") { |
| 814 | // to protect privacy, do not listen by default if a default proxy server is specified |
| 815 | if (args.SoftSetBoolArg("-listen", false)) |
| 816 | LogInfo("parameter interaction: -proxy set -> setting -listen=0\n"); |
| 817 | // to protect privacy, do not map ports when a proxy is set. The user may still specify -listen=1 |
| 818 | // to listen locally, so don't rely on this happening through -listen below. |
| 819 | if (args.SoftSetBoolArg("-natpmp", false)) { |
| 820 | LogInfo("parameter interaction: -proxy set -> setting -natpmp=0\n"); |
| 821 | } |
| 822 | // to protect privacy, do not discover addresses by default |
| 823 | if (args.SoftSetBoolArg("-discover", false)) |
| 824 | LogInfo("parameter interaction: -proxy set -> setting -discover=0\n"); |
| 825 | } |
| 826 | |
| 827 | if (!args.GetBoolArg("-listen", DEFAULT_LISTEN)) { |
| 828 | // do not map ports or try to retrieve public IP when not listening (pointless) |
| 829 | if (args.SoftSetBoolArg("-natpmp", false)) { |
| 830 | LogInfo("parameter interaction: -listen=0 -> setting -natpmp=0\n"); |
| 831 | } |
| 832 | if (args.SoftSetBoolArg("-discover", false)) |
| 833 | LogInfo("parameter interaction: -listen=0 -> setting -discover=0\n"); |
| 834 | if (args.SoftSetBoolArg("-listenonion", false)) |
| 835 | LogInfo("parameter interaction: -listen=0 -> setting -listenonion=0\n"); |
| 836 | if (args.SoftSetBoolArg("-i2pacceptincoming", false)) { |
| 837 | LogInfo("parameter interaction: -listen=0 -> setting -i2pacceptincoming=0\n"); |
| 838 | } |
| 839 | } |
| 840 | |
| 841 | if (!args.GetArgs("-externalip").empty()) { |
| 842 | // if an explicit public IP is specified, do not try to find others |
| 843 | if (args.SoftSetBoolArg("-discover", false)) |
| 844 | LogInfo("parameter interaction: -externalip set -> setting -discover=0\n"); |
| 845 | } |
| 846 | |
| 847 | if (args.GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY)) { |
no test coverage detected