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 charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>端口转发配置</title>
|
<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">
|
<link rel="stylesheet" crossorigin href="./assets/index-BA8XwqWY.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
|
@ -13,6 +13,7 @@ import (
|
||||||
"github.com/spf13/cast"
|
"github.com/spf13/cast"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/netip"
|
||||||
"proxyport/app/db"
|
"proxyport/app/db"
|
||||||
"proxyport/app/forward"
|
"proxyport/app/forward"
|
||||||
"proxyport/app/model"
|
"proxyport/app/model"
|
||||||
|
@ -269,23 +270,40 @@ func Delete(ctx *gin.Context) {
|
||||||
success(ctx, "ok")
|
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 {
|
func checkAddr(addr string) error {
|
||||||
res := addrReg.FindStringSubmatch(addr)
|
addr = strings.TrimSpace(addr)
|
||||||
if len(res) != 2 {
|
|
||||||
return fmt.Errorf("invalid addr: %s", addr)
|
if emptyReg.MatchString(addr) {
|
||||||
|
return fmt.Errorf("addr format err: %s", addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
intPort := cast.ToInt(res[1])
|
sp := strings.SplitN(addr, ":", 2)
|
||||||
if intPort < 10 || intPort > 65535 {
|
host := sp[0]
|
||||||
return fmt.Errorf("port: %d out of range: 10 - 65535", intPort)
|
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 !letterReg.MatchString(host) {
|
||||||
//if err != nil {
|
_, err := netip.ParseAddrPort(addr)
|
||||||
// return err
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,15 +9,15 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<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="协议">
|
<el-table-column align="center" label="协议">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<div v-if="scope.row.protocol === 1">
|
<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>
|
||||||
|
|
||||||
<div v-else>
|
<div v-else>
|
||||||
<el-tag type="primary">TCP</el-tag>
|
<el-tag disable-transitions type="primary">TCP</el-tag>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
@ -61,6 +61,8 @@
|
||||||
:title="data.form.id > 0 ? '修改': '添加'"
|
:title="data.form.id > 0 ? '修改': '添加'"
|
||||||
width="600px"
|
width="600px"
|
||||||
align-center
|
align-center
|
||||||
|
:close-on-click-modal="false"
|
||||||
|
:show-close="false"
|
||||||
>
|
>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
|
|
Loading…
Reference in New Issue