flash socket policy-file-request in Erlang


Warning: sizeof(): Parameter must be an array or an object that implements Countable in /var/www/clients/client1/web1/web/wp-content/plugins/ad-injection/ad-injection.php on line 824

Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/clients/client1/web1/web/wp-content/plugins/ad-injection/ad-injection.php on line 831

This Erlang version is pretty much a straight translation of this perl-flavoured socket policy file to give credit where it’s due

-module(fs_auth).
-export([start/0]).
start() ->
    {ok, Listen} = gen_tcp:listen(843, [binary,{reuseaddr, true}, {active, true}]),
    spawn(fun()-> connect(Listen) end).

connect(Listen)->
    {ok, Socket} = gen_tcp:accept(Listen),
    spawn(fun()-> connect(Listen) end),
    loop(Socket).

loop(Socket)->
    receive
        {tcp, Socket, <<"<policy-file-request/>", 0>>} ->
            Reply = <<"<cross-domain-policy><allow-access-from domain=\"*\" to-ports=\"*\" /></cross-domain-policy>", 0>>,
            gen_tcp:send(Socket, Reply),
            loop(Socket);
        {tcp, closed, Socket}->
            io:format("server closed socket")
    end.



coded by nessus