ssport 0.1.0
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 +7 -0
- data/.gitignore +8 -0
- data/.travis.yml +5 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +10 -0
- data/bin/ssport +4 -0
- data/lib/ssport/config.rb +44 -0
- data/lib/ssport/version.rb +3 -0
- data/lib/ssport.rb +74 -0
- data/ssport.gemspec +36 -0
- metadata +114 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b1097d6d64ab948059c12a084e59962c0a55ba6d24159e1d8de7ce02102375d7
|
4
|
+
data.tar.gz: 5842270f5dbf4facade4efea111501a6f167dcfb60c24227b271d1f0c5dc493a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cb710edd81dc0b0d0bc30401dfb8cb7f6a6a2e31a972af6a04474418a59b26e2308d5915d2c372fb5ee9894f5b42a5aad98aea751aa3a2e0819bba4eb39add6a
|
7
|
+
data.tar.gz: ba1fbd0375ac0899d0db1d4b7438a7d124bdd21ea528c62aa5cc5db6ccc17f6d2868ba12f152e2b4d36da557fe53be23b82b34a3779f69ffa13eb4bcaa7422a0
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 TODO: Write your name
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# Ssport
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/ssport`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'ssport'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install ssport
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/ssport.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/ssport
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
class Config
|
2
|
+
|
3
|
+
@@SERVER_PORT = "server_port"
|
4
|
+
@@PASSWORD = "password"
|
5
|
+
@@METHOD = "method"
|
6
|
+
|
7
|
+
def initialize(options)
|
8
|
+
@options = options
|
9
|
+
@config_file = options[:config]
|
10
|
+
if !@config_file
|
11
|
+
raise "config file not set"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def run
|
16
|
+
parseConfig
|
17
|
+
applyChange
|
18
|
+
end
|
19
|
+
|
20
|
+
def parseConfig
|
21
|
+
if File.exist? config_file
|
22
|
+
file_content = File.read @config_file
|
23
|
+
@config_json = JSON.parse file_content
|
24
|
+
else
|
25
|
+
p "Config 文件不存在".colorize(:red)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def changeField(config_key, option_key)
|
30
|
+
option_value = @options[option_key]
|
31
|
+
if option_value
|
32
|
+
@config_json[config_key] = option_value
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def applyChange(config_json)
|
37
|
+
changeField @@SERVER_PORT , :port
|
38
|
+
changeField @@PASSWORD , :password
|
39
|
+
changeField @@METHOD , :method
|
40
|
+
File.write @config_file , @config_json.to_json
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
end
|
data/lib/ssport.rb
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
require "ssport/version"
|
2
|
+
require "ssport/config"
|
3
|
+
require "colorize"
|
4
|
+
require 'fileutils'
|
5
|
+
require 'optparse'
|
6
|
+
require 'json'
|
7
|
+
require 'net/ssh'
|
8
|
+
|
9
|
+
module Ssport
|
10
|
+
|
11
|
+
def self.run
|
12
|
+
|
13
|
+
options = {}
|
14
|
+
options[:config] = "shadowsocks.json"
|
15
|
+
OptionParser.new do |opts|
|
16
|
+
opts.banner = "Usage: change shadowsocket port"
|
17
|
+
|
18
|
+
opts.on("-S", "--server host", "ssh server host") do |v|
|
19
|
+
options[:server] = v
|
20
|
+
end
|
21
|
+
|
22
|
+
opts.on("-U", "--username username", "ssh server username") do |v|
|
23
|
+
options[:username] = v
|
24
|
+
end
|
25
|
+
|
26
|
+
opts.on("-P", "--pass password", "ssh server password") do |v|
|
27
|
+
options[:pass] = v
|
28
|
+
end
|
29
|
+
|
30
|
+
opts.on("-b", "--bind port", "shadowsocket server bind port") do |v|
|
31
|
+
options[:port] = v
|
32
|
+
end
|
33
|
+
|
34
|
+
opts.on("-p", "--password password",Array,"shadowsocket password") do |v|
|
35
|
+
options[:password] = v
|
36
|
+
end
|
37
|
+
|
38
|
+
opts.on("-m", "--method method",Array,"shadowsocket encry method") do |v|
|
39
|
+
options[:method] = v
|
40
|
+
end
|
41
|
+
|
42
|
+
opts.on("-c", "--config filepath",Array,"shadowsocket config file path") do |v|
|
43
|
+
options[:config] = v
|
44
|
+
end
|
45
|
+
|
46
|
+
end.parse!
|
47
|
+
|
48
|
+
if options[:server]
|
49
|
+
ssh options
|
50
|
+
end
|
51
|
+
|
52
|
+
config = Config(options)
|
53
|
+
config.run
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.ssh(options)
|
58
|
+
|
59
|
+
Net::SSH.start(options[:server], options[:username], :password => options[:pass]) do |ssh|
|
60
|
+
# capture all stderr and stdout output from a remote process
|
61
|
+
parameter = """
|
62
|
+
if ! [ -x "$(command -v ssport)" ]; then
|
63
|
+
gem install ssport
|
64
|
+
if
|
65
|
+
ssport -b #{options[:port]}
|
66
|
+
"""
|
67
|
+
output = ssh.exec!("~/bin/command '#{parameter}'"
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
puts output
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
data/ssport.gemspec
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "ssport/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ssport"
|
8
|
+
spec.version = Ssport::VERSION
|
9
|
+
spec.authors = ["kaich"]
|
10
|
+
spec.email = ["chengkai1853@163.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{change shadowsocket config to avoid block.}
|
13
|
+
spec.description = %q{commandline change shadowsocket config to avoid block.}
|
14
|
+
spec.homepage = ""
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
21
|
+
else
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
23
|
+
"public gem pushes."
|
24
|
+
end
|
25
|
+
|
26
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
27
|
+
f.match(%r{^(test|spec|features)/})
|
28
|
+
end
|
29
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
30
|
+
spec.require_paths = ["lib","bin"]
|
31
|
+
|
32
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
33
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
34
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
35
|
+
spec.add_runtime_dependency 'colorize' , '~> 0.7'
|
36
|
+
end
|
metadata
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ssport
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- kaich
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-05-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: colorize
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.7'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.7'
|
69
|
+
description: commandline change shadowsocket config to avoid block.
|
70
|
+
email:
|
71
|
+
- chengkai1853@163.com
|
72
|
+
executables:
|
73
|
+
- ssport
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- ".travis.yml"
|
79
|
+
- Gemfile
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- bin/ssport
|
84
|
+
- lib/ssport.rb
|
85
|
+
- lib/ssport/config.rb
|
86
|
+
- lib/ssport/version.rb
|
87
|
+
- ssport.gemspec
|
88
|
+
homepage: ''
|
89
|
+
licenses:
|
90
|
+
- MIT
|
91
|
+
metadata:
|
92
|
+
allowed_push_host: https://rubygems.org
|
93
|
+
post_install_message:
|
94
|
+
rdoc_options: []
|
95
|
+
require_paths:
|
96
|
+
- lib
|
97
|
+
- bin
|
98
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
requirements: []
|
109
|
+
rubyforge_project:
|
110
|
+
rubygems_version: 2.7.6
|
111
|
+
signing_key:
|
112
|
+
specification_version: 4
|
113
|
+
summary: change shadowsocket config to avoid block.
|
114
|
+
test_files: []
|