tfarm is a tool for creating and managing tunnels. It is a wrapper around frp that provides a simple interface for managing tunnels. It consists of two components: a server and a client. The server is a wrapper around frpc that manages tunnels. The client is a CLI for interfacing with the server to create and manage tunnels.
If you are using go version 1.17 or later, you can install frpc and tfarm using the go install command.
go install github.com/fatedier/frp/cmd/frpc@latest
go install github.com/cbodonnell/tfarm/cmd/tfarm@latestIf you are using an older version of go, you can install tfarm using go get.
Otherwise, you can:
- Download the latest release of frp and tfarm for your platform.
- Extract the binaries from the archives.
- Move the binaries to a directory in your PATH.
Note: It is recommended to run the tfarm server using a process manager like systemd (example).
The following environment variables can optionally be used to configure the tfarm server.
Set the TFARMD_WORK_DIR environment variable to the path where you want to store the tfarm server state. By default, it will be the current working directory.
export TFARMD_WORK_DIR=/path/to/work/dirSet the TFARMD_FRPC_BIN_PATH environment variable to the path of the frpc binary. By default, tfarm will search the current users PATH.
export TFARMD_FRPC_BIN_PATH=/path/to/frpcStart the tfarmd server.
tfarm server startIn another terminal, create the $HOME/.tfarm directory and copy the server's client.json file to it.
mkdir -p $HOME/.tfarm
cp $TFARMD_WORK_DIR/tls/client.json $HOME/.tfarmCheck the status of the tfarm server.
tfarm statusThe next step is to configure the tfarm server as a ranch client.
Use the tfarm ranch command to interact with the tfarm ranch. The tfarm ranch is the frps server that frpc connects to. It provides an identity and access layer for frps. By default, tfarm will connect to the tunnel.farm ranch.
Login to the tfarm ranch.
tfarm ranch loginCreate a new ranch client and use it to configure the tfarm server.
tfarm ranch clients create --credentials | tfarm configure --credentials-stdinCheck the status of the tfarm server.
tfarm statusCreate a tunnel that forwards traffic to local port 8080.
tfarm create my-tunnel -p 8080Check the status.
tfarm statusDelete the tunnel.
tfarm delete my-tunnel- Git
- Make
- Go
- Docker
- frpc
Create a .env file with the following environment variables.
TFARMD_FRPC_BIN_PATH=/path/to/frpc
TFARMD_WORK_DIR=/path/to/work/dir
TFARMD_LOG_LEVEL=debugmake tfarm