Skip to content

Commit e608f15

Browse files
committed
add params for rapid deploy
1 parent c44af3d commit e608f15

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

server/src/http.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ pub async fn init_client(req: Request<Body>) -> Result<Response<Body>> {
147147
server_url = format!("{}://{}/report", scheme, domain);
148148
}
149149

150+
let debug = params.get("debug").map(|p| p.eq("1")).unwrap_or(false);
150151
let vnstat = params.get("vnstat").map(|p| p.eq("1")).unwrap_or(false);
151152
let disable_ping = params.get("ping").map(|p| p.eq("0")).unwrap_or(false);
152153
let disable_tupd = params.get("tupd").map(|p| p.eq("0")).unwrap_or(false);
@@ -165,8 +166,19 @@ pub async fn init_client(req: Request<Body>) -> Result<Response<Body>> {
165166
let host_type = params.get("type").unwrap_or(&invalid);
166167
let location = params.get("loc").unwrap_or(&invalid);
167168

169+
// cm, ct, cu
170+
let cm = params.get("cm").unwrap_or(&invalid);
171+
let ct = params.get("ct").unwrap_or(&invalid);
172+
let cu = params.get("cu").unwrap_or(&invalid);
173+
174+
let iface = params.get("iface").unwrap_or(&invalid);
175+
let exclude_iface = params.get("exclude-iface").unwrap_or(&invalid);
176+
168177
// build client opts
169178
let mut client_opts = format!(r#"-a "{}" -p "{}""#, server_url, pass);
179+
if debug {
180+
client_opts.push_str(" -d");
181+
}
170182
if vnstat {
171183
client_opts.push_str(" -n");
172184
}
@@ -201,6 +213,22 @@ pub async fn init_client(req: Request<Body>) -> Result<Response<Body>> {
201213
if !location.is_empty() {
202214
let _ = write!(client_opts, r#" --location "{}""#, location);
203215
}
216+
if !cm.is_empty() && cm.contains(":") {
217+
let _ = write!(client_opts, r#" --cm "{}""#, cm);
218+
}
219+
if !ct.is_empty() && ct.contains(":") {
220+
let _ = write!(client_opts, r#" --ct "{}""#, ct);
221+
}
222+
if !cu.is_empty() && cu.contains(":") {
223+
let _ = write!(client_opts, r#" --cu "{}""#, cu);
224+
}
225+
226+
if !iface.is_empty() {
227+
let _ = write!(client_opts, r#" --iface "{}""#, iface);
228+
}
229+
if !exclude_iface.is_empty() {
230+
let _ = write!(client_opts, r#" --exclude-iface "{}""#, exclude_iface);
231+
}
204232

205233
Ok(jinja::render_template(
206234
KIND,

0 commit comments

Comments
 (0)