CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/lib/rex/post/channel/container.rb
Views: 11623
1
# -*- coding: binary -*-
2
3
module Rex
4
module Post
5
module Channel
6
###
7
#
8
# This interface is meant to be included by things that are meant to contain
9
# zero or more channel instances in the form of a hash.
10
#
11
###
12
module Container
13
#
14
# Initializes the channel association hash
15
#
16
def initialize_channels
17
self.channels = {}
18
end
19
20
#
21
# Adds a channel to the container that is indexed by its channel identifier
22
#
23
def add_channel(channel)
24
channels[channel.cid] = channel
25
end
26
27
#
28
# Looks up a channel instance based on its channel identifier
29
#
30
def find_channel(cid)
31
return channels[cid]
32
end
33
34
#
35
# Removes a channel based on its channel identifier
36
#
37
def remove_channel(cid)
38
return channels.delete(cid)
39
end
40
41
#
42
# The hash of channels.
43
#
44
attr_reader :channels
45
46
protected
47
48
attr_writer :channels # :nodoc:
49
end
50
end
51
end
52
end
53
54