update
parent
8239477e53
commit
36d32e7222
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -4,7 +4,7 @@
|
|||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>端口转发配置</title>
|
||||
<script type="module" crossorigin src="./assets/index-lqpwyav5.js"></script>
|
||||
<script type="module" crossorigin src="./assets/index-51cHkXnS.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="./assets/index-BA8XwqWY.css">
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
@ -13,6 +13,7 @@ import (
|
|||
"github.com/spf13/cast"
|
||||
"gorm.io/gorm"
|
||||
"net/http"
|
||||
"net/netip"
|
||||
"proxyport/app/db"
|
||||
"proxyport/app/forward"
|
||||
"proxyport/app/model"
|
||||
|
@ -269,23 +270,40 @@ func Delete(ctx *gin.Context) {
|
|||
success(ctx, "ok")
|
||||
}
|
||||
|
||||
var addrReg = regexp.MustCompile(`^[^:]+:([0-9]{1,5})$`)
|
||||
var (
|
||||
hostReg = regexp.MustCompile(`^[a-zA-Z0-9]+[a-zA-Z0-9.]*[a-zA-Z]+$`)
|
||||
letterReg = regexp.MustCompile(`[a-zA-Z\-]`)
|
||||
emptyReg = regexp.MustCompile(`\s+`)
|
||||
)
|
||||
|
||||
func checkAddr(addr string) error {
|
||||
res := addrReg.FindStringSubmatch(addr)
|
||||
if len(res) != 2 {
|
||||
return fmt.Errorf("invalid addr: %s", addr)
|
||||
addr = strings.TrimSpace(addr)
|
||||
|
||||
if emptyReg.MatchString(addr) {
|
||||
return fmt.Errorf("addr format err: %s", addr)
|
||||
}
|
||||
|
||||
intPort := cast.ToInt(res[1])
|
||||
if intPort < 10 || intPort > 65535 {
|
||||
return fmt.Errorf("port: %d out of range: 10 - 65535", intPort)
|
||||
sp := strings.SplitN(addr, ":", 2)
|
||||
host := sp[0]
|
||||
port := sp[1]
|
||||
intPort := cast.ToInt(port)
|
||||
|
||||
if intPort > 65535 || intPort < 10 {
|
||||
return fmt.Errorf("port [%s] out of range: 10 - 65535", port)
|
||||
}
|
||||
|
||||
//_, err := netip.ParseAddrPort(addr)
|
||||
//if err != nil {
|
||||
// return err
|
||||
//}
|
||||
if !letterReg.MatchString(host) {
|
||||
_, err := netip.ParseAddrPort(addr)
|
||||
if err != nil {
|
||||
return fmt.Errorf("ip [%s] format err: %s", host, err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
if !hostReg.MatchString(host) {
|
||||
return fmt.Errorf("host [%s] format err", host)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -9,15 +9,15 @@
|
|||
</div>
|
||||
|
||||
<div>
|
||||
<el-table :data="data.list" style="width: 100%">
|
||||
<el-table :data="data.list" style="width: 100%;" max-height="75vh">
|
||||
<el-table-column align="center" label="协议">
|
||||
<template #default="scope">
|
||||
<div v-if="scope.row.protocol === 1">
|
||||
<el-tag type="success">UDP</el-tag>
|
||||
<el-tag disable-transitions type="success">UDP</el-tag>
|
||||
</div>
|
||||
|
||||
<div v-else>
|
||||
<el-tag type="primary">TCP</el-tag>
|
||||
<el-tag disable-transitions type="primary">TCP</el-tag>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
@ -61,6 +61,8 @@
|
|||
:title="data.form.id > 0 ? '修改': '添加'"
|
||||
width="600px"
|
||||
align-center
|
||||
:close-on-click-modal="false"
|
||||
:show-close="false"
|
||||
>
|
||||
|
||||
<div>
|
||||
|
|
Loading…
Reference in New Issue