Class: Shadowsocks::Config
- Inherits:
-
Object
- Object
- Shadowsocks::Config
- Defined in:
- lib/shadowsocks/config.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#chnroutes ⇒ Object
readonly
Returns the value of attribute chnroutes.
-
#config_path ⇒ Object
readonly
Returns the value of attribute config_path.
-
#local_port ⇒ Object
readonly
Returns the value of attribute local_port.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
-
#server_port ⇒ Object
readonly
Returns the value of attribute server_port.
-
#timeout ⇒ Object
readonly
Returns the value of attribute timeout.
Instance Method Summary collapse
-
#initialize(_args) ⇒ Config
constructor
A new instance of Config.
- #read_config ⇒ Object
Constructor Details
#initialize(_args) ⇒ Config
Returns a new instance of Config.
7 8 9 10 11 12 |
# File 'lib/shadowsocks/config.rb', line 7 def initialize(_args) @args = _args || [] parse_args read_config end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
5 6 7 |
# File 'lib/shadowsocks/config.rb', line 5 def args @args end |
#chnroutes ⇒ Object (readonly)
Returns the value of attribute chnroutes.
5 6 7 |
# File 'lib/shadowsocks/config.rb', line 5 def chnroutes @chnroutes end |
#config_path ⇒ Object (readonly)
Returns the value of attribute config_path.
5 6 7 |
# File 'lib/shadowsocks/config.rb', line 5 def config_path @config_path end |
#local_port ⇒ Object (readonly)
Returns the value of attribute local_port.
5 6 7 |
# File 'lib/shadowsocks/config.rb', line 5 def local_port @local_port end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
5 6 7 |
# File 'lib/shadowsocks/config.rb', line 5 def method @method end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
5 6 7 |
# File 'lib/shadowsocks/config.rb', line 5 def password @password end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
5 6 7 |
# File 'lib/shadowsocks/config.rb', line 5 def server @server end |
#server_port ⇒ Object (readonly)
Returns the value of attribute server_port.
5 6 7 |
# File 'lib/shadowsocks/config.rb', line 5 def server_port @server_port end |
#timeout ⇒ Object (readonly)
Returns the value of attribute timeout.
5 6 7 |
# File 'lib/shadowsocks/config.rb', line 5 def timeout @timeout end |
Instance Method Details
#read_config ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/shadowsocks/config.rb', line 14 def read_config @config_path = File.('../..', File.dirname(__FILE__)) + '/config.json' unless @config_path cfg_file = File.open @config_path json = JSON.parse cfg_file.read cfg_file.close @server = json["server"] if @server.nil? @password = json["password"] if @password.nil? @server_port = json["server_port"].to_i if @server_port.nil? @local_port = json["local_port"].to_i if @local_port.nil? @timeout = json["timeout"].to_i if @timeout.nil? @method = json["method"] if @method.nil? @chnroutes = json["chnroutes"] if @chnroutes.nil? end |