Browse Source

Use hex numbers

Bob Mottram 8 years ago
parent
commit
61ef4a3c35
1 changed files with 4 additions and 3 deletions
  1. 4
    3
      src/freedombone-utils-firewall

+ 4
- 3
src/freedombone-utils-firewall View File

@@ -346,10 +346,11 @@ function domain_to_hex_string {
346 346
     segment=$(echo "$domain" | awk -F '.' "{print \$$ctr}")
347 347
     while [ ${#segment} -gt 0 ]
348 348
     do
349
-        if [ ${#segment} -lt 10 ]; then
350
-            echo -n "|0${#segment}|$segment"
349
+        hexnum=$(echo "obase=16; $segment" | bc)
350
+        if [ ${hexnum} -lt 2 ]; then
351
+            echo -n "|0${hexnum}|$segment"
351 352
         else
352
-            echo -n "|${#segment}|$segment"
353
+            echo -n "|$hexnum|$segment"
353 354
         fi
354 355
         ctr=$((ctr + 1))
355 356
         segment=$(echo "$domain" | awk -F '.' "{print \$$ctr}")