Skip to content

Commit 2385876

Browse files
committed
chore: add more error info
1 parent 2a96237 commit 2385876

File tree

4 files changed

+52
-7
lines changed

4 files changed

+52
-7
lines changed

Cargo.lock

Lines changed: 39 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tuic-server/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ humantime-serde = "1"
5656
# Logging
5757
time = { version = "0.3", features = ["macros", "local-offset"] }
5858
humantime = { version = "2", default-features = false }
59-
tracing-subscriber = { version = "0.3", default-features = false, features = ["tracing-log", "std", "local-time","fmt"] }
59+
tracing-subscriber = { version = "0.3", default-features = false, features = ["tracing-log", "std", "local-time","fmt", "ansi"] }
6060
chrono = "0.4"
6161
tracing = "0.1"
6262

tuic-server/src/connection/handle_stream.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ impl Connection {
6868
addr = self.inner.remote_address(),
6969
user = self.auth,
7070
);
71-
self.close();
71+
self.close(&format!(
72+
"A serious error occurred at unidirectional stream pre-process stage {err}"
73+
));
7274
}
7375
}
7476
}
@@ -118,7 +120,9 @@ impl Connection {
118120
addr = self.inner.remote_address(),
119121
user = self.auth,
120122
);
121-
self.close();
123+
self.close(&format!(
124+
"A serious error occurred at bidirectional stream pre-process stage {err}"
125+
));
122126
}
123127
}
124128
}
@@ -159,7 +163,9 @@ impl Connection {
159163
addr = self.inner.remote_address(),
160164
user = self.auth,
161165
);
162-
self.close();
166+
self.close(&format!(
167+
"A serious error occurred at datagram pre-process stage {err}"
168+
));
163169
}
164170
}
165171
}

tuic-server/src/connection/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ impl Connection {
158158
id = self.id(),
159159
addr = self.inner.remote_address(),
160160
);
161-
self.close();
161+
self.close("Authentication error");
162162
}
163163
}
164164
}
@@ -192,7 +192,7 @@ impl Connection {
192192
self.inner.close_reason().is_some()
193193
}
194194

195-
fn close(&self) {
196-
self.inner.close(ERROR_CODE, &[]);
195+
fn close(&self, reason: &str) {
196+
self.inner.close(ERROR_CODE, reason.as_bytes());
197197
}
198198
}

0 commit comments

Comments
 (0)