port-plumber

Crates.ioport-plumber
lib.rsport-plumber
version0.3.1
sourcesrc
created_at2023-02-18 14:49:00.397989
updated_at2023-11-11 16:53:18.62521
descriptionUtility bind ports with initialization commands
homepage
repositoryhttps://github.com/dghilardi/port-plumber
max_upload_size
id788275
size69,250
Davide Ghilardi (dghilardi)

documentation

README

Port Plumber

Test Status Crate

Utility bind ports with initialization commands

Configuration

The following configuration file must be created:

$HOME/.config/portplumber/config.toml

# Bind 127.0.0.1:12345 to 127.0.0.1:80
[plumbing."127.0.0.1:12345"]
target = "127.0.0.1:80"


# Bind 127.0.0.1:23456 to 127.0.0.1:2048
# At first connection the setup command will be spawn and 500ms will be awaited before redirecting the connection to the target
[plumbing."127.0.0.1:23456"]
target = "127.0.0.1:2048"
resource.setup = { command = "http-server", args = ["-h", "127.0.0.1", "-p", "2048", "-v"] }
resource.warmup_millis = 500

Autostart

Systemd

On linux systems systemd can be used to automatically start this command on startup.

To achieve this, the following file needs to be created:

$HOME/.config/systemd/user/port-plumber.service

[Unit]
Description=Launch port-plumber

[Service]
Type=simple
ExecStart=%h/.cargo/bin/port-plumber
Environment=RUST_LOG=info
[Install]
WantedBy=default.target

And the following commands needs to be executed:

  • systemctl --user daemon-reload reload systemd user daemons
  • systemctl --user enable port-plumber enable port-plumber daemon
Commit count: 42

cargo fmt