93 lines
2.7 KiB
Plaintext
93 lines
2.7 KiB
Plaintext
// Generated using `moon info`, DON'T EDIT IT
|
|
package "experiments/moon_i2p/i2np"
|
|
|
|
import {
|
|
"experiments/moon_i2p/common",
|
|
"experiments/moon_i2p/encoding",
|
|
"moonbitlang/core/debug",
|
|
}
|
|
|
|
// Values
|
|
pub fn decode_short_message(@encoding.Reader) -> (ShortHeader, I2npPayload) raise I2npError
|
|
|
|
pub fn decode_standard_message(@encoding.Reader) -> (StandardHeader, I2npPayload) raise I2npError
|
|
|
|
pub fn encode_short_message(UInt32, UInt32, I2npPayload) -> Bytes raise I2npError
|
|
|
|
pub fn encode_standard_message(UInt32, UInt64, I2npPayload) -> Bytes raise I2npError
|
|
|
|
pub fn payload_checksum(Bytes) -> Byte
|
|
|
|
// Errors
|
|
#derive(Eq, @debug.Debug)
|
|
pub suberror I2npError {
|
|
Encoding(@encoding.EncodingError)
|
|
Common(@common.CommonError)
|
|
ChecksumMismatch(Byte, Byte)
|
|
InvalidLength(String)
|
|
}
|
|
|
|
// Types and methods
|
|
#derive(Eq, @debug.Debug)
|
|
pub(all) enum I2npMessageType {
|
|
DatabaseStore
|
|
DatabaseLookup
|
|
DatabaseSearchReply
|
|
DeliveryStatus
|
|
Garlic
|
|
TunnelData
|
|
TunnelGateway
|
|
Data
|
|
TunnelBuild
|
|
TunnelBuildReply
|
|
VariableTunnelBuild
|
|
VariableTunnelBuildReply
|
|
ShortTunnelBuild
|
|
ShortTunnelBuildReply
|
|
Unknown(Byte)
|
|
}
|
|
pub fn I2npMessageType::from_byte(Byte) -> Self
|
|
pub fn I2npMessageType::to_byte(Self) -> Byte
|
|
|
|
#derive(Eq, @debug.Debug)
|
|
pub(all) enum I2npPayload {
|
|
DatabaseStore(key~ : @common.Hash, store_type~ : Byte, reply_token~ : UInt32, reply_tunnel_id~ : UInt32, reply_gateway~ : @common.Hash?, data~ : Bytes)
|
|
DatabaseLookup(key~ : @common.Hash, from~ : @common.Hash, flags~ : Byte, reply_tunnel_id~ : UInt32?, excluded_peers~ : Array[@common.Hash])
|
|
DatabaseSearchReply(key~ : @common.Hash, peer_hashes~ : Array[@common.Hash], from~ : @common.Hash)
|
|
DeliveryStatus(msg_id~ : UInt32, timestamp_ms~ : UInt64)
|
|
Garlic(data~ : Bytes)
|
|
TunnelData(tunnel_id~ : UInt32, data~ : Bytes)
|
|
TunnelGateway(tunnel_id~ : UInt32, data~ : Bytes)
|
|
Data(data~ : Bytes)
|
|
ShortTunnelBuild(records~ : Array[Bytes])
|
|
ShortTunnelBuildReply(records~ : Array[Bytes])
|
|
Raw(msg_type~ : I2npMessageType, data~ : Bytes)
|
|
}
|
|
pub fn I2npPayload::decode_body(I2npMessageType, Bytes) -> Self raise I2npError
|
|
pub fn I2npPayload::encode_body(Self) -> Bytes raise I2npError
|
|
pub fn I2npPayload::msg_type(Self) -> I2npMessageType
|
|
|
|
#derive(Eq, @debug.Debug)
|
|
pub(all) struct ShortHeader {
|
|
msg_type : I2npMessageType
|
|
msg_id : UInt32
|
|
expiration_sec : UInt32
|
|
}
|
|
pub fn ShortHeader::decode(@encoding.Reader) -> Self raise I2npError
|
|
pub fn ShortHeader::encode(Self, @encoding.Writer) -> Unit
|
|
|
|
#derive(Eq, @debug.Debug)
|
|
pub(all) struct StandardHeader {
|
|
msg_type : I2npMessageType
|
|
msg_id : UInt32
|
|
expiration_ms : UInt64
|
|
size : UInt32
|
|
checksum : Byte
|
|
}
|
|
pub fn StandardHeader::decode(@encoding.Reader) -> Self raise I2npError
|
|
pub fn StandardHeader::encode(Self, @encoding.Writer) -> Unit
|
|
|
|
// Type aliases
|
|
|
|
// Traits
|