--remote: split port and protocol into separate arguments (bug 712720)
authorTJ <gnome@iam.tj>
Wed, 20 Nov 2013 00:22:18 +0000 (00:22 +0000)
committerTJ <gnome@iam.tj>
Wed, 20 Nov 2013 00:22:18 +0000 (00:22 +0000)
src/nm-openvpn-service.c

index 3975643..257e5fd 100644 (file)
@@ -905,11 +905,28 @@ nm_openvpn_start_openvpn_binary (NMOpenvpnPlugin *plugin,
 
        tmp = nm_setting_vpn_get_data_item (s_vpn, NM_OPENVPN_KEY_REMOTE);
        if (tmp && strlen (tmp)) {
-               char *tok;
+               char *tok, *tok2, *p;
                while ((tok = strsep((char**)&tmp, ",")) != NULL) {
                        if (strlen(tok)) {
                                add_openvpn_arg (args, "--remote");
                                add_openvpn_arg (args, tok);
+                               tmp2 = strdup(tok);
+                               while ((tok2 = strsep((char **)&tmp2, " ")) != NULL) {
+                                       gboolean port = FALSE;
+                                       if (strlen(tok2)) {
+                                               for (p=tok2, port=TRUE; *p; p++) {
+                                                       if (!isdigit(*p)) {
+                                                               port = FALSE;
+                                                               break;
+                                                       }
+                                               }
+                                               if (port)
+                                                       add_openvpn_arg (args, tok2);
+                                               else if ((strncmp("udp", tok2, 3) == 0 || strncmp("tcp", tok2, 3) == 0))
+                                                       add_openvpn_arg (args, tok2);
+                                       }
+                               }
+                               free((void *)tmp2);
                        }
                }
        }