Rename speedKbps and dataCapMB parameters to bytesPerSecond and quotaBytes, respectively, in API and traffic control logic

This commit is contained in:
ImBenji
2025-08-05 13:46:13 +01:00
parent daf67bf516
commit 2d692e0bc0
4 changed files with 123 additions and 31 deletions

View File

@@ -116,7 +116,7 @@ class PeerRoutes {
final body = await request.readAsString();
final data = jsonDecode(body) as Map<String, dynamic>;
final publicKey = data['publicKey'] as String?;
final speedKbps = data['speedKbps'] as int?;
final bytesPerSecond = data['bytesPerSecond'] as int?;
if (publicKey == null) {
return Response.badRequest(
@@ -128,17 +128,17 @@ class PeerRoutes {
);
}
if (speedKbps == null) {
if (bytesPerSecond == null) {
return Response.badRequest(
body: jsonEncode({
'success': false,
'error': 'speedKbps parameter is required',
'error': 'bytesPerSecond parameter is required',
}),
headers: {'Content-Type': 'application/json'},
);
}
await setSpeedLimit(publicKey, speedKbps);
await setSpeedLimit(publicKey, bytesPerSecond);
return Response.ok(
jsonEncode({
@@ -163,7 +163,7 @@ class PeerRoutes {
final body = await request.readAsString();
final data = jsonDecode(body) as Map<String, dynamic>;
final publicKey = data['publicKey'] as String?;
final dataCapMB = data['dataCapMB'] as int?;
final quotaBytes = data['quotaBytes'] as int?;
if (publicKey == null) {
return Response.badRequest(
@@ -175,17 +175,17 @@ class PeerRoutes {
);
}
if (dataCapMB == null) {
if (quotaBytes == null) {
return Response.badRequest(
body: jsonEncode({
'success': false,
'error': 'dataCapMB parameter is required',
'error': 'quotaBytes parameter is required',
}),
headers: {'Content-Type': 'application/json'},
);
}
await setDataCap(publicKey, dataCapMB);
await setDataCap(publicKey, quotaBytes);
return Response.ok(
jsonEncode({