Skip to content

Commit 6b58a4e

Browse files
committed
server-ssl.js
update default pages https://i.imgur.com/AZlWH5n.png /root │ ├── /error │ ├── 404.html │ └── 500.html │ ├── /ssl │ ├── /openssl │ ├── /module │ │ ├── /crypt │ │ ├── /jose │ │ └── lets-encrypt-acme-client.js │ │ │ ├── acmeKeys │ ├── private-key.pem │ └── certificate.pem │ └── ssl.js │ ├── /website │ └── index.html <---- Your website goes here │ ├── node.exe ├── server-ssl.js <--- server config └── start-windows.bat
1 parent f8dff1f commit 6b58a4e

6 files changed

Lines changed: 93 additions & 47 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ It can be as simple as this:
3636

3737
[![](https://i.imgur.com/NxJQeLm.gif)](https://github.com/FirstTimeEZ/server-ssl/archive/refs/heads/main.zip)
3838

39-
[![](https://i.imgur.com/8ETLFzk.png)](https://github.com/FirstTimeEZ/server-ssl/archive/refs/heads/main.zip)
39+
[![](https://i.imgur.com/AZlWH5n.png)](https://github.com/FirstTimeEZ/server-ssl/archive/refs/heads/main.zip)
4040

4141
### Optional Arguments
4242

server-ssl.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const HTTPS_SERVER = createServerHTTPS(S_SSL.loadDefaultSecureContext(), (req, r
2727
route = join(__websiteDir, "md", S_SSL.optEntry);
2828
}
2929

30-
route == undefined && (route = req.url); // no route, follow the url
30+
route == undefined && (route = join(__websiteDir, req.url)); // no route, follow the url
3131

3232
S_SSL.defaultFileHandling(res, route, CONTENT_TYPES);
3333
}).on('error', (e) => e.code === S_SSL.ADDR_IN_USE && console.error(`${S_SSL.optPort}${S_SSL.IN_USE}`)).listen(S_SSL.optPort, (err) => err ? console.error(S_SSL.ERROR_STARTING, err) : console.log(`${S_SSL.STARTED_HTTPS}${S_SSL.optPort}`));

ssl/ssl.js

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -198,40 +198,44 @@ export const S_SSL = {
198198
},
199199
checkNodeForUpdates: async () => {
200200
if (S_SSL.optNoAutoUpdate !== true) {
201-
const current = (await fetch(S_SSL.NODE_URL, { method: 'GET', redirect: 'follow' })).url
201+
try {
202+
const current = (await fetch(S_SSL.NODE_URL, { method: 'GET', redirect: 'follow' })).url
202203

203-
if (current != undefined) {
204-
const split = current.split("/");
204+
if (current != undefined) {
205+
const split = current.split("/");
205206

206-
if (split.length === S_SSL.NODE_URL_SPLITS) {
207-
for (let index = 0; index < split.length; index++) {
208-
const dist = split[index];
207+
if (split.length === S_SSL.NODE_URL_SPLITS) {
208+
for (let index = 0; index < split.length; index++) {
209+
const dist = split[index];
209210

210-
if (dist[0] === S_SSL.NODE_VERSION) {
211-
const updatePath = join(S_SSL.__sslFolder, S_SSL.NODE_FN);
211+
if (dist[0] === S_SSL.NODE_VERSION) {
212+
const updatePath = join(S_SSL.__sslFolder, S_SSL.NODE_FN);
212213

213-
if (existsSync(updatePath)) {
214-
const lastUpdate = JSON.parse(readFileSync(updatePath));
214+
if (existsSync(updatePath)) {
215+
const lastUpdate = JSON.parse(readFileSync(updatePath));
215216

216-
if (lastUpdate != undefined) {
217-
const lastVersion = lastUpdate.version;
217+
if (lastUpdate != undefined) {
218+
const lastVersion = lastUpdate.version;
218219

219-
if (lastVersion === dist) {
220-
console.log(S_SSL.NODE_YES, dist);
220+
if (lastVersion === dist) {
221+
console.log(S_SSL.NODE_YES, dist);
222+
}
223+
else {
224+
console.log(S_SSL.NODE_NO, dist);
225+
// Update Required
226+
}
221227
}
222-
else {
223-
console.log(S_SSL.NODE_NO, dist);
224-
// Update Required
225-
}
226-
}
227-
} else {
228-
console.log(S_SSL.NODE_FIRST, dist);
228+
} else {
229+
console.log(S_SSL.NODE_FIRST, dist);
229230

230-
writeFile(updatePath, JSON.stringify({ version: dist }), () => { });
231+
writeFile(updatePath, JSON.stringify({ version: dist }), () => { });
232+
}
231233
}
232234
}
233235
}
234236
}
237+
} catch {
238+
console.log("Could not determine if Node.js version is recent");
235239
}
236240
}
237241
},
@@ -256,6 +260,14 @@ export const S_SSL = {
256260
let contentType = contentTypes[fileExtension];
257261
!contentType && (contentType = S_SSL.TEXT_HTML);
258262

259-
readFile(route, (err, content) => !err ? (res.writeHead(S_SSL.SUCCESS, { [S_SSL.CONTENT_TYPE]: contentType }), res.end(content)) : S_SSL.getErrorPage(res, err));
263+
readFile(route, (err, content) => {
264+
if (!err) {
265+
res.writeHead(S_SSL.SUCCESS, { [S_SSL.CONTENT_TYPE]: contentType });
266+
res.end(content);
267+
}
268+
else {
269+
S_SSL.getErrorPage(res, err);
270+
}
271+
});
260272
}
261273
}

website/bg.png

61.6 KB
Loading

website/index.html

Lines changed: 55 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
<head>
44
<meta charset="UTF-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<link rel="icon" type="image/png" href="bg.png">
67
<title>Server Started</title>
78
<style>
89
body {
9-
font-family: -apple-system, sans-serif;
10+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
1011
background-color: #f4f4f4;
1112
display: flex;
1213
justify-content: center;
@@ -16,40 +17,73 @@
1617
text-align: center;
1718
}
1819
.container {
19-
background-color: white;
20-
padding: 20px;
21-
border-radius: 8px;
22-
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
23-
max-width: 300px;
20+
background-image: url("bg.png");
21+
background-size: cover;
22+
background-position: center;
23+
background-repeat: no-repeat;
24+
display: flex;
25+
flex-direction: column;
26+
align-items: center;
27+
justify-content: center;
28+
padding: 30px;
29+
border-radius: 16px;
30+
box-shadow: 0 10px 30px rgba(0,0,0,0.1);
31+
max-width: 350px;
2432
width: 100%;
33+
backdrop-filter: blur(10px);
34+
background-color: rgba(255,255,255,0.3);
35+
border: 1px solid rgba(255,255,255,0.2);
2536
}
2637
.status-icon {
2738
font-size: 72px;
2839
font-weight: bold;
29-
color: #10b981;
30-
margin-bottom: 10px;
40+
color: white;
41+
margin-bottom: 5px;
42+
text-shadow: 0 2px 4px rgba(0,0,0,0.2);
3143
}
3244
.status-message {
33-
font-size: 16px;
34-
color: #667085;
35-
margin-bottom: 15px;
45+
font-size: 18px;
46+
color: white;
47+
margin-bottom: 20px;
48+
font-weight: 800;
49+
text-shadow: 1px 1px 3px rgba(0, 0, 0, 1);
3650
}
3751
.server-details {
3852
font-size: 14px;
39-
color: #6b7280;
40-
margin-top: 10px;
53+
color: white;
54+
margin-top: 5px;
55+
font-weight: 800;
56+
text-shadow: 1px 1px 3px rgba(0, 0, 0, 1);
4157
}
42-
.action-link {
43-
display: inline-block;
44-
background-color: #3b82f6;
58+
.a {
59+
background-color: rgba(0, 0, 0, 0.418);
60+
border: 1px solid rgba(0,0,0,0.2);
61+
border-radius: 4px;
62+
padding: 2px 5px;
63+
font-weight: 800;
4564
color: white;
4665
text-decoration: none;
47-
padding: 8px 16px;
66+
text-shadow: 1px 1px 3px rgba(0, 0, 0, 1);
67+
transition: all 0.3s ease;
68+
}
69+
.a:hover {
70+
background-color: rgba(0, 0, 0, 0.618);
71+
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
72+
}
73+
.b {
74+
background-color: rgba(0,0,0,0.1);
75+
border: 1px solid rgba(0,0,0,0.2);
4876
border-radius: 4px;
49-
transition: background-color 0.2s;
77+
padding: 2px 5px;
78+
font-family: 'Courier New', Courier, monospace;
79+
color: white;
80+
text-decoration: none;
81+
transition: all 0.3s ease;
5082
}
51-
.action-link:hover {
52-
background-color: #2563eb;
83+
@supports not (backdrop-filter: blur(10px)) {
84+
.container {
85+
background-color: rgba(255,255,255,0.8);
86+
}
5387
}
5488
</style>
5589
</head>
@@ -58,7 +92,7 @@
5892
<div class="status-icon"></div>
5993
<div class="status-message">Server Started Successfully</div>
6094
<div class="server-details">
61-
Default page for server running <a href="https://github.com/FirstTimeEZ/server-ssl">server-ssl</a>
95+
Default page for server running <a href="https://github.com/FirstTimeEZ/server-ssl" class="a">server-ssl</a>
6296
</div>
6397
</div>
6498
</body>

website/md/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<head>
66
<title></title>
7-
<link rel="icon" type="image/png" href="boat.png">
7+
<link rel="icon" type="image/png" href="bg.png">
88
<style>
99
body {
1010
margin: 0;

0 commit comments

Comments
 (0)