blob: 7862e9e1cc5dfaab8185a0c70214abe16cbe9340 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
/* SPDX-License-Identifier: MIT */
/*
* Copyright (C) 2018 Wireguard LLC
*/
#include "client.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
const char *PROG_NAME;
static void show_usage()
{
fprintf(stderr, "Usage: %s <interface>\n\n", PROG_NAME);
}
int main(int argc, char *argv[])
{
const char *iface;
int sock;
PROG_NAME = argv[0];
if (argc == 1) {
show_usage();
return EXIT_FAILURE;
}
iface = argv[1];
if (!is_server_in_allowed_ips(iface)) {
fprintf(stderr, "server is not in allowed IPs for tunnel %s\n",
iface);
return EXIT_FAILURE;
}
if ((sock = connect_to_server(argv[1])) < 0) {
fprintf(stderr, "error connecting to server: %s\n",
strerror(-sock));
return EXIT_FAILURE;
}
if ((sock = close_connection(sock)) < 0) {
fprintf(stderr, "error closing socket: %s\n", strerror(-sock));
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
|