Class: ShadowsocksRuby::Protocols::NoIvCipherProtocol

Inherits:
Object
  • Object
show all
Includes:
DummyHelper
Defined in:
lib/shadowsocks_ruby/protocols/cipher/no_iv_cipher.rb

Overview

To be used with protocols without an IV, like Cipher::Table

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from DummyHelper

#async_recv, #raise_me, #send_data

Constructor Details

#initialize(params = {}) ⇒ NoIvCipherProtocol

Returns a new instance of NoIvCipherProtocol.

Parameters:

  • params (Hash) (defaults to: {})

    Configuration parameters

Options Hash (params):

  • :cipher (Cipher::Table)

    a cipher object without IV, required



12
13
14
# File 'lib/shadowsocks_ruby/protocols/cipher/no_iv_cipher.rb', line 12

def initialize params = {}
  @cipher = params[:cipher] or raise ProtocolError, "params[:cipher] is required"
end

Instance Attribute Details

#next_protocolObject

Returns the value of attribute next_protocol.



8
9
10
# File 'lib/shadowsocks_ruby/protocols/cipher/no_iv_cipher.rb', line 8

def next_protocol
  @next_protocol
end

Instance Method Details

#tcp_receive_from_localbackend(n) ⇒ Object



24
25
26
# File 'lib/shadowsocks_ruby/protocols/cipher/no_iv_cipher.rb', line 24

def tcp_receive_from_localbackend n
  @cipher.decrypt(async_recv n)
end

#tcp_receive_from_remoteserver(n) ⇒ Object



16
17
18
# File 'lib/shadowsocks_ruby/protocols/cipher/no_iv_cipher.rb', line 16

def tcp_receive_from_remoteserver n
  @cipher.decrypt(async_recv n)
end

#tcp_send_to_localbackend(data) ⇒ Object



28
29
30
# File 'lib/shadowsocks_ruby/protocols/cipher/no_iv_cipher.rb', line 28

def tcp_send_to_localbackend data
  send_data(@cipher.encrypt data)
end

#tcp_send_to_remoteserver(data) ⇒ Object



20
21
22
# File 'lib/shadowsocks_ruby/protocols/cipher/no_iv_cipher.rb', line 20

def tcp_send_to_remoteserver data
  send_data(@cipher.encrypt data)
end