Class: Shadowsocks::Cli
- Inherits:
-
Object
- Object
- Shadowsocks::Cli
- Includes:
- Table
- Defined in:
- lib/shadowsocks/cli.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
Returns the value of attribute args.
-
#config ⇒ Object
Returns the value of attribute config.
-
#side ⇒ Object
Returns the value of attribute side.
Instance Method Summary collapse
-
#initialize(options) ⇒ Cli
constructor
A new instance of Cli.
- #run ⇒ Object
Methods included from Table
#get_table, #merge, #merge_sort, #translate
Methods included from Ext
Constructor Details
#initialize(options) ⇒ Cli
Returns a new instance of Cli.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/shadowsocks/cli.rb', line 12 def initialize() @side = [:side] @config = [:config] @ip_detector = Shadowsocks::IPDetector.new if @config.chnroutes @method_options = { method: config.method, password: config.password } if @config.method == 'table' table = get_table(config.password) @method_options.merge!( encrypt_table: table[:encrypt], decrypt_table: table[:decrypt] ) end end |
Instance Attribute Details
#args ⇒ Object
Returns the value of attribute args.
10 11 12 |
# File 'lib/shadowsocks/cli.rb', line 10 def args @args end |
#config ⇒ Object
Returns the value of attribute config.
10 11 12 |
# File 'lib/shadowsocks/cli.rb', line 10 def config @config end |
#side ⇒ Object
Returns the value of attribute side.
10 11 12 |
# File 'lib/shadowsocks/cli.rb', line 10 def side @side end |
Instance Method Details
#run ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/shadowsocks/cli.rb', line 31 def run case side when :local EventMachine::run { Signal.trap("INT") { EventMachine.stop } Signal.trap("TERM") { EventMachine.stop } puts "*** Local side is up, port:#{config.local_port}" puts "*** Hit Ctrl+c to stop" EventMachine::start_server "0.0.0.0", config.local_port, Shadowsocks::Local::LocalListener, &method(:initialize_connection) } when :server EventMachine::run { Signal.trap("INT") { EventMachine.stop } Signal.trap("TERM") { EventMachine.stop } puts "*** Server side is up, port:#{config.server_port}" puts "*** Hit Ctrl+c to stop" EventMachine::start_server "0.0.0.0", config.server_port, Shadowsocks::Server::ServerListener, &method(:initialize_connection) } end end |