brona / iproute2mac

CLI wrapper for basic network utilites on Mac OS X inspired with iproute2 on Linux systems - ip command.
MIT License
898 stars 73 forks source link

`ip r` throws IndexError in macOS Catalina #32

Closed boris1993 closed 5 years ago

boris1993 commented 5 years ago

Command: ip r Output:

$ ip r
Traceback (most recent call last):
  File "/usr/local/bin/ip", line 556, in <module>
    main(sys.argv[1:])
  File "/usr/local/bin/ip", line 55, in inner
    if not func(*args, **kwargs):
  File "/usr/local/bin/ip", line 550, in main
    return cmd_func(argv, af)
  File "/usr/local/bin/ip", line 55, in inner
    if not func(*args, **kwargs):
  File "/usr/local/bin/ip", line 123, in do_route
    return do_route_list(af)
  File "/usr/local/bin/ip", line 171, in do_route_list
    dev    = ra[5]
IndexError: list index out of range
boris1993 commented 5 years ago

This is the output of netstat -nr -f inet 2>/dev/null on my macOS 10.15

Routing tables

Internet:
Destination        Gateway            Flags        Netif Expire
default            192.168.52.1       UGSc           en0
127                127.0.0.1          UCS            lo0
127.0.0.1          127.0.0.1          UH             lo0
169.254            link#4             UCS            en0      !
192.168.52/23      link#4             UCS            en0      !
192.168.52.1/32    link#4             UCS            en0      !
192.168.52.1       cc:16:7e:77:65:c4  UHLWIir        en0    509
192.168.53.90/32   link#4             UCS            en0      !
224.0.0/4          link#4             UmCS           en0      !
224.0.0.251        1:0:5e:0:0:fb      UHmLWI         en0
239.255.255.250    1:0:5e:7f:ff:fa    UHmLWI         en0
255.255.255.255/32 link#4             UCS            en0      !

in which the interfaces are on the 4th column instead of the 6th column.

I don't know if it will work on macOS 10.14 or earlier system if I modify ra[5] to ra[3] so I'm not gonna make a PR. Hope this information will help.

boris1993 commented 5 years ago

Seems fixed by #31. Closed.