(String[] args)
| 51 | } |
| 52 | |
| 53 | public static void main(String[] args) throws IOException, Client.ConfigError, Client.CredsUnspecifiedError { |
| 54 | if (args.length >= 1) |
| 55 | { |
| 56 | // load config file |
| 57 | String config = readFile(args[0]); |
| 58 | |
| 59 | // get creds |
| 60 | String username = ""; |
| 61 | String password = ""; |
| 62 | if (args.length >= 3) |
| 63 | { |
| 64 | username = args[1]; |
| 65 | password = args[2]; |
| 66 | } |
| 67 | |
| 68 | // instantiate client object |
| 69 | final Client client = new Client(config, username, password); |
| 70 | |
| 71 | // catch signals |
| 72 | final Thread mainThread = Thread.currentThread(); |
| 73 | Runtime.getRuntime().addShutdownHook(new Thread() { |
| 74 | public void run() { |
| 75 | client.stop(); |
| 76 | try { |
| 77 | mainThread.join(); |
| 78 | } |
| 79 | catch (InterruptedException e) { |
| 80 | } |
| 81 | } |
| 82 | }); |
| 83 | |
| 84 | // execute client session |
| 85 | client.connect(); |
| 86 | |
| 87 | // show stats before exit |
| 88 | client.show_stats(); |
| 89 | } |
| 90 | else |
| 91 | { |
| 92 | System.err.println("OpenVPN Java client"); |
| 93 | System.err.println("Usage: java Client <client.ovpn> [username] [password]"); |
| 94 | System.exit(2); |
| 95 | } |
| 96 | } |
| 97 | } |
nothing calls this directly
no test coverage detected