Sha256: 5433078151ebbf989985099e4c9ba4a56a9d8ba885150c0265363b406882070a
Contents?: true
Size: 1.39 KB
Versions: 3
Compression:
Stored size: 1.39 KB
Contents
require 'optparse' require 'pp' require File.expand_path('../version', __FILE__) module Shadowsocks class Cli include ::Shadowsocks::Table attr_accessor :side, :args, :config, :table def initialize(options) @side = options[:side] @config = options[:config] @table = get_table(config.password) end 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 private def initialize_connection connection connection.config = @config connection.table = @table connection.pending_connect_timeout = @config.timeout end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
shadowsocks-0.3 | lib/shadowsocks/cli.rb |
shadowsocks-0.2 | lib/shadowsocks/cli.rb |
shadowsocks-0.1 | lib/shadowsocks/cli.rb |