diff --git a/web/assets/js/model/xray.js b/web/assets/js/model/xray.js
index 113fa2aa..1258d704 100644
--- a/web/assets/js/model/xray.js
+++ b/web/assets/js/model/xray.js
@@ -592,7 +592,7 @@ class RealityStreamSettings extends XrayCommonClass {
dest = 'microsoft.com:443',
serverNames = 'microsoft.com,www.microsoft.com',
privateKey = '', minClient = '', maxClient = '',
- maxTimediff = 0, shortIds = [],
+ maxTimediff = 0, shortIds = RandomUtil.randomShortId(),
settings= new RealityStreamSettings.Settings()) {
super();
this.show = show;
diff --git a/web/assets/js/util/date-util.js b/web/assets/js/util/date-util.js
index b330ccbd..3809b009 100644
--- a/web/assets/js/util/date-util.js
+++ b/web/assets/js/util/date-util.js
@@ -119,7 +119,7 @@ Date.prototype.formatTime = function () {
};
/**
- * 格式化日期加时间
+ * Formatting date plus time
*
* @param split Division between date and time, the default is a space
*/
diff --git a/web/assets/js/util/utils.js b/web/assets/js/util/utils.js
index 8927833b..ba73fcab 100644
--- a/web/assets/js/util/utils.js
+++ b/web/assets/js/util/utils.js
@@ -149,6 +149,17 @@ class RandomUtil {
window.crypto.getRandomValues(array);
return btoa(String.fromCharCode.apply(null, array));
}
+
+ static randomShortId() {
+ let shortIds = ['','','',''];
+ for (var ii = 0; ii < 4; ii++) {
+ for (var jj = 0; jj < this.randomInt(8); jj++){
+ let randomNum = this.randomInt(256);
+ shortIds[ii] += ('0' + randomNum.toString(16)).slice(-2)
+ }
+ }
+ return shortIds;
+ }
}
class ObjectUtil {
diff --git a/web/html/xui/form/tls_settings.html b/web/html/xui/form/tls_settings.html
index 229a59b3..dc9c4895 100644
--- a/web/html/xui/form/tls_settings.html
+++ b/web/html/xui/form/tls_settings.html
@@ -225,7 +225,9 @@
- | Short Ids |
+ Short Ids
+
+ |
diff --git a/web/service/inbound.go b/web/service/inbound.go
index d24f41af..0d61ef0a 100644
--- a/web/service/inbound.go
+++ b/web/service/inbound.go
@@ -379,14 +379,14 @@ func (s *InboundService) AddInboundClient(data *model.Inbound) (bool, error) {
for _, client := range clients {
if len(client.Email) > 0 {
s.AddClientStat(tx, data.Id, &client)
- err = s.xrayApi.AddUser(string(oldInbound.Protocol), oldInbound.Tag, map[string]interface{}{
+ err1 := s.xrayApi.AddUser(string(oldInbound.Protocol), oldInbound.Tag, map[string]interface{}{
"email": client.Email,
"id": client.ID,
"alterId": client.AlterIds,
"flow": client.Flow,
"password": client.Password,
})
- if err == nil {
+ if err1 == nil {
logger.Debug("Client added by api:", client.Email)
} else {
needRestart = true
@@ -558,14 +558,14 @@ func (s *InboundService) UpdateInboundClient(data *model.Inbound, clientId strin
if len(oldEmail) > 0 {
s.xrayApi.RemoveUser(oldInbound.Tag, oldEmail)
if clients[0].Enable {
- err = s.xrayApi.AddUser(string(oldInbound.Protocol), oldInbound.Tag, map[string]interface{}{
+ err1 := s.xrayApi.AddUser(string(oldInbound.Protocol), oldInbound.Tag, map[string]interface{}{
"email": clients[0].Email,
"id": clients[0].ID,
"alterId": clients[0].AlterIds,
"flow": clients[0].Flow,
"password": clients[0].Password,
})
- if err == nil {
+ if err1 == nil {
logger.Debug("Client edited by api:", clients[0].Email)
needRestart = false
}
@@ -821,14 +821,14 @@ func (s *InboundService) ResetClientTraffic(id int, clientEmail string) (bool, e
for _, client := range clients {
if client.Email == clientEmail {
s.xrayApi.Init(p.GetAPIPort())
- err = s.xrayApi.AddUser(string(inbound.Protocol), inbound.Tag, map[string]interface{}{
+ err1 := s.xrayApi.AddUser(string(inbound.Protocol), inbound.Tag, map[string]interface{}{
"email": client.Email,
"id": client.ID,
"alterId": client.AlterIds,
"flow": client.Flow,
"password": client.Password,
})
- if err == nil {
+ if err1 == nil {
logger.Debug("Client enabled due to reset traffic:", clientEmail)
} else {
needRestart = true
|