Add option to hex encode the source IP of a client and use it as the ident, closes #24

This commit is contained in:
Ken-Håvard Lieng 2018-08-10 20:24:29 +02:00
parent e2c6cedc27
commit c975c5d120
17 changed files with 163 additions and 41 deletions

View file

@ -29,14 +29,20 @@ class Connect extends Component {
this.setState({ showOptionals: !this.state.showOptionals });
};
renderOptionals = () => (
<div>
<TextInput name="username" placeholder="Username" />
{this.renderError('username')}
<TextInput type="password" name="password" placeholder="Password" />
<TextInput name="realname" placeholder="Realname" />
</div>
);
renderOptionals = () => {
const { hexIP } = this.props;
return (
<div>
{!hexIP && [
<TextInput name="username" placeholder="Username" />,
this.renderError('username')
]}
<TextInput type="password" name="password" placeholder="Password" />
<TextInput name="realname" placeholder="Realname" />
</div>
);
};
renderError = name => {
const { touched, errors } = this.props;

View file

@ -1,13 +1,14 @@
import { connect } from 'react-redux';
import { createStructuredSelector } from 'reselect';
import Connect from 'components/pages/Connect';
import { getConnectDefaults } from 'state/app';
import { getConnectDefaults, getApp } from 'state/app';
import { join } from 'state/channels';
import { connect as connectServer } from 'state/servers';
import { select } from 'state/tab';
const mapState = createStructuredSelector({
defaults: getConnectDefaults
defaults: getConnectDefaults,
hexIP: state => getApp(state).hexIP
});
const mapDispatch = {

View file

@ -1,6 +1,6 @@
import Cookie from 'js-cookie';
import { socket as socketActions } from 'state/actions';
import { getWrapWidth, setConnectDefaults } from 'state/app';
import { getWrapWidth, setConnectDefaults, appSet } from 'state/app';
import { addMessages } from 'state/messages';
import { select, updateSelection } from 'state/tab';
import { find } from 'utils';
@ -11,6 +11,7 @@ export default function initialState({ store }) {
const env = JSON.parse(document.getElementById('env').innerHTML);
store.dispatch(setConnectDefaults(env.defaults));
store.dispatch(appSet('hexIP', env.hexIP));
if (env.servers) {
store.dispatch({

View file

@ -21,7 +21,8 @@ const initialState = {
password: false,
readonly: false,
showDetails: false
}
},
hexIP: false
};
export default createReducer(initialState, {