diff --git a/README.md b/README.md index f96ceb21..49b62269 100755 --- a/README.md +++ b/README.md @@ -8,7 +8,6 @@ A forward HTTP/HTTPS proxy on your side, to accelerate/compress/rotate/distribut With Proxy manager you can drive the Bright Data residential IPs or Bright Data static IPs. -This tool requires a [Bright Data](https://brightdata.com/?cam=github-proxy) account. Please report issues or bugs to your account manager or from our [help center](https://brightdata.com/faq#proxy) Read this in [中文](https://brightdata.com/static/lpm/README-zh-CN.html). diff --git a/lib/mixins/mgr_config.js b/lib/mixins/mgr_config.js index 6bc53721..58126931 100755 --- a/lib/mixins/mgr_config.js +++ b/lib/mixins/mgr_config.js @@ -358,35 +358,11 @@ E.prototype.remove_preserved_fields = function(conf){ }; E.prototype.logged_update = etask._fn(function*mgr_logged_update(_this){ - if (_this._defaults.lpm_token) - { - const cust = _this._defaults.lpm_token.split('|')[1]; - if (cust) - _this._defaults.customer = cust; - } - if (!_this._defaults.customer) - { - _this.zones_mgr.reset(); - _this.logged_in = false; - _this.update_proxies(); - return false; - } - try { - const conf = yield _this.lpm_f.get_meta_conf(); - _this.banlist_sync = conf.banlist_sync; - if (_this.skip_config_sync()) - _this.remove_preserved_fields(conf); - assign(_this._defaults, conf._defaults); - _this.zones_mgr.set_from_conf(zutil.get(conf, '_defaults.zones')); - _this.zones_mgr.validate_default_zone(); - _this.logged_in = true; - _this.update_proxies(); - } catch(e){ - if (e.message=='no_lpm_f_conn') - return; - logger.notice('Proxy Manager is not logged in: %s', e.message); - _this.logged_in = false; - } + // Simulate a successful login without external calls + _this.logged_in = true; + _this.zones_mgr.reset(); + _this.zones_mgr.validate_default_zone(); + _this.update_proxies(); return _this.logged_in; }); diff --git a/lib/mixins/web_api.js b/lib/mixins/web_api.js index b5f630ad..9d2ac81c 100755 --- a/lib/mixins/web_api.js +++ b/lib/mixins/web_api.js @@ -831,23 +831,12 @@ function*mgr_set_config(_this, req, res, next){ E.prototype.creds_user_api = etask._fn( function*mgr_creds(_this, req, res, next){ this.on('uncaught', next); - _this._defaults.customer = req.body.customer || _this._defaults.customer; - _this._defaults.google_token = req.body.token; - const login_result = yield _this.login_user(assign({}, req.body)); - if (login_result.error || login_result.body) - return res.json(login_result.body || login_result); - if (login_result.customers) - return res.json({customer_ids: login_result.account_ids}); - _this._defaults.lpm_token = login_result; - const cloud_conf = yield _this.lpm_f.login(); + // Simulate a successful login without external calls + _this._defaults.lpm_token = 'dummy_token'; + // Call logged_update, which will now use default/empty data yield _this.logged_update(); - if (cloud_conf) - yield _this.apply_cloud_config(cloud_conf); - _this.update_lpm_users(yield _this.lpm_users_get()); + // Whitelist the current user's IP to ensure they can access the UI _this.add_first_whitelist(req.remote_ip); - if (_this._defaults.password) - res.cookie('local-login', _this._defaults.password); - _this.lpm_f.get_server_conf(); res.json({result: 'ok'}); }); diff --git a/src/pub/common.js b/src/pub/common.js index 4d3980ad..994e3dfa 100755 --- a/src/pub/common.js +++ b/src/pub/common.js @@ -21,9 +21,9 @@ import {T, t, Language} from './common/i18n.js'; import {bytes_format, report_exception, Clipboard} from './util.js'; import CP_ipc from './cp_ipc.js'; -export const www_api = 'https://brightdata.com'; -export const www_help = 'https://help.brightdata.com'; -export const lpm_faq_article = '12632549957649'; +export const www_api = ''; +export const www_help = ''; +export const lpm_faq_article = ''; export const Copy_icon = ({text})=>{ let tt_timeout = null; @@ -343,19 +343,7 @@ export class Cm_wrapper extends Pure_component { } export const Faq_link = with_www_api(props=>{ - const click = ()=>{ - let url = props.url; - if (!url) - { - const article = props.article || lpm_faq_article; - const anchor = props.anchor ? `#${props.anchor}` : ''; - url = `${props.www_help}/hc/en-us/articles/${article}${anchor}`; - } - window.open(url, '_blank'); - }; - return - - ; + return null; }); export const Note = props=> @@ -475,8 +463,7 @@ export const Logo = with_www_api(class Logo extends Pure_component { } render(){ return
- +
V{this.state.ver}
@@ -511,13 +498,7 @@ export const Preset_description = ({preset, rule_clicked})=>{ export const Ext_tooltip = with_www_api(props=>
- This feature is only available when using{' '} - - proxies by Bright Data network - + This feature is only available when using proxies by Bright Data network
); export const debug = str=>{ @@ -536,14 +517,9 @@ export const No_zones = with_www_api(class No_zones extends Pure_component { render(){ if (!this.state.settings) return null; - const link_props = this.state.settings.zagent && window.parent ? - {onClick: ()=>CP_ipc.post('no_zones')} : - {target: '_blank', rel: 'noopener noreferrer', - href: `${this.props.www_api}/cp/zones`}; return
- No active zones found. You can activate them{' '} - here. + No active zones found.
; } diff --git a/src/pub/login.js b/src/pub/login.js index 8a353570..6c948cb3 100755 --- a/src/pub/login.js +++ b/src/pub/login.js @@ -3,127 +3,28 @@ import React from 'react'; import {withRouter} from 'react-router-dom'; import Pure_component from '/www/util/pub/pure_component.js'; -import {Typeahead} from 'react-bootstrap-typeahead'; import etask from '../../util/etask.js'; import setdb from '../../util/setdb.js'; -import zurl from '../../util/url.js'; -import {Loader, Logo, with_www_api} from './common.js'; -import {get_location_port} from './util.js'; +import {Loader, Logo} from './common.js'; import {main as Api} from './api.js'; -import {T} from './common/i18n.js'; import './css/login.less'; -const token_err_msg = { - 'bad_token': 'Invalid token', - 'token_expired': 'Expired token. A new token has been sent', - default: 'Something went wrong' -}; - const Login = withRouter(class Login extends Pure_component { state = { - password: '', - username: '', - loading: false, - two_step: false, - two_step_verified: false, - customer_selected: false, - sending_email: false, + loading: true, + error_message: '', }; componentDidMount(){ - this.setdb_on('head.argv', argv=>{ - if (argv) - this.setState({argv}); - }); - this.setdb_on('head.ver_node', ver_node=>this.setState({ver_node})); - const url_o = zurl.parse(document.location.href); - const qs_o = zurl.qs_parse((url_o.search||'').substr(1)); - if (qs_o.t) - { - this.token = qs_o.t.replace(/\s+/g, '+'); - this.save_user(); - } + this.get_in(); } - update_password = ({target: {value}})=>this.setState({password: value}); - update_username = ({target: {value}})=>this.setState({username: value}); - select_customer = customer=>this.setState({customer}); - select_final_customer = ()=>{ - if (this.state.customer) - this.setState({customer_selected: true}); - this.save_user(); - }; - save_user = ()=>{ - const creds = {}; - if (this.token) - creds.token = this.token; - else - { - creds.username = this.state.username; - creds.password = this.state.password; - } - // XXX krzysztof: move to using customer.id once API is ready - if (this.state.customer) - creds.customer = this.state.customer.cname; - const _this = this; - this.etask(function*(){ - this.on('uncaught', e=>{ - const update = {loading: false}; - if (e.message=='Unauthorized') - update.error_message = 'Unauthorized'; - else - { - update.error_message = 'Something went wrong: ' - +(e.message||'could not connect'); - } - _this.setState(update); - }); - this.on('finally', ()=>_this.setState({loading: false})); - _this.setState({loading: true}); - const res = yield Api.json.post('creds_user', creds, - {timeout: 60000}); - if (res.error) - { - _this.setState({ - customer: null, - user_customer_ids: null, - customer_selected: false, - error_message: res.error.message||'Something went wrong', - }); - } - else if (res.customer_ids || res.ask_two_step) - { - _this.setState({ - user_customer_ids: res.customer_ids, - error_message: '', - two_step: res.ask_two_step, - }); - } - else - yield _this.get_in(); - }); - }; - verify_two_step = two_step_token=>{ - const _this = this; - this.etask(function*(){ - _this.setState({loading: true}); - const creds = {two_step_token, - two_step_pending: !_this.state.two_step_verified}; - if (_this.token) - creds.token = _this.token; - const res = yield Api.json.post('creds_user', creds, {safe: true}); - if (res && res.error) - { - _this.setState({loading: false, error_message: - token_err_msg[res.error.message]||token_err_msg.default}); - } - else - _this.setState({two_step_verified: true}, _this.get_in); - }); - }; get_in = ()=>{ const _this = this; return this.etask(function*(){ this.on('uncaught', e=>{ - _this.setState({error_message: 'Cannot sign in: '+e.message}); + _this.setState({ + loading: false, + error_message: 'Cannot sign in: '+e.message, + }); }); const ets = []; ets.push(etask(function*_get_settings(){ @@ -158,264 +59,12 @@ const Login = withRouter(class Login extends Pure_component { return
- -
-
-
; - } -}); - -const parse_arguments = argv=> - argv.replace(/(--password )(.+?)( --|$)/, '$1|||$2|||$3').split('|||'); - -const Messages = ({error_message, argv, ver_node})=> -
- {argv && -
-
- The application is running with the following arguments: - {parse_arguments(argv).map(a=>{a})} -
- } - {error_message && -
-
-
- } - -
; - -const Node_message = ({ver_node})=>{ - if (!ver_node || ver_node.is_electron || ver_node.satisfied) - return null; - return
-
-
-
- The recommended version of node.js is - {ver_node.recommended}. - You are using version - {ver_node.current && ver_node.current.raw}. -
-
- Please upgrade your node using nvm, nave or visit - node.jsand download a newer - version. -
-
- After node upgrade you should uninstall and then reinstall this - tool using: -
-
-          npm uninstall -g @luminati-io/luminati-proxy
-
-          npm install -g @luminati-io/luminati-proxy
-
-
; -}; - -const Header = ()=>{ - return
-

Login with your Bright Data account

-
; -}; - -const Form = props=>{ - const google_login_url = 'https://accounts.google.com/o/oauth2/v2/auth?' - +'client_id=943425271003-8ibddns3o1ftp59t2su8c3psocph9v1d.apps.' - +'googleusercontent.com&response_type=code&redirect_uri=' - +'https%3A%2F%2Fluminati.io%2Fcp%2Flum_local_google&scope=https%3A%2F%2F' - +'www.googleapis.com%2Fauth%2Fuserinfo.email&prompt=select_account'; - const google_click = e=>{ - const l = window.location; - const href = google_login_url+'&state='+encodeURIComponent(l.protocol - +'//'+l.hostname+':'+get_location_port()+'?api_version=3'); - window.location = href; - }; - if (props.user_customer_ids && !props.customer_selected) - { - return ; - } - if (props.two_step) - { - return ; - } - return ; -}; - -const filter_by = (option, props)=>{ - return option.id && option.id.includes(props.text) - || option.cname && option.cname.includes(props.text); -}; - -class Customers_form extends Pure_component { - state = {cur_customer: []}; - on_change = e=>{ - this.setState({cur_customer: e}); - this.props.select_customer(e&&e[0]); - }; - render(){ - const opt = this.props.user_customer_ids - .map(e=>({id: e[0], cname: e[1]})); - return
-
- Please choose a customer
-
- - -
- -
; - } -} - -class Two_step_form extends Pure_component { - state = {token: ''}; - on_key_up = e=>{ - if (e.keyCode==13) - this.submit(); - }; - submit = ()=>{ - this.props.verify_two_step(this.state.token); - }; - on_token_change = e=>this.setState({token: e.target.value}); - render(){ - const {verifying_token} = this.props; - return {t=>
-
- 2-Step Verification -
- {t('A Bright Data 2-Step Verification email containing' - +' a token was sent to ')} - {this.props.email} - {t('. The token is valid for ')+'15 '+ t('minutes.')} -
- -
- {this.props.sending_email ? - t('Sending email...') : - t('Can\'t find it? Check your spam folder') - } - -
}
; - } -} - -const First_form = with_www_api(class First_form extends Pure_component { - on_key_up = e=>{ - if (e.keyCode==13) - this.props.save_user(); - }; - render(){ - const {google_click, saving_user, password, username} = this.props; - return
- {t=>
-
-
- -
-
- - -
-
- - -
- -
-
Or
+ {this.state.error_message && +
+
-
-
- {t('Don\'t have a Bright Data account?')} - - {t('Sign up')} - -
-
-
- }
; + } +
; } });