GeekVisit / uproot

A tool to migrate static leases between routers
137 stars 0 forks source link

Not all OpenWRT versions use 3 lines for host definitions #3

Open akhuraskin opened 3 years ago

akhuraskin commented 3 years ago

Keeping 3 lines after config host is not enough for some versions of OpenWRT. For OpenWrt SNAPSHOT r12235-49caf9f98a, /etc/config/dhcp contains at least 4 lines for each host config. As a result, OpenWRT export instructions don't work for these configurations. Changing 3 to 4 fixes the issue in my case, but I'm not sure if this will work for everybody:

grep -hnr -A4 "config host" /etc/config/dhcp > static_leases.openwrt
wongjustin99 commented 1 year ago

Need to make sure each line has a 'name' field as well. I have a bunch of leases without names in openwrt and this script doesn't like that as part of its validation.

Scanning static_leases.openwrt... Error:#0 _GrowableList.[] (dart:core-patch/growable_array.dart:254)

1 ValidateLeases.removeBadLeases (package:uprt/src/validate_leases.dart:175)

2 OpenWrt.getLeaseMap (package:uprt/src/open_wrt.dart:124)

3 Converter.getSourceLeaseMap (package:uprt/src/converter.dart:228)

4 Converter.toJson (package:uprt/src/converter.dart:260)

5 Converter.toOutput (package:uprt/src/converter.dart:70)

6 Converter.convertFileList (package:uprt/src/converter.dart:29)

7 main (file:///g:/users/david/documents/mega/projects/dart/convert-ddwrt/cli/bin/uprt.dart:74)

8 _delayEntrypointInvocation. (dart:isolate-patch/isolate_patch.dart:281)

9 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:184)