+Unknown-Horizons, +Rant, +Fail, +Functional, +HowTo, +Erlang

Unknown Horizons 2009.0; tags=Programmieren, Unknown-Horizons, Linux, FOSS

Unbestätigten Insiderinformationen (/me ist Teil des Teams) zufolge steht die Veröffentlichung von Unknown Horizons 2009.0 in wenigen Minuten an.
Nach über 5 Monaten Entwicklung hat das Unknown Horizons Projekt jetzt ein neues Snapshot Release in der Version 2009.0 herausgebracht. Nachdem wir heute Nachmittag Pakete gebaut und den letzten Feinschliff vollendet haben, durfte ich das neue Release im SVN tree des Projekts taggen.
Neben der Namensänderung sind jetzt auch erstmals Graphiken in einer ordentlichen Auflösung dabei, sowie eine deutlich ansprechendere Spielwelt -- keine quadratischen Inseln mehr! -- so dass die Hoffnung bleibt, dass möglichst viele Nutzer Gefallen an dem Spiel finden werden.
Eine weitere, wichtige Neuerung ist der Free Trader. Somit ist es jetzt möglich im Singleplayer Modus (Multiplayer müsste irgendwann implementiert werden) Waren zu kaufen/verkaufen.
Was hat es dann nicht in die neue Version geschafft? Leider eine ganze Menge -- das Release ist nunmal nicht zu Unrecht als Alpha gekennzeichnet. Meine Ziele für die nächste Zeit sind allerdings dann i18n/l10n, was leider von PyChans Fähigkeit abhängt Unicode Zeichen darzustellen, und saubere Installierbarkeit, sodass ich offizielle Debian Pakete bauen kann.
Wer sich für Details interessiert, der sei auf das Changelog verwiesen.
-- Christoph Egger <christoph@coders-nemesis.eu> Sun, 08 Mar 2009 20:28:30 +0100
[FAIL] Security; tags=Programmieren, Linux, FOSS, Rant, Fail
I'm all for security and really like encryption (my Notebook's harddrive is encrypted, I've recently got a GPG Smartcard, ...) but sometimes you see big failes where security is atemted but doesn't actually secure anything but only hinders the legitimate user.
Today one of these candidates ate way to much of my time again. I'm currently getting more and more used to GNU Emacs and currently experimenting with emacs-jabber. Therefore copying my jabber accounts over from psi. As with these passwords you never type in I couldn't remember some of my jabber passwords -- no problem psi has to store them so it should be easy to get them, right?
Well actually not. The configuration file (XML) had a password entry but all that was in it was just obviously hex-encoded numbers. These numbers turned out to be be 16bit packages of characters that are XOR-ed against the JID So now you have to read them in in junks of 16bit, XOR them against the JID and get the password.
Time to recapitulate what this security helped. I've written a hacky 10 lines C Program that can reliably retrieve passwords from any config file I might come across. Seems you can do the same in 2 lines of perl. Ergo no security at all was added.
Next question: What did it cost? Needed an hour or so of researching the encryption and trial&error out the right program fragment. For nothing gained at all. Fail.
-- Christoph Egger <christoph@coders-nemesis.eu> Wed, 02 Jun 2010 20:23:08 +0200
The erlang experience; tags=Programmieren, Linux, FOSS, Functional, HowTo, Erlang
This week I had to write a little tool that would collect input on different channels, via socket / netcat, via a http server, .... Calls for a parralel Design -- Maybe a good place to write something real in Erlang. While erlang itself was really nice to write -- I do like Prolog as well as the bunch of functional languages -- doing networking in erlang seems a bit special, the interfaces just aren't thin wrappers around the libc stuff.
Getting a Socket Text interface
What sounds like a easy challenge to accomplish was actually harder than expected. All I found was some way to pass binaries representing erlang code over a socket and evaluating it remotle. While it's nice that such things are as easy to do as they are it doesn't help me with my task of moving simple strings.
start() ->
{ok, Listen} = gen_tcp:listen(51622, [binary, {packet, 0},
{reuseaddr, true},
{active, true}]),
spawn(fun () -> accept_loop(Listen) end).
accept_loop(Listen) ->
{ok, Socket} = gen_tcp:accept(Listen),
accept_loop(Listen),
handle(Socket)
handle(Socket) ->
receive
{tcp, Socket, Bin} ->
io:format("~p~n", binary_to_list(Bin));
{tcp_closed, Socket} ->
Buffer
end.
So the socket is now up and receives text as wanted. However, as we
are already runnign a parralel program it would be nice to be hable to
handle multiple socket connections in parralel right? For that we just
need to add a spawn() at the right place. The right place is not
the handle(Socket) but the accept_loop(Listen) because the process
that called accept will receive all the tcp messages.
This last part was quite obvious after finding the documentation of
the {active, _} properties for the socket. always here means that
you'll receive all data from the socket as erlang Messages, once
delivers one package and waits until it is activated again and false
requires calling a method -- this would have been possible as well
when forking handle(Socket).
The web server
Ok we also want a webserver. We do not want to run some
webapplication inside appache or so, just do some post/get and simple
pages. Erlang here provides a built-in httpd with some mod_esi
that calls some function depending on the URL used. It doesn't do
anything fancy like templating or DB backends or stuff, just taking
strings and building the http answers.
Unfortunately there are no examples around and basically noone seems
to be using this combination (apart from some hacks like mine
probably). So as I needed to get some additional information into the
handler function (a Pid to connect to some service), I, as a novice,
just couldn't find a way. Asking on IRC the solution was rather
simple: Just using erlang's process registry. For more complex stuf
gproc might prove usefull here.
Result
I guess I've got a huge step farther in programming erlang now. The manpages are easily found by your search engine -- for python I have to either walk through the (well structured) online documentation or search for the right link in the search results, for erlang they're typically first. Also Joe Armstrong's Books as proven usefull. The most dificult part probably is getting around all the nice extras you can do (transfering functions over sockets et al) and find out how to do the thing you need.
-- Christoph Egger <christoph@coders-nemesis.eu> Sun, 05 Dec 2010 12:58:23 +0100