robphoenix / trawl Goto Github PK
View Code? Open in Web Editor NEW:boat: A strong fishing net for dragging along the sea bottom to collect IP addresses and similar flotsam & jetsam
License: Apache License 2.0
:boat: A strong fishing net for dragging along the sea bottom to collect IP addresses and similar flotsam & jetsam
License: Apache License 2.0
remove ipv6 from default and add a flag for it
[rob@agnesmartin] ~
> trawl
wlp1s0 192.168.1.78 255.255.255.0 192.168.1.0/24 1500 10:02:b5:e4:de:8c fe80::defe:3c33:4335:e669/64
enx9cebe838355c 10.90.128.6 255.255.0.0 10.90.0.0/16 1500 9c:eb:e8:38:35:5c fe80::9eeb:e8ff:fe38:355c/64
docker0 172.17.0.1 255.255.0.0 172.17.0.0/16 1500 02:42:d4:0b:98:63 -
Use Travis CI to build, using gox, and release, using ghr, on pushed tags (release branches?)
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x402fd7]
goroutine 1 [running]:
panic(0x624da0, 0xc42000c130)
/usr/local/go/src/runtime/panic.go:500 +0x1a1
main.New(0x7, 0x5dc, 0xc42007cfe0, 0xf, 0xc4200f3014, 0x6, 0x8ec, 0x13, 0xc4200742a0, 0x0, ...)
/home/rob/code/go/src/github.com/robphoenix/trawl/trawl.go:45 +0x1d7
main.main()
/home/rob/code/go/src/github.com/robphoenix/trawl/main.go:141 +0x76f
I think it belongs under a flag instead.
As interface names are not always a simple eth0
, (wlp1s0
on linux, Local Area Connection
on Windows) it would be good if this used a regex rather than the full interface name. I've always found myself in the past having to list the interface names to then get specific info about them.
$ trawl w*
wlp1s0 192.168.1.78 255.255.255.0 192.168.1.0/24 1500 7d:1a:b5:54:de:8c fe80::defe:3c33:4335:e669/64
% trawl w*
Wireless Network Connection 10.26.101.64 255.255.255.0 10.26.101.0/24 1500 87:77:a3:d1:7e:2c fe80::48e8:96c3:7457:8a3d/64
I'm not sure how I'd want to deal with multiple interfaces that match the regex, I guess it would be best to list all that match, rather than just the first, or list all matches and asking for a more specific regex.
If nothing matches it would be good to provide a list of available interfaces.
$ trawl y*
Available Interfaces:
lo
tun0
wlp1s0
docker0
I don't know why, yet.
C:\Users\robertph\go\src\github.com\robphoenix\trawl [master ↓]
λ .\trawl.exe
panic: runtime error: index out of range
goroutine 33 [running]:
panic(0x5f6600, 0xc042004040)
C:/Go/src/runtime/panic.go:500 +0x1af
main.New(0x27, 0x500, 0xc04208c990, 0x2d, 0xc04203eee0, 0x8, 0x8, 0x18, 0x0, 0x0, ...)
C:/Users/robertph/go/src/github.com/robphoenix/trawl/main.go:88 +0x3a8
main.main.func1(0xc04203c300, 0x27, 0x500, 0xc04208c990, 0x2d, 0xc04203eee0, 0x8, 0x8, 0x18)
C:/Users/robertph/go/src/github.com/robphoenix/trawl/main.go:50 +0x56
created by main.main
C:/Users/robertph/go/src/github.com/robphoenix/trawl/main.go:55 +0x154
C:\Users\robertph\go\src\github.com\robphoenix\trawl [master ↓]
λ .\trawl.exe
panic: runtime error: index out of range
goroutine 29 [running]:
panic(0x5f6600, 0xc042004040)
C:/Go/src/runtime/panic.go:500 +0x1af
main.New(0x25, 0x500, 0xc0420c4c40, 0x13, 0xc04203eec0, 0x8, 0x8, 0x18, 0x0, 0x0, ...)
C:/Users/robertph/go/src/github.com/robphoenix/trawl/main.go:88 +0x3a8
main.main.func1(0xc04203c300, 0x25, 0x500, 0xc0420c4c40, 0x13, 0xc04203eec0, 0x8, 0x8, 0x18)
C:/Users/robertph/go/src/github.com/robphoenix/trawl/main.go:50 +0x56
created by main.main
C:/Users/robertph/go/src/github.com/robphoenix/trawl/main.go:55 +0x154
panic: runtime error: index out of range
goroutine 34 [running]:
panic(0x5f6600, 0xc042004040)
C:/Go/src/runtime/panic.go:500 +0x1af
main.New(0x26, 0x500, 0xc04208c9c0, 0x2d, 0xc04203eee8, 0x8, 0x8, 0x18, 0x0, 0x0, ...)
C:/Users/robertph/go/src/github.com/robphoenix/trawl/main.go:88 +0x3a8
main.main.func1(0xc04203c300, 0x26, 0x500, 0xc04208c9c0, 0x2d, 0xc04203eee8, 0x8, 0x8, 0x18)
C:/Users/robertph/go/src/github.com/robphoenix/trawl/main.go:50 +0x56
created by main.main
C:/Users/robertph/go/src/github.com/robphoenix/trawl/main.go:55 +0x154
😨
From #20 (comment) by @siebenmann
For all-address mode and IPv6 addresses, you might want to default to excluding link-local fe80::/10 addresses, since otherwise all up interfaces will have an IPv6 address even if it's not particularly useful.
add a -h flag to include headers
Once #5 is closed it would be good to add flags similar to ifdata
to print out specific attributes, for instance just the IPv4 address or Subnet mask or IPv6 address.
$ trawl -pa w*
192.168.0.11
$ trawl -pn w*
255.255.255.0
The ifdata
flags:
> ifdata [2]
Usage: ifdata [options] iface
-e Reports interface existence via return code
-p Print out the whole config of iface
-pe Print out yes or no according to existence
-pa Print out the address
-pn Print netmask
-pN Print network address
-pb Print broadcast
-pm Print mtu
-ph Print out the hardware address
-pf Print flags
-si Print all statistics on input
-sip Print # of in packets
-sib Print # of in bytes
-sie Print # of in errors
-sid Print # of in drops
-sif Print # of in fifo overruns
-sic Print # of in compress
-sim Print # of in multicast
-so Print all statistics on output
-sop Print # of out packets
-sob Print # of out bytes
-soe Print # of out errors
-sod Print # of out drops
-sof Print # of out fifo overruns
-sox Print # of out collisions
-soc Print # of out carrier loss
-som Print # of out multicast
-bips Print # of incoming bytes per second
-bops Print # of outgoing bytes per second
From #20 (comment) by @siebenmann
My usage case is that I don't necessarily remember or care what a system's interface(s) are called, but I would like to get a list of all of its IP addresses, possibly with some information about which interfaces they're attached to.
I've spent more time trying to get it to work than actually using it. I don't think there's going to be many more releases tbh, that really require using this tool.
From #20 (comment) by @siebenmann
trawl -4c or trawl -6c doesn't report an error, although it doesn't work without an interface name. I think it should report an error here rather than effectively ignore the argument.
Also for these flags:
flag.BoolVar(&v4addr, "a", false, "print only IPv4 address, requires interface name")
flag.BoolVar(&v4mask, "m", false, "print only IPv4 subnet mask, requires interface name")
flag.BoolVar(&v4net, "s", false, "print only IPv4 network (subnet), requires interface name")
flag.BoolVar(&mtu, "u", false, "print only MTU, requires interface name")
flag.BoolVar(&mac, "hw", false, "print only MAC address (hardware address), requires interface name")
flag.BoolVar(&v6addr, "6a", false, "print only IPv6 address, requires interface name")
flag.BoolVar(&v4compl, "4c", false, "print all IPv4 address, requires interface name")
flag.BoolVar(&v6compl, "6c", false, "print all IPv6 address, requires interface name")
Local Area Connection 4 169.254.17.182 255.255.0.0 169.254.0.0/16 1500 02:00:4c:4f:4f:50 fe80::6cd7:885:5ae5:11b6/64
Wireless Network Connection 10.26.101.28 255.255.255.0 10.26.101.0/24 1500 24:77:03:c1:7e:2c fe80::48e8:96c3:7457:8a3d/64
VirtualBox Host-Only Network 192.168.56.1 255.255.255.0 192.168.56.0/24 1500 0a:00:27:00:00:1a fe80::31ac:de12:1d27:fbc9/64
VirtualBox Host-Only Network #2 10.0.0.1 255.255.0.0 10.0.0.0/16 1500 0a:00:27:00:00:1c fe80::701e:c603:1aee:597e/64
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x18 pc=0x40300b]
goroutine 1 [running]:
panic(0x617f80, 0xc04200c080)
C:/Go/src/runtime/panic.go:500 +0x1af
main.New(0x16, 0x500, 0xc04205ecf0, 0x21, 0xc04200d010, 0x8, 0x8, 0x19, 0xc042034b60, 0x0, ...)
C:/Users/robertph/MEGA/donaldjudd/code/go/src/github.com/robphoenix/trawl/trawl.go:52 +0x19b
main.main()
C:/Users/robertph/MEGA/donaldjudd/code/go/src/github.com/robphoenix/trawl/main.go:141 +0x776
If you have an interface with multiple IP addresses attached to it, trawl reports the last IPv4 address of the interface (and probably the last IPv6 interface). Traditionally one would report the first IP if you're only going to report one, because that is usually the primary IP address.
$ ip -4 addr list eno1
2: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
inet 128.100.3.124/24 brd 128.100.3.255 scope global eno1
valid_lft forever preferred_lft forever
inet 128.100.3.125/24 brd 128.100.3.255 scope global secondary eno1:1
valid_lft forever preferred_lft forever
inet 128.100.3.126/24 brd 128.100.3.255 scope global secondary eno1:2
valid_lft forever preferred_lft forever
inet 128.100.3.127/24 brd 128.100.3.255 scope global secondary eno1:3
valid_lft forever preferred_lft forever
inet 128.100.3.128/24 brd 128.100.3.255 scope global secondary eno1:4
valid_lft forever preferred_lft forever
$ trawl -f eno1
eno1 128.100.3.128 255.255.255.0 128.100.3.0/24 1500 d4:ae:52:cb:c2:2c fe80::d6ae:52ff:fecb:c22c/64
I think that the broad fix for this would be to change extractAddrs()
to return a list of IPv4 and IPv6 addresses, instead of trying to return just one of each. The current New()
could then use the first one of each.
On machines with multiple IP address aliases associated with a single interface, it would be quite nice if trawl had an option to report all of them. At least on Linux there is no current convenient, compact way to report this information, and trawl is already reporting so much other useful stuff in one place. As far as I can tell trawl already obtains all of the IP addresses for each interface (cf issue #19), it just doesn't report them (or record them).
This is horrible:
C:\Users\robertph\go\src\github.com\robphoenix\trawl [master ≡ +0 ~1 -0 ~]
λ .\trawl.exe
Local Area Connection 4 169.254.17.182 255.255.0.0 169.254.0.0/16 fe80::6cd7:885:5ae5:11b6/64
Bluetooth Network Connection 169.254.243.224 255.255.0.0 169.254.0.0/16 fe80::7429:19e:27a2:f3e0/64
isatap.{6AF716A3-0351-4525-9F2D-838AFBA61DEC} fe80::5efe:a9fe:11b6/128
isatap.{11760E69-ADA3-42AD-9DFE-3C0C473A6724}
Wireless Network Connection 2 169.254.152.175 255.255.0.0 169.254.0.0/16 fe80::49a:d5ff:9df5:98af/64
VirtualBox Host-Only Network 192.168.56.1 255.255.255.0 192.168.56.0/24 fe80::31ac:de12:1d27:fbc9/64
Mobile Broadband Connection 169.254.28.122 255.255.0.0 169.254.0.0/16 fe80::8d8d:9814:7174:1c7a/64
Local Area Connection 3 10.30.10.10 255.255.255.252 10.30.10.8/30 fe80::989:e670:8216:5528/64
Loopback Pseudo-Interface 1 127.0.0.1 255.0.0.0 127.0.0.0/8 ::1/128
Wireless Network Connection 10.26.101.68 255.255.255.0 10.26.101.0/24 fe80::48e8:96c3:7457:8a3d/64
isatap.{823CF13A-91C6-481B-8421-4B3E352C77C4} fe80::5efe:a00:1/128
Teredo Tunneling Pseudo-Interface fe80::ffff:ffff:fffe/64
isatap.btinet.local fe80::5efe:a1a:6544/128
isatap.{0ED049DF-0304-4802-A2DF-9F35080406D6} fe80::5efe:c0a8:3801/128
6TO4 Adapter
isatap.rd.dev fe80::5efe:a5a:8003/128
VirtualBox Host-Only Network #2 10.0.0.1 255.255.0.0 10.0.0.0/16 fe80::701e:c603:1aee:597e/64
Reusable ISATAP Interface {4012A4B3-5A94-4EE0-A188-831C3634E27F}
Local Area Connection 10.90.128.3 255.255.0.0 10.90.0.0/16 fe80::a4f5:c0bf:b0ca:5551/64
isatap.{BAD582B6-DF90-4A8C-91DC-BFA58D6A2F01}
public 62.239.185.194
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.