package My::parser::gitea_parser; use strict; use warnings; sub new { my $class = shift; my $self = {}; bless ($self, $class); return $self; } sub parser { my $self = shift; my $string = shift; my ($reply,$hostile,$host) = ("No match for $string",0,''); my $re_host = qr/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/; if($string =~ m/sshConnectionFailed/) { if($string =~ m/Failed connection from /) { $_ = $string; $reply = 'Failed connection'; $hostile = 1; PARSE: m/($re_host)\:[0-9]{1,6} /gcix && do { $host = $1; }; } elsif($string =~ m/Failed authentication attempt from /) { $_ = $string; $reply = 'Failed auth'; $hostile = 1; PARSE: m/($re_host)\:[0-9]{1,6}/gcix && do { $host = $1; }; } } else { $reply = 'non-ssh lines not supported yet'; } return { retval => 1, retmsg => $reply, hostile => $hostile, host => $host, string => $string }; } return 1;