11/*
22MIT License
33
4- Copyright (c) 2025 Andrea Fontana
4+ Copyright (c) 2025-2026 Andrea Fontana
55
66Permission is hereby granted, free of charge, to any person obtaining a copy
77of 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