line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package main;
|
2
|
|
|
|
|
|
|
$VERSION = '0.17';
|
3
|
1
|
|
|
1
|
|
13785
|
use Net::Shared::Local;
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
46
|
|
4
|
1
|
|
|
1
|
|
784
|
use Net::Shared::Remote;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
5
|
1
|
|
|
1
|
|
1470
|
use Net::Shared::Handler;
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
85
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
"JAPH";
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Net::Shared - Shared variables across processes that are either local or remote.
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 ABSTRACT
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Share data across local and remote processes.
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 SYNOPSIS
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
use Net::Shared;
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my $listen = new Net::Shared::Handler;
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my $new_shared = new Net::Shared::Local(name=>"new_shared", accept=>['127.0.0.1','164.107.70.126']);
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
my $remote_shared = new Net::Shared::Remote (name=>"remote_shared", ref=>"new_shared", port=>$new_shared->port, address=>'127.0.0.1');
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
$listen->add(\$new_shared, \$remote_shared);
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
$listen->store($new_shared, "One ");
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
print $listen->retrieve($new_shared);
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
$listen->store($remote_shared, [qw(and two.)]);
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
print $listen->retrieve($remote_shared);
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
$listen->destroy_all;
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 DESCRIPTION
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
C gives the ability to share variables across processes both local and remote.
|
44
|
|
|
|
|
|
|
C and C objects are created and interfaced with a
|
45
|
|
|
|
|
|
|
C object. Please see the documentation of the object types below and
|
46
|
|
|
|
|
|
|
also see the examples for more info.
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head2 Net::Shared
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Net::Shared itself is just a binding module. Using it will bring in Net::Shared::Local,
|
51
|
|
|
|
|
|
|
Net::Shared::Remote, and Net::Shared::Handler.
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head2 Net::Shared::Local
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
C is the class that is used to store the data. Interfacing directly
|
56
|
|
|
|
|
|
|
with C objects will almost never need to be done; C's.
|
57
|
|
|
|
|
|
|
interface should be sufficient. However, C does provide 2 useful methods:
|
58
|
|
|
|
|
|
|
lock and port. Lock functions like a file lock, and port returns the port number that the object
|
59
|
|
|
|
|
|
|
is listening on. See the methods section below for more details. The constructor to C
|
60
|
|
|
|
|
|
|
takes 1 argument: a hash. The hash can be configured to provide a number of
|
61
|
|
|
|
|
|
|
options:
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=over 3
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=item C
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
The name that you will use to refer to the variable; it is the only
|
68
|
|
|
|
|
|
|
required option. It can be anything; it does not have to be the same as the
|
69
|
|
|
|
|
|
|
variable itself. However, note that if C is going to be used on
|
70
|
|
|
|
|
|
|
another process, it will have to know the C of the shared variable to access it.
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=item C
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
C is an optional field used to designate which addresses to allow
|
75
|
|
|
|
|
|
|
access to the variable. C requires a reference to an array containing
|
76
|
|
|
|
|
|
|
the addresses to allow. C will default to localhost if it is not defined.
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=item C
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Specify which port to listen from; however, its probably best to let the OS pick
|
81
|
|
|
|
|
|
|
on unless C will be used.
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=item C
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
The signal sent to the object that means "send back stored data." Default
|
86
|
|
|
|
|
|
|
is '\bl\b'.
|
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=item C
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Set to a true value to turn on debuging for the object, which makes it
|
91
|
|
|
|
|
|
|
spew out all sorts of possibly useful info. Warning: VERY verbose.
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=back
|
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
As stated earlier, there are also 2 methods that can be called: port and
|
96
|
|
|
|
|
|
|
lock.
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=over 3
|
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=item C
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Returns the port number that the Net::Shared::Local object is listening on.
|
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=item C
|
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Works like a file lock; 0=not locked; 1=temp lock used during storage,
|
107
|
|
|
|
|
|
|
and 2=complete lock.
|
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=back
|
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head2 Net::Shared::Remote
|
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
C is an alias to accessing data stored by
|
114
|
|
|
|
|
|
|
Shared::Local objects on remote machines. C also takes
|
115
|
|
|
|
|
|
|
a hash as an argument, similarily to C. However,
|
116
|
|
|
|
|
|
|
C can take many more elements, and all of which are
|
117
|
|
|
|
|
|
|
required (except debug and response).
|
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=over 3
|
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=item C
|
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
The name that you will be using to reference this object.
|
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=item C[
] |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Ref will be the name of the Net::Shared::Local object on the machine that
|
128
|
|
|
|
|
|
|
you are accessing. You MUST correctly specify ref (think of it as
|
129
|
|
|
|
|
|
|
a "password") or you will be unable to access the data.
|
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=item C
|
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
The address of the machine where the data that you want to access is
|
134
|
|
|
|
|
|
|
located.
|
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=item C
|
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
The port number where the data is stored on the machine which you are
|
139
|
|
|
|
|
|
|
accessing
|
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=item C
|
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
The signal sent to the object that means "send back stored data." Default
|
144
|
|
|
|
|
|
|
is '\bl\b'. Needs to be the same as whatever the associated C
|
145
|
|
|
|
|
|
|
uses.
|
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=item C
|
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Set to a true value to turn on debuging for the object, which makes it
|
150
|
|
|
|
|
|
|
spew out all sorts of possibly useful info. Warning: VERY verbose.
|
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=back
|
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
There are no methods that you can access with C.
|
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head2 Net::Shared::Handler
|
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
C is the object used to interface with C
|
159
|
|
|
|
|
|
|
and C objects. You can think of C as
|
160
|
|
|
|
|
|
|
the class that actually all of the work: storing the data, retrieving the data, and
|
161
|
|
|
|
|
|
|
managing the objects. See method descriptions below for more info on methods. New
|
162
|
|
|
|
|
|
|
accepts 1 argument, and when set to a true value debugging is turned on (only for the Handler
|
163
|
|
|
|
|
|
|
object, however). Methods:
|
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=over 3
|
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=item C
|
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
Adds a list of C / C objects so that they
|
170
|
|
|
|
|
|
|
can be "managed." Nothing (storing/retrieving/etc) can be done with the
|
171
|
|
|
|
|
|
|
objects until they have been Ced, so don't forget to do it!
|
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=item C
|
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
C effectively kills any objects in C<@list> and all data in them, as
|
176
|
|
|
|
|
|
|
well as remove them from the management scheme.
|
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=item C
|
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
Stores the data in C<$object>, whether it be a C object or
|
181
|
|
|
|
|
|
|
C object. Note that storing data in a remote object is actually
|
182
|
|
|
|
|
|
|
just storing in the associated local object. Returns the number of bytes sent.
|
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=item C
|
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
Grabs the data out of C<$object>, and returns it value, in whatever form it was when
|
187
|
|
|
|
|
|
|
stored. That means if a hash is stored, a hash is returned, so remember to access
|
188
|
|
|
|
|
|
|
C in whatever context the data is expected in.
|
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=item C
|
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
Standard janitorial method. Call it at the end of every program in
|
193
|
|
|
|
|
|
|
which C Net::shared is used.
|
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=back
|
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=head1 CAVEATS
|
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
As of right now, there is no default encryption on the data, so if it is needed,
|
200
|
|
|
|
|
|
|
it will have to be used manually. That isn't to say the data is unprotected; there
|
201
|
|
|
|
|
|
|
is address and name checking on each end of the transfer. However, during transmission
|
202
|
|
|
|
|
|
|
the data might as well be in cleartext if a cracker knows it is sent via C.
|
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
Data is stored in memory, so one should be careful about storing large structures. Subclassing
|
205
|
|
|
|
|
|
|
C and redefining the private methods C and C to write and
|
206
|
|
|
|
|
|
|
retrieve from file rather than memory might be a good idea if large amounts of data needs to be stored.
|
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=head1 TODO
|
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=over 3
|
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=item Testing
|
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
This module needs LOTS of testing on many different platforms. Please email the author if any bugs are found.
|
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=item Encryption
|
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
It would be nice for the user to be able to pass a subroutine defining an
|
219
|
|
|
|
|
|
|
encryption scheme to use, or even to use C to automatically
|
220
|
|
|
|
|
|
|
encrypt the data if a flag is turned on.
|
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
=item Tied Interface
|
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
Because tied interfaces are easy to use...
|
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=back
|
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
=head1 AUTHOR
|
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
Joseph F. Ryan, ryan.311@osu.edu
|
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=head1 COPYRIGHT
|
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
Copyright (C) 2002 Joseph F. Ryan
|
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify
|
237
|
|
|
|
|
|
|
it under the same terms as Perl itself.
|
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
=cut |