timothymiller / cloudflare-ddns

🎉🌩️ Dynamic DNS (DDNS) service based on Cloudflare! Access your home network remotely via a custom domain name without a static IP!
https://timknowsbest.com/free-dynamic-dns
GNU General Public License v3.0
3.01k stars 316 forks source link

[feature] Extract ip address directly from interface. #112

Open comicchang opened 1 year ago

comicchang commented 1 year ago

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",
timothymiller commented 1 year ago

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 commented 1 year ago

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.

comicchang commented 1 year ago

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

comicchang commented 1 year ago

@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 commented 1 year ago

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

Please review the commit.

timothymiller commented 1 year ago

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

ricky9w commented 1 year ago

@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.

comicchang commented 1 year ago

@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.

ricky9w commented 1 year ago

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