2022-01-13 11:15:42 +00:00
|
|
|
use rocket::{catchers, fs::FileServer, routes, Build, Rocket};
|
|
|
|
use rocket_dyn_templates::Template;
|
|
|
|
|
2022-02-23 09:54:08 +00:00
|
|
|
use crate::{
|
|
|
|
routes::{
|
|
|
|
authentication::*,
|
|
|
|
catchers::*,
|
|
|
|
index::*,
|
|
|
|
scuttlebutt::*,
|
|
|
|
settings::{admin::*, dns::*, menu::*, network::*, scuttlebutt::*, theme::*},
|
|
|
|
status::{device::*, network::*, scuttlebutt::*},
|
|
|
|
},
|
|
|
|
utils,
|
2022-01-13 11:15:42 +00:00
|
|
|
};
|
|
|
|
|
2022-01-18 10:50:06 +00:00
|
|
|
/// Create a Rocket instance and mount PeachPub routes, fileserver and
|
|
|
|
/// catchers. This gives us everything we need to run PeachPub and excludes
|
|
|
|
/// settings and status routes related to networking and the device (memory,
|
2022-01-13 11:15:42 +00:00
|
|
|
/// hard disk, CPU etc.).
|
2022-01-18 15:00:53 +00:00
|
|
|
pub fn mount_peachpub_routes(rocket: Rocket<Build>) -> Rocket<Build> {
|
2022-02-23 09:54:08 +00:00
|
|
|
// set the `.ssb-go` path in order to mount the blob fileserver
|
|
|
|
let ssb_path = utils::get_go_ssb_path().expect("define ssb-go dir path");
|
|
|
|
let blobstore = format!("{}/blobs/sha256", ssb_path);
|
|
|
|
|
2022-01-18 15:00:53 +00:00
|
|
|
rocket
|
2022-01-13 11:15:42 +00:00
|
|
|
.mount(
|
|
|
|
"/",
|
|
|
|
routes![
|
|
|
|
help,
|
|
|
|
home,
|
|
|
|
login,
|
|
|
|
login_post,
|
|
|
|
logout,
|
|
|
|
settings_menu,
|
2022-02-03 14:29:20 +00:00
|
|
|
set_theme,
|
2022-01-13 11:15:42 +00:00
|
|
|
],
|
|
|
|
)
|
|
|
|
.mount(
|
|
|
|
"/settings/admin",
|
|
|
|
routes![
|
|
|
|
admin_menu,
|
|
|
|
configure_admin,
|
|
|
|
add_admin_post,
|
|
|
|
delete_admin_post,
|
|
|
|
change_password,
|
|
|
|
change_password_post,
|
|
|
|
reset_password,
|
|
|
|
reset_password_post,
|
|
|
|
forgot_password_page,
|
|
|
|
send_password_reset_post,
|
|
|
|
],
|
|
|
|
)
|
2022-01-17 13:20:08 +00:00
|
|
|
.mount(
|
|
|
|
"/settings/scuttlebutt",
|
2022-01-27 08:56:39 +00:00
|
|
|
routes![
|
|
|
|
ssb_settings_menu,
|
|
|
|
configure_sbot,
|
2022-02-02 12:14:12 +00:00
|
|
|
configure_sbot_default,
|
|
|
|
configure_sbot_post,
|
2022-01-27 08:56:39 +00:00
|
|
|
restart_sbot,
|
|
|
|
start_sbot,
|
|
|
|
stop_sbot
|
|
|
|
],
|
2022-01-17 13:20:08 +00:00
|
|
|
)
|
2022-01-13 11:15:42 +00:00
|
|
|
.mount(
|
|
|
|
"/scuttlebutt",
|
|
|
|
routes![
|
2022-02-23 08:21:58 +00:00
|
|
|
invites,
|
|
|
|
create_invite,
|
2022-02-11 08:32:39 +00:00
|
|
|
peers,
|
2022-03-01 08:53:45 +00:00
|
|
|
search,
|
|
|
|
search_post,
|
2022-02-11 08:32:39 +00:00
|
|
|
friends,
|
|
|
|
follows,
|
|
|
|
blocks,
|
|
|
|
profile,
|
|
|
|
update_profile,
|
|
|
|
update_profile_post,
|
|
|
|
private,
|
2022-03-02 09:57:10 +00:00
|
|
|
private_post,
|
2022-02-11 08:32:39 +00:00
|
|
|
follow,
|
|
|
|
unfollow,
|
|
|
|
block,
|
2022-03-02 06:58:54 +00:00
|
|
|
unblock,
|
2022-02-11 08:32:39 +00:00
|
|
|
publish,
|
2022-01-13 11:15:42 +00:00
|
|
|
],
|
|
|
|
)
|
2022-01-18 10:50:06 +00:00
|
|
|
.mount("/status", routes![scuttlebutt_status])
|
2022-01-13 11:15:42 +00:00
|
|
|
.mount("/", FileServer::from("static"))
|
2022-02-23 09:54:08 +00:00
|
|
|
.mount("/blob", FileServer::from(blobstore).rank(-1))
|
2022-01-13 11:15:42 +00:00
|
|
|
.register("/", catchers![not_found, internal_error, forbidden])
|
|
|
|
.attach(Template::fairing())
|
|
|
|
}
|
|
|
|
|
2022-01-18 10:50:06 +00:00
|
|
|
/// Create a Rocket instance with PeachPub routes, fileserver and catchers by
|
|
|
|
/// calling `mount_peachpub_routes()` and then mount all additional routes
|
|
|
|
/// required to run a complete PeachCloud build.
|
2022-01-18 15:00:53 +00:00
|
|
|
pub fn mount_peachcloud_routes(rocket: Rocket<Build>) -> Rocket<Build> {
|
|
|
|
mount_peachpub_routes(rocket)
|
2022-03-04 08:53:49 +00:00
|
|
|
.mount("/", routes![reboot_cmd, shutdown_cmd, power_menu,])
|
2022-01-13 11:15:42 +00:00
|
|
|
.mount(
|
|
|
|
"/settings/network",
|
|
|
|
routes![
|
|
|
|
add_credentials,
|
|
|
|
connect_wifi,
|
|
|
|
configure_dns,
|
|
|
|
configure_dns_post,
|
|
|
|
disconnect_wifi,
|
|
|
|
deploy_ap,
|
|
|
|
deploy_client,
|
|
|
|
forget_wifi,
|
|
|
|
network_home,
|
|
|
|
add_ssid,
|
|
|
|
add_wifi,
|
|
|
|
network_detail,
|
|
|
|
wifi_list,
|
|
|
|
wifi_password,
|
|
|
|
wifi_set_password,
|
|
|
|
wifi_usage,
|
|
|
|
wifi_usage_alerts,
|
|
|
|
wifi_usage_reset,
|
|
|
|
],
|
|
|
|
)
|
|
|
|
.mount("/status", routes![device_status, network_status])
|
|
|
|
}
|