arql 0.1.22 → 0.1.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/arql.rb +1 -0
- data/lib/arql/app.rb +5 -7
- data/lib/arql/commands/info.rb +16 -1
- data/lib/arql/commands/reconnect.rb +10 -0
- data/lib/arql/ssh_proxy.rb +30 -0
- data/lib/arql/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ebb803df936a94d7bb9599aff2dd0db0b625a576e6736799fb50c89d3402808e
|
4
|
+
data.tar.gz: 72e84b31307d1bb6d0dad35eeb96702debb55a54a7db0f5a007cd0edd1bf0d28
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7e4905293900ad7e515c35fd8b96a16357dedd940d2f65473a5a087e84444585d335e9922225a87156a453c7eff439cf015b9fbaed318ae8a9c80018dd99350
|
7
|
+
data.tar.gz: 69871e396b27eb0b9ceca1f5d3f66aef292d8eb82154018da720878373d95b5554971f5c492327d445bd5762fa1c118d299d9cacda3a163c8d75e94072cf4ddd
|
data/Gemfile.lock
CHANGED
data/lib/arql.rb
CHANGED
data/lib/arql/app.rb
CHANGED
@@ -9,10 +9,6 @@ module Arql
|
|
9
9
|
def config
|
10
10
|
@@effective_config
|
11
11
|
end
|
12
|
-
|
13
|
-
def local_ssh_proxy_port
|
14
|
-
@@local_ssh_proxy_port
|
15
|
-
end
|
16
12
|
end
|
17
13
|
|
18
14
|
def initialize(options)
|
@@ -48,11 +44,13 @@ module Arql
|
|
48
44
|
|
49
45
|
def start_ssh_proxy!
|
50
46
|
ssh_config = effective_config[:ssh]
|
51
|
-
|
52
|
-
|
47
|
+
local_ssh_proxy_port = Arql::SSHProxy.connect(ssh_config.slice(:host, :user, :port, :password).merge(
|
48
|
+
forward_host: effective_config[:host],
|
49
|
+
forward_port: effective_config[:port],
|
50
|
+
local_port: ssh_config[:local_port]))
|
53
51
|
{
|
54
52
|
host: '127.0.0.1',
|
55
|
-
port:
|
53
|
+
port: local_ssh_proxy_port
|
56
54
|
}
|
57
55
|
end
|
58
56
|
|
data/lib/arql/commands/info.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'rainbow'
|
2
|
+
|
1
3
|
module Arql::Commands
|
2
4
|
module Info
|
3
5
|
class << self
|
@@ -5,6 +7,8 @@ module Arql::Commands
|
|
5
7
|
<<~EOF
|
6
8
|
|
7
9
|
Database Connection Information:
|
10
|
+
|
11
|
+
Active: #{color_boolean(ActiveRecord::Base.connection.active?)}
|
8
12
|
Host: #{Arql::App.config[:host]}
|
9
13
|
Port: #{Arql::App.config[:port]}
|
10
14
|
Username: #{Arql::App.config[:username]}
|
@@ -20,13 +24,24 @@ module Arql::Commands
|
|
20
24
|
<<~EOF
|
21
25
|
|
22
26
|
SSH Connection Information:
|
27
|
+
|
28
|
+
Active: #{color_boolean(Arql::SSHProxy.active?)}
|
23
29
|
Host: #{Arql::App.config[:ssh][:host]}
|
24
30
|
Port: #{Arql::App.config[:ssh][:port]}
|
25
31
|
Username: #{Arql::App.config[:ssh][:user]}
|
26
32
|
Password: #{(Arql::App.config[:ssh][:password] || '').gsub(/./, '*')}
|
27
|
-
Local Port: #{Arql::
|
33
|
+
Local Port: #{Arql::SSHProxy.local_ssh_proxy_port}
|
28
34
|
EOF
|
29
35
|
end
|
36
|
+
|
37
|
+
private
|
38
|
+
def color_boolean(bool)
|
39
|
+
if bool
|
40
|
+
Rainbow('TRUE').green
|
41
|
+
else
|
42
|
+
Rainbow('FALSE').red
|
43
|
+
end
|
44
|
+
end
|
30
45
|
end
|
31
46
|
|
32
47
|
Pry.commands.block_command 'info' do
|
@@ -2,6 +2,12 @@ module Arql::Commands
|
|
2
2
|
module Reconnect
|
3
3
|
class << self
|
4
4
|
def reconnect
|
5
|
+
Arql::SSHProxy.reconnect
|
6
|
+
ActiveRecord::Base.connection.reconnect! unless ActiveRecord::Base.connection.active?
|
7
|
+
end
|
8
|
+
|
9
|
+
def reconnect!
|
10
|
+
Arql::SSHProxy.reconnect!
|
5
11
|
ActiveRecord::Base.connection.reconnect!
|
6
12
|
end
|
7
13
|
end
|
@@ -9,5 +15,9 @@ module Arql::Commands
|
|
9
15
|
Pry.commands.block_command 'reconnect' do
|
10
16
|
Reconnect.reconnect
|
11
17
|
end
|
18
|
+
|
19
|
+
Pry.commands.block_command 'reconnect!' do
|
20
|
+
Reconnect.reconnect!
|
21
|
+
end
|
12
22
|
end
|
13
23
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'net/ssh/gateway'
|
2
|
+
|
3
|
+
module Arql
|
4
|
+
class SSHProxy
|
5
|
+
class << self
|
6
|
+
|
7
|
+
attr_accessor :config, :ssh_gateway, :local_ssh_proxy_port
|
8
|
+
|
9
|
+
def connect(config)
|
10
|
+
@config = config
|
11
|
+
@ssh_gateway = Net::SSH::Gateway.new(config[:host], config[:user], config.slice(:port, :password).symbolize_keys)
|
12
|
+
@local_ssh_proxy_port = @ssh_gateway.open(config[:forward_host], config[:forward_port], config[:local_port])
|
13
|
+
end
|
14
|
+
|
15
|
+
def reconnect
|
16
|
+
reconnect! unless @ssh_gateway.active?
|
17
|
+
end
|
18
|
+
|
19
|
+
def reconnect!
|
20
|
+
@ssh_gateway.shutdown!
|
21
|
+
@ssh_gateway = Net::SSH::Gateway.new(@config[:host], @config[:user], @config.slice(:port, :password).symbolize_keys)
|
22
|
+
@ssh_gateway.open(config[:forward_host], config[:forward_port], @local_ssh_proxy_port)
|
23
|
+
end
|
24
|
+
|
25
|
+
def active?
|
26
|
+
@ssh_gateway.active?
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/arql/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.23
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Liu Xiang
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-06-
|
11
|
+
date: 2020-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mysql2
|
@@ -252,6 +252,7 @@ files:
|
|
252
252
|
- lib/arql/id.rb
|
253
253
|
- lib/arql/multi_io.rb
|
254
254
|
- lib/arql/repl.rb
|
255
|
+
- lib/arql/ssh_proxy.rb
|
255
256
|
- lib/arql/version.rb
|
256
257
|
homepage: https://github.com/lululau/arql
|
257
258
|
licenses:
|