mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-04-19 21:42:24 +00:00
New - Allocate
This commit is contained in:
parent
ad78cec7c7
commit
566cd9e9c4
9 changed files with 60 additions and 1 deletions
|
@ -46,6 +46,7 @@ type Inbound struct {
|
||||||
StreamSettings string `json:"streamSettings" form:"streamSettings"`
|
StreamSettings string `json:"streamSettings" form:"streamSettings"`
|
||||||
Tag string `json:"tag" form:"tag" gorm:"unique"`
|
Tag string `json:"tag" form:"tag" gorm:"unique"`
|
||||||
Sniffing string `json:"sniffing" form:"sniffing"`
|
Sniffing string `json:"sniffing" form:"sniffing"`
|
||||||
|
Allocate string `json:"allocate" form:"allocate"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type OutboundTraffics struct {
|
type OutboundTraffics struct {
|
||||||
|
@ -75,6 +76,7 @@ func (i *Inbound) GenXrayInboundConfig() *xray.InboundConfig {
|
||||||
StreamSettings: json_util.RawMessage(i.StreamSettings),
|
StreamSettings: json_util.RawMessage(i.StreamSettings),
|
||||||
Tag: i.Tag,
|
Tag: i.Tag,
|
||||||
Sniffing: json_util.RawMessage(i.Sniffing),
|
Sniffing: json_util.RawMessage(i.Sniffing),
|
||||||
|
Allocate: json_util.RawMessage(i.Allocate),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
"destOverride": [
|
"destOverride": [
|
||||||
"http",
|
"http",
|
||||||
"tls",
|
"tls",
|
||||||
|
"quic",
|
||||||
"fakedns"
|
"fakedns"
|
||||||
],
|
],
|
||||||
"enabled": true
|
"enabled": true
|
||||||
|
|
|
@ -1197,6 +1197,27 @@ class Sniffing extends XrayCommonClass {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class Allocate extends XrayCommonClass {
|
||||||
|
constructor(
|
||||||
|
strategy = "always",
|
||||||
|
refresh = 5,
|
||||||
|
concurrency = 3,
|
||||||
|
) {
|
||||||
|
super();
|
||||||
|
this.strategy = strategy;
|
||||||
|
this.refresh = refresh;
|
||||||
|
this.concurrency = concurrency;
|
||||||
|
}
|
||||||
|
|
||||||
|
static fromJson(json = {}) {
|
||||||
|
return new Allocate(
|
||||||
|
json.strategy,
|
||||||
|
json.refresh,
|
||||||
|
json.concurrency,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class Inbound extends XrayCommonClass {
|
class Inbound extends XrayCommonClass {
|
||||||
constructor(
|
constructor(
|
||||||
port = RandomUtil.randomIntRange(10000, 60000),
|
port = RandomUtil.randomIntRange(10000, 60000),
|
||||||
|
@ -1206,6 +1227,7 @@ class Inbound extends XrayCommonClass {
|
||||||
streamSettings = new StreamSettings(),
|
streamSettings = new StreamSettings(),
|
||||||
tag = '',
|
tag = '',
|
||||||
sniffing = new Sniffing(),
|
sniffing = new Sniffing(),
|
||||||
|
allocate = new Allocate(),
|
||||||
clientStats = '',
|
clientStats = '',
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
|
@ -1216,6 +1238,7 @@ class Inbound extends XrayCommonClass {
|
||||||
this.stream = streamSettings;
|
this.stream = streamSettings;
|
||||||
this.tag = tag;
|
this.tag = tag;
|
||||||
this.sniffing = sniffing;
|
this.sniffing = sniffing;
|
||||||
|
this.allocate = allocate;
|
||||||
this.clientStats = clientStats;
|
this.clientStats = clientStats;
|
||||||
}
|
}
|
||||||
getClientStats() {
|
getClientStats() {
|
||||||
|
@ -1406,6 +1429,7 @@ class Inbound extends XrayCommonClass {
|
||||||
this.stream = new StreamSettings();
|
this.stream = new StreamSettings();
|
||||||
this.tag = '';
|
this.tag = '';
|
||||||
this.sniffing = new Sniffing();
|
this.sniffing = new Sniffing();
|
||||||
|
this.allocate = new Allocate();
|
||||||
}
|
}
|
||||||
|
|
||||||
genVmessLink(address = '', port = this.port, forceTls, remark = '', clientId, security) {
|
genVmessLink(address = '', port = this.port, forceTls, remark = '', clientId, security) {
|
||||||
|
@ -1885,6 +1909,7 @@ class Inbound extends XrayCommonClass {
|
||||||
StreamSettings.fromJson(json.streamSettings),
|
StreamSettings.fromJson(json.streamSettings),
|
||||||
json.tag,
|
json.tag,
|
||||||
Sniffing.fromJson(json.sniffing),
|
Sniffing.fromJson(json.sniffing),
|
||||||
|
Allocate.fromJson(json.allocate),
|
||||||
json.clientStats
|
json.clientStats
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -1902,6 +1927,7 @@ class Inbound extends XrayCommonClass {
|
||||||
streamSettings: streamSettings,
|
streamSettings: streamSettings,
|
||||||
tag: this.tag,
|
tag: this.tag,
|
||||||
sniffing: this.sniffing.toJson(),
|
sniffing: this.sniffing.toJson(),
|
||||||
|
allocate: this.allocate.toJson(),
|
||||||
clientStats: this.clientStats
|
clientStats: this.clientStats
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
16
web/html/xui/form/allocate.html
Normal file
16
web/html/xui/form/allocate.html
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
{{define "form/allocate"}}
|
||||||
|
<a-divider style="margin:5px 0 0;">Allocate</a-divider>
|
||||||
|
<a-form :colon="false" :label-col="{ md: {span:8} }" :wrapper-col="{ md: {span:14} }">
|
||||||
|
<a-form-item label='strategy'>
|
||||||
|
<a-select v-model="inbound.allocate.strategy" :dropdown-class-name="themeSwitcher.currentTheme">
|
||||||
|
<a-select-option v-for="s in ['always','random']" :value="s">[[ s ]]</a-select-option>
|
||||||
|
</a-select>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label='refresh'>
|
||||||
|
<a-input-number v-model.number="inbound.allocate.refresh" min="0"></a-input-number>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label='concurrency'>
|
||||||
|
<a-input-number v-model.number="inbound.allocate.concurrency" min="0"></a-input-number>
|
||||||
|
</a-form-item>
|
||||||
|
</a-form>
|
||||||
|
{{end}}
|
|
@ -118,4 +118,10 @@
|
||||||
<template>
|
<template>
|
||||||
{{template "form/sniffing"}}
|
{{template "form/sniffing"}}
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<!-- allocate -->
|
||||||
|
<template>
|
||||||
|
{{template "form/allocate"}}
|
||||||
|
</template>
|
||||||
|
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{{define "form/sniffing"}}
|
{{define "form/sniffing"}}
|
||||||
<a-divider style="margin:5px 0 0;"></a-divider>
|
<a-divider style="margin:5px 0 0;">Sniffing</a-divider>
|
||||||
<a-form :colon="false" :label-col="{ md: {span:8} }" :wrapper-col="{ md: {span:14} }">
|
<a-form :colon="false" :label-col="{ md: {span:8} }" :wrapper-col="{ md: {span:14} }">
|
||||||
<a-form-item>
|
<a-form-item>
|
||||||
<span slot="label">
|
<span slot="label">
|
||||||
|
|
|
@ -935,6 +935,7 @@
|
||||||
settings: Inbound.Settings.getSettings(baseInbound.protocol).toString(),
|
settings: Inbound.Settings.getSettings(baseInbound.protocol).toString(),
|
||||||
streamSettings: baseInbound.stream.toString(),
|
streamSettings: baseInbound.stream.toString(),
|
||||||
sniffing: baseInbound.sniffing.toString(),
|
sniffing: baseInbound.sniffing.toString(),
|
||||||
|
allocate: baseInbound.allocate.toString(),
|
||||||
};
|
};
|
||||||
await this.submit('/panel/inbound/add', data, inModal);
|
await this.submit('/panel/inbound/add', data, inModal);
|
||||||
},
|
},
|
||||||
|
@ -980,6 +981,7 @@
|
||||||
};
|
};
|
||||||
if (inbound.canEnableStream()) data.streamSettings = inbound.stream.toString();
|
if (inbound.canEnableStream()) data.streamSettings = inbound.stream.toString();
|
||||||
data.sniffing = inbound.sniffing.toString();
|
data.sniffing = inbound.sniffing.toString();
|
||||||
|
data.allocate = inbound.allocate.toString();
|
||||||
|
|
||||||
await this.submit('/panel/inbound/add', data, inModal);
|
await this.submit('/panel/inbound/add', data, inModal);
|
||||||
},
|
},
|
||||||
|
@ -999,6 +1001,7 @@
|
||||||
};
|
};
|
||||||
if (inbound.canEnableStream()) data.streamSettings = inbound.stream.toString();
|
if (inbound.canEnableStream()) data.streamSettings = inbound.stream.toString();
|
||||||
data.sniffing = inbound.sniffing.toString();
|
data.sniffing = inbound.sniffing.toString();
|
||||||
|
data.allocate = inbound.allocate.toString();
|
||||||
|
|
||||||
await this.submit(`/panel/inbound/update/${dbInbound.id}`, data, inModal);
|
await this.submit(`/panel/inbound/update/${dbInbound.id}`, data, inModal);
|
||||||
},
|
},
|
||||||
|
|
|
@ -331,6 +331,7 @@ func (s *InboundService) UpdateInbound(inbound *model.Inbound) (*model.Inbound,
|
||||||
oldInbound.Settings = inbound.Settings
|
oldInbound.Settings = inbound.Settings
|
||||||
oldInbound.StreamSettings = inbound.StreamSettings
|
oldInbound.StreamSettings = inbound.StreamSettings
|
||||||
oldInbound.Sniffing = inbound.Sniffing
|
oldInbound.Sniffing = inbound.Sniffing
|
||||||
|
oldInbound.Allocate = inbound.Allocate
|
||||||
if inbound.Listen == "" || inbound.Listen == "0.0.0.0" || inbound.Listen == "::" || inbound.Listen == "::0" {
|
if inbound.Listen == "" || inbound.Listen == "0.0.0.0" || inbound.Listen == "::" || inbound.Listen == "::0" {
|
||||||
oldInbound.Tag = fmt.Sprintf("inbound-%v", inbound.Port)
|
oldInbound.Tag = fmt.Sprintf("inbound-%v", inbound.Port)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -14,6 +14,7 @@ type InboundConfig struct {
|
||||||
StreamSettings json_util.RawMessage `json:"streamSettings"`
|
StreamSettings json_util.RawMessage `json:"streamSettings"`
|
||||||
Tag string `json:"tag"`
|
Tag string `json:"tag"`
|
||||||
Sniffing json_util.RawMessage `json:"sniffing"`
|
Sniffing json_util.RawMessage `json:"sniffing"`
|
||||||
|
Allocate json_util.RawMessage `json:"allocate"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *InboundConfig) Equals(other *InboundConfig) bool {
|
func (c *InboundConfig) Equals(other *InboundConfig) bool {
|
||||||
|
@ -38,5 +39,8 @@ func (c *InboundConfig) Equals(other *InboundConfig) bool {
|
||||||
if !bytes.Equal(c.Sniffing, other.Sniffing) {
|
if !bytes.Equal(c.Sniffing, other.Sniffing) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
if !bytes.Equal(c.Allocate, other.Allocate) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue