Commit 62a5aad
committed
fix: wire dht router to composableRouter and return error when DHT disabled
fixes two issues with the GetClosestPeers endpoint:
1. endpoint returned HTTP 200 with empty results instead of actual DHT peers
2. when DHT disabled, returned HTTP 200 with empty results instead of error
root cause:
during rebase of PR #124 (commit 0dad3f7) when integrating with autoconf
refactor (PR #123 / ec76365), the dhtRouters initialization was accidentally
omitted from server.go. the autoconf PR renamed getCombinedRouting to
combineRouters and changed its signature, but the rebase failed to preserve
the dhtRouters creation line that existed in commit 42bd221.
changes:
- server.go:201-208: add explicit dhtRouters creation with caching and
sanitization, similar to original 42bd221 implementation
- server.go:232: wire dhtRouters to composableRouter.dht field
- server.go:338: update combineRouters signature to accept host.Host
parameter needed for GetClosestPeers peerstore lookups
- server_routers.go:73-77: return routing.ErrNotSupported instead of empty
iterator when DHT is nil, resulting in HTTP 500 instead of misleading
HTTP 200
- server_test.go:16,20,24: update combineRouters test calls with new signature
- server_dht_test.go:355-379: add test verifying HTTP 500 when DHT disabled1 parent 43188dd commit 62a5aad
File tree
4 files changed
+48
-10
lines changed4 files changed
+48
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
194 | 194 | | |
195 | 195 | | |
196 | 196 | | |
197 | | - | |
198 | | - | |
199 | | - | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
200 | 209 | | |
201 | 210 | | |
202 | 211 | | |
| |||
220 | 229 | | |
221 | 230 | | |
222 | 231 | | |
| 232 | + | |
223 | 233 | | |
224 | 234 | | |
225 | 235 | | |
| |||
325 | 335 | | |
326 | 336 | | |
327 | 337 | | |
328 | | - | |
| 338 | + | |
329 | 339 | | |
330 | 340 | | |
331 | 341 | | |
332 | | - | |
| 342 | + | |
333 | 343 | | |
334 | 344 | | |
335 | | - | |
| 345 | + | |
336 | 346 | | |
337 | 347 | | |
338 | 348 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
351 | 351 | | |
352 | 352 | | |
353 | 353 | | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
354 | 380 | | |
355 | 381 | | |
356 | 382 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
75 | 77 | | |
76 | 78 | | |
77 | 79 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
0 commit comments