2020-01-30 06:45:49 +00:00
|
|
|
<template>
|
|
|
|
<v-content>
|
|
|
|
<v-row v-if="server">
|
|
|
|
<v-col cols="12">
|
|
|
|
<v-card dark>
|
|
|
|
<v-list-item>
|
|
|
|
<v-list-item-content>
|
|
|
|
<v-list-item-title class="headline">Server configurations</v-list-item-title>
|
|
|
|
</v-list-item-content>
|
|
|
|
</v-list-item>
|
|
|
|
<div class="d-flex flex-no-wrap justify-space-between">
|
|
|
|
<v-col cols="6">
|
|
|
|
<v-text-field
|
|
|
|
v-model="server.name"
|
|
|
|
:rules="[
|
2020-02-03 07:19:24 +00:00
|
|
|
v => !!v || 'Friendly name is required',
|
2020-01-30 06:45:49 +00:00
|
|
|
]"
|
2020-02-03 07:19:24 +00:00
|
|
|
label="Friendly name"
|
2020-01-30 06:45:49 +00:00
|
|
|
required
|
|
|
|
/>
|
|
|
|
<v-text-field
|
|
|
|
type="number"
|
|
|
|
v-model="server.persistentKeepalive"
|
2020-02-03 07:19:24 +00:00
|
|
|
label="Persistent keepalive"
|
2020-01-30 06:45:49 +00:00
|
|
|
:rules="[
|
|
|
|
v => !!v || 'Persistent keepalive is required',
|
|
|
|
]"
|
|
|
|
required
|
|
|
|
/>
|
|
|
|
<v-text-field
|
|
|
|
v-model="server.endpoint"
|
2020-02-03 07:19:24 +00:00
|
|
|
label="Public endpoint for clients to connect to"
|
2020-01-30 06:45:49 +00:00
|
|
|
:rules="[
|
2020-02-03 07:19:24 +00:00
|
|
|
v => !!v || 'Public endpoint for clients to connect to is required',
|
2020-01-30 06:45:49 +00:00
|
|
|
]"
|
|
|
|
required
|
|
|
|
/>
|
2020-02-05 01:53:53 +00:00
|
|
|
<v-combobox
|
2020-01-30 06:45:49 +00:00
|
|
|
v-model="server.address"
|
2020-02-05 01:53:53 +00:00
|
|
|
chips
|
|
|
|
hint="Write IPv4 or IPv6 CIDR and hit enter"
|
2020-01-30 06:45:49 +00:00
|
|
|
label="Server interface addresses"
|
2020-02-05 01:53:53 +00:00
|
|
|
multiple
|
|
|
|
dark
|
|
|
|
>
|
|
|
|
<template v-slot:selection="{ attrs, item, select, selected }">
|
|
|
|
<v-chip
|
|
|
|
v-bind="attrs"
|
|
|
|
:input-value="selected"
|
|
|
|
close
|
|
|
|
@click="select"
|
|
|
|
@click:close="server.address.splice(server.address.indexOf(item), 1)"
|
|
|
|
>
|
|
|
|
<strong>{{ item }}</strong>
|
|
|
|
</v-chip>
|
|
|
|
</template>
|
|
|
|
</v-combobox>
|
2020-02-05 02:57:43 +00:00
|
|
|
<v-text-field
|
|
|
|
v-model="server.preUp"
|
|
|
|
label="PreUp: script snippets which will be executed by bash before setting up the interface"
|
|
|
|
/>
|
|
|
|
<v-text-field
|
|
|
|
v-model="server.postUp"
|
|
|
|
label="PostUp: script snippets which will be executed by bash after setting up the interface"
|
|
|
|
/>
|
2020-01-30 06:45:49 +00:00
|
|
|
</v-col>
|
|
|
|
<v-col cols="6">
|
|
|
|
<v-text-field
|
|
|
|
v-model="server.publicKey"
|
2020-02-03 07:19:24 +00:00
|
|
|
label="Public key"
|
2020-01-30 06:45:49 +00:00
|
|
|
disabled
|
|
|
|
/>
|
|
|
|
<v-text-field
|
|
|
|
v-model="server.presharedKey"
|
2020-02-03 07:19:24 +00:00
|
|
|
label="Preshared key"
|
2020-01-30 06:45:49 +00:00
|
|
|
disabled
|
|
|
|
/>
|
|
|
|
<v-text-field
|
|
|
|
v-model="server.listenPort"
|
|
|
|
type="number"
|
|
|
|
:rules="[
|
|
|
|
v => !!v || 'Listen port is required',
|
|
|
|
]"
|
2020-02-03 07:19:24 +00:00
|
|
|
label="Listen port"
|
2020-01-30 06:45:49 +00:00
|
|
|
required
|
|
|
|
/>
|
2020-02-05 01:53:53 +00:00
|
|
|
<v-combobox
|
|
|
|
v-model="server.dns"
|
|
|
|
chips
|
|
|
|
hint="Write IPv4 or IPv6 address and hit enter"
|
|
|
|
label="DNS servers for clients"
|
|
|
|
multiple
|
|
|
|
dark
|
|
|
|
>
|
|
|
|
<template v-slot:selection="{ attrs, item, select, selected }">
|
|
|
|
<v-chip
|
|
|
|
v-bind="attrs"
|
|
|
|
:input-value="selected"
|
|
|
|
close
|
|
|
|
@click="select"
|
|
|
|
@click:close="server.dns.splice(server.dns.indexOf(item), 1)"
|
|
|
|
>
|
|
|
|
<strong>{{ item }}</strong>
|
|
|
|
</v-chip>
|
|
|
|
</template>
|
|
|
|
</v-combobox>
|
2020-02-05 02:57:43 +00:00
|
|
|
<v-text-field
|
|
|
|
v-model="server.preDown"
|
|
|
|
label="PreDown: script snippets which will be executed by bash before setting down the interface"
|
|
|
|
/>
|
|
|
|
<v-text-field
|
|
|
|
v-model="server.postDown "
|
|
|
|
label="PostDown : script snippets which will be executed by bash after setting down the interface"
|
|
|
|
/>
|
2020-01-30 06:45:49 +00:00
|
|
|
</v-col>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<v-card-actions>
|
|
|
|
<v-spacer/>
|
|
|
|
<v-btn
|
2020-02-03 07:19:24 +00:00
|
|
|
class="ma-2"
|
2020-01-30 06:45:49 +00:00
|
|
|
color="warning"
|
|
|
|
@click="updateServer"
|
|
|
|
>
|
|
|
|
Update server configuration
|
2020-02-03 07:19:24 +00:00
|
|
|
<v-icon right dark>mdi-update</v-icon>
|
2020-01-30 06:45:49 +00:00
|
|
|
</v-btn>
|
|
|
|
</v-card-actions>
|
|
|
|
</v-card>
|
|
|
|
</v-col>
|
|
|
|
</v-row>
|
|
|
|
<v-divider dark/>
|
|
|
|
<v-row>
|
|
|
|
<v-col cols="12">
|
|
|
|
<v-card dark>
|
|
|
|
<v-list-item>
|
|
|
|
<v-list-item-content>
|
|
|
|
<v-list-item-title class="headline">Clients</v-list-item-title>
|
|
|
|
</v-list-item-content>
|
|
|
|
<v-btn
|
|
|
|
color="success"
|
2020-02-05 01:53:53 +00:00
|
|
|
@click.stop="startAddClient"
|
2020-01-30 06:45:49 +00:00
|
|
|
>
|
|
|
|
Add new client
|
2020-02-03 07:19:24 +00:00
|
|
|
<v-icon right dark>mdi-account-multiple-plus-outline</v-icon>
|
2020-01-30 06:45:49 +00:00
|
|
|
</v-btn>
|
|
|
|
</v-list-item>
|
|
|
|
<v-row>
|
|
|
|
<v-col
|
|
|
|
v-for="(client, i) in clients"
|
|
|
|
:key="i"
|
|
|
|
cols="6"
|
|
|
|
>
|
|
|
|
<v-card
|
2020-02-05 01:53:53 +00:00
|
|
|
:color="client.enable ? '#1F7087' : 'warning'"
|
2020-01-30 06:45:49 +00:00
|
|
|
class="mx-auto"
|
|
|
|
raised
|
|
|
|
shaped
|
|
|
|
>
|
|
|
|
<v-list-item>
|
|
|
|
<v-list-item-content>
|
|
|
|
<v-list-item-title class="headline">{{ client.name }}</v-list-item-title>
|
|
|
|
<v-list-item-subtitle>{{ client.email }}</v-list-item-subtitle>
|
|
|
|
<v-list-item-subtitle>Created: {{ client.created | formatDate }}</v-list-item-subtitle>
|
|
|
|
<v-list-item-subtitle>Updated: {{ client.updated | formatDate }}</v-list-item-subtitle>
|
|
|
|
</v-list-item-content>
|
|
|
|
|
|
|
|
<v-list-item-avatar
|
|
|
|
tile
|
|
|
|
size="150"
|
|
|
|
>
|
|
|
|
<v-img :src="getUrlToConfig(client.id, true)"/>
|
|
|
|
</v-list-item-avatar>
|
|
|
|
</v-list-item>
|
|
|
|
|
|
|
|
<v-card-text class="text--primary">
|
|
|
|
<v-chip
|
|
|
|
v-for="(ip, i) in client.address.split(',')"
|
|
|
|
:key="i"
|
|
|
|
color="indigo"
|
|
|
|
text-color="white"
|
|
|
|
>
|
|
|
|
<v-icon left>mdi-ip-network</v-icon>
|
|
|
|
{{ ip }}
|
|
|
|
</v-chip>
|
|
|
|
</v-card-text>
|
|
|
|
<v-card-actions>
|
|
|
|
<v-btn
|
|
|
|
text
|
|
|
|
:href="getUrlToConfig(client.id, false)"
|
|
|
|
>
|
2020-02-03 07:19:24 +00:00
|
|
|
Download
|
|
|
|
<v-icon right dark>mdi-cloud-download-outline</v-icon>
|
2020-01-30 06:45:49 +00:00
|
|
|
</v-btn>
|
|
|
|
<v-btn
|
|
|
|
text
|
2020-02-05 01:53:53 +00:00
|
|
|
@click.stop="editClient(client.id)"
|
2020-01-30 06:45:49 +00:00
|
|
|
>
|
|
|
|
Edit
|
|
|
|
<v-icon right dark>mdi-square-edit-outline</v-icon>
|
|
|
|
</v-btn>
|
|
|
|
<v-btn
|
|
|
|
text
|
|
|
|
@click="deleteClient(client.id)"
|
|
|
|
>
|
|
|
|
Delete
|
|
|
|
<v-icon right dark>mdi-trash-can-outline</v-icon>
|
|
|
|
</v-btn>
|
2020-02-03 07:19:24 +00:00
|
|
|
<v-btn
|
|
|
|
text
|
|
|
|
@click="sendEmailClient(client.id)"
|
|
|
|
>
|
|
|
|
Send email
|
|
|
|
<v-icon right dark>mdi-email-send-outline</v-icon>
|
|
|
|
</v-btn>
|
2020-01-30 06:45:49 +00:00
|
|
|
<v-spacer/>
|
|
|
|
<v-tooltip right>
|
|
|
|
<template v-slot:activator="{ on }">
|
|
|
|
<v-switch
|
|
|
|
dark
|
|
|
|
v-on="on"
|
|
|
|
color="success"
|
|
|
|
v-model="client.enable"
|
2020-02-05 01:53:53 +00:00
|
|
|
v-on:change="disableClient(client)"
|
2020-01-30 06:45:49 +00:00
|
|
|
/>
|
|
|
|
</template>
|
2020-02-03 07:19:24 +00:00
|
|
|
<span> {{client.enable ? 'Disable' : 'Enable'}} this client</span>
|
2020-01-30 06:45:49 +00:00
|
|
|
</v-tooltip>
|
|
|
|
|
|
|
|
</v-card-actions>
|
|
|
|
</v-card>
|
|
|
|
</v-col>
|
|
|
|
</v-row>
|
|
|
|
</v-card>
|
|
|
|
</v-col>
|
|
|
|
</v-row>
|
|
|
|
<v-dialog
|
2020-02-05 01:53:53 +00:00
|
|
|
v-if="client"
|
2020-01-30 06:45:49 +00:00
|
|
|
v-model="dialogAddClient"
|
|
|
|
max-width="550"
|
|
|
|
>
|
|
|
|
<v-card>
|
|
|
|
<v-card-title class="headline">Add new client</v-card-title>
|
|
|
|
<v-card-text>
|
|
|
|
<v-row>
|
|
|
|
<v-col
|
|
|
|
cols="12"
|
|
|
|
>
|
|
|
|
<v-form
|
|
|
|
ref="form"
|
|
|
|
v-model="valid"
|
|
|
|
>
|
|
|
|
<v-text-field
|
|
|
|
v-model="client.name"
|
|
|
|
label="Client friendly name"
|
|
|
|
:rules="[
|
|
|
|
v => !!v || 'Client name is required',
|
|
|
|
]"
|
|
|
|
required
|
|
|
|
/>
|
|
|
|
<v-text-field
|
|
|
|
v-model="client.email"
|
|
|
|
label="Client email"
|
|
|
|
:rules="[
|
|
|
|
v => !!v || 'E-mail is required',
|
|
|
|
v => /.+@.+\..+/.test(v) || 'E-mail must be valid',
|
|
|
|
]"
|
|
|
|
required
|
|
|
|
/>
|
|
|
|
<v-select
|
|
|
|
v-model="clientAddress"
|
|
|
|
:items="serverAddress"
|
|
|
|
label="Client IP will be chosen from these networks"
|
|
|
|
:rules="[
|
|
|
|
v => !!v || 'Network is required',
|
|
|
|
]"
|
|
|
|
multiple
|
|
|
|
chips
|
|
|
|
persistent-hint
|
|
|
|
required
|
|
|
|
/>
|
2020-02-05 01:53:53 +00:00
|
|
|
<v-combobox
|
|
|
|
v-model="client.allowedIPs"
|
|
|
|
chips
|
|
|
|
hint="Write IPv4 or IPv6 CIDR and hit enter"
|
|
|
|
label="Allowed IPs"
|
|
|
|
multiple
|
|
|
|
dark
|
|
|
|
>
|
|
|
|
<template v-slot:selection="{ attrs, item, select, selected }">
|
|
|
|
<v-chip
|
|
|
|
v-bind="attrs"
|
|
|
|
:input-value="selected"
|
|
|
|
close
|
|
|
|
@click="select"
|
|
|
|
@click:close="client.allowedIPs.splice(client.allowedIPs.indexOf(item), 1)"
|
|
|
|
>
|
|
|
|
<strong>{{ item }}</strong>
|
|
|
|
</v-chip>
|
|
|
|
</template>
|
|
|
|
</v-combobox>
|
|
|
|
|
2020-01-30 06:45:49 +00:00
|
|
|
<v-switch
|
|
|
|
v-model="client.enable"
|
|
|
|
color="red"
|
|
|
|
inset
|
|
|
|
:label="client.enable ? 'Enable client after creation': 'Disable client after creation'"
|
|
|
|
/>
|
|
|
|
</v-form>
|
|
|
|
</v-col>
|
|
|
|
</v-row>
|
|
|
|
</v-card-text>
|
|
|
|
<v-card-actions>
|
|
|
|
<v-spacer/>
|
|
|
|
<v-btn
|
|
|
|
:disabled="!valid"
|
|
|
|
color="success"
|
2020-02-05 01:53:53 +00:00
|
|
|
@click="addClient(client)"
|
2020-01-30 06:45:49 +00:00
|
|
|
>
|
|
|
|
Submit
|
2020-02-06 04:30:36 +00:00
|
|
|
<v-icon right dark>mdi-check-outline</v-icon>
|
2020-01-30 06:45:49 +00:00
|
|
|
</v-btn>
|
|
|
|
<v-btn
|
|
|
|
color="primary"
|
|
|
|
@click="dialogAddClient = false"
|
|
|
|
>
|
|
|
|
Cancel
|
2020-02-06 04:30:36 +00:00
|
|
|
<v-icon right dark>mdi-close-circle-outline</v-icon>
|
2020-01-30 06:45:49 +00:00
|
|
|
</v-btn>
|
|
|
|
</v-card-actions>
|
|
|
|
</v-card>
|
|
|
|
</v-dialog>
|
|
|
|
<v-dialog
|
2020-02-05 01:53:53 +00:00
|
|
|
v-if="client"
|
2020-01-30 06:45:49 +00:00
|
|
|
v-model="dialogEditClient"
|
|
|
|
max-width="550"
|
|
|
|
>
|
|
|
|
<v-card>
|
|
|
|
<v-card-title class="headline">Edit client</v-card-title>
|
|
|
|
<v-card-text>
|
|
|
|
<v-row>
|
|
|
|
<v-col
|
|
|
|
cols="12"
|
|
|
|
>
|
|
|
|
<v-form
|
|
|
|
ref="form"
|
|
|
|
v-model="valid"
|
|
|
|
>
|
|
|
|
<v-text-field
|
2020-02-05 01:53:53 +00:00
|
|
|
v-model="client.name"
|
|
|
|
label="Friendly name"
|
2020-01-30 06:45:49 +00:00
|
|
|
:rules="[
|
|
|
|
v => !!v || 'Client name is required',
|
|
|
|
]"
|
|
|
|
required
|
|
|
|
/>
|
|
|
|
<v-text-field
|
2020-02-05 01:53:53 +00:00
|
|
|
v-model="client.email"
|
|
|
|
label="Email"
|
2020-01-30 06:45:49 +00:00
|
|
|
:rules="[
|
2020-02-05 01:53:53 +00:00
|
|
|
v => !!v || 'Email is required',
|
|
|
|
v => /.+@.+\..+/.test(v) || 'Email must be valid',
|
|
|
|
]"
|
2020-01-30 06:45:49 +00:00
|
|
|
required
|
|
|
|
/>
|
2020-02-06 04:30:36 +00:00
|
|
|
<v-combobox
|
|
|
|
v-model="client.address"
|
|
|
|
chips
|
|
|
|
hint="Write IPv4 or IPv6 CIDR and hit enter"
|
|
|
|
label="Addresses"
|
|
|
|
multiple
|
|
|
|
dark
|
|
|
|
>
|
|
|
|
<template v-slot:selection="{ attrs, item, select, selected }">
|
|
|
|
<v-chip
|
|
|
|
v-bind="attrs"
|
|
|
|
:input-value="selected"
|
|
|
|
close
|
|
|
|
@click="select"
|
|
|
|
@click:close="client.address.splice(client.address.indexOf(item), 1)"
|
|
|
|
>
|
|
|
|
<strong>{{ item }}</strong>
|
|
|
|
</v-chip>
|
|
|
|
</template>
|
|
|
|
</v-combobox>
|
2020-02-05 01:53:53 +00:00
|
|
|
<v-combobox
|
|
|
|
v-model="client.allowedIPs"
|
|
|
|
chips
|
|
|
|
hint="Write IPv4 or IPv6 CIDR and hit enter"
|
|
|
|
label="Allowed IPs"
|
|
|
|
multiple
|
|
|
|
dark
|
|
|
|
>
|
|
|
|
<template v-slot:selection="{ attrs, item, select, selected }">
|
|
|
|
<v-chip
|
|
|
|
v-bind="attrs"
|
|
|
|
:input-value="selected"
|
|
|
|
close
|
|
|
|
@click="select"
|
|
|
|
@click:close="client.allowedIPs.splice(client.allowedIPs.indexOf(item), 1)"
|
|
|
|
>
|
|
|
|
<strong>{{ item }}</strong>
|
|
|
|
</v-chip>
|
|
|
|
</template>
|
|
|
|
</v-combobox>
|
2020-01-30 06:45:49 +00:00
|
|
|
</v-form>
|
|
|
|
</v-col>
|
|
|
|
</v-row>
|
|
|
|
</v-card-text>
|
|
|
|
<v-card-actions>
|
|
|
|
<v-spacer/>
|
|
|
|
<v-btn
|
|
|
|
:disabled="!valid"
|
|
|
|
color="success"
|
2020-02-05 01:53:53 +00:00
|
|
|
@click="updateClient(client)"
|
2020-01-30 06:45:49 +00:00
|
|
|
>
|
|
|
|
Submit
|
2020-02-06 04:30:36 +00:00
|
|
|
<v-icon right dark>mdi-check-outline</v-icon>
|
2020-01-30 06:45:49 +00:00
|
|
|
</v-btn>
|
|
|
|
<v-btn
|
|
|
|
color="primary"
|
|
|
|
@click="dialogEditClient = false"
|
|
|
|
>
|
|
|
|
Cancel
|
2020-02-06 04:30:36 +00:00
|
|
|
<v-icon right dark>mdi-close-circle-outline</v-icon>
|
2020-01-30 06:45:49 +00:00
|
|
|
</v-btn>
|
|
|
|
</v-card-actions>
|
|
|
|
</v-card>
|
|
|
|
</v-dialog>
|
|
|
|
<v-snackbar
|
|
|
|
v-model="notification.show"
|
|
|
|
:right="true"
|
|
|
|
:top="true"
|
|
|
|
:color="notification.color"
|
|
|
|
>
|
|
|
|
{{ notification.text }}
|
|
|
|
<v-btn
|
|
|
|
dark
|
|
|
|
text
|
|
|
|
@click="notification.show = false"
|
|
|
|
>
|
|
|
|
Close
|
|
|
|
</v-btn>
|
|
|
|
</v-snackbar>
|
|
|
|
</v-content>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
name: 'home',
|
|
|
|
mounted () {
|
|
|
|
this.getData()
|
|
|
|
},
|
|
|
|
data: () => ({
|
|
|
|
notification: {
|
|
|
|
show: false,
|
|
|
|
color: '',
|
|
|
|
text: '',
|
|
|
|
},
|
|
|
|
valid: true,
|
|
|
|
checkbox: false,
|
|
|
|
server: null,
|
|
|
|
clients: [],
|
|
|
|
ipDns: "",
|
|
|
|
ipAddress: "",
|
|
|
|
clientAddress: [],
|
|
|
|
serverAddress: [],
|
|
|
|
dialogAddClient: false,
|
|
|
|
dialogEditClient: false,
|
2020-02-05 01:53:53 +00:00
|
|
|
client: null,
|
2020-01-30 06:45:49 +00:00
|
|
|
}),
|
|
|
|
methods: {
|
2020-02-05 01:53:53 +00:00
|
|
|
startAddClient() {
|
|
|
|
this.dialogAddClient = true;
|
|
|
|
this.client = {
|
|
|
|
name: "",
|
|
|
|
email: "",
|
|
|
|
enable: true,
|
|
|
|
allowedIPs: ["0.0.0.0/0", "::/0"],
|
|
|
|
address: "",
|
|
|
|
}
|
|
|
|
},
|
|
|
|
editClient(id) {
|
|
|
|
this.$get(`/client/${id}`).then((res) => {
|
|
|
|
this.dialogEditClient = true;
|
|
|
|
res.allowedIPs = res.allowedIPs.split(',');
|
2020-02-06 04:30:36 +00:00
|
|
|
res.address = res.address.split(',');
|
2020-02-05 01:53:53 +00:00
|
|
|
this.client = res
|
|
|
|
}).catch((e) => {
|
|
|
|
this.notify('error', e.response.status + ' ' + e.response.statusText);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
disableClient(client) {
|
2020-02-06 04:30:36 +00:00
|
|
|
if(!Array.isArray(client.allowedIPs)){
|
|
|
|
client.allowedIPs = client.allowedIPs.split(',');
|
|
|
|
}
|
|
|
|
if(!Array.isArray(client.address)){
|
|
|
|
client.address = client.address.split(',');
|
|
|
|
}
|
2020-02-05 01:53:53 +00:00
|
|
|
this.updateClient(client)
|
|
|
|
},
|
2020-01-30 06:45:49 +00:00
|
|
|
getData() {
|
|
|
|
this.$get('/server').then((res) => {
|
2020-02-05 01:53:53 +00:00
|
|
|
res.address = res.address.split(',');
|
|
|
|
res.dns = res.dns.split(',');
|
2020-01-30 06:45:49 +00:00
|
|
|
this.server = res;
|
2020-02-05 01:53:53 +00:00
|
|
|
this.clientAddress = this.serverAddress = this.server.address
|
2020-01-30 06:45:49 +00:00
|
|
|
}).catch((e) => {
|
|
|
|
this.notify('error', e.response.status + ' ' + e.response.statusText);
|
|
|
|
});
|
|
|
|
|
|
|
|
this.$get('/client').then((res) => {
|
|
|
|
this.clients = res
|
|
|
|
}).catch((e) => {
|
|
|
|
this.notify('error', e.response.status + ' ' + e.response.statusText);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
updateServer () {
|
2020-01-31 02:27:30 +00:00
|
|
|
// convert int values
|
|
|
|
this.server.listenPort = parseInt(this.server.listenPort, 10);
|
|
|
|
this.server.persistentKeepalive = parseInt(this.server.persistentKeepalive, 10);
|
2020-02-05 01:53:53 +00:00
|
|
|
// check server addresses
|
|
|
|
if (this.server.address.length < 1) {
|
|
|
|
this.notify('error', 'Please provide at least one valid CIDR address for server interface');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (let i = 0; i < this.server.address.length; i++){
|
|
|
|
if (this.$isCidr(this.server.address[i]) === 0) {
|
|
|
|
this.notify('error', 'Invalid CIDR detected, please correct before submitting');
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.server.address = this.server.address.join(',');
|
|
|
|
this.server.dns = this.server.dns.join(',');
|
|
|
|
|
2020-01-30 06:45:49 +00:00
|
|
|
this.$patch('/server', this.server).then((res) => {
|
|
|
|
this.notify('success', "Server successfully updated");
|
|
|
|
this.getData()
|
|
|
|
}).catch((e) => {
|
|
|
|
this.notify('error', e.response.status + ' ' + e.response.statusText);
|
|
|
|
});
|
|
|
|
},
|
2020-02-05 01:53:53 +00:00
|
|
|
addClient(client) {
|
|
|
|
if (client.allowedIPs.length < 1) {
|
|
|
|
this.notify('error', 'Please provide at least one valid CIDR address for client allowed IPs');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (let i = 0; i < client.allowedIPs.length; i++){
|
|
|
|
if (this.$isCidr(client.allowedIPs[i]) === 0) {
|
|
|
|
this.notify('error', 'Invalid CIDR detected, please correct before submitting');
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-30 06:45:49 +00:00
|
|
|
this.dialogAddClient = false;
|
2020-02-05 01:53:53 +00:00
|
|
|
client.address = this.clientAddress.join(',');
|
|
|
|
client.allowedIPs = this.client.allowedIPs.join(',');
|
|
|
|
|
|
|
|
this.$post('/client', client).then((res) => {
|
2020-01-30 06:45:49 +00:00
|
|
|
this.notify('success', "Client successfully added");
|
|
|
|
this.getData()
|
|
|
|
}).catch((e) => {
|
|
|
|
this.notify('error', e.response.status + ' ' + e.response.statusText);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
deleteClient(id) {
|
|
|
|
if(confirm("Do you really want to delete?")){
|
|
|
|
this.$delete(`/client/${id}`).then((res) => {
|
|
|
|
this.notify('success', "Client successfully deleted");
|
|
|
|
this.getData()
|
|
|
|
}).catch((e) => {
|
|
|
|
this.notify('error', e.response.status + ' ' + e.response.statusText);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
2020-02-03 07:19:24 +00:00
|
|
|
sendEmailClient(id) {
|
|
|
|
this.$get(`/client/${id}/email`).then((res) => {
|
|
|
|
this.notify('success', "Email successfully sent");
|
|
|
|
this.getData()
|
|
|
|
}).catch((e) => {
|
|
|
|
this.notify('error', e.response.status + ' ' + e.response.statusText);
|
|
|
|
});
|
|
|
|
},
|
2020-01-30 06:45:49 +00:00
|
|
|
getUrlToConfig(id, qrcode){
|
|
|
|
let base = "/api/v1.0";
|
|
|
|
if (process.env.NODE_ENV === "development"){
|
|
|
|
base = process.env.VUE_APP_API_BASE_URL
|
|
|
|
}
|
|
|
|
if (qrcode){
|
|
|
|
return `${base}/client/${id}/config?qrcode=true`
|
|
|
|
} else {
|
|
|
|
return `${base}/client/${id}/config`
|
|
|
|
}
|
|
|
|
},
|
2020-01-31 02:27:30 +00:00
|
|
|
updateClient(client) {
|
2020-02-06 04:30:36 +00:00
|
|
|
// check allowed IPs
|
2020-02-05 01:53:53 +00:00
|
|
|
if (client.allowedIPs.length < 1) {
|
|
|
|
this.notify('error', 'Please provide at least one valid CIDR address for client allowed IPs');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (let i = 0; i < client.allowedIPs.length; i++){
|
|
|
|
if (this.$isCidr(client.allowedIPs[i]) === 0) {
|
|
|
|
this.notify('error', 'Invalid CIDR detected, please correct before submitting');
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
2020-02-06 04:30:36 +00:00
|
|
|
// check address
|
|
|
|
if (client.address.length < 1) {
|
|
|
|
this.notify('error', 'Please provide at least one valid CIDR address for client');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (let i = 0; i < client.address.length; i++){
|
|
|
|
if (this.$isCidr(client.address[i]) === 0) {
|
|
|
|
this.notify('error', 'Invalid CIDR detected, please correct before submitting');
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// all good, submit
|
2020-01-30 06:45:49 +00:00
|
|
|
this.dialogEditClient = false;
|
2020-02-05 01:53:53 +00:00
|
|
|
client.allowedIPs = client.allowedIPs.join(',');
|
2020-02-06 04:30:36 +00:00
|
|
|
client.address = client.address.join(',');
|
2020-02-05 01:53:53 +00:00
|
|
|
|
2020-01-31 02:27:30 +00:00
|
|
|
this.$patch(`/client/${client.id}`, client).then((res) => {
|
2020-01-30 06:45:49 +00:00
|
|
|
this.notify('success', "Client successfully updated");
|
|
|
|
this.getData()
|
|
|
|
}).catch((e) => {
|
|
|
|
this.notify('error', e.response.status + ' ' + e.response.statusText);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
notify(color, msg) {
|
|
|
|
this.notification.show = true;
|
|
|
|
this.notification.color = color;
|
|
|
|
this.notification.text = msg;
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
}
|
|
|
|
</script>
|