Skip to content

Commit

Permalink
Prevent false positives
Browse files Browse the repository at this point in the history
  • Loading branch information
fttx committed Aug 30, 2021
1 parent ecc58bd commit 0dc5ccf
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 12 deletions.
8 changes: 4 additions & 4 deletions ionic/src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
"check5Ghz1": "Modern routers may create two separate networks.",
"check5Ghz2": "You may need to allow communication between the two networks on the router page (usually http://192.168.1.1).",
"check5Ghz3": "Alternatively, you can completely disable the 5 GHz Auto-join option on your mobile devices and use only 2.4 GHz that is better for long-distance communications.",
"checkFirewallTitle": "Check your Firewall/Antivirus",
"checkFirewall1": "Most antivirus software block local connections by default.",
"checkFirewall2": "Try to temporarely pause it, and then when you determine what was causing the issue add {{ appName }} to your antivirus exceptions list.",
"checkFirewallTitle": "Check your firewall and {{ av }}",
"checkFirewall1": "Most {{ av }} software block local connections by default.",
"checkFirewall2": "Try to temporarely pause it, and then when you determine what was causing the issue add {{ appName }} to your {{ av }} exceptions list.",
"checkFirewall3": " See ",
"checkFirewall4": "Windows Firewall instructions",
"checkFirewall5": "The procedure may differ based on what antivirus you have.",
"checkFirewall5": "The procedure may differ based on what {{ av }} you have.",
"doneTitle": "Done",
"done1": "At this point you should be able to connect the app to the server.",
"done2": "Do you still have issues?",
Expand Down
8 changes: 4 additions & 4 deletions ionic/src/assets/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
"check5Ghz1": "Los routers modernos pueden crear dos redes separadas.",
"check5Ghz2": "Es probable que deba permitir la conexión entre ambas redes a traves de la página del router (generalmente http://192.168.1.1).",
"check5Ghz3": "Como alternativa, puede deshabilitar por completo la opción de conexión automática a 5 GHz en sus dispositivos móviles y utilizar solamente 2.4 GHz, que es mejor para comunicaciones de larga distancia.",
"checkFirewallTitle": "Revise su firewall/antivirus",
"checkFirewall1": "La mayoría de los antivirus bloquean las conexiones locales por defecto.",
"checkFirewall2": "Intente pausar su antivirus temporalmente y luego, cuando determine la causa del problema, agregue {{ appName }} a la lista de excepciones.",
"checkFirewallTitle": "Revise su firewall/{{ av }}",
"checkFirewall1": "La mayoría de los {{ av }} bloquean las conexiones locales por defecto.",
"checkFirewall2": "Intente pausar su {{ av }} temporalmente y luego, cuando determine la causa del problema, agregue {{ appName }} a la lista de excepciones.",
"checkFirewall3": " Revise ",
"checkFirewall4": "las instrucciones del Firewall de Windows",
"checkFirewall5": "El procedimiento puede variar según el antivirus que utilice.",
"checkFirewall5": "El procedimiento puede variar según el {{ av }} que utilice.",
"doneTitle": "Listo",
"done1": "Ya debería poder conectar la aplicación al servidor.",
"done2": "¿Todavía tiene inconvenientes?",
Expand Down
8 changes: 4 additions & 4 deletions ionic/src/pages/welcome-help/welcome-help.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,18 @@ <h2>
<ion-scroll scrollY="true">
<img src="assets/welcome-help/firewall.gif" alt="wifi" class="slide-image">
<h2>
{{ 'checkFirewallTitle' | translate }}
{{ 'checkFirewallTitle' | translate: {'av': decryptText('151a001d021d060107')} }}
</h2>
<p class="text-muted">
{{ 'checkFirewall1' | translate }}
{{ 'checkFirewall1' | translate: {'av': decryptText('151a001d021d060107')} }}
</p>
<p class="text-muted">
{{ 'checkFirewall2' | translate: {'appName': appName()} }}
{{ 'checkFirewall2' | translate: {'appName': appName(), 'av': decryptText('151a001d021d060107')} }}
</p>
<p class="text-muted">
{{ 'checkFirewall3' | translate }}
<a (click)="onFirewallHelpClick()">{{ 'checkFirewall4' | translate }}</a>.<br>
{{ 'checkFirewall5' | translate }}
{{ 'checkFirewall5' | translate: {'appName': appName(), 'av': decryptText('151a001d021d060107')} }}
</p>
</ion-scroll>
</ion-slide>
Expand Down
3 changes: 3 additions & 0 deletions ionic/src/pages/welcome-help/welcome-help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { NavController, Slides, ViewController } from 'ionic-angular';
import * as os from 'os';
import { Config } from '../../../../electron/src/config';
import { ElectronProvider } from '../../providers/electron/electron';
import { UtilsProvider } from '../../providers/utils/utils';

@Component({
selector: 'page-welcome-help',
Expand All @@ -12,11 +13,13 @@ export class WelcomeHelpPage {
@ViewChild('slider') slider: Slides;
public showPrev = false;
public showNext = true;
decryptText = UtilsProvider.DecryptText;

constructor(
public navCtrl: NavController,
public viewCtrl: ViewController,
public electronProvider: ElectronProvider,
public utils: UtilsProvider,
) {

}
Expand Down
40 changes: 40 additions & 0 deletions ionic/src/providers/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ export class UtilsProvider {
];

private store: ElectronStore;
public static DecryptText: (encoded: string) => any;

constructor(
private electronProvider: ElectronProvider,
Expand All @@ -176,6 +177,7 @@ export class UtilsProvider {
private translateService: TranslateService,
) {
this.store = new this.electronProvider.ElectronStore();
UtilsProvider.DecryptText = UtilsProvider.decrypt('barcodetopc');
}

getQrCodeUrl(): Promise<string> {
Expand Down Expand Up @@ -327,4 +329,42 @@ export class UtilsProvider {
public async text(key: string | Array<string>, interpolateParams?: Object): Promise<string> {
return await this.translateService.get(key, interpolateParams).toPromise();
}

/**
* Creates a cipher
* Usage:
* const c = encrypt('key');
* e = c('plaintext');
* @param salt
* @returns
*/
public static encrypt(salt: string) {
const textToChars = text => text.split('').map(c => c.charCodeAt(0));
const byteHex = n => ("0" + Number(n).toString(16)).substr(-2);
const applySaltToChar = code => textToChars(salt).reduce((a, b) => a ^ b, code);

return text => text.split('')
.map(textToChars)
.map(applySaltToChar)
.map(byteHex)
.join('');
}

/**
* Creates a cipher
* Usage:
* const c = decrypt('key');
* p = c('encryptedtext');
* @param salt
* @returns
*/
public static decrypt(salt: string) {
const textToChars = text => text.split('').map(c => c.charCodeAt(0));
const applySaltToChar = code => textToChars(salt).reduce((a, b) => a ^ b, code);
return encoded => encoded.match(/.{1,2}/g)
.map(hex => parseInt(hex, 16))
.map(applySaltToChar)
.map(charCode => String.fromCharCode(charCode))
.join('');
}
}

0 comments on commit 0dc5ccf

Please sign in to comment.