- Add `--public`, `--hops`, `--hosts`, and `--debug` router flags; `--public` auto-reseeds from the live network and keeps a status loop running. - Route NetDB lookups through tunnels with Noise_N garlic wrapping, fan out to two floodfills, and fetch unknown RouterInfos in the background. - Back off failed NTCP2 peers and fall back to IPv6 addresses when no IPv4 NTCP2 address is available. - Size session LeaseSet2 expiry from lease end dates and use the destination's X25519 key when present. - Add canonical Ed25519 Destination KeyCertificate constructors with round-trip tests. - Fix DatabaseStore gzip handling to honor the length prefix, and send `Wget/1.11.4` as the reseed User-Agent.
262 lines
8.2 KiB
Plaintext
262 lines
8.2 KiB
Plaintext
// Generated using `moon info`, DON'T EDIT IT
|
|
package "experiments/moon_i2p/common"
|
|
|
|
import {
|
|
"experiments/moon_i2p/crypto",
|
|
"experiments/moon_i2p/encoding",
|
|
"moonbitlang/core/debug",
|
|
}
|
|
|
|
// Values
|
|
pub fn parse_reseed_su3(Bytes) -> Array[RouterInfo] raise CommonError
|
|
|
|
// Errors
|
|
#derive(Eq, @debug.Debug)
|
|
pub suberror CommonError {
|
|
Encoding(@encoding.EncodingError)
|
|
Crypto(@crypto.CryptoError)
|
|
InvalidLength(String)
|
|
InvalidFormat(String)
|
|
}
|
|
|
|
// Types and methods
|
|
#derive(Eq, @debug.Debug)
|
|
pub(all) enum Certificate {
|
|
Null
|
|
HashCash(Bytes)
|
|
Hidden
|
|
Signed(Bytes)
|
|
Multiple(Bytes)
|
|
Key(KeyCertificate)
|
|
Unknown(Byte, Bytes)
|
|
}
|
|
pub fn Certificate::decode(@encoding.Reader) -> Self raise CommonError
|
|
pub fn Certificate::encode(Self, @encoding.Writer) -> Unit
|
|
|
|
#derive(Eq, @debug.Debug)
|
|
pub(all) enum CryptoPublicKeyType {
|
|
ElGamal
|
|
P256
|
|
P384
|
|
P521
|
|
X25519
|
|
Unknown(UInt32)
|
|
}
|
|
pub fn CryptoPublicKeyType::from_u16(UInt32) -> Self
|
|
pub fn CryptoPublicKeyType::key_length(Self) -> Int32
|
|
pub fn CryptoPublicKeyType::to_u16(Self) -> UInt32
|
|
|
|
#derive(Eq, @debug.Debug)
|
|
pub struct Destination {
|
|
inner : KeysAndCert
|
|
}
|
|
pub fn Destination::b32_address(Self) -> String
|
|
pub fn Destination::decode(@encoding.Reader) -> Self raise CommonError
|
|
pub fn Destination::encode(Self, @encoding.Writer) -> Unit
|
|
pub fn Destination::from_base64(String) -> Self raise CommonError
|
|
pub fn Destination::hash(Self) -> Hash
|
|
pub fn Destination::new(KeysAndCert) -> Self
|
|
pub fn Destination::new_ed25519(Bytes, padding? : Bytes) -> Self raise CommonError
|
|
pub fn Destination::new_x25519_ed25519(Bytes, Bytes, padding? : Bytes) -> Self raise CommonError
|
|
pub fn Destination::to_base64(Self) -> String
|
|
pub fn Destination::to_bytes(Self) -> Bytes
|
|
|
|
#derive(Eq, @debug.Debug)
|
|
pub struct Hash {
|
|
bytes : Bytes
|
|
}
|
|
pub fn Hash::as_bytes(Self) -> Bytes
|
|
pub fn Hash::decode(@encoding.Reader) -> Self raise CommonError
|
|
pub fn Hash::encode(Self, @encoding.Writer) -> Unit
|
|
pub fn Hash::from_bytes(Bytes) -> Self raise CommonError
|
|
pub fn Hash::sha256(Bytes) -> Self
|
|
pub fn Hash::to_b32_address(Self) -> String
|
|
pub fn Hash::to_base32(Self) -> String
|
|
pub fn Hash::to_base64(Self) -> String
|
|
pub fn Hash::to_hex(Self) -> String
|
|
|
|
#derive(Eq, @debug.Debug)
|
|
pub(all) struct KeyCertificate {
|
|
sig_type : SigningPublicKeyType
|
|
crypto_type : CryptoPublicKeyType
|
|
excess_signing_key : Bytes
|
|
excess_crypto_key : Bytes
|
|
}
|
|
pub fn KeyCertificate::new(SigningPublicKeyType, CryptoPublicKeyType, excess_signing_key? : Bytes, excess_crypto_key? : Bytes) -> Self
|
|
|
|
#derive(Eq, @debug.Debug)
|
|
pub struct KeysAndCert {
|
|
key_data : Bytes
|
|
certificate : Certificate
|
|
}
|
|
pub fn KeysAndCert::crypto_public_key(Self) -> Bytes
|
|
pub fn KeysAndCert::crypto_type(Self) -> CryptoPublicKeyType
|
|
pub fn KeysAndCert::decode(@encoding.Reader) -> Self raise CommonError
|
|
pub fn KeysAndCert::encode(Self, @encoding.Writer) -> Unit
|
|
pub fn KeysAndCert::hash(Self) -> Hash
|
|
pub fn KeysAndCert::new_destination_ed25519(Bytes, padding? : Bytes) -> Self raise CommonError
|
|
pub fn KeysAndCert::new_x25519_ed25519(Bytes, Bytes, padding? : Bytes) -> Self raise CommonError
|
|
pub fn KeysAndCert::signing_public_key(Self) -> Bytes
|
|
pub fn KeysAndCert::signing_type(Self) -> SigningPublicKeyType
|
|
pub fn KeysAndCert::to_bytes(Self) -> Bytes
|
|
|
|
#derive(Eq, @debug.Debug)
|
|
pub(all) struct Lease {
|
|
tunnel_gw : Hash
|
|
tunnel_id : UInt32
|
|
end_date_ms : UInt64
|
|
}
|
|
pub fn Lease::decode(@encoding.Reader) -> Self raise CommonError
|
|
pub fn Lease::encode(Self, @encoding.Writer) -> Unit
|
|
|
|
#derive(Eq, @debug.Debug)
|
|
pub(all) struct Lease2 {
|
|
tunnel_gw : Hash
|
|
tunnel_id : UInt32
|
|
end_date_sec : UInt32
|
|
}
|
|
pub fn Lease2::decode(@encoding.Reader) -> Self raise CommonError
|
|
pub fn Lease2::encode(Self, @encoding.Writer) -> Unit
|
|
|
|
#derive(Eq, @debug.Debug)
|
|
pub(all) struct LeaseSet2 {
|
|
destination : Destination
|
|
published_sec : UInt32
|
|
expires_offset : UInt32
|
|
flags : UInt32
|
|
offline_sig : OfflineSignature?
|
|
options : Mapping
|
|
encryption_keys : Array[LeaseSet2EncryptionKey]
|
|
leases : Array[Lease2]
|
|
signature : Bytes
|
|
}
|
|
pub fn LeaseSet2::decode(@encoding.Reader) -> Self raise CommonError
|
|
pub fn LeaseSet2::encode(Self, @encoding.Writer) -> Unit raise CommonError
|
|
pub fn LeaseSet2::sign_ed25519(Self, Bytes) -> Self raise CommonError
|
|
pub fn LeaseSet2::sign_with_transient_ed25519(Self, Bytes) -> Self raise CommonError
|
|
pub fn LeaseSet2::signing_bytes(Self) -> Bytes raise CommonError
|
|
pub fn LeaseSet2::to_bytes(Self) -> Bytes raise CommonError
|
|
pub fn LeaseSet2::unsigned_bytes(Self) -> Bytes raise CommonError
|
|
pub fn LeaseSet2::verify_signature(Self) -> Bool
|
|
|
|
#derive(Eq, @debug.Debug)
|
|
pub(all) struct LeaseSet2EncryptionKey {
|
|
key_type : CryptoPublicKeyType
|
|
key_data : Bytes
|
|
}
|
|
|
|
#derive(Eq, @debug.Debug)
|
|
pub struct Mapping {
|
|
entries : Array[(String, String)]
|
|
}
|
|
pub fn Mapping::decode(@encoding.Reader) -> Self raise CommonError
|
|
pub fn Mapping::encode(Self, @encoding.Writer) -> Unit raise CommonError
|
|
pub fn Mapping::from_entries(Array[(String, String)]) -> Self
|
|
pub fn Mapping::get(Self, String) -> String?
|
|
pub fn Mapping::length(Self) -> Int32
|
|
pub fn Mapping::new() -> Self
|
|
pub fn Mapping::set(Self, String, String) -> Unit
|
|
|
|
#derive(Eq, @debug.Debug)
|
|
pub(all) struct OfflineSignature {
|
|
expires_sec : UInt32
|
|
transient_sig_type : SigningPublicKeyType
|
|
transient_pub_key : Bytes
|
|
signature : Bytes
|
|
}
|
|
pub fn OfflineSignature::decode(@encoding.Reader, SigningPublicKeyType) -> Self raise CommonError
|
|
pub fn OfflineSignature::encode(Self, @encoding.Writer) -> Unit
|
|
pub fn OfflineSignature::sign_ed25519(Self, Bytes) -> Self raise CommonError
|
|
pub fn OfflineSignature::unsigned_bytes(Self) -> Bytes
|
|
pub fn OfflineSignature::verify_ed25519(Self, Bytes) -> Bool
|
|
|
|
#derive(Eq, @debug.Debug)
|
|
pub(all) struct RouterAddress {
|
|
cost : Byte
|
|
expiration : UInt64
|
|
transport_style : String
|
|
options : Mapping
|
|
}
|
|
pub fn RouterAddress::decode(@encoding.Reader) -> Self raise CommonError
|
|
pub fn RouterAddress::encode(Self, @encoding.Writer) -> Unit raise CommonError
|
|
pub fn RouterAddress::new(Byte, String, Mapping, expiration? : UInt64) -> Self
|
|
|
|
#derive(Eq, @debug.Debug)
|
|
pub struct RouterIdentity {
|
|
inner : KeysAndCert
|
|
}
|
|
pub fn RouterIdentity::b32_address(Self) -> String
|
|
pub fn RouterIdentity::crypto_public_key(Self) -> Bytes
|
|
pub fn RouterIdentity::decode(@encoding.Reader) -> Self raise CommonError
|
|
pub fn RouterIdentity::encode(Self, @encoding.Writer) -> Unit
|
|
pub fn RouterIdentity::hash(Self) -> Hash
|
|
pub fn RouterIdentity::new(KeysAndCert) -> Self
|
|
pub fn RouterIdentity::new_x25519_ed25519(Bytes, Bytes, padding? : Bytes) -> Self raise CommonError
|
|
pub fn RouterIdentity::signing_public_key(Self) -> Bytes
|
|
pub fn RouterIdentity::signing_type(Self) -> SigningPublicKeyType
|
|
pub fn RouterIdentity::to_bytes(Self) -> Bytes
|
|
|
|
#derive(Eq, @debug.Debug)
|
|
pub(all) struct RouterInfo {
|
|
identity : RouterIdentity
|
|
published : UInt64
|
|
addresses : Array[RouterAddress]
|
|
options : Mapping
|
|
signature : Bytes
|
|
}
|
|
pub fn RouterInfo::decode(@encoding.Reader) -> Self raise CommonError
|
|
pub fn RouterInfo::encode(Self, @encoding.Writer) -> Unit raise CommonError
|
|
pub fn RouterInfo::sign_ed25519(Self, Bytes) -> Self raise CommonError
|
|
pub fn RouterInfo::to_bytes(Self) -> Bytes raise CommonError
|
|
pub fn RouterInfo::unsigned_bytes(Self) -> Bytes raise CommonError
|
|
pub fn RouterInfo::verify_signature(Self) -> Bool
|
|
|
|
#derive(Eq, @debug.Debug)
|
|
pub struct SessionKey {
|
|
bytes : Bytes
|
|
}
|
|
pub fn SessionKey::from_bytes(Bytes) -> Self raise CommonError
|
|
|
|
#derive(Eq, @debug.Debug)
|
|
pub struct SessionTag {
|
|
bytes : Bytes
|
|
}
|
|
pub fn SessionTag::from_bytes(Bytes) -> Self raise CommonError
|
|
|
|
#derive(Eq, @debug.Debug)
|
|
pub(all) enum SigningPublicKeyType {
|
|
DsaSha1
|
|
EcdsaSha256P256
|
|
EcdsaSha384P384
|
|
EcdsaSha512P521
|
|
RsaSha256_2048
|
|
RsaSha384_3072
|
|
RsaSha512_4096
|
|
EdDsaSha512Ed25519
|
|
EdDsaSha512Ed25519ph
|
|
RedDsaSha512Ed25519
|
|
Unknown(UInt32)
|
|
}
|
|
pub fn SigningPublicKeyType::from_u16(UInt32) -> Self
|
|
pub fn SigningPublicKeyType::public_key_length(Self) -> Int32
|
|
pub fn SigningPublicKeyType::signature_length(Self) -> Int32
|
|
pub fn SigningPublicKeyType::to_u16(Self) -> UInt32
|
|
|
|
#derive(Eq, @debug.Debug)
|
|
pub(all) struct Su3File {
|
|
format_version : Byte
|
|
sig_type : UInt32
|
|
version : String
|
|
signer_id : String
|
|
file_type : Byte
|
|
content_type : Byte
|
|
content : Bytes
|
|
signature : Bytes
|
|
signed_bytes_len : Int32
|
|
}
|
|
pub fn Su3File::decode(Bytes) -> Self raise CommonError
|
|
|
|
// Type aliases
|
|
|
|
// Traits
|