move LinkGenerator ro backend

This commit is contained in:
Alireza Ahmadi
2025-01-05 19:33:31 +01:00
parent 753d1f9256
commit 56710aef1e
14 changed files with 697 additions and 648 deletions
+12 -15
View File
@@ -94,8 +94,13 @@ func (j *JsonService) getData(subId string) (*model.Client, []*model.Inbound, er
if err != nil {
return nil, nil, err
}
var clientInbounds []uint
err = json.Unmarshal(client.Inbounds, &clientInbounds)
if err != nil {
return nil, nil, err
}
var inbounds []*model.Inbound
err = db.Model(model.Inbound{}).Where("tag in ?", client.Inbounds).Find(&inbounds).Error
err = db.Model(model.Inbound{}).Where("id in ?", clientInbounds).Find(&inbounds).Error
if err != nil {
return nil, nil, err
}
@@ -156,22 +161,14 @@ func (j *JsonService) getOutbounds(clientConfig json.RawMessage, inbounds []*mod
newOut["server_port"] = int(port)
// Override TLS
newTls, overrideTls := addr["tls"].(bool)
if overrideTls {
tlsIf := map[string]interface{}{}
if newTls {
tlsIf["enabled"] = true
newSNI, overrideSNI := addr["server_name"].(string)
if overrideSNI {
tlsIf["server_name"] = newSNI
}
newInsecure, overrideInsecure := addr["insecure"].(bool)
if overrideInsecure {
tlsIf["insecure"] = newInsecure
}
outTls, _ := newOut["tls"].(map[string]interface{})
if addrTls, ok := addr["tls"].(map[string]interface{}); ok {
for key, value := range addrTls {
outTls[key] = value
}
newOut["tls"] = tlsIf
}
newOut["tls"] = outTls
remark, _ := addr["remark"].(string)
newTag := fmt.Sprintf("%d.%s%s", index+1, tag, remark)
newOut["tag"] = newTag