DOLNancyWeb - Embedded GSS Web Server

A forum for development and discussion on third party tools such as the Quest Designer

Moderator: Project Admin

DOLNancyWeb - Embedded GSS Web Server

Postby Leodagan » Wed Dec 17, 2014 12:52 pm

This is not ready for Production "Open" Use...
Please be aware that there are no Brute Force or Denial of Service security actually implemented !
Even then you should only open access to this Service through a regular HTTP Server Secured Tunnel (Apache/IIS/Nginx)


Some may have wondered why I upgraded the Game Server Scripts features recently (Data Table, Server Properties, Third Party Library support, etc...)

Here is the reply, I finally have the ability to embed a third party library (NancyFX / Nancy) inside Game Server Scripts, thus being optional to DOL Runtime, and add just any weird~crazy~experimental features to Dawn of Light, here in the shape of an Embedded Web Server being able to run concurrently with DOL Server and offering dynamic page rendering based on current Server Status !

DOLNancyWeb
  • An ugly name for a wonderful framework...
GitHub Repository : https://github.com/dol-leodagan/DOLNancyWeb

So here is a totally new and independent GSS package that just need to be copied to your DOL working directory, that will then enable an "On-Demand" Web Server features to your Shard, this web server comes with default security based on Form-Login querying the existing DOL "Account" Table to match players/gamemasters/admins Account, it can serve static content for images, styles sheets, javascripts designs, and you can route any query to a dedicated Object Module that runs in your shard process and can gather or edit data from GameServer Instance and Database Objects !

Actual code base is not finished, I tried to mimic a Model View Controller (MVC) paradigm so that most Web Developer feel at home, but the actual framework is not limited to this coding style and I still have some bad habit from PHP/CGI developments...

The Nancy Framework offer different View engine (Razor, SSVE and others) that can use pseudo-HTML template to build the resulting page, this is pretty easy to use and only a few keywords should be needed, most work is around "Model" and CSS Style Sheet to improve display experience.

Model are "dynamic" "ExpandoObject" / "IDictionary", this means : mostly ANY Objects ! (A GameServer Instance or a Player Instance can Fit nicely in there !) but the View engine expect Public Members or Public Properties (Properties are pretty good to call a runtime method inside getter/setter) so it's rather hard to query any Methods or Functions, it would also be ugly to subclass these objects to had "web oriented" properties...
The path I took for "Models" is a "Default" Class that implements most needed properties for a "Home Page" (Page Title / Constants, User Authentication, Server Info), then each module needing other data just need to subclass this object to keep the page display nice, and add his own Members/Properties to display additional data ! (this allow to display the "Frame" of the Home page in every modules)

Finally "Controllers" are pure C# NancyModule subclass that are needed to implement "Routes" (The URL where you want your page) with parameters customizing (pretty much like Mod_Rewrite for Apache) and that trigger user-made methods on different queries (GET/POST/HEAD...) to finally provide a "Model" object with every Members populated with Data to display (Controller can also handle Server Response, authentication requirements, specific AJAX queries, and will mostly need to implement GameServer objects Editors to be able to have any effect on current game...)

Available Documentation on Nancy is pretty "thin" there are some replies to beginner pitfall available on StackOverflow, and a wiki can help you get your hands Dirty : https://github.com/NancyFx/Nancy/wiki

Server Properties Switch
  • Code: Select all
    [ServerProperty("dolnancyweb", "enable_web_server", "Enable/Disable Embedded Nancy Web Server", true)]
  • Code: Select all
    [ServerProperty("dolnancyweb", "web_server_listen_uri", "Embedded Nancy Web Server Listen URI", "http://localhost:10200")]
  • Code: Select all
    [ServerProperty("dolnancyweb", "web_server_cookie_crypt_secret", "Embedded Web Server Cookie Encryption Secret (If Empty will be auto set on first start)", "")]
  • Code: Select all
    [ServerProperty("dolnancyweb", "web_server_cookie_crypt_hash_secret", "Embedded Web Server Cookie Encryption Hash Secret (If Empty will be auto set on first start)", "")]
Actual State

- Form Based Authentication
- GameServer / GamePlayer Queries
- Master/Partial Layout for "Frame Like" Design
- Static Content for Images, Scripts, CSS or anything (Streaming ? Flash ? Future Asm.js/WebGL DAOC client ? :lol: )
- Ugly Hand-Made "Developer" Style

This kind of project can take great advantage of community work, each page can be independently coded by anyone, on any "bugs" user can disable the plugin entirely with a delete key press on their keyboard !

Some Screenshots :
webhome.png
webhome.png (129.07 KiB) Viewed 3810 times
weblog.png
weblog.png (68.21 KiB) Viewed 3810 times
Last edited by Leodagan on Sun Dec 21, 2014 3:09 pm, edited 1 time in total.
User avatar
Leodagan
Developer
 
Posts: 1350
Joined: Tue May 01, 2012 9:30 am
Website: https://daoc.freyad.net
Location: Lyon

Re: DOLNancyWeb - Embedded GSS Web Server

Postby Graveen » Thu Dec 18, 2014 12:54 pm

Leo, awesome POC :) /Worship !
Image
* pm me to contribute in Dawn of Light: code, database *
User avatar
Graveen
Project Leader
 
Posts: 12660
Joined: Fri Oct 19, 2007 9:22 pm
Location: France

