shadowtls users only in v3
This commit is contained in:
@@ -48,6 +48,7 @@ func (s *InboundService) GetAll() (*[]map[string]interface{}, error) {
|
|||||||
}
|
}
|
||||||
var data []map[string]interface{}
|
var data []map[string]interface{}
|
||||||
for _, inbound := range inbounds {
|
for _, inbound := range inbounds {
|
||||||
|
var shadowtls_version uint
|
||||||
inbData := map[string]interface{}{
|
inbData := map[string]interface{}{
|
||||||
"id": inbound.Id,
|
"id": inbound.Id,
|
||||||
"type": inbound.Type,
|
"type": inbound.Type,
|
||||||
@@ -61,7 +62,25 @@ func (s *InboundService) GetAll() (*[]map[string]interface{}, error) {
|
|||||||
}
|
}
|
||||||
inbData["listen"] = restFields["listen"]
|
inbData["listen"] = restFields["listen"]
|
||||||
inbData["listen_port"] = restFields["listen_port"]
|
inbData["listen_port"] = restFields["listen_port"]
|
||||||
|
if inbound.Type == "shadowtls" {
|
||||||
|
json.Unmarshal(restFields["version"], &shadowtls_version)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
switch inbound.Type {
|
||||||
|
case "mixed", "socks", "http", "shadowsocks", "vmess", "trojan", "naive", "hysteria", "shadowtls", "tuic", "hysteria2", "vless":
|
||||||
|
if inbound.Type == "shadowtls" && shadowtls_version < 3 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
var users []string
|
||||||
|
err = db.Raw("SELECT clients.name FROM clients, json_each(clients.inbounds) as je WHERE je.value = ?", inbound.Id).Scan(&users).Error
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if len(users) > 0 || inbound.Type != "shadowsocks" {
|
||||||
|
inbData["users"] = users
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
data = append(data, inbData)
|
data = append(data, inbData)
|
||||||
}
|
}
|
||||||
return &data, nil
|
return &data, nil
|
||||||
@@ -214,6 +233,13 @@ func (s *InboundService) addUsers(db *gorm.DB, inboundJson []byte, inboundId uin
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if inboundType == "shadowtls" {
|
||||||
|
version, _ := inbound["version"].(float64)
|
||||||
|
if int(version) < 3 {
|
||||||
|
return inboundJson, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
if inboundType == "shadowsocks" {
|
if inboundType == "shadowsocks" {
|
||||||
method, _ := inbound["method"].(string)
|
method, _ := inbound["method"].(string)
|
||||||
if method == "2022-blake3-aes-128-gcm" {
|
if method == "2022-blake3-aes-128-gcm" {
|
||||||
@@ -233,6 +259,10 @@ func (s *InboundService) addUsers(db *gorm.DB, inboundJson []byte, inboundId uin
|
|||||||
usersJson = append(usersJson, json.RawMessage(user))
|
usersJson = append(usersJson, json.RawMessage(user))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(usersJson) > 0 || inboundType != "shadowsocks" {
|
||||||
|
inbound["users"] = usersJson
|
||||||
|
}
|
||||||
|
|
||||||
inbound["users"] = usersJson
|
inbound["users"] = usersJson
|
||||||
return json.Marshal(inbound)
|
return json.Marshal(inbound)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
hide-details
|
hide-details
|
||||||
:items="[1,2,3]"
|
:items="[1,2,3]"
|
||||||
:label="$t('version')"
|
:label="$t('version')"
|
||||||
|
:disabled="data.id > 0"
|
||||||
v-model="version">
|
v-model="version">
|
||||||
</v-select>
|
</v-select>
|
||||||
</v-col>
|
</v-col>
|
||||||
@@ -115,23 +116,18 @@ export default {
|
|||||||
switch (newValue) {
|
switch (newValue) {
|
||||||
case 1:
|
case 1:
|
||||||
delete this.Inbound.password
|
delete this.Inbound.password
|
||||||
delete this.Inbound.users
|
|
||||||
delete this.Inbound.handshake_for_server_name
|
delete this.Inbound.handshake_for_server_name
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
if (!this.Inbound.password) {
|
if (!this.Inbound.password) {
|
||||||
this.Inbound.password = ""
|
this.Inbound.password = ""
|
||||||
}
|
}
|
||||||
delete this.Inbound.users
|
|
||||||
if (!this.Inbound.handshake_for_server_name) {
|
if (!this.Inbound.handshake_for_server_name) {
|
||||||
this.Inbound.handshake_for_server_name = {}
|
this.Inbound.handshake_for_server_name = {}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
delete this.Inbound.password
|
delete this.Inbound.password
|
||||||
if (!Object.hasOwn(this.Inbound, 'users')) {
|
|
||||||
this.Inbound.users = []
|
|
||||||
}
|
|
||||||
if (!this.Inbound.handshake_for_server_name) {
|
if (!this.Inbound.handshake_for_server_name) {
|
||||||
this.Inbound.handshake_for_server_name = {}
|
this.Inbound.handshake_for_server_name = {}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user