Skip to content

Commit

Permalink
Move site from pj to server root
Browse files Browse the repository at this point in the history
Moves nolooking website from `/pj` to `/`, while keeping
the payjoin POST `/pj` and other endpoints the same.
  • Loading branch information
nickfarrow committed Nov 8, 2022
1 parent f01b22e commit 83bcf39
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ async fn handle_web_req(
use std::path::Path;

match (req.method(), req.uri().path()) {
(&Method::GET, "/pj") => {
(&Method::GET, "/") => {
let index =
std::fs::read(Path::new(STATIC_DIR).join("index.html")).expect("can't open index");
Ok(Response::new(Body::from(index)))
}

(&Method::GET, path) if path.starts_with("/pj/static/") => {
let directory_traversal_vulnerable_path = &path[("/pj/static/".len())..];
(&Method::GET, path) if path.starts_with("/static/") => {
let directory_traversal_vulnerable_path = &path[("/static/".len())..];
let file =
std::fs::read(Path::new(STATIC_DIR).join(directory_traversal_vulnerable_path))
.expect("can't open static file");
Expand Down Expand Up @@ -88,7 +88,7 @@ async fn handle_web_req(
Ok(Response::new(Body::from(proposal_psbt)))
}

(&Method::POST, "/pj/schedule") => {
(&Method::POST, "/schedule") => {
let bytes = hyper::body::to_bytes(req.into_body()).await?;
// deserialize x-www-form-urlencoded data with non-strict encoded "channel[arrayindex]"
let conf = serde_qs::Config::new(2, false);
Expand Down
8 changes: 4 additions & 4 deletions static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<link rel="stylesheet" href="https://rsms.me/inter/inter.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/selekkt-skelet@latest/css/skelet.min.css">
<!-- having trouble getting the right path on both umbrel and local.. -->
<link rel="stylesheet" href="/pj/static/style.css">
<link rel="stylesheet" href="/static/style.css">
<link rel="stylesheet" href="style.css">
<title>nolooking // Lightning PayJoin</title>
</head>
Expand All @@ -18,7 +18,7 @@ <h3 style="color: orange;">🎃 Halloween Alpha [experimental] | Avoid sp👀ks<
<h2>Queue batches of lightning channels to open in a single transaction</h2>
</header>
<main class="center-axyz">
<form action="/pj/schedule" method="post" enctype="application/x-www-form-urlencoded"
<form action="/schedule" method="post" enctype="application/x-www-form-urlencoded"
x-flex direction="column">
<fieldset>
<legend>Config</legend>
Expand All @@ -38,7 +38,7 @@ <h2>Queue batches of lightning channels to open in a single transaction</h2>
</div>
<div>
<label for="fee_rate">Maximum fee rate (sats/vB)</label>
<input type="number" name="fee_rate" id="feerate" value="1" min="1"><!-- /pj/schedule api accepts u64 -->
<input type="number" name="fee_rate" id="feerate" value="1" min="1"><!-- /schedule api accepts u64 -->
</div>
</fieldset>
<fieldset>
Expand Down Expand Up @@ -115,7 +115,7 @@ <h2>PayJoin here to open these channels</h2>
link.innerHTML = bip21;

var address = bip21.split("bitcoin:")[1].split("?")[0];
document.getElementById("qrcode").innerHTML = `<img src="pj/static/qr_codes/${address}.png" width="256px" />`;
document.getElementById("qrcode").innerHTML = `<img src="/static/qr_codes/${address}.png" width="256px" />`;
document.getElementById("queue").classList.add("invisible");
document.getElementById("queued").classList.remove("invisible");
})
Expand Down

0 comments on commit 83bcf39

Please sign in to comment.