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.
-
#table ⇒ Object
Returns the value of attribute table.
Instance Method Summary collapse
-
#initialize(options) ⇒ Cli
constructor
A new instance of Cli.
- #run ⇒ Object
Methods included from Table
#encrypt, #get_table, #merge, #merge_sort
Methods included from Ext
Constructor Details
#initialize(options) ⇒ Cli
Returns a new instance of Cli.
12 13 14 15 16 |
# File 'lib/shadowsocks/cli.rb', line 12 def initialize() @side = [:side] @config = [:config] @table = get_table(config.password) 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 |
#table ⇒ Object
Returns the value of attribute table.
10 11 12 |
# File 'lib/shadowsocks/cli.rb', line 10 def table @table end |
Instance Method Details
#run ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/shadowsocks/cli.rb', line 18 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 |