mirror of
https://github.com/anticensority/runet-censorship-bypass.git
synced 2024-11-23 18:03:44 +03:00
Move proxy scheme parsing to utils
This commit is contained in:
parent
bc439c22f7
commit
9495910261
|
@ -196,6 +196,40 @@
|
|||
|
||||
},
|
||||
|
||||
parseProxyScheme(proxyAsStringRaw) {
|
||||
|
||||
const proxyAsString = proxyAsStringRaw.trim();
|
||||
const [type] = proxyAsString.split(/\s+/);
|
||||
/*
|
||||
if (!/^[a-zA-Z0-9]+$/.test(type)) {
|
||||
throw new Error(`${type} is not a proxy type!`);
|
||||
}
|
||||
JS has no code blocks in RE, seems safe to omit this check.
|
||||
*/
|
||||
const typeRe = new RegExp(`^${type}\\s+`, 'g');
|
||||
const crededAddr = proxyAsString.replace(typeRe, '');
|
||||
|
||||
let parts;
|
||||
parts = crededAddr.split('@');
|
||||
let [creds, addr] = [parts.slice(0, -1).join('@'), parts[parts.length - 1]];
|
||||
|
||||
const [hostname, port] = addr.split(':');
|
||||
|
||||
parts = creds.split(':')
|
||||
const username = parts[0];
|
||||
const password = parts.slice(1).join(':');
|
||||
|
||||
return {
|
||||
type,
|
||||
username,
|
||||
password,
|
||||
hostname,
|
||||
port,
|
||||
creds,
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
const max = 2**16;
|
||||
|
|
|
@ -240,6 +240,9 @@
|
|||
customProxyArray.push(...self.torPoints);
|
||||
}
|
||||
|
||||
// Hanlde protected proxies in customProxyArray.
|
||||
// TODO:
|
||||
|
||||
self.filteredCustomsString = '';
|
||||
if (customProxyArray.length) {
|
||||
self.customProxyArray = customProxyArray;
|
||||
|
|
|
@ -331,21 +331,14 @@ export default function getProxyEditor(theState) {
|
|||
splitBySemi(this.props.proxyStringRaw).map((proxyAsStringRaw, index) => {
|
||||
|
||||
const proxyAsString = proxyAsStringRaw.trim();
|
||||
const [type] = proxyAsString.split(/\s+/);
|
||||
/*
|
||||
if (!/^[a-zA-Z0-9]+$/.test(type)) {
|
||||
throw new Error(`${type} is not a proxy type!`);
|
||||
}
|
||||
JS has no code blocks in RE, seems safe to omit this check.
|
||||
*/
|
||||
const typeRe = new RegExp(`^${type}\s+`, 'g');
|
||||
const crededAddr = proxyAsString.replace(typeRe, '');
|
||||
|
||||
let parts;
|
||||
parts = crededAddr.split('@');
|
||||
let [creds, addr] = [parts.slice(0, -1).join('@'), parts[parts.length - 1]];
|
||||
const {
|
||||
type,
|
||||
creds,
|
||||
hostname,
|
||||
port,
|
||||
} = theState.utils.parseProxyScheme(proxyAsString);
|
||||
|
||||
const [hostname, port] = addr.split(':');
|
||||
return (
|
||||
<tr class={scopedCss.proxyRow}>
|
||||
<td>
|
||||
|
|
Loading…
Reference in New Issue
Block a user