Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions cmd/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ limitations under the License.
package cmd

import (
"fmt"
"net"
"os"
"os/signal"
"syscall"
Expand Down Expand Up @@ -49,14 +51,13 @@ func createMockCmd() (c *cobra.Command) {
func (o *mockOption) runE(c *cobra.Command, args []string) (err error) {
reader := mock.NewLocalFileReader(args[0])
server := mock.NewInMemoryServer(o.port)

c.Println("start listen", o.port)
if err = server.Start(reader, o.prefix); err != nil {
return
}

clean := make(chan os.Signal, 1)
signal.Notify(clean, syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP, syscall.SIGQUIT)
printLocalIPs(c, o.port)

select {
case <-c.Context().Done():
Expand All @@ -65,3 +66,28 @@ func (o *mockOption) runE(c *cobra.Command, args []string) (err error) {
err = server.Stop()
return
}

func printLocalIPs(c *cobra.Command, port int) {
if ips, err := getLocalIPs(); err == nil {
for _, ip := range ips {
c.Printf("server is available at http://%s:%d\n", ip, port)
}
}
}

func getLocalIPs() ([]string, error) {
var ips []string
addrs, err := net.InterfaceAddrs()
if err != nil {
return nil, fmt.Errorf("failed to get interface addresses: %v", err)
}

for _, addr := range addrs {
if ipNet, ok := addr.(*net.IPNet); ok {
if ipNet.IP.To4() != nil && !ipNet.IP.IsLoopback() {
ips = append(ips, ipNet.IP.String())
}
}
}
return ips, nil
}
1 change: 1 addition & 0 deletions cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ func (o *serverOption) runE(cmd *cobra.Command, args []string) (err error) {
serverLogger.Info("HTTP server started", "addr", httplis.Addr())
serverLogger.Info("gRPC server started", "addr", lis.Addr())
serverLogger.Info("Server is running.")
printLocalIPs(cmd, o.httpPort)

err = o.httpServer.Serve(httplis)
err = util.IgnoreErrServerClosed(err)
Expand Down
11 changes: 6 additions & 5 deletions console/atest-ui/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import {
Histogram,
Location,
Share,
ArrowDown
ArrowDown,
Guide,
} from '@element-plus/icons-vue'
import { ref, watch } from 'vue'
import { API } from './views/net'
Expand Down Expand Up @@ -59,9 +60,9 @@ const handleSelect = (key: string) => {
const locale = ref(Cache.GetPreference().language)
i18nLocale.value = locale.value

watch(locale, (e) =>{
Cache.WithLocale(e.value)
i18nLocale.value = locale.value
watch(locale, (e: string) =>{
Cache.WithLocale(e)
i18nLocale.value = locale
})

const handleChangeLan = (command: string) => {
Expand Down Expand Up @@ -110,7 +111,7 @@ const toHistoryPanel = ({ ID: selectID, panelName: historyPanelName }) => {
<template #title>{{ t('title.history' )}}</template>
</el-menu-item>
<el-menu-item index="mock" test-id="mock-menu">
<el-icon><icon-menu /></el-icon>
<el-icon><Guide /></el-icon>
<template #title>{{ t('title.mock' )}}</template>
</el-menu-item>
<el-menu-item index="secret">
Expand Down
13 changes: 10 additions & 3 deletions console/atest-ui/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
"secrets": "Secrets",
"stores": "Stores",
"functionQuery": "Functions Query",
"output": "Output"
"output": "Output",
"proxy": "Proxy"
},
"tip": {
"filter": "Filter Keyword",
Expand All @@ -71,7 +72,8 @@
"storageLocation": "Location",
"suiteKind": "Suite Kind",
"key": "Key",
"value": "Value"
"value": "Value",
"proxy": "Proxy"
},
"//see http spec": "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403",
"httpCode": {
Expand All @@ -90,5 +92,10 @@
"500": "500 Internal Server Error",
"502": "502 Bad Gateway",
"503": "503 Service Unavailable"
},
"proxy": {
"http": "HTTP Proxy",
"https": "HTTPS Proxy",
"no": "No Proxy"
}
}
}
13 changes: 10 additions & 3 deletions console/atest-ui/src/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
"stores": "存储",
"parameter": "参数",
"functionQuery": "函数查询",
"output": "输出"
"output": "输出",
"proxy": "代理"
},
"tip": {
"filter": "过滤",
Expand All @@ -65,6 +66,12 @@
"storageLocation": "保存位置",
"suiteKind": "类型",
"key": "键",
"value": "值"
"value": "值",
"proxy": "代理"
},
"proxy": {
"http": "HTTP 代理",
"https": "HTTPS 代理",
"no": "跳过代理"
}
}
}
Loading
Loading