Parcourir la source

Hidden service path

Bob Mottram il y a 8 ans
Parent
révision
304963caca
2 fichiers modifiés avec 16 ajouts et 24 suppressions
  1. 1
    11
      src/freedombone-app-rss
  2. 15
    13
      src/freedombone-utils-onion

+ 1
- 11
src/freedombone-app-rss Voir le fichier

@@ -323,20 +323,10 @@ function install_rss_main {
323 323
     rss_create_database
324 324
 
325 325
     RSS_READER_ONION_HOSTNAME=$(add_onion_service rss 80 ${RSS_READER_ONION_PORT})
326
-    if [[ "$RSS_READER_ONION_HOSTNAME" != *".onion" ]]; then
327
-        echo $'Unable to create onion address for rss reader site'
328
-        echo "$RSS_READER_ONION_HOSTNAME"
329
-        exit 7352582
330
-    fi
331 326
 
332
-    sleep 4
327
+    sleep 2
333 328
 
334 329
     RSS_MOBILE_READER_ONION_HOSTNAME=$(add_onion_service rss_mobile 80 ${RSS_MOBILE_READER_ONION_PORT})
335
-    if [[ "$RSS_MOBILE_READER_ONION_HOSTNAME" != *".onion" ]]; then
336
-        echo $'Unable to create onion address for rss mobile site'
337
-        echo "$RSS_MOBILE_READER_ONION_HOSTNAME"
338
-        exit 7639532
339
-    fi
340 330
 
341 331
     echo 'server {' > /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME
342 332
     echo "  listen 127.0.0.1:$RSS_MOBILE_READER_ONION_PORT;" >> /etc/nginx/sites-available/$RSS_READER_DOMAIN_NAME

+ 15
- 13
src/freedombone-utils-onion Voir le fichier

@@ -34,6 +34,8 @@ TOR_MAX_TRAFFIC_PER_DAY_GB=3
34 34
 TOR_PACKAGE_UPSTREAM='http://deb.torproject.org/torproject.org'
35 35
 TOR_GPG_KEY='A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89'
36 36
 
37
+HIDDEN_SERVICE_PATH='/var/lib/tor/hidden_service_'
38
+
37 39
 function add_email_hostname {
38 40
     extra_email_hostname="$1"
39 41
     email_hostnames=$(cat /etc/exim4/update-exim4.conf.conf | grep "dc_other_hostnames" | awk -F "'" '{print $2}')
@@ -54,7 +56,7 @@ function wait_for_onion_service_base {
54 56
     onion_service_name="$1"
55 57
 
56 58
     sleep_ctr=0
57
-    while [ ! -f /var/lib/tor/hidden_service_${onion_service_name}/hostname ]; do
59
+    while [ ! -f ${HIDDEN_SERVICE_PATH}${onion_service_name}/hostname ]; do
58 60
         sleep 1
59 61
         sleep_ctr=$((sleep_ctr + 1))
60 62
         if [ $sleep_ctr -gt 10 ]; then
@@ -68,7 +70,7 @@ function wait_for_onion_service {
68 70
 
69 71
     wait_for_onion_service_base ${onion_service_name}
70 72
 
71
-    if [ ! -f /var/lib/tor/hidden_service_${onion_service_name}/hostname ]; then
73
+    if [ ! -f ${HIDDEN_SERVICE_PATH}${onion_service_name}/hostname ]; then
72 74
         # try a second time
73 75
         onion_update
74 76
         wait_for_onion_service_base ${onion_service_name}
@@ -95,13 +97,13 @@ function remove_onion_service {
95 97
             fi
96 98
         fi
97 99
     fi
98
-    if [ -d /var/lib/tor/hidden_service_${onion_service_name} ]; then
99
-        shred -zu /var/lib/tor/hidden_service_${onion_service_name}/*
100
-        rm -rf /var/lib/tor/hidden_service_${onion_service_name}
100
+    if [ -d ${HIDDEN_SERVICE_PATH}${onion_service_name} ]; then
101
+        shred -zu ${HIDDEN_SERVICE_PATH}${onion_service_name}/*
102
+        rm -rf ${HIDDEN_SERVICE_PATH}${onion_service_name}
101 103
     fi
102
-    if [ -d /var/lib/tor/hidden_service_${onion_service_name}_mobile ]; then
103
-        shred -zu /var/lib/tor/hidden_service_${onion_service_name}_mobile/*
104
-        rm -rf /var/lib/tor/hidden_service_${onion_service_name}_mobile
104
+    if [ -d ${HIDDEN_SERVICE_PATH}${onion_service_name}_mobile ]; then
105
+        shred -zu ${HIDDEN_SERVICE_PATH}${onion_service_name}_mobile/*
106
+        rm -rf ${HIDDEN_SERVICE_PATH}${onion_service_name}_mobile
105 107
     fi
106 108
     remove_completion_param "${onion_service_name} onion domain"
107 109
     onion_update
@@ -113,8 +115,8 @@ function add_onion_service {
113 115
     onion_service_port_to=$3
114 116
     onion_stealth_name="$4"
115 117
 
116
-    if [ -f /var/lib/tor/hidden_service_${onion_service_name}/hostname ]; then
117
-        echo $(cat /var/lib/tor/hidden_service_${onion_service_name}/hostname)
118
+    if [ -f ${HIDDEN_SERVICE_PATH}${onion_service_name}/hostname ]; then
119
+        echo $(cat ${HIDDEN_SERVICE_PATH}${onion_service_name}/hostname)
118 120
         return
119 121
     fi
120 122
 
@@ -123,7 +125,7 @@ function add_onion_service {
123 125
         exit 877367
124 126
     fi
125 127
     if ! grep -q "hidden_service_${onion_service_name}" /etc/tor/torrc; then
126
-        echo "HiddenServiceDir /var/lib/tor/hidden_service_${onion_service_name}/" >> /etc/tor/torrc
128
+        echo "HiddenServiceDir ${HIDDEN_SERVICE_PATH}${onion_service_name}/" >> /etc/tor/torrc
127 129
         echo "HiddenServicePort ${onion_service_port_from} 127.0.0.1:${onion_service_port_to}" >> /etc/tor/torrc
128 130
         if [ ${#onion_stealth_name} -gt 0 ]; then
129 131
             echo "HiddenServiceAuthorizeClient stealth ${onion_stealth_name}" >> /etc/tor/torrc
@@ -135,12 +137,12 @@ function add_onion_service {
135 137
     function_check wait_for_onion_service
136 138
     wait_for_onion_service ${onion_service_name}
137 139
 
138
-    if [ ! -f /var/lib/tor/hidden_service_${onion_service_name}/hostname ]; then
140
+    if [ ! -f ${HIDDEN_SERVICE_PATH}${onion_service_name}/hostname ]; then
139 141
         echo $"${onion_service_name} onion site hostname not found"
140 142
         exit 763624
141 143
     fi
142 144
 
143
-    onion_address=$(cat /var/lib/tor/hidden_service_${onion_service_name}/hostname)
145
+    onion_address=$(cat ${HIDDEN_SERVICE_PATH}${onion_service_name}/hostname)
144 146
 
145 147
     # Record the domain in the completion file
146 148
     set_completion_param "${onion_service_name} onion domain" "${onion_address}"