summary refs log tree commit diff
diff options
context:
space:
mode:
authorJorik Schellekens <joriks@matrix.org>2019-08-07 16:32:35 +0100
committerJorik Schellekens <joriks@matrix.org>2019-08-28 15:59:53 +0100
commita8cc43dfac45e20937ce18f3053863fb9f9aa4cd (patch)
treed8636206270e7881afd1e3e15634f7f018b3b049
parentTemplates (diff)
downloadsynapse-a8cc43dfac45e20937ce18f3053863fb9f9aa4cd.tar.xz
Finished templates, database config, and started converting options to synapse yaml.
-rw-r--r--synapse_topology/view/webui/js/actions/constants.js5
-rw-r--r--synapse_topology/view/webui/js/actions/index.js6
-rw-r--r--synapse_topology/view/webui/js/actions/types.js3
-rw-r--r--synapse_topology/view/webui/js/components/Database.jsx28
-rw-r--r--synapse_topology/view/webui/js/components/DelegationPortSelection.jsx2
-rw-r--r--synapse_topology/view/webui/js/components/DelegationSampleConfig.jsx78
-rw-r--r--synapse_topology/view/webui/js/components/DelegationServerName.jsx2
-rw-r--r--synapse_topology/view/webui/js/components/PortSelection.jsx2
-rw-r--r--synapse_topology/view/webui/js/components/ReverseProxy.jsx2
-rw-r--r--synapse_topology/view/webui/js/components/ReverseProxySampleConfig.jsx13
-rw-r--r--synapse_topology/view/webui/js/components/ServerName.jsx2
-rw-r--r--synapse_topology/view/webui/js/components/UI.jsx12
-rw-r--r--synapse_topology/view/webui/js/containers/ContentWrapper.js12
-rw-r--r--synapse_topology/view/webui/js/containers/Database.js20
-rw-r--r--synapse_topology/view/webui/js/containers/DelegationSampleConfig.js56
-rw-r--r--synapse_topology/view/webui/js/reducers/index.js7
-rw-r--r--synapse_topology/view/webui/js/reducers/reducer-base-config-ui.js24
-rw-r--r--synapse_topology/view/webui/js/reducers/reducer-base-config.js7
-rw-r--r--synapse_topology/view/webui/js/reducers/reducer-ui.js19
-rw-r--r--synapse_topology/view/webui/js/reducers/ui_constants.js2
-rw-r--r--synapse_topology/view/webui/js/templates/apache.js2
-rw-r--r--synapse_topology/view/webui/js/templates/caddy.js8
-rw-r--r--synapse_topology/view/webui/js/templates/client-well-known.js8
-rw-r--r--synapse_topology/view/webui/js/templates/dns-srv.js6
-rw-r--r--synapse_topology/view/webui/js/templates/federation-well-known.js8
-rw-r--r--synapse_topology/view/webui/js/templates/haproxy.js11
-rw-r--r--synapse_topology/view/webui/js/templates/nginx.js36
-rw-r--r--synapse_topology/view/webui/js/utils/yaml.js64
28 files changed, 341 insertions, 104 deletions
diff --git a/synapse_topology/view/webui/js/actions/constants.js b/synapse_topology/view/webui/js/actions/constants.js

