Skip to content

Commit 1b3bd58

Browse files
committed
Updates
1 parent 770162c commit 1b3bd58

3 files changed

Lines changed: 45 additions & 28 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ websitino-test-*
1414
*.o
1515
*.obj
1616
*.lst
17+
dub.selections.json

dub.json

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,40 @@
22
"authors": [
33
"Andrea Fontana"
44
],
5-
6-
"description": "File serving, simplified.",
5+
"license": "MIT",
76
"copyright": "Copyright © 2025-, Andrea Fontana",
8-
7+
"name": "websitino",
8+
"description": "File serving, simplified.",
99
"dependencies": {
10-
"serverino": "~master"
10+
"serverino": "~>0.7.21"
1111
},
12-
1312
"configurations": [
14-
1513
{
16-
"name": "default",
17-
"targetType": "executable"
14+
"targetType": "executable",
15+
"name": "default"
1816
},
19-
2017
{
21-
"name": "linux-static",
2218
"targetType": "executable",
23-
"dflags": ["-static", "-nodefaultlib"]
19+
"dflags": [
20+
"-static",
21+
"-nodefaultlib"
22+
],
23+
"name": "linux-static"
2424
},
25-
2625
{
27-
"name": "windows-static",
2826
"targetType": "executable",
29-
"dflags": ["-link-defaultlib-shared=false", "-static"]
27+
"dflags": [
28+
"-link-defaultlib-shared=false",
29+
"-static"
30+
],
31+
"name": "windows-static"
3032
},
31-
3233
{
33-
"name": "macos-static",
3434
"targetType": "executable",
35-
"dflags": ["-link-defaultlib-shared=false"]
35+
"dflags": [
36+
"-link-defaultlib-shared=false"
37+
],
38+
"name": "macos-static"
3639
}
37-
38-
],
39-
40-
"license": "MIT",
41-
"name": "websitino"
40+
]
4241
}

source/app.d

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
MIT License
33
4-
Copyright (c) 2025 Andrea Fontana
4+
Copyright (c) 2025-2026 Andrea Fontana
55
66
Permission is hereby granted, free of charge, to any person obtaining a copy
77
of this software and associated documentation files (the "Software"), to deal
@@ -110,8 +110,8 @@ auto staticServe(Request request, Output output)
110110
<meta charset="utf-8">
111111
<title>%TITLE%</title>
112112
<meta name="viewport" content="width=device-width, initial-scale=1.0">
113-
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
114-
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/5.2.0/github-markdown.min.css">
113+
<script src="https://cdn.jsdelivr.net/npm/marked@18.0.0/lib/marked.umd.min.js"></script>
114+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/5.9.0/github-markdown.min.css">
115115
<style>
116116
body { font-family: sans-serif; max-width: 800px; margin: 2em auto; line-height: 1.5; padding: 0 15px; }
117117
pre { background-color: #f5f5f5; padding: 1em; border-radius: 5px; overflow-x: auto; }
@@ -316,14 +316,16 @@ void logger(Request request, Output output)
316316
@onServerInit ServerinoConfig configure(string[] args)
317317
{
318318
ushort port = 8123;
319-
string ip = "0.0.0.0";
319+
string ip = string.init;
320320
string authString;
321321

322322
bool showHelp;
323+
bool ipv6;
323324

324325
// Parse the command line arguments using std.getopt looking for the --port option.
325326
try {
326327
showHelp = getopt(args,
328+
"6|ipv6", &ipv6,
327329
"a|auth", &authString,
328330
"b|bind", &ip,
329331
"p|port", &port,
@@ -361,6 +363,7 @@ websitino \x1b[2m[path] [options...]\x1b[0m
361363
\x1b[1m --auth -a\x1b[0m <user:pass> Set the authentication string. (default: disabled)
362364
\x1b[1m --port -p\x1b[0m <port> Set the port to listen on. (default: 8123)
363365
\x1b[1m --bind -b\x1b[0m <ip_address> Set the ip address to listen on. (default: 0.0.0.0)
366+
\x1b[1m --ipv6 -6\x1b[0m Force IPv6 (default: IPv4).
364367
\x1b[1m --verbose -v\x1b[0m Enable request logging (default: disabled).
365368
\x1b[1m --help -h\x1b[0m Show this help.
366369
@@ -389,6 +392,14 @@ websitino \x1b[2m[path] [options...]\x1b[0m
389392
return ServerinoConfig.create().setReturnCode(1);
390393
}
391394

395+
if (ip.count(':') > 1) ipv6 = true;
396+
397+
if (ip.empty)
398+
{
399+
if (ipv6) ip = "::";
400+
else ip = "0.0.0.0";
401+
}
402+
392403
singleFile = isFile(pathToServe);
393404

394405
environment["WEBSITINO_SINGLE_FILE"] = singleFile.to!string;
@@ -401,14 +412,20 @@ websitino \x1b[2m[path] [options...]\x1b[0m
401412

402413

403414
// Return the configuration for the serverino with the port set by the user.
404-
return ServerinoConfig.create()
405-
.addListener(ip, port)
415+
auto config = ServerinoConfig.create()
406416
.setLogLevel(LogLevel.info)
407417
.setMaxRequestTime(100.msecs)
408418
.setMaxRequestSize(1024)
409419
.setMaxDynamicWorkerIdling(15.seconds)
410420
.setMinWorkers(0)
411421
.setMaxWorkers(5);
422+
423+
424+
if (ipv6) config.addListener!(ServerinoConfig.ListenerProtocol.IPV6)(ip, port);
425+
else config.addListener!(ServerinoConfig.ListenerProtocol.IPV4)(ip, port);
426+
427+
return config;
428+
412429
}
413430

414431

0 commit comments

Comments
 (0)