line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#$Id: hubcli.pm 998 2013-08-14 12:21:20Z pro $ $URL: svn://svn.setun.net/dcppp/trunk/lib/Net/DirectConnect/hubcli.pm $ |
2
|
|
|
|
|
|
|
#reserved for future 8), but something works |
3
|
|
|
|
|
|
|
package #hide from cpan |
4
|
|
|
|
|
|
|
Net::DirectConnect::hubcli; |
5
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
6
|
1
|
|
|
1
|
|
4
|
no strict qw(refs); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
7
|
1
|
|
|
1
|
|
5
|
use warnings "NONFATAL" => "all"; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
8
|
1
|
|
|
1
|
|
5
|
no warnings qw(uninitialized); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
53
|
|
9
|
1
|
|
|
1
|
|
5
|
no if $] >= 5.017011, warnings => 'experimental::smartmatch'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
10
|
1
|
|
|
1
|
|
48
|
use Net::DirectConnect; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
16
|
|
11
|
1
|
|
|
1
|
|
14
|
use Data::Dumper; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
108
|
|
12
|
|
|
|
|
|
|
$Data::Dumper::Sortkeys = 1; |
13
|
|
|
|
|
|
|
our $VERSION = ( split( ' ', '$Revision: 998 $' ) )[1]; |
14
|
1
|
|
|
1
|
|
4
|
use base 'Net::DirectConnect'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
940
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub init { |
17
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
18
|
0
|
|
|
|
|
|
%$self = ( %$self,, @_ ); |
19
|
|
|
|
|
|
|
#$self->baseinit(); |
20
|
0
|
|
|
|
|
|
$self->get_peer_addr(); |
21
|
0
|
0
|
|
|
|
|
$self->log( 'info', "[$self->{'number'}] Incoming client $self->{'host'}:$self->{'port'}" ) if $self->{'incoming'}; |
22
|
|
|
|
|
|
|
$self->{'parse'} ||= { |
23
|
|
|
|
|
|
|
'Supports' => sub { |
24
|
|
|
|
|
|
|
#$self->supports_parse( $_[0], $self->{'NickList'}->{ $self->{'peernick'} } ); |
25
|
0
|
|
|
0
|
|
|
$self->supports_parse( $_[0], $self->{'peer_supports'} ); |
26
|
|
|
|
|
|
|
}, |
27
|
0
|
|
|
0
|
|
|
'Key' => sub { |
28
|
|
|
|
|
|
|
}, |
29
|
|
|
|
|
|
|
'ValidateNick' => sub { |
30
|
|
|
|
|
|
|
#$self->log('dev', 'denide', $_[0], Dumper $self->{'NickList'}), |
31
|
|
|
|
|
|
|
#!return $self->cmd('ValidateDenide') if exists $self->{'NickList'}{ $_[0] } and $self->{'NickList'}{ $_[0] }{'online'}; |
32
|
0
|
|
|
0
|
|
|
$self->{'peer_nick'} = $_[0]; |
33
|
0
|
|
|
|
|
|
$self->{'NickList'}->{ $self->{'peer_nick'} } = $self->{'peer_supports'}; |
34
|
0
|
|
|
|
|
|
$self->{'status'} = 'connected'; |
35
|
0
|
|
|
|
|
|
$self->cmd('Hello'); |
36
|
|
|
|
|
|
|
}, |
37
|
|
|
|
|
|
|
'Version' => sub { |
38
|
0
|
|
|
0
|
|
|
$self->{'NickList'}{ $self->{'peer_nick'} }{'Version'} = $_[0]; |
39
|
|
|
|
|
|
|
}, |
40
|
|
|
|
|
|
|
'GetNickList' => sub { |
41
|
0
|
|
|
0
|
|
|
$self->cmd('NickList'); |
42
|
0
|
|
|
|
|
|
$self->cmd('OpList'); |
43
|
|
|
|
|
|
|
}, |
44
|
|
|
|
|
|
|
'MyINFO' => sub { |
45
|
0
|
|
|
0
|
|
|
my ( $nick, $info ) = $_[0] =~ /\S+\s+(\S+)\s+(.*)/; |
46
|
0
|
0
|
|
|
|
|
return if $nick ne $self->{'peer_nick'}; |
47
|
0
|
|
|
|
|
|
$self->{'NickList'}{$nick}{'Nick'} = $nick; |
48
|
0
|
|
|
|
|
|
$self->info_parse( $info, $self->{'NickList'}{$nick} ); |
49
|
0
|
|
|
|
|
|
$self->{'NickList'}{$nick}{'online'} = 1; |
50
|
|
|
|
|
|
|
}, |
51
|
|
|
|
|
|
|
'GetINFO' => sub { |
52
|
0
|
|
|
0
|
|
|
my $to = shift; |
53
|
|
|
|
|
|
|
}, |
54
|
|
|
|
|
|
|
'chatline' => sub { |
55
|
0
|
|
|
0
|
|
|
$self->{'parent'}->rcmd( 'chatline', @_ ); |
56
|
|
|
|
|
|
|
}, |
57
|
0
|
|
0
|
|
|
|
}; |
58
|
|
|
|
|
|
|
$self->{'cmd'} ||= { |
59
|
0
|
|
|
0
|
|
|
'Lock' => sub { $self->sendcmd( 'Lock', $self->{'Lock'} ); }, |
60
|
0
|
|
|
0
|
|
|
'HubName' => sub { $self->sendcmd( 'HubName', $self->{'HubName'} ); }, |
61
|
0
|
|
|
0
|
|
|
'ValidateDenide' => sub { $self->sendcmd('ValidateDenide'); }, |
62
|
0
|
|
|
0
|
|
|
'Hello' => sub { $self->sendcmd( 'Hello', $self->{'peer_nick'} ); }, |
63
|
|
|
|
|
|
|
'NickList' => sub { |
64
|
0
|
|
|
0
|
|
|
$self->sendcmd( 'NickList', join '$$', grep { !$self->{'NickList'}{$_}{'oper'} } keys %{ $self->{'NickList'} } ); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
}, |
66
|
|
|
|
|
|
|
'OpList' => sub { |
67
|
0
|
|
|
0
|
|
|
$self->sendcmd( 'OpList', join '$$', grep { $self->{'NickList'}{$_}{'oper'} } keys %{ $self->{'NickList'} } ); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
}, |
69
|
|
|
|
|
|
|
'chatline_from' => sub { |
70
|
0
|
|
|
0
|
|
|
my $from = shift; |
71
|
|
|
|
|
|
|
#return if $self->{'_chatline_rec'}; |
72
|
0
|
|
|
|
|
|
for (@_) { |
73
|
0
|
0
|
|
|
|
|
return unless $self->{'socket'}; |
74
|
0
|
|
|
|
|
|
$self->log( 'dcdmp', "($self->{'number'}) we send [", "<$from> $_|", "]:", $self->{'socket'}->send("<$from> $_|"), $! ); |
75
|
|
|
|
|
|
|
#$self->log('dbg', 'sleep', $self->{'min_chat_delay'}), |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
}, |
78
|
|
|
|
|
|
|
'chatline' => sub { |
79
|
0
|
|
|
0
|
|
|
my ( $nick, $text ) = $_[0] =~ /^<([^>]+)> (.+)$/; |
80
|
|
|
|
|
|
|
#$self->{'_chatline_rec'} = 1; |
81
|
0
|
|
|
|
|
|
$self->log( 'dbg', "[$self->{'number'}]", 'chatline Rstart', ); |
82
|
0
|
0
|
|
|
|
|
$self->log( 'dbg', "[$self->{'number'}] to", $_->{'number'} ), |
83
|
|
|
|
|
|
|
#TO API |
84
|
|
|
|
|
|
|
$_->cmd( 'chatline_from', $self->{'peer_nick'}, $text ) |
85
|
0
|
|
|
|
|
|
for grep { $_ and $_ ne $self } values( %{ $self->{'parent'}{'clients'} } ); |
|
0
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
#$self->{'parent'}->rcmd('chatline_from', $self->{'peer_nick'}, $text); |
87
|
|
|
|
|
|
|
#delete $self->{'_chatline_rec'}; |
88
|
|
|
|
|
|
|
}, |
89
|
0
|
|
0
|
|
|
|
}; |
90
|
|
|
|
|
|
|
$self->{'handler_int'} ||= { |
91
|
|
|
|
|
|
|
'disconnect_aft' => sub { |
92
|
|
|
|
|
|
|
#$self->{'NickList'}{$self->{'peer_nick'}}{'online'} = 0; |
93
|
0
|
|
|
0
|
|
|
delete $self->{'NickList'}{ $self->{'peer_nick'} }; |
94
|
0
|
|
|
|
|
|
$self->log( 'dev', 'deleted', $self->{'peer_nick'}, Dumper $self->{'NickList'} ); |
95
|
|
|
|
|
|
|
}, |
96
|
0
|
|
0
|
|
|
|
}; |
97
|
0
|
|
|
|
|
|
$self->{'sendbuf'} = 1; |
98
|
0
|
|
|
|
|
|
$self->cmd('Lock'); |
99
|
0
|
|
|
|
|
|
$self->{'sendbuf'} = 0; |
100
|
0
|
|
|
|
|
|
$self->cmd('HubName'); |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
1; |