index ebd3498679..11b746d4c8 100644 --- a/synapse_topology/view/webui/js/actions/constants.js +++ b/synapse_topology/view/webui/js/actions/constants.js
@@ -16,4 +16,9 @@ export const TLS_TYPES = { ACME: "ACME", TLS: "TLS", REVERSE_PROXY: "REVERSE_PROXY", +} + +export const DATABASE_TYPES = { + SQLITE3: "SQLITE3", + POSTGRES: "POSTGRES", } \ No newline at end of file diff --git a/synapse_topology/view/webui/js/actions/index.js b/synapse_topology/view/webui/js/actions/index.js
index adf99c6073..5d7a686d17 100644 --- a/synapse_topology/view/webui/js/actions/index.js +++ b/synapse_topology/view/webui/js/actions/index.js
@@ -20,6 +20,7 @@ import { TESTING_SYNAPSE_PORTS, SET_SYNAPSE_PORTS, SET_SYNAPSE_PORTS_FREE, + SET_DATABASE, } from './types'; import { @@ -219,4 +220,9 @@ export const update_ports_free = (synapse_federation_port_free, synapse_client_p export const testing_synapse_ports = verifying => ({ type: TESTING_SYNAPSE_PORTS, verifying, +}) + +export const set_database = database => ({ + type: SET_DATABASE, + database, }) \ No newline at end of file diff --git a/synapse_topology/view/webui/js/actions/types.js b/synapse_topology/view/webui/js/actions/types.js
index 2dad5969a6..bb85933752 100644 --- a/synapse_topology/view/webui/js/actions/types.js +++ b/synapse_topology/view/webui/js/actions/types.js
@@ -18,4 +18,5 @@ export const SET_TLS_CERT_PATHS_VALIDITY = 'SET_TLS_CERT_PATHS_VALIDITY'; export const SET_TLS_CERT_FILES = 'SET_TLS_CERT_FILES'; export const TESTING_SYNAPSE_PORTS = 'TESTING_SYNAPSE_PORTS'; export const SET_SYNAPSE_PORTS = 'SET_SYNAPSE_PORTS'; -export const SET_SYNAPSE_PORTS_FREE = 'SET_SYNAPSE_PORTS_IN_USE'; \ No newline at end of file +export const SET_SYNAPSE_PORTS_FREE = 'SET_SYNAPSE_PORTS_IN_USE'; +export const SET_DATABASE = 'SET_DATABASE'; \ No newline at end of file diff --git a/synapse_topology/view/webui/js/components/Database.jsx b/synapse_topology/view/webui/js/components/Database.jsx new file mode 100644
index 0000000000..b1a05cf9e8 --- /dev/null +++ b/synapse_topology/view/webui/js/components/Database.jsx
@@ -0,0 +1,28 @@ +import React, { useState } from 'react'; + +import ContentWrapper from '../containers/ContentWrapper'; + +import { + DATABASE_TYPES +} from '../actions/constants' +import ButtonDisplay from './ButtonDisplay'; + +export default ({ + onClick, +}) => { + const defaultDatabase = DATABASE_TYPES.POSTGRES; + const [database, setDatabase] = useState(defaultDatabase) + return <ContentWrapper> + <h1>Database</h1> + <p>Synapse can use either SQLite3 or Postgres as it's databse.</p> + <p>If you don't have one of those two installed Postgres is the recommended database to use.</p> + + <select defaultValue={defaultDatabase} onChange={event => setDatabase(event.target.value)}> + <option value={DATABASE_TYPES.POSTGRES}>PostgreSQL</option> + <option value={DATABASE_TYPES.SQLITE3}>SQLite3</option> + </select> + <ButtonDisplay> + <button onClick={() => onClick(database)}>Continue</button> + </ButtonDisplay> + </ContentWrapper> +} diff --git a/synapse_topology/view/webui/js/components/DelegationPortSelection.jsx b/synapse_topology/view/webui/js/components/DelegationPortSelection.jsx
index f4ae8bb27f..ceb8e5dff4 100644 --- a/synapse_topology/view/webui/js/components/DelegationPortSelection.jsx +++ b/synapse_topology/view/webui/js/components/DelegationPortSelection.jsx
@@ -1,6 +1,6 @@ import React, { useState } from 'react'; -import ContentWrapper from './ContentWrapper'; +import ContentWrapper from '../containers/ContentWrapper'; import style from '../../less/main.less'; diff --git a/synapse_topology/view/webui/js/components/DelegationSampleConfig.jsx b/synapse_topology/view/webui/js/components/DelegationSampleConfig.jsx
index bed9bd7a20..ab4dd7d280 100644 --- a/synapse_topology/view/webui/js/components/DelegationSampleConfig.jsx +++ b/synapse_topology/view/webui/js/components/DelegationSampleConfig.jsx
@@ -3,24 +3,64 @@ import React from 'react'; import ContentWrapper from '../containers/ContentWrapper'; import ButtonDisplay from './ButtonDisplay'; import DownloadOrCopy from './DownloadOrCopy'; -import { REVERSE_PROXY_TYPES, DELEGATION_TYPES } from '../actions/constants'; +import { DELEGATION_TYPES } from '../actions/constants'; -export default (delegationType, serverConfig, clientConfig, fileName, serverName, onClick) => { - const delegationExplanation = delegationType == DELEGATION_TYPES.DNS ? - "You will need to add the following SRV record to your DNS zone." : - `You'll need to host the following at https://${serverName}/.well-known/matrix/server` - return <ContentWrapper> - <h1>Configure delegation</h1> - <p> - The delegation configuration needs to take place outside the installer. - </p> - {delegationExplanation} - <code> - {sampleConfig} - </code> - <DownloadOrCopy content={sampleConfig} fileName={fileName} /> - <ButtonDisplay> - <button onClick={onClick}>Continue</button> - </ButtonDisplay> - </ContentWrapper>; +export default ({ + delegationType, + serverConfig, + clientConfig, + serverConfigFileName, + clientConfigFileName, + serverName, + onClick +}) => { + if (delegationType == DELEGATION_TYPES.DNS) { + + return <ContentWrapper> + <h1>ConfigureDelegation</h1> + <p> + You will need to add the following SRV record to your DNS zone. + </p> + <pre> + <code> + {clientConfig} + </code> + </pre> + <DownloadOrCopy content={clientConfig} fileName={clientConfigFileName} /> + <ButtonDisplay> + <button onClick={onClick}>Continue</button> + </ButtonDisplay> + </ContentWrapper> + + } else { + + return <ContentWrapper> + <h1>Configure delegation</h1> + <p> + The delegation configuration needs to take place outside the installer. + </p> + <p> + You'll need to host the following at https://{serverName}/.well-known/matrix/server + </p> + <pre> + <code> + {serverConfig} + </code> + </pre> + <DownloadOrCopy content={serverConfig} fileName={serverConfigFileName} /> + <p> + You'll also need to host the following at https://{serverName}/.well-known/matrix/client + </p> + <pre> + <code> + {clientConfig} + </code> + </pre> + <DownloadOrCopy content={clientConfig} fileName={clientConfigFileName} /> + <ButtonDisplay> + <button onClick={onClick}>Continue</button> + </ButtonDisplay> + </ContentWrapper>; + + } } \ No newline at end of file diff --git a/synapse_topology/view/webui/js/components/DelegationServerName.jsx b/synapse_topology/view/webui/js/components/DelegationServerName.jsx
index 0d34f52be2..aa0382f5d2 100644 --- a/synapse_topology/view/webui/js/components/DelegationServerName.jsx +++ b/synapse_topology/view/webui/js/components/DelegationServerName.jsx
@@ -1,6 +1,6 @@ import React, { useState } from 'react'; -import ContentWrapper from './ContentWrapper'; +import ContentWrapper from '../containers/ContentWrapper'; export default ({ onClick }) => { const [servername, setServerName] = useState(""); diff --git a/synapse_topology/view/webui/js/components/PortSelection.jsx b/synapse_topology/view/webui/js/components/PortSelection.jsx
index 3e727c943e..81080745c0 100644 --- a/synapse_topology/view/webui/js/components/PortSelection.jsx +++ b/synapse_topology/view/webui/js/components/PortSelection.jsx
@@ -1,6 +1,6 @@ import React, { useState } from 'react'; -import ContentWrapper from './ContentWrapper'; +import ContentWrapper from '../containers/ContentWrapper'; import style from '../../less/main.less'; diff --git a/synapse_topology/view/webui/js/components/ReverseProxy.jsx b/synapse_topology/view/webui/js/components/ReverseProxy.jsx
index 9efbad8f3f..ce8806fabb 100644 --- a/synapse_topology/view/webui/js/components/ReverseProxy.jsx +++ b/synapse_topology/view/webui/js/components/ReverseProxy.jsx
@@ -1,6 +1,6 @@ import React, { useState } from 'react'; -import ContentWrapper from './ContentWrapper'; +import ContentWrapper from '../containers/ContentWrapper'; import { REVERSE_PROXY_TYPES diff --git a/synapse_topology/view/webui/js/components/ReverseProxySampleConfig.jsx b/synapse_topology/view/webui/js/components/ReverseProxySampleConfig.jsx
index 069fb3ab22..a90cde534a 100644 --- a/synapse_topology/view/webui/js/components/ReverseProxySampleConfig.jsx +++ b/synapse_topology/view/webui/js/components/ReverseProxySampleConfig.jsx
@@ -5,7 +5,10 @@ import ButtonDisplay from './ButtonDisplay'; import DownloadOrCopy from './DownloadOrCopy'; import { REVERSE_PROXY_TYPES } from '../actions/constants'; -export default (proxyType, sampleConfig, fileName, onClick) => { +export default ({ proxyType, sampleConfig, fileName, onClick }) => { + console.log("SFSFD") + console.log(sampleConfig) + console.log("SFSFD") return <ContentWrapper> <h1>Configure the ReverseProxy</h1> <p> @@ -23,9 +26,11 @@ export default (proxyType, sampleConfig, fileName, onClick) => { but here's the sample configuration for your {proxyType} proxy. </p> } - <code> - {sampleConfig} - </code> + <pre> + <code> + {sampleConfig} + </code> + </pre> <DownloadOrCopy content={sampleConfig} fileName={fileName} /> <ButtonDisplay> <button onClick={onClick}>Continue</button> diff --git a/synapse_topology/view/webui/js/components/ServerName.jsx b/synapse_topology/view/webui/js/components/ServerName.jsx
index f474300916..76e57e68d1 100644 --- a/synapse_topology/view/webui/js/components/ServerName.jsx +++ b/synapse_topology/view/webui/js/components/ServerName.jsx
@@ -1,6 +1,6 @@ import React, { useState } from 'react'; -import ContentWrapper from './ContentWrapper'; +import ContentWrapper from '../containers/ContentWrapper'; export default ({ onClick }) => { const [servername, setServerName] = useState(""); diff --git a/synapse_topology/view/webui/js/components/UI.jsx b/synapse_topology/view/webui/js/components/UI.jsx
index dcca04ebe0..169ef1a779 100644 --- a/synapse_topology/view/webui/js/components/UI.jsx +++ b/synapse_topology/view/webui/js/components/UI.jsx
@@ -20,6 +20,8 @@ import { DELEGATION_SERVER_NAME_UI, TLS_CERTPATH_UI, DELEGATION_PORT_SELECTION_UI, + DELEGATION_TEMPLATE_UI, + DATABASE_UI, } from '../reducers/ui_constants'; import Error from '../components/Error'; @@ -36,6 +38,9 @@ import TLS from '../containers/TLS'; import TLSCertPath from '../containers/TLSCertPath'; import DelegationPortSelection from '../containers/DelegationPortSelection'; import PortSelection from '../containers/PortSelection'; +import ReverseProxySampleConfig from '../containers/ReverseProxySampleConfig'; +import DelegationSampleConfig from '../containers/DelegationSampleConfig'; +import Database from '../containers/Database'; export default ({ active_ui, dispatch }) => { console.log(`switching to ui ${active_ui}`) @@ -66,9 +71,12 @@ export default ({ active_ui, dispatch }) => { return <TLSCertPath /> case PORT_SELECTION_UI: return <PortSelection /> - case WELL_KNOWN_UI: - case DNS_UI: case REVERSE_PROXY_TEMPLATE_UI: + return <ReverseProxySampleConfig /> + case DELEGATION_TEMPLATE_UI: + return <DelegationSampleConfig /> + case DATABASE_UI: + return <Database /> default: return <h1>how did i get here?</h1> } diff --git a/synapse_topology/view/webui/js/containers/ContentWrapper.js b/synapse_topology/view/webui/js/containers/ContentWrapper.js
index 20bf2fd952..47ebcadb21 100644 --- a/synapse_topology/view/webui/js/containers/ContentWrapper.js +++ b/synapse_topology/view/webui/js/containers/ContentWrapper.js
@@ -2,14 +2,10 @@ import { connect } from 'react-redux'; import ContentWrapper from '../components/ContentWrapper'; -const mapStateToProps = (state, { children }) => { - const servername = state.base_config.servername; - console.log(state) - return { - servername, - children, - } -} +const mapStateToProps = (state, { children }) => ({ + servername: state.base_config.servername, + children, +}) const mapDispatchToProps = (dispatch) => ({ diff --git a/synapse_topology/view/webui/js/containers/Database.js b/synapse_topology/view/webui/js/containers/Database.js new file mode 100644
index 0000000000..e590831405 --- /dev/null +++ b/synapse_topology/view/webui/js/containers/Database.js
@@ -0,0 +1,20 @@ +import { connect } from 'react-redux'; + +import Database from '../components/Database'; +import { set_database, advance_ui } from '../actions'; + +const mapStateToProps = (state) => { +} + + +const mapDispatchToProps = (dispatch) => ({ + onClick: database => { + dispatch(set_database(database)); + dispatch(advance_ui()); + } +}); + +export default connect( + null, + mapDispatchToProps, +)(Database); \ No newline at end of file diff --git a/synapse_topology/view/webui/js/containers/DelegationSampleConfig.js b/synapse_topology/view/webui/js/containers/DelegationSampleConfig.js
index e69de29bb2..82deabef2f 100644 --- a/synapse_topology/view/webui/js/containers/DelegationSampleConfig.js +++ b/synapse_topology/view/webui/js/containers/DelegationSampleConfig.js
@@ -0,0 +1,56 @@ +import { connect } from 'react-redux'; + +import DelegationSampleConfig from '../components/DelegationSampleConfig'; + +import { advance_ui } from '../actions'; + +import DNSConfig from '../templates/dns-srv'; +import FedWellKnownConfig from '../templates/federation-well-known' +import ClientWellKnownConfig from '../templates/client-well-known' +import { DELEGATION_TYPES } from '../actions/constants'; + +// synapseServerName: state.base_config.delegation_server_name ? state.base_config.delegation_server_name : state.base_config.servername, + +const serverConfig = state => { + if (state.delegation_type == DELEGATION_TYPES.DNS) { + return undefined; + } else { + return FedWellKnownConfig({ + synapseServerName: state.delegation_servername, + delegationSynapsePort: state.delegation_federation_port ? state.delegation_federation_port : 8448, + }); + } +} + +const clientConfig = state => { + if (state.delegation_type == DELEGATION_TYPES.WELL_KNOWN) { + return ClientWellKnownConfig({ + synapseServerName: state.delegation_servername, + delegationClientPort: state.delegation_client_port ? state.delegation_client_port : 443, + }); + } else { + return DNSConfig({ + serverName: state.servername, + synapseServerName: state.delegation_servername, + delegationClientPort: state.delegation_client_port ? state.delegation_client_port : 443, + }) + } +} + +const mapStateToProps = state => ({ + delegationType: state.base_config.delegation_type, + serverConfig: serverConfig(state.base_config), + clientConfig: clientConfig(state.base_config), + serverConfigFileName: `${state.base_config.servername}_delegation.conf`, + clientConfigFileName: `${state.base_config.servername}_client_delegation.conf`, + serverName: state.base_config.servername, +}); + +const mapDispatchToProps = dispatch => ({ + onClick: () => dispatch(advance_ui()), +}); + +export default connect( + mapStateToProps, + mapDispatchToProps +)(DelegationSampleConfig); \ No newline at end of file diff --git a/synapse_topology/view/webui/js/reducers/index.js b/synapse_topology/view/webui/js/reducers/index.js
index 0a0b154ad6..83a10a598a 100644 --- a/synapse_topology/view/webui/js/reducers/index.js +++ b/synapse_topology/view/webui/js/reducers/index.js
@@ -2,8 +2,9 @@ import { combineReducers } from 'redux'; import ui from './reducer-ui'; import base_config from './reducer-base-config'; import { get_server_setup } from '../api'; +import { LOADING_UI } from './ui_constants'; -export default combineReducers({ - ui, - base_config +export default (state = { ui: { active_ui: LOADING_UI }, base_config: {} }, action) => ({ + ui: ui(state, action), + base_config: base_config(state.base_config, action) }); \ No newline at end of file diff --git a/synapse_topology/view/webui/js/reducers/reducer-base-config-ui.js b/synapse_topology/view/webui/js/reducers/reducer-base-config-ui.js
index 8e28f59a07..424328de03 100644 --- a/synapse_topology/view/webui/js/reducers/reducer-base-config-ui.js +++ b/synapse_topology/view/webui/js/reducers/reducer-base-config-ui.js
@@ -15,18 +15,20 @@ import { REVERSE_PROXY_TEMPLATE_UI, TLS_CERTPATH_UI, DELEGATION_PORT_SELECTION_UI, + DELEGATION_TEMPLATE_UI, + DATABASE_UI, } from './ui_constants'; import { DELEGATION_TYPES, TLS_TYPES } from '../actions/constants'; -export default (state, action) => { +export default ({ ui, base_config }, action) => { switch (action.type) { case BASE_CONFIG_CHECKED: return BASE_INTRO_UI; case ADVANCE_UI: - switch (state) { + switch (ui.active_ui) { case BASE_INTRO_UI: return SERVER_NAME_UI; case SERVER_NAME_UI: @@ -64,17 +66,27 @@ export default (state, action) => { return PORT_SELECTION_UI; case TLS_CERTPATH_UI: return PORT_SELECTION_UI; + case PORT_SELECTION_UI: + return base_config.tls == TLS_TYPES.REVERSE_PROXY ? + REVERSE_PROXY_TEMPLATE_UI : + base_config.delegation_type != DELEGATION_TYPES.LOCAL ? + DELEGATION_TEMPLATE_UI : + DATABASE_UI; + case REVERSE_PROXY_TEMPLATE_UI: + return base_config.delegation_type != DELEGATION_TYPES.LOCAL ? + DELEGATION_TEMPLATE_UI : + DATABASE_UI; + case DELEGATION_TEMPLATE_UI: + return DATABASE_UI; case WELL_KNOWN_UI: case DNS_UI: - case PORT_SELECTION_UI: - return REVERSE_PROXY_TEMPLATE_UI; default: return BASE_INTRO_UI; } // TODO: Think about how back should work.. case BACK_UI: - switch (state) { + switch (ui.active_ui) { case STATS_REPORT_UI: return SERVER_NAME_UI; case KEY_EXPORT_UI: @@ -89,6 +101,6 @@ export default (state, action) => { BASE_INTRO_UI; } default: - return state; + return ui.active_ui; } } diff --git a/synapse_topology/view/webui/js/reducers/reducer-base-config.js b/synapse_topology/view/webui/js/reducers/reducer-base-config.js
index 0192b0ff22..fdd8e48633 100644 --- a/synapse_topology/view/webui/js/reducers/reducer-base-config.js +++ b/synapse_topology/view/webui/js/reducers/reducer-base-config.js
@@ -15,6 +15,7 @@ import { TESTING_SYNAPSE_PORTS, SET_SYNAPSE_PORTS, SET_SYNAPSE_PORTS_FREE, + SET_DATABASE, } from "../actions/types"; export default (state = { servername: undefined }, action) => { @@ -111,7 +112,11 @@ export default (state = { servername: undefined }, action) => { synapse_federation_port_free: action.synapse_federation_port_free, synapse_client_port_free: action.synapse_client_port_free, } - + case SET_DATABASE: + return { + ...state, + database: action.database, + } default: return state; } diff --git a/synapse_topology/view/webui/js/reducers/reducer-ui.js b/synapse_topology/view/webui/js/reducers/reducer-ui.js
index 792f0ead0a..20421e956e 100644 --- a/synapse_topology/view/webui/js/reducers/reducer-ui.js +++ b/synapse_topology/view/webui/js/reducers/reducer-ui.js
@@ -4,33 +4,34 @@ import { LOADING_UI, ERROR_UI } from './ui_constants'; import { BASE_CONFIG_CHECKED, FAIL } from '../actions/types'; -export default (state = { active_ui: LOADING_UI }, action) => { +export default (state, action) => { + console.log(state) console.log(action) switch (action.type) { case FAIL: return { - ...state, + ...state.ui, active_ui: ERROR_UI } case BASE_CONFIG_CHECKED: if (action.base_config_done) { return { base_config_done: true, - active_ui: advanced_config_ui(state.active_ui, action), + active_ui: advanced_config_ui(state, action), } } else { return { base_config_done: false, - active_ui: base_config_ui(state.active_ui, action), + active_ui: base_config_ui(state, action), } } default: - const newstate = { ...state }; - if ('base_config_done' in state) { - if (state.base_config_done) { - newstate.active_ui = advanced_ui(state.active_ui, action); + const newstate = { ...state.ui }; + if ('base_config_done' in state.ui) { + if (state.ui.base_config_done) { + newstate.active_ui = advanced_ui(state, action); } else { - newstate.active_ui = base_config_ui(state.active_ui, action); + newstate.active_ui = base_config_ui(state, action); } } return newstate; diff --git a/synapse_topology/view/webui/js/reducers/ui_constants.js b/synapse_topology/view/webui/js/reducers/ui_constants.js
index 8515329765..d6bc565893 100644 --- a/synapse_topology/view/webui/js/reducers/ui_constants.js +++ b/synapse_topology/view/webui/js/reducers/ui_constants.js
@@ -13,6 +13,8 @@ export const TLS_CERTPATH_UI = "tls_certpath_ui"; export const REVERSE_PROXY_UI = "reverse_proxy_ui"; export const PORT_SELECTION_UI = "port_selection_ui"; export const REVERSE_PROXY_TEMPLATE_UI = "reverse_proxy_tamplate_ui"; +export const DELEGATION_TEMPLATE_UI = "delegation_tamplate_ui"; +export const DATABASE_UI = "database_ui"; // Advanced Config export const CONFIG_SELECTION_UI = "config_selection_ui"; diff --git a/synapse_topology/view/webui/js/templates/apache.js b/synapse_topology/view/webui/js/templates/apache.js
index cd7f7797f3..1c9a489fe3 100644 --- a/synapse_topology/view/webui/js/templates/apache.js +++ b/synapse_topology/view/webui/js/templates/apache.js
@@ -1,4 +1,4 @@ -export default config = ({ +export default ({ delegationFedPort, delegationClientPort, fedPort, diff --git a/synapse_topology/view/webui/js/templates/caddy.js b/synapse_topology/view/webui/js/templates/caddy.js
index b2702b2030..d073358811 100644 --- a/synapse_topology/view/webui/js/templates/caddy.js +++ b/synapse_topology/view/webui/js/templates/caddy.js
@@ -1,11 +1,10 @@ -export default config = ({ +export default ({ delegationFedPort, delegationClientPort, fedPort, clientPort, synapseServerName, -}) => ` -${synapseServerName}:${delegationClientPort} { +}) => `${synapseServerName}:${delegationClientPort} { proxy /_matrix http://localhost:${clientPort} { transparent } @@ -15,5 +14,4 @@ ${synapseServerName}:${delegationFedPort} { proxy / http://localhost:${fedPort} { transparent } -} -` \ No newline at end of file +}` \ No newline at end of file diff --git a/synapse_topology/view/webui/js/templates/client-well-known.js b/synapse_topology/view/webui/js/templates/client-well-known.js
index 053acadc35..2919695eab 100644 --- a/synapse_topology/view/webui/js/templates/client-well-known.js +++ b/synapse_topology/view/webui/js/templates/client-well-known.js
@@ -1,13 +1,11 @@ -export default config = ({ +export default ({ synapseServerName, delegationClientPort, -}) => ` -{ +}) => `{ "m.homeserver": { "base_url": "https://${synapseServerName}${delegationClientPort ? `:${delegationClientPort}` : ""}" }, -} -` +}` // TODO: Maybe include this? // "m.identity_server": { // "base_url": "https://identity.example.com" diff --git a/synapse_topology/view/webui/js/templates/dns-srv.js b/synapse_topology/view/webui/js/templates/dns-srv.js
index 2b4defd739..40826d6eb0 100644 --- a/synapse_topology/view/webui/js/templates/dns-srv.js +++ b/synapse_topology/view/webui/js/templates/dns-srv.js
@@ -1,10 +1,8 @@ -export default config = ({ +export default ({ delegationFedPort, delegationClientPort, fedPort, clientPort, serverName, synapseServerName, -}) => ` -_matrix._tcp.${serverName} 3600 IN SRV 10 5 ${delegationClientPort} ${synapseServerName} -` \ No newline at end of file +}) => `_matrix._tcp.${serverName} 3600 IN SRV 10 5 ${delegationClientPort} ${synapseServerName}` \ No newline at end of file diff --git a/synapse_topology/view/webui/js/templates/federation-well-known.js b/synapse_topology/view/webui/js/templates/federation-well-known.js
index 63f559f2a2..39c9f15c0a 100644 --- a/synapse_topology/view/webui/js/templates/federation-well-known.js +++ b/synapse_topology/view/webui/js/templates/federation-well-known.js
@@ -1,8 +1,6 @@ -export const config = ( +export default ({ synapseServerName, delegationSynapsePort, -) => ` -{ +}) => `{ "m.server": "${synapseServerName}:${delegationSynapsePort}" -} -` \ No newline at end of file +}` \ No newline at end of file diff --git a/synapse_topology/view/webui/js/templates/haproxy.js b/synapse_topology/view/webui/js/templates/haproxy.js
index 78b21a29a8..25b9cf1734 100644 --- a/synapse_topology/view/webui/js/templates/haproxy.js +++ b/synapse_topology/view/webui/js/templates/haproxy.js
@@ -1,4 +1,4 @@ -export default config = ({ +export default ({ delegationFedPort, delegationClientPort, fedPort, @@ -6,8 +6,7 @@ export default config = ({ synapseServerName, }) => { if (fedPort == clientPort) { - return ` -frontend https + return `frontend https bind :::${delegationClientPort} v4v6 ssl crt /etc/ssl/haproxy/ strict-sni alpn h2,http/1.1 # Matrix client traffic @@ -24,8 +23,7 @@ backend matrix server matrix 127.0.0.1:${fedPort} ` } else { - return ` -frontend https + return `frontend https bind:::${delegationClientPort} v4v6 ssl crt /etc/ssl/haproxy/ strict-sni alpn h2, http / 1.1 # Matrix client traffic @@ -41,7 +39,6 @@ default_backend matrix backend matrix server matrix 127.0.0.1:${fedPort} -backend matrix-client 127.0.0.1:${clientPort} -` +backend matrix-client 127.0.0.1:${clientPort}` } } \ No newline at end of file diff --git a/synapse_topology/view/webui/js/templates/nginx.js b/synapse_topology/view/webui/js/templates/nginx.js
index 31e5f7e89a..294f47baf7 100644 --- a/synapse_topology/view/webui/js/templates/nginx.js +++ b/synapse_topology/view/webui/js/templates/nginx.js
@@ -1,29 +1,27 @@ -export default config = ({ +import React from 'react'; +export default ({ delegationFedPort, delegationClientPort, fedPort, clientPort, synapseServerName, -}) => ` -server { - listen ${delegationClientPort} ssl; - listen [::]:${delegationClientPort} ssl; - server_name ${synapseServerName}; +}) => `listen {delegationClientPort} ssl; +listen [::]:${delegationClientPort} ssl; +server_name ${synapseServerName}; - location /_matrix { - proxy_pass http://localhost:${clientPort}; - proxy_set_header X-Forwarded-For $remote_addr; - } + location /_matrix { + proxy_pass http://localhost:${clientPort}; + proxy_set_header X-Forwarded-For $remote_addr; + } } server { - listen ${delegationFedPort} ssl default_server; - listen [::]:${delegationFedPort} ssl default_server; - server_name example.com; + listen ${delegationFedPort} ssl default_server; + listen [::]:${delegationFedPort} ssl default_server; + server_name ${synapseServerName}; - location / { - proxy_pass http://localhost:${fedPort}; - proxy_set_header X-Forwarded-For $remote_addr; - } -} -` \ No newline at end of file + location / { + proxy_pass http://localhost:${fedPort}; + proxy_set_header X-Forwarded-For $remote_addr; + } +}` \ No newline at end of file diff --git a/synapse_topology/view/webui/js/utils/yaml.js b/synapse_topology/view/webui/js/utils/yaml.js new file mode 100644
index 0000000000..c95f2683a2 --- /dev/null +++ b/synapse_topology/view/webui/js/utils/yaml.js
@@ -0,0 +1,64 @@ +import yaml from 'yaml'; +import { TLS_TYPES } from '../actions/constants'; + +const listeners = conf => { + const listeners = []; + if (conf.tls == TLS_TYPES.TLS) { + listeners.append({ + port: conf.synapse_federation_port, + tls: true, + bind_addresses: ['::1', '127.0.0.1'], + type: "http", + x_forwarded: true, + + resources: [{ + names: ["federation"], + compress: false, + }], + }); + } else { + listeners.append({ + port: conf.synapse_federation_port, + tls: true, + type: "http", + + resources: [{ + names: ["federation"], + }], + }); + } + + if (conf.synapse_client_port == conf.synapse_federation_port) { + listeners[0].resources[0].names.append("client"); + } else if (conf.tls == TLS_TYPES.TLS) { + listeners.append({ + port: conf.synapse_client_port, + tls: true, + bind_addresses: ['::1', '127.0.0.1'], + type: "http", + x_forwarded: true, + + resources: [{ + names: ["client"], + compress: false, + }], + }); + } else { + listeners.append({ + port: conf.synapse_client_port, + tls: true, + type: "http", + + resources: [{ + names: ["client"], + }], + }); + } + return listeners; +} + +const base_config_to_yaml = conf => ({ + server_name: conf.servername, + listeners: listeners(conf), + +}) \ No newline at end of file