Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

Lightweight Webserver [Supports: Plugins,Mime,Directory Listing and more .. ]

Lightweight Webserver

Default screenshots
Spoiler (Click to View)

Xm Script Front-End screenshot
Spoiler (Click to View)

Features:
  • Mime Support
  • Multiple Vhosts
  • Directory Listing
  • Basic Security Checks
  • Compressed Transfers
  • Custom Error Reponse
  • Readme.md embedding
  • Plugin Support
  • GET/POST Handling
  • XML Configuration
  • Per Directory Access control

Mime Support

The server has an internal database with content types (MIME) which you change within the config,
these settings are important since they tell the browser how to handle certain files, ie show text files as plain but send zip files instead.
If a certain extension is not found, the server will fall back to the default octet-stream which the browser receives as a download.

Virtual Hostings aka Prefix

You can define multiple hostnames on the server within each its own VirtualHost elements inside the config file,
Obviously you cannot just put anything in there, however if you change your Hosts file in your OS, for instance
you add '127.0.1.1   my.local.website' in which then the prefix/VirtualHost 'my.local.website' can respond for that hostname with a VirtualHost definition.
If you are not interested in this and just want to host on local and be able to catch all, use the *:80 as prefix, this will do just that.

Directory Listing

The server has the ability to list a folder with no defined or default index pages, each VirtualHost has its own Template.xml where the body of that page is made from.
Also when the directory contains a Readme.md it will display the content of the readme inside the header automatically.

Example of template config:
https://github.com/TheBarret/WebServer.N...mplate.xml

Security

The server has a few basic security checks upon each request, it will always verify the GET variables and path request for illegal characters such
as attempts for breaking out of the root folder using the double dots, ie "..\..\..\file.ext".


Speed and Compression

The server by default uses GZip for each data transfer of anything that is to be send and we utilize a threadpool and queue system so the server can throttle on your settings,
nothing is done in a single thread.

Plugin Support

The server has a plugin support where the plugins can claim a request or modify live the send buffer, there is an example plugin project included that shows how to do this.
Plugins are setup in the config.xml, notice that the plugins require the Webserver.exe for reference, the '../' is required to load the plugins inside the base directory.

Example of a demo plugin
https://github.com/TheBarret/WebServer.N.../Plugin.vb

Example of a plugin script handler
https://github.com/TheBarret/WebServer.N.../Plugin.vb

Remark:

You need to recompile the plugins (regarding the XM plugin and its engine) yourself else you get a security/CAS exception, this is a VS built-in safety feature.

Accessing GET/POST variables

The server stores all the variables, send by the user, in the Client.Data collection.

Per directory access control

You can Allow or Deny who can access certain directories done in the access.xml, this file can be placed in any directory.
This approach is adopted from the Apache server software where it utilizes the .htaccess config files

Example of such access config:
https://github.com/TheBarret/WebServer.N...access.xml

The Configuration file

The base paths are relative to where the server is operating (executes), the default base path in this project is .\html, for each website an individual directory.
You can add or remove custom headers for whatever reason, it will automatically send these each request.
It will hide by default filenames and directories with a name that starts with a dot, this is familiar and normal in the Linux OS as well, this can be disabled.
You can also define file extensions that you absolutely don't want to be shown or send, this can be found under the HiddenFileTypes.

Example of the config file: https://github.com/TheBarret/WebServer.N...config.xml

Alright, have fun!

Github: https://github.com/TheBarret/WebServer.Net
Okay as someone who loves to do Server-side work along with client side. I find this very cool. I definitionally need to look over this when I have more time. Nice work man!
Great concept, have you implemented any error logging?
Recently started playing with HttpListener. First thing I saw was an error binding to port 80 and then a firewall issue. Both OS configuration settings I'm sure, just ended up turning the firewall off temporarily. I used it as a webhook to notifications I want to receive from a service.

I must say one of the first things that went through my mind was "wow I can easily build on this, serve files, etc" pretty much everything else a web server can do. Glad to see it be done by none other than "The Barret" pretty cool.
(Dec 10, 2017 08:09 PM)Closed User Wrote:  Great concept, have you implemented any error logging?

Not yet, the current setup only emits errors (script wise) as page to the browser (much like php does)
Others proposed me to implement a PDO'ish concept like php does in xm. but thats quit something else.

(Dec 10, 2017 08:31 PM)DBots Wrote:  Recently started playing with HttpListener. First thing I saw was an error binding to port 80 and then a firewall issue. Both OS configuration settings I'm sure, just ended up turning the firewall off temporarily. I used it as a webhook to notifications I want to receive from a service.

I must say one of the first things that went through my mind was "wow I can easily build on this, serve files, etc" pretty much everything else a web server can do. Glad to see it be done by none other than "The Barret" pretty cool.

Yeah i walked into that problem myself, the httplistener does not work when the hosting process is not elevated to "admin" level.
You gotta add a manifest file and have the following line in it:

Code
<requestedExecutionLevel  level="requireAdministrator" uiAccess="false" />
Major update, optimized and cleaned up into a vanilla state ready to be modified to your liking.
This is pretty impressive, It's really cool to see this sort of stuff using Vb.net. Great work.
Update: Plugin support (demo included) and revamped the GET/POST access code.
Amazing Project. thx for advance
Amazing work mister. Is this something like apache webserver?
[Image: signaturetwo.png]
(Dec 16, 2017 08:16 AM)Vyxn Wrote:  Amazing work mister. Is this something like apache webserver?

I could never top Apache :P but yes, some settings are indeed inspired from Apache.
(Dec 16, 2017 08:25 AM)Barret Wrote:  I could never top Apache :P but yes, some settings are indeed inspired from Apache.

I doesn't matter, it has the idea so you still did a great work. 🤝
[Image: signaturetwo.png]
Added a new feature, adopted from the Apache software, known as .htaccess configuration files.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by 0u1lawJul 15, 2021 08:20 AM 2 186 Jul 15, 2021 08:20 AM
Last Post: 3phase
[C#] by Formula 1Apr 24, 2020 02:50 AM 7 248 Apr 24, 2020 02:50 AM
Last Post: Shadow_Cloud
[Python] by Robin2Jan 13, 2019 06:27 AM 2 121 Jan 13, 2019 06:27 AM
Last Post: lockhead