@@ -83,6 +83,170 @@ func convert(in io.Reader, out io.Writer, convBootstrap convArray, convAddresses
8383 return err
8484}
8585
86+ // Convert Routing.Type to implicit default
87+ // https://github.com/ipfs/kubo/pull/9475
88+ func convertRouting (confMap map [string ]interface {}) {
89+ routing , _ := confMap ["Routing" ].(map [string ]interface {})
90+ if routing == nil {
91+ log .Log ("No Routing field in config, skipping" )
92+ return
93+ }
94+
95+ rType , ok := routing ["Type" ].(string )
96+ if ! ok {
97+ log .Log ("No Routing.Type field in config, skipping" )
98+ return
99+ }
100+ if rType == "dht" || rType == "" {
101+ delete (routing , "Type" )
102+ } else {
103+ log .Log ("Routing.Type settings is different than the old default, skipping" )
104+ }
105+ }
106+ func undoRouting (confMap map [string ]interface {}) {
107+ routing , ok := confMap ["Routing" ].(map [string ]interface {})
108+ if routing == nil {
109+ log .Log ("No Routing field in config, skipping" )
110+ return
111+ }
112+
113+ t , ok := routing ["Type" ].(string )
114+ if ! ok || t == "" {
115+ routing ["Type" ] = "dht"
116+ } else {
117+ log .Log ("Custom Routing.Type settings, skipping" )
118+ }
119+ }
120+
121+ // Convert Reprovider to implicit defaults
122+ // https://github.com/ipfs/kubo/pull/9326
123+ func convertReprovider (confMap map [string ]interface {}) {
124+ reprovider , _ := confMap ["Reprovider" ].(map [string ]interface {})
125+ if reprovider == nil {
126+ log .Log ("No Reprovider field in config, skipping" )
127+ return
128+ }
129+
130+ interval , ok := reprovider ["Interval" ].(string )
131+ if ! ok {
132+ log .Log ("No Reprovider.Interval field in config, skipping" )
133+ return
134+ }
135+ if interval == "12h" {
136+ delete (reprovider , "Interval" )
137+ } else {
138+ log .Log ("Reprovider.Interval settings is different than the old default, skipping" )
139+ }
140+
141+ strategy , ok := reprovider ["Strategy" ].(string )
142+ if ! ok {
143+ log .Log ("No Reprovider.Strategy field in config, skipping" )
144+ return
145+ }
146+ if strategy == "all" {
147+ delete (reprovider , "Strategy" )
148+ } else {
149+ log .Log ("Reprovider.Strategy settings is different than the old default, skipping" )
150+ }
151+ }
152+ func undoReprovider (confMap map [string ]interface {}) {
153+ reprovider , _ := confMap ["Reprovider" ].(map [string ]interface {})
154+ if reprovider == nil {
155+ log .Log ("No Reprovider field in config, skipping" )
156+ return
157+ }
158+
159+ _ , ok := reprovider ["Interval" ].(string )
160+ if ! ok {
161+ reprovider ["Interval" ] = "12h"
162+ } else {
163+ log .Log ("Custom Reprovider.Interval settings present, skipping" )
164+ }
165+
166+ _ , ok = reprovider ["Strategy" ].(string )
167+ if ! ok {
168+ reprovider ["Strategy" ] = "all"
169+ } else {
170+ log .Log ("Custom Reprovider.Strategy settings present, skipping" )
171+ }
172+ }
173+
174+ // Convert Swarm.ConnMgr to implicit defaults
175+ // https://github.com/ipfs/kubo/pull/9467
176+ func convertConnMgr (confMap map [string ]interface {}) {
177+ swarm , _ := confMap ["Swarm" ].(map [string ]interface {})
178+ if swarm == nil {
179+ log .Log ("No Swarm field in config, skipping" )
180+ return
181+ }
182+ connmgr , _ := swarm ["ConnMgr" ].(map [string ]interface {})
183+ if connmgr == nil {
184+ log .Log ("No Swarm.ConnMgr field in config, skipping" )
185+ return
186+ }
187+ cmType , ok := connmgr ["Type" ].(string )
188+ if ! ok {
189+ log .Log ("No Swarm.ConnMgr.Type field in config, skipping" )
190+ return
191+ }
192+ cmLowWater , ok := connmgr ["LowWater" ].(float64 )
193+ if ! ok {
194+ log .Log ("No Swarm.ConnMgr.LowWater field in config, skipping" )
195+ return
196+ }
197+ cmHighWater , ok := connmgr ["HighWater" ].(float64 )
198+ if ! ok {
199+ log .Log ("No Swarm.ConnMgr.HighWater field in config, skipping" )
200+ return
201+ }
202+ cmGrace , ok := connmgr ["GracePeriod" ].(string )
203+ if ! ok {
204+ log .Log ("No Swarm.ConnMgr.GracePeriod field in config, skipping" )
205+ return
206+ }
207+
208+ if cmType == "basic" &&
209+ int (cmLowWater ) == 600 &&
210+ int (cmHighWater ) == 900 &&
211+ cmGrace == "20s" {
212+ // remove defaults from config, switch user to implicit ones
213+ delete (connmgr , "Type" )
214+ delete (connmgr , "LowWater" )
215+ delete (connmgr , "HighWater" )
216+ delete (connmgr , "GracePeriod" )
217+ } else {
218+ log .Log ("Swarm.ConnMgr settings are different than the old defaults, skipping" )
219+ }
220+ }
221+ func undoConnMgr (confMap map [string ]interface {}) {
222+ swarm , _ := confMap ["Swarm" ].(map [string ]interface {})
223+ if swarm == nil {
224+ log .Log ("No Swarm field in config, skipping" )
225+ return
226+ }
227+ connmgr , _ := swarm ["ConnMgr" ].(map [string ]interface {})
228+ if connmgr == nil {
229+ log .Log ("No Swarm.ConnMgr field in config, skipping" )
230+ return
231+ }
232+ _ , ok := connmgr ["Type" ].(string )
233+ if ! ok {
234+ connmgr ["Type" ] = "basic"
235+ }
236+ _ , ok = connmgr ["LowWater" ].(float64 )
237+ if ! ok {
238+ connmgr ["LowWater" ] = 600
239+ }
240+ _ , ok = connmgr ["HighWater" ].(float64 )
241+ if ! ok {
242+ connmgr ["HighWater" ] = 900
243+ }
244+ _ , ok = connmgr ["GracePeriod" ].(string )
245+ if ! ok {
246+ connmgr ["GracePeriod" ] = "20s"
247+ }
248+ }
249+
86250// Convert Bootstrap addresses to/from QUIC
87251func convertBootstrap (confMap map [string ]interface {}, conv convArray ) {
88252 bootstrapi , _ := confMap ["Bootstrap" ].([]interface {})
0 commit comments