Merge pull request #1924 from loafoe/master
[#1923] Make Websocket ports configurable
Этот коммит содержится в:
@@ -41,6 +41,13 @@ Set the number of days before SSO sessions expire.
|
|||||||
```"SessionCacheInMinutes" : 10```
|
```"SessionCacheInMinutes" : 10```
|
||||||
Set the number of minutes to cache a session in memory.
|
Set the number of minutes to cache a session in memory.
|
||||||
|
|
||||||
|
```"WebsocketSecurePort": 443```
|
||||||
|
The port to use for secure websocket connections being initiated from the client. By default wss:// uses port 443. Some server configurations (e.g. Cloudfoundry) support wss on a different port.
|
||||||
|
|
||||||
|
```"WebsocketPort": 80```
|
||||||
|
The port to use for websocket connections being initiated from the client. By default ws:// uses port 80.
|
||||||
|
|
||||||
|
|
||||||
#### Webhooks
|
#### Webhooks
|
||||||
|
|
||||||
```"EnableIncomingWebhooks": true```
|
```"EnableIncomingWebhooks": true```
|
||||||
|
|||||||
@@ -40,6 +40,8 @@ type ServiceSettings struct {
|
|||||||
SessionLengthMobileInDays *int
|
SessionLengthMobileInDays *int
|
||||||
SessionLengthSSOInDays *int
|
SessionLengthSSOInDays *int
|
||||||
SessionCacheInMinutes *int
|
SessionCacheInMinutes *int
|
||||||
|
WebsocketSecurePort *int
|
||||||
|
WebsocketPort *int
|
||||||
}
|
}
|
||||||
|
|
||||||
type SSOSettings struct {
|
type SSOSettings struct {
|
||||||
@@ -330,6 +332,14 @@ func (o *Config) SetDefaults() {
|
|||||||
o.ServiceSettings.SessionCacheInMinutes = new(int)
|
o.ServiceSettings.SessionCacheInMinutes = new(int)
|
||||||
*o.ServiceSettings.SessionCacheInMinutes = 10
|
*o.ServiceSettings.SessionCacheInMinutes = 10
|
||||||
}
|
}
|
||||||
|
if o.ServiceSettings.WebsocketPort == nil {
|
||||||
|
o.ServiceSettings.WebsocketPort = new(int)
|
||||||
|
*o.ServiceSettings.WebsocketPort = 80
|
||||||
|
}
|
||||||
|
if o.ServiceSettings.WebsocketSecurePort == nil {
|
||||||
|
o.ServiceSettings.WebsocketSecurePort = new(int)
|
||||||
|
*o.ServiceSettings.WebsocketSecurePort = 443
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *Config) IsValid() *AppError {
|
func (o *Config) IsValid() *AppError {
|
||||||
|
|||||||
@@ -223,5 +223,8 @@ func getClientConfig(c *model.Config) map[string]string {
|
|||||||
|
|
||||||
props["EnableLdap"] = strconv.FormatBool(*c.LdapSettings.Enable)
|
props["EnableLdap"] = strconv.FormatBool(*c.LdapSettings.Enable)
|
||||||
|
|
||||||
|
props["WebsocketPort"] = fmt.Sprintf("%v", *c.ServiceSettings.WebsocketPort)
|
||||||
|
props["WebsocketSecurePort"] = fmt.Sprintf("%v", *c.ServiceSettings.WebsocketSecurePort)
|
||||||
|
|
||||||
return props
|
return props
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ class SocketStoreClass extends EventEmitter {
|
|||||||
protocol = 'wss://';
|
protocol = 'wss://';
|
||||||
}
|
}
|
||||||
|
|
||||||
var connUrl = protocol + location.host + '/api/v1/websocket?' + Utils.getSessionIndex();
|
var connUrl = protocol + location.host + ((/:\d+/).test(location.host) ? '' : Utils.getWebsocketPort(protocol)) + '/api/v1/websocket?' + Utils.getSessionIndex();
|
||||||
|
|
||||||
if (this.failCount === 0) {
|
if (this.failCount === 0) {
|
||||||
console.log('websocket connecting to ' + connUrl); //eslint-disable-line no-console
|
console.log('websocket connecting to ' + connUrl); //eslint-disable-line no-console
|
||||||
|
|||||||
@@ -1101,6 +1101,17 @@ export function getFileName(path) {
|
|||||||
return split[split.length - 1];
|
return split[split.length - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Gets the websocket port to use. Configurable on the server.
|
||||||
|
export function getWebsocketPort(protocol) {
|
||||||
|
if ((/^wss:/).test(protocol)) { // wss://
|
||||||
|
return ':' + global.window.mm_config.WebsocketSecurePort;
|
||||||
|
}
|
||||||
|
if ((/^ws:/).test(protocol)) {
|
||||||
|
return ':' + global.window.mm_config.WebsocketPort;
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
export function getSessionIndex() {
|
export function getSessionIndex() {
|
||||||
if (global.window.mm_session_token_index >= 0) {
|
if (global.window.mm_session_token_index >= 0) {
|
||||||
return 'session_token_index=' + global.window.mm_session_token_index;
|
return 'session_token_index=' + global.window.mm_session_token_index;
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user