|
|
This months project is called EOL - Erlang on-line. The idea is to set up a collaborative project to build a server-less pager - rather like ICQ but without the server.
The pager will have an open architecture to allow anybody to plug in an application module. I'll write the basic stub code to do authentication and launch an application, I'll even write the first application (chat) and throw it open to the world. All the code will be published here.
The idea is as follows:
This won't work through a firewall - I'll need some help with socks here (I think) - the basic scheme should work with dynamically allocated IPs (If your ISP is not paranoid) and with fixed IPs - If you can ping the IP of the machine in question it should work!
The first bit of code is eol.erl, this reads and writes an Erlang ground term to a web page, some of the interfaces are:
eol:put_term(Host, User, Password, File, T) -> ok | Error eol:get_term(Url) -> T
put_term is implemented with FTP, and get_term is implemented with HTTP. The term T must be a ground term (Why - think about it).
The term itself is stored by computing term_to_binary(T), converting the result to a list and base64 encoding the result with base64.erl.
There is also a little test program eol_test.erl that was used to test this stuff, and to maintain the eol pages.
|
|
I gave the following command:
eol_test:put_term(X)
Which resulted in this term. What was the value of X? All the code you need to answer this is on this page. You might also need a copy of Erlang to solve the problem.
The first person to mail me an answer will get an honorable mention.
|
|
|
|
... to write the pager. From now on I'm thinking out loud.
We start with a user profile, something like ...
%% Profile
%% -------
%% The next line has the FTP location where I store my dynamic data.
%% The port, 3345 argument means "set up a listening port on port 3345"
%% every,10,mins means update this information every 10 minutes
{myprofile, Host, User, Password, File, every, 10, mins, port, 3345}.
%% Aliases
%% -------
%% Define some aliases - these are URLs of groups
%% or individuals. The group page just contains lists of
%% individuals.
{group, gamers, "http://hem.passagen.se/joepass/gamers.html"}.
{friend, joe, "http://hem.passagen.se/joepass/eol.html"}.
{friend, helen, "http://hem.passagen.se/helenpass/eol.html"}.
%% Watch points
%% ------------
%% Setup watch points (the names in the lists must be friend or
%% group aliases)
%% Each watch command pops up a toolbar, containing the status
%% of the users in the watch list. The user's URL is polled
%% every 30 seconds. The user is colored red or green.
%% If green you can click on the user and request a connection
{watch, [joe, helen]}.
{watch, [gamers]}.
%% Allowed services
%% ----------------
%% This is a list of services I want to run on my machine
{allow, [watch, message, chat]}.
%% Admission control
%% -----------------
%% This is a mini language that that specifies what to do
%% if I get a connection request on my Erlang port
{accept, watch, from, any, password, none}.
{reject, message, from, "madman"}.
{accept, message, from, any, password, none}.
{accept, chat, from, helen, password, none}.
{accept, chat, from, any, password, "chatter"}.
Was that self explanatory?
Converted from eol.ehtml by ehtml.html