ASN.1 module schema specification for DHT protocol

This commit is contained in:
Trolli Schmittlauch 2020-04-28 15:58:53 +02:00
parent e1228da74d
commit 24936d48c1
3 changed files with 81 additions and 9 deletions

View file

@ -2,12 +2,88 @@ FediChordProtocol DEFINITIONS AUTOMATIC TAGS ::= BEGIN
NodeID ::= INTEGER (0..115792089237316195423570985008687907853269984665640564039457584007913129639935) NodeID ::= INTEGER (0..115792089237316195423570985008687907853269984665640564039457584007913129639935)
Domain ::= VisibleString
Request ::= SEQUENCE { Request ::= SEQUENCE {
requestID INTEGER, requestID INTEGER,
senderID NodeID, senderID NodeID,
parts INTEGER, parts INTEGER, -- number of message parts
part INTEGER, part INTEGER, -- part number of this message
action ENUMERATED {queryID, join, leave, stabilise} action ENUMERATED {queryID, join, leave, stabilise, ping},
actionPayload CHOICE {
queryIDSendPayload QueryIDSendPayload,
joinSendPayload JoinSendPayload,
leaveSendPayload LeaveSendPayload,
stabiliseSendPayload StabiliseSendPayload
}
} }
Response ::= SEQUENCE {
responseTo INTEGER,
senderID NodeID,
parts INTEGER,
part INTEGER,
action ENUMERATED {queryID, join, leave, stabilise, ping},
actionPayload CHOICE {
queryIDReceivePayload QueryIDReceivePayload,
joinReceivePayload JoinReceivePayload,
leaveReceivePayload LeaveReceivePayload,
stabiliseReceivePayload StabiliseReceivePayload
}
}
NodeState ::= SEQUENCE {
nid NodeID,
domain Domain,
ipAddr OCTET STRING (SIZE(16)),
dhtPort INTEGER,
apPort INTEGER,
vServer INTEGER
}
CacheEntry ::= SEQUENCE {
node NodeState,
-- use unix time stamp, as DATE-TIME isn't supported by the Haskell lib
timestamp INTEGER
}
NodeCache ::= SEQUENCE OF CacheEntry
JoinSendPayload ::= NodeState
JoinReceivePayload ::= SEQUENCE {
successors SEQUENCE OF NodeID,
predecessors SEQUENCE OF NodeID,
cache NodeCache
}
QueryIDSendPayload ::= SEQUENCE {
targetID NodeID,
lBestNodes INTEGER
}
QueryResult ::= ENUMERATED { found, forward }
QueryIDReceivePayload ::= SEQUENCE {
result QueryResult,
nodeData NodeCache
}
StabiliseSendPayload ::= NodeState
StabiliseReceivePayload ::= SEQUENCE {
successors SEQUENCE OF NodeID,
predecessors SEQUENCE OF NodeID
-- ToDo: transfer of handled key data, if newly responsible for it
}
LeaveSendPayload ::= SEQUENCE {
successors SEQUENCE OF NodeID,
predecessors SEQUENCE OF NodeID
-- ToDo: transfer of own data to newly responsible node
}
LeaveReceivePayload ::= NULL -- just a confirmation
END END

View file

@ -111,6 +111,8 @@ data NodeState = NodeState {
, apPort :: Maybe PortNumber , apPort :: Maybe PortNumber
-- ^ port of the ActivityPub relay and storage service -- ^ port of the ActivityPub relay and storage service
-- might have to be queried first -- might have to be queried first
-- ==== internal state ====
, nodeCache :: NodeCache , nodeCache :: NodeCache
-- ^ EpiChord node cache with expiry times for nodes -- ^ EpiChord node cache with expiry times for nodes
-- as the map is ordered, lookups for the closes preceding node can be done using @lookupLT@ -- as the map is ordered, lookups for the closes preceding node can be done using @lookupLT@

View file

@ -37,12 +37,6 @@ testParser = do
getAll :: ASN1P.ParseASN1 [ASN1.ASN1] getAll :: ASN1P.ParseASN1 [ASN1.ASN1]
getAll = ASN1P.getMany ASN1P.getNext getAll = ASN1P.getMany ASN1P.getNext
-- | run a function of the next elements of a container of specified type
onNextContainer' :: ASN1.ASN1ConstructionType -> ASN1P.ParseASN1 a -> ASN1P.ParseASN1 a
onNextContainer' ty f = do
cont <- ASN1P.getNextContainer ty
either ASN1P.throwParseError return . trace (show cont) $ ASN1P.runParseASN1 f cont
--stringParser asn1obj = --stringParser asn1obj =
-- fmap (fromMaybe "" $ ASN1.asn1CharacterToString) ASN1P.getNext -- fmap (fromMaybe "" $ ASN1.asn1CharacterToString) ASN1P.getNext