ssport 0.2.0 → 0.2.1
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/lib/ssport/config.rb +17 -1
- data/lib/ssport/installer.rb +20 -0
- data/lib/ssport/remote.rb +8 -4
- data/lib/ssport/version.rb +1 -1
- data/lib/ssport.rb +15 -4
- 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: 5467c72ea8a18951e86729e5ce33954171cf20cdc596e3d0a7860cf58e52c9ec
|
4
|
+
data.tar.gz: f16d7481c66b70aaa2d5ca556d4e2c663fdf16090df7943243d8f1906e163c9e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24df4f8132ad222743fd991d868e9924965ac59587f9861c950cf9f3cbff4c9cb7efc1c8c48d48845a9115621b4f5053272bda71c037f8df2189641be2da0e50
|
7
|
+
data.tar.gz: e86fba4fb3ed18a1e9c97741c3087781a6dae1119e1986550d4f1b47de86a16a635aaa19322f8e4ad58099359ec71e22f48ea411cca03aad2a2e193cd0705e6d
|
data/lib/ssport/config.rb
CHANGED
@@ -12,7 +12,23 @@ class Config
|
|
12
12
|
@config_file = options[:config]
|
13
13
|
end
|
14
14
|
|
15
|
-
def
|
15
|
+
def create
|
16
|
+
defualt_config = {
|
17
|
+
"server": @options[:server] || "my_server_ip",
|
18
|
+
"server_port": 8388,
|
19
|
+
"local_address":"127.0.0.1",
|
20
|
+
"local_port": 1080,
|
21
|
+
"password": "123456",
|
22
|
+
"timeout": 300,
|
23
|
+
"method": "rc4-md5"
|
24
|
+
}
|
25
|
+
File.write '/etc/shadowsocks.json' , defualt_config
|
26
|
+
|
27
|
+
parseConfig
|
28
|
+
applyChange
|
29
|
+
end
|
30
|
+
|
31
|
+
def update
|
16
32
|
if !@config_file
|
17
33
|
raise "config file not set"
|
18
34
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'colorize'
|
3
|
+
|
4
|
+
class Installer
|
5
|
+
|
6
|
+
def self.run
|
7
|
+
puts "---------Bengin Install SS ------------".colorize(:yellow)
|
8
|
+
|
9
|
+
script = %Q{
|
10
|
+
if [ -x "$(command -v yum)" ]; then
|
11
|
+
yum install python-setuptools && easy_install pip
|
12
|
+
elif [ -x "$(command -v apt-get)" ]; then
|
13
|
+
apt-get install python-pip
|
14
|
+
fi
|
15
|
+
pip install shadowsocks
|
16
|
+
}
|
17
|
+
system script
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
data/lib/ssport/remote.rb
CHANGED
@@ -23,10 +23,14 @@ class Remote
|
|
23
23
|
command = "ssport -c #{@options[:config]}"
|
24
24
|
keys.each do |key|
|
25
25
|
if @options[key]
|
26
|
-
if key ==
|
27
|
-
command += "
|
28
|
-
else
|
29
|
-
|
26
|
+
if @options[key] == true
|
27
|
+
command += " --#{key} "
|
28
|
+
else
|
29
|
+
if key == :port
|
30
|
+
command += " -b #{@options[key]}"
|
31
|
+
else
|
32
|
+
command += " --#{key} #{@options[key]}"
|
33
|
+
end
|
30
34
|
end
|
31
35
|
end
|
32
36
|
end
|
data/lib/ssport/version.rb
CHANGED
data/lib/ssport.rb
CHANGED
@@ -2,6 +2,7 @@ require "ssport/version"
|
|
2
2
|
require "ssport/config"
|
3
3
|
require "ssport/profile"
|
4
4
|
require "ssport/remote"
|
5
|
+
require "ssport/installer"
|
5
6
|
require "colorize"
|
6
7
|
require 'fileutils'
|
7
8
|
require 'optparse'
|
@@ -59,6 +60,10 @@ module Ssport
|
|
59
60
|
options[:pass] = v
|
60
61
|
end
|
61
62
|
|
63
|
+
opts.on("-I", "--install shadowsocket", "install shadowsocket on server, default port: 8388, password: 123456, method: rc4-md5") do |v|
|
64
|
+
options[:install] = true
|
65
|
+
end
|
66
|
+
|
62
67
|
opts.on("-b", "--bind port", "shadowsocket server bind port") do |v|
|
63
68
|
options[:port] = v
|
64
69
|
end
|
@@ -105,11 +110,17 @@ module Ssport
|
|
105
110
|
end
|
106
111
|
|
107
112
|
if options[:server]
|
108
|
-
|
109
|
-
|
113
|
+
remote = Remote.new(options)
|
114
|
+
remote.ssh
|
110
115
|
elsif options[:config]
|
111
|
-
|
112
|
-
|
116
|
+
if options[:install]
|
117
|
+
Installer.run
|
118
|
+
config = Config.new(options)
|
119
|
+
config.create
|
120
|
+
else
|
121
|
+
config = Config.new(options)
|
122
|
+
config.update
|
123
|
+
end
|
113
124
|
end
|
114
125
|
|
115
126
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ssport
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kaich
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-05-
|
11
|
+
date: 2018-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -97,6 +97,7 @@ files:
|
|
97
97
|
- bin/ssport
|
98
98
|
- lib/ssport.rb
|
99
99
|
- lib/ssport/config.rb
|
100
|
+
- lib/ssport/installer.rb
|
100
101
|
- lib/ssport/profile.rb
|
101
102
|
- lib/ssport/remote.rb
|
102
103
|
- lib/ssport/version.rb
|