summaryrefslogtreecommitdiffstats
path: root/sources/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/socket/NettyTcpServer.kt
diff options
context:
space:
mode:
Diffstat (limited to 'sources/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/socket/NettyTcpServer.kt')
-rw-r--r--sources/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/socket/NettyTcpServer.kt19
1 files changed, 10 insertions, 9 deletions
diff --git a/sources/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/socket/NettyTcpServer.kt b/sources/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/socket/NettyTcpServer.kt
index 123956ad..fab96560 100644
--- a/sources/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/socket/NettyTcpServer.kt
+++ b/sources/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/socket/NettyTcpServer.kt
@@ -19,8 +19,10 @@
*/
package org.onap.dcae.collectors.veshv.impl.socket
+import arrow.core.Option
import arrow.core.getOrElse
import arrow.effects.IO
+import io.netty.handler.ssl.SslContext
import org.onap.dcae.collectors.veshv.boundary.Collector
import org.onap.dcae.collectors.veshv.boundary.CollectorProvider
import org.onap.dcae.collectors.veshv.boundary.Metrics
@@ -30,7 +32,6 @@ import org.onap.dcae.collectors.veshv.impl.adapters.ClientContextLogging.debug
import org.onap.dcae.collectors.veshv.impl.adapters.ClientContextLogging.info
import org.onap.dcae.collectors.veshv.model.ClientContext
import org.onap.dcae.collectors.veshv.model.ServiceContext
-import org.onap.dcae.collectors.veshv.ssl.boundary.SslContextFactory
import org.onap.dcae.collectors.veshv.utils.NettyServerHandle
import org.onap.dcae.collectors.veshv.utils.ServerHandle
import org.onap.dcae.collectors.veshv.utils.logging.Logger
@@ -41,6 +42,7 @@ import reactor.netty.NettyInbound
import reactor.netty.NettyOutbound
import reactor.netty.tcp.TcpServer
import java.net.InetAddress
+import java.net.InetSocketAddress
import java.time.Duration
@@ -48,14 +50,14 @@ import java.time.Duration
* @author Piotr Jaszczyk <piotr.jaszczyk@nokia.com>
* @since May 2018
*/
-internal class NettyTcpServer(private val serverConfig: ServerConfiguration,
- private val sslContextFactory: SslContextFactory,
+internal class NettyTcpServer(private val serverConfiguration: ServerConfiguration,
+ private val sslContext: Option<SslContext>,
private val collectorProvider: CollectorProvider,
private val metrics: Metrics) : Server {
override fun start(): IO<ServerHandle> = IO {
TcpServer.create()
- .addressSupplier { serverConfig.serverListenAddress }
+ .addressSupplier { InetSocketAddress(serverConfiguration.listenPort) }
.configureSsl()
.handle(this::handleConnection)
.doOnUnbound {
@@ -66,11 +68,10 @@ internal class NettyTcpServer(private val serverConfig: ServerConfiguration,
}
private fun TcpServer.configureSsl() =
- sslContextFactory
- .createServerContext(serverConfig.securityConfiguration)
- .map { sslContext ->
+ sslContext
+ .map { serverContext ->
logger.info { "Collector configured with SSL enabled" }
- this.secure { b -> b.sslContext(sslContext) }
+ this.secure { it.sslContext(serverContext) }
}.getOrElse {
logger.info { "Collector configured with SSL disabled" }
this
@@ -125,7 +126,7 @@ internal class NettyTcpServer(private val serverConfig: ServerConfiguration,
nettyInbound: NettyInbound): (Collector) -> Mono<Void> = { collector ->
withConnectionFrom(nettyInbound) { connection ->
connection
- .configureIdleTimeout(clientContext, serverConfig.idleTimeout)
+ .configureIdleTimeout(clientContext, serverConfiguration.idleTimeout)
.logConnectionClosed(clientContext)
}.run {
collector.handleConnection(nettyInbound.createDataStream())