Re: DOLNancyWeb - Embedded GSS Web Server

Postby Leodagan » Sun Dec 21, 2014 3:08 pm

This Module keeps growing and get mostly usable for Anything !

I still won't recommend you use this module to give player access to any Ressources, Some Models can get really heavy on DOL Runtime, it should be enough for allowing Admin / GameMaster editing, but not hundreds of Client displaying data on Mobs or other use case...

But it should be easy to build "Web Services" that could exchange data with a regular Web Server (like a PHP framework) to filter access through the embedded Web Module, JSON can be a nice "inter-service" data exchange.

Here the new Features :

- Full Server Properties Editor, using some JS to give visual hint on field editing, using RegEx to prevent entering wrong data, allowing to change Runtime Value or Database Value. (Restricted to PrivLevel 3)
- Regular Server HTTP Error response code handled to use the default Layout.
- User Roles are now populated using the "PrivLevel" in Database
- There is some basic Anti-Brute Force for restricted access Login.
- There is some Cleanup Timer to get rid of dynamic User Sessions.
- Basic Styling Generally Improved / Usable Menu (not Dynamic) / Some Status Data Printed on Home Page.

More screenshots :
websp.png
websp.png (109.08 KiB) Viewed 3810 times
weberror.png
weberror.png (123.79 KiB) Viewed 3810 times
User avatar
Leodagan
Developer
 
Posts: 1350
Joined: Tue May 01, 2012 9:30 am
Website: https://daoc.freyad.net
Location: Lyon

Re: DOLNancyWeb - Embedded GSS Web Server

Postby Eudes » Tue Dec 23, 2014 7:34 pm

Hello,

Leo, is there a possibility to write a short "how-to" to explain beginners (like me) how to use your project?
- Download Archive to deploy directly in your Working Dawn of Light Directory
- Clone locally near your Dawn of Light code base to include project for easier object references
That is what I did, but what to do now?

Should I add DOLNancyWeb.csproj to DOL solution? (I gave it a try but not really a success).

Thanks
Eudes
DOL Freak
 
Posts: 561
Joined: Wed Dec 05, 2007 12:27 am

Re: DOLNancyWeb - Embedded GSS Web Server

Postby Leodagan » Tue Dec 23, 2014 8:50 pm

In the Provided repository there is a "scripts" folder, that is meant to match your server "scripts" folder !

If you download the full archive from "GitHub" (Download Zip Link), you need to merge (overwrite) the scripts directory from DOLNancyWeb into your current DOL script directory

You will need to do the same with the "lib" directory, that is why the Github repository "looks like" a DOL server directory.

the .csproj file is only meant for developers or users that want to try to compile this module with their current DOL project (for improvement or debug...), so you shouldn't need it, but if you unzip the whole package in the same place as your DOL working directory, the .csproj file should be located next to your DOLServer.exe (that will mean you used the correct root path to unzip the whole package ;) )
User avatar
Leodagan
Developer
 
Posts: 1350
Joined: Tue May 01, 2012 9:30 am
Website: https://daoc.freyad.net
Location: Lyon

Re: DOLNancyWeb - Embedded GSS Web Server

Postby Eudes » Tue Dec 23, 2014 10:20 pm

Ok, it is finally easy :)

Thanks Leo, will try again!
Eudes
DOL Freak
 
Posts: 561
Joined: Wed Dec 05, 2007 12:27 am

Re: DOLNancyWeb - Embedded GSS Web Server

Postby Dinberg » Mon Apr 13, 2015 9:57 pm

Interesting work Leo, but I have a question - what is the inherent advantage of this method over, say, running the web server and game server separately and using a shared database or something like a chat bot to execute commands (which is what storm does)?
The Marvelous Contraption begins to stir...
User avatar
Dinberg
Inactive Staff Member
 
Posts: 4695
Joined: Sat Mar 10, 2007 9:47 am
Yahoo Messenger: dinberg_darktouch
Location: Jordheim

Re: DOLNancyWeb - Embedded GSS Web Server

Postby Leodagan » Tue Apr 14, 2015 7:21 am

Well this web module runs entirely "within" the DOL Runtime...

Which means you can virtually do ANYTHING, any kind of interaction with the runtime !

You could implement most of update behavior as "slash commands", I agree...

But you won't have the same easiness of getting Object State and Data with an external "Service" Querying Database, with this module you could even display any Mob Aggro Table dynamically, or debug a player Object Update Cache in realtime, it can access any objects collections directly inside the server runtime and not only rely on "static" Database records ;)

And you can still use this as a Gateway with an External "Service" (a real standalone WebServer or other Chat Bot), exchanging with a simple HTTP Protocol, which should be easier to use than specific Scripts (relying on POST Data Methods or GET'ing JSON or XML Object State)

It may be only my point of view of an old Web Dev, but doing anything "over HTTP" is really easy, and it can be secured as easily with doing anything "over HTTPS", it's the kind of mechanisms that are used even in biggest "Professional" Application Server (REST, SOAP, WSDL etc...)
User avatar
Leodagan
Developer
 
Posts: 1350
Joined: Tue May 01, 2012 9:30 am
Website: https://daoc.freyad.net
Location: Lyon


Return to “%s” Third Party Tools

Who is online

Users browsing this forum: No registered users and 1 guest