summaryrefslogtreecommitdiff
path: root/url_to_id
blob: 69cc0fc97fdfd8451a64b6289bb889c78652430c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/sh

## get a selector in gph format:
##
##   [TYPE|SEL|HOST|PORT]
##
## and print on output the corresponding selectorid:
##
##   TYPE|SEL|HOST|PORT|SHA256
## 
## which is understood by `burrow`

gph_to_id(){
	gph="$( echo $1| sed 's/\[//g;s/\]//g')"
	OLDIFS=$IFS
	#IFS=$'\t\n'
	IFS="|"
	sid=$(echo "${gph}" | sha256sum | cut -d " " -f 1)
	echo "${gph}|${sid}"
	IFS="$OLDIFS"
}

gph_to_id "$1"