Skip to content

Commit

Permalink
Underflow fix (#35)
Browse files Browse the repository at this point in the history
* disable rate-limiting

* underflow fix
  • Loading branch information
neonphog authored Oct 22, 2024
1 parent 885c699 commit d0e8f57
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 19 deletions.
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ panic = "abort"

[workspace.dependencies]
# workspace member deps
sbd-bench = { version = "0.0.6-alpha", path = "rust/sbd-bench" }
sbd-client = { version = "0.0.6-alpha", path = "rust/sbd-client" }
sbd-e2e-crypto-client = { version = "0.0.6-alpha", path = "rust/sbd-e2e-crypto-client" }
sbd-o-bahn-client-tester = { version = "0.0.6-alpha", path = "rust/sbd-o-bahn-client-tester" }
sbd-o-bahn-server-tester = { version = "0.0.6-alpha", path = "rust/sbd-o-bahn-server-tester" }
sbd-server = { version = "0.0.6-alpha", path = "rust/sbd-server" }
sbd-bench = { version = "0.0.7-alpha", path = "rust/sbd-bench" }
sbd-client = { version = "0.0.7-alpha", path = "rust/sbd-client" }
sbd-e2e-crypto-client = { version = "0.0.7-alpha", path = "rust/sbd-e2e-crypto-client" }
sbd-o-bahn-client-tester = { version = "0.0.7-alpha", path = "rust/sbd-o-bahn-client-tester" }
sbd-o-bahn-server-tester = { version = "0.0.7-alpha", path = "rust/sbd-o-bahn-server-tester" }
sbd-server = { version = "0.0.7-alpha", path = "rust/sbd-server" }
# crate deps
anstyle = "1.0.6"
base64 = "0.22.0"
Expand Down
2 changes: 1 addition & 1 deletion rust/sbd-bench/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sbd-bench"
version = "0.0.6-alpha"
version = "0.0.7-alpha"
edition = "2021"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion rust/sbd-client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sbd-client"
version = "0.0.6-alpha"
version = "0.0.7-alpha"
description = "simple websocket-based message relay client"
license = "MIT OR Apache-2.0"
repository = "https://github.com/holochain/sbd"
Expand Down
6 changes: 5 additions & 1 deletion rust/sbd-client/src/send_buf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@ impl SendBuf {
self.limit_rate = limit;
let kbps = (8_000_000.0 / limit as f64) as u64;
let now = self.origin.elapsed().as_nanos() as u64;
let next_send_s = (now - self.next_send_at) as f64 / 1_000_000_000.0;
let next_send_s = if now > self.next_send_at {
(now - self.next_send_at) as f64 / 1_000_000_000.0
} else {
0.0
};
tracing::debug!(
target: "NETAUDIT",
full_url = self.full_url,
Expand Down
2 changes: 1 addition & 1 deletion rust/sbd-e2e-crypto-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ documentation = "https://docs.rs/sbd-e2e-crypto-client"
authors = ["Holochain Core Dev Team <devcore@holochain.org>"]
keywords = ["holochain", "holo", "p2p", "networking"]
categories = ["network-programming"]
version = "0.0.6-alpha"
version = "0.0.7-alpha"
edition = "2021"

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion rust/sbd-o-bahn-client-tester/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sbd-o-bahn-client-tester"
version = "0.0.6-alpha"
version = "0.0.7-alpha"
description = "simple websocket-based message relay client tester"
license = "MIT OR Apache-2.0"
repository = "https://github.com/holochain/sbd"
Expand Down
2 changes: 1 addition & 1 deletion rust/sbd-o-bahn-server-tester/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sbd-o-bahn-server-tester"
version = "0.0.6-alpha"
version = "0.0.7-alpha"
description = "simple websocket-based message relay server tester"
license = "MIT OR Apache-2.0"
repository = "https://github.com/holochain/sbd"
Expand Down
2 changes: 1 addition & 1 deletion rust/sbd-server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sbd-server"
version = "0.0.6-alpha"
version = "0.0.7-alpha"
description = "simple websocket-based message relay server"
license = "MIT OR Apache-2.0"
repository = "https://github.com/holochain/sbd"
Expand Down
8 changes: 8 additions & 0 deletions ts/sbd-server/src/signal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,13 @@ export class DoSignal extends DurableObject {
* closing the websocket if we violate the limit.
*/
async ipRateLimit(ip: string, pk: string, bytes: number, ws: WebSocket) {
// disabling rate limiting temporarily as an experiment
const HACK_NANOS_PER_BYTE = 1;
if (this.curLimit !== HACK_NANOS_PER_BYTE) {
this.curLimit = HACK_NANOS_PER_BYTE;
ws.send(new MsgLbrt(HACK_NANOS_PER_BYTE).encoded());
}
/*
try {
const ipId = this.env.RATE_LIMIT.idFromName(ip);
const ipStub = this.env.RATE_LIMIT.get(
Expand All @@ -179,6 +186,7 @@ export class DoSignal extends DurableObject {
} catch (e) {
throw common.err(`limit ${e}`, 429);
}
*/
}

/**
Expand Down

0 comments on commit d0e8f57

Please sign in to comment.