From d16295baa575536253d347a86de95d7a1c0b5aaa Mon Sep 17 00:00:00 2001 From: dushixiang <798148596@qq.com> Date: Fri, 5 Mar 2021 19:38:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0k8s=E6=8E=A5=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/api/tunnel.go | 15 ++ pkg/guacd/guacd.go | 9 + pkg/model/asset-attribute.go | 6 + web/src/components/asset/Asset.js | 6 + web/src/components/asset/AssetModal.js | 279 ++++++++++++++++++++----- 5 files changed, 257 insertions(+), 58 deletions(-) diff --git a/pkg/api/tunnel.go b/pkg/api/tunnel.go index 7a2b4d5..500141a 100644 --- a/pkg/api/tunnel.go +++ b/pkg/api/tunnel.go @@ -111,6 +111,8 @@ func TunEndpoint(c echo.Context) error { configuration.SetParameter(guacd.FontSize, propertyMap[guacd.FontSize]) configuration.SetParameter(guacd.FontName, propertyMap[guacd.FontName]) configuration.SetParameter(guacd.ColorScheme, propertyMap[guacd.ColorScheme]) + configuration.SetParameter(guacd.Backspace, propertyMap[guacd.Backspace]) + configuration.SetParameter(guacd.TerminalType, propertyMap[guacd.TerminalType]) break case "vnc": configuration.SetParameter("username", session.Username) @@ -119,7 +121,20 @@ func TunEndpoint(c echo.Context) error { case "telnet": configuration.SetParameter("username", session.Username) configuration.SetParameter("password", session.Password) + + configuration.SetParameter(guacd.FontSize, propertyMap[guacd.FontSize]) + configuration.SetParameter(guacd.FontName, propertyMap[guacd.FontName]) + configuration.SetParameter(guacd.ColorScheme, propertyMap[guacd.ColorScheme]) + configuration.SetParameter(guacd.Backspace, propertyMap[guacd.Backspace]) + configuration.SetParameter(guacd.TerminalType, propertyMap[guacd.TerminalType]) break + case "kubernetes": + + configuration.SetParameter(guacd.FontSize, propertyMap[guacd.FontSize]) + configuration.SetParameter(guacd.FontName, propertyMap[guacd.FontName]) + configuration.SetParameter(guacd.ColorScheme, propertyMap[guacd.ColorScheme]) + configuration.SetParameter(guacd.Backspace, propertyMap[guacd.Backspace]) + configuration.SetParameter(guacd.TerminalType, propertyMap[guacd.TerminalType]) } configuration.SetParameter("hostname", session.IP) diff --git a/pkg/guacd/guacd.go b/pkg/guacd/guacd.go index 0db2947..a58b01f 100644 --- a/pkg/guacd/guacd.go +++ b/pkg/guacd/guacd.go @@ -48,6 +48,15 @@ const ( PasswordRegex = "password-regex" LoginSuccessRegex = "login-success-regex" LoginFailureRegex = "login-failure-regex" + + Namespace = "namespace" + Pod = "pod" + Container = "container" + UesSSL = "use-ssl" + ClientCert = "client-cert" + ClientKey = "client-key" + CaCert = "ca-cert" + IgnoreCert = "ignore-cert" ) const Delimiter = ';' diff --git a/pkg/model/asset-attribute.go b/pkg/model/asset-attribute.go index bf2f8fd..5b58f29 100644 --- a/pkg/model/asset-attribute.go +++ b/pkg/model/asset-attribute.go @@ -24,6 +24,7 @@ var SSHParameterNames = []string{guacd.FontName, guacd.FontSize, guacd.ColorSche var RDPParameterNames = []string{guacd.RemoteApp, guacd.RemoteAppDir, guacd.RemoteAppArgs} var VNCParameterNames = []string{guacd.ColorDepth, guacd.Cursor, guacd.SwapRedBlue, guacd.DestHost, guacd.DestPort} var TelnetParameterNames = []string{guacd.FontName, guacd.FontSize, guacd.ColorScheme, guacd.Backspace, guacd.TerminalType, guacd.UsernameRegex, guacd.PasswordRegex, guacd.LoginSuccessRegex, guacd.LoginFailureRegex} +var KubernetesParameterNames = []string{guacd.FontName, guacd.FontSize, guacd.ColorScheme, guacd.Backspace, guacd.TerminalType, guacd.Namespace, guacd.Pod, guacd.Container, guacd.UesSSL, guacd.ClientCert, guacd.ClientKey, guacd.CaCert, guacd.IgnoreCert} func UpdateAssetAttributes(assetId, protocol string, m echo.Map) error { var data []AssetAttribute @@ -37,6 +38,9 @@ func UpdateAssetAttributes(assetId, protocol string, m echo.Map) error { parameterNames = VNCParameterNames case "telnet": parameterNames = TelnetParameterNames + case "kubernetes": + parameterNames = KubernetesParameterNames + } for i := range parameterNames { @@ -94,6 +98,8 @@ func FindAssetAttrMapByAssetId(assetId string) (map[string]interface{}, error) { parameterNames = VNCParameterNames case "telnet": parameterNames = TelnetParameterNames + case "kubernetes": + parameterNames = KubernetesParameterNames } propertiesMap := FindAllPropertiesMap() var attributeMap = make(map[string]interface{}) diff --git a/web/src/components/asset/Asset.js b/web/src/components/asset/Asset.js index 773bb59..8c316e9 100644 --- a/web/src/components/asset/Asset.js +++ b/web/src/components/asset/Asset.js @@ -270,6 +270,12 @@ class Asset extends Component { asset['tags'] = []; } + asset['use-ssl'] = asset['use-ssl'] === 'true'; + + asset['ignore-cert'] = asset['ignore-cert'] === 'true'; + + console.log(asset) + this.setState({ modalTitle: title, modalVisible: true, diff --git a/web/src/components/asset/AssetModal.js b/web/src/components/asset/AssetModal.js index f204a73..a122ebe 100644 --- a/web/src/components/asset/AssetModal.js +++ b/web/src/components/asset/AssetModal.js @@ -1,5 +1,18 @@ import React, {useState} from 'react'; -import {Col, Collapse, Form, Input, InputNumber, Modal, Radio, Row, Select, Tooltip, Typography} from "antd/lib/index"; +import { + Col, + Collapse, + Form, + Input, + InputNumber, + Modal, + Radio, + Row, + Select, + Switch, + Tooltip, + Typography +} from "antd/lib/index"; import {ExclamationCircleOutlined} from "@ant-design/icons"; import {isEmpty} from "../../utils/utils"; @@ -43,13 +56,14 @@ const AssetModal = function ({title, visible, handleOk, handleCancel, confirmLoa let [accountType, setAccountType] = useState(model.accountType); let [protocol, setProtocol] = useState(model.protocol); let [sshMode, setSshMode] = useState(model['ssh-mode']); - console.log(sshMode) let initAccountTypes = [] if (model.protocol) { initAccountTypes = protocolMapping[model.protocol]; } let [accountTypes, setAccountTypes] = useState(initAccountTypes); + let [useSSL, setUseSSL] = useState(model['use-ssl']); + let [ignoreCert, setIgnoreCert] = useState(model['ignore-cert']); for (let key in model) { if (model.hasOwnProperty(key)) { @@ -95,6 +109,9 @@ const AssetModal = function ({title, visible, handleOk, handleCancel, confirmLoa }); handleAccountTypeChange('custom'); break; + case 'kubernetes': + port = 6443; + break default: port = 65535; } @@ -135,7 +152,7 @@ const AssetModal = function ({title, visible, handleOk, handleCancel, confirmLoa
- + @@ -150,10 +167,11 @@ const AssetModal = function ({title, visible, handleOk, handleCancel, confirmLoa - rdp - ssh - vnc - telnet + RDP + SSH + VNC + Telnet + Kubernetes @@ -161,63 +179,93 @@ const AssetModal = function ({title, visible, handleOk, handleCancel, confirmLoa - - - - { - accountType === 'credential' ? - - + + + + + + + + + + : <> + + - : null - } - { - accountType === 'custom' ? - <> - - - - - - - - : null - } + { + accountType === 'credential' ? + + + + : null + } - { - accountType === 'private-key' ? - <> - - - + { + accountType === 'custom' ? + <> + + + - -