Kraknet

Login
Share  |  Github  |  Chat  |  Mostly Harmless  |  8086 Reference 12:51:51 PM
Directory Listing
 

When a directory doesn't have an index file on an Apache server, an optional directory listing can be provided instead. I wrote a script which creates a nicely formatted listing and this will be incorporated in the current build of Kraknet on Github.

Building tools like this means that some things involving configuration need to change first. A new subdirectory conf/sites/ will be created to hold site configuration; just like in Apache, you will be able to host multiple domains with aliases on the same server, using the HTTP/1.1 Host header.

Moving Forward Through Git
 

Over the past couple weeks the source code for the latest iteration of Kraknet, including the nascent web server which will become a permanent feature moving forward, has been moved to a repository on Github. This should allow development to become more stream-lined, as well as easing deployment. The new server system is very robust, allowing you to change essentially every configuration option while the server is running and have those changes be reflected immediately.

You can download the source code and run the in-dev server right now from the repository. This software is far from complete, but absolutely functional for testing. As modules are ported over to the new system they will become a part of this repository.

Krakchat is next on the list for a redesign, with some big plans for a persistent server handling requests through Unix domain sockets and a compressed server-side chat history.

SQLite and Krakchat Color Preferences
 

All of the accounts database has been moved from flat files to a SQLite database. The idea here is to make it easier for other applications to interface with that data. SQLite was chosen because it's simple and doesn't require a server. Databases are stored as a single file, and can exist anywhere on the hard disk or RAM disk. Session management was also reworked to allow unlimited simultaneous logins and sessions which last an arbitrary amount of time (I set this to a month).

Krakchat has its own preferences system, which right now is essentially just a color choice. Your name is your preferred color, but brackets and emotes show up as the traditional IP color.

Switching from OpenVZ to Xen
 

Tonight I moved the entire Kraknet (except for DNS) from a server with OpenVZ virtualization to one running on Xen instead. The cluster for the old server was way too crowded, making it hard to get any disk I/O or CPU time in. Everything should be more stable on the new server. The TTL for krakissi.net is 3600 seconds, although old records may persist longer than that.

Registration and Style
 

The long awaited Kraknet registration system is finally online in its rudimentary state. In a fury of studying for a programming competition, I took the time to figure out regular expressions in C, which made it very easy to make a fairly safe registration system. It's not immediately obvious, but in order to use normal regex symbols like ^ and $ (beginning and end of string anchors, respectively) you must escape them.

For example's sake, consider the regex used to check that newly registered names are all lowercase letters, at least four of them and no more than 31. I actually used ` (backtick) and ' (apostrophe) instead of ^ and $; it works the same way.

regex_t loweral; regcomp(&loweral,"\\`[a-z]\\{4,31\\}\\'",REG_NOSUB);

Setting up the regex in this way allows you to match the entire string with no substring elements. This is perfect for quickly evaluating, as I was in this case, usernames. When it comes time to actually match, it's fairly straightforward again.

if(regexec(&loweral,user,0,NULL,0)){ printf("Username must be 4 to 31 characters, ...\r\n"); return -1; }

regexec will return some non-zero value if the string doesn't match the regular expression, and therefore isn't a value user name. A similar system was used to validate passwords, and you can see the whole hacked together registration code here.

You might also have noticed the slight changes to the style of Kraknet. The very plain old CSS has been replaced by somewhat less plain new CSS. I was just sick of looking at high-contrast, bold colors everywhere.

New Server
 

Fighting with Apache has finally led to the development of an actual Kraknet server. The plan had long been to build the whole system to be compatible with Apache so that anyone could drop it into their website and be done with it. Apache is, however, overburdened with features that makes its configuration dense and complicated. New users often can't figure out how to make even the simplest changes to their server.

Instead of building inside of these constraints, the site system will be ported to run on a new, tiny server written entirely in C. Already that server is functional, and will have built-in websockets support with a simple CGI-like stdin/stdout interface for application developers. That means that the server handles the difficult handshaking, and your application (which could be a script or compiled program in any language your machine can execute) needs only write to stdout and read from stdin.

Kraknet Server
 

Fighting with Apache has finally led to the development of an actual Kraknet server. The plan had long been to build the whole system to be compatible with Apache so that anyone could drop it into their website and be done with it. Apache is, however, overburdened with features that makes its configuration dense and complicated. New users often can't figure out how to make even the simplest changes to their server.

Instead of building inside of these constraints, the site system will be ported to run on a new, tiny server written entirely in C. Already that server is functional, and will have built-in websockets support with a simple CGI-like stdin/stdout interface for application developers. That means that the server handles the difficult handshaking, and your application (which could be a script or compiled program in any language your machine can execute) needs only write to stdout and read from stdin.

wifi_eval Tool
 

Quick post here, just dropping a download link for my "wifi evaluation" tool. This is a linux program which constantly polls /proc/net/wireless to track the quality and signal attenuation of a wireless connection. Source code included (written in C) along with a statically linked binary that should work out of the box. If it doesn't, rm wifi_eval and then run make in directory with the Makefile and main.c.

Get it here.

Optimizations
 

Minor changes have been implemented that will greatly improve the portability and speed of the site system. The biggest is moving away from piping in ls when directory lists are required and instead using readdir(). This means that the implementation of ls isn't important, and that sorting is done by the site system itself rather than ls, so the results are guaranteed to be exactly what I'm expecting on every system. Ideally, no system calls should be made by any part of the site system.

The automatic detection system for installed modules has also been redesigned, and now smartly looks only at directories for info.txt files rather than attempting to find a '/info.txt' for every file in the server's home directory. Omitted directories (which did not contain an info.txt file, or which could not be read) are now commented in the mods.lst file mod_detect produces. The next major feature update will be related to the control panel system. Once this is done, and all the other temporary bits of Kraknet are sorted out, the site system will be essentially ready for beta.

I added a new section to the site, Letters from Nigeria, for sharing interesting spam emails. If you want to share yours, send it to krakissi at krakissi.net as a plain text file. The first one, from the Central Bank of Nigeria seems legit.

Chat with Nicknames
 

Chat now supports regular Kraknet user accounts for nicknames. Once I have all the kinks worked out, user registration will be automated and anyone can make their own account to use on the chat (as well as pick their own color and text formatting). I also fixed a bug that was created when moving from a shell script to generate timestamps to a small C program. In essence, the issue was that gluing nanoseconds onto the end of the timestamps required prepending zeroes if the nanosecond value was less than a tenth of a second. This has been corrected.

Having the user accounts being tested in a closed setting has exposed another potential issue with password security which will be corrected, and then the management page for users will be built.

0246694