The branch starts out by splitting the descriptor-generation code into its own file.
There is some code (currently in clientkey.[ch]) that I was not able to extract, since it is used when running as a client. I believe this code to be useless for clients, and I'll open another ticket to look at removing it or making it relay only. But that refactoring seems orthogonal to this one.
I've tried using some helper macros to generate the stubs in router.h. If we like those, we could extract them and use them to generate stubs in other files.
I'm traveling today, so I won't be able to check whether or not CI has passed. I'll put this into needs_review if it does.
I've answered the comment about the missing lock: that lock is only used to protect onion keys, which clients don't have.
I've also fixed the typo and rebased to master. I checked the conflicting diff in question (07ab22bfd3ce43a7c3f8a5e7dd8608ceb1de18b6) with --color-moved to make sure I didn't mess up any other code, but an extra look-see wouldn't hurt.
I opened #33739 (moved) for moving the dirauth-only keys to the dirauth module.
I've answered the comment about the missing lock: that lock is only used to protect onion keys, which clients don't have.
Thanks!
Can we add some comments that document this information?
+1
init_keys_common() and init_keys_client() don't have function comments, and init_keys_common() is a really confusing name for a relay-only function.
It looks like init_keys_client() has a function comment. (It was previously in the header file.) I'm not sure I understand how init_keys_common() is a relay-only function, though. It looks like init_keys_client() calls it?
OK I looked a bit more closely and it's more confusing than I thought. I think it really could use better documentation in comments.
The init_keys_common() definition in router.c is not built on clients, because router.c is not built on clients. However, clientkey.c includes router.h, which has a macro to stub out init_keys_common(). Also oddly enough, these patches change init_keys_common() to remove the static qualifier, which seems unnecessary to change?
Or maybe rewrite things so that the naming isn't so confusing?