summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKatolaZ <katolaz@freaknet.org>2018-07-31 21:55:50 +0100
committerKatolaZ <katolaz@freaknet.org>2018-07-31 21:55:50 +0100
commit06eee070651f69769fd6f8feb57950515c4a1150 (patch)
tree77897ccf3fd1174039c3c419f264db785f06c2fe
parent181800b700d89f79b57ba634a19a3fa62ad6d9a5 (diff)
added url_to_id
-rwxr-xr-xurl_to_id23
1 files changed, 23 insertions, 0 deletions
diff --git a/url_to_id b/url_to_id
new file mode 100755
index 0000000..69cc0fc
--- /dev/null
+++ b/url_to_id
@@ -0,0 +1,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"