How to pass IPv6 parameter for snmp session creation using - perl

I am using SNMP package to create SNMPv3 session. But I am not sure how to pass transport information as UDP6 as I think default behavior is UDP. As far as I know that when use Net::SNMP to create session then we have "domain" parameter to classify between ipv4 and ipv6 address . But the same is not applicable to SNMP::Session. Can you please let me know how to pass transport information?
new SNMP::Session(DestHost => $self->{'ip'},
version => 3,
RemotePort => $self->{'port'},
SecEngineId => ‘0x8888233356',
SecName => $hashVal{'userName'},
AuthProto => $authProto,
AuthPass => $hashVal{'authPW'},
PrivProto => $privProto,
PrivPass => $hashVal{'privPW'},
SecLevel => $hashVal{‘secLevel’');

Related

external distributed memcache not workking

this is my first post on here.
I installed the latest version of Nextcloud (19.0.0) on one machine and try to split all the services to different vm's. that means DB (mariadb), Storage, redis (for file locking), memcached (distributed cache) on different machines, all of which are running Ubuntu 20.04 LTS. This setup is a bit janky, but it helps me better understand, how each service functions. The DB-Server and Redis are working fine. Now I want to get memcached to work. as soon as i add the parameters i get an internal server error. this is what I have in my config.php
array (
0 => '10.10.10.45',
1 => 'nextcloudtest.test.lan',
),
'datadirectory' => '/nextcloud-data',
'dbtype' => 'mysql',
'version' => '19.0.0.12',
'overwrite.cli.url' => 'https://nextcloudtest.test.lan',
'htaccess.RewriteBase' => '/',
'dbname' => 'nextcloud',
'dbhost' => '10.10.10.49',
'dbport' => '3306',
'dbtableprefix' => 'oc_',
'mysql.utf8mb4' => true,
'dbuser' => 'nextcloud',
'dbpassword' => 'password',
'installed' => true,
// 'memcache.local' => '\OC\Memcache\APCu',
'memcache.distributed' => '\\OC\Memcache\\Memcached',
'memcached_servers' => array(
array('10.10.10.47', 11211),
),
'memcache.locking' => '\\OC\\Memcache\\Redis',
'filelocking.enabled' => 'true',
'redis' =>
array (
'host' => '10.10.10.46',
'port' =>6379,
'timeout' => 0.0,
),
);
Then i get this error in the nextcloud.log
\\OC\\Memcache\\Memcached not available for distributed cache","Code":0
I did set the bind address in the memcached.conf to 0.0.0.0 so it accepts all incoming connections and also added a rule to the firewall to allow incoming connections on port 11211.
I hope you guys cane give me some tipps.

Perl using USAePay billing module

I was wondering if anybody has experience using the USAePay billing module? I have reached out to the developer and his response was he does not have time to help people. My problem is this -
I have written the following code to add a customer's billing information using the Sandbox server but it looks as though the module defaults to the production server so each time I attempt to validate the transaction I get the response -
Card was rejected: Specified source key not found.
How do I tell it to use the Sandbox server?
use strict;
use warnings;
use Business::OnlinePayment;
use constant {
LOGIN => 'source key', #USAePay source key
PASSWORD => '12345', #USAePay PIN
};
my $tx = new Business::OnlinePayment("USAePay");
$tx->content(
login => LOGIN,
password => PASSWORD,
type => 'CC',
action => 'Recurring Authorization',
description => 'Business::OnlinePayment test',
amount => '49.95',
invoice_number => '100100',
name => 'Tofu Beast',
card_number => '4000100011112224',
expiration => '09/19',
address => '1234 Bean Curd Lane',
city => 'San Francisco',
state => 'CA',
zip => '94102',
);
$tx->submit();
if($tx->is_success()) {
print 'Card processed successfully: '.$tx->authorization.'\n';
} else {
print 'Card was rejected: '.$tx->error_message."\n";
}
As Business::OnlinePayment::USAePay is a processor for Business::OnlinePayment, but doesn't have a lot of docs itself, a look at the docs of Business::OnlinePayment might help. It reveales the test_transaction method.
Most processors provide a test mode, where submitted transactions will not actually be charged or added to your batch, calling this function with a true argument will turn that mode on if the processor supports it, or generate a fatal error if the processor does not support a test mode (which is probably better than accidentally making real charges).
An untested example:
my $tx = new Business::OnlinePayment("USAePay");
$tx->test_transaction; # here
$tx->content(
login => LOGIN,
password => PASSWORD,
type => 'CC',
action => 'Recurring Authorization',
description => 'Business::OnlinePayment test',
amount => '49.95',
invoice_number => '100100',
name => 'Tofu Beast',
card_number => '4000100011112224',
expiration => '09/19',
address => '1234 Bean Curd Lane',
city => 'San Francisco',
state => 'CA',
zip => '94102',
);
$tx->submit();
Digging a bit deeper in the source of Business::OnlinePayment::USAePay shows that this particular processor actually has three different test modes.
# test_transaction(0): normal mode
# 1 : test mode (validates formatting only)
# 2 : use sandbox server
# 3 : test mode on sandbox server
It looks like you can set the server details in the constructor - it takes an optional hash of parameters beyond the processor name.
Have you tried something like:
my $tx = new Business::OnlinePayment(
"USAePay",
Server => 'https://sandbox.usaepay.com/gate'
);

Send trap with Perl (net-snmp)

I run snmptrapd and can see incoming trap, when send trap via snmptrap
snmptrap -c public -v 2c localhost "" 1.3.3.3.3.3.3.3 1.2.2.2.2.2.2 s "Aliens here"
But I no have trap, when send via Perl script
use SNMP;
$sess = new SNMP::Session(DestHost => '127.0.0.1', RemotePort => "162" );
$sess->trap(enterprise=>'.1.3.6.1.4.1.2021', # or 'ucdavis' [default]
agent => '127.0.0.1', # or 'localhost',[dflt 1st intf on host]
generic => specific, # can be omitted if 'specific' supplied
specific => 5, # can be omitted if 'generic' supplied
uptime => 1234, # dflt to localhost uptime (0 on win32)
[[ifIndex, 1, 1],[sysLocation, 0, "here"]]);
What's wrong?
Your second version i.e. the perl one is not specifying community or version, unlike the first one. Try adding them
$sess = new SNMP::Session(DestHost => '127.0.0.1',
RemotePort => "162",
Community => "public,
Version => 2);
Also see http://www.remothelast.altervista.org/SNMP_Perl.html
and http://www.net-snmp.org/docs/perl-SNMP-README.html for SNMP::Session usage.

How to manipulate and send packets caught with Net::PCAP on windows

I need to change the tcp/ip headers of packets caught with Net::PCAP. I know this is possible with Net::RawIP, but this doesn't work under windows?
Is there a module for this that works with windows? Is there at least to do this in windows with another programming language that I can call in perl, such as C?
To demonstrate what I want to do, here is the code using Net::RawIP, which does not work under windows because I can't install the module:
$n = Net::RawIP->new({
ip => {
saddr => 'my.target.lan',
daddr => 'my.target.lan',
},
tcp => {
source => 139,
dest => 139,
psh => 1,
syn => 1,
data => $your_data
},
});
$n->send();
Try pcap_sendpacket using this per module https://metacpan.org/pod/Net::Pcap

How to use Zend_Mail_Transport_Smtp with hosted Google Apps?

So I'm under the impression that bad things will happen if I don't use Zend_Mail_Transport_Smtp when sending lots of emails. Problem is...I can't figure out how to set it up. I am using Google Apps hosted email for my domain. So to access my email, I go to mail.mydomain.com, which takes me to a google login page.
This is the code that I am using, but it's not working.
$config = array('ssl' => 'tls', 'port' => 587, 'auth' => 'login', 'username' => 'webmaster#mydomain.com', 'password' => 'password');
$smtpConnection = new Zend_Mail_Transport_Smtp('mail.mydomain.com', $config);
Using "mail.mydomain.com" I get a "connection timed out" error (which makes me think its the wrong thing to use.
Using "smtp.mydomain.com" I get a "Could not open socket" error.
What am I doing wrong?
Since you are sending emails through gmail, you should use "smtp.gmail.com" and not your domain.
$config = array('ssl' => 'tls', 'port' => 587, 'auth' => 'login', 'username' => 'webmaster#mydomain.com', 'password' => 'password');
$smtpConnection = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $config);
Some more reference. Check the port using port scanner on remote end which are open, do a test if they reply packets, sometimes port 25 is not working so email fails, and also the SSL or TLS.
$config = array(
'ssl' => 'ssl', //TLS = tcp:// use port 25
//SSL = ssl:// use port 465 or 587
'port' => 465,
'auth' => 'login',
'username'=> 'x',
'password'=> 'b/c',
);
$tr = new Zend_Mail_Transport_Smtp('email-smtp.us-east-1.amazonaws.com', $config);
Zend_Mail::setDefaultTransport($tr);