@@ -264,37 +264,3 @@ func reserveSubnet(subnet string, period time.Duration) bool {
264
264
reservedSubnets .Store (subnet , reservation {createdAt : time .Now ()})
265
265
return true
266
266
}
267
-
268
- // IncIP returns address calculated by adding (positive or negative) val to addr.
269
- // If addr is not in CIDR format it will use its default mask and set "out-of-network" if calculated address doesn't belong to same network as addr.
270
- func IncIP (addr string , val int ) (calc string , oon bool , err error ) {
271
- ip , network , err := net .ParseCIDR (addr )
272
- if err != nil { // addr not in CIDR format - use default mask for IP addr
273
- ip = net .ParseIP (addr )
274
- if ip == nil {
275
- return "" , false , fmt .Errorf ("failed parsing address %s: %w" , addr , err )
276
- }
277
- prefix , _ := ip .DefaultMask ().Size () // assume default network mask
278
- _ , network , err = net .ParseCIDR (fmt .Sprintf ("%s/%d" , addr , prefix ))
279
- if err != nil {
280
- return "" , false , fmt .Errorf ("failed parsing CIDR %s/%d: %w" , addr , prefix , err )
281
- }
282
- }
283
-
284
- ip0 := ip .To4 () // convert to 4-byte representation
285
- n0 := binary .BigEndian .Uint32 (ip0 )
286
-
287
- n1 := int (n0 ) + val
288
- if n1 < 0 {
289
- return "" , true , fmt .Errorf ("failed decrementing IP %s: value %d too big" , addr , val )
290
- }
291
-
292
- ip1 := make (net.IP , 4 )
293
- binary .BigEndian .PutUint32 (ip1 , uint32 (n1 ))
294
-
295
- if ! network .Contains (ip1 ) {
296
- return "" , true , fmt .Errorf ("failed incrementing IP %s: value %d too big (%s would cross network boundary)" , addr , val , ip )
297
- }
298
-
299
- return ip1 .String (), false , nil
300
- }
0 commit comments