Trigger tunnel
Overview
Triggers are commands executed on a specific event. tuna supports two types of events:
- HTTP request (Webhook)
- Email (SMTP)
Creating a Trigger tunnel is only available with a subscription.
Example
You can see all current flags, hints and examples by calling the help:
tuna trigger --help
tuna trigger webhook --help
tuna trigger smtp --help
Almost all flags have corresponding environment variables.
Script to run
For example, create a script /tmp/trigger.sh that will create a file and write the phrase Hello tuna to it:
#!/bin/sh
set -xe
touch /tmp/test_file.txt
echo "Hello tuna" > /tmp/test_file.txt
Then make it executable with the command chmod +x /tmp/trigger.sh.
HTTP request (Webhook)
tuna trigger webhook /tmp/trigger.sh
tuna will generate a link:
INFO[13:00:00] Welcome to Tuna
INFO[13:00:00] Forwarding tcp://ru.tuna.am:16502 -> 127.0.0.1:35839
INFO[13:00:00] Send an HTTP request to http://ru.tuna.am:16502 to execute the command "/tmp/trigger.sh"
Now you can send a request to the specified address, and tuna will execute the specified script, for example:
curl -sSLf http://ru.tuna.am:16502
Email (SMTP)
tuna trigger smtp /tmp/trigger.sh
tuna will generate a link:
INFO[13:00:00] Welcome to Tuna
INFO[13:00:00] Forwarding tcp://ru.tuna.am:19284 -> 127.0.0.1:1025
INFO[13:00:00] Send a message to SMTP server ru.tuna.am:19284 to execute the command "/tmp/trigger.sh"
Now you can send an email to the specified address, and tuna will execute the specified script, for example:
curl -s \
--url "smtp://ru.tuna.am:19284" \
--mail-from "tuna@example.com" \
--mail-rcpt "tuna@example.com" \
--upload-file /tmp/trigger.sh
С указанием токена
Можно указать специфичный токен через флаг --token или переменную окружения TUNA_TOKEN. Переопределение происходит в соответствии с политикой очерёдности конфигурации.
tuna trigger webhook --token=tt_***
tuna trigger smtp --token=tt_***
С указанием региона для подключения
Можно указать специфичный регион через флаг --location/-l или переменную окружения TUNA_LOCATION. Переопределение происходит в соответствии с политикой очерёдности конфигурации.
tuna trigger webhook --location=nl
tuna trigger smtp --location=nl
Статичный порт
В качестве значения флага --port/-p может выступать алиас или назначенный порт.
Порты можно резервировать в личном кабинете и после перезапуска туннеля адрес останется прежним.
Подробнее о портах читайте в отдельной инструкции.
tuna trigger webhook --port=postgres
tuna trigger webhook --port=35000
tuna trigger smtp --port=postgres
tuna trigger smtp --port=35000