AC-Yenta

 view release on metacpan or  search on metacpan

MANIFEST  view on Meta::CPAN

lib/AC/Yenta/Kibitz/Store/Client.pm
lib/AC/Yenta/Kibitz/Status.pm
lib/AC/Yenta/AC/MySelf.pm
lib/AC/Yenta/Store.pm
lib/AC/Yenta/Client.pm
lib/AC/Yenta/Server.pm
lib/AC/Yenta/Crypto.pm
lib/AC/Yenta/Monitor.pm
lib/AC/protobuf/heartbeat.pl
lib/AC/protobuf/std_reply.pl
lib/AC/protobuf/auth.pl
lib/AC/protobuf/yenta_status.pl
lib/AC/protobuf/yenta_getset.pl
lib/AC/protobuf/std_ipport.pl
lib/AC/protobuf/yenta_check.pl
lib/AC/Yenta.pm
LICENSE
eg/yenta_get_direct
eg/myself.pm
eg/yentad
eg/yenta.conf
eg/yenta_get
eg/yenta_put
MANIFEST
proto/yenta_status.proto
proto/std_reply.proto
proto/yenta_check.proto
proto/std_ipport.proto
proto/yenta_getset.proto
proto/heartbeat.proto
proto/auth.proto
Makefile.PL
META.yml                                 Module meta-data (added by MakeMaker)

META.yml  view on Meta::CPAN

--- #YAML:1.0
name:               AC-Yenta
version:            1.1
abstract:           eventually-consistent distributed key/value data store. et al.
author:
    - AdCopy <http://www.adcopy.com>
license:            perl
distribution_type:  module
configure_requires:
    ExtUtils::MakeMaker:  0
requires:
    AC::DC:               0
    BerkeleyDB:           0
    Crypt::Rijndael:      0
    Digest::SHA:          0

lib/AC/Yenta.pm  view on Meta::CPAN


=item allow

specify networks allowed to connect.

    allow 127.0.0.1
    allow 192.168.10.0/24

=item seedpeer

specify initial peers to contact when starting. the author generally
specifies 2 on the east coast, and 2 on the west coast.

    seedpeer 192.168.10.11:3503
    seedpeer 192.168.10.12:3503

=item secret

specify a secret key used to encrypt data transfered between
yentas in different datacenters.

lib/AC/Yenta/Crypto.pm  view on Meta::CPAN

# $Id$

package AC::Yenta::Crypto;
use AC::Yenta::Debug 'crypto';
use AC::Misc;
use Time::HiRes 'time';
use Crypt::Rijndael;
use Digest::SHA  qw(sha256 hmac_sha256_base64);
use strict;

require 'AC/protobuf/auth.pl';

my $ALGORITHM = 'x-acy-aes-1';

sub new {
    my $class  = shift;
    my $secret = shift;

    return bless {
        secret	=> $secret,
    }, $class;

lib/AC/Yenta/Protocol.pm  view on Meta::CPAN

use AC::Yenta::Debug 'protocol';
use AC::Yenta::Config;
use AC::DC::Protocol;
use AC::Yenta::MySelf;
use AC::Yenta::Crypto;
use AC::Misc;
use AC::Import;
use strict;

require 'AC/protobuf/heartbeat.pl';
require 'AC/protobuf/auth.pl';
require 'AC/protobuf/std_reply.pl';
require 'AC/protobuf/yenta_status.pl';
require 'AC/protobuf/yenta_check.pl';
require 'AC/protobuf/yenta_getset.pl';


our @ISA    = 'AC::DC::Protocol';
our @EXPORT = qw(read_protocol use_encryption);
my $HDRSIZE = __PACKAGE__->header_size();

lib/AC/Yenta/Protocol.pm  view on Meta::CPAN

            });
            $io->shut();
            return;
        }
    }

    my $p = $io->{proto_header};
    return unless $p; 	# read more

    # do we have everything?
    return unless length($io->{rbuffer}) >= ($p->{auth_length} + $p->{data_length} + $p->{content_length} + $HDRSIZE);

    my $auth    = substr($io->{rbuffer}, $HDRSIZE,  $p->{auth_length});
    my $data    = substr($io->{rbuffer}, $HDRSIZE + $p->{auth_length},  $p->{data_length});
    my $content = substr($io->{rbuffer}, $HDRSIZE + $p->{auth_length} + $p->{data_length}, $p->{content_length});

    # RSN - validate auth

    if( $p->{data_encrypted} && $data ){
        $data = $me->_decrypt_data( $io, $auth, $data );
        return unless $data;
    }

    if( $p->{content_encrypted} && $content ){
        $content = $me->_decrypt_data( $io, $auth, $content );
        return unless $content;
    }

    # content is passed as reference
    return ($p, $data, ($content ? \$content : undef));
}

# for simple status queries, argus, debugging
# this is not an RFC compliant http server
sub _read_http {

lib/AC/Yenta/Protocol.pm  view on Meta::CPAN

    my($get, $url, $http) = split /\s+/, $io->{rbuffer};

    return ( { type => 'http', method => $get }, $url );
}

################################################################

sub _decrypt_data {
    my $me   = shift;
    my $io   = shift;
    my $auth = shift;
    my $data = shift;

    eval {
        $data = $me->decrypt( $auth, $data );
    };
    if(my $e=$@){
        verbose("cannot decrypt protocol data: $e");
        $io->run_callback('error', {
            cause	=> 'read',
            error	=> "cannot decrypt protocol: $e",
        });
        $io->shut();
        return;
    }

lib/AC/Yenta/Protocol.pm  view on Meta::CPAN

sub use_encryption {
    my $peer = shift;

    return unless conf_value('secret');
    # only encrypt far-away traffic, not local
    return $peer->{datacenter} ne my_datacenter();
}

sub encrypt {
    my $me    = shift;
    my $auth  = shift;	# not currently used
    my $buf   = shift;

    my $secret = $me->{secret};
    return $buf unless $secret;
    return unless $buf;
    my $crypto = AC::Yenta::Crypto->new( $secret );
    return $crypto->encrypt( $buf );
}

sub decrypt {

proto/auth.proto  view on Meta::CPAN

// Copyright (c) 2009 AdCopy
// Author: Jeff Weisberg
// Created: 2009-Sep-10 13:18 (EDT)
// Function: protocol authentication
//
// $Id$

message ACPAuth {
        required string         algorithm       = 1;
        // NYI
}

message ACPEncrypt {



( run in 1.356 second using v1.01-cache-2.11-cpan-5c0b1e786e0 )