This file is indexed.

/usr/share/perl5/Transmission/Session.pm is in libtransmission-client-perl 0.0805-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
# ex:ts=4:sw=4:sts=4:et
package Transmission::Session;
# See Transmission::Client for copyright statement.

=head1 NAME

Transmission::Session - Transmission session

=head1 DESCRIPTION

See "4 Session requests" from
L<https://trac.transmissionbt.com/browser/trunk/extras/rpc-spec.txt>

This class holds data, regarding the Transmission session.

=cut

use Moose;
use Transmission::Types ':all';
use Transmission::Stats;

BEGIN {
    with 'Transmission::AttributeRole';
}

=head1 ATTRIBUTES

=head2 stats

 $stats_obj = $self->stats;
 
Returns a L<Transmission::Stats> object.

=cut

has stats => (
    is => 'ro',
    isa => 'Object',
    lazy => 1,
    default => sub {
        Transmission::Stats->new(client => $_[0]->client);
    }
);

=head2 alt_speed_down

 $number = $self->alt_speed_down

max global download speed (in K/s)

=head2 alt_speed_enabled

 $boolean = $self->alt_speed_enabled

true means use the alt speeds

=head2 alt_speed_time_begin

 $number = $self->alt_speed_time_begin

when to turn on alt speeds (units: minutes after midnight)

=head2 alt_speed_time_enabled

 $boolean = $self->alt_speed_time_enabled

true means the scheduled on/off times are used

=head2 alt_speed_time_end

 $number = $self->alt_speed_time_end

when to turn off alt speeds (units: same)

=head2 alt_speed_time_day

 $number = $self->alt_speed_time_day

what day(s) to turn on alt speeds (look at tr_sched_day)

=head2 alt_speed_up

 $number = $self->alt_speed_up

max global upload speed (in K/s)

=head2 blocklist_enabled

 $boolean = $self->blocklist_enabled

true means enabled

=head2 dht_enabled

 $boolean = $self->dht_enabled

true means allow dht in public torrents

=head2 encryption

 $string = $self->encryption

"required", "preferred", "tolerated"

=head2 download_dir

 $string = $self->download_dir

default path to download torrents

=head2 peer_limit_global

 $number = $self->peer_limit_global

maximum global number of peers

=head2 peer_limit_per_torrent

 $number = $self->peer_limit_per_torrent

maximum global number of peers

=head2 pex_enabled

 $boolean = $self->pex_enabled

true means allow pex in public torrents

=head2 peer_port

 $number = $self->peer_port

port number

=head2 peer_port_random_on_start

 $boolean = $self->peer_port_random_on_start

true means pick a random peer port on launch

=head2 port_forwarding_enabled

 $boolean = $self->port_forwarding_enabled

true means enabled

=head2 seedRatioLimit

 $double = $self->seedRatioLimit

the default seed ratio for torrents to use

=head2 seedRatioLimited

 $boolean = $self->seedRatioLimited

true if seedRatioLimit is honored by default

=head2 speed_limit_down

 $number = $self->speed_limit_down

max global download speed (in K/s)

=head2 speed_limit_down_enabled

 $boolean = $self->speed_limit_down_enabled

true means enabled

=head2 speed_limit_up

 $number = $self->speed_limit_up

max global upload speed (in K/s)

=head2 speed_limit_up_enabled

 $boolean = $self->speed_limit_up_enabled

true means enabled

=cut

BEGIN {
    my %both = (
        'alt-speed-down'             => number,
        'alt-speed-enabled'          => boolean,
        'alt-speed-time-begin'       => number,
        'alt-speed-time-enabled'     => boolean,
        'alt-speed-time-end'         => number,
        'alt-speed-time-day'         => number,
        'alt-speed-up'               => number,
        'blocklist-enabled'          => boolean,
        'dht-enabled'                => boolean,
        'encryption'                 => string,
        'download-dir'               => string,
        'peer-limit-global'          => number,
        'peer-limit-per-torrent'     => number,
        'pex-enabled'                => boolean,
        'peer-port'                  => number,
        'peer-port-random-on-start'  => boolean,
        'port-forwarding-enabled'    => boolean,
        'seedRatioLimit'             => number,
        'seedRatioLimited'           => boolean,
        'speed-limit-down'           => number,
        'speed-limit-down-enabled'   => boolean,
        'speed-limit-up'             => number,
        'speed-limit-up-enabled'     => boolean,
    );

    for my $camel (keys %both) {
        my $name = __PACKAGE__->_camel2Normal($camel);
        __PACKAGE__->meta->add_attribute($name => (
            is => 'rw',
            isa => $both{$camel},
            coerce => 1,
            lazy => 1,
            clearer => "clear_$name",
            trigger => sub {
                return if($_[0]->lazy_write);
                $_[0]->client->rpc('session-set' => $camel =>
                    ($both{$camel} eq boolean and $_[1])  ? 'true'
                  : ($both{$camel} eq boolean and !$_[1]) ? 'false'
                  :                                         $_[1]
                );
            },
            default => sub {
                my $self = shift;
                my $val = delete $self->_tmp_store->{$name};

                if(defined $val) {
                    return $val;
                }
                else {
                    $self->_clear_tmp_store;
                    return delete $self->_tmp_store->{$name};
                }
            },
        ));
    }

    __PACKAGE__->meta->add_attribute(_tmp_store => (
        is => 'ro',
        isa => 'HashRef',
        lazy => 1,
        builder => 'read_all',
        clearer => '_clear_tmp_store',
    ));

    __PACKAGE__->meta->add_method(read_all => sub {
        my $self = shift;
        my $lazy = $self->lazy_write;
        my($rpc, %res);

        $rpc = $self->client->rpc('session-get') or return;

        $self->lazy_write(1);

        for my $camel (keys %both) {
            my $name = __PACKAGE__->_camel2Normal($camel);
            $res{$name} = $rpc->{$camel};
            $self->$name($rpc->{$camel});
        }

        $self->lazy_write($lazy);

        return \%res;
 
    });
}

=head1 LICENSE

=head1 AUTHOR

See L<Transmission::Client>

=cut

1;