mirror of
https://github.com/corda/corda.git
synced 2025-04-16 07:27:17 +00:00
ENT-2669: SocksProxy rename into Proxy (#1533)
* ENT-2669: Rename SocksProxyVersion into ProxyVersion * ENT-2669: Rename SocksProxyConfig into ProxyConfig Update documentation and make code changes such that old style configs are still parsed. * ENT-2669: Changelog update
This commit is contained in:
parent
07719489e4
commit
513305ee7d
@ -1,7 +1,7 @@
|
||||
firewallMode = SenderReceiver
|
||||
outboundConfig : {
|
||||
artemisBrokerAddress = "localhost:11005"
|
||||
socksProxyConfig : {
|
||||
proxyConfig : {
|
||||
version = SOCKS5
|
||||
proxyAddress = "localhost:12345"
|
||||
userName = "proxyUser"
|
||||
|
@ -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?
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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<FirewallConfigurationImpl>()
|
||||
} catch (ex: UnknownConfigurationKeysException) {
|
||||
|
||||
// Previously `proxyConfig` was known as `socksProxyConfig`
|
||||
data class Version3BridgeOutboundConfigurationImpl(val artemisBrokerAddress: NetworkHostAndPort,
|
||||
val alternateArtemisBrokerAddresses: List<NetworkHostAndPort>,
|
||||
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<NetworkHostAndPort>,
|
||||
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
|
||||
|
@ -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) },
|
||||
|
@ -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<IllegalArgumentException> {
|
||||
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)
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
firewallMode = SenderReceiver
|
||||
outboundConfig : {
|
||||
artemisBrokerAddress = "localhost:11005"
|
||||
socksProxyConfig : {
|
||||
proxyConfig : {
|
||||
version = SOCKS5
|
||||
proxyAddress = "localhost:12345"
|
||||
userName = "proxyUser"
|
||||
|
@ -1,7 +1,7 @@
|
||||
firewallMode = SenderReceiver
|
||||
outboundConfig : {
|
||||
artemisBrokerAddress = "localhost:11005"
|
||||
socksProxyConfig : {
|
||||
proxyConfig : {
|
||||
version = SOCKS5
|
||||
proxyAddress = "localhost:12345"
|
||||
userName = "proxyUser"
|
||||
|
@ -1,7 +1,7 @@
|
||||
firewallMode = SenderReceiver
|
||||
outboundConfig : {
|
||||
artemisBrokerAddress = "localhost:11005"
|
||||
socksProxyConfig : {
|
||||
proxyConfig : {
|
||||
version = SOCKS5
|
||||
proxyAddress = "localhost:12345"
|
||||
userName = "proxyUser"
|
||||
|
@ -1,7 +1,7 @@
|
||||
firewallMode = SenderReceiver
|
||||
outboundConfig : {
|
||||
artemisBrokerAddress = "localhost:11005"
|
||||
socksProxyConfig : {
|
||||
proxyConfig : {
|
||||
version = 4
|
||||
proxyAddress = "localhost:12345"
|
||||
userName = "proxyUser"
|
||||
|
@ -1,7 +1,7 @@
|
||||
firewallMode = SenderReceiver
|
||||
outboundConfig : {
|
||||
artemisBrokerAddress = "localhost:11005"
|
||||
socksProxyConfig : {
|
||||
proxyConfig : {
|
||||
version = 5
|
||||
proxyAddress = "localhost:12345"
|
||||
userName = "proxyUser"
|
||||
|
@ -1,7 +1,7 @@
|
||||
firewallMode = SenderReceiver
|
||||
outboundConfig : {
|
||||
artemisBrokerAddress = "localhost:11005"
|
||||
socksProxyConfig : {
|
||||
proxyConfig : {
|
||||
version = SOCKS4
|
||||
proxyAddress = "localhost:12345"
|
||||
userName = "proxyUser"
|
||||
|
@ -1,7 +1,7 @@
|
||||
firewallMode = SenderReceiver
|
||||
outboundConfig : {
|
||||
artemisBrokerAddress = "localhost:11005"
|
||||
socksProxyConfig : {
|
||||
proxyConfig : {
|
||||
version = SOCKS5
|
||||
proxyAddress = "localhost:12345"
|
||||
userName = "proxyUser"
|
||||
|
@ -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.
|
||||
|
@ -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"
|
||||
|
@ -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)
|
||||
|
@ -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<String>()
|
||||
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()
|
||||
|
@ -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()
|
||||
|
@ -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<NetworkHostAndPort>,
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ interface AMQPConfiguration {
|
||||
val maxMessageSize: Int
|
||||
|
||||
@JvmDefault
|
||||
val socksProxyConfig: SocksProxyConfig?
|
||||
val proxyConfig: ProxyConfig?
|
||||
get() = null
|
||||
|
||||
@JvmDefault
|
||||
|
@ -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(
|
||||
|
Loading…
x
Reference in New Issue
Block a user