(FYI: you can just push the fixup on the same branch on Github, the PR will adapt. This way, we keep the discussion thread instead of spawning it to multiple PRs.)
In RELAY_RESOLVED there's also TTL value, which NETINFO does not have. I suppose we could define an object consisting of type-length-value sequence and use it in both cells. That would require to either: 1) Implement file include feature in trunnel (AFAIK it doesn't support that) or 2) have both RELAY_RESOLVED and NETINFO cells defined in the same trunnel file (e.g. cells.trunnel or handshake.trunnel or something).
Or we could explicitly decouple wire formats of the two cells and decide that they are independently defined. RELAY_RESOLVED addresses can have one of the five types (hostname, IPv4, IPv6, transient error, non-transient error), but does the same apply for NETINFO? Does it make sense to ever send hostname in NETINFO cell during handshake? Error conditions can always happen, but does Tor protocol specify a way to signal them when NETINFO cell is needed?
My code takes second path, but I think we need to take a step back and do a little bit of design work here and possibly a patch to tor-spec regarding how addresses are represented in Tor cells and whether or not there is/should be a dependency between common part of wire format in different cells.
In RELAY_RESOLVED there's also TTL value, which NETINFO does not have. I suppose we could define an object consisting of type-length-value sequence and use it in both cells. That would require to either: 1) Implement file include feature in trunnel (AFAIK it doesn't support that) or 2) have both RELAY_RESOLVED and NETINFO cells defined in the same trunnel file (e.g. cells.trunnel or handshake.trunnel or something).
Hmmm so I think the TTL field is specific to the RELAY_RESOLVED cell so in theory we could do a trunnel definition (thus obj) that would represent an "address" as section 6.4 specifies without the TTL.
Then we would use that object with RELAY_RESOLVED and explicitly add the TTL field. Sorta makes sense?
Or we could explicitly decouple wire formats of the two cells and decide that they are independently defined. RELAY_RESOLVED addresses can have one of the five types (hostname, IPv4, IPv6, transient error, non-transient error), but does the same apply for NETINFO? Does it make sense to ever send hostname in NETINFO cell during handshake? Error conditions can always happen, but does Tor protocol specify a way to signal them when NETINFO cell is needed?
My code takes second path, but I think we need to take a step back and do a little bit of design work here and possibly a patch to tor-spec regarding how addresses are represented in Tor cells and whether or not there is/should be a dependency between common part of wire format in different cells.
The problem with changing the format is backward compatibility so changing what those cells contain is a big endeavor tbh.
Well I'm not talking about making changes in how Tor protocols de facto works and what wire format is actually being used. What I mean to change is to reword section 4.5 to be more precise about what is in the address part of NETINFO cell and refrain from mentioning section 6.4, as that confusingly says that we're reusing wire format fragment from RELAY_RESOLVED cell in NETINFO cell (which is a shaky claim, for reasons outlined above).
I propose to keep netinfo.trunnel as it is now, and also merge the following patch to torspec:
Well I'm not talking about making changes in how Tor protocols de facto works and what wire format is actually being used. What I mean is to change is to reword section 4.5 to be more precise about what is in the address part of NETINFO cell and refrain from mentioning section 6.4, as that's confusingly says that we're reusing wire format fragment from RELAY_RESOLVED cell in NETINFO cell (which is a shaky claim, for reasons outlined above).
Ok I think this is a wise thing to do. This means that the NETINFO address format becomes specific to the NETINFO cell and thus needs its own specification in tor-spec.txt. I'm fine with that and less hackish then "check other section but minus one field and also ignore some Types"...
I propose to keep netinfo.trunnel as it is now, and also merge the following patch to torspec:
This is basically it but I would use the syntax from section 5.1.2 for example. The HS specs do use that syntax all around and it is much nicer and clearer. Ultimately, we want tor-spec.txt to all follow the same style and that one from section 5.1.2 is a step in the right direction.
We should be good to go with that code with such a spec change from above.
There is probably a world where we might formalize the concept of "Address" and then also use it in the RESOLVED cell but for now I'm happy with this and the code.
Hi! I've left a couple of comments on the patch. I think we're supposed to be allowing and ignoring unrecognized address types, rather than treating them as reason to close the connection.