~ubuntu-branches/debian/experimental/smokeping/experimental

« back to all changes in this revision

Viewing changes to lib/Smokeping/probes/SipSak.pm

  • Committer: Package Import Robot
  • Author(s): Antoine Beaupré
  • Date: 2013-03-16 11:34:03 UTC
  • mfrom: (1.3.1) (7.1.5 sid)
  • Revision ID: package-import@ubuntu.com-20130316113403-ht1ik5dtc457l6jj
Tags: 2.6.9-1~exp0
* New upstream release to properly fix CVE-2012-0790 (Closes: #659899)
* Acknowledge the NMU, thanks gregor!

Show diffs side-by-side

added added

removed removed

Lines of Context:
58
58
    my @times;
59
59
    my $elapsed;
60
60
    my $pingcount = $self->pings($target);
 
61
    my $keep = $vars->{keep_second};
61
62
    $host = $vars->{user}.'@'.$host if $vars->{user};
62
 
    $host = $host . ':' . $vars->{port} if $vars->{port};    
 
63
    $host = $host . ':' . $vars->{port} if $vars->{port};        
63
64
    my @extra_opts = ();
64
65
    @extra_opts = split /\s/, $vars->{params} if $vars->{params};
65
66
    open (my $sak,'-|',$self->{properties}{binary},'-vv','-A',$pingcount,'-s','sip:'.$host,@extra_opts)
66
67
        or die("ERROR: $target->{binary}: $!\n");
67
 
    while(<$sak>){    
68
 
        chomp;
69
 
        if (/^(?:\s+and|\*\*\sreply\sreceived\safter)\s(\d+(?:\.\d+))\sms\s/){  
 
68
    my $reply = join ("",<$sak>);
 
69
    close $sak;
 
70
 
 
71
    my @reply = split /\*\*\sreply/, $reply;
 
72
    # don't need the stuff before the first replyx
 
73
    shift @reply;
 
74
 
 
75
    my $filter = '.*';
 
76
    $self->do_debug("SipSak: got ".(scalar @reply)." replies, expected $pingcount");
 
77
    if (scalar @reply > $pingcount){
 
78
        $filter = $keep eq 'yes' ? 'final received' : 'provisional received';
 
79
    }
 
80
    for my $item (@reply){
 
81
        $self->do_debug("SipSak: looking at '$item'");
 
82
        if (not $item =~ /$filter/){
 
83
            $self->do_debug("SipSak: skipping as there was not match for $filter");
 
84
            next;
 
85
        }
 
86
        if ($item =~ /(?:\sand|\sreceived\safter)\s(\d+(?:\.\d+)?)\sms\s/){
 
87
            $self->do_debug("SipSak: match");
70
88
            push @times,$1/1000;
71
89
        }
 
90
        else {
 
91
            $self->do_debug("SipSak: no match");
 
92
        }
72
93
    }
73
 
    close $sak;
74
94
    return sort { $a <=> $b } @times;
75
95
}
76
96
 
105
125
            _doc => "additional sipsak options. The options will get split on space.",
106
126
            _example => '--numeric --password=mysecret'
107
127
        },        
 
128
        keep_second => {
 
129
            _doc => "If OPTIONS is actually implemented by the server, SipSak will receive two responses. If this option is set, the timeing from the second, final response will be counter",
 
130
            _example => 'yes',
 
131
            _re => 'yes|no'
 
132
            
 
133
        }
108
134
    });
109
135
}
110
136