rapiz1 / rathole

A lightweight and high-performance reverse proxy for NAT traversal, written in Rust. An alternative to frp and ngrok.
Apache License 2.0
8.8k stars 440 forks source link

Rathole config watcher doesn't work with symlinks #359

Open yashgorana opened 1 month ago

yashgorana commented 1 month ago

Describe the bug When config files are symlinks, rathole won't pickup any changes file pointed to by the symlink. This is needed to detect any changes that are made to a Kubernetes ConfigMap mounted to a rathole pod at a path.

To Reproduce Steps to reproduce the behavior:

  1. Create a test/config.toml
  2. Create a symlink ln -s ./test/config.toml ./config.toml
  3. Run rathole --server ./config.toml
  4. Edit test/config.toml or config.toml to change the server config to bind_addr = "0.0.0.0:1333"
  5. Observe changes are not picked up and rathole doesn't hot reload.

Configuration

[server]
bind_addr = "0.0.0.0:2333"

[server.services.domain]
token = "domain-specific-rathole-secret"
bind_addr = "0.0.0.0:8001"

Logs

No hot reload log even after changing the config

$ RUST_BACKTRACE=1 rathole ./server.toml
2024-05-01T13:34:09.659589Z  INFO rathole::server: Listening at 0.0.0.0:2333
2024-05-01T13:34:09.659660Z  INFO config_watcher{path="./server.toml"}: rathole::config_watcher: Start watching the config

Environment:

Bubbleioa commented 1 month ago

Just change this line. https://github.com/Bubbleioa/rathole/commit/5017970890293977184adfc62baa38ccc45c2ec4