jackpal / gateway

A golang library for discovering the address of a LAN gateway.
BSD 3-Clause "New" or "Revised" License
226 stars 69 forks source link

reworked & added interface IP for win & lin #25

Closed AtakanColak closed 3 years ago

AtakanColak commented 3 years ago

Hiya, I came across this library when I was looking for a way to get the default IP address of a computer. Wanted to add that functionality over it so anyone in the same need could use it. Tested DefaultInterface() on 4 different Windows and 11 different Linux VMs. Please review, thank you.

AtakanColak commented 3 years ago

@jackpal please review

jackpal commented 3 years ago

Thanks very much for the pull request. I will try to review it soon. (The delay is because I am between PCs. I gave my old PC to one of my kids for COVID schooling, and my replacement laptop hasn't arrived yet. It should arrive in the next week or so.)

AtakanColak commented 3 years ago

No worries, feel free to ask for any questions or request changes.

jackpal commented 3 years ago

I made two post-commit changes:

1) I added a \n to the end of the .gitignore file.

2) I commented out the Linux interfaceTestCases, since they failed when run on my Darwin machine.

If you can figure out how to make them pass in general, I'd be happy to take a pull request that restores them.

AtakanColak commented 3 years ago

Thank you, I couldn't really figure out how to do that in general that is why I added a comment.