Module: NetD
- Defined in:
- lib/netd_core/netop.rb,
lib/netd_core/request.rb
Overview
parse requests from a pipe delimited line
Defined Under Namespace
Classes: LocalPortForward, NetworkOperation, OperationRequest, RemotePortForward
Instance Method Summary
collapse
Instance Method Details
#test ⇒ Object
87
88
89
90
91
92
93
94
95
96
97
98
99
|
# File 'lib/netd_core/netop.rb', line 87
def test
puts 'testing forwards'
Net::SSH::Authentication::Agent.connect(nil, nil, '/home/shellspawn/.1password/agent.sock')
lpfwd, rpfwd = test_setup_port_forwards
puts lpfwd, rpfwd
test_forward
[lpfwd, rpfwd].map(&:close)
puts 'all cleaned up'
end
|
#test_forward ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/netd_core/netop.rb', line 57
def test_forward
data = 'HELLO'
TCPServer.open('127.0.0.1', 2224) do |svr|
TCPSocket.open('127.0.0.1', 2222) do |c|
s = svr.accept
c.puts data
raise 'Forward test failed!!!' unless s.readline(chomp: true) == data
end
end
sleep(1) end
|
#test_setup_port_forwards ⇒ Object
74
75
76
77
78
79
80
81
82
83
84
85
|
# File 'lib/netd_core/netop.rb', line 74
def test_setup_port_forwards
lpfwd = LocalPortForward.new({ 'request': 'lpfwd',
'host': 'localhost',
'bind_port': 2222, 'bind_addr': 'localhost',
'remote_port': 2223, 'remote_addr': 'localhost' })
rpfwd = RemotePortForward.new({ 'request': 'rpfwd',
'host': 'localhost',
'bind_port': 2224, 'bind_addr': 'localhost',
'local_port': 2223, 'local_addr': 'localhost' })
sleep(1) [lpfwd, rpfwd]
end
|