mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-11-27 09:18:58 +03:00
Merge pull request #187 in DNS/adguard-dns from fix/655 to master
* commit '0c973334be33c77e509676d65394d99ead4b26e2': * client: if 0.0.0.0 is selected, then redirect to the current IP
This commit is contained in:
commit
d6b83d4a63
6 changed files with 40 additions and 14 deletions
|
@ -155,3 +155,5 @@ export const UNSAFE_PORTS = [
|
|||
6668,
|
||||
6669,
|
||||
];
|
||||
|
||||
export const ALL_INTERFACES_IP = '0.0.0.0';
|
||||
|
|
|
@ -2,12 +2,13 @@ import React from 'react';
|
|||
import PropTypes from 'prop-types';
|
||||
|
||||
import { getIpList, getDnsAddress, getWebAddress } from '../../helpers/helpers';
|
||||
import { ALL_INTERFACES_IP } from '../../helpers/constants';
|
||||
|
||||
const AddressList = (props) => {
|
||||
let webAddress = getWebAddress(props.address, props.port);
|
||||
let dnsAddress = getDnsAddress(props.address, props.port);
|
||||
|
||||
if (props.address === '0.0.0.0') {
|
||||
if (props.address === ALL_INTERFACES_IP) {
|
||||
return getIpList(props.interfaces).map((ip) => {
|
||||
webAddress = getWebAddress(ip, props.port);
|
||||
dnsAddress = getDnsAddress(ip, props.port);
|
||||
|
|
|
@ -25,13 +25,22 @@ class Controls extends Component {
|
|||
}
|
||||
|
||||
renderNextButton(step) {
|
||||
const {
|
||||
nextStep,
|
||||
invalid,
|
||||
pristine,
|
||||
install,
|
||||
ip,
|
||||
port,
|
||||
} = this.props;
|
||||
|
||||
switch (step) {
|
||||
case 1:
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-success btn-lg setup__button"
|
||||
onClick={this.props.nextStep}
|
||||
onClick={nextStep}
|
||||
>
|
||||
<Trans>get_started</Trans>
|
||||
</button>
|
||||
|
@ -43,9 +52,9 @@ class Controls extends Component {
|
|||
type="submit"
|
||||
className="btn btn-success btn-lg setup__button"
|
||||
disabled={
|
||||
this.props.invalid
|
||||
|| this.props.pristine
|
||||
|| this.props.install.processingSubmit
|
||||
invalid
|
||||
|| pristine
|
||||
|| install.processingSubmit
|
||||
}
|
||||
>
|
||||
<Trans>next</Trans>
|
||||
|
@ -56,7 +65,7 @@ class Controls extends Component {
|
|||
<button
|
||||
type="button"
|
||||
className="btn btn-success btn-lg setup__button"
|
||||
onClick={this.props.nextStep}
|
||||
onClick={nextStep}
|
||||
>
|
||||
<Trans>next</Trans>
|
||||
</button>
|
||||
|
@ -66,7 +75,8 @@ class Controls extends Component {
|
|||
<button
|
||||
type="button"
|
||||
className="btn btn-success btn-lg setup__button"
|
||||
onClick={() => this.props.openDashboard(this.props.address)}
|
||||
onClick={() =>
|
||||
this.props.openDashboard(ip, port)}
|
||||
>
|
||||
<Trans>open_dashboard</Trans>
|
||||
</button>
|
||||
|
@ -98,7 +108,8 @@ Controls.propTypes = {
|
|||
submitting: PropTypes.bool,
|
||||
invalid: PropTypes.bool,
|
||||
pristine: PropTypes.bool,
|
||||
address: PropTypes.string,
|
||||
ip: PropTypes.string,
|
||||
port: PropTypes.number,
|
||||
};
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
|
|
|
@ -9,6 +9,7 @@ import Controls from './Controls';
|
|||
import AddressList from './AddressList';
|
||||
import renderField from './renderField';
|
||||
import { getInterfaceIp } from '../../helpers/helpers';
|
||||
import { ALL_INTERFACES_IP } from '../../helpers/constants';
|
||||
|
||||
const required = (value) => {
|
||||
if (value || value === 0) {
|
||||
|
@ -75,7 +76,7 @@ let Settings = (props) => {
|
|||
component="select"
|
||||
className="form-control custom-select"
|
||||
>
|
||||
<option value="0.0.0.0">
|
||||
<option value={ALL_INTERFACES_IP}>
|
||||
<Trans>install_settings_all_interfaces</Trans>
|
||||
</option>
|
||||
{renderInterfaces(interfaces)}
|
||||
|
@ -130,7 +131,7 @@ let Settings = (props) => {
|
|||
component="select"
|
||||
className="form-control custom-select"
|
||||
>
|
||||
<option value="0.0.0.0">
|
||||
<option value={ALL_INTERFACES_IP}>
|
||||
<Trans>install_settings_all_interfaces</Trans>
|
||||
</option>
|
||||
{renderInterfaces(interfaces)}
|
||||
|
|
|
@ -6,7 +6,6 @@ import { Trans, withNamespaces } from 'react-i18next';
|
|||
import flow from 'lodash/flow';
|
||||
|
||||
import Controls from './Controls';
|
||||
import { getWebAddress } from '../../helpers/helpers';
|
||||
|
||||
let Submit = props => (
|
||||
<div className="setup__step">
|
||||
|
@ -20,7 +19,8 @@ let Submit = props => (
|
|||
</div>
|
||||
<Controls
|
||||
openDashboard={props.openDashboard}
|
||||
address={getWebAddress(props.webIp, props.webPort)}
|
||||
ip={props.webIp}
|
||||
port={props.webPort}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
|
|
@ -3,7 +3,12 @@ import { connect } from 'react-redux';
|
|||
import PropTypes from 'prop-types';
|
||||
|
||||
import * as actionCreators from '../../actions/install';
|
||||
import { INSTALL_FIRST_STEP, INSTALL_TOTAL_STEPS } from '../../helpers/constants';
|
||||
import { getWebAddress } from '../../helpers/helpers';
|
||||
import {
|
||||
INSTALL_FIRST_STEP,
|
||||
INSTALL_TOTAL_STEPS,
|
||||
ALL_INTERFACES_IP,
|
||||
} from '../../helpers/constants';
|
||||
|
||||
import Loading from '../../components/ui/Loading';
|
||||
import Greeting from './Greeting';
|
||||
|
@ -29,7 +34,13 @@ class Setup extends Component {
|
|||
this.props.setAllSettings(values);
|
||||
};
|
||||
|
||||
openDashboard = (address) => {
|
||||
openDashboard = (ip, port) => {
|
||||
let address = getWebAddress(ip, port);
|
||||
|
||||
if (ip === ALL_INTERFACES_IP) {
|
||||
address = getWebAddress(window.location.hostname, port);
|
||||
}
|
||||
|
||||
window.location.replace(address);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue