Class: Mysql::Protocol::InitialPacket
- Inherits:
-
Object
- Object
- Mysql::Protocol::InitialPacket
- Defined in:
- lib/mysql/protocol.rb
Overview
Initial packet
Instance Attribute Summary collapse
-
#auth_plugin ⇒ Object
readonly
Returns the value of attribute auth_plugin.
-
#protocol_version ⇒ Object
readonly
Returns the value of attribute protocol_version.
-
#scramble_buff ⇒ Object
readonly
Returns the value of attribute scramble_buff.
-
#server_capabilities ⇒ Object
readonly
Returns the value of attribute server_capabilities.
-
#server_charset ⇒ Object
readonly
Returns the value of attribute server_charset.
-
#server_status ⇒ Object
readonly
Returns the value of attribute server_status.
-
#server_version ⇒ Object
readonly
Returns the value of attribute server_version.
-
#thread_id ⇒ Object
readonly
Returns the value of attribute thread_id.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(*args) ⇒ InitialPacket
constructor
A new instance of InitialPacket.
Constructor Details
#initialize(*args) ⇒ InitialPacket
Returns a new instance of InitialPacket.
671 672 673 |
# File 'lib/mysql/protocol.rb', line 671 def initialize(*args) @protocol_version, @server_version, @thread_id, @server_capabilities, @server_charset, @server_status, @scramble_buff, @auth_plugin = args end |
Instance Attribute Details
#auth_plugin ⇒ Object (readonly)
Returns the value of attribute auth_plugin.
669 670 671 |
# File 'lib/mysql/protocol.rb', line 669 def auth_plugin @auth_plugin end |
#protocol_version ⇒ Object (readonly)
Returns the value of attribute protocol_version.
669 670 671 |
# File 'lib/mysql/protocol.rb', line 669 def protocol_version @protocol_version end |
#scramble_buff ⇒ Object (readonly)
Returns the value of attribute scramble_buff.
669 670 671 |
# File 'lib/mysql/protocol.rb', line 669 def scramble_buff @scramble_buff end |
#server_capabilities ⇒ Object (readonly)
Returns the value of attribute server_capabilities.
669 670 671 |
# File 'lib/mysql/protocol.rb', line 669 def server_capabilities @server_capabilities end |
#server_charset ⇒ Object (readonly)
Returns the value of attribute server_charset.
669 670 671 |
# File 'lib/mysql/protocol.rb', line 669 def server_charset @server_charset end |
#server_status ⇒ Object (readonly)
Returns the value of attribute server_status.
669 670 671 |
# File 'lib/mysql/protocol.rb', line 669 def server_status @server_status end |
#server_version ⇒ Object (readonly)
Returns the value of attribute server_version.
669 670 671 |
# File 'lib/mysql/protocol.rb', line 669 def server_version @server_version end |
#thread_id ⇒ Object (readonly)
Returns the value of attribute thread_id.
669 670 671 |
# File 'lib/mysql/protocol.rb', line 669 def thread_id @thread_id end |
Class Method Details
.parse(pkt) ⇒ Object
644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 |
# File 'lib/mysql/protocol.rb', line 644 def self.parse(pkt) protocol_version = pkt.utiny server_version = pkt.string thread_id = pkt.ulong scramble_buff = pkt.read(8) f0 = pkt.utiny server_capabilities = pkt.ushort server_charset = pkt.utiny server_status = pkt.ushort server_capabilities2 = pkt.ushort scramble_length = pkt.utiny _f1 = pkt.read(10) rest_scramble_buff = pkt.string auth_plugin = pkt.string server_capabilities |= server_capabilities2 << 16 scramble_buff.concat rest_scramble_buff raise ProtocolError, "unsupported version: #{protocol_version}" unless protocol_version == VERSION raise ProtocolError, "invalid packet: f0=#{f0}" unless f0 == 0 raise ProtocolError, "invalid packet: scramble_length(#{scramble_length}) != length of scramble(#{scramble_buff.size + 1})" unless scramble_length == scramble_buff.size + 1 self.new protocol_version, server_version, thread_id, server_capabilities, server_charset, server_status, scramble_buff, auth_plugin end |