
AnyEvent::FCP - freenet client protocol 2.0

use AnyEvent::FCP; my $fcp = new AnyEvent::FCP;
# transactions return condvars my $lp_cv = $fcp->list_peers; my $pr_cv = $fcp->list_persistent_requests;
my $peers = $lp_cv->recv; my $reqs = $pr_cv->recv;

This module implements the freenet client protocol version 2.0, as used by freenet 0.7. See Net::FCP for the earlier freenet 0.5 version.
See http://wiki.freenetproject.org/FreenetFCPSpec2Point0 for a description of what the messages do.
The module uses AnyEvent to find a suitable event module.
Only very little is implemented, ask if you need more, and look at the example program later in this section.
Nothing much can be "imported" from this module right now.
Create a new FCP connection to the given host and port (default 127.0.0.1:9481, or the environment variables FREDHOST and FREDPORT).
If no name was specified, then AnyEvent::FCP will generate a (hopefully) unique client name for you.
%kv can contain (http://wiki.freenetproject.org/FCP2p0ClientGet).
ignore_ds, ds_only, verbosity, max_size, max_temp_size, max_retries, priority_class, persistence, client_token, global, return_type, binary_blob, allowed_mime_types, filename, temp_filename

use AnyEvent::FCP;
my $fcp = new AnyEvent::FCP;
# let us look at the global request list
$fcp->watch_global (1, 0);
# list them, synchronously
my $req = $fcp->list_persistent_requests_sync;
# go through all requests
for my $req (values %$req) {
# skip jobs not directly-to-disk
next unless $req->{return_type} eq "disk";
# skip jobs not issued by FProxy
next unless $req->{identifier} =~ /^FProxy:/;
if ($req->{data_found}) {
# file has been successfully downloaded
... move the file away
(left as exercise)
# remove the request
$fcp->remove_request (1, $req->{identifier});
} elsif ($req->{get_failed}) {
# request has failed
if ($req->{get_failed}{code} == 11) {
# too many path components, should restart
} else {
# other failure
}
} else {
# modify priorities randomly, to improve download rates
$fcp->modify_persistent_request (1, $req->{identifier}, undef, int 6 - 5 * (rand) ** 1.7)
if 0.1 > rand;
}
}
# see if the dummy plugin is loaded, to ensure all previous requests have finished.
$fcp->get_plugin_info_sync ("dummy");

http://wiki.freenetproject.org/FreenetFCPSpec2Point0, Net::FCP.


Marc Lehmann <schmorp@schmorp.de> http://home.schmorp.de/