Class: I2P::Destination
- Defined in:
- lib/i2p/data/destination.rb,
lib/i2p/sdk.rb
Overview
I2P destination data structure.
Defines an endpoint in the I2P network. The destination may move around in the network, but messages sent to the destination will reach it.
Constant Summary collapse
- BYTESIZE =
minimum
387
Instance Attribute Summary collapse
Class Method Summary collapse
-
.read(input) ⇒ Destination
Reads a destination from the given
inputstream.
Instance Method Summary collapse
-
#initialize(public_key, signing_key, certificate = Certificate.new) ⇒ Destination
constructor
Initializes a new destination instance.
-
#size ⇒ Integer
(also: #bytesize)
Returns the byte size of this data structure.
-
#to_java ⇒ Object
Returns an instance of the Java class
net.i2p.data.Destination. -
#to_s ⇒ String
Returns the binary string representation of this destination.
Methods inherited from Structure
#==, #eql?, parse, #to_base64
Constructor Details
#initialize(public_key, signing_key, certificate = Certificate.new) ⇒ Destination
Initializes a new destination instance.
28 29 30 31 32 |
# File 'lib/i2p/data/destination.rb', line 28 def initialize(public_key, signing_key, certificate = Certificate.new) @public_key = public_key @signing_key = signing_key @certificate = certificate end |
Instance Attribute Details
#certificate ⇒ Certificate
44 45 46 |
# File 'lib/i2p/data/destination.rb', line 44 def certificate @certificate end |
#public_key ⇒ PublicKey
36 37 38 |
# File 'lib/i2p/data/destination.rb', line 36 def public_key @public_key end |
#signing_key ⇒ SigningPublicKey
40 41 42 |
# File 'lib/i2p/data/destination.rb', line 40 def signing_key @signing_key end |
Class Method Details
.read(input) ⇒ Destination
Reads a destination from the given input stream.
18 19 20 |
# File 'lib/i2p/data/destination.rb', line 18 def self.read(input) self.new(PublicKey.read(input), SigningPublicKey.read(input), Certificate.read(input)) end |
Instance Method Details
#size ⇒ Integer Also known as: bytesize
Returns the byte size of this data structure.
50 51 52 |
# File 'lib/i2p/data/destination.rb', line 50 def size public_key.size + signing_key.size + certificate.size end |
#to_java ⇒ Object
Returns an instance of the Java class net.i2p.data.Destination.
This method only works with JRuby, not with MRI or YARV.
95 96 97 |
# File 'lib/i2p/sdk.rb', line 95 def to_java I2P::SDK::Destination.new(to_base64) end |
#to_s ⇒ String
Returns the binary string representation of this destination.
59 60 61 62 63 64 65 66 |
# File 'lib/i2p/data/destination.rb', line 59 def to_s StringIO.open do |buffer| buffer.write(public_key.to_s) buffer.write(signing_key.to_s) buffer.write(certificate.to_s) buffer.string end end |