jhonoryza / argotunnel-laravel
使用 Laravel 集成 argotunnel TCP 连接数据库
1.0.0
2021-08-22 13:38 UTC
Requires
- php: ^7.4|^8.0
This package is auto-updated.
Last update: 2024-09-30 19:26:25 UTC
README
此包允许您通过 Cloudflare 上的 argo tunnel 连接到远程数据库,这假设您已经从远程服务器创建了一个使用 TCP 连接的隧道。
安装
您可以通过 composer 安装此包
composer require jhonoryza/argotunnel-laravel
基本用法
在 .env 文件中的配置
; Process used to verify connection
; Use bash if your distro uses nmap-ncat (RHEL/CentOS 7.x)
TUNNELER_VERIFY_PROCESS=nc
; Path to the nc executable
TUNNELER_NC_PATH=/usr/bin/nc
; Path to the bash executable
TUNNELER_BASH_PATH=/usr/bin/bash
; Path to the ssh executable
TUNNELER_SSH_PATH=/usr/bin/ssh
; Path to the nohup executable
TUNNELER_NOHUP_PATH=/usr/bin/nohup
; Log messages for troubleshooting
SSH_VERBOSITY=
NOHUP_LOG=/dev/null
; The identity file you want to use for ssh auth
TUNNELER_IDENTITY_FILE=/home/user/.ssh/id_rsa
; The local address and port for the tunnel
TUNNELER_LOCAL_PORT=13306
TUNNELER_LOCAL_ADDRESS=127.0.0.1
; The remote address and port for the tunnel
TUNNELER_BIND_PORT=3306
TUNNELER_BIND_ADDRESS=127.0.0.1
; The ssh connection: sshuser@sshhost:sshport
TUNNELER_USER=sshuser
TUNNELER_HOSTNAME=sshhost
TUNNELER_PORT=sshport
; How long to wait, in microseconds, before testing to see if the tunnel is created.
; Depending on your network speeds you will want to modify the default of 1 seconds
TUNNELER_CONN_WAIT=1000000
; How often it is checked if the tunnel is created. Useful if the tunnel creation is sometimes slow,
; and you want to minimize waiting times
TUNNELER_CONN_TRIES=1
; Do you want to ensure you have the Tunnel in place for each bootstrap of the framework?
TUNNELER_ON_BOOT=false
; Do you want to use additional SSH options when the tunnel is created?
TUNNELER_SSH_OPTIONS="-o StrictHostKeyChecking=no"
工作原理
它首先通过 exec 使用 netcat (nc) 检查本地端口以查看隧道是否打开。如果端口存在,则不执行其他操作。
如果端口不存在,它将创建 SSH 隧道连接命令,并通过 exec 执行该命令。执行后,我们等待定义的 TUNNELER_CONN_WAIT 时间,然后再运行 netcat 以验证连接是否建立。
就是这样。隧道将持续到超时,如果超时。
许可
MIT 许可证 (MIT)。有关更多信息,请参阅许可文件。