diff --git a/bridge/bridgecapsule/src/smoke-test/resources/net/corda/bridge/smoketest/firewall.conf b/bridge/bridgecapsule/src/smoke-test/resources/net/corda/bridge/smoketest/firewall.conf index 2504263f15..444338cf27 100644 --- a/bridge/bridgecapsule/src/smoke-test/resources/net/corda/bridge/smoketest/firewall.conf +++ b/bridge/bridgecapsule/src/smoke-test/resources/net/corda/bridge/smoketest/firewall.conf @@ -1,7 +1,7 @@ firewallMode = SenderReceiver outboundConfig : { artemisBrokerAddress = "localhost:11005" - socksProxyConfig : { + proxyConfig : { version = SOCKS5 proxyAddress = "localhost:12345" userName = "proxyUser" diff --git a/bridge/src/main/kotlin/net/corda/bridge/services/api/FirewallConfiguration.kt b/bridge/src/main/kotlin/net/corda/bridge/services/api/FirewallConfiguration.kt index 3454ec5288..4c3b36d01a 100644 --- a/bridge/src/main/kotlin/net/corda/bridge/services/api/FirewallConfiguration.kt +++ b/bridge/src/main/kotlin/net/corda/bridge/services/api/FirewallConfiguration.kt @@ -3,7 +3,7 @@ package net.corda.bridge.services.api import net.corda.core.identity.CordaX500Name import net.corda.core.utilities.NetworkHostAndPort import net.corda.nodeapi.internal.config.MutualSslConfiguration -import net.corda.nodeapi.internal.protonwrapper.netty.SocksProxyConfig +import net.corda.nodeapi.internal.protonwrapper.netty.ProxyConfig import java.nio.file.Path enum class FirewallMode { @@ -40,7 +40,7 @@ interface BridgeOutboundConfiguration { // Allows override of [KeyStore] details for the artemis connection, otherwise the general top level details are used. val customSSLConfiguration: BridgeSSLConfiguration? // Allows use of a SOCKS 4/5 proxy - val socksProxyConfig: SocksProxyConfig? + val proxyConfig: ProxyConfig? } /** diff --git a/bridge/src/main/kotlin/net/corda/bridge/services/config/FirewallConfigurationImpl.kt b/bridge/src/main/kotlin/net/corda/bridge/services/config/FirewallConfigurationImpl.kt index 878fb1a04d..5aec4fe745 100644 --- a/bridge/src/main/kotlin/net/corda/bridge/services/config/FirewallConfigurationImpl.kt +++ b/bridge/src/main/kotlin/net/corda/bridge/services/config/FirewallConfigurationImpl.kt @@ -9,7 +9,7 @@ import net.corda.core.internal.div import net.corda.core.utilities.NetworkHostAndPort import net.corda.nodeapi.internal.ArtemisMessagingComponent import net.corda.nodeapi.internal.config.* -import net.corda.nodeapi.internal.protonwrapper.netty.SocksProxyConfig +import net.corda.nodeapi.internal.protonwrapper.netty.ProxyConfig import java.nio.file.Path fun Config.parseAsFirewallConfiguration(): FirewallConfiguration { @@ -17,6 +17,18 @@ fun Config.parseAsFirewallConfiguration(): FirewallConfiguration { parseAs() } catch (ex: UnknownConfigurationKeysException) { + // Previously `proxyConfig` was known as `socksProxyConfig` + data class Version3BridgeOutboundConfigurationImpl(val artemisBrokerAddress: NetworkHostAndPort, + val alternateArtemisBrokerAddresses: List, + val customSSLConfiguration: BridgeSSLConfigurationImpl?, + val socksProxyConfig: ProxyConfig? = null) { + + fun toConfig(): BridgeOutboundConfigurationImpl { + return BridgeOutboundConfigurationImpl(artemisBrokerAddress, alternateArtemisBrokerAddresses, + customSSLConfiguration, socksProxyConfig) + } + } + data class Version3BridgeConfigurationImpl( val baseDirectory: Path, val certificatesDirectory: Path = baseDirectory / "certificates", @@ -27,7 +39,7 @@ fun Config.parseAsFirewallConfiguration(): FirewallConfiguration { val trustStorePassword: String, val bridgeMode: FirewallMode, val networkParametersPath: Path, - val outboundConfig: BridgeOutboundConfigurationImpl?, + val outboundConfig: Version3BridgeOutboundConfigurationImpl?, val inboundConfig: BridgeInboundConfigurationImpl?, val bridgeInnerConfig: BridgeInnerConfigurationImpl?, val floatOuterConfig: FloatOuterConfigurationImpl?, @@ -51,7 +63,7 @@ fun Config.parseAsFirewallConfiguration(): FirewallConfiguration { trustStorePassword, bridgeMode, networkParametersPath, - outboundConfig, + outboundConfig?.toConfig(), inboundConfig, bridgeInnerConfig, floatOuterConfig, @@ -95,7 +107,7 @@ data class BridgeSSLConfigurationImpl(private val sslKeystore: Path, data class BridgeOutboundConfigurationImpl(override val artemisBrokerAddress: NetworkHostAndPort, override val alternateArtemisBrokerAddresses: List, override val customSSLConfiguration: BridgeSSLConfigurationImpl?, - override val socksProxyConfig: SocksProxyConfig? = null) : BridgeOutboundConfiguration + override val proxyConfig: ProxyConfig? = null) : BridgeOutboundConfiguration data class BridgeInboundConfigurationImpl(override val listeningAddress: NetworkHostAndPort, override val customSSLConfiguration: BridgeSSLConfigurationImpl?) : BridgeInboundConfiguration diff --git a/bridge/src/main/kotlin/net/corda/bridge/services/sender/DirectBridgeSenderService.kt b/bridge/src/main/kotlin/net/corda/bridge/services/sender/DirectBridgeSenderService.kt index 8c0c545565..985fff7544 100644 --- a/bridge/src/main/kotlin/net/corda/bridge/services/sender/DirectBridgeSenderService.kt +++ b/bridge/src/main/kotlin/net/corda/bridge/services/sender/DirectBridgeSenderService.kt @@ -29,7 +29,7 @@ class DirectBridgeSenderService(val conf: FirewallConfiguration, private var statusSubscriber: Subscription? = null private var listenerActiveSubscriber: Subscription? = null private var bridgeControlListener = BridgeControlListener(conf.p2pSslOptions, - conf.outboundConfig!!.socksProxyConfig, + conf.outboundConfig!!.proxyConfig, maxMessageSize, conf.bridgeInnerConfig?.enableSNI ?: true, { ForwardingArtemisMessageClient(artemisConnectionService) }, diff --git a/bridge/src/test/kotlin/net/corda/bridge/ConfigTest.kt b/bridge/src/test/kotlin/net/corda/bridge/ConfigTest.kt index 18af42d34e..fe9c54451f 100644 --- a/bridge/src/test/kotlin/net/corda/bridge/ConfigTest.kt +++ b/bridge/src/test/kotlin/net/corda/bridge/ConfigTest.kt @@ -5,7 +5,7 @@ import net.corda.bridge.services.api.FirewallMode import net.corda.core.identity.CordaX500Name import net.corda.core.internal.div import net.corda.core.utilities.NetworkHostAndPort -import net.corda.nodeapi.internal.protonwrapper.netty.SocksProxyVersion +import net.corda.nodeapi.internal.protonwrapper.netty.ProxyVersion import net.corda.testing.core.SerializationEnvironmentRule import org.junit.Assert.assertEquals import org.junit.Assert.assertNull @@ -118,10 +118,10 @@ class ConfigTest { fun `Load config withsocks support`() { val configResource = "/net/corda/bridge/withsocks/firewall.conf" val config = createAndLoadConfigFromResource(tempFolder.root.toPath(), configResource) - assertEquals(SocksProxyVersion.SOCKS5, config.outboundConfig!!.socksProxyConfig!!.version) - assertEquals(NetworkHostAndPort("localhost", 12345), config.outboundConfig!!.socksProxyConfig!!.proxyAddress) - assertEquals("proxyUser", config.outboundConfig!!.socksProxyConfig!!.userName) - assertEquals("pwd", config.outboundConfig!!.socksProxyConfig!!.password) + assertEquals(ProxyVersion.SOCKS5, config.outboundConfig!!.proxyConfig!!.version) + assertEquals(NetworkHostAndPort("localhost", 12345), config.outboundConfig!!.proxyConfig!!.proxyAddress) + assertEquals("proxyUser", config.outboundConfig!!.proxyConfig!!.userName) + assertEquals("pwd", config.outboundConfig!!.proxyConfig!!.password) val badConfigResource4 = "/net/corda/bridge/withsocks/badconfig/badsocksversion4.conf" assertFailsWith { createAndLoadConfigFromResource(tempFolder.root.toPath() / "4", badConfigResource4) @@ -162,6 +162,6 @@ class ConfigTest { val configResource = "/net/corda/bridge/version3/bridge.conf" val config = createAndLoadConfigFromResource(tempFolder.root.toPath(), configResource) assertEquals("HelloCorda!", config.healthCheckPhrase) - assertEquals("proxyUser", config.outboundConfig?.socksProxyConfig?.userName) + assertEquals("proxyUser", config.outboundConfig?.proxyConfig?.userName) } } \ No newline at end of file diff --git a/bridge/src/test/resources/net/corda/bridge/healthcheckphrase/firewall.conf b/bridge/src/test/resources/net/corda/bridge/healthcheckphrase/firewall.conf index e79b1d2a28..723fda9012 100644 --- a/bridge/src/test/resources/net/corda/bridge/healthcheckphrase/firewall.conf +++ b/bridge/src/test/resources/net/corda/bridge/healthcheckphrase/firewall.conf @@ -1,7 +1,7 @@ firewallMode = SenderReceiver outboundConfig : { artemisBrokerAddress = "localhost:11005" - socksProxyConfig : { + proxyConfig : { version = SOCKS5 proxyAddress = "localhost:12345" userName = "proxyUser" diff --git a/bridge/src/test/resources/net/corda/bridge/withaudit/badconfig/badInterval.conf b/bridge/src/test/resources/net/corda/bridge/withaudit/badconfig/badInterval.conf index becf64becb..3680604ceb 100644 --- a/bridge/src/test/resources/net/corda/bridge/withaudit/badconfig/badInterval.conf +++ b/bridge/src/test/resources/net/corda/bridge/withaudit/badconfig/badInterval.conf @@ -1,7 +1,7 @@ firewallMode = SenderReceiver outboundConfig : { artemisBrokerAddress = "localhost:11005" - socksProxyConfig : { + proxyConfig : { version = SOCKS5 proxyAddress = "localhost:12345" userName = "proxyUser" diff --git a/bridge/src/test/resources/net/corda/bridge/withaudit/firewall.conf b/bridge/src/test/resources/net/corda/bridge/withaudit/firewall.conf index 5c325f4a0e..cfc59021a7 100644 --- a/bridge/src/test/resources/net/corda/bridge/withaudit/firewall.conf +++ b/bridge/src/test/resources/net/corda/bridge/withaudit/firewall.conf @@ -1,7 +1,7 @@ firewallMode = SenderReceiver outboundConfig : { artemisBrokerAddress = "localhost:11005" - socksProxyConfig : { + proxyConfig : { version = SOCKS5 proxyAddress = "localhost:12345" userName = "proxyUser" diff --git a/bridge/src/test/resources/net/corda/bridge/withsocks/badconfig/badsocksversion4.conf b/bridge/src/test/resources/net/corda/bridge/withsocks/badconfig/badsocksversion4.conf index 6add547fe1..ddb13e4bcd 100644 --- a/bridge/src/test/resources/net/corda/bridge/withsocks/badconfig/badsocksversion4.conf +++ b/bridge/src/test/resources/net/corda/bridge/withsocks/badconfig/badsocksversion4.conf @@ -1,7 +1,7 @@ firewallMode = SenderReceiver outboundConfig : { artemisBrokerAddress = "localhost:11005" - socksProxyConfig : { + proxyConfig : { version = 4 proxyAddress = "localhost:12345" userName = "proxyUser" diff --git a/bridge/src/test/resources/net/corda/bridge/withsocks/badconfig/badsocksversion5.conf b/bridge/src/test/resources/net/corda/bridge/withsocks/badconfig/badsocksversion5.conf index ab5647facd..898e48f90d 100644 --- a/bridge/src/test/resources/net/corda/bridge/withsocks/badconfig/badsocksversion5.conf +++ b/bridge/src/test/resources/net/corda/bridge/withsocks/badconfig/badsocksversion5.conf @@ -1,7 +1,7 @@ firewallMode = SenderReceiver outboundConfig : { artemisBrokerAddress = "localhost:11005" - socksProxyConfig : { + proxyConfig : { version = 5 proxyAddress = "localhost:12345" userName = "proxyUser" diff --git a/bridge/src/test/resources/net/corda/bridge/withsocks/badconfig/socks4passwordsillegal.conf b/bridge/src/test/resources/net/corda/bridge/withsocks/badconfig/socks4passwordsillegal.conf index 4be3238c92..63fb641d08 100644 --- a/bridge/src/test/resources/net/corda/bridge/withsocks/badconfig/socks4passwordsillegal.conf +++ b/bridge/src/test/resources/net/corda/bridge/withsocks/badconfig/socks4passwordsillegal.conf @@ -1,7 +1,7 @@ firewallMode = SenderReceiver outboundConfig : { artemisBrokerAddress = "localhost:11005" - socksProxyConfig : { + proxyConfig : { version = SOCKS4 proxyAddress = "localhost:12345" userName = "proxyUser" diff --git a/bridge/src/test/resources/net/corda/bridge/withsocks/firewall.conf b/bridge/src/test/resources/net/corda/bridge/withsocks/firewall.conf index 4f39b78585..52605a6bf4 100644 --- a/bridge/src/test/resources/net/corda/bridge/withsocks/firewall.conf +++ b/bridge/src/test/resources/net/corda/bridge/withsocks/firewall.conf @@ -1,7 +1,7 @@ firewallMode = SenderReceiver outboundConfig : { artemisBrokerAddress = "localhost:11005" - socksProxyConfig : { + proxyConfig : { version = SOCKS5 proxyAddress = "localhost:12345" userName = "proxyUser" diff --git a/docs/source/changelog-enterprise.rst b/docs/source/changelog-enterprise.rst index e13df4a248..2ccf3295d4 100644 --- a/docs/source/changelog-enterprise.rst +++ b/docs/source/changelog-enterprise.rst @@ -12,9 +12,11 @@ Please refer to :doc:`changelog` for all Open Source changes which automatically Changelog entries in this unreleased section refer to Enterprise-only changes. * The ``corda-bridgserver.jar`` has been renamed to ``corda-firewall.jar`` to be more consistent - with marketing materials and purpose of the jar. Further to this we have also renamed ``bridge.conf`` to ``firewall.conf`` - and within that file the ``bridgeMode`` propety has been modified to ``firewallMode`` for overall consistency. - This will be a breaking change for early adopters and their deployments, but hopefully will be more future proof. + with marketing materials and purpose of the jar. Further to this we have also renamed ``bridge.conf`` to ``firewall.conf``. + Within that configuration file the ``bridgeMode`` property has been modified to ``firewallMode`` for overall consistency. + Furthermore, under ``outboundConfig`` - ``socksProxyConfig`` been renamed into ``proxyConfig``. + This will not be a breaking change for early adopters and their deployments, as new version of software can still consume + old style configs and produce a meaningful warning. * Introduced a hierarchy of ``DatabaseMigrationException``s, allowing ``NodeStartup`` to gracefully inform users of problems related to database migrations before exiting with a non-zero code. diff --git a/docs/source/firewall-configuration-file.rst b/docs/source/firewall-configuration-file.rst index 4836bc4fb8..9139e2b253 100644 --- a/docs/source/firewall-configuration-file.rst +++ b/docs/source/firewall-configuration-file.rst @@ -117,7 +117,7 @@ absolute path to the firewall's base directory. :crlCheckSoftFail: If true (recommended setting) allows certificate checks to pass if the CRL(certificate revocation list) provider is unavailable. - :socksProxyConfig: This section is optionally present if outgoing peer connections should go via a SOCKS4, or SOCKS5 proxy: + :proxyConfig: This section is optionally present if outgoing peer connections should go via a SOCKS4, or SOCKS5 proxy: :version: Either SOCKS4, or SOCKS5 to define the protocol version used in connecting to the SOCKS proxy. @@ -397,7 +397,7 @@ Configuration in ``firewall.conf`` for ``bridgeserver1``: outboundConfig { // Required section artemisBrokerAddress = "nodeserver1:11005" // point at primary Artemis address in the node alternateArtemisBrokerAddresses = [ "nodeserver2:11005" ] // List any other HA Artemis addresses - socksProxyConfig { // Enable SOCKS proxying by specifying this section + proxyConfig { // Enable SOCKS proxying by specifying this section version = SOCKS5 proxyAddress = "proxyserver:12345" username = "proxyuser" @@ -428,7 +428,7 @@ Configuration in ``firewall.conf`` for ``bridgeserver2``: outboundConfig { // Required section artemisBrokerAddress = "nodeserver2:11005" // point at primary Artemis address in the node alternateArtemisBrokerAddresses = [ "nodeserver1:11005" ] // List any other HA Artemis addresses - socksProxyConfig { // Enable SOCKS proxying by specifying this section + proxyConfig { // Enable SOCKS proxying by specifying this section version = SOCKS5 proxyAddress = "proxyserver:12345" username = "proxyuser" diff --git a/node-api/src/main/kotlin/net/corda/nodeapi/internal/bridging/AMQPBridgeManager.kt b/node-api/src/main/kotlin/net/corda/nodeapi/internal/bridging/AMQPBridgeManager.kt index c65238cdd1..42446edb3d 100644 --- a/node-api/src/main/kotlin/net/corda/nodeapi/internal/bridging/AMQPBridgeManager.kt +++ b/node-api/src/main/kotlin/net/corda/nodeapi/internal/bridging/AMQPBridgeManager.kt @@ -16,7 +16,7 @@ import net.corda.nodeapi.internal.config.MutualSslConfiguration import net.corda.nodeapi.internal.protonwrapper.messages.MessageStatus import net.corda.nodeapi.internal.protonwrapper.netty.AMQPClient import net.corda.nodeapi.internal.protonwrapper.netty.AMQPConfiguration -import net.corda.nodeapi.internal.protonwrapper.netty.SocksProxyConfig +import net.corda.nodeapi.internal.protonwrapper.netty.ProxyConfig import org.apache.activemq.artemis.api.core.SimpleString import org.apache.activemq.artemis.api.core.client.ActiveMQClient.DEFAULT_ACK_BATCH_SIZE import org.apache.activemq.artemis.api.core.client.ClientConsumer @@ -36,7 +36,7 @@ import kotlin.concurrent.withLock */ @VisibleForTesting open class AMQPBridgeManager(config: MutualSslConfiguration, - socksProxyConfig: SocksProxyConfig? = null, + proxyConfig: ProxyConfig? = null, maxMessageSize: Int, enableSNI: Boolean, private val artemisMessageClientFactory: () -> ArtemisSessionProvider, @@ -47,24 +47,24 @@ open class AMQPBridgeManager(config: MutualSslConfiguration, private class AMQPConfigurationImpl(override val keyStore: CertificateStore, override val trustStore: CertificateStore, - override val socksProxyConfig: SocksProxyConfig?, + override val proxyConfig: ProxyConfig?, override val maxMessageSize: Int, override val useOpenSsl: Boolean, override val enableSNI: Boolean, override val sourceX500Name: String? = null) : AMQPConfiguration { - constructor(config: MutualSslConfiguration, socksProxyConfig: SocksProxyConfig?, maxMessageSize: Int, enableSNI: Boolean) : this(config.keyStore.get(), + constructor(config: MutualSslConfiguration, proxyConfig: ProxyConfig?, maxMessageSize: Int, enableSNI: Boolean) : this(config.keyStore.get(), config.trustStore.get(), - socksProxyConfig, + proxyConfig, maxMessageSize, config.useOpenSsl, enableSNI) } - private val amqpConfig: AMQPConfiguration = AMQPConfigurationImpl(config, socksProxyConfig, maxMessageSize, enableSNI) + private val amqpConfig: AMQPConfiguration = AMQPConfigurationImpl(config, proxyConfig, maxMessageSize, enableSNI) private var sharedEventLoopGroup: EventLoopGroup? = null private var artemis: ArtemisSessionProvider? = null - constructor(config: MutualSslConfiguration, p2pAddress: NetworkHostAndPort, maxMessageSize: Int, enableSNI: Boolean, socksProxyConfig: SocksProxyConfig? = null) : this(config, socksProxyConfig, maxMessageSize, enableSNI, { ArtemisMessagingClient(config, p2pAddress, maxMessageSize) }) + constructor(config: MutualSslConfiguration, p2pAddress: NetworkHostAndPort, maxMessageSize: Int, enableSNI: Boolean, proxyConfig: ProxyConfig? = null) : this(config, proxyConfig, maxMessageSize, enableSNI, { ArtemisMessagingClient(config, p2pAddress, maxMessageSize) }) companion object { private const val NUM_BRIDGE_THREADS = 0 // Default sized pool @@ -239,7 +239,7 @@ open class AMQPBridgeManager(config: MutualSslConfiguration, return } } - val newAMQPConfig = with(amqpConfig) { AMQPConfigurationImpl(keyStore, trustStore, socksProxyConfig, maxMessageSize, useOpenSsl, enableSNI, sourceX500Name) } + val newAMQPConfig = with(amqpConfig) { AMQPConfigurationImpl(keyStore, trustStore, proxyConfig, maxMessageSize, useOpenSsl, enableSNI, sourceX500Name) } val newBridge = AMQPBridge(sourceX500Name, queueName, targets, legalNames, newAMQPConfig, sharedEventLoopGroup!!, artemis!!, bridgeMetricsService) bridges += newBridge bridgeMetricsService?.bridgeCreated(targets, legalNames) diff --git a/node-api/src/main/kotlin/net/corda/nodeapi/internal/bridging/BridgeControlListener.kt b/node-api/src/main/kotlin/net/corda/nodeapi/internal/bridging/BridgeControlListener.kt index 59cc625880..7b7db809f3 100644 --- a/node-api/src/main/kotlin/net/corda/nodeapi/internal/bridging/BridgeControlListener.kt +++ b/node-api/src/main/kotlin/net/corda/nodeapi/internal/bridging/BridgeControlListener.kt @@ -12,7 +12,7 @@ import net.corda.nodeapi.internal.ArtemisMessagingComponent.Companion.P2P_PREFIX import net.corda.nodeapi.internal.ArtemisMessagingComponent.Companion.PEERS_PREFIX import net.corda.nodeapi.internal.ArtemisSessionProvider import net.corda.nodeapi.internal.config.MutualSslConfiguration -import net.corda.nodeapi.internal.protonwrapper.netty.SocksProxyConfig +import net.corda.nodeapi.internal.protonwrapper.netty.ProxyConfig import org.apache.activemq.artemis.api.core.ActiveMQQueueExistsException import org.apache.activemq.artemis.api.core.RoutingType import org.apache.activemq.artemis.api.core.SimpleString @@ -24,7 +24,7 @@ import rx.subjects.PublishSubject import java.util.* class BridgeControlListener(val config: MutualSslConfiguration, - socksProxyConfig: SocksProxyConfig? = null, + proxyConfig: ProxyConfig? = null, maxMessageSize: Int, enableSNI: Boolean, private val artemisMessageClientFactory: () -> ArtemisSessionProvider, @@ -34,9 +34,9 @@ class BridgeControlListener(val config: MutualSslConfiguration, private val bridgeNotifyQueue = "$BRIDGE_NOTIFY.$bridgeId" private val validInboundQueues = mutableSetOf() private val bridgeManager = if (enableSNI) { - LoopbackBridgeManager(config, socksProxyConfig, maxMessageSize, enableSNI, artemisMessageClientFactory, bridgeMetricsService, this::validateReceiveTopic) + LoopbackBridgeManager(config, proxyConfig, maxMessageSize, enableSNI, artemisMessageClientFactory, bridgeMetricsService, this::validateReceiveTopic) } else { - AMQPBridgeManager(config, socksProxyConfig, maxMessageSize, enableSNI, artemisMessageClientFactory, bridgeMetricsService) + AMQPBridgeManager(config, proxyConfig, maxMessageSize, enableSNI, artemisMessageClientFactory, bridgeMetricsService) } private var artemis: ArtemisSessionProvider? = null private var controlConsumer: ClientConsumer? = null @@ -46,7 +46,7 @@ class BridgeControlListener(val config: MutualSslConfiguration, p2pAddress: NetworkHostAndPort, maxMessageSize: Int, enableSNI: Boolean, - socksProxy: SocksProxyConfig? = null) : this(config, socksProxy, maxMessageSize, enableSNI, { ArtemisMessagingClient(config, p2pAddress, maxMessageSize) }) + proxy: ProxyConfig? = null) : this(config, proxy, maxMessageSize, enableSNI, { ArtemisMessagingClient(config, p2pAddress, maxMessageSize) }) companion object { private val log = contextLogger() diff --git a/node-api/src/main/kotlin/net/corda/nodeapi/internal/bridging/LoopbackBridgeManager.kt b/node-api/src/main/kotlin/net/corda/nodeapi/internal/bridging/LoopbackBridgeManager.kt index 8657c2515f..8cc70fd58f 100644 --- a/node-api/src/main/kotlin/net/corda/nodeapi/internal/bridging/LoopbackBridgeManager.kt +++ b/node-api/src/main/kotlin/net/corda/nodeapi/internal/bridging/LoopbackBridgeManager.kt @@ -11,7 +11,7 @@ import net.corda.nodeapi.internal.ArtemisMessagingComponent.RemoteInboxAddress.C import net.corda.nodeapi.internal.ArtemisSessionProvider import net.corda.nodeapi.internal.config.MutualSslConfiguration import net.corda.nodeapi.internal.protonwrapper.messages.impl.SendableMessageImpl -import net.corda.nodeapi.internal.protonwrapper.netty.SocksProxyConfig +import net.corda.nodeapi.internal.protonwrapper.netty.ProxyConfig import org.apache.activemq.artemis.api.core.SimpleString import org.apache.activemq.artemis.api.core.client.ActiveMQClient.DEFAULT_ACK_BATCH_SIZE import org.apache.activemq.artemis.api.core.client.ClientConsumer @@ -26,12 +26,12 @@ import org.slf4j.MDC */ @VisibleForTesting class LoopbackBridgeManager(config: MutualSslConfiguration, - socksProxyConfig: SocksProxyConfig? = null, + proxyConfig: ProxyConfig? = null, maxMessageSize: Int, enableSNI: Boolean, private val artemisMessageClientFactory: () -> ArtemisSessionProvider, private val bridgeMetricsService: BridgeMetricsService? = null, - private val isLocalInbox: (String) -> Boolean) : AMQPBridgeManager(config, socksProxyConfig, maxMessageSize, enableSNI, artemisMessageClientFactory, bridgeMetricsService) { + private val isLocalInbox: (String) -> Boolean) : AMQPBridgeManager(config, proxyConfig, maxMessageSize, enableSNI, artemisMessageClientFactory, bridgeMetricsService) { companion object { private val log = contextLogger() diff --git a/node-api/src/main/kotlin/net/corda/nodeapi/internal/protonwrapper/netty/AMQPClient.kt b/node-api/src/main/kotlin/net/corda/nodeapi/internal/protonwrapper/netty/AMQPClient.kt index 1e49766b61..1c28f01ae0 100644 --- a/node-api/src/main/kotlin/net/corda/nodeapi/internal/protonwrapper/netty/AMQPClient.kt +++ b/node-api/src/main/kotlin/net/corda/nodeapi/internal/protonwrapper/netty/AMQPClient.kt @@ -28,14 +28,14 @@ import javax.net.ssl.KeyManagerFactory import javax.net.ssl.TrustManagerFactory import kotlin.concurrent.withLock -enum class SocksProxyVersion { +enum class ProxyVersion { SOCKS4, SOCKS5 } -data class SocksProxyConfig(val version: SocksProxyVersion, val proxyAddress: NetworkHostAndPort, val userName: String? = null, val password: String? = null) { +data class ProxyConfig(val version: ProxyVersion, val proxyAddress: NetworkHostAndPort, val userName: String? = null, val password: String? = null) { init { - if (version == SocksProxyVersion.SOCKS4) { + if (version == ProxyVersion.SOCKS4) { require(password == null) { "SOCKS4 does not support a password" } } } @@ -136,14 +136,14 @@ class AMQPClient(val targets: List, override fun initChannel(ch: SocketChannel) { val pipeline = ch.pipeline() - val socksConfig = conf.socksProxyConfig + val socksConfig = conf.proxyConfig if (socksConfig != null) { val proxyAddress = InetSocketAddress(socksConfig.proxyAddress.host, socksConfig.proxyAddress.port) - val proxy = when (conf.socksProxyConfig!!.version) { - SocksProxyVersion.SOCKS4 -> { + val proxy = when (conf.proxyConfig!!.version) { + ProxyVersion.SOCKS4 -> { Socks4ProxyHandler(proxyAddress, socksConfig.userName) } - SocksProxyVersion.SOCKS5 -> { + ProxyVersion.SOCKS5 -> { Socks5ProxyHandler(proxyAddress, socksConfig.userName, socksConfig.password) } } diff --git a/node-api/src/main/kotlin/net/corda/nodeapi/internal/protonwrapper/netty/AMQPConfiguration.kt b/node-api/src/main/kotlin/net/corda/nodeapi/internal/protonwrapper/netty/AMQPConfiguration.kt index 24d5e9fc8a..19f98e0486 100644 --- a/node-api/src/main/kotlin/net/corda/nodeapi/internal/protonwrapper/netty/AMQPConfiguration.kt +++ b/node-api/src/main/kotlin/net/corda/nodeapi/internal/protonwrapper/netty/AMQPConfiguration.kt @@ -52,7 +52,7 @@ interface AMQPConfiguration { val maxMessageSize: Int @JvmDefault - val socksProxyConfig: SocksProxyConfig? + val proxyConfig: ProxyConfig? get() = null @JvmDefault diff --git a/node/src/integration-test/kotlin/net/corda/node/amqp/SocksTests.kt b/node/src/integration-test/kotlin/net/corda/node/amqp/SocksTests.kt index 006ee4c50c..59b3f47cc3 100644 --- a/node/src/integration-test/kotlin/net/corda/node/amqp/SocksTests.kt +++ b/node/src/integration-test/kotlin/net/corda/node/amqp/SocksTests.kt @@ -312,7 +312,7 @@ class SocksTests { override val trustStore = clientTruststore override val trace: Boolean = true override val maxMessageSize: Int = MAX_MESSAGE_SIZE - override val socksProxyConfig: SocksProxyConfig? = SocksProxyConfig(SocksProxyVersion.SOCKS5, NetworkHostAndPort("127.0.0.1", socksPort), null, null) + override val proxyConfig: ProxyConfig? = ProxyConfig(ProxyVersion.SOCKS5, NetworkHostAndPort("127.0.0.1", socksPort), null, null) } return AMQPClient( listOf(NetworkHostAndPort("localhost", serverPort), @@ -344,7 +344,7 @@ class SocksTests { override val trustStore = clientTruststore override val trace: Boolean = true override val maxMessageSize: Int = MAX_MESSAGE_SIZE - override val socksProxyConfig: SocksProxyConfig? = SocksProxyConfig(SocksProxyVersion.SOCKS5, NetworkHostAndPort("127.0.0.1", socksPort), null, null) + override val proxyConfig: ProxyConfig? = ProxyConfig(ProxyVersion.SOCKS5, NetworkHostAndPort("127.0.0.1", socksPort), null, null) } return AMQPClient(