Check if redirect available
This commit is contained in:
parent
e873149bee
commit
340a4fb58e
|
@ -199,11 +199,19 @@ let Form = (props) => {
|
||||||
: <Trans>encryption_chain_invalid</Trans>
|
: <Trans>encryption_chain_invalid</Trans>
|
||||||
}
|
}
|
||||||
</li>
|
</li>
|
||||||
|
{valid_cert &&
|
||||||
|
<Fragment>
|
||||||
{subject &&
|
{subject &&
|
||||||
<li><Trans>encryption_subject</Trans>: {subject}</li>
|
<li>
|
||||||
|
<Trans>encryption_subject</Trans>:
|
||||||
|
{subject}
|
||||||
|
</li>
|
||||||
}
|
}
|
||||||
{issuer &&
|
{issuer &&
|
||||||
<li><Trans>encryption_issuer</Trans>: {issuer}</li>
|
<li>
|
||||||
|
<Trans>encryption_issuer</Trans>:
|
||||||
|
{issuer}
|
||||||
|
</li>
|
||||||
}
|
}
|
||||||
{not_after && not_after !== EMPTY_DATE &&
|
{not_after && not_after !== EMPTY_DATE &&
|
||||||
<li>
|
<li>
|
||||||
|
@ -213,9 +221,12 @@ let Form = (props) => {
|
||||||
}
|
}
|
||||||
{dns_names &&
|
{dns_names &&
|
||||||
<li>
|
<li>
|
||||||
<Trans>encryption_hostnames</Trans>: {dns_names}
|
<Trans>encryption_hostnames</Trans>:
|
||||||
|
{dns_names}
|
||||||
</li>
|
</li>
|
||||||
}
|
}
|
||||||
|
</Fragment>
|
||||||
|
}
|
||||||
</ul>
|
</ul>
|
||||||
</Fragment>
|
</Fragment>
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
|
||||||
import { withNamespaces } from 'react-i18next';
|
import { withNamespaces } from 'react-i18next';
|
||||||
import debounce from 'lodash/debounce';
|
import debounce from 'lodash/debounce';
|
||||||
|
|
||||||
|
import { DEBOUNCE_TIMEOUT } from '../../../helpers/constants';
|
||||||
import Form from './Form';
|
import Form from './Form';
|
||||||
import Card from '../../ui/Card';
|
import Card from '../../ui/Card';
|
||||||
|
|
||||||
|
@ -13,7 +14,7 @@ class Encryption extends Component {
|
||||||
|
|
||||||
handleFormChange = debounce((values) => {
|
handleFormChange = debounce((values) => {
|
||||||
this.props.validateTlsConfig(values);
|
this.props.validateTlsConfig(values);
|
||||||
}, 300);
|
}, DEBOUNCE_TIMEOUT);
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { encryption, t } = this.props;
|
const { encryption, t } = this.props;
|
||||||
|
|
|
@ -73,8 +73,13 @@ export const SETTINGS_NAMES = {
|
||||||
|
|
||||||
export const STANDARD_DNS_PORT = 53;
|
export const STANDARD_DNS_PORT = 53;
|
||||||
export const STANDARD_WEB_PORT = 80;
|
export const STANDARD_WEB_PORT = 80;
|
||||||
|
|
||||||
export const EMPTY_DATE = '0001-01-01T00:00:00Z';
|
export const EMPTY_DATE = '0001-01-01T00:00:00Z';
|
||||||
|
|
||||||
|
export const DEBOUNCE_TIMEOUT = 300;
|
||||||
|
export const CHECK_TIMEOUT = 1000;
|
||||||
|
export const STOP_TIMEOUT = 10000;
|
||||||
|
|
||||||
export const UNSAFE_PORTS = [
|
export const UNSAFE_PORTS = [
|
||||||
1,
|
1,
|
||||||
7,
|
7,
|
||||||
|
|
|
@ -4,7 +4,13 @@ import subHours from 'date-fns/sub_hours';
|
||||||
import addHours from 'date-fns/add_hours';
|
import addHours from 'date-fns/add_hours';
|
||||||
import round from 'lodash/round';
|
import round from 'lodash/round';
|
||||||
|
|
||||||
import { STATS_NAMES, STANDARD_DNS_PORT, STANDARD_WEB_PORT } from './constants';
|
import {
|
||||||
|
STATS_NAMES,
|
||||||
|
STANDARD_DNS_PORT,
|
||||||
|
STANDARD_WEB_PORT,
|
||||||
|
CHECK_TIMEOUT,
|
||||||
|
STOP_TIMEOUT,
|
||||||
|
} from './constants';
|
||||||
|
|
||||||
export const formatTime = (time) => {
|
export const formatTime = (time) => {
|
||||||
const parsedTime = dateParse(time);
|
const parsedTime = dateParse(time);
|
||||||
|
@ -151,7 +157,19 @@ export const redirectToCurrentProtocol = (values) => {
|
||||||
if (protocol !== 'https:' && enabled && port_https) {
|
if (protocol !== 'https:' && enabled && port_https) {
|
||||||
window.location.replace(`https://${hostname}${httpsPort}/${hash}`);
|
window.location.replace(`https://${hostname}${httpsPort}/${hash}`);
|
||||||
} else if (protocol === 'https:' && enabled && port_https && port_https !== port) {
|
} else if (protocol === 'https:' && enabled && port_https && port_https !== port) {
|
||||||
|
// TODO
|
||||||
|
const redirectCheck = setInterval(() => {
|
||||||
|
fetch(`https://${hostname}${httpsPort}/${hash}`, { mode: 'no-cors' })
|
||||||
|
.then(() => {
|
||||||
|
clearInterval(redirectCheck);
|
||||||
window.location.replace(`https://${hostname}${httpsPort}/${hash}`);
|
window.location.replace(`https://${hostname}${httpsPort}/${hash}`);
|
||||||
|
})
|
||||||
|
.catch(() => false);
|
||||||
|
}, CHECK_TIMEOUT);
|
||||||
|
setTimeout(() => {
|
||||||
|
clearInterval(redirectCheck);
|
||||||
|
console.error('Redirect check stopped');
|
||||||
|
}, STOP_TIMEOUT);
|
||||||
} else if (protocol === 'https:' && (!enabled || !port_https)) {
|
} else if (protocol === 'https:' && (!enabled || !port_https)) {
|
||||||
window.location.replace(`http://${hostname}/${hash}`);
|
window.location.replace(`http://${hostname}/${hash}`);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue