🐛 Allowing spaces in server names
parent
f81d819c31
commit
49cd292115
|
@ -108,7 +108,7 @@ struct Config {
|
||||||
|
|
||||||
impl From <&ConfigFile> for Config {
|
impl From <&ConfigFile> for Config {
|
||||||
fn from (f: &ConfigFile) -> Self {
|
fn from (f: &ConfigFile) -> Self {
|
||||||
let trips = HashMap::from_iter (f.server_tripcodes.iter ()
|
let server_tripcodes = HashMap::from_iter (f.server_tripcodes.iter ()
|
||||||
.map (|(k, v)| {
|
.map (|(k, v)| {
|
||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
let bytes: Vec <u8> = base64::decode (v).unwrap ();
|
let bytes: Vec <u8> = base64::decode (v).unwrap ();
|
||||||
|
@ -116,11 +116,15 @@ impl From <&ConfigFile> for Config {
|
||||||
|
|
||||||
let v = blake3::Hash::from (bytes);
|
let v = blake3::Hash::from (bytes);
|
||||||
|
|
||||||
(k.clone (), v)
|
let k = percent_encoding::percent_encode (k.as_bytes (), percent_encoding::NON_ALPHANUMERIC).to_string ();
|
||||||
|
|
||||||
|
debug! ("Tripcode {} => {}", k, v.to_hex ());
|
||||||
|
|
||||||
|
(k, v)
|
||||||
}));
|
}));
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
server_tripcodes: trips,
|
server_tripcodes,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -485,10 +489,12 @@ async fn handle_all (req: Request <Body>, state: Arc <RelayState>)
|
||||||
}
|
}
|
||||||
else if let Some (rest) = prefix_match ("/frontend/servers/", path) {
|
else if let Some (rest) = prefix_match ("/frontend/servers/", path) {
|
||||||
if rest == "" {
|
if rest == "" {
|
||||||
|
use std::borrow::Cow;
|
||||||
|
|
||||||
#[derive (Serialize)]
|
#[derive (Serialize)]
|
||||||
struct ServerEntry <'a> {
|
struct ServerEntry <'a> {
|
||||||
path: &'a str,
|
path: &'a str,
|
||||||
name: &'a str,
|
name: Cow <'a, str>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive (Serialize)]
|
#[derive (Serialize)]
|
||||||
|
@ -503,7 +509,7 @@ async fn handle_all (req: Request <Body>, state: Arc <RelayState>)
|
||||||
let page = ServerListPage {
|
let page = ServerListPage {
|
||||||
servers: names.iter ()
|
servers: names.iter ()
|
||||||
.map (|name| ServerEntry {
|
.map (|name| ServerEntry {
|
||||||
name: &name,
|
name: percent_encoding::percent_decode_str (name).decode_utf8 ().unwrap_or_else (|_| "Server name isn't UTF-8".into ()),
|
||||||
path: &name,
|
path: &name,
|
||||||
})
|
})
|
||||||
.collect (),
|
.collect (),
|
||||||
|
|
1
todo.md
1
todo.md
|
@ -2,7 +2,6 @@
|
||||||
- Reduce idle memory use?
|
- Reduce idle memory use?
|
||||||
|
|
||||||
- Impl multi-range / multi-part byte serving
|
- Impl multi-range / multi-part byte serving
|
||||||
- Allow spaces in server names
|
|
||||||
- Deny unused HTTP methods for endpoints
|
- Deny unused HTTP methods for endpoints
|
||||||
- ETag cache based on mtime
|
- ETag cache based on mtime
|
||||||
- Server-side hash?
|
- Server-side hash?
|
||||||
|
|
Loading…
Reference in New Issue