mirror of
https://github.com/Av0idD4rk/packmate.git
synced 2026-10-25 02:29:26 +00:00
Merge branch 'pattern-editing' into 'master'
Pattern editing See merge request packmate/packmate-frontend!3
This commit is contained in:
commit
07607d9464
10
src/App.vue
10
src/App.vue
@ -14,9 +14,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Settings/>
|
<Settings/>
|
||||||
<AddService/>
|
|
||||||
<AddPattern/>
|
|
||||||
<LookBack ref="lookBack" />
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -26,9 +23,6 @@
|
|||||||
|
|
||||||
import Navbar from './components/Navbar';
|
import Navbar from './components/Navbar';
|
||||||
import Settings from './views/Settings';
|
import Settings from './views/Settings';
|
||||||
import AddService from './views/AddService';
|
|
||||||
import AddPattern from './views/AddPattern';
|
|
||||||
import LookBack from './views/LookBack';
|
|
||||||
import SockJS from 'sockjs-client';
|
import SockJS from 'sockjs-client';
|
||||||
import {openDB,} from 'idb';
|
import {openDB,} from 'idb';
|
||||||
|
|
||||||
@ -147,6 +141,7 @@
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'FINISH_LOOKBACK': {
|
case 'FINISH_LOOKBACK': {
|
||||||
|
console.debug('Lookback completed');
|
||||||
this.$bvToast.toast(`Lookback completed`, {
|
this.$bvToast.toast(`Lookback completed`, {
|
||||||
title: 'Notification',
|
title: 'Notification',
|
||||||
variant: 'success',
|
variant: 'success',
|
||||||
@ -200,9 +195,6 @@
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
AddPattern,
|
|
||||||
AddService,
|
|
||||||
LookBack,
|
|
||||||
Settings,
|
Settings,
|
||||||
Navbar,
|
Navbar,
|
||||||
},
|
},
|
||||||
|
|||||||
@ -30,6 +30,12 @@
|
|||||||
<template v-else>of service {{ getServiceName(pattern.serviceId) }} #{{ pattern.serviceId }}</template>
|
<template v-else>of service {{ getServiceName(pattern.serviceId) }} #{{ pattern.serviceId }}</template>
|
||||||
|
|
||||||
<div class="float-right" style="margin-left: 2em;">
|
<div class="float-right" style="margin-left: 2em;">
|
||||||
|
<button type="button" class="btn btn-outline-info btn-sm mr-1"
|
||||||
|
@click.stop.prevent="showEditPattern(pattern)"
|
||||||
|
title="Edit pattern">
|
||||||
|
<i class="fas fa-edit"></i>
|
||||||
|
</button>
|
||||||
|
|
||||||
<button v-if="pattern.actionType === 'FIND'" type="button" class="btn btn-outline-warning btn-sm mr-1"
|
<button v-if="pattern.actionType === 'FIND'" type="button" class="btn btn-outline-warning btn-sm mr-1"
|
||||||
@click.stop.prevent="showLookBack(pattern)"
|
@click.stop.prevent="showLookBack(pattern)"
|
||||||
title="Apply pattern to older streams">
|
title="Apply pattern to older streams">
|
||||||
@ -54,11 +60,26 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</b-dropdown-item-button>
|
</b-dropdown-item-button>
|
||||||
|
|
||||||
|
<PatternModal :creating="patternModalIsCreating" :initial-pattern="patternModalEditingPattern" />
|
||||||
|
<LookBack :pattern-id="patternIdForLookback" />
|
||||||
</b-dropdown>
|
</b-dropdown>
|
||||||
</template>
|
</template>
|
||||||
|
<!--suppress JSUnresolvedReference -->
|
||||||
<script>
|
<script>
|
||||||
|
import PatternModal from '@/views/PatternModal.vue';
|
||||||
|
import LookBack from '@/views/LookBack.vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'PatternsDropdown',
|
name: 'PatternsDropdown',
|
||||||
|
components: {LookBack, PatternModal, },
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
patternModalIsCreating: true,
|
||||||
|
patternModalEditingPattern: {},
|
||||||
|
patternIdForLookback: 0,
|
||||||
|
};
|
||||||
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.updatePatterns();
|
this.updatePatterns();
|
||||||
},
|
},
|
||||||
@ -84,11 +105,22 @@
|
|||||||
return this.$store.state.services.find(o => o.port === port)?.name ?? '<Deleted service>'
|
return this.$store.state.services.find(o => o.port === port)?.name ?? '<Deleted service>'
|
||||||
},
|
},
|
||||||
showAddPattern() {
|
showAddPattern() {
|
||||||
this.$bvModal.show('addPatternModal');
|
this.patternModalIsCreating = true;
|
||||||
|
this.patternModalEditingPattern = {};
|
||||||
|
this.$bvModal.show('patternModal');
|
||||||
|
console.debug('Showing patternModal (create)');
|
||||||
|
},
|
||||||
|
showEditPattern(pattern) {
|
||||||
|
this.patternModalIsCreating = false;
|
||||||
|
this.patternModalEditingPattern = {};
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.patternModalEditingPattern = pattern;
|
||||||
|
this.$bvModal.show('patternModal');
|
||||||
|
console.debug('Showing patternModal (edit)');
|
||||||
|
});
|
||||||
},
|
},
|
||||||
showLookBack(pattern) {
|
showLookBack(pattern) {
|
||||||
// Не знаю, как сделать это без костылей
|
this.patternIdForLookback = pattern.id;
|
||||||
this.$root.$children[0].$refs.lookBack.patternId = pattern.id;
|
|
||||||
this.$bvModal.show('lookBackModal');
|
this.$bvModal.show('lookBackModal');
|
||||||
},
|
},
|
||||||
updatePatterns() {
|
updatePatterns() {
|
||||||
|
|||||||
@ -1,145 +0,0 @@
|
|||||||
<template>
|
|
||||||
<b-modal @ok="createService" @cancel="reset" id="addServiceModal" title="Add service"
|
|
||||||
cancel-title="Cancel"
|
|
||||||
centered scrollable>
|
|
||||||
<form ref="addServiceForm">
|
|
||||||
<b-form-group
|
|
||||||
label-cols-sm="4"
|
|
||||||
label="Name"
|
|
||||||
label-for="addSvc-name">
|
|
||||||
<b-form-input @keydown.native.enter="createService" id="addSvc-name" required
|
|
||||||
v-model="svcName"/>
|
|
||||||
</b-form-group>
|
|
||||||
<b-form-group
|
|
||||||
label-cols-sm="4"
|
|
||||||
label="Port"
|
|
||||||
label-for="addSvc-port">
|
|
||||||
<b-form-input @keydown.native.enter="createService" type="number" min="1" max="65535"
|
|
||||||
id="addSvc-port" required v-model.number="svcPort"/>
|
|
||||||
</b-form-group>
|
|
||||||
<b-form-group
|
|
||||||
label-cols-sm="4"
|
|
||||||
label="Process chunked transfer encoding"
|
|
||||||
label-for="addSvc-process-chunked">
|
|
||||||
<b-form-checkbox id="addSvc-process-chunked" required
|
|
||||||
v-model="processChunkedEncoding"/>
|
|
||||||
</b-form-group>
|
|
||||||
<b-form-group
|
|
||||||
label-cols-sm="4"
|
|
||||||
label="Decompress GZIP"
|
|
||||||
label-for="addSvc-ungzip">
|
|
||||||
<b-form-checkbox id="addSvc-ungzip" required
|
|
||||||
v-model="ungzipHttp"/>
|
|
||||||
</b-form-group>
|
|
||||||
<b-form-group
|
|
||||||
label-cols-sm="4"
|
|
||||||
label="Apply urldecode"
|
|
||||||
label-for="addSvc-urldecode">
|
|
||||||
<b-form-checkbox id="addSvc-urldecode" required
|
|
||||||
v-model="urldecodeHttpRequests"/>
|
|
||||||
</b-form-group>
|
|
||||||
<b-form-group
|
|
||||||
label-cols-sm="4"
|
|
||||||
label="Merge adjacent packets"
|
|
||||||
label-for="addSvc-mergeAdjacent">
|
|
||||||
<b-form-checkbox id="addSvc-mergeAdjacent" required
|
|
||||||
v-model="mergeAdjacentPackets"/>
|
|
||||||
</b-form-group>
|
|
||||||
<b-form-group
|
|
||||||
label-cols-sm="4"
|
|
||||||
label="Inflate WebSockets"
|
|
||||||
label-for="addSvc-inflateWS">
|
|
||||||
<b-form-checkbox id="addSvc-inflateWS" required
|
|
||||||
v-model="parseWebSockets"/>
|
|
||||||
</b-form-group>
|
|
||||||
<b-form-group
|
|
||||||
label-cols-sm="4"
|
|
||||||
label="Decrypt TLS (TLS_RSA_WITH_AES only)"
|
|
||||||
label-for="addSvc-decryptTls">
|
|
||||||
<b-form-checkbox id="addSvc-decryptTls" required
|
|
||||||
v-model="decryptTls"/>
|
|
||||||
</b-form-group>
|
|
||||||
</form>
|
|
||||||
</b-modal>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
export default {
|
|
||||||
name: 'AddService',
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
svcName: String(),
|
|
||||||
svcPort: Number(),
|
|
||||||
processChunkedEncoding: Boolean,
|
|
||||||
ungzipHttp: Boolean(),
|
|
||||||
urldecodeHttpRequests: Boolean(),
|
|
||||||
mergeAdjacentPackets: Boolean(),
|
|
||||||
parseWebSockets: Boolean(),
|
|
||||||
decryptTls: Boolean(),
|
|
||||||
};
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
checkValidity() {
|
|
||||||
return this.$refs.addServiceForm.reportValidity()
|
|
||||||
&& this.svcPort >= 1
|
|
||||||
&& this.svcPort <= 65535;
|
|
||||||
},
|
|
||||||
|
|
||||||
reset() {
|
|
||||||
this.svcName = '';
|
|
||||||
this.svcPort = 0;
|
|
||||||
this.processChunkedEncoding = false;
|
|
||||||
this.ungzipHttp = false;
|
|
||||||
this.urldecodeHttpRequests = false;
|
|
||||||
this.mergeAdjacentPackets = false;
|
|
||||||
this.parseWebSockets = false;
|
|
||||||
this.decryptTls = false;
|
|
||||||
},
|
|
||||||
|
|
||||||
createService(ev) {
|
|
||||||
const name = this.svcName;
|
|
||||||
const port = this.svcPort;
|
|
||||||
const processChunkedEncoding = this.processChunkedEncoding;
|
|
||||||
const ungzipHttp = this.ungzipHttp;
|
|
||||||
const urldecodeHttpRequests = this.urldecodeHttpRequests;
|
|
||||||
const mergeAdjacentPackets = this.mergeAdjacentPackets;
|
|
||||||
const parseWebSockets = this.parseWebSockets;
|
|
||||||
const decryptTls = this.decryptTls;
|
|
||||||
if (!this.checkValidity()) {
|
|
||||||
ev.preventDefault();
|
|
||||||
console.debug('Form is invalid');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
console.debug(`Creating service ${name} (${port})...`);
|
|
||||||
|
|
||||||
this.$http.post('service/', {
|
|
||||||
name,
|
|
||||||
port,
|
|
||||||
processChunkedEncoding,
|
|
||||||
ungzipHttp,
|
|
||||||
urldecodeHttpRequests,
|
|
||||||
mergeAdjacentPackets,
|
|
||||||
parseWebSockets,
|
|
||||||
decryptTls,
|
|
||||||
}).then(response => {
|
|
||||||
const data = response.data;
|
|
||||||
console.debug('Done adding service', data);
|
|
||||||
this.$emit('serviceAddComplete');
|
|
||||||
this.reset();
|
|
||||||
this.$bvModal.hide('addServiceModal');
|
|
||||||
}).catch(e => {
|
|
||||||
this.$bvToast.toast(`Failed to add service: ${e}`, {
|
|
||||||
title: 'Error',
|
|
||||||
variant: 'danger',
|
|
||||||
});
|
|
||||||
console.error('Failed to add service', e);
|
|
||||||
});
|
|
||||||
ev.preventDefault();
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
|
|
||||||
</style>
|
|
||||||
@ -67,7 +67,3 @@
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
|
|
||||||
</style>
|
|
||||||
|
|||||||
@ -20,11 +20,10 @@
|
|||||||
export default {
|
export default {
|
||||||
name: 'LookBack',
|
name: 'LookBack',
|
||||||
props: {
|
props: {
|
||||||
id: Number,
|
patternId: Number,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
patternId: null,
|
|
||||||
minutes: 5,
|
minutes: 5,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<b-modal @ok="addPattern" @cancel="reset" id="addPatternModal"
|
<b-modal @ok="addPattern" @cancel="reset" id="patternModal"
|
||||||
title="Creating pattern"
|
title="Creating pattern"
|
||||||
cancel-title="Cancel"
|
cancel-title="Cancel"
|
||||||
centered scrollable>
|
centered scrollable>
|
||||||
@ -14,6 +14,7 @@
|
|||||||
</b-form-group>
|
</b-form-group>
|
||||||
|
|
||||||
<b-form-group
|
<b-form-group
|
||||||
|
v-if="creating"
|
||||||
label-cols-sm="4"
|
label-cols-sm="4"
|
||||||
label-cols-lg="3"
|
label-cols-lg="3"
|
||||||
label="Pattern"
|
label="Pattern"
|
||||||
@ -25,6 +26,7 @@
|
|||||||
</b-form-group>
|
</b-form-group>
|
||||||
|
|
||||||
<b-form-group
|
<b-form-group
|
||||||
|
v-if="creating"
|
||||||
label-cols-sm="4"
|
label-cols-sm="4"
|
||||||
label-cols-lg="3"
|
label-cols-lg="3"
|
||||||
label="Search action"
|
label="Search action"
|
||||||
@ -46,6 +48,7 @@
|
|||||||
</b-form-group>
|
</b-form-group>
|
||||||
|
|
||||||
<b-form-group
|
<b-form-group
|
||||||
|
v-if="creating"
|
||||||
label-cols-sm="4"
|
label-cols-sm="4"
|
||||||
label-cols-lg="3"
|
label-cols-lg="3"
|
||||||
label="Search method"
|
label="Search method"
|
||||||
@ -59,6 +62,7 @@
|
|||||||
</b-form-group>
|
</b-form-group>
|
||||||
|
|
||||||
<b-form-group
|
<b-form-group
|
||||||
|
v-if="creating"
|
||||||
label-cols-sm="4"
|
label-cols-sm="4"
|
||||||
label-cols-lg="3"
|
label-cols-lg="3"
|
||||||
label="Search type"
|
label="Search type"
|
||||||
@ -72,6 +76,7 @@
|
|||||||
</b-form-group>
|
</b-form-group>
|
||||||
|
|
||||||
<b-form-group
|
<b-form-group
|
||||||
|
v-if="creating"
|
||||||
label-cols-sm="4"
|
label-cols-sm="4"
|
||||||
label-cols-lg="3"
|
label-cols-lg="3"
|
||||||
label="Service"
|
label="Service"
|
||||||
@ -85,22 +90,44 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const hexRegex = /[0-9A-Fa-f ]/;
|
|
||||||
|
const hexRegex = /[0-9A-Fa-f ]/;
|
||||||
|
const defaultPattern = {
|
||||||
|
name: '',
|
||||||
|
value: '',
|
||||||
|
color: '#FF7474',
|
||||||
|
searchType: 'SUBSTRING',
|
||||||
|
directionType: 'BOTH',
|
||||||
|
actionType: 'FIND',
|
||||||
|
serviceId: null,
|
||||||
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'AddPattern',
|
name: 'PatternModal',
|
||||||
|
props: {
|
||||||
|
creating: Boolean,
|
||||||
|
|
||||||
|
initialPattern: {
|
||||||
|
name: String,
|
||||||
|
value: String,
|
||||||
|
color: String,
|
||||||
|
searchType: String,
|
||||||
|
directionType: String,
|
||||||
|
actionType: String,
|
||||||
|
serviceId: Number,
|
||||||
|
},
|
||||||
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
newPattern: {
|
newPattern: {},
|
||||||
name: '',
|
|
||||||
value: '',
|
|
||||||
color: '#FF7474',
|
|
||||||
searchType: 'SUBSTRING',
|
|
||||||
directionType: 'BOTH',
|
|
||||||
actionType: 'FIND',
|
|
||||||
serviceId: null,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
watch: {
|
||||||
|
initialPattern() {
|
||||||
|
console.debug('initialService changed, reassigning...', this.initialPattern);
|
||||||
|
this.newPattern = {...defaultPattern, ...this.initialPattern,};
|
||||||
|
},
|
||||||
|
},
|
||||||
computed: {
|
computed: {
|
||||||
serviceOptions: function () {
|
serviceOptions: function () {
|
||||||
let services = this.$store.state.services;
|
let services = this.$store.state.services;
|
||||||
@ -136,14 +163,7 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
reset() {
|
reset() {
|
||||||
this.newPattern = {
|
this.newPattern = {...defaultPattern,};
|
||||||
name: '',
|
|
||||||
value: '',
|
|
||||||
color: '#FF7474',
|
|
||||||
searchType: 'SUBSTRING',
|
|
||||||
directionType: 'BOTH',
|
|
||||||
actionType: 'FIND',
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
|
|
||||||
addPattern(ev) {
|
addPattern(ev) {
|
||||||
@ -152,19 +172,26 @@
|
|||||||
console.debug('Form is invalid');
|
console.debug('Form is invalid');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.debug('Adding pattern...', this.newPattern);
|
console.debug('Adding/editing pattern...', this.newPattern);
|
||||||
|
|
||||||
if (this.newPattern.searchType === 'SUBBYTES') {
|
if (this.newPattern.searchType === 'SUBBYTES') {
|
||||||
this.newPattern.value = this.newPattern.value.replace(/\s+/g, '').toLowerCase();
|
this.newPattern.value = this.newPattern.value.replace(/\s+/g, '').toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$http.post('pattern/', this.newPattern)
|
let url;
|
||||||
|
if (this.creating) {
|
||||||
|
url = 'pattern/'
|
||||||
|
} else {
|
||||||
|
url = 'pattern/' + this.newPattern.id
|
||||||
|
}
|
||||||
|
|
||||||
|
this.$http.post(url, this.newPattern)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
const data = response.data;
|
const data = response.data;
|
||||||
console.debug('Done adding pattern', data);
|
console.debug('Done adding/editing pattern', data);
|
||||||
this.$emit('patternAddComplete');
|
this.$emit('patternAddComplete');
|
||||||
this.reset();
|
this.reset();
|
||||||
this.$bvModal.hide('addPatternModal');
|
this.$bvModal.hide('patternModal');
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
this.$bvToast.toast(`Failed to add pattern: ${e}`, {
|
this.$bvToast.toast(`Failed to add pattern: ${e}`, {
|
||||||
title: 'Error',
|
title: 'Error',
|
||||||
@ -102,7 +102,16 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.debug('Submitting service...', this.service, this.creating);
|
console.debug('Submitting service...', this.service, this.creating);
|
||||||
this.$http.post('service/', this.service)
|
|
||||||
|
let url;
|
||||||
|
|
||||||
|
if (this.creating) {
|
||||||
|
url = 'service/';
|
||||||
|
} else {
|
||||||
|
url = 'service/' + this.initialService.port
|
||||||
|
}
|
||||||
|
|
||||||
|
this.$http.post(url, this.service)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
console.info('Done editing/creating service', response.data);
|
console.info('Done editing/creating service', response.data);
|
||||||
this.$emit('service-update-needed');
|
this.$emit('service-update-needed');
|
||||||
@ -133,7 +142,3 @@
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
|
|
||||||
</style>
|
|
||||||
|
|||||||
@ -62,7 +62,3 @@
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
|
|
||||||
</style>
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user