m1k1o / neko

A self hosted virtual browser that runs in docker and uses WebRTC.
https://neko.m1k1o.net/
Apache License 2.0
5.96k stars 449 forks source link

Dynamic IP #247

Open Svenum opened 1 year ago

Svenum commented 1 year ago

I want to expose my docker to the public internet, but i have a dynamic IP from my ISP. Is it Posible to set a refresh interval or a dyndns to the ENV section, so that the IP updates automaticaly?

m1k1o commented 1 year ago

Currently, if you do not specify any NEKO_NAT1TO1 when strating the instance, a request is made to http://checkip.amazonaws.com. But it is not refreshed throughout the session.

Do you plan to have that long running sessions? You could theoretically restart them when IP has changed or peridically, to refresh IP now.

There has been raised a similar concern, but in the context of neko rooms: https://github.com/m1k1o/neko-rooms/issues/62

Svenum commented 1 year ago

Yes I want to use long running sessions. https://github.com/m1k1o/neko-rooms/issues/62 is same as i want.

Xeddius commented 1 year ago

I want to expose my docker to the public internet, but i have a dynamic IP from my ISP. Is it Posible to set a refresh interval or a dyndns to the ENV section, so that the IP updates automaticaly?

I highly recommend a dynamic dns provider with a reverse proxy like Caddy V2 (which also has a lightweight docker image). It will allow you to set a custom url, and it should keep the instance accessible. It also has the added bonus of providing HTTPS support.

Svenum commented 1 year ago

I have an dyndns provider but it dont fetch the ip every request or so. It only fetches the IP on Container start

m1k1o commented 1 year ago

It could be easily implemented by adding new goroutine and ticker every X minutes. Or would you prefer having possibility to set it using CLI and calling it using crontab?

Svenum commented 1 year ago

Every X seconds is better maybe to set the interval via ENV.

juliaszone commented 1 year ago

It could be easily implemented by adding new goroutine and ticker every X minutes. Or would you prefer having possibility to set it using CLI and calling it using crontab?

Both might make sense, however the latter one probably makes the most sense for now. I for example run my own DDNS server, so I can make it push the new IPv4 to the host running the Neko as soon as it changes. However, someone else who uses an external DDNS provider is probably not be able to do that, so just an ENVVAR you can set to seconds in how often it will fetch the new IPv4 from NEKO_IPFETCH is a good idea.

Svenum commented 1 year ago

Some news on this toppic?

alanmilinovic commented 9 months ago

In my case I am having a VPN on my server and neko pick-up the wrong IP before VPN is established. Having an interval that will fetch the IP regularly would be great.

For now I simply execute container down and up commands automatically after VPN is established.

Svenum commented 8 months ago

Any updates in this Case?

alanmilinovic commented 8 months ago

Any updates in this Case?

No

m1k1o commented 8 months ago

I looked at the code and the whole module must be restaretd. So there is no difference in setting up custom CRON script that restarts neko:

docker exec neko supervisorctl restart neko

You could wrap it in such simple bash script:

#!/bin/bash

# Get current ip
current_ip=$(dig +short myip.opendns.com @resolver1.opendns.com)

# Get last ip
last_ip=$(cat /opt/last_ip)

# Check if ip changed
if [ "$current_ip" != "$last_ip" ]; then
    # Restart network
    docker exec neko supervisorctl restart neko
    # Save new ip
    echo $current_ip > /opt/last_ip
fi

And run e.g. every 5min in CRON.

Svenum commented 8 months ago

Maybe you could buildin this script in the container so that you can enable it with an env?

alanmilinovic commented 8 months ago

Maybe you could buildin this script in the container so that you can enable it with an env?

I agree, that was the idea at some point in time.