mirror of
https://github.com/ViaVersion/VIAaaS.git
synced 2025-01-24 22:01:49 +01:00
multi port binding
This commit is contained in:
parent
d4628a113a
commit
c7ef8d4481
@ -70,7 +70,7 @@ object AspirinServer {
|
|||||||
|
|
||||||
val parentLoop = eventLoopGroup()
|
val parentLoop = eventLoopGroup()
|
||||||
val childLoop = eventLoopGroup()
|
val childLoop = eventLoopGroup()
|
||||||
var chFuture: ChannelFuture? = null
|
var chFutures = mutableListOf<ChannelFuture>()
|
||||||
val dnsResolver = DnsNameResolverBuilder(childLoop.next())
|
val dnsResolver = DnsNameResolverBuilder(childLoop.next())
|
||||||
.socketChannelFactory(channelSocketFactory(childLoop))
|
.socketChannelFactory(channelSocketFactory(childLoop))
|
||||||
.channelFactory(channelDatagramFactory(childLoop))
|
.channelFactory(channelDatagramFactory(childLoop))
|
||||||
@ -95,11 +95,10 @@ object AspirinServer {
|
|||||||
mainFinishSignal()
|
mainFinishSignal()
|
||||||
ktorServer?.stop(1000, 1000)
|
ktorServer?.stop(1000, 1000)
|
||||||
httpClient.close()
|
httpClient.close()
|
||||||
listOf<Future<*>?>(
|
(chFutures.map { it.channel().close() } + listOf<Future<*>?>(
|
||||||
chFuture?.channel()?.close(),
|
|
||||||
parentLoop.shutdownGracefully(),
|
parentLoop.shutdownGracefully(),
|
||||||
childLoop.shutdownGracefully()
|
childLoop.shutdownGracefully()
|
||||||
)
|
))
|
||||||
.forEach { it?.sync() }
|
.forEach { it?.sync() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -115,7 +114,7 @@ object AspirinServer {
|
|||||||
fun mainStartSignal() = initFuture.complete(Unit)
|
fun mainStartSignal() = initFuture.complete(Unit)
|
||||||
|
|
||||||
fun listenPorts(args: Array<String>) {
|
fun listenPorts(args: Array<String>) {
|
||||||
chFuture = ServerBootstrap()
|
val serverBootstrap = ServerBootstrap()
|
||||||
.group(parentLoop, childLoop)
|
.group(parentLoop, childLoop)
|
||||||
.channelFactory(channelServerSocketFactory(parentLoop))
|
.channelFactory(channelServerSocketFactory(parentLoop))
|
||||||
.childHandler(FrontEndInit)
|
.childHandler(FrontEndInit)
|
||||||
@ -123,12 +122,16 @@ object AspirinServer {
|
|||||||
.childOption(ChannelOption.IP_TOS, 0x18)
|
.childOption(ChannelOption.IP_TOS, 0x18)
|
||||||
.childOption(ChannelOption.TCP_NODELAY, true)
|
.childOption(ChannelOption.TCP_NODELAY, true)
|
||||||
.option(ChannelOption.TCP_FASTOPEN, 32)
|
.option(ChannelOption.TCP_FASTOPEN, 32)
|
||||||
.bind(InetAddress.getByName(VIAaaSConfig.bindAddress), VIAaaSConfig.port)
|
VIAaaSConfig.ports.forEach {
|
||||||
|
chFutures.add(serverBootstrap.bind(InetAddress.getByName(VIAaaSConfig.bindAddress), it))
|
||||||
|
}
|
||||||
|
|
||||||
ktorServer = embeddedServer(Netty, commandLineEnvironment(args)) {}.start(false)
|
ktorServer = embeddedServer(Netty, commandLineEnvironment(args)) {}.start(false)
|
||||||
|
|
||||||
viaaasLogger.info("Using compression: ${Natives.compress.loadedVariant}, crypto: ${Natives.cipher.loadedVariant}")
|
viaaasLogger.info("Using compression: ${Natives.compress.loadedVariant}, crypto: ${Natives.cipher.loadedVariant}")
|
||||||
viaaasLogger.info("Binded minecraft into " + chFuture!!.sync().channel().localAddress())
|
chFutures.forEach {
|
||||||
|
viaaasLogger.info("Binded minecraft into into " + it.sync().channel().localAddress())
|
||||||
|
}
|
||||||
viaaasLogger.info(
|
viaaasLogger.info(
|
||||||
"Application started in " + ManagementFactory.getRuntimeMXBean().uptime
|
"Application started in " + ManagementFactory.getRuntimeMXBean().uptime
|
||||||
.milliseconds.toDouble(DurationUnit.SECONDS) + "s"
|
.milliseconds.toDouble(DurationUnit.SECONDS) + "s"
|
||||||
|
@ -63,7 +63,7 @@ object VIAaaSConfig : Config(File("config/viaaas.yml")) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val port: Int get() = this.getInt("port", 25565)
|
val ports: List<Int> get() = Objects.toString(this.get("port", Any::class.java, "25565"))!!.split(',').map { it.trim().toInt() }.distinct()
|
||||||
val bindAddress: String get() = this.getString("bind-address", "localhost")!!
|
val bindAddress: String get() = this.getString("bind-address", "localhost")!!
|
||||||
val hostName: List<String>
|
val hostName: List<String>
|
||||||
get() = this.get("host-name", List::class.java, listOf("viaaas.localhost"))!!.map { it.toString() }
|
get() = this.get("host-name", List::class.java, listOf("viaaas.localhost"))!!.map { it.toString() }
|
||||||
|
Loading…
Reference in New Issue
Block a user