MCPcopy Create free account
hub / github.com/OpenVPN/openvpn3 / main

Method main

javacli/Main.java:53–96  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

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}

Callers

nothing calls this directly

Calls 3

readFileMethod · 0.95
connectMethod · 0.95
show_statsMethod · 0.95

Tested by

no test coverage detected