Skip to content

Commit

Permalink
Version 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
GregHib committed Jan 19, 2021
1 parent 5dfb4c9 commit 9980144
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 44 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# RS2 File Server

A stand-alone server for distributing rs2 cache files.
A stand-alone server for distributing rs2 cache files.

## Quick guide

Download the latest [released jar](../../releases/) and [file-server.properties](./file-server.properties) into the same directory.

Update `file-server.properties` with your own values, including cache directory and rsa keys.

> You can remove the `prefetchKeys` property to auto generate them on start-up.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ plugins {
}

group = "world.gregs.rs2.file"
group = "1.0-SNAPSHOP"
group = "1.0.0"

repositories {
mavenCentral()
Expand Down
87 changes: 45 additions & 42 deletions src/main/kotlin/world/gregs/rs2/file/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,51 +6,54 @@ import java.io.File
import java.math.BigInteger
import kotlin.concurrent.thread

fun main() {
val logger = InlineLogger()
val start = System.currentTimeMillis()
logger.info { "Start up..." }
val file = File("./file-server.properties")
if (!file.exists()) {
logger.error { "Unable to find server properties file." }
return
}
object Main {
@JvmStatic
fun main(args: Array<String>) {
val logger = InlineLogger()
val start = System.currentTimeMillis()
logger.info { "Start up..." }
val file = File("./file-server.properties")
if (!file.exists()) {
logger.error { "Unable to find server properties file." }
return
}

var revision = 0
var port = 0
var threads = 0
lateinit var cachePath: String
lateinit var modulus: BigInteger
lateinit var exponent: BigInteger
var prefetchKeys: IntArray = intArrayOf()
file.forEachLine { line ->
val (key, value) = line.split("=")
when (key) {
"revision" -> revision = value.toInt()
"port" -> port = value.toInt()
"threads" -> threads = value.toInt()
"cachePath" -> cachePath = value
"rsaModulus" -> modulus = BigInteger(value, 16)
"rsaPrivate" -> exponent = BigInteger(value, 16)
"prefetchKeys" -> prefetchKeys = value.split(",").map { it.toInt() }.toIntArray()
var revision = 0
var port = 0
var threads = 0
lateinit var cachePath: String
lateinit var modulus: BigInteger
lateinit var exponent: BigInteger
var prefetchKeys: IntArray = intArrayOf()
file.forEachLine { line ->
val (key, value) = line.split("=")
when (key) {
"revision" -> revision = value.toInt()
"port" -> port = value.toInt()
"threads" -> threads = value.toInt()
"cachePath" -> cachePath = value
"rsaModulus" -> modulus = BigInteger(value, 16)
"rsaPrivate" -> exponent = BigInteger(value, 16)
"prefetchKeys" -> prefetchKeys = value.split(",").map { it.toInt() }.toIntArray()
}
}
}
logger.info { "Settings loaded." }
logger.info { "Settings loaded." }

val cache = CacheLibrary(cachePath)
val versionTable = cache.generateNewUkeys(exponent, modulus)
logger.debug { "Version table generated: ${versionTable.contentToString()}" }
val cache = CacheLibrary(cachePath)
val versionTable = cache.generateNewUkeys(exponent, modulus)
logger.debug { "Version table generated: ${versionTable.contentToString()}" }

if (prefetchKeys.isEmpty()) {
prefetchKeys = generatePrefetchKeys(cache)
logger.debug { "Prefetch keys generated: ${prefetchKeys.contentToString()}" }
}
logger.info { "Cache loaded." }
if (prefetchKeys.isEmpty()) {
prefetchKeys = generatePrefetchKeys(cache)
logger.debug { "Prefetch keys generated: ${prefetchKeys.contentToString()}" }
}
logger.info { "Cache loaded." }

val fileServer = FileServer(DataProvider(cache), versionTable)
val network = Network(fileServer, prefetchKeys, revision)
logger.info { "Loading complete [${System.currentTimeMillis() - start}ms]" }
val runtime = Runtime.getRuntime()
runtime.addShutdownHook(thread(start = false) { network.stop() })
network.start(port, threads)
val fileServer = FileServer(DataProvider(cache), versionTable)
val network = Network(fileServer, prefetchKeys, revision)
logger.info { "Loading complete [${System.currentTimeMillis() - start}ms]" }
val runtime = Runtime.getRuntime()
runtime.addShutdownHook(thread(start = false) { network.stop() })
network.start(port, threads)
}
}

0 comments on commit 9980144

Please sign in to comment.