1
1
#!/usr /bin /ucode
2
2
3
- // TODO:
4
- // - [x] procd service
5
- // - [x] config via uci
6
- // - [x] load keys from file
7
- // - [x] bug: high cpu usage
8
- // - [x] generate private keys
9
- // - [x] don't abort for common failures
10
- // - [x] test olsrd and babel
11
- // - [x] test multiple ifaces
12
- // - [x] bug: possible multiple use of servers
13
- // - [x] better logging
14
- // - [x] handle dhcp renewals
15
- // - [ ] disable strom temporarily
16
- // - [ ] nftables rules for mss clamping
17
- // - [ ] retry dhcp on boot
18
- // - [ ] less logging
19
- // - [x] implement insecure_cert option
20
- // - [x] implement disabled option
21
- // - [ ] warn if ipv6 RA is disabled
22
-
23
3
const uloop = require ("uloop" );
24
4
const rtnl = require ("rtnl" );
25
5
const wg = require ("wireguard" );
@@ -28,7 +8,7 @@ const math = require("math");
28
8
const uci = require ("uci" );
29
9
30
10
const UPLINK_NETNS_IFNAME = 'ts_uplink' ;
31
- const WG_LOGIN = { "username" : "wginstaller" , "password" : "wginstaller" };
11
+ const UBUS_LOGIN = { "username" : "wginstaller" , "password" : "wginstaller" };
32
12
33
13
let cfg = {};
34
14
@@ -51,6 +31,7 @@ function load_config(name) {
51
31
52
32
ctx .foreach (name , "wg-server" , function (c ) {
53
33
cfg .wireguard_servers ["" +c .name ] = {
34
+ "name" : "" +c .name ,
54
35
"url" : "" +c .url ,
55
36
"insecure_cert" : int (c .insecure_cert ) != 0 ,
56
37
"disabled" : int (c .disabled ) != 0 ,
@@ -59,6 +40,7 @@ function load_config(name) {
59
40
60
41
ctx .foreach (name , "wg-interface" , function (c ) {
61
42
cfg .wireguard_interfaces ["" +c .ifname ] = {
43
+ "ifname" : "" +c .ifname ,
62
44
"ipv6" : "" +c .ipv6 ,
63
45
"ipv4" : "" +c .ipv4 ,
64
46
"mtu" : int (c .mtu ),
@@ -287,7 +269,7 @@ function wg_replace_endpoint(ifname, cfg, next) {
287
269
"00000000000000000000000000000000" ,
288
270
"session" ,
289
271
"login" ,
290
- WG_LOGIN ]};
272
+ UBUS_LOGIN ]};
291
273
let cmd = sprintf ("ip netns exec %s uclient-fetch -q -O - %s --post-data='%s' %s" , cfg .uplink_netns , certopt , "%s" , srvcfg .url );
292
274
let p = fs .popen (sprintf (cmd , msg ), "r" );
293
275
let out = p .read ("all" );
0 commit comments