$id, 'name' => $id, 'type' => $type, 'ssh_host' => 'gateway.example.com', 'ssh_port' => 22, 'ssh_user' => 'deploy', 'identity_file' => '', 'bind_host' => '127.0.0.1', 'bind_port' => $type === TunnelRule::TYPE_SOCKS5 ? 1080 : 8080, 'target_host' => '127.0.0.1', 'target_port' => 3000, // Legacy configurations may still contain this field. It must no // longer disable startup. 'auto_start' => false, ]); } $file = sys_get_temp_dir() . '/typephp-ssh-startup-' . uniqid('', true) . '.json'; $repository = new TunnelRepository($file); $repository->create(startup_rule('first', TunnelRule::TYPE_LOCAL)); $repository->create(startup_rule('second', TunnelRule::TYPE_SOCKS5)); $application = new TunnelApplication($repository); $result = $application->run(); sort($startedRuleIds); if ($result !== 0 || $startedRuleIds !== ['first', 'second'] || count($renderedRows) !== 2) { throw new RuntimeException('all persisted tunnel rules must start during application startup'); } unlink($file); unlink($file . '.bak'); echo "ssh-tunnel startup tests passed\n";