Skip to content

Commit

Permalink
WebSocket: Add heartbeatPeriod
Browse files Browse the repository at this point in the history
  • Loading branch information
MHSanaei committed Dec 3, 2024
1 parent 462e021 commit 3e8fc59
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
6 changes: 5 additions & 1 deletion web/assets/js/model/inbound.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,13 +379,15 @@ class WsStreamSettings extends XrayCommonClass {
acceptProxyProtocol = false,
path = '/',
host = '',
headers = []
headers = [],
heartbeatPeriod = 0,
) {
super();
this.acceptProxyProtocol = acceptProxyProtocol;
this.path = path;
this.host = host;
this.headers = headers;
this.heartbeatPeriod = heartbeatPeriod;
}

addHeader(name, value) {
Expand All @@ -402,6 +404,7 @@ class WsStreamSettings extends XrayCommonClass {
json.path,
json.host,
XrayCommonClass.toHeaders(json.headers),
json.heartbeatPeriod,
);
}

Expand All @@ -411,6 +414,7 @@ class WsStreamSettings extends XrayCommonClass {
path: this.path,
host: this.host,
headers: XrayCommonClass.toV2Headers(this.headers, false),
heartbeatPeriod: this.heartbeatPeriod,
};
}
}
Expand Down
10 changes: 9 additions & 1 deletion web/assets/js/model/outbound.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,23 +206,31 @@ class KcpStreamSettings extends CommonClass {
}

class WsStreamSettings extends CommonClass {
constructor(path = '/', host = '') {
constructor(
path = '/',
host = '',
heartbeatPeriod = 0,

) {
super();
this.path = path;
this.host = host;
this.heartbeatPeriod = heartbeatPeriod;
}

static fromJson(json = {}) {
return new WsStreamSettings(
json.path,
json.host,
json.heartbeatPeriod,
);
}

toJson() {
return {
path: this.path,
host: this.host,
heartbeatPeriod: this.heartbeatPeriod
};
}
}
Expand Down
3 changes: 3 additions & 0 deletions web/html/xui/form/outbound.html
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,9 @@
<a-form-item label='{{ i18n "path" }}'>
<a-input v-model.trim="outbound.stream.ws.path"></a-input>
</a-form-item>
<a-form-item label='Heartbeat Period'>
<a-input-number v-model.number="outbound.stream.ws.heartbeatPeriod" :min="0"></a-input-number>
</a-form-item>
</template>

<!-- http -->
Expand Down
3 changes: 3 additions & 0 deletions web/html/xui/form/stream/stream_ws.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
<a-form-item label='{{ i18n "path" }}'>
<a-input v-model.trim="inbound.stream.ws.path"></a-input>
</a-form-item>
<a-form-item label='Heartbeat Period'>
<a-input-number v-model.number="inbound.stream.ws.heartbeatPeriod" :min="0"></a-input-number>
</a-form-item>
<a-form-item label='{{ i18n "pages.inbounds.stream.tcp.requestHeader" }}'>
<a-button icon="plus" size="small" @click="inbound.stream.ws.addHeader('host', '')"></a-button>
</a-form-item>
Expand Down

0 comments on commit 3e8fc59

Please sign in to comment.