Skip to content

Commit

Permalink
Add file server disabling #407
Browse files Browse the repository at this point in the history
  • Loading branch information
GregHib committed Feb 24, 2024
1 parent 37ace9f commit 4cfdf44
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions network/src/main/kotlin/world/gregs/voidps/network/FileServer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,19 @@ class FileServer(
fun load(cache: Cache, properties: Properties): Server {
val fileServer = properties.getProperty("fileServer").toBoolean()
if (!fileServer) {
return object : Server {
override suspend fun connect(read: ByteReadChannel, write: ByteWriteChannel, hostname: String) {
}
}
return offlineFileServer()
}
val fileProvider: FileProvider = FileProvider.load(cache, properties)
val revision = properties.getProperty("revision").toInt()
val prefetchKeys = prefetchKeys(cache, properties)
return FileServer(revision, prefetchKeys, fileProvider)
}

private fun offlineFileServer() = object : Server {
override suspend fun connect(read: ByteReadChannel, write: ByteWriteChannel, hostname: String) {
write.writeByte(Response.LOGIN_SERVER_OFFLINE)
write.close()
}
}
}
}

0 comments on commit 4cfdf44

Please sign in to comment.