
Dicop::Client -- a client object

use Dicop::Client;
my $client = new Dicop::Client ('config/client.cfg');
$client->work(); # never returns unless hard error occurs

perl5.004, Dicop::Event, Dicop::Config, Dicop::Item, Dicop::Request, Linux::Cpuinfo, Dicop::Hash

Exports nothing.

This module represents a client and manages all communication between servers and client and the client and the workers.
It uses Dicop::Connect for the network connection via HTTP/FTP to the server or proxy.

Create a client object by using the supplied config file (or uses 'config/client.cfg' as default.
Main loop. Start working and never return (except in case of fatal errors).
$client->change_root();
Uses chroot() to change the root directory to the given directory from the configuration file (or command line). Call before change_user_and_group because chroot() only works for root.
$client->change_user_and_group();
Uses POSIX to change the real user and group id of the process.
print $client->architecture();
Return the name of the base arcitecture the client is running on.
print $client->full_arch();
Return the full arcitecture string (including sub_arch). See also sub_arch.
print $client->sub_arch();
Return the sub architecture string. See also full_arch.
$self->output( "text", "test", "foo");
Prrint a list of texts. Overrided by the testsuite to inhibit unwanted output.
Adds another request to the queue, unless we already have a request for work in there.
Log an error text to the logfile, and then die finally.
The server sends us the chunks to work on as a compact string. Ths routine breaks them down into parts and returns a hash containing the pieces.
For all the chunks to work on the server sent us, break them down, then start the worker and insert the result (FAIL, SUCCESS, TIMEOUT or DONE) as request into the sending queue.
Add the given request(s) to the list of to-be-sent items (insert it into the send-queue). The input is a list of Dicop::Requests, or scalars holding strings, the output the number of requests now in the queue.
Parse the server's response into requests, and throw away any garbage/junk. This also throws away responses with an code lower than 100, as these are only idle chatter.
The input is an response object from the server, or a scalar (for test suite).
This returns a ref to an array which contains in every element [ response_id, response_code, response_text]. So for two responses the array has two entries.
This method walks the list of requests/messages/answers we got from the server, and extracts each file we will need to work from them. All the files are entered into a HASH keyed on their filename (to avoid doubles) and the value is the hash of the file we must download.
From list of the server's responses, clear any request from our send list, that was answered successfully by the server.
After this, anything that needs to be send again will be in the send stack, including our authentication, anything other will be deleted.
Chunks of work or test will be added to our todo list, which is than processed by work_on_chunks.
After an hard error, we clear the send queue from the requests we tried to send and then fill it with our auth request and one request for more work.
This ensures that after some hard error we start with a fresh and new list of requests for the server and forget the old, malformed ones.
Called automatically by _handle_responses.
($code,$res,$crc) = $self->_extract_result($rc);
Takes the output of the worker and tries to extract the result, the chunk CRC (checksum) and stopcode from it. Returns -1 for $code when it doesn't find a stopcode, and '' as result when there was no result in the output to be found.
Given a hash representation of a chunk, start the appropiate worker and let it work on the chunk. Returns a request-string to be entered into the send queue and the status code as text.
Adds together all the requests we need to send to the server, including our authentication request. Then calls connect_to_server(), parse_responses(), and _handle_responses().
if ($self->_check_file($filename,$hash)
{
print "$file is ok.\n";
}
else
{
print "$file is not there or outdated.\n";
}
This routine checks if we got the required version of a file. If the file is not there or does not have the proper hash, it will return false.
Given a list of filenames in form of a hash reference, will ask server for download locations of all the files, then uses _download_file to download them one by one.
Does not report whether all could be downloaded or not, this needs to be checked on a file-by-file basis to correctly decide which requests from the server we can work on and which are missing files - the same file might be missing for more than one request!.
$self->_download_file($file,$hash, $uris);
Download a file from a given list of URIs and checks via hash that we got the right file. Return 0 for success or 1 for error.
From the architecture name of the client, the worker dir and the worker name supplied by the server (via the request/chunk), construct the path to the worker. If a .exe file exists, this will be returned, otherwise just the executable name as it is.
Returns a list consisting of the path and name of the worker.
When an error occured, or we got no response, or no work, we wait a time to not overload the server. This routine does log the error, prints some information and then sleeps.
Deletes all temporary files that got sent from the server for the current chunk.
Does currently not take into account of we need to work on more than one chunk, so needs to be called after all chunks have been completed.

None discovered yet.

(c) Bundesamt fuer Sicherheit in der Informationstechnik 1998-2006
DiCoP is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation.
See http://www.bsi.de/ for more information.