Merge branch 'revamp-units' into 'master'
Revamped configuration & units See merge request mangadex/mangadex_at_home!32
This commit is contained in:
commit
564f92190c
|
@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- [2020-06-16] Reworked graceful shutdown [@carbotaniuman].
|
||||
- [2020-06-16] Changed log level of response timings to INFO by [@lflare].
|
||||
- [2020-06-16] api/pastStats no longer called on load of WebUI (this shouldn't affect hits/misses), will be reimplemented later [@RedMatriz].
|
||||
- [2020-06-17] Revamped configuration & units by [@lflare].
|
||||
|
||||
### Deprecated
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ public class Main {
|
|||
dieWithError("Config Error: Invalid port number");
|
||||
}
|
||||
|
||||
if (settings.getMaxCacheSizeMib() < 1024) {
|
||||
if (settings.getMaxCacheSizeInMebibytes() < 1024) {
|
||||
dieWithError("Config Error: Invalid max cache size, must be >= 1024 MiB (1GiB)");
|
||||
}
|
||||
|
||||
|
@ -82,11 +82,11 @@ public class Main {
|
|||
dieWithError("Config Error: Invalid number of threads, must be >= 4");
|
||||
}
|
||||
|
||||
if (settings.getMaxBandwidthMibPerHour() < 0) {
|
||||
if (settings.getMaxMebibytesPerHour() < 0) {
|
||||
dieWithError("Config Error: Max bandwidth must be >= 0");
|
||||
}
|
||||
|
||||
if (settings.getMaxBurstRateKibPerSecond() < 0) {
|
||||
if (settings.getMaxKilobitsPerSecond() < 0) {
|
||||
dieWithError("Config Error: Max burst rate must be >= 0");
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ public class MangaDexClient {
|
|||
|
||||
try {
|
||||
cache = DiskLruCache.open(new File("cache"), 1, 1,
|
||||
clientSettings.getMaxCacheSizeMib() * 1024 * 1024 /* MiB to bytes */);
|
||||
clientSettings.getMaxCacheSizeInMebibytes() * 1024 * 1024 /* MiB to bytes */);
|
||||
|
||||
DiskLruCache.Snapshot snapshot = cache.get("statistics");
|
||||
if (snapshot != null) {
|
||||
|
@ -165,8 +165,8 @@ public class MangaDexClient {
|
|||
}
|
||||
|
||||
long currentBytesSent = statistics.get().getBytesSent() - lastBytesSent;
|
||||
if (clientSettings.getMaxBandwidthMibPerHour() != 0
|
||||
&& clientSettings.getMaxBandwidthMibPerHour() * 1024 * 1024 /* MiB to bytes */ < currentBytesSent) {
|
||||
if (clientSettings.getMaxMebibytesPerHour() != 0
|
||||
&& clientSettings.getMaxMebibytesPerHour() * 1024 * 1024 /* MiB to bytes */ < currentBytesSent) {
|
||||
if (LOGGER.isInfoEnabled()) {
|
||||
LOGGER.info("Shutting down server as hourly bandwidth limit reached");
|
||||
}
|
||||
|
|
|
@ -41,8 +41,8 @@ public class ServerHandler {
|
|||
HashMap<String, Object> params = new HashMap<>();
|
||||
params.put("secret", settings.getClientSecret());
|
||||
params.put("port", settings.getClientPort());
|
||||
params.put("disk_space", settings.getMaxCacheSizeMib() * 1024 * 1024 /* MiB to bytes */);
|
||||
params.put("network_speed", settings.getMaxBurstRateKibPerSecond() * 1024 /* KiB to bytes */);
|
||||
params.put("disk_space", settings.getMaxCacheSizeInMebibytes() * 1024 * 1024 /* MiB to bytes */);
|
||||
params.put("network_speed", settings.getMaxKilobitsPerSecond() * 1000 * 8 /* Kbps to bytes */);
|
||||
params.put("build_version", Constants.CLIENT_BUILD);
|
||||
|
||||
HttpResponse<ServerSettings> response = Unirest.post(SERVER_ADDRESS + "ping")
|
||||
|
@ -65,8 +65,8 @@ public class ServerHandler {
|
|||
HashMap<String, Object> params = new HashMap<>();
|
||||
params.put("secret", settings.getClientSecret());
|
||||
params.put("port", settings.getClientPort());
|
||||
params.put("disk_space", settings.getMaxCacheSizeMib() * 1024 * 1024 /* MiB to bytes */);
|
||||
params.put("network_speed", settings.getMaxBurstRateKibPerSecond() * 1024 /* KiB to bytes */);
|
||||
params.put("disk_space", settings.getMaxCacheSizeInMebibytes() * 1024 * 1024 /* MiB to bytes */);
|
||||
params.put("network_speed", settings.getMaxKilobitsPerSecond() * 1000 * 8 /* Kbps to bytes */);
|
||||
params.put("build_version", Constants.CLIENT_BUILD);
|
||||
params.put("tls_created_at", old.getTls().getCreatedAt());
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ class Netty(private val tls: ServerSettings.TlsCert, private val clientSettings:
|
|||
private lateinit var address: InetSocketAddress
|
||||
|
||||
private val burstLimiter = object : GlobalTrafficShapingHandler(
|
||||
workerGroup, 1024L * clientSettings.maxBurstRateKibPerSecond, 0, 50) {
|
||||
workerGroup, clientSettings.maxKilobitsPerSecond * 1000L, 0, 50) {
|
||||
override fun doAccounting(counter: TrafficCounter) {
|
||||
statistics.getAndUpdate {
|
||||
it.copy(bytesSent = it.bytesSent + counter.cumulativeWrittenBytes())
|
||||
|
|
|
@ -4,9 +4,9 @@ import com.google.gson.annotations.SerializedName
|
|||
import dev.afanasev.sekret.Secret
|
||||
|
||||
data class ClientSettings(
|
||||
@field:SerializedName("max_cache_size_mib") val maxCacheSizeMib: Long = 20480,
|
||||
@field:SerializedName("max_bandwidth_mib_per_hour") val maxBandwidthMibPerHour: Long = 0,
|
||||
@field:SerializedName("max_burst_rate_kib_per_second") val maxBurstRateKibPerSecond: Long = 0,
|
||||
@field:SerializedName("max_cache_size_in_mebibytes") val maxCacheSizeInMebibytes: Long = 20480,
|
||||
@field:SerializedName("max_mebibytes_per_hour") val maxMebibytesPerHour: Long = 0,
|
||||
@field:SerializedName("max_kilobits_per_second") val maxKilobitsPerSecond: Long = 0,
|
||||
@field:SerializedName("client_hostname") val clientHostname: String = "0.0.0.0",
|
||||
@field:SerializedName("client_port") val clientPort: Int = 443,
|
||||
@field:Secret @field:SerializedName("client_secret") val clientSecret: String = "PASTE-YOUR-SECRET-HERE",
|
||||
|
|
Loading…
Reference in a new issue