Skip to content

Commit

Permalink
v1.8.6
Browse files Browse the repository at this point in the history
  • Loading branch information
alireza0 committed Sep 1, 2024
1 parent 509fff0 commit aaabbda
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 26 deletions.
2 changes: 1 addition & 1 deletion config/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.8.5
1.8.6
6 changes: 3 additions & 3 deletions web/assets/js/model/outbound.js
Original file line number Diff line number Diff line change
Expand Up @@ -872,15 +872,15 @@ Outbound.FreedomSettings.Fragment = class extends CommonClass {
}
};
Outbound.FreedomSettings.Noise = class extends CommonClass {
constructor(packets = '', delay = '') {
constructor(packet = '', delay = '') {
super();
this.packets = packets;
this.packet = packet;
this.delay = delay;
}

static fromJson(json = {}) {
return new Outbound.FreedomSettings.Noise(
json.packets,
json.packet,
json.delay,
);
}
Expand Down
4 changes: 2 additions & 2 deletions web/html/xui/form/outbound.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
</a-switch>
</a-form-item>
<template v-if="Object.keys(outbound.settings.noise).length >0">
<a-form-item label='Packets'>
<a-input v-model.trim="outbound.settings.noise.packets"></a-input>
<a-form-item label='Packet'>
<a-input v-model.trim="outbound.settings.noise.packet"></a-input>
</a-form-item>
<a-form-item label='Delay'>
<a-input v-model.trim="outbound.settings.noise.delay"></a-input>
Expand Down
10 changes: 5 additions & 5 deletions web/html/xui/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@
<setting-list-item type="text" title='Interval' v-model="fragmentInterval" placeholder="10-20"></setting-list-item>
</a-collapse-panel>
<a-collapse-panel header='Noise' v-if="enableNoise">
<setting-list-item type="text" title='Packets' v-model="noisePackets" placeholder="rand:5-10"></setting-list-item>
<setting-list-item type="text" title='Packet' v-model="noisePacket" placeholder="rand:5-10"></setting-list-item>
<setting-list-item type="text" title='Delay' v-model="noiseDelay" placeholder="5-10"></setting-list-item>
</a-collapse-panel>
<a-collapse-panel header='Mux' v-if="enableMux">
Expand Down Expand Up @@ -307,7 +307,7 @@
settings: {
domainStrategy: "AsIs",
noise: {
packets: "rand:5-10",
packet: "rand:5-10",
delay: "5-10",
}
},
Expand Down Expand Up @@ -469,12 +469,12 @@
this.allSetting.subJsonNoise = v ? JSON.stringify(this.defaultNoise) : "";
}
},
noisePackets: {
get: function () { return this.enableNoise ? JSON.parse(this.allSetting.subJsonNoise).settings.noise.packets : ""; },
noisePacket: {
get: function () { return this.enableNoise ? JSON.parse(this.allSetting.subJsonNoise).settings.noise.packet : ""; },
set: function (v) {
if (v != "") {
newNoise = JSON.parse(this.allSetting.subJsonNoise);
newNoise.settings.noise.packets = v;
newNoise.settings.noise.packet = v;
this.allSetting.subJsonNoise = JSON.stringify(newNoise);
}
}
Expand Down
41 changes: 26 additions & 15 deletions web/service/inbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,11 +518,13 @@ func (s *InboundService) DelInboundClient(inboundId int, clientId string) (bool,

interfaceClients := settings["clients"].([]interface{})
var newClients []interface{}
needApiDel := false
for _, client := range interfaceClients {
c := client.(map[string]interface{})
c_id := c[client_key].(string)
if c_id == clientId {
email = c["email"].(string)
email, _ = c["email"].(string)
needApiDel, _ = c["enable"].(bool)
} else {
newClients = append(newClients, client)
}
Expand All @@ -541,23 +543,32 @@ func (s *InboundService) DelInboundClient(inboundId int, clientId string) (bool,
oldInbound.Settings = string(newSettings)

db := database.GetDB()
err = s.DelClientStat(db, email)
if err != nil {
logger.Error("Delete stats Data Error")
return false, err
}
needRestart := false

if len(email) > 0 {
s.xrayApi.Init(p.GetAPIPort())
err1 := s.xrayApi.RemoveUser(oldInbound.Tag, email)
if err1 == nil {
logger.Debug("Client deleted by api:", email)
needRestart = false
} else {
logger.Debug("Unable to del client by api:", err1)
needRestart = true
notDepleted := true
err = db.Model(xray.ClientTraffic{}).Select("enable").Where("email = ?", email).First(&notDepleted).Error
if err != nil {
logger.Error("Get stats error")
return false, err
}
err = s.DelClientStat(db, email)
if err != nil {
logger.Error("Delete stats Data Error")
return false, err
}
if needApiDel && notDepleted {
s.xrayApi.Init(p.GetAPIPort())
err1 := s.xrayApi.RemoveUser(oldInbound.Tag, email)
if err1 == nil {
logger.Debug("Client deleted by api:", email)
needRestart = false
} else {
logger.Debug("Unable to del client by api:", err1)
needRestart = true
}
s.xrayApi.Close()
}
s.xrayApi.Close()
}
return needRestart, db.Save(oldInbound).Error
}
Expand Down

0 comments on commit aaabbda

Please sign in to comment.