mirror of
https://github.com/ngoduykhanh/wireguard-ui
synced 2024-06-10 18:02:26 +02:00
Handle paused configs correctly
- Removed unnecessary qr generation
This commit is contained in:
parent
1114ef3214
commit
2adb1c5c80
|
@ -581,12 +581,7 @@ func SendTelegramClient(db store.IStore) echo.HandlerFunc {
|
||||||
var payload clientIdUseridPayload
|
var payload clientIdUseridPayload
|
||||||
c.Bind(&payload)
|
c.Bind(&payload)
|
||||||
|
|
||||||
qrCodeSettings := model.QRCodeSettings{
|
clientData, err := db.GetClientByID(payload.ID, model.QRCodeSettings{Enabled: false})
|
||||||
Enabled: true,
|
|
||||||
IncludeDNS: true,
|
|
||||||
IncludeMTU: true,
|
|
||||||
}
|
|
||||||
clientData, err := db.GetClientByID(payload.ID, qrCodeSettings)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("Cannot generate client id %s config file for downloading: %v", payload.ID, err)
|
log.Errorf("Cannot generate client id %s config file for downloading: %v", payload.ID, err)
|
||||||
return c.JSON(http.StatusNotFound, jsonHTTPResponse{false, "Client not found"})
|
return c.JSON(http.StatusNotFound, jsonHTTPResponse{false, "Client not found"})
|
||||||
|
|
|
@ -169,7 +169,7 @@ func (o *JsonDB) Init() error {
|
||||||
}
|
}
|
||||||
for _, cl := range clients {
|
for _, cl := range clients {
|
||||||
client := cl.Client
|
client := cl.Client
|
||||||
if len(client.TgUserid) > 3 {
|
if client.Enabled && len(client.TgUserid) > 0 {
|
||||||
if userid, err := strconv.ParseInt(client.TgUserid, 10, 64); err == nil {
|
if userid, err := strconv.ParseInt(client.TgUserid, 10, 64); err == nil {
|
||||||
util.UpdateTgToClientID(userid, client.ID)
|
util.UpdateTgToClientID(userid, client.ID)
|
||||||
}
|
}
|
||||||
|
@ -329,10 +329,16 @@ func (o *JsonDB) GetClientByID(clientID string, qrCodeSettings model.QRCodeSetti
|
||||||
func (o *JsonDB) SaveClient(client model.Client) error {
|
func (o *JsonDB) SaveClient(client model.Client) error {
|
||||||
clientPath := path.Join(path.Join(o.dbPath, "clients"), client.ID+".json")
|
clientPath := path.Join(path.Join(o.dbPath, "clients"), client.ID+".json")
|
||||||
output := o.conn.Write("clients", client.ID, client)
|
output := o.conn.Write("clients", client.ID, client)
|
||||||
if output == nil && len(client.TgUserid) > 3 {
|
if output == nil {
|
||||||
if userid, err := strconv.ParseInt(client.TgUserid, 10, 64); err == nil {
|
if client.Enabled && len(client.TgUserid) > 0 {
|
||||||
util.UpdateTgToClientID(userid, client.ID)
|
if userid, err := strconv.ParseInt(client.TgUserid, 10, 64); err == nil {
|
||||||
|
util.UpdateTgToClientID(userid, client.ID)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
util.RemoveTgToClientID(client.ID)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
util.RemoveTgToClientID(client.ID)
|
||||||
}
|
}
|
||||||
err := util.ManagePerms(clientPath)
|
err := util.ManagePerms(clientPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue