Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a netifc field in the UI for configuring the VPN server #1158

Merged
merged 2 commits into from
Apr 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@
{{ 'apps.vpn-socks-server-settings.passwords-not-match' | translate }}
</mat-error>
</mat-form-field>
<mat-form-field *ngIf="configuringVpn">
<input
id="netifc"
type="text"
formControlName="netifc"
[placeholder]="'apps.vpn-socks-server-settings.netifc' | translate"
matInput
>
</mat-form-field>
<div class="main-theme settings-option" *ngIf="configuringVpn">
<mat-checkbox
color="primary"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,27 +58,32 @@ export class SkysocksSettingsComponent implements OnInit, OnDestroy {
if (data.name.toLocaleLowerCase().indexOf('vpn') !== -1) {
this.configuringVpn = true;
}

// Get the current values saved on the visor, if returned by the API.
if (this.data.args && this.data.args.length > 0) {
for (const arg of this.data.args) {
if ((arg as string).toLowerCase().includes('-secure')) {
this.secureMode = (arg as string).toLowerCase().includes('true');
}
}
}
}

ngOnInit() {
this.form = this.formBuilder.group({
password: [''],
passwordConfirmation: ['', this.validatePasswords.bind(this)],
netifc: [''],
});

this.formSubscription = this.form.get('password').valueChanges.subscribe(() => {
this.form.get('passwordConfirmation').updateValueAndValidity();
});

// Get the current values saved on the visor, if returned by the API.
if (this.data.args && this.data.args.length > 0) {
for (let i = 0; i < this.data.args.length; i++) {
const arg = this.data.args[i];
if ((arg as string).toLowerCase().includes('-secure')) {
this.secureMode = (arg as string).toLowerCase().includes('true');
}
if ((arg as string).toLowerCase().includes('-netifc') && i < this.data.args.length - 1) {
this.form.get('netifc').setValue(this.data.args[i + 1]);
}
}
}

setTimeout(() => (this.firstInput.nativeElement as HTMLElement).focus());
}

Expand Down Expand Up @@ -123,6 +128,7 @@ export class SkysocksSettingsComponent implements OnInit, OnDestroy {
// The "secure" value is only for the VPN app.
if (this.configuringVpn) {
data['secure'] = this.secureMode;
data['netifc'] = this.form.get('netifc').value;
}

this.operationSubscription = this.appsService.changeAppSettings(
Expand Down
1 change: 1 addition & 0 deletions static/skywire-manager-src/src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@
"vpn-title": "VPN-Server Settings",
"new-password": "New password (Leave empty to remove the password)",
"repeat-password": "Repeat password",
"netifc": "Default network interface (optional)",
"passwords-not-match": "Passwords do not match.",
"secure-mode-check": "Use secure mode",
"secure-mode-info": "When active, the server doesn't allow client/server SSH and doesn't allow any traffic from VPN clients to the server local network.",
Expand Down
1 change: 1 addition & 0 deletions static/skywire-manager-src/src/assets/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@
"vpn-title": "Configuración de VPN-Server",
"new-password": "Nueva contraseña (dejar en blanco para eliminar la contraseña)",
"repeat-password": "Repita la contraseña",
"netifc": "Interfaz de red predeterminada (opcional)",
"passwords-not-match": "Las contraseñas no coinciden.",
"secure-mode-check": "Usar modo seguro",
"secure-mode-info": "Cuando está activo, el servidor no permite SSH con los clientes y no permite ningún tráfico de clientes VPN a la red local del servidor.",
Expand Down
1 change: 1 addition & 0 deletions static/skywire-manager-src/src/assets/i18n/es_base.json
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@
"vpn-title": "VPN-Server Settings",
"new-password": "New password (Leave empty to remove the password)",
"repeat-password": "Repeat password",
"netifc": "Default network interface (optional)",
"passwords-not-match": "Passwords do not match.",
"secure-mode-check": "Use secure mode",
"secure-mode-info": "When active, the server doesn't allow client/server SSH and doesn't allow any traffic from VPN clients to the server local network.",
Expand Down