- Add --http-proxy/--proxy [host:port] (default 127.0.0.1:4444) to route .i2p and .b32.i2p HTTP requests over I2P streams - Block clearnet hosts with 403 and reject CONNECT and https:// with 501 - Support ?i2paddresshelper= jump links that register host aliases - Add `just proxy` target and -h/--help usage output - Expire idle ratchet sessions after 300s and add RatchetSessionManager::drop_session for fresh NewSession handshakes - Add NetDb::remove_lease_set2 and bound the outbound pending queue to 64 entries
139 lines
4.4 KiB
Plaintext
139 lines
4.4 KiB
Plaintext
// Generated using `moon info`, DON'T EDIT IT
|
|
package "experiments/moon_i2p/ratchet"
|
|
|
|
import {
|
|
"experiments/moon_i2p/common",
|
|
"experiments/moon_i2p/crypto",
|
|
"experiments/moon_i2p/encoding",
|
|
"experiments/moon_i2p/i2np",
|
|
"experiments/moon_i2p/noise",
|
|
"moonbitlang/core/debug",
|
|
}
|
|
|
|
// Values
|
|
pub fn decode_blocks(Bytes) -> Array[RatchetBlock] raise RatchetError
|
|
|
|
pub fn decode_garlic_clove_i2np(Bytes) -> (@i2np.ShortHeader, @i2np.I2npPayload) raise RatchetError
|
|
|
|
pub fn decrypt_ecies_lookup_reply(Bytes, Bytes, Bytes) -> Array[RatchetBlock] raise RatchetError
|
|
|
|
pub fn decrypt_new_session(@noise.KeyPair, Bytes) -> (Array[RatchetBlock], PendingNewSession?) raise RatchetError
|
|
|
|
pub fn decrypt_new_session_reply(@noise.KeyPair, PendingNewSession, Bytes) -> (Array[RatchetBlock], RatchetPeerSession) raise RatchetError
|
|
|
|
pub fn decrypt_router_garlic(@noise.KeyPair, Bytes) -> Array[RatchetBlock] raise RatchetError
|
|
|
|
pub fn dh_initialize(Bytes, Bytes) -> (Bytes, TagSet) raise RatchetError
|
|
|
|
pub let ecies_protocol_name : Bytes
|
|
|
|
pub fn encode_blocks(Array[RatchetBlock]) -> Bytes raise RatchetError
|
|
|
|
pub fn encrypt_ecies_lookup_reply(Bytes, Bytes, Array[RatchetBlock]) -> Bytes raise RatchetError
|
|
|
|
pub fn encrypt_new_session(@noise.KeyPair?, Bytes, ElligatorKeyPair, Array[RatchetBlock]) -> (Bytes, PendingNewSession?) raise RatchetError
|
|
|
|
pub fn encrypt_new_session_reply(PendingNewSession, ElligatorKeyPair, Array[RatchetBlock]) -> (Bytes, RatchetPeerSession) raise RatchetError
|
|
|
|
pub fn encrypt_router_garlic(Bytes, @noise.KeyPair, Array[RatchetBlock]) -> Bytes raise RatchetError
|
|
|
|
pub fn garlic_clove_block(GarlicDelivery, UInt32, UInt32, @i2np.I2npPayload) -> RatchetBlock raise RatchetError
|
|
|
|
pub fn generate_elligator_keypair(() -> Bytes) -> ElligatorKeyPair raise RatchetError
|
|
|
|
pub let router_garlic_protocol_name : Bytes
|
|
|
|
// Errors
|
|
#derive(Eq, @debug.Debug)
|
|
pub suberror RatchetError {
|
|
Crypto(@crypto.CryptoError)
|
|
Noise(@noise.NoiseError)
|
|
Encoding(@encoding.EncodingError)
|
|
Common(@common.CommonError)
|
|
I2np(@i2np.I2npError)
|
|
InvalidLength(String)
|
|
InvalidFormat(String)
|
|
UnknownSession
|
|
AuthenticationFailed
|
|
}
|
|
|
|
// Types and methods
|
|
#derive(Eq, @debug.Debug)
|
|
pub(all) struct ElligatorKeyPair {
|
|
private_key : Bytes
|
|
public_key : Bytes
|
|
elligator_repr : Bytes
|
|
}
|
|
|
|
#derive(Eq, @debug.Debug)
|
|
pub(all) enum GarlicDelivery {
|
|
Local
|
|
Destination(@common.Hash)
|
|
Router(@common.Hash)
|
|
Tunnel(@common.Hash, UInt32)
|
|
}
|
|
|
|
pub struct PendingNewSession {
|
|
ck : Bytes
|
|
h : Bytes
|
|
local_ephem_priv : Bytes
|
|
remote_ephem_pub : Bytes
|
|
remote_static_pub : Bytes
|
|
nsr_tagset : TagSet
|
|
}
|
|
|
|
#derive(Eq, @debug.Debug)
|
|
pub(all) enum RatchetBlock {
|
|
DateTime(UInt32)
|
|
Termination(reason~ : Byte, additional_data~ : Bytes)
|
|
Options(Bytes)
|
|
MessageNumber(UInt32)
|
|
NextKey(flags~ : Byte, key_id~ : UInt32, public_key~ : Bytes?)
|
|
Ack(Array[(UInt32, UInt32)])
|
|
AckRequest(Byte)
|
|
GarlicClove(delivery~ : GarlicDelivery, i2np_short~ : Bytes)
|
|
Padding(Bytes)
|
|
Unknown(Byte, Bytes)
|
|
}
|
|
pub fn RatchetBlock::encode(Self, @encoding.Writer) -> Unit raise RatchetError
|
|
|
|
pub struct RatchetPeerSession {
|
|
remote_static_pub : Bytes
|
|
mut send_root_key : Bytes
|
|
mut send_tagset : TagSet
|
|
mut recv_root_key : Bytes
|
|
mut recv_tagset : TagSet
|
|
recv_window : Array[(UInt32, Bytes, Bytes)]
|
|
mut dh_ratchet_key_id : UInt32
|
|
mut local_next_priv : Bytes?
|
|
mut local_next_pub : Bytes?
|
|
mut remote_next_pub : Bytes?
|
|
mut last_used_sec : UInt32
|
|
}
|
|
pub fn RatchetPeerSession::apply_dh_ratchet(Self, Bytes, Bytes, for_send~ : Bool) -> Unit raise RatchetError
|
|
pub fn RatchetPeerSession::encrypt_existing(Self, Array[RatchetBlock]) -> Bytes raise RatchetError
|
|
|
|
pub struct RatchetSessionManager {
|
|
local_static : @noise.KeyPair
|
|
sessions : Array[RatchetPeerSession]
|
|
outbound_pending : Array[(Bytes, PendingNewSession)]
|
|
inbound_pending : Array[PendingNewSession]
|
|
}
|
|
pub fn RatchetSessionManager::create_next_key_block(Self, Bytes, () -> Bytes) -> RatchetBlock? raise RatchetError
|
|
pub fn RatchetSessionManager::decrypt_incoming(Self, Bytes) -> (Bytes?, Array[RatchetBlock]) raise RatchetError
|
|
pub fn RatchetSessionManager::drop_session(Self, Bytes) -> Unit
|
|
pub fn RatchetSessionManager::encrypt_to_peer(Self, Bytes, Array[RatchetBlock], UInt32, () -> Bytes) -> Bytes raise RatchetError
|
|
pub fn RatchetSessionManager::new(@noise.KeyPair) -> Self
|
|
|
|
pub struct TagSet {
|
|
mut tag_ck : Bytes
|
|
sesstag_const : Bytes
|
|
mut symm_ck : Bytes
|
|
mut msg_num : UInt32
|
|
}
|
|
pub fn TagSet::next_entry(Self) -> (UInt32, Bytes, Bytes) raise RatchetError
|
|
|
|
// Type aliases
|
|
|
|
// Traits
|