Commit 5d99de65 authored by Janis Streib's avatar Janis Streib 🦉
Browse files

ADD: ipaddr search (closes #167)

parent 1297a617
Pipeline #117394 passed with stages
in 6 minutes and 41 seconds
......@@ -8510,6 +8510,12 @@
"execa": "^1.0.0",
"ip-regex": "^2.1.0"
}
},
"ipaddr.js": {
"version": "1.9.1",
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
"integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==",
"dev": true
}
}
},
......@@ -8540,10 +8546,9 @@
"dev": true
},
"ipaddr.js": {
"version": "1.9.1",
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
"integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==",
"dev": true
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-2.0.0.tgz",
"integrity": "sha512-S54H9mIj0rbxRIyrDMEuuER86LdlgUg9FSeZ8duQb6CUG2iRrA36MYVQBSprTF/ZeAwvyQ5mDGuNvIPM0BIl3w=="
},
"is-absolute-url": {
"version": "2.1.0",
......@@ -13183,6 +13188,14 @@
"requires": {
"forwarded": "~0.1.2",
"ipaddr.js": "1.9.1"
},
"dependencies": {
"ipaddr.js": {
"version": "1.9.1",
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
"integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==",
"dev": true
}
}
},
"prr": {
......
......@@ -20,6 +20,7 @@
"bootstrap-vue": "^2.18.1",
"http-proxy-middleware": "^0.19.2",
"i": "^0.3.6",
"ipaddr.js": "^2.0.0",
"jquery": "^3.5.1",
"leaflet": "^1.7.1",
"node-sass": "^4.14.1",
......
......@@ -50,5 +50,33 @@ export default {
}
]
return TransactionService.execute(config, ta)
},
searchRRByIP(config, ip, own) {
const ta = [
{
name: 'dns.record.list',
old: apiutil.denullify_dict({
target_ipaddr_cidr: ip,
is_own: own,
fetch_limit: 20,
sorting_params_list: ['target_ipaddr']
})
}
]
return TransactionService.execute(config, ta)
},
searchBCDSubnet(config, term, own) {
const ta = [
{
name: 'nd.ip_subnet.list',
old: apiutil.denullify_dict({
cidr: term,
is_own: own,
fetch_limit: 20,
cidr_operator: 'smallest_cts'
})
}
]
return TransactionService.execute(config, ta)
}
}
......@@ -53,7 +53,8 @@
<hr/>
Enter oder Such-Button klicken, um eine neue Suche auszulösen<br>
<code>s/&lt;regex&gt;</code> für RegEx-Suche<br>
<code>&lt;systemname&gt;:&lt;suche&gt;</code> für globale Suche im System (z.B. <code>dnsvs:s/^kit.edu</code>)
<code>&lt;systemname&gt;:&lt;suche&gt;</code> für globale Suche im System (z.B.
<code>dnsvs:s/^kit.edu</code>)
</template>
</div>
</div>
......@@ -70,6 +71,7 @@
<script>
import SearchService from '@/api-services/search.service'
import ipaddress from 'ipaddr.js'
export default {
name: 'GlobalSearch',
......@@ -176,6 +178,30 @@ export default {
}
}
break
case 'nd.ip_subnet':
if (isRegex) {
suggestions.push({
name:
['',
item.term.cidr
.substring(index, index + search.length),
''
],
type: item.type,
url: '/dnsvs/bcds/' + item.term.bcd
})
} else {
suggestions.push({
name:
['',
item.term.cidr + ' zur BCD ' + item.term.bcd,
''
],
type: item.type,
url: '/dnsvs/bcds/' + item.term.bcd
})
}
break
case 'nd.bcd':
if (isRegex) {
suggestions.push({
......@@ -255,14 +281,14 @@ export default {
}
return this.search_input
},
dispatch_search(fun, type) {
dispatch_search(fun, type, index = 0) {
const self = this
fun.then((response) => {
if (this.searching === 0) {
window.console.debug('Dropping result.')
return
}
response.data[0].forEach((item) => {
response.data[index].forEach((item) => {
self.search_res.push({term: item, type: type})
})
self.searching--
......@@ -286,13 +312,24 @@ export default {
this.search_res = []
this.descriminator = this.getSearchDiscriminator()
const term = this.cutDescriminator()
const termIsIP = ipaddress.isValid(term.split('/')[0])
if (this.descriminator == null) { // Nur is_own, ohne regex
this.dispatch_search(SearchService.searchBCDRegex(this.$store.state.netdb_axios_config, term, true), 'nd.bcd')
this.dispatch_search(SearchService.searchRecordRegex(this.$store.state.netdb_axios_config, term, true), 'dns.record')
if (termIsIP) {
this.dispatch_search(SearchService.searchRRByIP(this.$store.state.netdb_axios_config, term, true), 'dns.record')
this.dispatch_search(SearchService.searchBCDSubnet(this.$store.state.netdb_axios_config, term, true), 'nd.ip_subnet')
} else {
this.dispatch_search(SearchService.searchBCDRegex(this.$store.state.netdb_axios_config, term, true), 'nd.bcd')
this.dispatch_search(SearchService.searchRecordRegex(this.$store.state.netdb_axios_config, term, true), 'dns.record')
}
} else if (this.descriminator === 'dnsvs') {
this.dispatch_search(SearchService.searchBCDRegex(this.$store.state.netdb_axios_config, term, null), 'nd.bcd')
this.dispatch_search(SearchService.searchRecordRegex(this.$store.state.netdb_axios_config, term, null), 'dns.record')
this.dispatch_search(SearchService.searchRRDataRegex(this.$store.state.netdb_axios_config, term, null), 'dns.record')
if (termIsIP) {
this.dispatch_search(SearchService.searchRRByIP(this.$store.state.netdb_axios_config, term, null), 'dns.record')
this.dispatch_search(SearchService.searchBCDSubnet(this.$store.state.netdb_axios_config, term, null), 'nd.ip_subnet')
} else {
this.dispatch_search(SearchService.searchBCDRegex(this.$store.state.netdb_axios_config, term, null), 'nd.bcd')
this.dispatch_search(SearchService.searchRecordRegex(this.$store.state.netdb_axios_config, term, null), 'dns.record')
this.dispatch_search(SearchService.searchRRDataRegex(this.$store.state.netdb_axios_config, term, null), 'dns.record')
}
}
this.descriminator = null
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment