-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 6d368e9
Showing
26 changed files
with
3,354 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
FileVersion = 1 | ||
|
||
[Project] | ||
Name = "darkredhttpd" | ||
StartupObject = "darkredhttpd.Program" | ||
|
||
[Configs.Debug.Win64] | ||
DebugCommandArguments = "D:\\YouTube\\Fortissimo --timeout 0" | ||
|
||
[Configs.Release.Win64] | ||
DebugCommandArguments = "D:\\YouTube\\Fortissimo --timeout 0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
FileVersion = 1 | ||
Projects = {darkredhttpd = {Path = "."}} | ||
|
||
[Workspace] | ||
StartupProject = "darkredhttpd" | ||
|
||
[Configs.Debug.Win64] | ||
AllocStackTraceDepth = 15 | ||
|
||
[Configs.Release.Win64] | ||
Toolset = "LLVM" | ||
LTOType = "Thin" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Copyright (c) 2021 disarray | ||
Copyright (c) 2003-2021 Emil Mikulic <emikulic@gmail.com> | ||
|
||
Permission to use, copy, modify, and distribute this software for any | ||
purpose with or without fee is hereby granted, provided that the | ||
above copyright notice and this permission notice appear in all | ||
copies. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL | ||
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED | ||
WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE | ||
AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL | ||
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR | ||
PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER | ||
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
# darkredhttpd | ||
|
||
A version of [darkhttpd](https://github.com/emikulic/darkhttpd) for BeefLang. | ||
|
||
Features: | ||
|
||
* Almost every feature of [darkhttpd](https://github.com/emikulic/darkhttpd), features not implemented are left as TODO. | ||
* Works on Windows and Linux, and should also work on others operating systems that Beef supports (But some code changes may be necessary). | ||
* Can throttle the upload speed with the argument `--throttle` | ||
|
||
Security: | ||
|
||
* Almost every security feature of [darkhttpd](https://github.com/emikulic/darkhttpd), features not implemented are left as TODO. | ||
* Rate-limited authentication | ||
|
||
Limitations: | ||
|
||
* Only serves static content - no CGI. | ||
|
||
## How to build darkredhttpd | ||
|
||
To build darkredhttpd you need to have the BeefLang compiler, if you're on Windows you can download it [here](https://www.beeflang.org/#releases), for any other operating system it's necessary to build from source, you can find BeefLang repository [here](https://github.com/beefytech/Beef). | ||
|
||
## How to run darkredhttpd | ||
|
||
Serve /var/www/htdocs on the default port (80 if running as root, else 8080): | ||
|
||
``` | ||
./darkhttpd /var/www/htdocs | ||
``` | ||
|
||
Serve `~/public_html` on port 8081: | ||
|
||
``` | ||
./darkhttpd ~/public_html --port 8081 | ||
``` | ||
|
||
Only bind to one IP address (useful on multi-homed systems): | ||
|
||
``` | ||
./darkhttpd ~/public_html --addr 192.168.0.1 | ||
``` | ||
|
||
Serve at most 4 simultaneous connections: | ||
|
||
``` | ||
./darkhttpd ~/public_html --maxconn 4 | ||
``` | ||
|
||
Log accesses to a file: | ||
|
||
``` | ||
./darkhttpd ~/public_html --log access.log | ||
``` | ||
|
||
Chroot for extra security (you need root privs for chroot): | ||
|
||
``` | ||
./darkhttpd /var/www/htdocs --chroot | ||
``` | ||
|
||
Use default.htm instead of index.html: | ||
|
||
``` | ||
./darkhttpd /var/www/htdocs --index default.htm | ||
``` | ||
|
||
Add mimetypes - in this case, serve .dat files as text/plain: | ||
|
||
``` | ||
$ cat extramime | ||
text/plain dat | ||
$ ./darkhttpd /var/www/htdocs --mimetypes extramime | ||
``` | ||
|
||
Drop privileges: | ||
|
||
``` | ||
./darkhttpd /var/www/htdocs --uid www --gid www | ||
``` | ||
|
||
Use acceptfilter (FreeBSD only): | ||
|
||
``` | ||
kldload accf_http | ||
./darkhttpd /var/www/htdocs --accf | ||
``` | ||
|
||
Run in the background and create a pidfile: | ||
|
||
``` | ||
./darkhttpd /var/www/htdocs --pidfile /var/run/httpd.pid --daemon | ||
``` | ||
|
||
Web forward (301) requests for some hosts: | ||
|
||
``` | ||
./darkhttpd /var/www/htdocs --forward example.com http://www.example.com \ | ||
--forward secure.example.com https://www.example.com/secure | ||
``` | ||
|
||
Web forward (301) requests for all hosts: | ||
|
||
``` | ||
./darkhttpd /var/www/htdocs --forward example.com http://www.example.com \ | ||
--forward-all http://catchall.example.com | ||
``` | ||
|
||
Commandline options can be combined: | ||
|
||
``` | ||
./darkhttpd ~/public_html --port 8080 --addr 127.0.0.1 | ||
``` | ||
|
||
To see a full list of commandline options, | ||
run darkhttpd without any arguments: | ||
|
||
``` | ||
./darkhttpd | ||
``` | ||
|
||
## How to run darkhttpd in Docker | ||
|
||
First, build the image. | ||
``` | ||
docker build -t darkhttpd . | ||
``` | ||
Then run using volumes for the served files and port mapping for access. | ||
|
||
For example, the following would serve files from the current user's dev/mywebsite directory on http://localhost:8080/ | ||
``` | ||
docker run -p 8080:80 -v ~/dev/mywebsite:/var/www/htdocs:ro darkhttpd | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using System; | ||
|
||
namespace darkredhttpd | ||
{ | ||
public static class Constants | ||
{ | ||
public static readonly String PKG_NAME = "darkredhttpd/1.13.from.git"; | ||
public static readonly String COPYRIGHT = "copyright (c) 2021 disarray, 2003-2021 Emil Mikulic (darkhttpd)"; | ||
|
||
#if DEBUG | ||
public const bool DEBUG = true; | ||
#else | ||
public const bool DEBUG = false; | ||
#endif | ||
|
||
// Be aware that many strings are allocated on the stack, so a very large MAX_REQUEST_VALUE | ||
// would require refactoring them from scope to new:ScopedAlloc! | ||
public static readonly int MAX_REQUEST_LENGTH = 4096; | ||
|
||
public static readonly String DEFAULT_EXTENSION_MAP = | ||
""" | ||
application/emg emg | ||
application/pdf pdf | ||
application/wasm wasm | ||
application/xml xsl xml | ||
application/xml-dtd dtd | ||
application/xslt+xml xslt | ||
application/zip zip | ||
audio/flac flac | ||
audio/mpeg mp2 mp3 mpga | ||
audio/ogg ogg | ||
audio/opus opus | ||
image/gif gif | ||
image/jpeg jpeg jpe jpg | ||
image/png png | ||
image/svg+xml svg | ||
text/css css | ||
text/html html htm | ||
text/javascript js | ||
text/plain txt asc | ||
text/vtt vtt | ||
video/mpeg mpeg mpe mpg | ||
video/ogg daala ogv | ||
video/divx divx | ||
video/quicktime qt mov | ||
video/x-matroska mkv | ||
video/x-msvideo avi | ||
video/mp4 mp4 | ||
"""; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
namespace System | ||
{ | ||
extension Char8 | ||
{ | ||
public bool IsXDigit | ||
{ | ||
get | ||
{ | ||
return ((this >= '0' && this <= '9') || | ||
(this >= 'a' && this <= 'f') || | ||
(this >= 'A' && this <= 'F')); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.