浏览代码

Ask for domain first and only complain if vpn files are not available

Bob Mottram 7 年前
父节点
当前提交
59c8de0089
共有 1 个文件被更改,包括 12 次插入17 次删除
  1. 12
    17
      src/freedombone-mesh-connect

+ 12
- 17
src/freedombone-mesh-connect 查看文件

@@ -157,20 +157,10 @@ function mesh_setup_vpn {
157 157
     fi
158 158
 }
159 159
 
160
-function connect_to_vpn {
161
-    dialog --title $"VPN Connect to another mesh network" \
162
-           --backtitle $"Freedombone Mesh" \
163
-           --defaultno \
164
-           --yesno $"\nHave you received the vpn.tar.gz file from the other mesh administrator, uncompressed it into the /home/fbone directory and also forwarded port $VPN_MESH_TLS_PORT from your internet router to this system?" 10 70
165
-    sel=$?
166
-    case $sel in
167
-        1) return;;
168
-        255) return;;
169
-    esac
170
-
160
+function connect_to_mesh {
171 161
     data=$(tempfile 2>/dev/null)
172 162
     trap "rm -f $data" 0 1 2 5 15
173
-    dialog --title $"VPN Connect to another mesh network" \
163
+    dialog --title $"Connect to another mesh network" \
174 164
            --backtitle $"Freedombone Mesh" \
175 165
            --inputbox $'Enter the IP address or domain name of the other mesh.' 10 60 2>$data
176 166
     sel=$?
@@ -180,15 +170,20 @@ function connect_to_vpn {
180 170
             if [ ${#ip_or_domain} -gt 1 ]; then
181 171
                 if [[ "$ip_or_domain" == *'.'* ]]; then
182 172
 
173
+                    connect_failed=
183 174
                     if [ ! -f ~/client.ovpn ]; then
184
-                        rm $data
185
-                        exit 1
175
+                        connect_failed=1
186 176
                     fi
187 177
                     if [ ! -f ~/stunnel.pem ]; then
188
-                        rm $data
189
-                        exit 1
178
+                        connect_failed=1
190 179
                     fi
191 180
                     if [ ! -f ~/stunnel.p12 ]; then
181
+                        connect_failed=1
182
+                    fi
183
+
184
+                    if [ $connect_failed ]; then
185
+                        dialog --title $"Connect to another mesh network" \
186
+                               --msgbox $"\nObtain the vpn.tar.gz file from the other mesh administrator, uncompress it into the /home/fbone directory and also forwarded port $VPN_MESH_TLS_PORT from your internet router to this system." 10 50
192 187
                         rm $data
193 188
                         exit 1
194 189
                     fi
@@ -221,7 +216,7 @@ case $sel in
221 216
 esac
222 217
 case $(cat $data) in
223 218
     1) rm $data
224
-       connect_to_vpn;;
219
+       connect_to_mesh;;
225 220
     2) rm $data
226 221
        mesh_setup_vpn;;
227 222
 esac