Requirements
Native support in Brave (brave/brave-browser#10220) requires a way of starting daemon without worrying about user having the default ports taken.
Specific needs are:
$IPFS_PATH/config should be the source of truth about Swarm, API and Gateway ports
- Conflict avoidance should be future-proof, meaning if current port gets taken by something else in the future, daemon will automatically pick next one and update source of truth
Note that setting ports to 0 is not feasible:
- it is meant to be used in tests, reading config tells us nothing about
Gateway port, produces different port every time, and it is hard to read randomly-picked ports without capturing stout of ipfs daemon
- we don't want gateway URLs to change all the time, as that would mean Origins are different every time daemon restarts, which breaks web storage on websites. it should change only if there is a conflict.
Proposed implementation
Add a parameter ipfs daemon --update-ports-if-taken
(or --find-free-ports ? suggestions? 🚲 🏚️ )
This new parameter should enable additional checks before ipfs daemon starts:
- check if ports defined in
$IPFS_PATH/config are free before starting (Swarm, API, Gateway)
- if not
- increase them
+1 and retry until all are free
- save new values to
$IPFS_PATH/config
- start regular
ipfs daemon
cc @autonome @aschmahmann
Requirements
Native support in Brave (brave/brave-browser#10220) requires a way of starting daemon without worrying about user having the default ports taken.
Specific needs are:
$IPFS_PATH/configshould be the source of truth about Swarm, API and Gateway portsNote that setting ports to
0is not feasible:Gatewayport, produces different port every time, and it is hard to read randomly-picked ports without capturing stout ofipfs daemonProposed implementation
Add a parameter
ipfs daemon --update-ports-if-taken(or
--find-free-ports? suggestions? 🚲 🏚️ )This new parameter should enable additional checks before
ipfs daemonstarts:$IPFS_PATH/configare free before starting (Swarm,API,Gateway)+1and retry until all are free$IPFS_PATH/configipfs daemoncc @autonome @aschmahmann