1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
|
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import React from 'react';
import * as Utils from 'utils/utils.jsx';
import AdminSettings from './admin_settings.jsx';
import {FormattedMessage, FormattedHTMLMessage} from 'react-intl';
import SettingsGroup from './settings_group.jsx';
import TextSetting from './text_setting.jsx';
import ReloadConfigButton from './reload_config.jsx';
import WebserverModeDropdownSetting from './webserver_mode_dropdown_setting.jsx';
import {ConnectionSecurityDropdownSettingWebserver} from './connection_security_dropdown_setting.jsx';
import BooleanSetting from './boolean_setting.jsx';
export default class ConfigurationSettings extends AdminSettings {
constructor(props) {
super(props);
this.getConfigFromState = this.getConfigFromState.bind(this);
this.renderSettings = this.renderSettings.bind(this);
}
componentWillReceiveProps(nextProps) {
// special case for this page since we don't update AdminSettings components when the
// stored config changes, but we want this page to update when you reload the config
this.setState(this.getStateFromConfig(nextProps.config));
}
getConfigFromState(config) {
config.ServiceSettings.SiteURL = this.state.siteURL;
config.ServiceSettings.ListenAddress = this.state.listenAddress;
config.ServiceSettings.WebserverMode = this.state.webserverMode;
config.ServiceSettings.ConnectionSecurity = this.state.connectionSecurity;
config.ServiceSettings.TLSCertFile = this.state.TLSCertFile;
config.ServiceSettings.TLSKeyFile = this.state.TLSKeyFile;
config.ServiceSettings.UseLetsEncrypt = this.state.useLetsEncrypt;
config.ServiceSettings.LetsEncryptCertificateCacheFile = this.state.letsEncryptCertificateCacheFile;
config.ServiceSettings.Forward80To443 = this.state.forward80To443;
config.ServiceSettings.ReadTimeout = this.parseIntNonZero(this.state.readTimeout);
config.ServiceSettings.WriteTimeout = this.parseIntNonZero(this.state.writeTimeout);
return config;
}
getStateFromConfig(config) {
return {
siteURL: config.ServiceSettings.SiteURL,
listenAddress: config.ServiceSettings.ListenAddress,
webserverMode: config.ServiceSettings.WebserverMode,
connectionSecurity: config.ServiceSettings.ConnectionSecurity,
TLSCertFile: config.ServiceSettings.TLSCertFile,
TLSKeyFile: config.ServiceSettings.TLSKeyFile,
useLetsEncrypt: config.ServiceSettings.UseLetsEncrypt,
letsEncryptCertificateCacheFile: config.ServiceSettings.LetsEncryptCertificateCacheFile,
forward80To443: config.ServiceSettings.Forward80To443,
readTimeout: config.ServiceSettings.ReadTimeout,
writeTimeout: config.ServiceSettings.WriteTimeout
};
}
renderTitle() {
return (
<h3>
<FormattedMessage
id='admin.general.configuration'
defaultMessage='Configuration'
/>
</h3>
);
}
renderSettings() {
return (
<SettingsGroup>
<div className='banner'>
<div className='banner__content'>
<FormattedMessage
id='admin.rate.noteDescription'
defaultMessage='Changing properties in this section will require a server restart before taking effect.'
/>
</div>
</div>
<TextSetting
id='siteURL'
label={
<FormattedMessage
id='admin.service.siteURL'
defaultMessage='Site URL:'
/>
}
placeholder={Utils.localizeMessage('admin.service.siteURLExample', 'Ex "https://mattermost.example.com:1234"')}
helpText={
<FormattedHTMLMessage
id='admin.service.siteURLDescription'
defaultMessage='The URL, including port number and protocol, that users will use to access Mattermost. This field can be left blank unless you are configuring email batching in <b>Notifications > Email</b>. When blank, the URL is automatically configured based on incoming traffic.'
/>
}
value={this.state.siteURL}
onChange={this.handleChange}
/>
<TextSetting
id='listenAddress'
label={
<FormattedMessage
id='admin.service.listenAddress'
defaultMessage='Listen Address:'
/>
}
placeholder={Utils.localizeMessage('admin.service.listenExample', 'Ex ":8065"')}
helpText={
<FormattedMessage
id='admin.service.listenDescription'
defaultMessage='The address and port to which to bind and listen. Specifying ":8065" will bind to all network interfaces. Specifying "127.0.0.1:8065" will only bind to the network interface having that IP address. If you choose a port of a lower level (called "system ports" or "well-known ports", in the range of 0-1023), you must have permissions to bind to that port. On Linux you can use: "sudo setcap cap_net_bind_service=+ep ./bin/platform" to allow Mattermost to bind to well-known ports.'
/>
}
value={this.state.listenAddress}
onChange={this.handleChange}
/>
<ConnectionSecurityDropdownSettingWebserver
value={this.state.connectionSecurity}
onChange={this.handleChange}
disabled={false}
/>
<TextSetting
id='TLSCertFile'
label={
<FormattedMessage
id='admin.service.tlsCertFile'
defaultMessage='TLS Certificate File:'
/>
}
helpText={
<FormattedMessage
id='admin.service.tlsCertFileDescription'
defaultMessage='The certificate file to use.'
/>
}
disabled={this.state.useLetsEncrypt}
value={this.state.TLSCertFile}
onChange={this.handleChange}
/>
<TextSetting
id='TLSKeyFile'
label={
<FormattedMessage
id='admin.service.tlsKeyFile'
defaultMessage='TLS Key File:'
/>
}
helpText={
<FormattedMessage
id='admin.service.tlsKeyFileDescription'
defaultMessage='The private key file to use.'
/>
}
disabled={this.state.useLetsEncrypt}
value={this.state.TLSKeyFile}
onChange={this.handleChange}
/>
<BooleanSetting
id='useLetsEncrypt'
label={
<FormattedMessage
id='admin.service.useLetsEncrypt'
defaultMessage="Use Let's Encrypt:"
/>
}
helpText={
<FormattedMessage
id='admin.service.useLetsEncryptDescription'
defaultMessage="Enable the automatic retreval of certificates from the Let's Encrypt. The certificate will be retrieved when a client attempts to connect from a new domain. This will work with multiple domains."
/>
}
value={this.state.useLetsEncrypt}
onChange={this.handleChange}
/>
<TextSetting
id='letsEncryptCertificateCacheFile'
label={
<FormattedMessage
id='admin.service.letsEncryptCertificateCacheFile'
defaultMessage="Let's Encrypt Certificate Cache File:"
/>
}
helpText={
<FormattedMessage
id='admin.service.letsEncryptCertificateCacheFileDescription'
defaultMessage="Certificates retrieved and other data about the Let's Encrypt service will be stored in this file."
/>
}
disabled={!this.state.useLetsEncrypt}
value={this.state.letsEncryptCertificateCacheFile}
onChange={this.handleChange}
/>
<BooleanSetting
id='forward80To443'
label={
<FormattedMessage
id='admin.service.forward80To443'
defaultMessage='Forward port 80 to 443:'
/>
}
helpText={
<FormattedMessage
id='admin.service.forward80To443Description'
defaultMessage='Forwards all insecure traffic from port 80 to secure port 443'
/>
}
value={this.state.forward80To443}
onChange={this.handleChange}
/>
<TextSetting
id='readTimeout'
label={
<FormattedMessage
id='admin.service.readTimeout'
defaultMessage='Read Timeout:'
/>
}
helpText={
<FormattedMessage
id='admin.service.readTimeoutDescription'
defaultMessage='Maximum time allowed from when the connection is accepted to when the request body is fully read.'
/>
}
value={this.state.readTimeout}
onChange={this.handleChange}
/>
<TextSetting
id='writeTimeout'
label={
<FormattedMessage
id='admin.service.writeTimeout'
defaultMessage='Write Timeout:'
/>
}
helpText={
<FormattedMessage
id='admin.service.writeTimeoutDescription'
defaultMessage='If using HTTP (insecure), this is the maximum time allowed from the end of reading the request headers until the response is written. If using HTTPS, it is the total time from when the connection is accepted until the response is written.'
/>
}
value={this.state.writeTimeout}
onChange={this.handleChange}
/>
<WebserverModeDropdownSetting
value={this.state.webserverMode}
onChange={this.handleChange}
disabled={false}
/>
<ReloadConfigButton/>
</SettingsGroup>
);
}
}
|