hugsy / sstoper

SSTP VPN client for Linux
Other
18 stars 7 forks source link

Status information #3

Open lnxbil opened 9 years ago

lnxbil commented 9 years ago

It would be great to have information about a daemonized session in a file similar to openvpn. This file should include at least the PID of the process and it would also be nice if there could be the ppppd information aswell.

Or is there already an interface to a daemonized session that I'm not aware of?

lnxbil commented 9 years ago

One possible step in the right direction could be this patch:

diff --git a/libsstp.c b/libsstp.c
index 9aac3b0..bbe56c1 100644
--- a/libsstp.c
+++ b/libsstp.c
@@ -1393,6 +1393,12 @@ int sstp_fork()
       pppd_args[i++] = cfg->domain;
     }

+  if (cfg->ifname != NULL)
+    {
+      pppd_args[i++] = "ifname";
+      pppd_args[i++] = cfg->ifname;
+    }
+
   pppd_args[i++] = NULL;

   memset(&pty, 0, sizeof(struct termios));
diff --git a/main.c b/main.c
index 1808f37..b013e8b 100644
--- a/main.c
+++ b/main.c
@@ -197,6 +197,7 @@ static void usage(char* name, int retcode)
          "\t-n, --proxy-port=PROXYPORT\t\t\tSpecify proxy port\n"
          "\t-v, --verbose\t\t\t\t\tIncrement verbose mode\n"
          "\t-D, --daemon\t\t\t\t\tStart as daemon\n"
+         "\t-i, --ifname=ppp_net1\t\t\t\tUse this name as interface name\n"
          "\t-h, --help\t\t\t\t\tShow this menu\n"
          "\n\n",
          PROGNAME, VERSION,
@@ -300,6 +301,7 @@ static void parse_options (sstp_config* cfg, int argc, char** argv)
     { "proxy", 1, 0, 'm' },
     { "proxy-port", 1, 0, 'n' },
     { "daemon", 0, 0, 'D' },
+    { "ifname", 1, 0, 'i' },
     { 0, 0, 0, 0 }
   };

@@ -309,7 +311,7 @@ static void parse_options (sstp_config* cfg, int argc, char** argv)
       curopt_idx = 0;

       curopt = getopt_long (argc, argv,
-                           "hvs:p:c:U:P:x:l:d:m:n:D",
+                           "hvs:p:c:U:P:x:l:d:m:n:Di:",
                            long_opts, &curopt_idx);

       if (curopt == -1) break;
@@ -328,6 +330,7 @@ static void parse_options (sstp_config* cfg, int argc, char** argv)
        case 'D': cfg->daemon = 1; break;
        case 'm': cfg->proxy = optarg; break;
        case 'n': cfg->proxy_port = optarg; break;
+       case 'i': cfg->ifname = optarg; break;
        case 'h':
          usage (argv[0], EXIT_SUCCESS);
        case '?':
diff --git a/main.h b/main.h
index b857361..5a1c717 100644
--- a/main.h
+++ b/main.h
@@ -70,6 +70,7 @@ typedef struct
   char* domain;
   char* proxy;
   char* proxy_port;
+  char* ifname;
 } sstp_config;

 #ifdef HAS_GNUTLS

This was the only option I found which could lead to a simple way to determine connection data.

hugsy commented 9 years ago

That looks ok. Can you submit your changes in a Pull Request ? It makes it easy to add and track changes.

lnxbil commented 9 years ago

Yes, sure. I just wanted to discuss it before changing a lot and creating pull requests. I also created a Debian Jessie package, so that the software can be installed and maintained easily.

hugsy commented 9 years ago

That's awesome! Thanks man :+1: You're doing everything I was too lazy to do ;)