← Index
NYTProf Performance Profile   « line view »
For /usr/local/bin/sa-learn
  Run on Sun Nov 5 02:36:06 2017
Reported on Sun Nov 5 02:56:21 2017

Filename/usr/local/lib/perl5/5.24/Net/Config.pm
StatementsExecuted 51 statements in 4.91ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1112.59ms2.59msNet::Config::::CORE:gpwuidNet::Config::CORE:gpwuid (opcode)
131145µs45µsNet::Config::::CORE:matchNet::Config::CORE:match (opcode)
11141µs41µsNet::Config::::BEGIN@13Net::Config::BEGIN@13
22137µs37µsNet::Config::::CORE:ftfileNet::Config::CORE:ftfile (opcode)
11132µs199µsNet::Config::::BEGIN@19Net::Config::BEGIN@19
11129µs120µsNet::Config::::BEGIN@18Net::Config::BEGIN@18
11123µs23µsNet::Config::::CORE:substNet::Config::CORE:subst (opcode)
11122µs42µsNet::Config::::BEGIN@15Net::Config::BEGIN@15
11120µs45µsNet::Config::::BEGIN@16Net::Config::BEGIN@16
0000s0sNet::Config::::requires_firewallNet::Config::requires_firewall
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1# Net::Config.pm
2#
3# Versions up to 1.11 Copyright (c) 2000 Graham Barr <gbarr@pobox.com>.
4# All rights reserved.
5# Changes in Version 1.11_01 onwards Copyright (C) 2013-2014 Steve Hay. All
6# rights reserved.
7# This module is free software; you can redistribute it and/or modify it under
8# the same terms as Perl itself, i.e. under the terms of either the GNU General
9# Public License or the Artistic License, as specified in the F<LICENCE> file.
10
11package Net::Config;
12
132108µs141µs
# spent 41µs within Net::Config::BEGIN@13 which was called: # once (41µs+0s) by Net::SMTP::BEGIN@21 at line 13
use 5.008001;
# spent 41µs making 1 call to Net::Config::BEGIN@13
14
15267µs262µs
# spent 42µs (22+20) within Net::Config::BEGIN@15 which was called: # once (22µs+20µs) by Net::SMTP::BEGIN@21 at line 15
use strict;
# spent 42µs making 1 call to Net::Config::BEGIN@15 # spent 20µs making 1 call to strict::import
16272µs270µs
# spent 45µs (20+25) within Net::Config::BEGIN@16 which was called: # once (20µs+25µs) by Net::SMTP::BEGIN@21 at line 16
use warnings;
# spent 45µs making 1 call to Net::Config::BEGIN@16 # spent 25µs making 1 call to warnings::import
17
18288µs2210µs
# spent 120µs (29+91) within Net::Config::BEGIN@18 which was called: # once (29µs+91µs) by Net::SMTP::BEGIN@21 at line 18
use Exporter;
# spent 120µs making 1 call to Net::Config::BEGIN@18 # spent 91µs making 1 call to Exporter::import
1921.31ms2366µs
# spent 199µs (32+167) within Net::Config::BEGIN@19 which was called: # once (32µs+167µs) by Net::SMTP::BEGIN@21 at line 19
use Socket qw(inet_aton inet_ntoa);
# spent 199µs making 1 call to Net::Config::BEGIN@19 # spent 167µs making 1 call to Exporter::import
20
2118µsour @EXPORT = qw(%NetConfig);
22114µsour @ISA = qw(Net::LocalCfg Exporter);
2312µsour $VERSION = "3.08_01";
24
25our($CONFIGURE, $LIBNET_CFG);
26
2712µseval {
2815µs local @INC = @INC;
2912µs pop @INC if $INC[-1] eq '.';
3014µs local $SIG{__DIE__};
311143µs require Net::LocalCfg;
32};
33
34114µsour %NetConfig = (
35 nntp_hosts => [],
36 snpp_hosts => [],
37 pop3_hosts => [],
38 smtp_hosts => [],
39 ph_hosts => [],
40 daytime_hosts => [],
41 time_hosts => [],
42 inet_domain => undef,
43 ftp_firewall => undef,
44 ftp_ext_passive => 1,
45 ftp_int_passive => 1,
46 test_hosts => 1,
47 test_exist => 1,
48);
49
50#
51# Try to get as much configuration info as possible from InternetConfig
52#
53{
54## no critic (BuiltinFunctions::ProhibitStringyEval)
5527µs$^O eq 'MacOS' and eval <<TRY_INTERNET_CONFIG;
56use Mac::InternetConfig;
57
58{
59my %nc = (
60 nntp_hosts => [ \$InternetConfig{ kICNNTPHost() } ],
61 pop3_hosts => [ \$InternetConfig{ kICMailAccount() } =~ /\@(.*)/ ],
62 smtp_hosts => [ \$InternetConfig{ kICSMTPHost() } ],
63 ftp_testhost => \$InternetConfig{ kICFTPHost() } ? \$InternetConfig{ kICFTPHost()} : undef,
64 ph_hosts => [ \$InternetConfig{ kICPhHost() } ],
65 ftp_ext_passive => \$InternetConfig{"646F676F\xA5UsePassiveMode"} || 0,
66 ftp_int_passive => \$InternetConfig{"646F676F\xA5UsePassiveMode"} || 0,
67 socks_hosts =>
68 \$InternetConfig{ kICUseSocks() } ? [ \$InternetConfig{ kICSocksHost() } ] : [],
69 ftp_firewall =>
70 \$InternetConfig{ kICUseFTPProxy() } ? [ \$InternetConfig{ kICFTPProxyHost() } ] : [],
71);
72\@NetConfig{keys %nc} = values %nc;
73}
74TRY_INTERNET_CONFIG
75}
76
7712µsmy $file = __FILE__;
7811µsmy $ref;
79139µs123µs$file =~ s/Config.pm/libnet.cfg/;
# spent 23µs making 1 call to Net::Config::CORE:subst
80136µs123µsif (-f $file) {
# spent 23µs making 1 call to Net::Config::CORE:ftfile
81 $ref = eval { local $SIG{__DIE__}; do $file };
82 if (ref($ref) eq 'HASH') {
83 %NetConfig = (%NetConfig, %{$ref});
84 $LIBNET_CFG = $file;
85 }
86}
8716µsif ($< == $> and !$CONFIGURE) {
8832.63ms12.59ms my $home = eval { local $SIG{__DIE__}; (getpwuid($>))[7] } || $ENV{HOME};
# spent 2.59ms making 1 call to Net::Config::CORE:gpwuid
8917µs $home ||= $ENV{HOMEDRIVE} . ($ENV{HOMEPATH} || '') if defined $ENV{HOMEDRIVE};
9014µs if (defined $home) {
9118µs $file = $home . "/.libnetrc";
92122µs114µs $ref = eval { local $SIG{__DIE__}; do $file } if -f $file;
# spent 14µs making 1 call to Net::Config::CORE:ftfile
9313µs %NetConfig = (%NetConfig, %{$ref})
94 if ref($ref) eq 'HASH';
95 }
96}
9712µsmy ($k, $v);
9818µswhile (($k, $v) = each %NetConfig) {
9913199µs1345µs $NetConfig{$k} = [$v]
# spent 45µs making 13 calls to Net::Config::CORE:match, avg 3µs/call
100 if ($k =~ /_hosts$/ and $k ne "test_hosts" and defined($v) and !ref($v));
101}
102
103# Take a hostname and determine if it is inside the firewall
104
105
106sub requires_firewall {
107 shift; # ignore package
108 my $host = shift;
109
110 return 0 unless defined $NetConfig{'ftp_firewall'};
111
112 $host = inet_aton($host) or return -1;
113 $host = inet_ntoa($host);
114
115 if (exists $NetConfig{'local_netmask'}) {
116 my $quad = unpack("N", pack("C*", split(/\./, $host)));
117 my $list = $NetConfig{'local_netmask'};
118 $list = [$list] unless ref($list);
119 foreach (@$list) {
120 my ($net, $bits) = (m#^(\d+\.\d+\.\d+\.\d+)/(\d+)$#) or next;
121 my $mask = ~0 << (32 - $bits);
122 my $addr = unpack("N", pack("C*", split(/\./, $net)));
123
124 return 0 if (($addr & $mask) == ($quad & $mask));
125 }
126 return 1;
127 }
128
129 return 0;
130}
131
132114µs*is_external = \&requires_firewall;
133
134178µs1;
135
136__END__
 
# spent 37µs within Net::Config::CORE:ftfile which was called 2 times, avg 19µs/call: # once (23µs+0s) by Net::SMTP::BEGIN@21 at line 80 # once (14µs+0s) by Net::SMTP::BEGIN@21 at line 92
sub Net::Config::CORE:ftfile; # opcode
# spent 2.59ms within Net::Config::CORE:gpwuid which was called: # once (2.59ms+0s) by Net::SMTP::BEGIN@21 at line 88
sub Net::Config::CORE:gpwuid; # opcode
# spent 45µs within Net::Config::CORE:match which was called 13 times, avg 3µs/call: # 13 times (45µs+0s) by Net::SMTP::BEGIN@21 at line 99, avg 3µs/call
sub Net::Config::CORE:match; # opcode
# spent 23µs within Net::Config::CORE:subst which was called: # once (23µs+0s) by Net::SMTP::BEGIN@21 at line 79
sub Net::Config::CORE:subst; # opcode