diyhue / diyHue

Main diyHue software repo
https://diyhue.org/
Other
1.52k stars 274 forks source link

Binding used ports to ip, seems not to work. #934

Open JorinL opened 8 months ago

JorinL commented 8 months ago

Feature does not already exist?

I searched and did not find an existing feature request

Summarize feature

Hey there :-)

I would normally run the diy hue in bridge mode in a docker container. Sadly that does not bring my Philips TV to see the bridge in its search. So -> Host mode is the choice.

But I cannot set the diyHue bridge to only listen on a specific ip - also when in config it is set to. ipaddress: 192.168.0.7 gateway: 192.168.0.1 mac: c4:bd:e5:d7:59:9c

At the end it opens: tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 0 8515358 1510044/python3 tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 0 8514442 1510044/python3 udp 0 0 172.21.0.1:5353 0.0.0.0:* 0 8517151 1510044/python3 udp 0 0 192.168.0.8:5353 0.0.0.0:* 0 8514441 1510044/python3 udp 0 0 172.17.0.1:5353 0.0.0.0:* 0 8514438 1510044/python3 udp 0 0 127.0.0.1:5353 0.0.0.0:* 0 8512164 1510044/python3 udp 0 0 0.0.0.0:5353 0.0.0.0:* 0 8514437 1510044/python3 udp 0 0 0.0.0.0:34229 0.0.0.0:* 0 8511452 1510044/python3

There is also a warning in the log about using this: 2023-10-15 19:19:06,066 - werkzeug - WARNING - * Running on all addresses.

So my main problem is: 0.0.0.0:80 and 0.0.0.0:443 - IfI could set this up to 192.168.0.7:80 and 192.168.0.7:443.

Because I have two Ips on my server so I can use more then one time 80 and 443. (Mainly the 192.168.0.7 is exactly and only for diyHue established).

Is there a way we can archive this? Can I provide needed stuff?

Other way around -> If I can get my TV finding the bridge in Docker Birdged mode -> also fine solution :-)

When I run it in host mode - while my other app on 192.168.0.8 ist running it throws errors:

app.run(host=BIND_IP, port=HOST_HTTP_PORT)Exception in thread Thread-11 (runHttps): File "/usr/local/lib/python3.11/dist-packages/flask/app.py", line 920, in run

So it should be a way given to set this to a specific ip. :-) or?

Thanks!

JorinL commented 8 months ago

I found myself a "dirty workaround":

`def runHttps(BIND_IP, HOST_HTTPS_PORT, CONFIG_PATH): ctx = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH) ctx.load_cert_chain(certfile=CONFIG_PATH + "/cert.pem") ctx.options |= ssl.OP_CIPHER_SERVER_PREFERENCE ctx.set_ciphers('ECDHE-ECDSA-AES128-GCM-SHA256') ctx.set_ecdh_curve('prime256v1')

app.run(host=BIND_IP, port=HOST_HTTPS_PORT, ssl_context=ctx)

[app.run](http://app.run/)(host="192.168.0.7", port=HOST_HTTPS_PORT, ssl_context=ctx)

def runHttp(BIND_IP, HOST_HTTP_PORT): app.run(host="192.168.0.7", port=HOST_HTTP_PORT)

app.run(host=BIND_IP, port=HOST_HTTP_PORT)`

Maybe there can be something done, so we get able to provide the variable "BIND_IP" from an ENV with docker?