diff --git a/app/controller/System.php b/app/controller/System.php index 0e2ebf3..3b9597a 100644 --- a/app/controller/System.php +++ b/app/controller/System.php @@ -95,11 +95,12 @@ class System extends BaseController public function proxytest() { if (!checkPermission(2)) return $this->alert('error', '无权限'); - $proxy_server = trim($_POST['proxy_server']); - $proxy_port = $_POST['proxy_port']; - $proxy_user = trim($_POST['proxy_user']); - $proxy_pwd = trim($_POST['proxy_pwd']); - $proxy_type = $_POST['proxy_type']; + $proxy_server = input('post.proxy_server', '', 'trim'); + $proxy_port = input('post.proxy_port/d', 0); + $proxy_user = input('post.proxy_user', '', 'trim'); + $proxy_pwd = input('post.proxy_pwd', '', 'trim'); + $proxy_type = input('post.proxy_type', 'http', 'trim'); + try { check_proxy('https://dl.amh.sh/ip.htm', $proxy_server, $proxy_port, $proxy_type, $proxy_user, $proxy_pwd); } catch (Exception $e) { diff --git a/app/lib/deploy/ssh.php b/app/lib/deploy/ssh.php index bd964c0..88a1501 100644 --- a/app/lib/deploy/ssh.php +++ b/app/lib/deploy/ssh.php @@ -159,14 +159,20 @@ class ssh implements DeployInterface file_put_contents($privateKeyPath, $this->config['privatekey']); file_put_contents($publicKeyPath, $publicKey); umask($umask); - if (!empty($this->config['passphrase'])) { - if (!ssh2_auth_pubkey_file($connection, $this->config['username'], $publicKeyPath, $privateKeyPath, $this->config['passphrase'])) { - throw new Exception('私钥认证失败'); - } - } else { - if (!ssh2_auth_pubkey_file($connection, $this->config['username'], $publicKeyPath, $privateKeyPath)) { - throw new Exception('私钥认证失败'); + + try { + if (!empty($this->config['passphrase'])) { + if (!ssh2_auth_pubkey_file($connection, $this->config['username'], $publicKeyPath, $privateKeyPath, $this->config['passphrase'])) { + throw new Exception('私钥认证失败'); + } + } else { + if (!ssh2_auth_pubkey_file($connection, $this->config['username'], $publicKeyPath, $privateKeyPath)) { + throw new Exception('私钥认证失败'); + } } + } finally { + unlink($publicKeyPath); + unlink($privateKeyPath); } } else { if (!ssh2_auth_password($connection, $this->config['username'], $this->config['password'])) {