Class: Rex::Ui::Text::BidirectionalPipe
- Inherits:
-
Input
- Object
- Input
- Rex::Ui::Text::BidirectionalPipe
show all
- Defined in:
- lib/rex/ui/text/bidirectional_pipe.rb
Instance Attribute Summary collapse
Attributes inherited from Input
#config, #eof, #prompt_char
Instance Method Summary
collapse
Methods inherited from Input
#auto_color, #disable_color, #disable_readline, #enable_color, #enable_readline, #reset_color, #reset_tab_completion, #update_prompt
Constructor Details
Returns a new instance of BidirectionalPipe.
[View source] [
View on GitHub]
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/rex/ui/text/bidirectional_pipe.rb', line 9
def initialize
@subscribers_out = {}
@subscribers_ref = {}
@subscribers_idx = 0
@pipe_input = Rex::Ui::Text::Input::Buffer.new
self.output = self
self.input = self
end
|
Instance Attribute Details
Wrappers for shell methods
[
View on GitHub]
133
134
135
|
# File 'lib/rex/ui/text/bidirectional_pipe.rb', line 133
def input
@input
end
|
Wrappers for shell methods
[
View on GitHub]
133
134
135
|
# File 'lib/rex/ui/text/bidirectional_pipe.rb', line 133
def output
@output
end
|
Wrappers for shell methods
[
View on GitHub]
133
134
135
|
# File 'lib/rex/ui/text/bidirectional_pipe.rb', line 133
def prompt
@prompt
end
|
Instance Method Details
Wrappers for the pipe_input methods
[View source] [
View on GitHub]
105
106
107
|
# File 'lib/rex/ui/text/bidirectional_pipe.rb', line 105
def close
@pipe_input.close
end
|
permalink
#create_subscriber_proc(id = nil, &block) ⇒ Object
[View source] [
View on GitHub]
38
39
40
41
|
# File 'lib/rex/ui/text/bidirectional_pipe.rb', line 38
def create_subscriber_proc(id=nil, &block)
id = create_subscriber(id)
@subscribers_ref[id] = block
end
|
[View source] [
View on GitHub]
121
122
123
|
# File 'lib/rex/ui/text/bidirectional_pipe.rb', line 121
def eof?
@pipe_input.eof?
end
|
[View source] [
View on GitHub]
125
126
127
|
# File 'lib/rex/ui/text/bidirectional_pipe.rb', line 125
def fd
@pipe_input.fd
end
|
[View source] [
View on GitHub]
117
118
119
|
# File 'lib/rex/ui/text/bidirectional_pipe.rb', line 117
def gets
@pipe_input.gets
end
|
permalink
#has_subscriber?(id) ⇒ Boolean
[View source] [
View on GitHub]
28
29
30
|
# File 'lib/rex/ui/text/bidirectional_pipe.rb', line 28
def has_subscriber?(id)
@subscribers_out.has_key?(id)
end
|
[View source] [
View on GitHub]
20
21
22
|
# File 'lib/rex/ui/text/bidirectional_pipe.rb', line 20
def pipe_input
@pipe_input
end
|
permalink
#print(msg = '') ⇒ Object
[View source] [
View on GitHub]
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/rex/ui/text/bidirectional_pipe.rb', line 64
def print(msg='')
@subscribers_out.each_pair { |id, buf|
begin
@subscribers_ref[id] ? @subscribers_ref[id].call(msg) : buf.print(msg)
rescue ::Exception => e
raise e
end
}
msg
end
|
permalink
#print_error(msg = '') ⇒ Object
Also known as:
print_bad
[View source] [
View on GitHub]
76
77
78
|
# File 'lib/rex/ui/text/bidirectional_pipe.rb', line 76
def print_error(msg='')
print_line('[-] ' + msg)
end
|
permalink
#print_good(msg = '') ⇒ Object
[View source] [
View on GitHub]
86
87
88
|
# File 'lib/rex/ui/text/bidirectional_pipe.rb', line 86
def print_good(msg='')
print_line('[+] ' + msg)
end
|
permalink
#print_line(msg = '') ⇒ Object
[View source] [
View on GitHub]
82
83
84
|
# File 'lib/rex/ui/text/bidirectional_pipe.rb', line 82
def print_line(msg='')
print(msg + "\n")
end
|
permalink
#print_status(msg = '') ⇒ Object
[View source] [
View on GitHub]
93
94
95
|
# File 'lib/rex/ui/text/bidirectional_pipe.rb', line 93
def print_status(msg='')
print_line('[*] ' + msg)
end
|
permalink
#print_warning(msg = '') ⇒ Object
[View source] [
View on GitHub]
97
98
99
|
# File 'lib/rex/ui/text/bidirectional_pipe.rb', line 97
def print_warning(msg='')
print_line('[!] ' + msg)
end
|
permalink
#read_subscriber(id) ⇒ Object
[View source] [
View on GitHub]
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/rex/ui/text/bidirectional_pipe.rb', line 52
def read_subscriber(id)
output = @subscribers_out[id]
return '' if output.nil?
buf = output.buf
output.reset
buf
end
|
permalink
#remove_subscriber(id) ⇒ Object
[View source] [
View on GitHub]
43
44
45
46
|
# File 'lib/rex/ui/text/bidirectional_pipe.rb', line 43
def remove_subscriber(id)
@subscribers_out.delete(id)
@subscribers_ref.delete(id)
end
|
permalink
#sysread(len = 1) ⇒ Object
[View source] [
View on GitHub]
109
110
111
|
# File 'lib/rex/ui/text/bidirectional_pipe.rb', line 109
def sysread(len = 1)
@pipe_input.sysread(len)
end
|
[View source] [
View on GitHub]
48
49
50
|
# File 'lib/rex/ui/text/bidirectional_pipe.rb', line 48
def write_input(buf)
@pipe_input.put(buf)
end
|