cloudflare-ddns icon indicating copy to clipboard operation
cloudflare-ddns copied to clipboard

[feature] Extract ip address directly from interface.

Open comicchang opened this issue 3 years ago • 9 comments

Directly extract ip address from network interface.

Useful if you:

  1. Has multiply interfaces and ECMP.
  2. Behind nat.

config file:

"method": "netif", // or anything other than "http"
"interface": "ppp0",

comicchang avatar Sep 27 '22 03:09 comicchang

I just merged your changes. I had to merge a few changes from other PRs. I included you in the commit messages: https://github.com/timothymiller/cloudflare-ddns/commit/cb7b1804cf896627546c280d92ea0690274f7c58

timothymiller avatar Feb 15 '23 21:02 timothymiller

Had to revert the PR because netif is not compatible with alpine linux.

Let me know if you have time to investigate a solution for alpine linux that is compatible with your netif solution.

timothymiller avatar Feb 15 '23 22:02 timothymiller

Sure, I'll look into it when I have time.

comicchang avatar Feb 16 '23 01:02 comicchang

@timothymiller I can remove the dependency on netifaces and use a pure Python method to get the IP address of a network interface. However, this method only works on Linux and may not work on Windows or macOS. Does this modification meet your expectations?

comicchang avatar Feb 19 '23 12:02 comicchang

Hi, I've removed the netifaces dependency, reimplemented in pure python, rebased to the latest master, and tested it.

Please review the commit.

comicchang avatar Feb 19 '23 14:02 comicchang

That sounds like a fine trade off @comicchang since the primary way of running this will be in a Linux container.

timothymiller avatar Feb 19 '23 18:02 timothymiller

@comicchang @timothymiller Maybe allowing users to customize the IP query command would be a more flexible solution? This would solve the cross-platform issue and provide greater flexibility.

ricky9w avatar Mar 09 '23 06:03 ricky9w

@comicchang @timothymiller Maybe allowing users to customize the IP query command would be a more flexible solution? This would solve the cross-platform issue and provide greater flexibility.

Sounds good to me! I'll try to implement it this weekend.

comicchang avatar Mar 09 '23 08:03 comicchang

Another PR to allow running custom script to get IPv4 & 6 address #131

ricky9w avatar Mar 09 '23 15:03 ricky9w