Parameter interaction based on rules
| 697 | |
| 698 | // Parameter interaction based on rules |
| 699 | void InitParameterInteraction(ArgsManager& args) |
| 700 | { |
| 701 | // when specifying an explicit binding address, you want to listen on it |
| 702 | // even when -connect or -proxy is specified |
| 703 | if (args.IsArgSet("-bind")) { |
| 704 | if (args.SoftSetBoolArg("-listen", true)) |
| 705 | LogPrintf("%s: parameter interaction: -bind set -> setting -listen=1\n", __func__); |
| 706 | } |
| 707 | if (args.IsArgSet("-whitebind")) { |
| 708 | if (args.SoftSetBoolArg("-listen", true)) |
| 709 | LogPrintf("%s: parameter interaction: -whitebind set -> setting -listen=1\n", __func__); |
| 710 | } |
| 711 | |
| 712 | if (args.IsArgSet("-connect")) { |
| 713 | // when only connecting to trusted nodes, do not seed via DNS, or listen by default |
| 714 | if (args.SoftSetBoolArg("-dnsseed", false)) |
| 715 | LogPrintf("%s: parameter interaction: -connect set -> setting -dnsseed=0\n", __func__); |
| 716 | if (args.SoftSetBoolArg("-listen", false)) |
| 717 | LogPrintf("%s: parameter interaction: -connect set -> setting -listen=0\n", __func__); |
| 718 | } |
| 719 | |
| 720 | if (args.IsArgSet("-proxy")) { |
| 721 | // to protect privacy, do not listen by default if a default proxy server is specified |
| 722 | if (args.SoftSetBoolArg("-listen", false)) |
| 723 | LogPrintf("%s: parameter interaction: -proxy set -> setting -listen=0\n", __func__); |
| 724 | // to protect privacy, do not map ports when a proxy is set. The user may still specify -listen=1 |
| 725 | // to listen locally, so don't rely on this happening through -listen below. |
| 726 | if (args.SoftSetBoolArg("-upnp", false)) |
| 727 | LogPrintf("%s: parameter interaction: -proxy set -> setting -upnp=0\n", __func__); |
| 728 | if (args.SoftSetBoolArg("-natpmp", false)) { |
| 729 | LogPrintf("%s: parameter interaction: -proxy set -> setting -natpmp=0\n", __func__); |
| 730 | } |
| 731 | // to protect privacy, do not discover addresses by default |
| 732 | if (args.SoftSetBoolArg("-discover", false)) |
| 733 | LogPrintf("%s: parameter interaction: -proxy set -> setting -discover=0\n", __func__); |
| 734 | } |
| 735 | |
| 736 | if (!args.GetBoolArg("-listen", DEFAULT_LISTEN)) { |
| 737 | // do not map ports or try to retrieve public IP when not listening (pointless) |
| 738 | if (args.SoftSetBoolArg("-upnp", false)) |
| 739 | LogPrintf("%s: parameter interaction: -listen=0 -> setting -upnp=0\n", __func__); |
| 740 | if (args.SoftSetBoolArg("-natpmp", false)) { |
| 741 | LogPrintf("%s: parameter interaction: -listen=0 -> setting -natpmp=0\n", __func__); |
| 742 | } |
| 743 | if (args.SoftSetBoolArg("-discover", false)) |
| 744 | LogPrintf("%s: parameter interaction: -listen=0 -> setting -discover=0\n", __func__); |
| 745 | if (args.SoftSetBoolArg("-listenonion", false)) |
| 746 | LogPrintf("%s: parameter interaction: -listen=0 -> setting -listenonion=0\n", __func__); |
| 747 | if (args.SoftSetBoolArg("-i2pacceptincoming", false)) { |
| 748 | LogPrintf("%s: parameter interaction: -listen=0 -> setting -i2pacceptincoming=0\n", __func__); |
| 749 | } |
| 750 | } |
| 751 | |
| 752 | if (args.IsArgSet("-externalip")) { |
| 753 | // if an explicit public IP is specified, do not try to find others |
| 754 | if (args.SoftSetBoolArg("-discover", false)) |
| 755 | LogPrintf("%s: parameter interaction: -externalip set -> setting -discover=0\n", __func__); |
| 756 | } |
no test coverage detected