Complete HTML template separation

- Moved login page HTML to html_pages/login_page.h
- Moved users page HTML to html_pages/users_page.h
- Updated assets.c to use templates from header files
- Updated web.c to use login and users templates directly
- Updated configure.sh and regenerated Makefile with all new dependencies
parent dfbc6012
...@@ -33,7 +33,7 @@ tunnel.o: tunnel.c tunnel.h websocket.h ...@@ -33,7 +33,7 @@ tunnel.o: tunnel.c tunnel.h websocket.h
terminal.o: terminal.c terminal.h config.h terminal.o: terminal.c terminal.h config.h
websocket.o: websocket.c websocket.h websocket_protocol.h config.h websocket.o: websocket.c websocket.h websocket_protocol.h config.h
websocket_protocol.o: websocket_protocol.c websocket_protocol.h websocket_protocol.o: websocket_protocol.c websocket_protocol.h
web.o: web.c web.h terminal.h assets.h websocket.h html_pages/index_page.h html_pages/terminal_page.h web.o: web.c web.h terminal.h assets.h websocket.h html_pages/index_page.h html_pages/login_page.h html_pages/terminal_page.h html_pages/users_page.h
assets.o: assets.c assets.h assets.o: assets.c assets.h
ssl.o: ssl.c ssl.h ssl.o: ssl.c ssl.h
......
...@@ -19,172 +19,35 @@ ...@@ -19,172 +19,35 @@
#include <string.h> #include <string.h>
#include "assets.h" #include "assets.h"
#include "image_data.h"
#include "html_pages/login_page.h"
#include "html_pages/terminal_page.h"
#include "html_pages/users_page.h"
// Simplified HTML pages (without Jinja2 templating for embedded version) // HTML pages are now defined in separate header files in html_pages/ directory
const char *index_html = // This file now only contains fallback definitions for compatibility
"<!DOCTYPE html>" const char *index_html = NULL; // Generated dynamically
"<html lang=\"en\">" const char *login_html = NULL; // Now in html_pages/login_page.h
"<head>" const char *terminal_html = NULL; // Now in html_pages/terminal_page.h
" <meta charset=\"UTF-8\">" const char *users_html = NULL; // Now in html_pages/users_page.h
" <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">"
" <title>WebSocket SSH Daemon</title>"
" <link href=\"https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css\" rel=\"stylesheet\">"
" <link href=\"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css\" rel=\"stylesheet\">"
"</head>"
"<body>"
" <nav class=\"navbar navbar-expand-lg navbar-dark bg-primary\">"
" <div class=\"container\">"
" <a class=\"navbar-brand\" href=\"/\">"
" <i class=\"fas fa-terminal\"></i> WebSocket SSH Daemon"
" </a>"
" </div>"
" </nav>"
" <div class=\"container mt-4\">"
" <div class=\"card\">"
" <div class=\"card-header\">"
" <h3 class=\"card-title mb-0\">"
" <i class=\"fas fa-server\"></i> Connected Clients"
" </h3>"
" </div>"
" <div class=\"card-body\">"
" <div class=\"text-center py-5\">"
" <i class=\"fas fa-server fa-4x text-muted mb-3\"></i>"
" <h4 class=\"text-muted\">WebSocket SSH Daemon</h4>"
" <p class=\"text-muted\">Clients will appear here when they connect.</p>"
" </div>"
" </div>"
" </div>"
" </div>"
" <script src=\"https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js\"></script>"
"</body>"
"</html>";
const char *login_html = // Embedded image from image.jpg (declared in image_data.h)
"<!DOCTYPE html>"
"<html lang=\"en\">"
"<head>"
" <meta charset=\"UTF-8\">"
" <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">"
" <title>Login - WebSocket SSH Daemon</title>"
" <link href=\"https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css\" rel=\"stylesheet\">"
"</head>"
"<body>"
" <div class=\"container mt-5\">"
" <div class=\"row justify-content-center\">"
" <div class=\"col-md-6\">"
" <div class=\"card\">"
" <div class=\"card-header\">"
" <h3 class=\"card-title mb-0\"><i class=\"fas fa-sign-in-alt\"></i> Login</h3>"
" </div>"
" <div class=\"card-body\">"
" <form method=\"post\">"
" <div class=\"mb-3\">"
" <label for=\"username\" class=\"form-label\">Username</label>"
" <input type=\"text\" class=\"form-control\" id=\"username\" name=\"username\" required>"
" </div>"
" <div class=\"mb-3\">"
" <label for=\"password\" class=\"form-label\">Password</label>"
" <input type=\"password\" class=\"form-control\" id=\"password\" name=\"password\" required>"
" </div>"
" <button type=\"submit\" class=\"btn btn-primary\">"
" <i class=\"fas fa-sign-in-alt\"></i> Login"
" </button>"
" </form>"
" <div class=\"mt-3\">"
" <small class=\"text-muted\">"
" Default credentials: admin / admin123"
" </small>"
" </div>"
" </div>"
" </div>"
" </div>"
" </div>"
" </div>"
" <script src=\"https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js\"></script>"
"</body>"
"</html>";
const char *terminal_html =
"<!DOCTYPE html>"
"<html lang=\"en\">"
"<head>"
" <meta charset=\"UTF-8\">"
" <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">"
" <title>Terminal - WebSocket SSH Daemon</title>"
" <link href=\"https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css\" rel=\"stylesheet\">"
" <link rel=\"stylesheet\" href=\"https://unpkg.com/xterm@5.3.0/css/xterm.css\">"
"</head>"
"<body>"
" <div class=\"container mt-4\">"
" <div class=\"card\">"
" <div class=\"card-header\">"
" <h3 class=\"card-title mb-0\">"
" <i class=\"fas fa-terminal\"></i> SSH Terminal"
" </h3>"
" </div>"
" <div class=\"card-body\">"
" <div id=\"terminal\" class=\"terminal-container\"></div>"
" </div>"
" </div>"
" </div>"
" <script src=\"https://unpkg.com/xterm@5.3.0/lib/xterm.js\"></script>"
" <script src=\"https://unpkg.com/xterm-addon-fit@0.8.0/lib/xterm-addon-fit.js\"></script>"
" <script>"
" const terminal = new Terminal();"
" const fitAddon = new FitAddon.FitAddon();"
" terminal.loadAddon(fitAddon);"
" terminal.open(document.getElementById('terminal'));"
" fitAddon.fit();"
" terminal.write('WebSocket SSH Terminal\\r\\n');"
" terminal.write('Connecting...\\r\\n');"
" </script>"
"</body>"
"</html>";
const char *users_html =
"<!DOCTYPE html>"
"<html lang=\"en\">"
"<head>"
" <meta charset=\"UTF-8\">"
" <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">"
" <title>Users - WebSocket SSH Daemon</title>"
" <link href=\"https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css\" rel=\"stylesheet\">"
"</head>"
"<body>"
" <div class=\"container mt-4\">"
" <div class=\"card\">"
" <div class=\"card-header\">"
" <h3 class=\"card-title mb-0\">"
" <i class=\"fas fa-users\"></i> User Management"
" </h3>"
" </div>"
" <div class=\"card-body\">"
" <p>User management interface would be implemented here.</p>"
" </div>"
" </div>"
" </div>"
"</body>"
"</html>";
// Placeholder for embedded image (would be generated from actual image.jpg)
const unsigned char *image_jpg = NULL;
size_t image_jpg_len = 0;
const char *get_embedded_asset(const char *path, size_t *size) { const char *get_embedded_asset(const char *path, size_t *size) {
if (size) *size = 0; if (size) *size = 0;
// Note: index.html is generated dynamically in web.c
if (strcmp(path, "/") == 0 || strcmp(path, "/index.html") == 0) { if (strcmp(path, "/") == 0 || strcmp(path, "/index.html") == 0) {
if (size) *size = strlen(index_html); return NULL; // Handled dynamically
return index_html;
} else if (strcmp(path, "/login") == 0 || strcmp(path, "/login.html") == 0) { } else if (strcmp(path, "/login") == 0 || strcmp(path, "/login.html") == 0) {
if (size) *size = strlen(login_html); if (size) *size = strlen(login_page_html);
return login_html; return login_page_html;
} else if (strcmp(path, "/terminal.html") == 0) { } else if (strcmp(path, "/terminal.html") == 0) {
if (size) *size = strlen(terminal_html); if (size) *size = strlen(terminal_page_html);
return terminal_html; return terminal_page_html;
} else if (strcmp(path, "/users.html") == 0) { } else if (strcmp(path, "/users.html") == 0) {
if (size) *size = strlen(users_html); if (size) *size = strlen(users_page_html);
return users_html; return users_page_html;
} else if (strcmp(path, "/image.jpg") == 0) { } else if (strcmp(path, "/image.jpg") == 0) {
if (size) *size = image_jpg_len; if (size) *size = image_jpg_len;
return (const char *)image_jpg; return (const char *)image_jpg;
......
...@@ -88,7 +88,7 @@ tunnel.o: tunnel.c tunnel.h websocket.h ...@@ -88,7 +88,7 @@ tunnel.o: tunnel.c tunnel.h websocket.h
terminal.o: terminal.c terminal.h config.h terminal.o: terminal.c terminal.h config.h
websocket.o: websocket.c websocket.h websocket_protocol.h config.h websocket.o: websocket.c websocket.h websocket_protocol.h config.h
websocket_protocol.o: websocket_protocol.c websocket_protocol.h websocket_protocol.o: websocket_protocol.c websocket_protocol.h
web.o: web.c web.h terminal.h assets.h websocket.h html_pages/index_page.h html_pages/terminal_page.h web.o: web.c web.h terminal.h assets.h websocket.h html_pages/index_page.h html_pages/login_page.h html_pages/terminal_page.h html_pages/users_page.h
assets.o: assets.c assets.h assets.o: assets.c assets.h
ssl.o: ssl.c ssl.h ssl.o: ssl.c ssl.h
......
/**
* Login page HTML template for wssshd
*
* Copyright (C) 2024 Stefy Lanza <stefy@nexlab.net> and SexHack.me
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef LOGIN_PAGE_H
#define LOGIN_PAGE_H
// Login page HTML template
static const char *login_page_html =
"<!DOCTYPE html>"
"<html lang=\"en\">"
"<head>"
" <meta charset=\"UTF-8\">"
" <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">"
" <title>Login - WebSocket SSH Daemon</title>"
" <link href=\"https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css\" rel=\"stylesheet\">"
"</head>"
"<body>"
" <div class=\"container mt-5\">"
" <div class=\"row justify-content-center\">"
" <div class=\"col-md-6\">"
" <div class=\"card\">"
" <div class=\"card-header\">"
" <h3 class=\"card-title mb-0\"><i class=\"fas fa-sign-in-alt\"></i> Login</h3>"
" </div>"
" <div class=\"card-body\">"
" <form method=\"post\">"
" <div class=\"mb-3\">"
" <label for=\"username\" class=\"form-label\">Username</label>"
" <input type=\"text\" class=\"form-control\" id=\"username\" name=\"username\" required>"
" </div>"
" <div class=\"mb-3\">"
" <label for=\"password\" class=\"form-label\">Password</label>"
" <input type=\"password\" class=\"form-control\" id=\"password\" name=\"password\" required>"
" </div>"
" <button type=\"submit\" class=\"btn btn-primary\">"
" <i class=\"fas fa-sign-in-alt\"></i> Login"
" </button>"
" </form>"
" <div class=\"mt-3\">"
" <small class=\"text-muted\">"
" Default credentials: admin / admin123"
" </small>"
" </div>"
" </div>"
" </div>"
" </div>"
" </div>"
" </div>"
" <script src=\"https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js\"></script>"
"</body>"
"</html>";
#endif /* LOGIN_PAGE_H */
\ No newline at end of file
/**
* Users page HTML template for wssshd
*
* Copyright (C) 2024 Stefy Lanza <stefy@nexlab.net> and SexHack.me
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef USERS_PAGE_H
#define USERS_PAGE_H
// Users page HTML template
static const char *users_page_html =
"<!DOCTYPE html>"
"<html lang=\"en\">"
"<head>"
" <meta charset=\"UTF-8\">"
" <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">"
" <title>Users - WebSocket SSH Daemon</title>"
" <link href=\"https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css\" rel=\"stylesheet\">"
"</head>"
"<body>"
" <div class=\"container mt-4\">"
" <div class=\"card\">"
" <div class=\"card-header\">"
" <h3 class=\"card-title mb-0\">"
" <i class=\"fas fa-users\"></i> User Management"
" </h3>"
" </div>"
" <div class=\"card-body\">"
" <p>User management interface would be implemented here.</p>"
" </div>"
" </div>"
" </div>"
"</body>"
"</html>";
#endif /* USERS_PAGE_H */
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment