Add a config option to toggle auto IP discovery

This commit is contained in:
Andrius Dagys
2017-06-23 11:42:55 +01:00
parent bf9e2c6f54
commit 7804c68401
3 changed files with 11 additions and 3 deletions

View File

@ -134,5 +134,9 @@ path to the node's base directory.
does not exist, a developer keystore will be used if ``devMode`` is true. The node will exit if ``devMode`` is false does not exist, a developer keystore will be used if ``devMode`` is true. The node will exit if ``devMode`` is false
and keystore does not exist. and keystore does not exist.
:detectPublicIp: This flag toggles the auto IP detection behaviour, it is enabled by default. On startup the node will
attempt to discover its externally visible IP address first by looking for any public addresses on its network
interfaces, and then by sending an IP discovery request to the network map service. Set to ``false`` to disable.
:certificateSigningService: Certificate Signing Server address. It is used by the certificate signing request utility to :certificateSigningService: Certificate Signing Server address. It is used by the certificate signing request utility to
obtain SSL certificate. (See :doc:`permissioning` for more information.) obtain SSL certificate. (See :doc:`permissioning` for more information.)

View File

@ -169,8 +169,11 @@ open class Node(override val configuration: FullNodeConfiguration,
private fun getAdvertisedAddress(): HostAndPort { private fun getAdvertisedAddress(): HostAndPort {
return with(configuration) { return with(configuration) {
val publicHost = tryDetectIfNotPublicHost(p2pAddress.host) val useHost = if (detectPublicIp) {
val useHost = publicHost ?: p2pAddress.host tryDetectIfNotPublicHost(p2pAddress.host) ?: p2pAddress.host
} else {
p2pAddress.host
}
HostAndPort.fromParts(useHost, p2pAddress.port) HostAndPort.fromParts(useHost, p2pAddress.port)
} }
} }

View File

@ -58,7 +58,8 @@ data class FullNodeConfiguration(
val notaryClusterAddresses: List<HostAndPort>, val notaryClusterAddresses: List<HostAndPort>,
override val certificateChainCheckPolicies: List<CertChainPolicyConfig>, override val certificateChainCheckPolicies: List<CertChainPolicyConfig>,
override val devMode: Boolean = false, override val devMode: Boolean = false,
val useTestClock: Boolean = false val useTestClock: Boolean = false,
val detectPublicIp: Boolean = true
) : NodeConfiguration { ) : NodeConfiguration {
/** This is not retrieved from the config file but rather from a command line argument. */ /** This is not retrieved from the config file but rather from a command line argument. */
@Suppress("DEPRECATION") @Suppress("DEPRECATION")