anchor.diff:  %% prf callbacks
   -export([collect/1,config/2]).
   
  -% gen_serv callbacks
  --export(
  -   [handle_info/2
  -    ,handle_call/3
  -    ,init/1
  -    ,rec_info/1]).
  +-behaviour(gen_server).
  +-export([init/1,terminate/2,code_change/3,
  +         handle_call/3,handle_cast/2,handle_info/2]).
  +
  +-export([state/0]).
  +state() ->
  +  gen_server:call(?MODULE,state).
   
   -include("log.hrl").
   
  
positive.code:   LD.
  
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %% gen_serv callbacks
  
  -record(ld,{port,
              acceptor,
              udp_socket,
  
negative.code:             msg=orddict:new(),
              secret}).
  
  init([]) ->
    {ok,#ld{}}.
  
  handle_call(state,_,LD) ->
    Fields = record_info(fields,ld),
    {reply,lists:zip(Fields,tl(tuple_to_list(LD))),LD};
  handle_call({config,{port,Port}},_,LD) ->
    {reply,[],LD#ld{acceptor=accept(Port),udp_socket=udp_open(Port)}};
  handle_call({config,{secret,Secret}},_,LD) ->
    {reply,[],LD#ld{secret=Secret}};
  handle_call(get_data,_,LD) ->
    {reply,LD#ld.msg,LD#ld{msg=orddict:new()}}.
  
  handle_info({new_socket,Sock},LD) ->
    %% we accepted a socket towards a producer.
    {noreply,LD#ld{tcp_sockets=[Sock|LD#ld.tcp_sockets]}};
  handle_info({tcp,Sock,Bin},LD) ->
    case lists:member(Sock,LD#ld.tcp_sockets) of
      true ->
        %% got data from a known socket. this is good
        {noreply,decrypt(Bin,LD)};
      false->
        %% got data from unknown socket. wtf?
        ?log([{data_from,Sock},{bytes,byte_size(Bin)}]),
        {noreply,LD}
    end;
  handle_info({tcp_closed, Sock},LD) ->
    case lists:member(Sock,LD#ld.tcp_sockets) of
      true ->
        {noreply,LD#ld{tcp_sockets=LD#ld.tcp_sockets--[Sock]}};
      false ->
        ?log([{unknown_socket_exited,Sock}]),
        {noreply,LD}
    end;
  handle_info({tcp_error, Sock, Reason},LD) ->
    ?log([{tcp_error,Reason},{socket,Sock}]),
    {noreply,LD};
  handle_info({udp,Socket,_IP,_Port,Bin},LD) ->
    case Socket == LD#ld.udp_socket of
      true ->
        inet:setopts(Socket,[{active,once}]),
        {noreply,decrypt(Bin,LD)};
      false ->
        %% got data from unknown socket. wtf?
        ?log([{unknown_socket,Socket},{bytes,byte_size(Bin)}]),
        {noreply,LD}
    end;
  handle_info(Msg,LD) ->
    ?log([{unrec,Msg}]),
    {noreply,LD}.
  
  decrypt(Bin,LD) ->
    case LD#ld.secret of
  